Commit 72053703 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix API repository specs

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 0082cfb1
...@@ -3,6 +3,8 @@ require 'mime/types' ...@@ -3,6 +3,8 @@ require 'mime/types'
describe API::API, api: true do describe API::API, api: true do
include ApiHelpers include ApiHelpers
include RepoHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
...@@ -29,6 +31,7 @@ describe API::API, api: true do ...@@ -29,6 +31,7 @@ describe API::API, api: true do
response.status.should == 201 response.status.should == 201
json_response['name'].should == 'v1.0.0' json_response['name'].should == 'v1.0.0'
end end
it 'should deny for user without push access' do it 'should deny for user without push access' do
post api("/projects/#{project.id}/repository/tags", user2), post api("/projects/#{project.id}/repository/tags", user2),
tag_name: 'v1.0.0', tag_name: 'v1.0.0',
...@@ -47,7 +50,7 @@ describe API::API, api: true do ...@@ -47,7 +50,7 @@ describe API::API, api: true do
response.status.should == 200 response.status.should == 200
json_response.should be_an Array 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['type'].should == 'tree'
json_response.first['mode'].should == '040000' json_response.first['mode'].should == '040000'
end end
...@@ -92,7 +95,7 @@ describe API::API, api: true do ...@@ -92,7 +95,7 @@ describe API::API, api: true do
describe "GET /projects/:id/repository/raw_blobs/:sha" do describe "GET /projects/:id/repository/raw_blobs/:sha" do
it "should get the raw file contents" 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 response.status.should == 200
end end
end end
...@@ -130,21 +133,21 @@ describe API::API, api: true do ...@@ -130,21 +133,21 @@ describe API::API, api: true do
describe 'GET /projects/:id/repository/compare' do describe 'GET /projects/:id/repository/compare' do
it "should compare branches" 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 response.status.should == 200
json_response['commits'].should be_present json_response['commits'].should be_present
json_response['diffs'].should be_present json_response['diffs'].should be_present
end end
it "should compare tags" do 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 response.status.should == 200
json_response['commits'].should be_present json_response['commits'].should be_present
json_response['diffs'].should be_present json_response['diffs'].should be_present
end end
it "should compare commits" do 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 response.status.should == 200
json_response['commits'].should be_empty json_response['commits'].should be_empty
json_response['diffs'].should be_empty json_response['diffs'].should be_empty
...@@ -152,7 +155,7 @@ describe API::API, api: true do ...@@ -152,7 +155,7 @@ describe API::API, api: true do
end end
it "should compare commits in reverse order" do 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 response.status.should == 200
json_response['commits'].should be_present json_response['commits'].should be_present
json_response['diffs'].should be_present json_response['diffs'].should be_present
...@@ -175,9 +178,9 @@ describe API::API, api: true do ...@@ -175,9 +178,9 @@ describe API::API, api: true do
contributor = json_response.first contributor = json_response.first
contributor['email'].should == 'dmitriy.zaporozhets@gmail.com' contributor['email'].should == 'dmitriy.zaporozhets@gmail.com'
contributor['name'].should == 'Dmitriy Zaporozhets' contributor['name'].should == 'Dmitriy Zaporozhets'
contributor['commits'].should == 185 contributor['commits'].should == 13
contributor['additions'].should == 66072 contributor['additions'].should == 4081
contributor['deletions'].should == 63013 contributor['deletions'].should == 29
end end
end end
end end
...@@ -13,6 +13,7 @@ module RepoHelpers ...@@ -13,6 +13,7 @@ module RepoHelpers
# #
def sample_blob def sample_blob
OpenStruct.new( OpenStruct.new(
oid: '5f53439ca4b009096571d3c8bc3d09d30e7431b3',
path: "files/js/commit.js.coffee", path: "files/js/commit.js.coffee",
data: <<eos data: <<eos
class Commit class Commit
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment