API: commits belong to project repository

This commit is contained in:
Nihad Abbasov 2012-09-21 04:34:07 -07:00
parent 131553627d
commit 4a072be2d7
8 changed files with 77 additions and 102 deletions

View file

@ -1,29 +0,0 @@
require 'spec_helper'
describe Gitlab::API do
include ApiHelpers
let(:user) { Factory :user }
let!(:project) { Factory :project, owner: user }
describe "GET /projects/:id/commits" do
context "authorized user" do
before { project.add_access(user, :read) }
it "should return project commits" do
get api("/projects/#{project.code}/commits", user)
response.status.should == 200
json_response.should be_an Array
json_response.first['id'].should == project.commit.id
end
end
context "unauthorized user" do
it "should return project commits" do
get api("/projects/#{project.code}/commits")
response.status.should == 401
end
end
end
end

View file

@ -199,6 +199,27 @@ describe Gitlab::API do
end
end
describe "GET /projects/:id/repository/commits" do
context "authorized user" do
before { project.add_access(user2, :read) }
it "should return project commits" do
get api("/projects/#{project.code}/repository/commits", user)
response.status.should == 200
json_response.should be_an Array
json_response.first['id'].should == project.commit.id
end
end
context "unauthorized user" do
it "should not return project commits" do
get api("/projects/#{project.code}/repository/commits")
response.status.should == 401
end
end
end
describe "GET /projects/:id/snippets/:snippet_id" do
it "should return a project snippet" do
get api("/projects/#{project.code}/snippets/#{snippet.id}", user)