summaryrefslogtreecommitdiff
path: root/spec/requests/api/repositories_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/repositories_spec.rb')
-rw-r--r--spec/requests/api/repositories_spec.rb132
1 files changed, 66 insertions, 66 deletions
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index 5518d2df566..729970153d1 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -16,9 +16,9 @@ describe API::API, api: true do
describe "GET /projects/:id/repository/tags" do
it "should return an array of project tags" do
get api("/projects/#{project.id}/repository/tags", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['name'].should == project.repo.tags.sort_by(&:name).reverse.first.name
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['name']).to eq(project.repo.tags.sort_by(&:name).reverse.first.name)
end
end
@@ -29,8 +29,8 @@ describe API::API, api: true do
tag_name: 'v7.0.1',
ref: 'master'
- response.status.should == 201
- json_response['name'].should == 'v7.0.1'
+ expect(response.status).to eq(201)
+ expect(json_response['name']).to eq('v7.0.1')
end
end
@@ -46,9 +46,9 @@ describe API::API, api: true do
ref: 'master',
message: 'Release 7.1.0'
- response.status.should == 201
- json_response['name'].should == 'v7.1.0'
- json_response['message'].should == 'Release 7.1.0'
+ expect(response.status).to eq(201)
+ expect(json_response['name']).to eq('v7.1.0')
+ expect(json_response['message']).to eq('Release 7.1.0')
end
end
@@ -56,35 +56,35 @@ describe API::API, api: true do
post api("/projects/#{project.id}/repository/tags", user2),
tag_name: 'v1.9.0',
ref: '621491c677087aa243f165eab467bfdfbee00be1'
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it 'should return 400 if tag name is invalid' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v 1.0.0',
ref: 'master'
- response.status.should == 400
- json_response['message'].should == 'Tag name invalid'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('Tag name invalid')
end
it 'should return 400 if tag already exists' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v8.0.0',
ref: 'master'
- response.status.should == 201
+ expect(response.status).to eq(201)
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v8.0.0',
ref: 'master'
- response.status.should == 400
- json_response['message'].should == 'Tag already exists'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('Tag already exists')
end
it 'should return 400 if ref name is invalid' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'mytag',
ref: 'foo'
- response.status.should == 400
- json_response['message'].should == 'Invalid reference name'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('Invalid reference name')
end
end
@@ -94,19 +94,19 @@ describe API::API, api: true do
it "should return project commits" do
get api("/projects/#{project.id}/repository/tree", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response.should be_an Array
- json_response.first['name'].should == 'encoding'
- json_response.first['type'].should == 'tree'
- json_response.first['mode'].should == '040000'
+ expect(json_response).to be_an Array
+ expect(json_response.first['name']).to eq('encoding')
+ expect(json_response.first['type']).to eq('tree')
+ expect(json_response.first['mode']).to eq('040000')
end
it 'should return a 404 for unknown ref' do
get api("/projects/#{project.id}/repository/tree?ref_name=foo", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
- json_response.should be_an Object
+ expect(json_response).to be_an Object
json_response['message'] == '404 Tree Not Found'
end
end
@@ -114,7 +114,7 @@ describe API::API, api: true do
context "unauthorized user" do
it "should not return project commits" do
get api("/projects/#{project.id}/repository/tree")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
end
@@ -122,43 +122,43 @@ describe API::API, api: true do
describe "GET /projects/:id/repository/blobs/:sha" do
it "should get the raw file contents" do
get api("/projects/#{project.id}/repository/blobs/master?filepath=README.md", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return 404 for invalid branch_name" do
get api("/projects/#{project.id}/repository/blobs/invalid_branch_name?filepath=README.md", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should return 404 for invalid file" do
get api("/projects/#{project.id}/repository/blobs/master?filepath=README.invalid", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should return a 400 error if filepath is missing" do
get api("/projects/#{project.id}/repository/blobs/master", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
describe "GET /projects/:id/repository/commits/:sha/blob" do
it "should get the raw file contents" do
get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.md", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
end
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/#{sample_blob.oid}", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it 'should return a 404 for unknown blob' do
get api("/projects/#{project.id}/repository/raw_blobs/123456", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
- json_response.should be_an Object
+ expect(json_response).to be_an Object
json_response['message'] == '404 Blob Not Found'
end
end
@@ -167,83 +167,83 @@ describe API::API, api: true do
it "should get the archive" do
get api("/projects/#{project.id}/repository/archive", user)
repo_name = project.repository.name.gsub("\.git", "")
- response.status.should == 200
- response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.tar.gz\"/
- response.content_type.should == MIME::Types.type_for('file.tar.gz').first.content_type
+ expect(response.status).to eq(200)
+ expect(response.headers['Content-Disposition']).to match(/filename\=\"#{repo_name}\-[^\.]+\.tar.gz\"/)
+ expect(response.content_type).to eq(MIME::Types.type_for('file.tar.gz').first.content_type)
end
it "should get the archive.zip" do
get api("/projects/#{project.id}/repository/archive.zip", user)
repo_name = project.repository.name.gsub("\.git", "")
- response.status.should == 200
- response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.zip\"/
- response.content_type.should == MIME::Types.type_for('file.zip').first.content_type
+ expect(response.status).to eq(200)
+ expect(response.headers['Content-Disposition']).to match(/filename\=\"#{repo_name}\-[^\.]+\.zip\"/)
+ expect(response.content_type).to eq(MIME::Types.type_for('file.zip').first.content_type)
end
it "should get the archive.tar.bz2" do
get api("/projects/#{project.id}/repository/archive.tar.bz2", user)
repo_name = project.repository.name.gsub("\.git", "")
- response.status.should == 200
- response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.tar.bz2\"/
- response.content_type.should == MIME::Types.type_for('file.tar.bz2').first.content_type
+ expect(response.status).to eq(200)
+ expect(response.headers['Content-Disposition']).to match(/filename\=\"#{repo_name}\-[^\.]+\.tar.bz2\"/)
+ expect(response.content_type).to eq(MIME::Types.type_for('file.tar.bz2').first.content_type)
end
it "should return 404 for invalid sha" do
get api("/projects/#{project.id}/repository/archive/?sha=xxx", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
describe 'GET /projects/:id/repository/compare' do
it "should compare branches" do
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
+ expect(response.status).to eq(200)
+ expect(json_response['commits']).to be_present
+ expect(json_response['diffs']).to be_present
end
it "should compare tags" do
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
+ expect(response.status).to eq(200)
+ expect(json_response['commits']).to be_present
+ expect(json_response['diffs']).to be_present
end
it "should compare commits" do
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
- json_response['compare_same_ref'].should be_false
+ expect(response.status).to eq(200)
+ expect(json_response['commits']).to be_empty
+ expect(json_response['diffs']).to be_empty
+ expect(json_response['compare_same_ref']).to be_falsey
end
it "should compare commits in reverse order" do
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
+ expect(response.status).to eq(200)
+ expect(json_response['commits']).to be_present
+ expect(json_response['diffs']).to be_present
end
it "should compare same refs" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'master'
- response.status.should == 200
- json_response['commits'].should be_empty
- json_response['diffs'].should be_empty
- json_response['compare_same_ref'].should be_true
+ expect(response.status).to eq(200)
+ expect(json_response['commits']).to be_empty
+ expect(json_response['diffs']).to be_empty
+ expect(json_response['compare_same_ref']).to be_truthy
end
end
describe 'GET /projects/:id/repository/contributors' do
it 'should return valid data' do
get api("/projects/#{project.id}/repository/contributors", user)
- response.status.should == 200
- json_response.should be_an Array
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
contributor = json_response.first
- contributor['email'].should == 'dmitriy.zaporozhets@gmail.com'
- contributor['name'].should == 'Dmitriy Zaporozhets'
- contributor['commits'].should == 13
- contributor['additions'].should == 0
- contributor['deletions'].should == 0
+ expect(contributor['email']).to eq('dmitriy.zaporozhets@gmail.com')
+ expect(contributor['name']).to eq('Dmitriy Zaporozhets')
+ expect(contributor['commits']).to eq(13)
+ expect(contributor['additions']).to eq(0)
+ expect(contributor['deletions']).to eq(0)
end
end
end