summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-08-01 15:41:02 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-08-01 15:41:02 +0300
commit72053703e816c848a54b089ecb318e66291b8b8c (patch)
treec12f84f40d2cd58e9f4abbc11a0cf0aee1632baa
parent0082cfb14641ca7fa0cdf3aee641694c26c0ae26 (diff)
downloadgitlab-ce-72053703e816c848a54b089ecb318e66291b8b8c.tar.gz
Fix API repository specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--spec/requests/api/repositories_spec.rb21
-rw-r--r--spec/support/repo_helpers.rb1
2 files changed, 13 insertions, 9 deletions
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index a02231a5bba..f8603e11a04 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -3,6 +3,8 @@ require 'mime/types'
describe API::API, api: true do
include ApiHelpers
+ include RepoHelpers
+
let(:user) { create(:user) }
let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) }
@@ -29,6 +31,7 @@ describe API::API, api: true do
response.status.should == 201
json_response['name'].should == 'v1.0.0'
end
+
it 'should deny for user without push access' do
post api("/projects/#{project.id}/repository/tags", user2),
tag_name: 'v1.0.0',
@@ -47,7 +50,7 @@ describe API::API, api: true do
response.status.should == 200
json_response.should be_an Array
- json_response.first['name'].should == 'app'
+ json_response.first['name'].should == 'encoding'
json_response.first['type'].should == 'tree'
json_response.first['mode'].should == '040000'
end
@@ -92,7 +95,7 @@ describe API::API, api: true do
describe "GET /projects/:id/repository/raw_blobs/:sha" do
it "should get the raw file contents" do
- get api("/projects/#{project.id}/repository/raw_blobs/d1aff2896d99d7acc4d9780fbb716b113c45ecf7", user)
+ get api("/projects/#{project.id}/repository/raw_blobs/#{sample_blob.oid}", user)
response.status.should == 200
end
end
@@ -130,21 +133,21 @@ describe API::API, api: true do
describe 'GET /projects/:id/repository/compare' do
it "should compare branches" do
- get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'simple_merge_request'
+ get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'feature'
response.status.should == 200
json_response['commits'].should be_present
json_response['diffs'].should be_present
end
it "should compare tags" do
- get api("/projects/#{project.id}/repository/compare", user), from: 'v1.0.1', to: 'v1.0.2'
+ get api("/projects/#{project.id}/repository/compare", user), from: 'v1.0.0', to: 'v1.1.0'
response.status.should == 200
json_response['commits'].should be_present
json_response['diffs'].should be_present
end
it "should compare commits" do
- get api("/projects/#{project.id}/repository/compare", user), from: 'b1e6a9dbf1c85', to: '1e689bfba395'
+ get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.id, to: sample_commit.parent_id
response.status.should == 200
json_response['commits'].should be_empty
json_response['diffs'].should be_empty
@@ -152,7 +155,7 @@ describe API::API, api: true do
end
it "should compare commits in reverse order" do
- get api("/projects/#{project.id}/repository/compare", user), from: '1e689bfba395', to: 'b1e6a9dbf1c85'
+ get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.parent_id, to: sample_commit.id
response.status.should == 200
json_response['commits'].should be_present
json_response['diffs'].should be_present
@@ -175,9 +178,9 @@ describe API::API, api: true do
contributor = json_response.first
contributor['email'].should == 'dmitriy.zaporozhets@gmail.com'
contributor['name'].should == 'Dmitriy Zaporozhets'
- contributor['commits'].should == 185
- contributor['additions'].should == 66072
- contributor['deletions'].should == 63013
+ contributor['commits'].should == 13
+ contributor['additions'].should == 4081
+ contributor['deletions'].should == 29
end
end
end
diff --git a/spec/support/repo_helpers.rb b/spec/support/repo_helpers.rb
index 8c4c96ea851..f19c8ebf844 100644
--- a/spec/support/repo_helpers.rb
+++ b/spec/support/repo_helpers.rb
@@ -13,6 +13,7 @@ module RepoHelpers
#
def sample_blob
OpenStruct.new(
+ oid: '5f53439ca4b009096571d3c8bc3d09d30e7431b3',
path: "files/js/commit.js.coffee",
data: <<eos
class Commit