summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/api_helpers_spec.rb30
-rw-r--r--spec/requests/api/award_emoji_spec.rb6
-rw-r--r--spec/requests/api/branches_spec.rb38
-rw-r--r--spec/requests/api/builds_spec.rb38
-rw-r--r--spec/requests/api/commit_statuses_spec.rb10
-rw-r--r--spec/requests/api/commits_spec.rb42
-rw-r--r--spec/requests/api/files_spec.rb22
-rw-r--r--spec/requests/api/fork_spec.rb12
-rw-r--r--spec/requests/api/group_members_spec.rb34
-rw-r--r--spec/requests/api/groups_spec.rb56
-rw-r--r--spec/requests/api/issues_spec.rb104
-rw-r--r--spec/requests/api/keys_spec.rb6
-rw-r--r--spec/requests/api/labels_spec.rb60
-rw-r--r--spec/requests/api/merge_requests_spec.rb88
-rw-r--r--spec/requests/api/milestones_spec.rb30
-rw-r--r--spec/requests/api/namespaces_spec.rb10
-rw-r--r--spec/requests/api/notes_spec.rb56
-rw-r--r--spec/requests/api/project_hooks_spec.rb36
-rw-r--r--spec/requests/api/project_members_spec.rb34
-rw-r--r--spec/requests/api/project_snippets_spec.rb2
-rw-r--r--spec/requests/api/projects_spec.rb176
-rw-r--r--spec/requests/api/repositories_spec.rb40
-rw-r--r--spec/requests/api/runners_spec.rb98
-rw-r--r--spec/requests/api/services_spec.rb22
-rw-r--r--spec/requests/api/session_spec.rb12
-rw-r--r--spec/requests/api/settings_spec.rb4
-rw-r--r--spec/requests/api/system_hooks_spec.rb20
-rw-r--r--spec/requests/api/tags_spec.rb34
-rw-r--r--spec/requests/api/triggers_spec.rb44
-rw-r--r--spec/requests/api/users_spec.rb216
-rw-r--r--spec/requests/api/variables_spec.rb38
-rw-r--r--spec/requests/ci/api/builds_spec.rb36
-rw-r--r--spec/requests/ci/api/triggers_spec.rb16
33 files changed, 735 insertions, 735 deletions
diff --git a/spec/requests/api/api_helpers_spec.rb b/spec/requests/api/api_helpers_spec.rb
index 831889afb6c..c65510fadec 100644
--- a/spec/requests/api/api_helpers_spec.rb
+++ b/spec/requests/api/api_helpers_spec.rb
@@ -41,19 +41,19 @@ describe API::Helpers, api: true do
describe ".current_user" do
describe "when authenticating using a user's private token" do
- it "should return nil for an invalid token" do
+ it "returns nil for an invalid token" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = 'invalid token'
allow_any_instance_of(self.class).to receive(:doorkeeper_guard){ false }
expect(current_user).to be_nil
end
- it "should return nil for a user without access" do
+ it "returns nil for a user without access" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = user.private_token
allow_any_instance_of(Gitlab::UserAccess).to receive(:allowed?).and_return(false)
expect(current_user).to be_nil
end
- it "should leave user as is when sudo not specified" do
+ it "leaves user as is when sudo not specified" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = user.private_token
expect(current_user).to eq(user)
clear_env
@@ -65,19 +65,19 @@ describe API::Helpers, api: true do
describe "when authenticating using a user's personal access tokens" do
let(:personal_access_token) { create(:personal_access_token, user: user) }
- it "should return nil for an invalid token" do
+ it "returns nil for an invalid token" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = 'invalid token'
allow_any_instance_of(self.class).to receive(:doorkeeper_guard){ false }
expect(current_user).to be_nil
end
- it "should return nil for a user without access" do
+ it "returns nil for a user without access" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = personal_access_token.token
allow_any_instance_of(Gitlab::UserAccess).to receive(:allowed?).and_return(false)
expect(current_user).to be_nil
end
- it "should leave user as is when sudo not specified" do
+ it "leaves user as is when sudo not specified" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = personal_access_token.token
expect(current_user).to eq(user)
clear_env
@@ -100,7 +100,7 @@ describe API::Helpers, api: true do
end
end
- it "should change current user to sudo when admin" do
+ it "changes current user to sudo when admin" do
set_env(admin, user.id)
expect(current_user).to eq(user)
set_param(admin, user.id)
@@ -111,7 +111,7 @@ describe API::Helpers, api: true do
expect(current_user).to eq(user)
end
- it "should throw an error when the current user is not an admin and attempting to sudo" do
+ it "throws an error when the current user is not an admin and attempting to sudo" do
set_env(user, admin.id)
expect { current_user }.to raise_error(Exception)
set_param(user, admin.id)
@@ -122,7 +122,7 @@ describe API::Helpers, api: true do
expect { current_user }.to raise_error(Exception)
end
- it "should throw an error when the user cannot be found for a given id" do
+ it "throws an error when the user cannot be found for a given id" do
id = user.id + admin.id
expect(user.id).not_to eq(id)
expect(admin.id).not_to eq(id)
@@ -133,7 +133,7 @@ describe API::Helpers, api: true do
expect { current_user }.to raise_error(Exception)
end
- it "should throw an error when the user cannot be found for a given username" do
+ it "throws an error when the user cannot be found for a given username" do
username = "#{user.username}#{admin.username}"
expect(user.username).not_to eq(username)
expect(admin.username).not_to eq(username)
@@ -144,7 +144,7 @@ describe API::Helpers, api: true do
expect { current_user }.to raise_error(Exception)
end
- it "should handle sudo's to oneself" do
+ it "handles sudo's to oneself" do
set_env(admin, admin.id)
expect(current_user).to eq(admin)
set_param(admin, admin.id)
@@ -155,7 +155,7 @@ describe API::Helpers, api: true do
expect(current_user).to eq(admin)
end
- it "should handle multiple sudo's to oneself" do
+ it "handles multiple sudo's to oneself" do
set_env(admin, user.id)
expect(current_user).to eq(user)
expect(current_user).to eq(user)
@@ -171,7 +171,7 @@ describe API::Helpers, api: true do
expect(current_user).to eq(user)
end
- it "should handle multiple sudo's to oneself using string ids" do
+ it "handles multiple sudo's to oneself using string ids" do
set_env(admin, user.id.to_s)
expect(current_user).to eq(user)
expect(current_user).to eq(user)
@@ -183,7 +183,7 @@ describe API::Helpers, api: true do
end
describe '.sudo_identifier' do
- it "should return integers when input is an int" do
+ it "returns integers when input is an int" do
set_env(admin, '123')
expect(sudo_identifier).to eq(123)
set_env(admin, '0001234567890')
@@ -195,7 +195,7 @@ describe API::Helpers, api: true do
expect(sudo_identifier).to eq(1234567890)
end
- it "should return string when input is an is not an int" do
+ it "returns string when input is an is not an int" do
set_env(admin, '12.30')
expect(sudo_identifier).to eq("12.30")
set_env(admin, 'hello')
diff --git a/spec/requests/api/award_emoji_spec.rb b/spec/requests/api/award_emoji_spec.rb
index 2b74dd4bbb0..73c268c0d1e 100644
--- a/spec/requests/api/award_emoji_spec.rb
+++ b/spec/requests/api/award_emoji_spec.rb
@@ -22,7 +22,7 @@ describe API::API, api: true do
expect(json_response.first['name']).to eq(award_emoji.name)
end
- it "should return a 404 error when issue id not found" do
+ it "returns a 404 error when issue id not found" do
get api("/projects/#{project.id}/issues/12345/award_emoji", user)
expect(response).to have_http_status(404)
@@ -124,13 +124,13 @@ describe API::API, api: true do
expect(json_response['user']['username']).to eq(user.username)
end
- it "should return a 400 bad request error if the name is not given" do
+ it "returns a 400 bad request error if the name is not given" do
post api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user)
expect(response).to have_http_status(400)
end
- it "should return a 401 unauthorized error if the user is not authenticated" do
+ it "returns a 401 unauthorized error if the user is not authenticated" do
post api("/projects/#{project.id}/issues/#{issue.id}/award_emoji"), name: 'thumbsup'
expect(response).to have_http_status(401)
diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb
index e8fd697965f..9444138f93d 100644
--- a/spec/requests/api/branches_spec.rb
+++ b/spec/requests/api/branches_spec.rb
@@ -13,7 +13,7 @@ describe API::API, api: true do
let!(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
describe "GET /projects/:id/repository/branches" do
- it "should return an array of project branches" do
+ it "returns an array of project branches" do
project.repository.expire_cache
get api("/projects/#{project.id}/repository/branches", user)
@@ -25,7 +25,7 @@ describe API::API, api: true do
end
describe "GET /projects/:id/repository/branches/:branch" do
- it "should return the branch information for a single branch" do
+ it "returns the branch information for a single branch" do
get api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response).to have_http_status(200)
@@ -36,12 +36,12 @@ describe API::API, api: true do
expect(json_response['developers_can_merge']).to eq(false)
end
- it "should return a 403 error if guest" do
+ it "returns a 403 error if guest" do
get api("/projects/#{project.id}/repository/branches", user2)
expect(response).to have_http_status(403)
end
- it "should return a 404 error if branch is not available" do
+ it "returns a 404 error if branch is not available" do
get api("/projects/#{project.id}/repository/branches/unknown", user)
expect(response).to have_http_status(404)
end
@@ -138,17 +138,17 @@ describe API::API, api: true do
end
end
- it "should return a 404 error if branch not found" do
+ it "returns a 404 error if branch not found" do
put api("/projects/#{project.id}/repository/branches/unknown/protect", user)
expect(response).to have_http_status(404)
end
- it "should return a 403 error if guest" do
+ it "returns a 403 error if guest" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user2)
expect(response).to have_http_status(403)
end
- it "should return success when protect branch again" do
+ it "returns success when protect branch again" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user)
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user)
expect(response).to have_http_status(200)
@@ -156,7 +156,7 @@ describe API::API, api: true do
end
describe "PUT /projects/:id/repository/branches/:branch/unprotect" do
- it "should unprotect a single branch" do
+ it "unprotects a single branch" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
expect(response).to have_http_status(200)
@@ -165,12 +165,12 @@ describe API::API, api: true do
expect(json_response['protected']).to eq(false)
end
- it "should return success when unprotect branch" do
+ it "returns success when unprotect branch" do
put api("/projects/#{project.id}/repository/branches/unknown/unprotect", user)
expect(response).to have_http_status(404)
end
- it "should return success when unprotect branch again" do
+ it "returns success when unprotect branch again" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
expect(response).to have_http_status(200)
@@ -178,7 +178,7 @@ describe API::API, api: true do
end
describe "POST /projects/:id/repository/branches" do
- it "should create a new branch" do
+ it "creates a new branch" do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'feature1',
ref: branch_sha
@@ -189,14 +189,14 @@ describe API::API, api: true do
expect(json_response['commit']['id']).to eq(branch_sha)
end
- it "should deny for user without push access" do
+ it "denies for user without push access" do
post api("/projects/#{project.id}/repository/branches", user2),
branch_name: branch_name,
ref: branch_sha
expect(response).to have_http_status(403)
end
- it 'should return 400 if branch name is invalid' do
+ it 'returns 400 if branch name is invalid' do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new design',
ref: branch_sha
@@ -204,7 +204,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Branch name is invalid')
end
- it 'should return 400 if branch already exists' do
+ it 'returns 400 if branch already exists' do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new_design1',
ref: branch_sha
@@ -217,7 +217,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Branch already exists')
end
- it 'should return 400 if ref name is invalid' do
+ it 'returns 400 if ref name is invalid' do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new_design3',
ref: 'foo'
@@ -231,25 +231,25 @@ describe API::API, api: true do
allow_any_instance_of(Repository).to receive(:rm_branch).and_return(true)
end
- it "should remove branch" do
+ it "removes branch" do
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response).to have_http_status(200)
expect(json_response['branch_name']).to eq(branch_name)
end
- it 'should return 404 if branch not exists' do
+ it 'returns 404 if branch not exists' do
delete api("/projects/#{project.id}/repository/branches/foobar", user)
expect(response).to have_http_status(404)
end
- it "should remove protected branch" do
+ it "removes protected branch" do
project.protected_branches.create(name: branch_name)
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response).to have_http_status(405)
expect(json_response['message']).to eq('Protected branch cant be removed')
end
- it "should not remove HEAD branch" do
+ it "does not remove HEAD branch" do
delete api("/projects/#{project.id}/repository/branches/master", user)
expect(response).to have_http_status(405)
expect(json_response['message']).to eq('Cannot remove HEAD branch')
diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb
index 86a7b242fbe..966d302dfd3 100644
--- a/spec/requests/api/builds_spec.rb
+++ b/spec/requests/api/builds_spec.rb
@@ -18,7 +18,7 @@ describe API::API, api: true do
before { get api("/projects/#{project.id}/builds?#{query}", api_user) }
context 'authorized user' do
- it 'should return project builds' do
+ it 'returns project builds' do
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
end
@@ -84,7 +84,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/repository/commits/#{project.commit.id}/builds", api_user)
end
- it 'should return project builds for specific commit' do
+ it 'returns project builds for specific commit' do
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.size).to eq 2
@@ -113,7 +113,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/repository/commits/#{project.commit.id}/builds", nil)
end
- it 'should not return project builds' do
+ it 'does not return project builds' do
expect(response).to have_http_status(401)
expect(json_response.except('message')).to be_empty
end
@@ -125,7 +125,7 @@ describe API::API, api: true do
before { get api("/projects/#{project.id}/builds/#{build.id}", api_user) }
context 'authorized user' do
- it 'should return specific build data' do
+ it 'returns specific build data' do
expect(response).to have_http_status(200)
expect(json_response['name']).to eq('test')
end
@@ -134,7 +134,7 @@ describe API::API, api: true do
context 'unauthorized user' do
let(:api_user) { nil }
- it 'should not return specific build data' do
+ it 'does not return specific build data' do
expect(response).to have_http_status(401)
end
end
@@ -152,7 +152,7 @@ describe API::API, api: true do
'Content-Disposition' => 'attachment; filename=ci_build_artifacts.zip' }
end
- it 'should return specific build artifacts' do
+ it 'returns specific build artifacts' do
expect(response).to have_http_status(200)
expect(response.headers).to include(download_headers)
end
@@ -161,13 +161,13 @@ describe API::API, api: true do
context 'unauthorized user' do
let(:api_user) { nil }
- it 'should not return specific build artifacts' do
+ it 'does not return specific build artifacts' do
expect(response).to have_http_status(401)
end
end
end
- it 'should not return build artifacts if not uploaded' do
+ it 'does not return build artifacts if not uploaded' do
expect(response).to have_http_status(404)
end
end
@@ -272,7 +272,7 @@ describe API::API, api: true do
end
context 'authorized user' do
- it 'should return specific build trace' do
+ it 'returns specific build trace' do
expect(response).to have_http_status(200)
expect(response.body).to eq(build.trace)
end
@@ -281,7 +281,7 @@ describe API::API, api: true do
context 'unauthorized user' do
let(:api_user) { nil }
- it 'should not return specific build trace' do
+ it 'does not return specific build trace' do
expect(response).to have_http_status(401)
end
end
@@ -292,7 +292,7 @@ describe API::API, api: true do
context 'authorized user' do
context 'user with :update_build persmission' do
- it 'should cancel running or pending build' do
+ it 'cancels running or pending build' do
expect(response).to have_http_status(201)
expect(project.builds.first.status).to eq('canceled')
end
@@ -301,7 +301,7 @@ describe API::API, api: true do
context 'user without :update_build permission' do
let(:api_user) { reporter.user }
- it 'should not cancel build' do
+ it 'does not cancel build' do
expect(response).to have_http_status(403)
end
end
@@ -310,7 +310,7 @@ describe API::API, api: true do
context 'unauthorized user' do
let(:api_user) { nil }
- it 'should not cancel build' do
+ it 'does not cancel build' do
expect(response).to have_http_status(401)
end
end
@@ -323,7 +323,7 @@ describe API::API, api: true do
context 'authorized user' do
context 'user with :update_build permission' do
- it 'should retry non-running build' do
+ it 'retries non-running build' do
expect(response).to have_http_status(201)
expect(project.builds.first.status).to eq('canceled')
expect(json_response['status']).to eq('pending')
@@ -333,7 +333,7 @@ describe API::API, api: true do
context 'user without :update_build permission' do
let(:api_user) { reporter.user }
- it 'should not retry build' do
+ it 'does not retry build' do
expect(response).to have_http_status(403)
end
end
@@ -342,7 +342,7 @@ describe API::API, api: true do
context 'unauthorized user' do
let(:api_user) { nil }
- it 'should not retry build' do
+ it 'does not retry build' do
expect(response).to have_http_status(401)
end
end
@@ -356,14 +356,14 @@ describe API::API, api: true do
context 'build is erasable' do
let(:build) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline) }
- it 'should erase build content' do
+ it 'erases build content' do
expect(response.status).to eq 201
expect(build.trace).to be_empty
expect(build.artifacts_file.exists?).to be_falsy
expect(build.artifacts_metadata.exists?).to be_falsy
end
- it 'should update build' do
+ it 'updates build' do
expect(build.reload.erased_at).to be_truthy
expect(build.reload.erased_by).to eq user
end
@@ -372,7 +372,7 @@ describe API::API, api: true do
context 'build is not erasable' do
let(:build) { create(:ci_build, :trace, project: project, pipeline: pipeline) }
- it 'should respond with forbidden' do
+ it 'responds with forbidden' do
expect(response.status).to eq 403
end
end
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb
index 2da01da7fa1..2d6093fec7a 100644
--- a/spec/requests/api/commit_statuses_spec.rb
+++ b/spec/requests/api/commit_statuses_spec.rb
@@ -99,7 +99,7 @@ describe API::CommitStatuses, api: true do
context "guest user" do
before { get api(get_url, guest) }
- it "should not return project commits" do
+ it "does not return project commits" do
expect(response).to have_http_status(403)
end
end
@@ -107,7 +107,7 @@ describe API::CommitStatuses, api: true do
context "unauthorized user" do
before { get api(get_url) }
- it "should not return project commits" do
+ it "does not return project commits" do
expect(response).to have_http_status(401)
end
end
@@ -179,7 +179,7 @@ describe API::CommitStatuses, api: true do
context 'reporter user' do
before { post api(post_url, reporter) }
- it 'should not create commit status' do
+ it 'does not create commit status' do
expect(response).to have_http_status(403)
end
end
@@ -187,7 +187,7 @@ describe API::CommitStatuses, api: true do
context 'guest user' do
before { post api(post_url, guest) }
- it 'should not create commit status' do
+ it 'does not create commit status' do
expect(response).to have_http_status(403)
end
end
@@ -195,7 +195,7 @@ describe API::CommitStatuses, api: true do
context 'unauthorized user' do
before { post api(post_url) }
- it 'should not create commit status' do
+ it 'does not create commit status' do
expect(response).to have_http_status(401)
end
end
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index 51ee2167d47..4379fcb3c1e 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -17,7 +17,7 @@ describe API::API, api: true do
context "authorized user" do
before { project.team << [user2, :reporter] }
- it "should return project commits" do
+ it "returns project commits" do
get api("/projects/#{project.id}/repository/commits", user)
expect(response).to have_http_status(200)
@@ -27,14 +27,14 @@ describe API::API, api: true do
end
context "unauthorized user" do
- it "should not return project commits" do
+ it "does not return project commits" do
get api("/projects/#{project.id}/repository/commits")
expect(response).to have_http_status(401)
end
end
context "since optional parameter" do
- it "should return project commits since provided parameter" do
+ it "returns project commits since provided parameter" do
commits = project.repository.commits("master")
since = commits.second.created_at
@@ -47,7 +47,7 @@ describe API::API, api: true do
end
context "until optional parameter" do
- it "should return project commits until provided parameter" do
+ it "returns project commits until provided parameter" do
commits = project.repository.commits("master")
before = commits.second.created_at
@@ -60,7 +60,7 @@ describe API::API, api: true do
end
context "invalid xmlschema date parameters" do
- it "should return an invalid parameter error message" do
+ it "returns an invalid parameter error message" do
get api("/projects/#{project.id}/repository/commits?since=invalid-date", user)
expect(response).to have_http_status(400)
@@ -71,7 +71,7 @@ describe API::API, api: true do
describe "GET /projects:id/repository/commits/:sha" do
context "authorized user" do
- it "should return a commit by sha" do
+ it "returns a commit by sha" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
expect(response).to have_http_status(200)
@@ -82,18 +82,18 @@ describe API::API, api: true do
expect(json_response['stats']['total']).to eq(project.repository.commit.stats.total)
end
- it "should return a 404 error if not found" do
+ it "returns a 404 error if not found" do
get api("/projects/#{project.id}/repository/commits/invalid_sha", user)
expect(response).to have_http_status(404)
end
- it "should return nil for commit without CI" do
+ it "returns nil for commit without CI" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
expect(response).to have_http_status(200)
expect(json_response['status']).to be_nil
end
- it "should return status for CI" do
+ it "returns status for CI" do
pipeline = project.ensure_pipeline(project.repository.commit.sha, 'master')
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
expect(response).to have_http_status(200)
@@ -102,7 +102,7 @@ describe API::API, api: true do
end
context "unauthorized user" do
- it "should not return the selected commit" do
+ it "does not return the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}")
expect(response).to have_http_status(401)
end
@@ -113,7 +113,7 @@ describe API::API, api: true do
context "authorized user" do
before { project.team << [user2, :reporter] }
- it "should return the diff of the selected commit" do
+ it "returns the diff of the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff", user)
expect(response).to have_http_status(200)
@@ -122,14 +122,14 @@ describe API::API, api: true do
expect(json_response.first.keys).to include "diff"
end
- it "should return a 404 error if invalid commit" do
+ it "returns a 404 error if invalid commit" do
get api("/projects/#{project.id}/repository/commits/invalid_sha/diff", user)
expect(response).to have_http_status(404)
end
end
context "unauthorized user" do
- it "should not return the diff of the selected commit" do
+ it "does not return the diff of the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff")
expect(response).to have_http_status(401)
end
@@ -138,7 +138,7 @@ describe API::API, api: true do
describe 'GET /projects:id/repository/commits/:sha/comments' do
context 'authorized user' do
- it 'should return merge_request comments' do
+ it 'returns merge_request comments' do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -147,14 +147,14 @@ describe API::API, api: true do
expect(json_response.first['author']['id']).to eq(user.id)
end
- it 'should return a 404 error if merge_request_id not found' do
+ it 'returns a 404 error if merge_request_id not found' do
get api("/projects/#{project.id}/repository/commits/1234ab/comments", user)
expect(response).to have_http_status(404)
end
end
context 'unauthorized user' do
- it 'should not return the diff of the selected commit' do
+ it 'does not return the diff of the selected commit' do
get api("/projects/#{project.id}/repository/commits/1234ab/comments")
expect(response).to have_http_status(401)
end
@@ -163,7 +163,7 @@ describe API::API, api: true do
describe 'POST /projects:id/repository/commits/:sha/comments' do
context 'authorized user' do
- it 'should return comment' do
+ it 'returns comment' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment'
expect(response).to have_http_status(201)
expect(json_response['note']).to eq('My comment')
@@ -172,7 +172,7 @@ describe API::API, api: true do
expect(json_response['line_type']).to be_nil
end
- it 'should return the inline comment' do
+ it 'returns the inline comment' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment', path: project.repository.commit.raw_diffs.first.new_path, line: 7, line_type: 'new'
expect(response).to have_http_status(201)
expect(json_response['note']).to eq('My comment')
@@ -181,19 +181,19 @@ describe API::API, api: true do
expect(json_response['line_type']).to eq('new')
end
- it 'should return 400 if note is missing' do
+ it 'returns 400 if note is missing' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user)
expect(response).to have_http_status(400)
end
- it 'should return 404 if note is attached to non existent commit' do
+ it 'returns 404 if note is attached to non existent commit' do
post api("/projects/#{project.id}/repository/commits/1234ab/comments", user), note: 'My comment'
expect(response).to have_http_status(404)
end
end
context 'unauthorized user' do
- it 'should not return the diff of the selected commit' do
+ it 'does not return the diff of the selected commit' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments")
expect(response).to have_http_status(401)
end
diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb
index 2e5448143d5..2d1213df8a7 100644
--- a/spec/requests/api/files_spec.rb
+++ b/spec/requests/api/files_spec.rb
@@ -9,7 +9,7 @@ describe API::API, api: true do
before { project.team << [user, :developer] }
describe "GET /projects/:id/repository/files" do
- it "should return file info" do
+ it "returns file info" do
params = {
file_path: file_path,
ref: 'master',
@@ -23,12 +23,12 @@ describe API::API, api: true do
expect(Base64.decode64(json_response['content']).lines.first).to eq("require 'fileutils'\n")
end
- it "should return a 400 bad request if no params given" do
+ it "returns a 400 bad request if no params given" do
get api("/projects/#{project.id}/repository/files", user)
expect(response).to have_http_status(400)
end
- it "should return a 404 if such file does not exist" do
+ it "returns a 404 if such file does not exist" do
params = {
file_path: 'app/models/application.rb',
ref: 'master',
@@ -49,18 +49,18 @@ describe API::API, api: true do
}
end
- it "should create a new file in project repo" do
+ it "creates a new file in project repo" do
post api("/projects/#{project.id}/repository/files", user), valid_params
expect(response).to have_http_status(201)
expect(json_response['file_path']).to eq('newfile.rb')
end
- it "should return a 400 bad request if no params given" do
+ it "returns a 400 bad request if no params given" do
post api("/projects/#{project.id}/repository/files", user)
expect(response).to have_http_status(400)
end
- it "should return a 400 if editor fails to create file" do
+ it "returns a 400 if editor fails to create file" do
allow_any_instance_of(Repository).to receive(:commit_file).
and_return(false)
@@ -79,13 +79,13 @@ describe API::API, api: true do
}
end
- it "should update existing file in project repo" do
+ it "updates existing file in project repo" do
put api("/projects/#{project.id}/repository/files", user), valid_params
expect(response).to have_http_status(200)
expect(json_response['file_path']).to eq(file_path)
end
- it "should return a 400 bad request if no params given" do
+ it "returns a 400 bad request if no params given" do
put api("/projects/#{project.id}/repository/files", user)
expect(response).to have_http_status(400)
end
@@ -100,18 +100,18 @@ describe API::API, api: true do
}
end
- it "should delete existing file in project repo" do
+ it "deletes existing file in project repo" do
delete api("/projects/#{project.id}/repository/files", user), valid_params
expect(response).to have_http_status(200)
expect(json_response['file_path']).to eq(file_path)
end
- it "should return a 400 bad request if no params given" do
+ it "returns a 400 bad request if no params given" do
delete api("/projects/#{project.id}/repository/files", user)
expect(response).to have_http_status(400)
end
- it "should return a 400 if fails to create file" do
+ it "returns a 400 if fails to create file" do
allow_any_instance_of(Repository).to receive(:remove_file).and_return(false)
delete api("/projects/#{project.id}/repository/files", user), valid_params
diff --git a/spec/requests/api/fork_spec.rb b/spec/requests/api/fork_spec.rb
index a9f5aa924b7..f802fcd2d2e 100644
--- a/spec/requests/api/fork_spec.rb
+++ b/spec/requests/api/fork_spec.rb
@@ -20,7 +20,7 @@ describe API::API, api: true do
before { user3 }
context 'when authenticated' do
- it 'should fork if user has sufficient access to project' do
+ it 'forks if user has sufficient access to project' do
post api("/projects/fork/#{project.id}", user2)
expect(response).to have_http_status(201)
expect(json_response['name']).to eq(project.name)
@@ -30,7 +30,7 @@ describe API::API, api: true do
expect(json_response['forked_from_project']['id']).to eq(project.id)
end
- it 'should fork if user is admin' do
+ it 'forks if user is admin' do
post api("/projects/fork/#{project.id}", admin)
expect(response).to have_http_status(201)
expect(json_response['name']).to eq(project.name)
@@ -40,20 +40,20 @@ describe API::API, api: true do
expect(json_response['forked_from_project']['id']).to eq(project.id)
end
- it 'should fail on missing project access for the project to fork' do
+ it 'fails on missing project access for the project to fork' do
post api("/projects/fork/#{project.id}", user3)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found')
end
- it 'should fail if forked project exists in the user namespace' do
+ it 'fails if forked project exists in the user namespace' do
post api("/projects/fork/#{project.id}", user)
expect(response).to have_http_status(409)
expect(json_response['message']['name']).to eq(['has already been taken'])
expect(json_response['message']['path']).to eq(['has already been taken'])
end
- it 'should fail if project to fork from does not exist' do
+ it 'fails if project to fork from does not exist' do
post api('/projects/fork/424242', user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found')
@@ -61,7 +61,7 @@ describe API::API, api: true do
end
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
post api("/projects/fork/#{project.id}")
expect(response).to have_http_status(401)
expect(json_response['message']).to eq('401 Unauthorized')
diff --git a/spec/requests/api/group_members_spec.rb b/spec/requests/api/group_members_spec.rb
index 52f9e7d4681..8bd6a8062ae 100644
--- a/spec/requests/api/group_members_spec.rb
+++ b/spec/requests/api/group_members_spec.rb
@@ -28,7 +28,7 @@ describe API::API, api: true do
describe "GET /groups/:id/members" do
context "when authenticated as user that is part or the group" do
- it "each user: should return an array of members groups of group3" do
+ it "each user: returns an array of members groups of group3" do
[owner, master, developer, reporter, guest].each do |user|
get api("/groups/#{group_with_members.id}/members", user)
expect(response).to have_http_status(200)
@@ -52,14 +52,14 @@ describe API::API, api: true do
describe "POST /groups/:id/members" do
context "when not a member of the group" do
- it "should not add guest as member of group_no_members when adding being done by person outside the group" do
+ it "does not add guest as member of group_no_members when adding being done by person outside the group" do
post api("/groups/#{group_no_members.id}/members", reporter), user_id: guest.id, access_level: GroupMember::MASTER
expect(response).to have_http_status(403)
end
end
context "when a member of the group" do
- it "should return ok and add new member" do
+ it "returns ok and add new member" do
new_user = create(:user)
expect do
@@ -71,7 +71,7 @@ describe API::API, api: true do
expect(json_response['access_level']).to eq(GroupMember::MASTER)
end
- it "should not allow guest to modify group members" do
+ it "does not allow guest to modify group members" do
new_user = create(:user)
expect do
@@ -81,22 +81,22 @@ describe API::API, api: true do
expect(response).to have_http_status(403)
end
- it "should return error if member already exists" do
+ it "returns error if member already exists" do
post api("/groups/#{group_with_members.id}/members", owner), user_id: master.id, access_level: GroupMember::MASTER
expect(response).to have_http_status(409)
end
- it "should return a 400 error when user id is not given" do
+ it "returns a 400 error when user id is not given" do
post api("/groups/#{group_no_members.id}/members", owner), access_level: GroupMember::MASTER
expect(response).to have_http_status(400)
end
- it "should return a 400 error when access level is not given" do
+ it "returns a 400 error when access level is not given" do
post api("/groups/#{group_no_members.id}/members", owner), user_id: master.id
expect(response).to have_http_status(400)
end
- it "should return a 422 error when access level is not known" do
+ it "returns a 422 error when access level is not known" do
post api("/groups/#{group_no_members.id}/members", owner), user_id: master.id, access_level: 1234
expect(response).to have_http_status(422)
end
@@ -105,7 +105,7 @@ describe API::API, api: true do
describe 'PUT /groups/:id/members/:user_id' do
context 'when not a member of the group' do
- it 'should return a 409 error if the user is not a group member' do
+ it 'returns a 409 error if the user is not a group member' do
put(
api("/groups/#{group_no_members.id}/members/#{developer.id}",
owner), access_level: GroupMember::MASTER
@@ -115,7 +115,7 @@ describe API::API, api: true do
end
context 'when a member of the group' do
- it 'should return ok and update member access level' do
+ it 'returns ok and update member access level' do
put(
api("/groups/#{group_with_members.id}/members/#{reporter.id}",
owner),
@@ -132,7 +132,7 @@ describe API::API, api: true do
expect(json_reporter['access_level']).to eq(GroupMember::MASTER)
end
- it 'should not allow guest to modify group members' do
+ it 'does not allow guest to modify group members' do
put(
api("/groups/#{group_with_members.id}/members/#{developer.id}",
guest),
@@ -149,14 +149,14 @@ describe API::API, api: true do
expect(json_developer['access_level']).to eq(GroupMember::DEVELOPER)
end
- it 'should return a 400 error when access level is not given' do
+ it 'returns a 400 error when access level is not given' do
put(
api("/groups/#{group_with_members.id}/members/#{master.id}", owner)
)
expect(response).to have_http_status(400)
end
- it 'should return a 422 error when access level is not known' do
+ it 'returns a 422 error when access level is not known' do
put(
api("/groups/#{group_with_members.id}/members/#{master.id}", owner),
access_level: 1234
@@ -168,7 +168,7 @@ describe API::API, api: true do
describe 'DELETE /groups/:id/members/:user_id' do
context 'when not a member of the group' do
- it "should not delete guest's membership of group_with_members" do
+ it "does not delete guest's membership of group_with_members" do
random_user = create(:user)
delete api("/groups/#{group_with_members.id}/members/#{owner.id}", random_user)
@@ -177,7 +177,7 @@ describe API::API, api: true do
end
context "when a member of the group" do
- it "should delete guest's membership of group" do
+ it "deletes guest's membership of group" do
expect do
delete api("/groups/#{group_with_members.id}/members/#{guest.id}", owner)
end.to change { group_with_members.members.count }.by(-1)
@@ -185,12 +185,12 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it "should return a 404 error when user id is not known" do
+ it "returns a 404 error when user id is not known" do
delete api("/groups/#{group_with_members.id}/members/1328", owner)
expect(response).to have_http_status(404)
end
- it "should not allow guest to modify group members" do
+ it "does not allow guest to modify group members" do
delete api("/groups/#{group_with_members.id}/members/#{master.id}", guest)
expect(response).to have_http_status(403)
end
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index c2c94040ece..4860b23c2ed 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -21,14 +21,14 @@ describe API::API, api: true do
describe "GET /groups" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/groups")
expect(response).to have_http_status(401)
end
end
context "when authenticated as user" do
- it "normal user: should return an array of groups of user1" do
+ it "normal user: returns an array of groups of user1" do
get api("/groups", user1)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -38,7 +38,7 @@ describe API::API, api: true do
end
context "when authenticated as admin" do
- it "admin: should return an array of all groups" do
+ it "admin: returns an array of all groups" do
get api("/groups", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -70,12 +70,12 @@ describe API::API, api: true do
expect(json_response['shared_projects'][0]['id']).to eq(project.id)
end
- it "should not return a non existing group" do
+ it "does not return a non existing group" do
get api("/groups/1328", user1)
expect(response).to have_http_status(404)
end
- it "should not return a group not attached to user1" do
+ it "does not return a group not attached to user1" do
get api("/groups/#{group2.id}", user1)
expect(response).to have_http_status(404)
@@ -83,31 +83,31 @@ describe API::API, api: true do
end
context "when authenticated as admin" do
- it "should return any existing group" do
+ it "returns any existing group" do
get api("/groups/#{group2.id}", admin)
expect(response).to have_http_status(200)
expect(json_response['name']).to eq(group2.name)
end
- it "should not return a non existing group" do
+ it "does not return a non existing group" do
get api("/groups/1328", admin)
expect(response).to have_http_status(404)
end
end
context 'when using group path in URL' do
- it 'should return any existing group' do
+ it 'returns any existing group' do
get api("/groups/#{group1.path}", admin)
expect(response).to have_http_status(200)
expect(json_response['name']).to eq(group1.name)
end
- it 'should not return a non existing group' do
+ it 'does not return a non existing group' do
get api('/groups/unknown', admin)
expect(response).to have_http_status(404)
end
- it 'should not return a group not attached to user1' do
+ it 'does not return a group not attached to user1' do
get api("/groups/#{group2.path}", user1)
expect(response).to have_http_status(404)
@@ -161,7 +161,7 @@ describe API::API, api: true do
describe "GET /groups/:id/projects" do
context "when authenticated as user" do
- it "should return the group's projects" do
+ it "returns the group's projects" do
get api("/groups/#{group1.id}/projects", user1)
expect(response).to have_http_status(200)
@@ -170,12 +170,12 @@ describe API::API, api: true do
expect(project_names).to match_array([project1.name, project3.name])
end
- it "should not return a non existing group" do
+ it "does not return a non existing group" do
get api("/groups/1328/projects", user1)
expect(response).to have_http_status(404)
end
- it "should not return a group not attached to user1" do
+ it "does not return a group not attached to user1" do
get api("/groups/#{group2.id}/projects", user1)
expect(response).to have_http_status(404)
@@ -215,12 +215,12 @@ describe API::API, api: true do
expect(project_names).to match_array([project1.name, project3.name])
end
- it 'should not return a non existing group' do
+ it 'does not return a non existing group' do
get api('/groups/unknown/projects', admin)
expect(response).to have_http_status(404)
end
- it 'should not return a group not attached to user1' do
+ it 'does not return a group not attached to user1' do
get api("/groups/#{group2.path}/projects", user1)
expect(response).to have_http_status(404)
@@ -230,30 +230,30 @@ describe API::API, api: true do
describe "POST /groups" do
context "when authenticated as user without group permissions" do
- it "should not create group" do
+ it "does not create group" do
post api("/groups", user1), attributes_for(:group)
expect(response).to have_http_status(403)
end
end
context "when authenticated as user with group permissions" do
- it "should create group" do
+ it "creates group" do
post api("/groups", user3), attributes_for(:group)
expect(response).to have_http_status(201)
end
- it "should not create group, duplicate" do
+ it "does not create group, duplicate" do
post api("/groups", user3), { name: 'Duplicate Test', path: group2.path }
expect(response).to have_http_status(400)
expect(response.message).to eq("Bad Request")
end
- it "should return 400 bad request error if name not given" do
+ it "returns 400 bad request error if name not given" do
post api("/groups", user3), { path: group2.path }
expect(response).to have_http_status(400)
end
- it "should return 400 bad request error if path not given" do
+ it "returns 400 bad request error if path not given" do
post api("/groups", user3), { name: 'test' }
expect(response).to have_http_status(400)
end
@@ -262,24 +262,24 @@ describe API::API, api: true do
describe "DELETE /groups/:id" do
context "when authenticated as user" do
- it "should remove group" do
+ it "removes group" do
delete api("/groups/#{group1.id}", user1)
expect(response).to have_http_status(200)
end
- it "should not remove a group if not an owner" do
+ it "does not remove a group if not an owner" do
user4 = create(:user)
group1.add_master(user4)
delete api("/groups/#{group1.id}", user3)
expect(response).to have_http_status(403)
end
- it "should not remove a non existing group" do
+ it "does not remove a non existing group" do
delete api("/groups/1328", user1)
expect(response).to have_http_status(404)
end
- it "should not remove a group not attached to user1" do
+ it "does not remove a group not attached to user1" do
delete api("/groups/#{group2.id}", user1)
expect(response).to have_http_status(404)
@@ -287,12 +287,12 @@ describe API::API, api: true do
end
context "when authenticated as admin" do
- it "should remove any existing group" do
+ it "removes any existing group" do
delete api("/groups/#{group2.id}", admin)
expect(response).to have_http_status(200)
end
- it "should not remove a non existing group" do
+ it "does not remove a non existing group" do
delete api("/groups/1328", admin)
expect(response).to have_http_status(404)
end
@@ -308,14 +308,14 @@ describe API::API, api: true do
end
context "when authenticated as user" do
- it "should not transfer project to group" do
+ it "does not transfer project to group" do
post api("/groups/#{group1.id}/projects/#{project.id}", user2)
expect(response).to have_http_status(403)
end
end
context "when authenticated as admin" do
- it "should transfer project to group" do
+ it "transfers project to group" do
post api("/groups/#{group1.id}/projects/#{project.id}", admin)
expect(response).to have_http_status(201)
end
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 9d3d28e0b91..3cd4e981fb2 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -49,28 +49,28 @@ describe API::API, api: true do
describe "GET /issues" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/issues")
expect(response).to have_http_status(401)
end
end
context "when authenticated" do
- it "should return an array of issues" do
+ it "returns an array of issues" do
get api("/issues", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(issue.title)
end
- it "should add pagination headers and keep query params" do
+ it "adds pagination headers and keep query params" do
get api("/issues?state=closed&per_page=3", user)
expect(response.headers['Link']).to eq(
'<http://www.example.com/api/v3/issues?page=1&per_page=3&private_token=%s&state=closed>; rel="first", <http://www.example.com/api/v3/issues?page=1&per_page=3&private_token=%s&state=closed>; rel="last"' % [user.private_token, user.private_token]
)
end
- it 'should return an array of closed issues' do
+ it 'returns an array of closed issues' do
get api('/issues?state=closed', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -78,7 +78,7 @@ describe API::API, api: true do
expect(json_response.first['id']).to eq(closed_issue.id)
end
- it 'should return an array of opened issues' do
+ it 'returns an array of opened issues' do
get api('/issues?state=opened', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -86,7 +86,7 @@ describe API::API, api: true do
expect(json_response.first['id']).to eq(issue.id)
end
- it 'should return an array of all issues' do
+ it 'returns an array of all issues' do
get api('/issues?state=all', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -95,7 +95,7 @@ describe API::API, api: true do
expect(json_response.second['id']).to eq(closed_issue.id)
end
- it 'should return an array of labeled issues' do
+ it 'returns an array of labeled issues' do
get api("/issues?labels=#{label.title}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -103,7 +103,7 @@ describe API::API, api: true do
expect(json_response.first['labels']).to eq([label.title])
end
- it 'should return an array of labeled issues when at least one label matches' do
+ it 'returns an array of labeled issues when at least one label matches' do
get api("/issues?labels=#{label.title},foo,bar", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -111,14 +111,14 @@ describe API::API, api: true do
expect(json_response.first['labels']).to eq([label.title])
end
- it 'should return an empty array if no issue matches labels' do
+ it 'returns an empty array if no issue matches labels' do
get api('/issues?labels=foo,bar', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'should return an array of labeled issues matching given state' do
+ it 'returns an array of labeled issues matching given state' do
get api("/issues?labels=#{label.title}&state=opened", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -127,7 +127,7 @@ describe API::API, api: true do
expect(json_response.first['state']).to eq('opened')
end
- it 'should return an empty array if no issue matches labels and state filters' do
+ it 'returns an empty array if no issue matches labels and state filters' do
get api("/issues?labels=#{label.title}&state=closed", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -282,7 +282,7 @@ describe API::API, api: true do
let(:base_url) { "/projects/#{project.id}" }
let(:title) { milestone.title }
- it 'should return project issues without confidential issues for non project members' do
+ it 'returns project issues without confidential issues for non project members' do
get api("#{base_url}/issues", non_member)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -290,7 +290,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return project issues without confidential issues for project members with guest role' do
+ it 'returns project issues without confidential issues for project members with guest role' do
get api("#{base_url}/issues", guest)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -298,7 +298,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return project confidential issues for author' do
+ it 'returns project confidential issues for author' do
get api("#{base_url}/issues", author)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -306,7 +306,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return project confidential issues for assignee' do
+ it 'returns project confidential issues for assignee' do
get api("#{base_url}/issues", assignee)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -314,7 +314,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return project issues with confidential issues for project members' do
+ it 'returns project issues with confidential issues for project members' do
get api("#{base_url}/issues", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -322,7 +322,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return project confidential issues for admin' do
+ it 'returns project confidential issues for admin' do
get api("#{base_url}/issues", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -330,7 +330,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return an array of labeled project issues' do
+ it 'returns an array of labeled project issues' do
get api("#{base_url}/issues?labels=#{label.title}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -338,7 +338,7 @@ describe API::API, api: true do
expect(json_response.first['labels']).to eq([label.title])
end
- it 'should return an array of labeled project issues when at least one label matches' do
+ it 'returns an array of labeled project issues when at least one label matches' do
get api("#{base_url}/issues?labels=#{label.title},foo,bar", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -346,28 +346,28 @@ describe API::API, api: true do
expect(json_response.first['labels']).to eq([label.title])
end
- it 'should return an empty array if no project issue matches labels' do
+ it 'returns an empty array if no project issue matches labels' do
get api("#{base_url}/issues?labels=foo,bar", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'should return an empty array if no issue matches milestone' do
+ it 'returns an empty array if no issue matches milestone' do
get api("#{base_url}/issues?milestone=#{empty_milestone.title}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'should return an empty array if milestone does not exist' do
+ it 'returns an empty array if milestone does not exist' do
get api("#{base_url}/issues?milestone=foo", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'should return an array of issues in given milestone' do
+ it 'returns an array of issues in given milestone' do
get api("#{base_url}/issues?milestone=#{title}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -376,7 +376,7 @@ describe API::API, api: true do
expect(json_response.second['id']).to eq(closed_issue.id)
end
- it 'should return an array of issues matching state in milestone' do
+ it 'returns an array of issues matching state in milestone' do
get api("#{base_url}/issues?milestone=#{milestone.title}"\
'&state=closed', user)
expect(response).to have_http_status(200)
@@ -405,7 +405,7 @@ describe API::API, api: true do
expect(json_response['author']).to be_a Hash
end
- it "should return a project issue by id" do
+ it "returns a project issue by id" do
get api("/projects/#{project.id}/issues/#{issue.id}", user)
expect(response).to have_http_status(200)
@@ -413,7 +413,7 @@ describe API::API, api: true do
expect(json_response['iid']).to eq(issue.iid)
end
- it 'should return a project issue by iid' do
+ it 'returns a project issue by iid' do
get api("/projects/#{project.id}/issues?iid=#{issue.iid}", user)
expect(response.status).to eq 200
expect(json_response.first['title']).to eq issue.title
@@ -421,44 +421,44 @@ describe API::API, api: true do
expect(json_response.first['iid']).to eq issue.iid
end
- it "should return 404 if issue id not found" do
+ it "returns 404 if issue id not found" do
get api("/projects/#{project.id}/issues/54321", user)
expect(response).to have_http_status(404)
end
context 'confidential issues' do
- it "should return 404 for non project members" do
+ it "returns 404 for non project members" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", non_member)
expect(response).to have_http_status(404)
end
- it "should return 404 for project members with guest role" do
+ it "returns 404 for project members with guest role" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", guest)
expect(response).to have_http_status(404)
end
- it "should return confidential issue for project members" do
+ it "returns confidential issue for project members" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", user)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
end
- it "should return confidential issue for author" do
+ it "returns confidential issue for author" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", author)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
end
- it "should return confidential issue for assignee" do
+ it "returns confidential issue for assignee" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", assignee)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
end
- it "should return confidential issue for admin" do
+ it "returns confidential issue for admin" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", admin)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
@@ -468,7 +468,7 @@ describe API::API, api: true do
end
describe "POST /projects/:id/issues" do
- it "should create a new project issue" do
+ it "creates a new project issue" do
post api("/projects/#{project.id}/issues", user),
title: 'new issue', labels: 'label, label2'
expect(response).to have_http_status(201)
@@ -477,12 +477,12 @@ describe API::API, api: true do
expect(json_response['labels']).to eq(['label', 'label2'])
end
- it "should return a 400 bad request if title not given" do
+ it "returns a 400 bad request if title not given" do
post api("/projects/#{project.id}/issues", user), labels: 'label, label2'
expect(response).to have_http_status(400)
end
- it 'should allow special label names' do
+ it 'allows special label names' do
post api("/projects/#{project.id}/issues", user),
title: 'new issue',
labels: 'label, label?, label&foo, ?, &'
@@ -494,7 +494,7 @@ describe API::API, api: true do
expect(json_response['labels']).to include '&'
end
- it 'should return 400 if title is too long' do
+ it 'returns 400 if title is too long' do
post api("/projects/#{project.id}/issues", user),
title: 'g' * 256
expect(response).to have_http_status(400)
@@ -543,7 +543,7 @@ describe API::API, api: true do
}
end
- it "should not create a new project issue" do
+ it "does not create a new project issue" do
expect { post api("/projects/#{project.id}/issues", user), params }.not_to change(Issue, :count)
expect(response).to have_http_status(400)
expect(json_response['message']).to eq({ "error" => "Spam detected" })
@@ -559,7 +559,7 @@ describe API::API, api: true do
end
describe "PUT /projects/:id/issues/:issue_id to update only title" do
- it "should update a project issue" do
+ it "updates a project issue" do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'updated title'
expect(response).to have_http_status(200)
@@ -567,13 +567,13 @@ describe API::API, api: true do
expect(json_response['title']).to eq('updated title')
end
- it "should return 404 error if issue id not found" do
+ it "returns 404 error if issue id not found" do
put api("/projects/#{project.id}/issues/44444", user),
title: 'updated title'
expect(response).to have_http_status(404)
end
- it 'should allow special label names' do
+ it 'allows special label names' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'updated title',
labels: 'label, label?, label&foo, ?, &'
@@ -587,33 +587,33 @@ describe API::API, api: true do
end
context 'confidential issues' do
- it "should return 403 for non project members" do
+ it "returns 403 for non project members" do
put api("/projects/#{project.id}/issues/#{confidential_issue.id}", non_member),
title: 'updated title'
expect(response).to have_http_status(403)
end
- it "should return 403 for project members with guest role" do
+ it "returns 403 for project members with guest role" do
put api("/projects/#{project.id}/issues/#{confidential_issue.id}", guest),
title: 'updated title'
expect(response).to have_http_status(403)
end
- it "should update a confidential issue for project members" do
+ it "updates a confidential issue for project members" do
put api("/projects/#{project.id}/issues/#{confidential_issue.id}", user),
title: 'updated title'
expect(response).to have_http_status(200)
expect(json_response['title']).to eq('updated title')
end
- it "should update a confidential issue for author" do
+ it "updates a confidential issue for author" do
put api("/projects/#{project.id}/issues/#{confidential_issue.id}", author),
title: 'updated title'
expect(response).to have_http_status(200)
expect(json_response['title']).to eq('updated title')
end
- it "should update a confidential issue for admin" do
+ it "updates a confidential issue for admin" do
put api("/projects/#{project.id}/issues/#{confidential_issue.id}", admin),
title: 'updated title'
expect(response).to have_http_status(200)
@@ -626,21 +626,21 @@ describe API::API, api: true do
let!(:label) { create(:label, title: 'dummy', project: project) }
let!(:label_link) { create(:label_link, label: label, target: issue) }
- it 'should not update labels if not present' do
+ it 'does not update labels if not present' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'updated title'
expect(response).to have_http_status(200)
expect(json_response['labels']).to eq([label.title])
end
- it 'should remove all labels' do
+ it 'removes all labels' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: ''
expect(response).to have_http_status(200)
expect(json_response['labels']).to eq([])
end
- it 'should update labels' do
+ it 'updates labels' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'foo,bar'
expect(response).to have_http_status(200)
@@ -648,7 +648,7 @@ describe API::API, api: true do
expect(json_response['labels']).to include 'bar'
end
- it 'should allow special label names' do
+ it 'allows special label names' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'label:foo, label-bar,label_bar,label/bar,label?bar,label&bar,?,&'
expect(response.status).to eq(200)
@@ -662,7 +662,7 @@ describe API::API, api: true do
expect(json_response['labels']).to include '&'
end
- it 'should return 400 if title is too long' do
+ it 'returns 400 if title is too long' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'g' * 256
expect(response).to have_http_status(400)
@@ -673,7 +673,7 @@ describe API::API, api: true do
end
describe "PUT /projects/:id/issues/:issue_id to update state and label" do
- it "should update a project issue" do
+ it "updates a project issue" do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'label2', state_event: "close"
expect(response).to have_http_status(200)
diff --git a/spec/requests/api/keys_spec.rb b/spec/requests/api/keys_spec.rb
index 1861882d59e..893ed5c2b10 100644
--- a/spec/requests/api/keys_spec.rb
+++ b/spec/requests/api/keys_spec.rb
@@ -12,20 +12,20 @@ describe API::API, api: true do
before { admin }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api("/keys/#{key.id}")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should return 404 for non-existing key' do
+ it 'returns 404 for non-existing key' do
get api('/keys/999999', admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found')
end
- it 'should return single ssh key with user information' do
+ it 'returns single ssh key with user information' do
user.keys << key
user.save
get api("/keys/#{key.id}", admin)
diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb
index 63636b4a1b6..83789223019 100644
--- a/spec/requests/api/labels_spec.rb
+++ b/spec/requests/api/labels_spec.rb
@@ -12,7 +12,7 @@ describe API::API, api: true do
end
describe 'GET /projects/:id/labels' do
- it 'should return project labels' do
+ it 'returns project labels' do
get api("/projects/#{project.id}/labels", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -22,7 +22,7 @@ describe API::API, api: true do
end
describe 'POST /projects/:id/labels' do
- it 'should return created label when all params' do
+ it 'returns created label when all params' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAABB',
@@ -33,7 +33,7 @@ describe API::API, api: true do
expect(json_response['description']).to eq('test')
end
- it 'should return created label when only required params' do
+ it 'returns created label when only required params' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo & Bar',
color: '#FFAABB'
@@ -43,17 +43,17 @@ describe API::API, api: true do
expect(json_response['description']).to be_nil
end
- it 'should return a 400 bad request if name not given' do
+ it 'returns a 400 bad request if name not given' do
post api("/projects/#{project.id}/labels", user), color: '#FFAABB'
expect(response).to have_http_status(400)
end
- it 'should return a 400 bad request if color not given' do
+ it 'returns a 400 bad request if color not given' do
post api("/projects/#{project.id}/labels", user), name: 'Foobar'
expect(response).to have_http_status(400)
end
- it 'should return 400 for invalid color' do
+ it 'returns 400 for invalid color' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAA'
@@ -61,7 +61,7 @@ describe API::API, api: true do
expect(json_response['message']['color']).to eq(['must be a valid color code'])
end
- it 'should return 400 for too long color code' do
+ it 'returns 400 for too long color code' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAAFFFF'
@@ -69,7 +69,7 @@ describe API::API, api: true do
expect(json_response['message']['color']).to eq(['must be a valid color code'])
end
- it 'should return 400 for invalid name' do
+ it 'returns 400 for invalid name' do
post api("/projects/#{project.id}/labels", user),
name: ',',
color: '#FFAABB'
@@ -77,7 +77,7 @@ describe API::API, api: true do
expect(json_response['message']['title']).to eq(['is invalid'])
end
- it 'should return 409 if label already exists' do
+ it 'returns 409 if label already exists' do
post api("/projects/#{project.id}/labels", user),
name: 'label1',
color: '#FFAABB'
@@ -87,25 +87,25 @@ describe API::API, api: true do
end
describe 'DELETE /projects/:id/labels' do
- it 'should return 200 for existing label' do
+ it 'returns 200 for existing label' do
delete api("/projects/#{project.id}/labels", user), name: 'label1'
expect(response).to have_http_status(200)
end
- it 'should return 404 for non existing label' do
+ it 'returns 404 for non existing label' do
delete api("/projects/#{project.id}/labels", user), name: 'label2'
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Label Not Found')
end
- it 'should return 400 for wrong parameters' do
+ it 'returns 400 for wrong parameters' do
delete api("/projects/#{project.id}/labels", user)
expect(response).to have_http_status(400)
end
end
describe 'PUT /projects/:id/labels' do
- it 'should return 200 if name and colors and description are changed' do
+ it 'returns 200 if name and colors and description are changed' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
new_name: 'New Label',
@@ -117,7 +117,7 @@ describe API::API, api: true do
expect(json_response['description']).to eq('test')
end
- it 'should return 200 if name is changed' do
+ it 'returns 200 if name is changed' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
new_name: 'New Label'
@@ -126,7 +126,7 @@ describe API::API, api: true do
expect(json_response['color']).to eq(label1.color)
end
- it 'should return 200 if colors is changed' do
+ it 'returns 200 if colors is changed' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
color: '#FFFFFF'
@@ -135,7 +135,7 @@ describe API::API, api: true do
expect(json_response['color']).to eq('#FFFFFF')
end
- it 'should return 200 if description is changed' do
+ it 'returns 200 if description is changed' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
description: 'test'
@@ -144,27 +144,27 @@ describe API::API, api: true do
expect(json_response['description']).to eq('test')
end
- it 'should return 404 if label does not exist' do
+ it 'returns 404 if label does not exist' do
put api("/projects/#{project.id}/labels", user),
name: 'label2',
new_name: 'label3'
expect(response).to have_http_status(404)
end
- it 'should return 400 if no label name given' do
+ it 'returns 400 if no label name given' do
put api("/projects/#{project.id}/labels", user), new_name: 'label2'
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "name" not given')
end
- it 'should return 400 if no new parameters given' do
+ it 'returns 400 if no new parameters given' do
put api("/projects/#{project.id}/labels", user), name: 'label1'
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('Required parameters '\
'"new_name" or "color" missing')
end
- it 'should return 400 for invalid name' do
+ it 'returns 400 for invalid name' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
new_name: ',',
@@ -173,7 +173,7 @@ describe API::API, api: true do
expect(json_response['message']['title']).to eq(['is invalid'])
end
- it 'should return 400 when color code is too short' do
+ it 'returns 400 when color code is too short' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
color: '#FF'
@@ -181,7 +181,7 @@ describe API::API, api: true do
expect(json_response['message']['color']).to eq(['must be a valid color code'])
end
- it 'should return 400 for too long color code' do
+ it 'returns 400 for too long color code' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAAFFFF'
@@ -192,7 +192,7 @@ describe API::API, api: true do
describe "POST /projects/:id/labels/:label_id/subscription" do
context "when label_id is a label title" do
- it "should subscribe to the label" do
+ it "subscribes to the label" do
post api("/projects/#{project.id}/labels/#{label1.title}/subscription", user)
expect(response).to have_http_status(201)
@@ -202,7 +202,7 @@ describe API::API, api: true do
end
context "when label_id is a label ID" do
- it "should subscribe to the label" do
+ it "subscribes to the label" do
post api("/projects/#{project.id}/labels/#{label1.id}/subscription", user)
expect(response).to have_http_status(201)
@@ -214,7 +214,7 @@ describe API::API, api: true do
context "when user is already subscribed to label" do
before { label1.subscribe(user) }
- it "should return 304" do
+ it "returns 304" do
post api("/projects/#{project.id}/labels/#{label1.id}/subscription", user)
expect(response).to have_http_status(304)
@@ -222,7 +222,7 @@ describe API::API, api: true do
end
context "when label ID is not found" do
- it "should a return 404 error" do
+ it "returns 404 error" do
post api("/projects/#{project.id}/labels/1234/subscription", user)
expect(response).to have_http_status(404)
@@ -234,7 +234,7 @@ describe API::API, api: true do
before { label1.subscribe(user) }
context "when label_id is a label title" do
- it "should unsubscribe from the label" do
+ it "unsubscribes from the label" do
delete api("/projects/#{project.id}/labels/#{label1.title}/subscription", user)
expect(response).to have_http_status(200)
@@ -244,7 +244,7 @@ describe API::API, api: true do
end
context "when label_id is a label ID" do
- it "should unsubscribe from the label" do
+ it "unsubscribes from the label" do
delete api("/projects/#{project.id}/labels/#{label1.id}/subscription", user)
expect(response).to have_http_status(200)
@@ -256,7 +256,7 @@ describe API::API, api: true do
context "when user is already unsubscribed from label" do
before { label1.unsubscribe(user) }
- it "should return 304" do
+ it "returns 304" do
delete api("/projects/#{project.id}/labels/#{label1.id}/subscription", user)
expect(response).to have_http_status(304)
@@ -264,7 +264,7 @@ describe API::API, api: true do
end
context "when label ID is not found" do
- it "should a return 404 error" do
+ it "returns 404 error" do
delete api("/projects/#{project.id}/labels/1234/subscription", user)
expect(response).to have_http_status(404)
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 651b91e9f68..617600d6173 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -20,14 +20,14 @@ describe API::API, api: true do
describe "GET /projects/:id/merge_requests" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/projects/#{project.id}/merge_requests")
expect(response).to have_http_status(401)
end
end
context "when authenticated" do
- it "should return an array of all merge_requests" do
+ it "returns an array of all merge_requests" do
get api("/projects/#{project.id}/merge_requests", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -35,7 +35,7 @@ describe API::API, api: true do
expect(json_response.last['title']).to eq(merge_request.title)
end
- it "should return an array of all merge_requests" do
+ it "returns an array of all merge_requests" do
get api("/projects/#{project.id}/merge_requests?state", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -43,7 +43,7 @@ describe API::API, api: true do
expect(json_response.last['title']).to eq(merge_request.title)
end
- it "should return an array of open merge_requests" do
+ it "returns an array of open merge_requests" do
get api("/projects/#{project.id}/merge_requests?state=opened", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -51,7 +51,7 @@ describe API::API, api: true do
expect(json_response.last['title']).to eq(merge_request.title)
end
- it "should return an array of closed merge_requests" do
+ it "returns an array of closed merge_requests" do
get api("/projects/#{project.id}/merge_requests?state=closed", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -59,7 +59,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(merge_request_closed.title)
end
- it "should return an array of merged merge_requests" do
+ it "returns an array of merged merge_requests" do
get api("/projects/#{project.id}/merge_requests?state=merged", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -73,7 +73,7 @@ describe API::API, api: true do
@mr_earlier = mr_with_earlier_created_and_updated_at_time
end
- it "should return an array of merge_requests in ascending order" do
+ it "returns an array of merge_requests in ascending order" do
get api("/projects/#{project.id}/merge_requests?sort=asc", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -82,7 +82,7 @@ describe API::API, api: true do
expect(response_dates).to eq(response_dates.sort)
end
- it "should return an array of merge_requests in descending order" do
+ it "returns an array of merge_requests in descending order" do
get api("/projects/#{project.id}/merge_requests?sort=desc", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -91,7 +91,7 @@ describe API::API, api: true do
expect(response_dates).to eq(response_dates.sort.reverse)
end
- it "should return an array of merge_requests ordered by updated_at" do
+ it "returns an array of merge_requests ordered by updated_at" do
get api("/projects/#{project.id}/merge_requests?order_by=updated_at", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -100,7 +100,7 @@ describe API::API, api: true do
expect(response_dates).to eq(response_dates.sort.reverse)
end
- it "should return an array of merge_requests ordered by created_at" do
+ it "returns an array of merge_requests ordered by created_at" do
get api("/projects/#{project.id}/merge_requests?order_by=created_at&sort=asc", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -142,7 +142,7 @@ describe API::API, api: true do
expect(json_response['force_close_merge_request']).to be_falsy
end
- it "should return merge_request" do
+ it "returns merge_request" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(merge_request.title)
@@ -153,7 +153,7 @@ describe API::API, api: true do
expect(json_response['force_close_merge_request']).to be_falsy
end
- it 'should return merge_request by iid' do
+ it 'returns merge_request by iid' do
url = "/projects/#{project.id}/merge_requests?iid=#{merge_request.iid}"
get api(url, user)
expect(response.status).to eq 200
@@ -161,7 +161,7 @@ describe API::API, api: true do
expect(json_response.first['id']).to eq merge_request.id
end
- it "should return a 404 error if merge_request_id not found" do
+ it "returns a 404 error if merge_request_id not found" do
get api("/projects/#{project.id}/merge_requests/999", user)
expect(response).to have_http_status(404)
end
@@ -169,7 +169,7 @@ describe API::API, api: true do
context 'Work in Progress' do
let!(:merge_request_wip) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "WIP: Test", created_at: base_time + 1.second) }
- it "should return merge_request" do
+ it "returns merge_request" do
get api("/projects/#{project.id}/merge_requests/#{merge_request_wip.id}", user)
expect(response).to have_http_status(200)
expect(json_response['work_in_progress']).to eq(true)
@@ -195,7 +195,7 @@ describe API::API, api: true do
end
describe 'GET /projects/:id/merge_requests/:merge_request_id/changes' do
- it 'should return the change information of the merge_request' do
+ it 'returns the change information of the merge_request' do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/changes", user)
expect(response.status).to eq 200
expect(json_response['changes'].size).to eq(merge_request.diffs.size)
@@ -209,7 +209,7 @@ describe API::API, api: true do
describe "POST /projects/:id/merge_requests" do
context 'between branches projects' do
- it "should return merge_request" do
+ it "returns merge_request" do
post api("/projects/#{project.id}/merge_requests", user),
title: 'Test merge_request',
source_branch: 'feature_conflict',
@@ -223,31 +223,31 @@ describe API::API, api: true do
expect(json_response['milestone']['id']).to eq(milestone.id)
end
- it "should return 422 when source_branch equals target_branch" do
+ it "returns 422 when source_branch equals target_branch" do
post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", source_branch: "master", target_branch: "master", author: user
expect(response).to have_http_status(422)
end
- it "should return 400 when source_branch is missing" do
+ it "returns 400 when source_branch is missing" do
post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", target_branch: "master", author: user
expect(response).to have_http_status(400)
end
- it "should return 400 when target_branch is missing" do
+ it "returns 400 when target_branch is missing" do
post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", source_branch: "markdown", author: user
expect(response).to have_http_status(400)
end
- it "should return 400 when title is missing" do
+ it "returns 400 when title is missing" do
post api("/projects/#{project.id}/merge_requests", user),
target_branch: 'master', source_branch: 'markdown'
expect(response).to have_http_status(400)
end
- it 'should allow special label names' do
+ it 'allows special label names' do
post api("/projects/#{project.id}/merge_requests", user),
title: 'Test merge_request',
source_branch: 'markdown',
@@ -272,7 +272,7 @@ describe API::API, api: true do
@mr = MergeRequest.all.last
end
- it 'should return 409 when MR already exists for source/target' do
+ it 'returns 409 when MR already exists for source/target' do
expect do
post api("/projects/#{project.id}/merge_requests", user),
title: 'New test merge_request',
@@ -294,7 +294,7 @@ describe API::API, api: true do
fork_project.team << [user2, :reporters]
end
- it "should return merge_request" do
+ it "returns merge_request" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', source_branch: "feature_conflict", target_branch: "master",
author: user2, target_project_id: project.id, description: 'Test description for Test merge_request'
@@ -303,7 +303,7 @@ describe API::API, api: true do
expect(json_response['description']).to eq('Test description for Test merge_request')
end
- it "should not return 422 when source_branch equals target_branch" do
+ it "does not return 422 when source_branch equals target_branch" do
expect(project.id).not_to eq(fork_project.id)
expect(fork_project.forked?).to be_truthy
expect(fork_project.forked_from_project).to eq(project)
@@ -313,26 +313,26 @@ describe API::API, api: true do
expect(json_response['title']).to eq('Test merge_request')
end
- it "should return 400 when source_branch is missing" do
+ it "returns 400 when source_branch is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id
expect(response).to have_http_status(400)
end
- it "should return 400 when target_branch is missing" do
+ it "returns 400 when target_branch is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id
expect(response).to have_http_status(400)
end
- it "should return 400 when title is missing" do
+ it "returns 400 when title is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: project.id
expect(response).to have_http_status(400)
end
context 'when target_branch is specified' do
- it 'should return 422 if not a forked project' do
+ it 'returns 422 if not a forked project' do
post api("/projects/#{project.id}/merge_requests", user),
title: 'Test merge_request',
target_branch: 'master',
@@ -342,7 +342,7 @@ describe API::API, api: true do
expect(response).to have_http_status(422)
end
- it 'should return 422 if targeting a different fork' do
+ it 'returns 422 if targeting a different fork' do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request',
target_branch: 'master',
@@ -353,7 +353,7 @@ describe API::API, api: true do
end
end
- it "should return 201 when target_branch is specified and for the same project" do
+ it "returns 201 when target_branch is specified and for the same project" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: fork_project.id
expect(response).to have_http_status(201)
@@ -385,7 +385,7 @@ describe API::API, api: true do
end
describe "PUT /projects/:id/merge_requests/:merge_request_id to close MR" do
- it "should return merge_request" do
+ it "returns merge_request" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), state_event: "close"
expect(response).to have_http_status(200)
expect(json_response['state']).to eq('closed')
@@ -395,13 +395,13 @@ describe API::API, api: true do
describe "PUT /projects/:id/merge_requests/:merge_request_id/merge" do
let(:pipeline) { create(:ci_pipeline_without_jobs) }
- it "should return merge_request in case of success" do
+ it "returns merge_request in case of success" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user)
expect(response).to have_http_status(200)
end
- it "should return 406 if branch can't be merged" do
+ it "returns 406 if branch can't be merged" do
allow_any_instance_of(MergeRequest).
to receive(:can_be_merged?).and_return(false)
@@ -411,14 +411,14 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Branch cannot be merged')
end
- it "should return 405 if merge_request is not open" do
+ it "returns 405 if merge_request is not open" do
merge_request.close
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user)
expect(response).to have_http_status(405)
expect(json_response['message']).to eq('405 Method Not Allowed')
end
- it "should return 405 if merge_request is a work in progress" do
+ it "returns 405 if merge_request is a work in progress" do
merge_request.update_attribute(:title, "WIP: #{merge_request.title}")
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user)
expect(response).to have_http_status(405)
@@ -434,7 +434,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('405 Method Not Allowed')
end
- it "should return 401 if user has no permissions to merge" do
+ it "returns 401 if user has no permissions to merge" do
user2 = create(:user)
project.team << [user2, :reporter]
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user2)
@@ -486,19 +486,19 @@ describe API::API, api: true do
expect(json_response['milestone']['id']).to eq(milestone.id)
end
- it "should return 400 when source_branch is specified" do
+ it "returns 400 when source_branch is specified" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user),
source_branch: "master", target_branch: "master"
expect(response).to have_http_status(400)
end
- it "should return merge_request with renamed target_branch" do
+ it "returns merge_request with renamed target_branch" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), target_branch: "wiki"
expect(response).to have_http_status(200)
expect(json_response['target_branch']).to eq('wiki')
end
- it 'should allow special label names' do
+ it 'allows special label names' do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}",
user),
title: 'new issue',
@@ -513,7 +513,7 @@ describe API::API, api: true do
end
describe "POST /projects/:id/merge_requests/:merge_request_id/comments" do
- it "should return comment" do
+ it "returns comment" do
original_count = merge_request.notes.size
post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user), note: "My comment"
@@ -524,12 +524,12 @@ describe API::API, api: true do
expect(merge_request.notes.size).to eq(original_count + 1)
end
- it "should return 400 if note is missing" do
+ it "returns 400 if note is missing" do
post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user)
expect(response).to have_http_status(400)
end
- it "should return 404 if note is attached to non existent merge request" do
+ it "returns 404 if note is attached to non existent merge request" do
post api("/projects/#{project.id}/merge_requests/404/comments", user),
note: 'My comment'
expect(response).to have_http_status(404)
@@ -537,7 +537,7 @@ describe API::API, api: true do
end
describe "GET :id/merge_requests/:merge_request_id/comments" do
- it "should return merge_request comments ordered by created_at" do
+ it "returns merge_request comments ordered by created_at" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -547,7 +547,7 @@ describe API::API, api: true do
expect(json_response.last['note']).to eq("another comment on a MR")
end
- it "should return a 404 error if merge_request_id not found" do
+ it "returns a 404 error if merge_request_id not found" do
get api("/projects/#{project.id}/merge_requests/999/comments", user)
expect(response).to have_http_status(404)
end
diff --git a/spec/requests/api/milestones_spec.rb b/spec/requests/api/milestones_spec.rb
index 0f4e38b2475..d6a0c656e74 100644
--- a/spec/requests/api/milestones_spec.rb
+++ b/spec/requests/api/milestones_spec.rb
@@ -10,14 +10,14 @@ describe API::API, api: true do
before { project.team << [user, :developer] }
describe 'GET /projects/:id/milestones' do
- it 'should return project milestones' do
+ it 'returns project milestones' do
get api("/projects/#{project.id}/milestones", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(milestone.title)
end
- it 'should return a 401 error if user not authenticated' do
+ it 'returns a 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones")
expect(response).to have_http_status(401)
end
@@ -42,14 +42,14 @@ describe API::API, api: true do
end
describe 'GET /projects/:id/milestones/:milestone_id' do
- it 'should return a project milestone by id' do
+ it 'returns a project milestone by id' do
get api("/projects/#{project.id}/milestones/#{milestone.id}", user)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(milestone.title)
expect(json_response['iid']).to eq(milestone.iid)
end
- it 'should return a project milestone by iid' do
+ it 'returns a project milestone by iid' do
get api("/projects/#{project.id}/milestones?iid=#{closed_milestone.iid}", user)
expect(response.status).to eq 200
@@ -58,26 +58,26 @@ describe API::API, api: true do
expect(json_response.first['id']).to eq closed_milestone.id
end
- it 'should return 401 error if user not authenticated' do
+ it 'returns 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones/#{milestone.id}")
expect(response).to have_http_status(401)
end
- it 'should return a 404 error if milestone id not found' do
+ it 'returns a 404 error if milestone id not found' do
get api("/projects/#{project.id}/milestones/1234", user)
expect(response).to have_http_status(404)
end
end
describe 'POST /projects/:id/milestones' do
- it 'should create a new project milestone' do
+ it 'creates a new project milestone' do
post api("/projects/#{project.id}/milestones", user), title: 'new milestone'
expect(response).to have_http_status(201)
expect(json_response['title']).to eq('new milestone')
expect(json_response['description']).to be_nil
end
- it 'should create a new project milestone with description and due date' do
+ it 'creates a new project milestone with description and due date' do
post api("/projects/#{project.id}/milestones", user),
title: 'new milestone', description: 'release', due_date: '2013-03-02'
expect(response).to have_http_status(201)
@@ -85,21 +85,21 @@ describe API::API, api: true do
expect(json_response['due_date']).to eq('2013-03-02')
end
- it 'should return a 400 error if title is missing' do
+ it 'returns a 400 error if title is missing' do
post api("/projects/#{project.id}/milestones", user)
expect(response).to have_http_status(400)
end
end
describe 'PUT /projects/:id/milestones/:milestone_id' do
- it 'should update a project milestone' do
+ it 'updates a project milestone' do
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
title: 'updated title'
expect(response).to have_http_status(200)
expect(json_response['title']).to eq('updated title')
end
- it 'should return a 404 error if milestone id not found' do
+ it 'returns a 404 error if milestone id not found' do
put api("/projects/#{project.id}/milestones/1234", user),
title: 'updated title'
expect(response).to have_http_status(404)
@@ -107,7 +107,7 @@ describe API::API, api: true do
end
describe 'PUT /projects/:id/milestones/:milestone_id to close milestone' do
- it 'should update a project milestone' do
+ it 'updates a project milestone' do
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
state_event: 'close'
expect(response).to have_http_status(200)
@@ -117,7 +117,7 @@ describe API::API, api: true do
end
describe 'PUT /projects/:id/milestones/:milestone_id to test observer on close' do
- it 'should create an activity event when an milestone is closed' do
+ it 'creates an activity event when an milestone is closed' do
expect(Event).to receive(:create)
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
@@ -129,14 +129,14 @@ describe API::API, api: true do
before do
milestone.issues << create(:issue, project: project)
end
- it 'should return project issues for a particular milestone' do
+ it 'returns project issues for a particular milestone' do
get api("/projects/#{project.id}/milestones/#{milestone.id}/issues", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.first['milestone']['title']).to eq(milestone.title)
end
- it 'should return a 401 error if user not authenticated' do
+ it 'returns a 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones/#{milestone.id}/issues")
expect(response).to have_http_status(401)
end
diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb
index 237b4b17eb5..5347cf4f7bc 100644
--- a/spec/requests/api/namespaces_spec.rb
+++ b/spec/requests/api/namespaces_spec.rb
@@ -9,14 +9,14 @@ describe API::API, api: true do
describe "GET /namespaces" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/namespaces")
expect(response).to have_http_status(401)
end
end
context "when authenticated as admin" do
- it "admin: should return an array of all namespaces" do
+ it "admin: returns an array of all namespaces" do
get api("/namespaces", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -24,7 +24,7 @@ describe API::API, api: true do
expect(json_response.length).to eq(Namespace.count)
end
- it "admin: should return an array of matched namespaces" do
+ it "admin: returns an array of matched namespaces" do
get api("/namespaces?search=#{group1.name}", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -34,7 +34,7 @@ describe API::API, api: true do
end
context "when authenticated as a regular user" do
- it "user: should return an array of namespaces" do
+ it "user: returns an array of namespaces" do
get api("/namespaces", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -42,7 +42,7 @@ describe API::API, api: true do
expect(json_response.length).to eq(1)
end
- it "admin: should return an array of matched namespaces" do
+ it "admin: returns an array of matched namespaces" do
get api("/namespaces?search=#{user.username}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb
index 65c53211dd3..737fa14cbb0 100644
--- a/spec/requests/api/notes_spec.rb
+++ b/spec/requests/api/notes_spec.rb
@@ -37,7 +37,7 @@ describe API::API, api: true do
end
context "when noteable is an Issue" do
- it "should return an array of issue notes" do
+ it "returns an array of issue notes" do
get api("/projects/#{project.id}/issues/#{issue.id}/notes", user)
expect(response).to have_http_status(200)
@@ -45,14 +45,14 @@ describe API::API, api: true do
expect(json_response.first['body']).to eq(issue_note.note)
end
- it "should return a 404 error when issue id not found" do
+ it "returns a 404 error when issue id not found" do
get api("/projects/#{project.id}/issues/12345/notes", user)
expect(response).to have_http_status(404)
end
context "and current user cannot view the notes" do
- it "should return an empty array" do
+ it "returns an empty array" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes", user)
expect(response).to have_http_status(200)
@@ -71,7 +71,7 @@ describe API::API, api: true do
end
context "and current user can view the note" do
- it "should return an empty array" do
+ it "returns an empty array" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes", private_user)
expect(response).to have_http_status(200)
@@ -83,7 +83,7 @@ describe API::API, api: true do
end
context "when noteable is a Snippet" do
- it "should return an array of snippet notes" do
+ it "returns an array of snippet notes" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user)
expect(response).to have_http_status(200)
@@ -91,7 +91,7 @@ describe API::API, api: true do
expect(json_response.first['body']).to eq(snippet_note.note)
end
- it "should return a 404 error when snippet id not found" do
+ it "returns a 404 error when snippet id not found" do
get api("/projects/#{project.id}/snippets/42/notes", user)
expect(response).to have_http_status(404)
@@ -105,7 +105,7 @@ describe API::API, api: true do
end
context "when noteable is a Merge Request" do
- it "should return an array of merge_requests notes" do
+ it "returns an array of merge_requests notes" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/notes", user)
expect(response).to have_http_status(200)
@@ -113,7 +113,7 @@ describe API::API, api: true do
expect(json_response.first['body']).to eq(merge_request_note.note)
end
- it "should return a 404 error if merge request id not found" do
+ it "returns a 404 error if merge request id not found" do
get api("/projects/#{project.id}/merge_requests/4444/notes", user)
expect(response).to have_http_status(404)
@@ -129,21 +129,21 @@ describe API::API, api: true do
describe "GET /projects/:id/noteable/:noteable_id/notes/:note_id" do
context "when noteable is an Issue" do
- it "should return an issue note by id" do
+ it "returns an issue note by id" do
get api("/projects/#{project.id}/issues/#{issue.id}/notes/#{issue_note.id}", user)
expect(response).to have_http_status(200)
expect(json_response['body']).to eq(issue_note.note)
end
- it "should return a 404 error if issue note not found" do
+ it "returns a 404 error if issue note not found" do
get api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user)
expect(response).to have_http_status(404)
end
context "and current user cannot view the note" do
- it "should return a 404 error" do
+ it "returns a 404 error" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes/#{cross_reference_note.id}", user)
expect(response).to have_http_status(404)
@@ -160,7 +160,7 @@ describe API::API, api: true do
end
context "and current user can view the note" do
- it "should return an issue note by id" do
+ it "returns an issue note by id" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes/#{cross_reference_note.id}", private_user)
expect(response).to have_http_status(200)
@@ -171,14 +171,14 @@ describe API::API, api: true do
end
context "when noteable is a Snippet" do
- it "should return a snippet note by id" do
+ it "returns a snippet note by id" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/notes/#{snippet_note.id}", user)
expect(response).to have_http_status(200)
expect(json_response['body']).to eq(snippet_note.note)
end
- it "should return a 404 error if snippet note not found" do
+ it "returns a 404 error if snippet note not found" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/notes/12345", user)
expect(response).to have_http_status(404)
@@ -188,7 +188,7 @@ describe API::API, api: true do
describe "POST /projects/:id/noteable/:noteable_id/notes" do
context "when noteable is an Issue" do
- it "should create a new issue note" do
+ it "creates a new issue note" do
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!'
expect(response).to have_http_status(201)
@@ -196,13 +196,13 @@ describe API::API, api: true do
expect(json_response['author']['username']).to eq(user.username)
end
- it "should return a 400 bad request error if body not given" do
+ it "returns a 400 bad request error if body not given" do
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user)
expect(response).to have_http_status(400)
end
- it "should return a 401 unauthorized error if user not authenticated" do
+ it "returns a 401 unauthorized error if user not authenticated" do
post api("/projects/#{project.id}/issues/#{issue.id}/notes"), body: 'hi!'
expect(response).to have_http_status(401)
@@ -223,7 +223,7 @@ describe API::API, api: true do
end
context "when noteable is a Snippet" do
- it "should create a new snippet note" do
+ it "creates a new snippet note" do
post api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user), body: 'hi!'
expect(response).to have_http_status(201)
@@ -231,13 +231,13 @@ describe API::API, api: true do
expect(json_response['author']['username']).to eq(user.username)
end
- it "should return a 400 bad request error if body not given" do
+ it "returns a 400 bad request error if body not given" do
post api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user)
expect(response).to have_http_status(400)
end
- it "should return a 401 unauthorized error if user not authenticated" do
+ it "returns a 401 unauthorized error if user not authenticated" do
post api("/projects/#{project.id}/snippets/#{snippet.id}/notes"), body: 'hi!'
expect(response).to have_http_status(401)
@@ -267,7 +267,7 @@ describe API::API, api: true do
end
describe "POST /projects/:id/noteable/:noteable_id/notes to test observer on create" do
- it "should create an activity event when an issue note is created" do
+ it "creates an activity event when an issue note is created" do
expect(Event).to receive(:create)
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!'
@@ -276,7 +276,7 @@ describe API::API, api: true do
describe 'PUT /projects/:id/noteable/:noteable_id/notes/:note_id' do
context 'when noteable is an Issue' do
- it 'should return modified note' do
+ it 'returns modified note' do
put api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user), body: 'Hello!'
@@ -284,14 +284,14 @@ describe API::API, api: true do
expect(json_response['body']).to eq('Hello!')
end
- it 'should return a 404 error when note id not found' do
+ it 'returns a 404 error when note id not found' do
put api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user),
body: 'Hello!'
expect(response).to have_http_status(404)
end
- it 'should return a 400 bad request error if body not given' do
+ it 'returns a 400 bad request error if body not given' do
put api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user)
@@ -300,7 +300,7 @@ describe API::API, api: true do
end
context 'when noteable is a Snippet' do
- it 'should return modified note' do
+ it 'returns modified note' do
put api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/#{snippet_note.id}", user), body: 'Hello!'
@@ -308,7 +308,7 @@ describe API::API, api: true do
expect(json_response['body']).to eq('Hello!')
end
- it 'should return a 404 error when note id not found' do
+ it 'returns a 404 error when note id not found' do
put api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/12345", user), body: "Hello!"
@@ -317,7 +317,7 @@ describe API::API, api: true do
end
context 'when noteable is a Merge Request' do
- it 'should return modified note' do
+ it 'returns modified note' do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
"notes/#{merge_request_note.id}", user), body: 'Hello!'
@@ -325,7 +325,7 @@ describe API::API, api: true do
expect(json_response['body']).to eq('Hello!')
end
- it 'should return a 404 error when note id not found' do
+ it 'returns a 404 error when note id not found' do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
"notes/12345", user), body: "Hello!"
diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb
index fd1fffa6223..34fac297923 100644
--- a/spec/requests/api/project_hooks_spec.rb
+++ b/spec/requests/api/project_hooks_spec.rb
@@ -20,7 +20,7 @@ describe API::API, 'ProjectHooks', api: true do
describe "GET /projects/:id/hooks" do
context "authorized user" do
- it "should return project hooks" do
+ it "returns project hooks" do
get api("/projects/#{project.id}/hooks", user)
expect(response).to have_http_status(200)
@@ -38,7 +38,7 @@ describe API::API, 'ProjectHooks', api: true do
end
context "unauthorized user" do
- it "should not access project hooks" do
+ it "does not access project hooks" do
get api("/projects/#{project.id}/hooks", user3)
expect(response).to have_http_status(403)
end
@@ -47,7 +47,7 @@ describe API::API, 'ProjectHooks', api: true do
describe "GET /projects/:id/hooks/:hook_id" do
context "authorized user" do
- it "should return a project hook" do
+ it "returns a project hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_http_status(200)
expect(json_response['url']).to eq(hook.url)
@@ -59,27 +59,27 @@ describe API::API, 'ProjectHooks', api: true do
expect(json_response['enable_ssl_verification']).to eq(hook.enable_ssl_verification)
end
- it "should return a 404 error if hook id is not available" do
+ it "returns a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user)
expect(response).to have_http_status(404)
end
end
context "unauthorized user" do
- it "should not access an existing hook" do
+ it "does not access an existing hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user3)
expect(response).to have_http_status(403)
end
end
- it "should return a 404 error if hook id is not available" do
+ it "returns a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user)
expect(response).to have_http_status(404)
end
end
describe "POST /projects/:id/hooks" do
- it "should add hook to project" do
+ it "adds hook to project" do
expect do
post api("/projects/#{project.id}/hooks", user), url: "http://example.com", issues_events: true
end.to change {project.hooks.count}.by(1)
@@ -94,19 +94,19 @@ describe API::API, 'ProjectHooks', api: true do
expect(json_response['enable_ssl_verification']).to eq(true)
end
- it "should return a 400 error if url not given" do
+ it "returns a 400 error if url not given" do
post api("/projects/#{project.id}/hooks", user)
expect(response).to have_http_status(400)
end
- it "should return a 422 error if url not valid" do
+ it "returns a 422 error if url not valid" do
post api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com"
expect(response).to have_http_status(422)
end
end
describe "PUT /projects/:id/hooks/:hook_id" do
- it "should update an existing project hook" do
+ it "updates an existing project hook" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user),
url: 'http://example.org', push_events: false
expect(response).to have_http_status(200)
@@ -119,46 +119,46 @@ describe API::API, 'ProjectHooks', api: true do
expect(json_response['enable_ssl_verification']).to eq(hook.enable_ssl_verification)
end
- it "should return 404 error if hook id not found" do
+ it "returns 404 error if hook id not found" do
put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org'
expect(response).to have_http_status(404)
end
- it "should return 400 error if url is not given" do
+ it "returns 400 error if url is not given" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_http_status(400)
end
- it "should return a 422 error if url is not valid" do
+ it "returns a 422 error if url is not valid" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com'
expect(response).to have_http_status(422)
end
end
describe "DELETE /projects/:id/hooks/:hook_id" do
- it "should delete hook from project" do
+ it "deletes hook from project" do
expect do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
end.to change {project.hooks.count}.by(-1)
expect(response).to have_http_status(200)
end
- it "should return success when deleting hook" do
+ it "returns success when deleting hook" do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_http_status(200)
end
- it "should return a 404 error when deleting non existent hook" do
+ it "returns a 404 error when deleting non existent hook" do
delete api("/projects/#{project.id}/hooks/42", user)
expect(response).to have_http_status(404)
end
- it "should return a 405 error if hook id not given" do
+ it "returns a 405 error if hook id not given" do
delete api("/projects/#{project.id}/hooks", user)
expect(response).to have_http_status(405)
end
- it "shold return a 404 if a user attempts to delete project hooks he/she does not own" do
+ it "returns a 404 if a user attempts to delete project hooks he/she does not own" do
test_user = create(:user)
other_project = create(:project)
other_project.team << [test_user, :master]
diff --git a/spec/requests/api/project_members_spec.rb b/spec/requests/api/project_members_spec.rb
index 9a7c1da4401..13cc0d81ac8 100644
--- a/spec/requests/api/project_members_spec.rb
+++ b/spec/requests/api/project_members_spec.rb
@@ -13,7 +13,7 @@ describe API::API, api: true do
before { project_member }
before { project_member2 }
- it "should return project team members" do
+ it "returns project team members" do
get api("/projects/#{project.id}/members", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -29,7 +29,7 @@ describe API::API, api: true do
expect(json_response.first['username']).to eq(user.username)
end
- it "should return a 404 error if id not found" do
+ it "returns a 404 error if id not found" do
get api("/projects/9999/members", user)
expect(response).to have_http_status(404)
end
@@ -38,21 +38,21 @@ describe API::API, api: true do
describe "GET /projects/:id/members/:user_id" do
before { project_member }
- it "should return project team member" do
+ it "returns project team member" do
get api("/projects/#{project.id}/members/#{user.id}", user)
expect(response).to have_http_status(200)
expect(json_response['username']).to eq(user.username)
expect(json_response['access_level']).to eq(ProjectMember::MASTER)
end
- it "should return a 404 error if user id not found" do
+ it "returns a 404 error if user id not found" do
get api("/projects/#{project.id}/members/1234", user)
expect(response).to have_http_status(404)
end
end
describe "POST /projects/:id/members" do
- it "should add user to project team" do
+ it "adds user to project team" do
expect do
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER
end.to change { ProjectMember.count }.by(1)
@@ -62,7 +62,7 @@ describe API::API, api: true do
expect(json_response['access_level']).to eq(ProjectMember::DEVELOPER)
end
- it "should return a 201 status if user is already project member" do
+ it "returns a 201 status if user is already project member" do
post api("/projects/#{project.id}/members", user),
user_id: user2.id,
access_level: ProjectMember::DEVELOPER
@@ -75,17 +75,17 @@ describe API::API, api: true do
expect(json_response['access_level']).to eq(ProjectMember::DEVELOPER)
end
- it "should return a 400 error when user id is not given" do
+ it "returns a 400 error when user id is not given" do
post api("/projects/#{project.id}/members", user), access_level: ProjectMember::MASTER
expect(response).to have_http_status(400)
end
- it "should return a 400 error when access level is not given" do
+ it "returns a 400 error when access level is not given" do
post api("/projects/#{project.id}/members", user), user_id: user2.id
expect(response).to have_http_status(400)
end
- it "should return a 422 error when access level is not known" do
+ it "returns a 422 error when access level is not known" do
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: 1234
expect(response).to have_http_status(422)
end
@@ -94,24 +94,24 @@ describe API::API, api: true do
describe "PUT /projects/:id/members/:user_id" do
before { project_member2 }
- it "should update project team member" do
+ it "updates project team member" do
put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: ProjectMember::MASTER
expect(response).to have_http_status(200)
expect(json_response['username']).to eq(user3.username)
expect(json_response['access_level']).to eq(ProjectMember::MASTER)
end
- it "should return a 404 error if user_id is not found" do
+ it "returns a 404 error if user_id is not found" do
put api("/projects/#{project.id}/members/1234", user), access_level: ProjectMember::MASTER
expect(response).to have_http_status(404)
end
- it "should return a 400 error when access level is not given" do
+ it "returns a 400 error when access level is not given" do
put api("/projects/#{project.id}/members/#{user3.id}", user)
expect(response).to have_http_status(400)
end
- it "should return a 422 error when access level is not known" do
+ it "returns a 422 error when access level is not known" do
put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: 123
expect(response).to have_http_status(422)
end
@@ -123,13 +123,13 @@ describe API::API, api: true do
project_member2
end
- it "should remove user from project team" do
+ it "removes user from project team" do
expect do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
end.to change { ProjectMember.count }.by(-1)
end
- it "should return 200 if team member is not part of a project" do
+ it "returns 200 if team member is not part of a project" do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
expect do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
@@ -137,13 +137,13 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it "should return 200 if team member already removed" do
+ it "returns 200 if team member already removed" do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
delete api("/projects/#{project.id}/members/#{user3.id}", user)
expect(response).to have_http_status(200)
end
- it "should return 200 OK when the user was not member" do
+ it "returns 200 OK when the user was not member" do
expect do
delete api("/projects/#{project.id}/members/1000000", user)
end.to change { ProjectMember.count }.by(0)
diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb
index 4ebde201941..42757ff21b0 100644
--- a/spec/requests/api/project_snippets_spec.rb
+++ b/spec/requests/api/project_snippets_spec.rb
@@ -17,7 +17,7 @@ describe API::API, api: true do
end
describe 'GET /projects/:project_id/snippets/' do
- it 'all snippets available to team member' do
+ it 'returns all snippets available to team member' do
project = create(:project, :public)
user = create(:user)
project.team << [user, :developer]
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 6b78326213b..4742b3d0e37 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -43,14 +43,14 @@ describe API::API, api: true do
before { project }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api('/projects')
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should return an array of projects' do
+ it 'returns an array of projects' do
get api('/projects', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -58,21 +58,21 @@ describe API::API, api: true do
expect(json_response.first['owner']['username']).to eq(user.username)
end
- it 'should include the project labels as the tag_list' do
+ it 'includes the project labels as the tag_list' do
get api('/projects', user)
expect(response.status).to eq 200
expect(json_response).to be_an Array
expect(json_response.first.keys).to include('tag_list')
end
- it 'should include open_issues_count' do
+ it 'includes open_issues_count' do
get api('/projects', user)
expect(response.status).to eq 200
expect(json_response).to be_an Array
expect(json_response.first.keys).to include('open_issues_count')
end
- it 'should not include open_issues_count' do
+ it 'does not include open_issues_count' do
project.update_attributes( { issues_enabled: false } )
get api('/projects', user)
@@ -94,7 +94,7 @@ describe API::API, api: true do
end
context 'and using search' do
- it 'should return searched project' do
+ it 'returns searched project' do
get api('/projects', user), { search: project.name }
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -103,21 +103,21 @@ describe API::API, api: true do
end
context 'and using the visibility filter' do
- it 'should filter based on private visibility param' do
+ it 'filters based on private visibility param' do
get api('/projects', user), { visibility: 'private' }
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::PRIVATE).count)
end
- it 'should filter based on internal visibility param' do
+ it 'filters based on internal visibility param' do
get api('/projects', user), { visibility: 'internal' }
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::INTERNAL).count)
end
- it 'should filter based on public visibility param' do
+ it 'filters based on public visibility param' do
get api('/projects', user), { visibility: 'public' }
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -131,7 +131,7 @@ describe API::API, api: true do
project3
end
- it 'should return the correct order when sorted by id' do
+ it 'returns the correct order when sorted by id' do
get api('/projects', user), { order_by: 'id', sort: 'desc' }
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -145,21 +145,21 @@ describe API::API, api: true do
before { project }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api('/projects/all')
expect(response).to have_http_status(401)
end
end
context 'when authenticated as regular user' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api('/projects/all', user)
expect(response).to have_http_status(403)
end
end
context 'when authenticated as admin' do
- it 'should return an array of all projects' do
+ it 'returns an array of all projects' do
get api('/projects/all', admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -183,7 +183,7 @@ describe API::API, api: true do
user3.update_attributes(starred_projects: [project, project2, project3, public_project])
end
- it 'should return the starred projects viewable by the user' do
+ it 'returns the starred projects viewable by the user' do
get api('/projects/starred', user3)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -193,7 +193,7 @@ describe API::API, api: true do
describe 'POST /projects' do
context 'maximum number of projects reached' do
- it 'should not create new project and respond with 403' do
+ it 'does not create new project and respond with 403' do
allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0)
expect { post api('/projects', user2), name: 'foo' }.
to change {Project.count}.by(0)
@@ -201,24 +201,24 @@ describe API::API, api: true do
end
end
- it 'should create new project without path and return 201' do
+ it 'creates new project without path and return 201' do
expect { post api('/projects', user), name: 'foo' }.
to change { Project.count }.by(1)
expect(response).to have_http_status(201)
end
- it 'should create last project before reaching project limit' do
+ it 'creates last project before reaching project limit' do
allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1)
post api('/projects', user2), name: 'foo'
expect(response).to have_http_status(201)
end
- it 'should not create new project without name and return 400' do
+ it 'does not create new project without name and return 400' do
expect { post api('/projects', user) }.not_to change { Project.count }
expect(response).to have_http_status(400)
end
- it "should assign attributes to project" do
+ it "assigns attributes to project" do
project = attributes_for(:project, {
path: 'camelCasePath',
description: FFaker::Lorem.sentence,
@@ -234,42 +234,42 @@ describe API::API, api: true do
end
end
- it 'should set a project as public' do
+ it 'sets a project as public' do
project = attributes_for(:project, :public)
post api('/projects', user), project
expect(json_response['public']).to be_truthy
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
- it 'should set a project as public using :public' do
+ it 'sets a project as public using :public' do
project = attributes_for(:project, { public: true })
post api('/projects', user), project
expect(json_response['public']).to be_truthy
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
- it 'should set a project as internal' do
+ it 'sets a project as internal' do
project = attributes_for(:project, :internal)
post api('/projects', user), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
- it 'should set a project as internal overriding :public' do
+ it 'sets a project as internal overriding :public' do
project = attributes_for(:project, :internal, { public: true })
post api('/projects', user), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
- it 'should set a project as private' do
+ it 'sets a project as private' do
project = attributes_for(:project, :private)
post api('/projects', user), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
- it 'should set a project as private using :public' do
+ it 'sets a project as private using :public' do
project = attributes_for(:project, { public: false })
post api('/projects', user), project
expect(json_response['public']).to be_falsey
@@ -282,7 +282,7 @@ describe API::API, api: true do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
end
- it 'should not allow a non-admin to use a restricted visibility level' do
+ it 'does not allow a non-admin to use a restricted visibility level' do
post api('/projects', user), @project
expect(response).to have_http_status(400)
@@ -291,7 +291,7 @@ describe API::API, api: true do
)
end
- it 'should allow an admin to override restricted visibility settings' do
+ it 'allows an admin to override restricted visibility settings' do
post api('/projects', admin), @project
expect(json_response['public']).to be_truthy
expect(json_response['visibility_level']).to(
@@ -310,7 +310,7 @@ describe API::API, api: true do
expect(response).to have_http_status(201)
end
- it 'should respond with 400 on failure and not project' do
+ it 'responds with 400 on failure and not project' do
expect { post api("/projects/user/#{user.id}", admin) }.
not_to change { Project.count }
@@ -327,7 +327,7 @@ describe API::API, api: true do
])
end
- it 'should assign attributes to project' do
+ it 'assigns attributes to project' do
project = attributes_for(:project, {
description: FFaker::Lorem.sentence,
issues_enabled: false,
@@ -343,42 +343,42 @@ describe API::API, api: true do
end
end
- it 'should set a project as public' do
+ it 'sets a project as public' do
project = attributes_for(:project, :public)
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_truthy
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
- it 'should set a project as public using :public' do
+ it 'sets a project as public using :public' do
project = attributes_for(:project, { public: true })
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_truthy
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
- it 'should set a project as internal' do
+ it 'sets a project as internal' do
project = attributes_for(:project, :internal)
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
- it 'should set a project as internal overriding :public' do
+ it 'sets a project as internal overriding :public' do
project = attributes_for(:project, :internal, { public: true })
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
- it 'should set a project as private' do
+ it 'sets a project as private' do
project = attributes_for(:project, :private)
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
- it 'should set a project as private using :public' do
+ it 'sets a project as private using :public' do
project = attributes_for(:project, { public: false })
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_falsey
@@ -446,25 +446,25 @@ describe API::API, api: true do
expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access)
end
- it 'should return a project by path name' do
+ it 'returns a project by path name' do
get api("/projects/#{project.id}", user)
expect(response).to have_http_status(200)
expect(json_response['name']).to eq(project.name)
end
- it 'should return a 404 error if not found' do
+ it 'returns a 404 error if not found' do
get api('/projects/42', user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found')
end
- it 'should return a 404 error if user is not a member' do
+ it 'returns a 404 error if user is not a member' do
other_user = create(:user)
get api("/projects/#{project.id}", other_user)
expect(response).to have_http_status(404)
end
- it 'should handle users with dots' do
+ it 'handles users with dots' do
dot_user = create(:user, username: 'dot.user')
project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace)
@@ -504,7 +504,7 @@ describe API::API, api: true do
before { project2.group.add_owner(user) }
- it 'should set the owner and return 200' do
+ it 'sets the owner and return 200' do
get api("/projects/#{project2.id}", user)
expect(response).to have_http_status(200)
@@ -545,13 +545,13 @@ describe API::API, api: true do
end
end
- it 'should return a 404 error if not found' do
+ it 'returns a 404 error if not found' do
get api('/projects/42/events', user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found')
end
- it 'should return a 404 error if user is not a member' do
+ it 'returns a 404 error if user is not a member' do
other_user = create(:user)
get api("/projects/#{project.id}/events", other_user)
expect(response).to have_http_status(404)
@@ -561,7 +561,7 @@ describe API::API, api: true do
describe 'GET /projects/:id/snippets' do
before { snippet }
- it 'should return an array of project snippets' do
+ it 'returns an array of project snippets' do
get api("/projects/#{project.id}/snippets", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -570,20 +570,20 @@ describe API::API, api: true do
end
describe 'GET /projects/:id/snippets/:snippet_id' do
- it 'should return a project snippet' do
+ it 'returns a project snippet' do
get api("/projects/#{project.id}/snippets/#{snippet.id}", user)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(snippet.title)
end
- it 'should return a 404 error if snippet id not found' do
+ it 'returns a 404 error if snippet id not found' do
get api("/projects/#{project.id}/snippets/1234", user)
expect(response).to have_http_status(404)
end
end
describe 'POST /projects/:id/snippets' do
- it 'should create a new project snippet' do
+ it 'creates a new project snippet' do
post api("/projects/#{project.id}/snippets", user),
title: 'api test', file_name: 'sample.rb', code: 'test',
visibility_level: '0'
@@ -591,14 +591,14 @@ describe API::API, api: true do
expect(json_response['title']).to eq('api test')
end
- it 'should return a 400 error if invalid snippet is given' do
+ it 'returns a 400 error if invalid snippet is given' do
post api("/projects/#{project.id}/snippets", user)
expect(status).to eq(400)
end
end
describe 'PUT /projects/:id/snippets/:snippet_id' do
- it 'should update an existing project snippet' do
+ it 'updates an existing project snippet' do
put api("/projects/#{project.id}/snippets/#{snippet.id}", user),
code: 'updated code'
expect(response).to have_http_status(200)
@@ -606,7 +606,7 @@ describe API::API, api: true do
expect(snippet.reload.content).to eq('updated code')
end
- it 'should update an existing project snippet with new title' do
+ it 'updates an existing project snippet with new title' do
put api("/projects/#{project.id}/snippets/#{snippet.id}", user),
title: 'other api test'
expect(response).to have_http_status(200)
@@ -617,31 +617,31 @@ describe API::API, api: true do
describe 'DELETE /projects/:id/snippets/:snippet_id' do
before { snippet }
- it 'should delete existing project snippet' do
+ it 'deletes existing project snippet' do
expect do
delete api("/projects/#{project.id}/snippets/#{snippet.id}", user)
end.to change { Snippet.count }.by(-1)
expect(response).to have_http_status(200)
end
- it 'should return 404 when deleting unknown snippet id' do
+ it 'returns 404 when deleting unknown snippet id' do
delete api("/projects/#{project.id}/snippets/1234", user)
expect(response).to have_http_status(404)
end
end
describe 'GET /projects/:id/snippets/:snippet_id/raw' do
- it 'should get a raw project snippet' do
+ it 'gets a raw project snippet' do
get api("/projects/#{project.id}/snippets/#{snippet.id}/raw", user)
expect(response).to have_http_status(200)
end
- it 'should return a 404 error if raw project snippet not found' do
+ it 'returns a 404 error if raw project snippet not found' do
get api("/projects/#{project.id}/snippets/5555/raw", user)
expect(response).to have_http_status(404)
end
end
-
+
describe :fork_admin do
let(:project_fork_target) { create(:project) }
let(:project_fork_source) { create(:project, :public) }
@@ -649,12 +649,12 @@ describe API::API, api: true do
describe 'POST /projects/:id/fork/:forked_from_id' do
let(:new_project_fork_source) { create(:project, :public) }
- it "shouldn't available for non admin users" do
+ it "is not available for non admin users" do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user)
expect(response).to have_http_status(403)
end
- it 'should allow project to be forked from an existing project' do
+ it 'allows project to be forked from an existing project' do
expect(project_fork_target.forked?).not_to be_truthy
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
expect(response).to have_http_status(201)
@@ -664,12 +664,12 @@ describe API::API, api: true do
expect(project_fork_target.forked?).to be_truthy
end
- it 'should fail if forked_from project which does not exist' do
+ it 'fails if forked_from project which does not exist' do
post api("/projects/#{project_fork_target.id}/fork/9999", admin)
expect(response).to have_http_status(404)
end
- it 'should fail with 409 if already forked' do
+ it 'fails with 409 if already forked' do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
project_fork_target.reload
expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id)
@@ -682,7 +682,7 @@ describe API::API, api: true do
end
describe 'DELETE /projects/:id/fork' do
- it "shouldn't be visible to users outside group" do
+ it "is not visible to users outside group" do
delete api("/projects/#{project_fork_target.id}/fork", user)
expect(response).to have_http_status(404)
end
@@ -695,12 +695,12 @@ describe API::API, api: true do
project_fork_target.group.add_developer user2
end
- it 'should be forbidden to non-owner users' do
+ it 'is forbidden to non-owner users' do
delete api("/projects/#{project_fork_target.id}/fork", user2)
expect(response).to have_http_status(403)
end
- it 'should make forked project unforked' do
+ it 'makes forked project unforked' do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
project_fork_target.reload
expect(project_fork_target.forked_from_project).not_to be_nil
@@ -712,7 +712,7 @@ describe API::API, api: true do
expect(project_fork_target.forked?).not_to be_truthy
end
- it 'should be idempotent if not forked' do
+ it 'is idempotent if not forked' do
expect(project_fork_target.forked_from_project).to be_nil
delete api("/projects/#{project_fork_target.id}/fork", admin)
expect(response).to have_http_status(200)
@@ -725,7 +725,7 @@ describe API::API, api: true do
describe "POST /projects/:id/share" do
let(:group) { create(:group) }
- it "should share project with group" do
+ it "shares project with group" do
expect do
post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER
end.to change { ProjectGroupLink.count }.by(1)
@@ -735,23 +735,23 @@ describe API::API, api: true do
expect(json_response['group_access']).to eq Gitlab::Access::DEVELOPER
end
- it "should return a 400 error when group id is not given" do
+ it "returns a 400 error when group id is not given" do
post api("/projects/#{project.id}/share", user), group_access: Gitlab::Access::DEVELOPER
expect(response.status).to eq 400
end
- it "should return a 400 error when access level is not given" do
+ it "returns a 400 error when access level is not given" do
post api("/projects/#{project.id}/share", user), group_id: group.id
expect(response.status).to eq 400
end
- it "should return a 400 error when sharing is disabled" do
+ it "returns a 400 error when sharing is disabled" do
project.namespace.update(share_with_group_lock: true)
post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER
expect(response.status).to eq 400
end
- it "should return a 409 error when wrong params passed" do
+ it "returns a 409 error when wrong params passed" do
post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: 1234
expect(response.status).to eq 409
expect(json_response['message']).to eq 'Group access is not included in the list'
@@ -771,14 +771,14 @@ describe API::API, api: true do
let!(:unfound_public) { create(:empty_project, :public, name: 'unfound public') }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api("/projects/search/#{query}")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should return an array of projects' do
+ it 'returns an array of projects' do
get api("/projects/search/#{query}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -788,7 +788,7 @@ describe API::API, api: true do
end
context 'when authenticated as a different user' do
- it 'should return matching public projects' do
+ it 'returns matching public projects' do
get api("/projects/search/#{query}", user2)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -809,7 +809,7 @@ describe API::API, api: true do
before { project_member2 }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
project_param = { name: 'bar' }
put api("/projects/#{project.id}"), project_param
expect(response).to have_http_status(401)
@@ -817,7 +817,7 @@ describe API::API, api: true do
end
context 'when authenticated as project owner' do
- it 'should update name' do
+ it 'updates name' do
project_param = { name: 'bar' }
put api("/projects/#{project.id}", user), project_param
expect(response).to have_http_status(200)
@@ -826,7 +826,7 @@ describe API::API, api: true do
end
end
- it 'should update visibility_level' do
+ it 'updates visibility_level' do
project_param = { visibility_level: 20 }
put api("/projects/#{project3.id}", user), project_param
expect(response).to have_http_status(200)
@@ -835,7 +835,7 @@ describe API::API, api: true do
end
end
- it 'should update visibility_level from public to private' do
+ it 'updates visibility_level from public to private' do
project3.update_attributes({ visibility_level: Gitlab::VisibilityLevel::PUBLIC })
project_param = { public: false }
@@ -847,14 +847,14 @@ describe API::API, api: true do
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
- it 'should not update name to existing name' do
+ it 'does not update name to existing name' do
project_param = { name: project3.name }
put api("/projects/#{project.id}", user), project_param
expect(response).to have_http_status(400)
expect(json_response['message']['name']).to eq(['has already been taken'])
end
- it 'should update path & name to existing path & name in different namespace' do
+ it 'updates path & name to existing path & name in different namespace' do
project_param = { path: project4.path, name: project4.name }
put api("/projects/#{project3.id}", user), project_param
expect(response).to have_http_status(200)
@@ -865,7 +865,7 @@ describe API::API, api: true do
end
context 'when authenticated as project master' do
- it 'should update path' do
+ it 'updates path' do
project_param = { path: 'bar' }
put api("/projects/#{project3.id}", user4), project_param
expect(response).to have_http_status(200)
@@ -874,7 +874,7 @@ describe API::API, api: true do
end
end
- it 'should update other attributes' do
+ it 'updates other attributes' do
project_param = { issues_enabled: true,
wiki_enabled: true,
snippets_enabled: true,
@@ -888,20 +888,20 @@ describe API::API, api: true do
end
end
- it 'should not update path to existing path' do
+ it 'does not update path to existing path' do
project_param = { path: project.path }
put api("/projects/#{project3.id}", user4), project_param
expect(response).to have_http_status(400)
expect(json_response['message']['path']).to eq(['has already been taken'])
end
- it 'should not update name' do
+ it 'does not update name' do
project_param = { name: 'bar' }
put api("/projects/#{project3.id}", user4), project_param
expect(response).to have_http_status(403)
end
- it 'should not update visibility_level' do
+ it 'does not update visibility_level' do
project_param = { visibility_level: 20 }
put api("/projects/#{project3.id}", user4), project_param
expect(response).to have_http_status(403)
@@ -909,7 +909,7 @@ describe API::API, api: true do
end
context 'when authenticated as project developer' do
- it 'should not update other attributes' do
+ it 'does not update other attributes' do
project_param = { path: 'bar',
issues_enabled: true,
wiki_enabled: true,
@@ -1044,36 +1044,36 @@ describe API::API, api: true do
describe 'DELETE /projects/:id' do
context 'when authenticated as user' do
- it 'should remove project' do
+ it 'removes project' do
delete api("/projects/#{project.id}", user)
expect(response).to have_http_status(200)
end
- it 'should not remove a project if not an owner' do
+ it 'does not remove a project if not an owner' do
user3 = create(:user)
project.team << [user3, :developer]
delete api("/projects/#{project.id}", user3)
expect(response).to have_http_status(403)
end
- it 'should not remove a non existing project' do
+ it 'does not remove a non existing project' do
delete api('/projects/1328', user)
expect(response).to have_http_status(404)
end
- it 'should not remove a project not attached to user' do
+ it 'does not remove a project not attached to user' do
delete api("/projects/#{project.id}", user2)
expect(response).to have_http_status(404)
end
end
context 'when authenticated as admin' do
- it 'should remove any existing project' do
+ it 'removes any existing project' do
delete api("/projects/#{project.id}", admin)
expect(response).to have_http_status(200)
end
- it 'should not remove a non existing project' do
+ it 'does not remove a non existing project' do
delete api('/projects/1328', admin)
expect(response).to have_http_status(404)
end
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index 5890e9c9d3d..80a856a6e90 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -16,7 +16,7 @@ describe API::API, api: true do
context "authorized user" do
before { project.team << [user2, :reporter] }
- it "should return project commits" do
+ it "returns project commits" do
get api("/projects/#{project.id}/repository/tree", user)
expect(response).to have_http_status(200)
@@ -26,7 +26,7 @@ describe API::API, api: true do
expect(json_response.first['mode']).to eq('040000')
end
- it 'should return a 404 for unknown ref' do
+ it 'returns a 404 for unknown ref' do
get api("/projects/#{project.id}/repository/tree?ref_name=foo", user)
expect(response).to have_http_status(404)
@@ -36,7 +36,7 @@ describe API::API, api: true do
end
context "unauthorized user" do
- it "should not return project commits" do
+ it "does not return project commits" do
get api("/projects/#{project.id}/repository/tree")
expect(response).to have_http_status(401)
end
@@ -44,41 +44,41 @@ describe API::API, api: true do
end
describe "GET /projects/:id/repository/blobs/:sha" do
- it "should get the raw file contents" do
+ it "gets the raw file contents" do
get api("/projects/#{project.id}/repository/blobs/master?filepath=README.md", user)
expect(response).to have_http_status(200)
end
- it "should return 404 for invalid branch_name" do
+ it "returns 404 for invalid branch_name" do
get api("/projects/#{project.id}/repository/blobs/invalid_branch_name?filepath=README.md", user)
expect(response).to have_http_status(404)
end
- it "should return 404 for invalid file" do
+ it "returns 404 for invalid file" do
get api("/projects/#{project.id}/repository/blobs/master?filepath=README.invalid", user)
expect(response).to have_http_status(404)
end
- it "should return a 400 error if filepath is missing" do
+ it "returns a 400 error if filepath is missing" do
get api("/projects/#{project.id}/repository/blobs/master", user)
expect(response).to have_http_status(400)
end
end
describe "GET /projects/:id/repository/commits/:sha/blob" do
- it "should get the raw file contents" do
+ it "gets the raw file contents" do
get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.md", user)
expect(response).to have_http_status(200)
end
end
describe "GET /projects/:id/repository/raw_blobs/:sha" do
- it "should get the raw file contents" do
+ it "gets the raw file contents" do
get api("/projects/#{project.id}/repository/raw_blobs/#{sample_blob.oid}", user)
expect(response).to have_http_status(200)
end
- it 'should return a 404 for unknown blob' do
+ it 'returns a 404 for unknown blob' do
get api("/projects/#{project.id}/repository/raw_blobs/123456", user)
expect(response).to have_http_status(404)
@@ -88,7 +88,7 @@ describe API::API, api: true do
end
describe "GET /projects/:id/repository/archive(.:format)?:sha" do
- it "should get the archive" do
+ it "gets the archive" do
get api("/projects/#{project.id}/repository/archive", user)
repo_name = project.repository.name.gsub("\.git", "")
expect(response).to have_http_status(200)
@@ -97,7 +97,7 @@ describe API::API, api: true do
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.tar.gz/)
end
- it "should get the archive.zip" do
+ it "gets the archive.zip" do
get api("/projects/#{project.id}/repository/archive.zip", user)
repo_name = project.repository.name.gsub("\.git", "")
expect(response).to have_http_status(200)
@@ -106,7 +106,7 @@ describe API::API, api: true do
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.zip/)
end
- it "should get the archive.tar.bz2" do
+ it "gets the archive.tar.bz2" do
get api("/projects/#{project.id}/repository/archive.tar.bz2", user)
repo_name = project.repository.name.gsub("\.git", "")
expect(response).to have_http_status(200)
@@ -115,28 +115,28 @@ describe API::API, api: true do
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.tar.bz2/)
end
- it "should return 404 for invalid sha" do
+ it "returns 404 for invalid sha" do
get api("/projects/#{project.id}/repository/archive/?sha=xxx", user)
expect(response).to have_http_status(404)
end
end
describe 'GET /projects/:id/repository/compare' do
- it "should compare branches" do
+ it "compares branches" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'feature'
expect(response).to have_http_status(200)
expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present
end
- it "should compare tags" do
+ it "compares tags" do
get api("/projects/#{project.id}/repository/compare", user), from: 'v1.0.0', to: 'v1.1.0'
expect(response).to have_http_status(200)
expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present
end
- it "should compare commits" do
+ it "compares commits" do
get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.id, to: sample_commit.parent_id
expect(response).to have_http_status(200)
expect(json_response['commits']).to be_empty
@@ -144,14 +144,14 @@ describe API::API, api: true do
expect(json_response['compare_same_ref']).to be_falsey
end
- it "should compare commits in reverse order" do
+ it "compares commits in reverse order" do
get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.parent_id, to: sample_commit.id
expect(response).to have_http_status(200)
expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present
end
- it "should compare same refs" do
+ it "compares same refs" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'master'
expect(response).to have_http_status(200)
expect(json_response['commits']).to be_empty
@@ -161,7 +161,7 @@ describe API::API, api: true do
end
describe 'GET /projects/:id/repository/contributors' do
- it 'should return valid data' do
+ it 'returns valid data' do
get api("/projects/#{project.id}/repository/contributors", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index 00a3c917b6a..f46f016135e 100644
--- a/spec/requests/api/runners_spec.rb
+++ b/spec/requests/api/runners_spec.rb
@@ -35,7 +35,7 @@ describe API::Runners, api: true do
describe 'GET /runners' do
context 'authorized user' do
- it 'should return user available runners' do
+ it 'returns user available runners' do
get api('/runners', user)
shared = json_response.any?{ |r| r['is_shared'] }
@@ -44,7 +44,7 @@ describe API::Runners, api: true do
expect(shared).to be_falsey
end
- it 'should filter runners by scope' do
+ it 'filters runners by scope' do
get api('/runners?scope=active', user)
shared = json_response.any?{ |r| r['is_shared'] }
@@ -53,14 +53,14 @@ describe API::Runners, api: true do
expect(shared).to be_falsey
end
- it 'should avoid filtering if scope is invalid' do
+ it 'avoids filtering if scope is invalid' do
get api('/runners?scope=unknown', user)
expect(response).to have_http_status(400)
end
end
context 'unauthorized user' do
- it 'should not return runners' do
+ it 'does not return runners' do
get api('/runners')
expect(response).to have_http_status(401)
@@ -71,7 +71,7 @@ describe API::Runners, api: true do
describe 'GET /runners/all' do
context 'authorized user' do
context 'with admin privileges' do
- it 'should return all runners' do
+ it 'returns all runners' do
get api('/runners/all', admin)
shared = json_response.any?{ |r| r['is_shared'] }
@@ -82,14 +82,14 @@ describe API::Runners, api: true do
end
context 'without admin privileges' do
- it 'should not return runners list' do
+ it 'does not return runners list' do
get api('/runners/all', user)
expect(response).to have_http_status(403)
end
end
- it 'should filter runners by scope' do
+ it 'filters runners by scope' do
get api('/runners/all?scope=specific', admin)
shared = json_response.any?{ |r| r['is_shared'] }
@@ -98,14 +98,14 @@ describe API::Runners, api: true do
expect(shared).to be_falsey
end
- it 'should avoid filtering if scope is invalid' do
+ it 'avoids filtering if scope is invalid' do
get api('/runners?scope=unknown', admin)
expect(response).to have_http_status(400)
end
end
context 'unauthorized user' do
- it 'should not return runners' do
+ it 'does not return runners' do
get api('/runners')
expect(response).to have_http_status(401)
@@ -116,7 +116,7 @@ describe API::Runners, api: true do
describe 'GET /runners/:id' do
context 'admin user' do
context 'when runner is shared' do
- it "should return runner's details" do
+ it "returns runner's details" do
get api("/runners/#{shared_runner.id}", admin)
expect(response).to have_http_status(200)
@@ -125,7 +125,7 @@ describe API::Runners, api: true do
end
context 'when runner is not shared' do
- it "should return runner's details" do
+ it "returns runner's details" do
get api("/runners/#{specific_runner.id}", admin)
expect(response).to have_http_status(200)
@@ -133,7 +133,7 @@ describe API::Runners, api: true do
end
end
- it 'should return 404 if runner does not exists' do
+ it 'returns 404 if runner does not exists' do
get api('/runners/9999', admin)
expect(response).to have_http_status(404)
@@ -142,7 +142,7 @@ describe API::Runners, api: true do
context "runner project's administrative user" do
context 'when runner is not shared' do
- it "should return runner's details" do
+ it "returns runner's details" do
get api("/runners/#{specific_runner.id}", user)
expect(response).to have_http_status(200)
@@ -151,7 +151,7 @@ describe API::Runners, api: true do
end
context 'when runner is shared' do
- it "should return runner's details" do
+ it "returns runner's details" do
get api("/runners/#{shared_runner.id}", user)
expect(response).to have_http_status(200)
@@ -161,7 +161,7 @@ describe API::Runners, api: true do
end
context 'other authorized user' do
- it "should not return runner's details" do
+ it "does not return runner's details" do
get api("/runners/#{specific_runner.id}", user2)
expect(response).to have_http_status(403)
@@ -169,7 +169,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it "should not return runner's details" do
+ it "does not return runner's details" do
get api("/runners/#{specific_runner.id}")
expect(response).to have_http_status(401)
@@ -180,7 +180,7 @@ describe API::Runners, api: true do
describe 'PUT /runners/:id' do
context 'admin user' do
context 'when runner is shared' do
- it 'should update runner' do
+ it 'updates runner' do
description = shared_runner.description
active = shared_runner.active
@@ -201,7 +201,7 @@ describe API::Runners, api: true do
end
context 'when runner is not shared' do
- it 'should update runner' do
+ it 'updates runner' do
description = specific_runner.description
update_runner(specific_runner.id, admin, description: 'test')
specific_runner.reload
@@ -212,7 +212,7 @@ describe API::Runners, api: true do
end
end
- it 'should return 404 if runner does not exists' do
+ it 'returns 404 if runner does not exists' do
update_runner(9999, admin, description: 'test')
expect(response).to have_http_status(404)
@@ -225,7 +225,7 @@ describe API::Runners, api: true do
context 'authorized user' do
context 'when runner is shared' do
- it 'should not update runner' do
+ it 'does not update runner' do
put api("/runners/#{shared_runner.id}", user)
expect(response).to have_http_status(403)
@@ -233,13 +233,13 @@ describe API::Runners, api: true do
end
context 'when runner is not shared' do
- it 'should not update runner without access to it' do
+ it 'does not update runner without access to it' do
put api("/runners/#{specific_runner.id}", user2)
expect(response).to have_http_status(403)
end
- it 'should update runner with access to it' do
+ it 'updates runner with access to it' do
description = specific_runner.description
put api("/runners/#{specific_runner.id}", admin), description: 'test'
specific_runner.reload
@@ -252,7 +252,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it 'should not delete runner' do
+ it 'does not delete runner' do
put api("/runners/#{specific_runner.id}")
expect(response).to have_http_status(401)
@@ -263,7 +263,7 @@ describe API::Runners, api: true do
describe 'DELETE /runners/:id' do
context 'admin user' do
context 'when runner is shared' do
- it 'should delete runner' do
+ it 'deletes runner' do
expect do
delete api("/runners/#{shared_runner.id}", admin)
end.to change{ Ci::Runner.shared.count }.by(-1)
@@ -272,14 +272,14 @@ describe API::Runners, api: true do
end
context 'when runner is not shared' do
- it 'should delete unused runner' do
+ it 'deletes unused runner' do
expect do
delete api("/runners/#{unused_specific_runner.id}", admin)
end.to change{ Ci::Runner.specific.count }.by(-1)
expect(response).to have_http_status(200)
end
- it 'should delete used runner' do
+ it 'deletes used runner' do
expect do
delete api("/runners/#{specific_runner.id}", admin)
end.to change{ Ci::Runner.specific.count }.by(-1)
@@ -287,7 +287,7 @@ describe API::Runners, api: true do
end
end
- it 'should return 404 if runner does not exists' do
+ it 'returns 404 if runner does not exists' do
delete api('/runners/9999', admin)
expect(response).to have_http_status(404)
@@ -296,24 +296,24 @@ describe API::Runners, api: true do
context 'authorized user' do
context 'when runner is shared' do
- it 'should not delete runner' do
+ it 'does not delete runner' do
delete api("/runners/#{shared_runner.id}", user)
expect(response).to have_http_status(403)
end
end
context 'when runner is not shared' do
- it 'should not delete runner without access to it' do
+ it 'does not delete runner without access to it' do
delete api("/runners/#{specific_runner.id}", user2)
expect(response).to have_http_status(403)
end
- it 'should not delete runner with more than one associated project' do
+ it 'does not delete runner with more than one associated project' do
delete api("/runners/#{two_projects_runner.id}", user)
expect(response).to have_http_status(403)
end
- it 'should delete runner for one owned project' do
+ it 'deletes runner for one owned project' do
expect do
delete api("/runners/#{specific_runner.id}", user)
end.to change{ Ci::Runner.specific.count }.by(-1)
@@ -323,7 +323,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it 'should not delete runner' do
+ it 'does not delete runner' do
delete api("/runners/#{specific_runner.id}")
expect(response).to have_http_status(401)
@@ -333,7 +333,7 @@ describe API::Runners, api: true do
describe 'GET /projects/:id/runners' do
context 'authorized user with master privileges' do
- it "should return project's runners" do
+ it "returns project's runners" do
get api("/projects/#{project.id}/runners", user)
shared = json_response.any?{ |r| r['is_shared'] }
@@ -344,7 +344,7 @@ describe API::Runners, api: true do
end
context 'authorized user without master privileges' do
- it "should not return project's runners" do
+ it "does not return project's runners" do
get api("/projects/#{project.id}/runners", user2)
expect(response).to have_http_status(403)
@@ -352,7 +352,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it "should not return project's runners" do
+ it "does not return project's runners" do
get api("/projects/#{project.id}/runners")
expect(response).to have_http_status(401)
@@ -368,21 +368,21 @@ describe API::Runners, api: true do
end
end
- it 'should enable specific runner' do
+ it 'enables specific runner' do
expect do
post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id
end.to change{ project.runners.count }.by(+1)
expect(response).to have_http_status(201)
end
- it 'should avoid changes when enabling already enabled runner' do
+ it 'avoids changes when enabling already enabled runner' do
expect do
post api("/projects/#{project.id}/runners", user), runner_id: specific_runner.id
end.to change{ project.runners.count }.by(0)
expect(response).to have_http_status(409)
end
- it 'should not enable locked runner' do
+ it 'does not enable locked runner' do
specific_runner2.update(locked: true)
expect do
@@ -392,14 +392,14 @@ describe API::Runners, api: true do
expect(response).to have_http_status(403)
end
- it 'should not enable shared runner' do
+ it 'does not enable shared runner' do
post api("/projects/#{project.id}/runners", user), runner_id: shared_runner.id
expect(response).to have_http_status(403)
end
context 'user is admin' do
- it 'should enable any specific runner' do
+ it 'enables any specific runner' do
expect do
post api("/projects/#{project.id}/runners", admin), runner_id: unused_specific_runner.id
end.to change{ project.runners.count }.by(+1)
@@ -408,14 +408,14 @@ describe API::Runners, api: true do
end
context 'user is not admin' do
- it 'should not enable runner without access to' do
+ it 'does not enable runner without access to' do
post api("/projects/#{project.id}/runners", user), runner_id: unused_specific_runner.id
expect(response).to have_http_status(403)
end
end
- it 'should raise an error when no runner_id param is provided' do
+ it 'raises an error when no runner_id param is provided' do
post api("/projects/#{project.id}/runners", admin)
expect(response).to have_http_status(400)
@@ -423,7 +423,7 @@ describe API::Runners, api: true do
end
context 'authorized user without permissions' do
- it 'should not enable runner' do
+ it 'does not enable runner' do
post api("/projects/#{project.id}/runners", user2)
expect(response).to have_http_status(403)
@@ -431,7 +431,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it 'should not enable runner' do
+ it 'does not enable runner' do
post api("/projects/#{project.id}/runners")
expect(response).to have_http_status(401)
@@ -442,7 +442,7 @@ describe API::Runners, api: true do
describe 'DELETE /projects/:id/runners/:runner_id' do
context 'authorized user' do
context 'when runner have more than one associated projects' do
- it "should disable project's runner" do
+ it "disables project's runner" do
expect do
delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user)
end.to change{ project.runners.count }.by(-1)
@@ -451,7 +451,7 @@ describe API::Runners, api: true do
end
context 'when runner have one associated projects' do
- it "should not disable project's runner" do
+ it "does not disable project's runner" do
expect do
delete api("/projects/#{project.id}/runners/#{specific_runner.id}", user)
end.to change{ project.runners.count }.by(0)
@@ -459,7 +459,7 @@ describe API::Runners, api: true do
end
end
- it 'should return 404 is runner is not found' do
+ it 'returns 404 is runner is not found' do
delete api("/projects/#{project.id}/runners/9999", user)
expect(response).to have_http_status(404)
@@ -467,7 +467,7 @@ describe API::Runners, api: true do
end
context 'authorized user without permissions' do
- it "should not disable project's runner" do
+ it "does not disable project's runner" do
delete api("/projects/#{project.id}/runners/#{specific_runner.id}", user2)
expect(response).to have_http_status(403)
@@ -475,7 +475,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it "should not disable project's runner" do
+ it "does not disable project's runner" do
delete api("/projects/#{project.id}/runners/#{specific_runner.id}")
expect(response).to have_http_status(401)
diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb
index a2446e12804..375671bca4c 100644
--- a/spec/requests/api/services_spec.rb
+++ b/spec/requests/api/services_spec.rb
@@ -11,13 +11,13 @@ describe API::API, api: true do
describe "PUT /projects/:id/services/#{service.dasherize}" do
include_context service
- it "should update #{service} settings" do
+ it "updates #{service} settings" do
put api("/projects/#{project.id}/services/#{dashed_service}", user), service_attrs
expect(response).to have_http_status(200)
end
- it "should return if required fields missing" do
+ it "returns if required fields missing" do
attrs = service_attrs
required_attributes = service_attrs_list.select do |attr|
@@ -32,7 +32,7 @@ describe API::API, api: true do
attrs.delete(required_attributes.sample)
expected_code = 400
end
-
+
put api("/projects/#{project.id}/services/#{dashed_service}", user), attrs
expect(response.status).to eq(expected_code)
@@ -42,7 +42,7 @@ describe API::API, api: true do
describe "DELETE /projects/:id/services/#{service.dasherize}" do
include_context service
- it "should delete #{service}" do
+ it "deletes #{service}" do
delete api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response).to have_http_status(200)
@@ -62,29 +62,29 @@ describe API::API, api: true do
service_object.save
end
- it 'should return authentication error when unauthenticated' do
+ it 'returns authentication error when unauthenticated' do
get api("/projects/#{project.id}/services/#{dashed_service}")
expect(response).to have_http_status(401)
end
-
- it "should return all properties of service #{service} when authenticated as admin" do
+
+ it "returns all properties of service #{service} when authenticated as admin" do
get api("/projects/#{project.id}/services/#{dashed_service}", admin)
-
+
expect(response).to have_http_status(200)
expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list.map)
end
- it "should return properties of service #{service} other than passwords when authenticated as project owner" do
+ it "returns properties of service #{service} other than passwords when authenticated as project owner" do
get api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response).to have_http_status(200)
expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list_without_passwords)
end
- it "should return error when authenticated but not a project owner" do
+ it "returns error when authenticated but not a project owner" do
project.team << [user2, :developer]
get api("/projects/#{project.id}/services/#{dashed_service}", user2)
-
+
expect(response).to have_http_status(403)
end
end
diff --git a/spec/requests/api/session_spec.rb b/spec/requests/api/session_spec.rb
index c15b7ff9792..519e7ce12ad 100644
--- a/spec/requests/api/session_spec.rb
+++ b/spec/requests/api/session_spec.rb
@@ -7,7 +7,7 @@ describe API::API, api: true do
describe "POST /session" do
context "when valid password" do
- it "should return private token" do
+ it "returns private token" do
post api("/session"), email: user.email, password: '12345678'
expect(response).to have_http_status(201)
@@ -20,7 +20,7 @@ describe API::API, api: true do
end
context 'when email has case-typo and password is valid' do
- it 'should return private token' do
+ it 'returns private token' do
post api('/session'), email: user.email.upcase, password: '12345678'
expect(response.status).to eq 201
@@ -33,7 +33,7 @@ describe API::API, api: true do
end
context 'when login has case-typo and password is valid' do
- it 'should return private token' do
+ it 'returns private token' do
post api('/session'), login: user.username.upcase, password: '12345678'
expect(response.status).to eq 201
@@ -46,7 +46,7 @@ describe API::API, api: true do
end
context "when invalid password" do
- it "should return authentication error" do
+ it "returns authentication error" do
post api("/session"), email: user.email, password: '123'
expect(response).to have_http_status(401)
@@ -56,7 +56,7 @@ describe API::API, api: true do
end
context "when empty password" do
- it "should return authentication error" do
+ it "returns authentication error" do
post api("/session"), email: user.email
expect(response).to have_http_status(401)
@@ -66,7 +66,7 @@ describe API::API, api: true do
end
context "when empty name" do
- it "should return authentication error" do
+ it "returns authentication error" do
post api("/session"), password: user.password
expect(response).to have_http_status(401)
diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb
index 684c2cd8e24..54d096e8b7f 100644
--- a/spec/requests/api/settings_spec.rb
+++ b/spec/requests/api/settings_spec.rb
@@ -7,7 +7,7 @@ describe API::API, 'Settings', api: true do
let(:admin) { create(:admin) }
describe "GET /application/settings" do
- it "should return application settings" do
+ it "returns application settings" do
get api("/application/settings", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Hash
@@ -23,7 +23,7 @@ describe API::API, 'Settings', api: true do
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end
- it "should update application settings" do
+ it "updates application settings" do
put api("/application/settings", admin),
default_projects_limit: 3, signin_enabled: false, repository_storage: 'custom'
expect(response).to have_http_status(200)
diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb
index cf66f261ade..1ce2658569e 100644
--- a/spec/requests/api/system_hooks_spec.rb
+++ b/spec/requests/api/system_hooks_spec.rb
@@ -11,21 +11,21 @@ describe API::API, api: true do
describe "GET /hooks" do
context "when no user" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/hooks")
expect(response).to have_http_status(401)
end
end
context "when not an admin" do
- it "should return forbidden error" do
+ it "returns forbidden error" do
get api("/hooks", user)
expect(response).to have_http_status(403)
end
end
context "when authenticated as admin" do
- it "should return an array of hooks" do
+ it "returns an array of hooks" do
get api("/hooks", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -35,18 +35,18 @@ describe API::API, api: true do
end
describe "POST /hooks" do
- it "should create new hook" do
+ it "creates new hook" do
expect do
post api("/hooks", admin), url: 'http://example.com'
end.to change { SystemHook.count }.by(1)
end
- it "should respond with 400 if url not given" do
+ it "responds with 400 if url not given" do
post api("/hooks", admin)
expect(response).to have_http_status(400)
end
- it "should not create new hook without url" do
+ it "does not create new hook without url" do
expect do
post api("/hooks", admin)
end.not_to change { SystemHook.count }
@@ -54,26 +54,26 @@ describe API::API, api: true do
end
describe "GET /hooks/:id" do
- it "should return hook by id" do
+ it "returns hook by id" do
get api("/hooks/#{hook.id}", admin)
expect(response).to have_http_status(200)
expect(json_response['event_name']).to eq('project_create')
end
- it "should return 404 on failure" do
+ it "returns 404 on failure" do
get api("/hooks/404", admin)
expect(response).to have_http_status(404)
end
end
describe "DELETE /hooks/:id" do
- it "should delete a hook" do
+ it "deletes a hook" do
expect do
delete api("/hooks/#{hook.id}", admin)
end.to change { SystemHook.count }.by(-1)
end
- it "should return success if hook id not found" do
+ it "returns success if hook id not found" do
delete api("/hooks/12345", admin)
expect(response).to have_http_status(200)
end
diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb
index fa700ab7343..d563883cd47 100644
--- a/spec/requests/api/tags_spec.rb
+++ b/spec/requests/api/tags_spec.rb
@@ -16,7 +16,7 @@ describe API::API, api: true do
let(:description) { 'Awesome release!' }
context 'without releases' do
- it "should return an array of project tags" do
+ it "returns an array of project tags" do
get api("/projects/#{project.id}/repository/tags", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -30,7 +30,7 @@ describe API::API, api: true do
release.update_attributes(description: description)
end
- it "should return an array of project tags with release info" do
+ it "returns an array of project tags with release info" do
get api("/projects/#{project.id}/repository/tags", user)
expect(response).to have_http_status(200)
@@ -61,7 +61,7 @@ describe API::API, api: true do
describe 'POST /projects/:id/repository/tags' do
context 'lightweight tags' do
- it 'should create a new tag' do
+ it 'creates a new tag' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v7.0.1',
ref: 'master'
@@ -72,7 +72,7 @@ describe API::API, api: true do
end
context 'lightweight tags with release notes' do
- it 'should create a new tag' do
+ it 'creates a new tag' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v7.0.1',
ref: 'master',
@@ -92,13 +92,13 @@ describe API::API, api: true do
end
context 'delete tag' do
- it 'should delete an existing tag' do
+ it 'deletes an existing tag' do
delete api("/projects/#{project.id}/repository/tags/#{tag_name}", user)
expect(response).to have_http_status(200)
expect(json_response['tag_name']).to eq(tag_name)
end
- it 'should raise 404 if the tag does not exist' do
+ it 'raises 404 if the tag does not exist' do
delete api("/projects/#{project.id}/repository/tags/foobar", user)
expect(response).to have_http_status(404)
end
@@ -106,7 +106,7 @@ describe API::API, api: true do
end
context 'annotated tag' do
- it 'should create a new annotated tag' do
+ it 'creates a new annotated tag' do
# Identity must be set in .gitconfig to create annotated tag.
repo_path = project.repository.path_to_repo
system(*%W(#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} config user.name #{user.name}))
@@ -123,14 +123,14 @@ describe API::API, api: true do
end
end
- it 'should deny for user without push access' do
+ it 'denies for user without push access' do
post api("/projects/#{project.id}/repository/tags", user2),
tag_name: 'v1.9.0',
ref: '621491c677087aa243f165eab467bfdfbee00be1'
expect(response).to have_http_status(403)
end
- it 'should return 400 if tag name is invalid' do
+ it 'returns 400 if tag name is invalid' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v 1.0.0',
ref: 'master'
@@ -138,7 +138,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Tag name invalid')
end
- it 'should return 400 if tag already exists' do
+ it 'returns 400 if tag already exists' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v8.0.0',
ref: 'master'
@@ -150,7 +150,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Tag v8.0.0 already exists')
end
- it 'should return 400 if ref name is invalid' do
+ it 'returns 400 if ref name is invalid' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'mytag',
ref: 'foo'
@@ -163,7 +163,7 @@ describe API::API, api: true do
let(:tag_name) { project.repository.tag_names.first }
let(:description) { 'Awesome release!' }
- it 'should create description for existing git tag' do
+ it 'creates description for existing git tag' do
post api("/projects/#{project.id}/repository/tags/#{tag_name}/release", user),
description: description
@@ -172,7 +172,7 @@ describe API::API, api: true do
expect(json_response['description']).to eq(description)
end
- it 'should return 404 if the tag does not exist' do
+ it 'returns 404 if the tag does not exist' do
post api("/projects/#{project.id}/repository/tags/foobar/release", user),
description: description
@@ -186,7 +186,7 @@ describe API::API, api: true do
release.update_attributes(description: description)
end
- it 'should return 409 if there is already a release' do
+ it 'returns 409 if there is already a release' do
post api("/projects/#{project.id}/repository/tags/#{tag_name}/release", user),
description: description
@@ -207,7 +207,7 @@ describe API::API, api: true do
release.update_attributes(description: description)
end
- it 'should update the release description' do
+ it 'updates the release description' do
put api("/projects/#{project.id}/repository/tags/#{tag_name}/release", user),
description: new_description
@@ -217,7 +217,7 @@ describe API::API, api: true do
end
end
- it 'should return 404 if the tag does not exist' do
+ it 'returns 404 if the tag does not exist' do
put api("/projects/#{project.id}/repository/tags/foobar/release", user),
description: new_description
@@ -225,7 +225,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Tag does not exist')
end
- it 'should return 404 if the release does not exist' do
+ it 'returns 404 if the release does not exist' do
put api("/projects/#{project.id}/repository/tags/#{tag_name}/release", user),
description: new_description
diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb
index 8992996c30a..5702682fc7d 100644
--- a/spec/requests/api/triggers_spec.rb
+++ b/spec/requests/api/triggers_spec.rb
@@ -27,17 +27,17 @@ describe API::API do
end
context 'Handles errors' do
- it 'should return bad request if token is missing' do
+ it 'returns bad request if token is missing' do
post api("/projects/#{project.id}/trigger/builds"), ref: 'master'
expect(response).to have_http_status(400)
end
- it 'should return not found if project is not found' do
+ it 'returns not found if project is not found' do
post api('/projects/0/trigger/builds'), options.merge(ref: 'master')
expect(response).to have_http_status(404)
end
- it 'should return unauthorized if token is for different project' do
+ it 'returns unauthorized if token is for different project' do
post api("/projects/#{project2.id}/trigger/builds"), options.merge(ref: 'master')
expect(response).to have_http_status(401)
end
@@ -46,14 +46,14 @@ describe API::API do
context 'Have a commit' do
let(:pipeline) { project.pipelines.last }
- it 'should create builds' do
+ it 'creates builds' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(ref: 'master')
expect(response).to have_http_status(201)
pipeline.builds.reload
expect(pipeline.builds.size).to eq(2)
end
- it 'should return bad request with no builds created if there\'s no commit for that ref' do
+ it 'returns bad request with no builds created if there\'s no commit for that ref' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(ref: 'other-branch')
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('No builds created')
@@ -64,19 +64,19 @@ describe API::API do
{ 'TRIGGER_KEY' => 'TRIGGER_VALUE' }
end
- it 'should validate variables to be a hash' do
+ it 'validates variables to be a hash' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(variables: 'value', ref: 'master')
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('variables needs to be a hash')
end
- it 'should validate variables needs to be a map of key-valued strings' do
+ it 'validates variables needs to be a map of key-valued strings' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(variables: { key: %w(1 2) }, ref: 'master')
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('variables needs to be a map of key-valued strings')
end
- it 'create trigger request with variables' do
+ it 'creates trigger request with variables' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(variables: variables, ref: 'master')
expect(response).to have_http_status(201)
pipeline.builds.reload
@@ -88,7 +88,7 @@ describe API::API do
describe 'GET /projects/:id/triggers' do
context 'authenticated user with valid permissions' do
- it 'should return list of triggers' do
+ it 'returns list of triggers' do
get api("/projects/#{project.id}/triggers", user)
expect(response).to have_http_status(200)
@@ -98,7 +98,7 @@ describe API::API do
end
context 'authenticated user with invalid permissions' do
- it 'should not return triggers list' do
+ it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers", user2)
expect(response).to have_http_status(403)
@@ -106,7 +106,7 @@ describe API::API do
end
context 'unauthenticated user' do
- it 'should not return triggers list' do
+ it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers")
expect(response).to have_http_status(401)
@@ -116,14 +116,14 @@ describe API::API do
describe 'GET /projects/:id/triggers/:token' do
context 'authenticated user with valid permissions' do
- it 'should return trigger details' do
+ it 'returns trigger details' do
get api("/projects/#{project.id}/triggers/#{trigger.token}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_a(Hash)
end
- it 'should respond with 404 Not Found if requesting non-existing trigger' do
+ it 'responds with 404 Not Found if requesting non-existing trigger' do
get api("/projects/#{project.id}/triggers/abcdef012345", user)
expect(response).to have_http_status(404)
@@ -131,7 +131,7 @@ describe API::API do
end
context 'authenticated user with invalid permissions' do
- it 'should not return triggers list' do
+ it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers/#{trigger.token}", user2)
expect(response).to have_http_status(403)
@@ -139,7 +139,7 @@ describe API::API do
end
context 'unauthenticated user' do
- it 'should not return triggers list' do
+ it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers/#{trigger.token}")
expect(response).to have_http_status(401)
@@ -149,7 +149,7 @@ describe API::API do
describe 'POST /projects/:id/triggers' do
context 'authenticated user with valid permissions' do
- it 'should create trigger' do
+ it 'creates trigger' do
expect do
post api("/projects/#{project.id}/triggers", user)
end.to change{project.triggers.count}.by(1)
@@ -160,7 +160,7 @@ describe API::API do
end
context 'authenticated user with invalid permissions' do
- it 'should not create trigger' do
+ it 'does not create trigger' do
post api("/projects/#{project.id}/triggers", user2)
expect(response).to have_http_status(403)
@@ -168,7 +168,7 @@ describe API::API do
end
context 'unauthenticated user' do
- it 'should not create trigger' do
+ it 'does not create trigger' do
post api("/projects/#{project.id}/triggers")
expect(response).to have_http_status(401)
@@ -178,14 +178,14 @@ describe API::API do
describe 'DELETE /projects/:id/triggers/:token' do
context 'authenticated user with valid permissions' do
- it 'should delete trigger' do
+ it 'deletes trigger' do
expect do
delete api("/projects/#{project.id}/triggers/#{trigger.token}", user)
end.to change{project.triggers.count}.by(-1)
expect(response).to have_http_status(200)
end
- it 'should respond with 404 Not Found if requesting non-existing trigger' do
+ it 'responds with 404 Not Found if requesting non-existing trigger' do
delete api("/projects/#{project.id}/triggers/abcdef012345", user)
expect(response).to have_http_status(404)
@@ -193,7 +193,7 @@ describe API::API do
end
context 'authenticated user with invalid permissions' do
- it 'should not delete trigger' do
+ it 'does not delete trigger' do
delete api("/projects/#{project.id}/triggers/#{trigger.token}", user2)
expect(response).to have_http_status(403)
@@ -201,7 +201,7 @@ describe API::API do
end
context 'unauthenticated user' do
- it 'should not delete trigger' do
+ it 'does not delete trigger' do
delete api("/projects/#{project.id}/triggers/#{trigger.token}")
expect(response).to have_http_status(401)
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index e43e3e269bf..69b5072a81e 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -13,7 +13,7 @@ describe API::API, api: true do
describe "GET /users" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/users")
expect(response).to have_http_status(401)
end
@@ -38,7 +38,7 @@ describe API::API, api: true do
end
end
- it "should return an array of users" do
+ it "returns an array of users" do
get api("/users", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -48,7 +48,7 @@ describe API::API, api: true do
end['username']).to eq(username)
end
- it "should return one user" do
+ it "returns one user" do
get api("/users?username=#{omniauth_user.username}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -57,7 +57,7 @@ describe API::API, api: true do
end
context "when admin" do
- it "should return an array of users" do
+ it "returns an array of users" do
get api("/users", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -72,24 +72,24 @@ describe API::API, api: true do
end
describe "GET /users/:id" do
- it "should return a user by id" do
+ it "returns a user by id" do
get api("/users/#{user.id}", user)
expect(response).to have_http_status(200)
expect(json_response['username']).to eq(user.username)
end
- it "should return a 401 if unauthenticated" do
+ it "returns a 401 if unauthenticated" do
get api("/users/9998")
expect(response).to have_http_status(401)
end
- it "should return a 404 error if user id not found" do
+ it "returns a 404 error if user id not found" do
get api("/users/9999", user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found')
end
- it "should return a 404 if invalid ID" do
+ it "returns a 404 if invalid ID" do
get api("/users/1ASDF", user)
expect(response).to have_http_status(404)
end
@@ -98,13 +98,13 @@ describe API::API, api: true do
describe "POST /users" do
before{ admin }
- it "should create user" do
+ it "creates user" do
expect do
post api("/users", admin), attributes_for(:user, projects_limit: 3)
end.to change { User.count }.by(1)
end
- it "should create user with correct attributes" do
+ it "creates user with correct attributes" do
post api('/users', admin), attributes_for(:user, admin: true, can_create_group: true)
expect(response).to have_http_status(201)
user_id = json_response['id']
@@ -114,7 +114,7 @@ describe API::API, api: true do
expect(new_user.can_create_group).to eq(true)
end
- it "should create non-admin user" do
+ it "creates non-admin user" do
post api('/users', admin), attributes_for(:user, admin: false, can_create_group: false)
expect(response).to have_http_status(201)
user_id = json_response['id']
@@ -124,7 +124,7 @@ describe API::API, api: true do
expect(new_user.can_create_group).to eq(false)
end
- it "should create non-admin users by default" do
+ it "creates non-admin users by default" do
post api('/users', admin), attributes_for(:user)
expect(response).to have_http_status(201)
user_id = json_response['id']
@@ -133,7 +133,7 @@ describe API::API, api: true do
expect(new_user.admin).to eq(false)
end
- it "should return 201 Created on success" do
+ it "returns 201 Created on success" do
post api("/users", admin), attributes_for(:user, projects_limit: 3)
expect(response).to have_http_status(201)
end
@@ -148,7 +148,7 @@ describe API::API, api: true do
expect(new_user.external).to be_falsy
end
- it 'should allow an external user to be created' do
+ it 'allows an external user to be created' do
post api("/users", admin), attributes_for(:user, external: true)
expect(response).to have_http_status(201)
@@ -158,7 +158,7 @@ describe API::API, api: true do
expect(new_user.external).to be_truthy
end
- it "should not create user with invalid email" do
+ it "does not create user with invalid email" do
post api('/users', admin),
email: 'invalid email',
password: 'password',
@@ -166,27 +166,27 @@ describe API::API, api: true do
expect(response).to have_http_status(400)
end
- it 'should return 400 error if name not given' do
+ it 'returns 400 error if name not given' do
post api('/users', admin), attributes_for(:user).except(:name)
expect(response).to have_http_status(400)
end
- it 'should return 400 error if password not given' do
+ it 'returns 400 error if password not given' do
post api('/users', admin), attributes_for(:user).except(:password)
expect(response).to have_http_status(400)
end
- it 'should return 400 error if email not given' do
+ it 'returns 400 error if email not given' do
post api('/users', admin), attributes_for(:user).except(:email)
expect(response).to have_http_status(400)
end
- it 'should return 400 error if username not given' do
+ it 'returns 400 error if username not given' do
post api('/users', admin), attributes_for(:user).except(:username)
expect(response).to have_http_status(400)
end
- it 'should return 400 error if user does not validate' do
+ it 'returns 400 error if user does not validate' do
post api('/users', admin),
password: 'pass',
email: 'test@example.com',
@@ -205,7 +205,7 @@ describe API::API, api: true do
to eq([Gitlab::Regex.namespace_regex_message])
end
- it "shouldn't available for non admin users" do
+ it "is not available for non admin users" do
post api("/users", user), attributes_for(:user)
expect(response).to have_http_status(403)
end
@@ -219,7 +219,7 @@ describe API::API, api: true do
name: 'foo'
end
- it 'should return 409 conflict error if user with same email exists' do
+ it 'returns 409 conflict error if user with same email exists' do
expect do
post api('/users', admin),
name: 'foo',
@@ -231,7 +231,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Email has already been taken')
end
- it 'should return 409 conflict error if same username exists' do
+ it 'returns 409 conflict error if same username exists' do
expect do
post api('/users', admin),
name: 'foo',
@@ -246,7 +246,7 @@ describe API::API, api: true do
end
describe "GET /users/sign_up" do
- it "should redirect to sign in page" do
+ it "redirects to sign in page" do
get "/users/sign_up"
expect(response).to have_http_status(302)
expect(response).to redirect_to(new_user_session_path)
@@ -258,55 +258,55 @@ describe API::API, api: true do
before { admin }
- it "should update user with new bio" do
+ it "updates user with new bio" do
put api("/users/#{user.id}", admin), { bio: 'new test bio' }
expect(response).to have_http_status(200)
expect(json_response['bio']).to eq('new test bio')
expect(user.reload.bio).to eq('new test bio')
end
- it 'should update user with his own email' do
+ it 'updates user with his own email' do
put api("/users/#{user.id}", admin), email: user.email
expect(response).to have_http_status(200)
expect(json_response['email']).to eq(user.email)
expect(user.reload.email).to eq(user.email)
end
- it 'should update user with his own username' do
+ it 'updates user with his own username' do
put api("/users/#{user.id}", admin), username: user.username
expect(response).to have_http_status(200)
expect(json_response['username']).to eq(user.username)
expect(user.reload.username).to eq(user.username)
end
- it "should update user's existing identity" do
+ it "updates user's existing identity" do
put api("/users/#{omniauth_user.id}", admin), provider: 'ldapmain', extern_uid: '654321'
expect(response).to have_http_status(200)
expect(omniauth_user.reload.identities.first.extern_uid).to eq('654321')
end
- it 'should update user with new identity' do
+ it 'updates user with new identity' do
put api("/users/#{user.id}", admin), provider: 'github', extern_uid: '67890'
expect(response).to have_http_status(200)
expect(user.reload.identities.first.extern_uid).to eq('67890')
expect(user.reload.identities.first.provider).to eq('github')
end
- it "should update admin status" do
+ it "updates admin status" do
put api("/users/#{user.id}", admin), { admin: true }
expect(response).to have_http_status(200)
expect(json_response['is_admin']).to eq(true)
expect(user.reload.admin).to eq(true)
end
- it "should update external status" do
+ it "updates external status" do
put api("/users/#{user.id}", admin), { external: true }
expect(response.status).to eq 200
expect(json_response['external']).to eq(true)
expect(user.reload.external?).to be_truthy
end
- it "should not update admin status" do
+ it "does not update admin status" do
put api("/users/#{admin_user.id}", admin), { can_create_group: false }
expect(response).to have_http_status(200)
expect(json_response['is_admin']).to eq(true)
@@ -314,28 +314,28 @@ describe API::API, api: true do
expect(admin_user.can_create_group).to eq(false)
end
- it "should not allow invalid update" do
+ it "does not allow invalid update" do
put api("/users/#{user.id}", admin), { email: 'invalid email' }
expect(response).to have_http_status(400)
expect(user.reload.email).not_to eq('invalid email')
end
- it "shouldn't available for non admin users" do
+ it "is not available for non admin users" do
put api("/users/#{user.id}", user), attributes_for(:user)
expect(response).to have_http_status(403)
end
- it "should return 404 for non-existing user" do
+ it "returns 404 for non-existing user" do
put api("/users/999999", admin), { bio: 'update should fail' }
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found')
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{put api("/users/ASDF", admin) }.to raise_error(ActionController::RoutingError)
end
- it 'should return 400 error if user does not validate' do
+ it 'returns 400 error if user does not validate' do
put api("/users/#{user.id}", admin),
password: 'pass',
email: 'test@example.com',
@@ -361,13 +361,13 @@ describe API::API, api: true do
@user = User.all.last
end
- it 'should return 409 conflict error if email address exists' do
+ it 'returns 409 conflict error if email address exists' do
put api("/users/#{@user.id}", admin), email: 'test@example.com'
expect(response).to have_http_status(409)
expect(@user.reload.email).to eq(@user.email)
end
- it 'should return 409 conflict error if username taken' do
+ it 'returns 409 conflict error if username taken' do
@user_id = User.all.last.id
put api("/users/#{@user.id}", admin), username: 'test'
expect(response).to have_http_status(409)
@@ -379,26 +379,26 @@ describe API::API, api: true do
describe "POST /users/:id/keys" do
before { admin }
- it "should not create invalid ssh key" do
+ it "does not create invalid ssh key" do
post api("/users/#{user.id}/keys", admin), { title: "invalid key" }
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "key" not given')
end
- it 'should not create key without title' do
+ it 'does not create key without title' do
post api("/users/#{user.id}/keys", admin), key: 'some key'
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "title" not given')
end
- it "should create ssh key" do
+ it "creates ssh key" do
key_attrs = attributes_for :key
expect do
post api("/users/#{user.id}/keys", admin), key_attrs
end.to change{ user.keys.count }.by(1)
end
- it "should return 405 for invalid ID" do
+ it "returns 405 for invalid ID" do
post api("/users/ASDF/keys", admin)
expect(response).to have_http_status(405)
end
@@ -408,20 +408,20 @@ describe API::API, api: true do
before { admin }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api("/users/#{user.id}/keys")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should return 404 for non-existing user' do
+ it 'returns 404 for non-existing user' do
get api('/users/999999/keys', admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
end
- it 'should return array of ssh keys' do
+ it 'returns array of ssh keys' do
user.keys << key
user.save
get api("/users/#{user.id}/keys", admin)
@@ -430,7 +430,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(key.title)
end
- it "should return 405 for invalid ID" do
+ it "returns 405 for invalid ID" do
get api("/users/ASDF/keys", admin)
expect(response).to have_http_status(405)
end
@@ -441,14 +441,14 @@ describe API::API, api: true do
before { admin }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
delete api("/users/#{user.id}/keys/42")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should delete existing key' do
+ it 'deletes existing key' do
user.keys << key
user.save
expect do
@@ -457,7 +457,7 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it 'should return 404 error if user not found' do
+ it 'returns 404 error if user not found' do
user.keys << key
user.save
delete api("/users/999999/keys/#{key.id}", admin)
@@ -465,7 +465,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('404 User Not Found')
end
- it 'should return 404 error if key not foud' do
+ it 'returns 404 error if key not foud' do
delete api("/users/#{user.id}/keys/42", admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Key Not Found')
@@ -476,20 +476,20 @@ describe API::API, api: true do
describe "POST /users/:id/emails" do
before { admin }
- it "should not create invalid email" do
+ it "does not create invalid email" do
post api("/users/#{user.id}/emails", admin), {}
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "email" not given')
end
- it "should create email" do
+ it "creates email" do
email_attrs = attributes_for :email
expect do
post api("/users/#{user.id}/emails", admin), email_attrs
end.to change{ user.emails.count }.by(1)
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
post api("/users/ASDF/emails", admin)
expect(response).to have_http_status(405)
end
@@ -499,20 +499,20 @@ describe API::API, api: true do
before { admin }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api("/users/#{user.id}/emails")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should return 404 for non-existing user' do
+ it 'returns 404 for non-existing user' do
get api('/users/999999/emails', admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
end
- it 'should return array of emails' do
+ it 'returns array of emails' do
user.emails << email
user.save
get api("/users/#{user.id}/emails", admin)
@@ -521,7 +521,7 @@ describe API::API, api: true do
expect(json_response.first['email']).to eq(email.email)
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
put api("/users/ASDF/emails", admin)
expect(response).to have_http_status(405)
end
@@ -532,14 +532,14 @@ describe API::API, api: true do
before { admin }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
delete api("/users/#{user.id}/emails/42")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should delete existing email' do
+ it 'deletes existing email' do
user.emails << email
user.save
expect do
@@ -548,7 +548,7 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it 'should return 404 error if user not found' do
+ it 'returns 404 error if user not found' do
user.emails << email
user.save
delete api("/users/999999/emails/#{email.id}", admin)
@@ -556,13 +556,13 @@ describe API::API, api: true do
expect(json_response['message']).to eq('404 User Not Found')
end
- it 'should return 404 error if email not foud' do
+ it 'returns 404 error if email not foud' do
delete api("/users/#{user.id}/emails/42", admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Email Not Found')
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{delete api("/users/ASDF/emails/bar", admin) }.to raise_error(ActionController::RoutingError)
end
end
@@ -571,36 +571,36 @@ describe API::API, api: true do
describe "DELETE /users/:id" do
before { admin }
- it "should delete user" do
+ it "deletes user" do
delete api("/users/#{user.id}", admin)
expect(response).to have_http_status(200)
expect { User.find(user.id) }.to raise_error ActiveRecord::RecordNotFound
expect(json_response['email']).to eq(user.email)
end
- it "should not delete for unauthenticated user" do
+ it "does not delete for unauthenticated user" do
delete api("/users/#{user.id}")
expect(response).to have_http_status(401)
end
- it "shouldn't available for non admin users" do
+ it "is not available for non admin users" do
delete api("/users/#{user.id}", user)
expect(response).to have_http_status(403)
end
- it "should return 404 for non-existing user" do
+ it "returns 404 for non-existing user" do
delete api("/users/999999", admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{delete api("/users/ASDF", admin) }.to raise_error(ActionController::RoutingError)
end
end
describe "GET /user" do
- it "should return current user" do
+ it "returns current user" do
get api("/user", user)
expect(response).to have_http_status(200)
expect(json_response['email']).to eq(user.email)
@@ -610,7 +610,7 @@ describe API::API, api: true do
expect(json_response['projects_limit']).to eq(user.projects_limit)
end
- it "should return 401 error if user is unauthenticated" do
+ it "returns 401 error if user is unauthenticated" do
get api("/user")
expect(response).to have_http_status(401)
end
@@ -618,14 +618,14 @@ describe API::API, api: true do
describe "GET /user/keys" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/user/keys")
expect(response).to have_http_status(401)
end
end
context "when authenticated" do
- it "should return array of ssh keys" do
+ it "returns array of ssh keys" do
user.keys << key
user.save
get api("/user/keys", user)
@@ -637,7 +637,7 @@ describe API::API, api: true do
end
describe "GET /user/keys/:id" do
- it "should return single key" do
+ it "returns single key" do
user.keys << key
user.save
get api("/user/keys/#{key.id}", user)
@@ -645,13 +645,13 @@ describe API::API, api: true do
expect(json_response["title"]).to eq(key.title)
end
- it "should return 404 Not Found within invalid ID" do
+ it "returns 404 Not Found within invalid ID" do
get api("/user/keys/42", user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found')
end
- it "should return 404 error if admin accesses user's ssh key" do
+ it "returns 404 error if admin accesses user's ssh key" do
user.keys << key
user.save
admin
@@ -660,14 +660,14 @@ describe API::API, api: true do
expect(json_response['message']).to eq('404 Not found')
end
- it "should return 404 for invalid ID" do
+ it "returns 404 for invalid ID" do
get api("/users/keys/ASDF", admin)
expect(response).to have_http_status(404)
end
end
describe "POST /user/keys" do
- it "should create ssh key" do
+ it "creates ssh key" do
key_attrs = attributes_for :key
expect do
post api("/user/keys", user), key_attrs
@@ -675,31 +675,31 @@ describe API::API, api: true do
expect(response).to have_http_status(201)
end
- it "should return a 401 error if unauthorized" do
+ it "returns a 401 error if unauthorized" do
post api("/user/keys"), title: 'some title', key: 'some key'
expect(response).to have_http_status(401)
end
- it "should not create ssh key without key" do
+ it "does not create ssh key without key" do
post api("/user/keys", user), title: 'title'
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "key" not given')
end
- it 'should not create ssh key without title' do
+ it 'does not create ssh key without title' do
post api('/user/keys', user), key: 'some key'
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "title" not given')
end
- it "should not create ssh key without title" do
+ it "does not create ssh key without title" do
post api("/user/keys", user), key: "somekey"
expect(response).to have_http_status(400)
end
end
describe "DELETE /user/keys/:id" do
- it "should delete existed key" do
+ it "deletes existed key" do
user.keys << key
user.save
expect do
@@ -708,33 +708,33 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it "should return success if key ID not found" do
+ it "returns success if key ID not found" do
delete api("/user/keys/42", user)
expect(response).to have_http_status(200)
end
- it "should return 401 error if unauthorized" do
+ it "returns 401 error if unauthorized" do
user.keys << key
user.save
delete api("/user/keys/#{key.id}")
expect(response).to have_http_status(401)
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{delete api("/users/keys/ASDF", admin) }.to raise_error(ActionController::RoutingError)
end
end
describe "GET /user/emails" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/user/emails")
expect(response).to have_http_status(401)
end
end
context "when authenticated" do
- it "should return array of emails" do
+ it "returns array of emails" do
user.emails << email
user.save
get api("/user/emails", user)
@@ -746,7 +746,7 @@ describe API::API, api: true do
end
describe "GET /user/emails/:id" do
- it "should return single email" do
+ it "returns single email" do
user.emails << email
user.save
get api("/user/emails/#{email.id}", user)
@@ -754,13 +754,13 @@ describe API::API, api: true do
expect(json_response["email"]).to eq(email.email)
end
- it "should return 404 Not Found within invalid ID" do
+ it "returns 404 Not Found within invalid ID" do
get api("/user/emails/42", user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found')
end
- it "should return 404 error if admin accesses user's email" do
+ it "returns 404 error if admin accesses user's email" do
user.emails << email
user.save
admin
@@ -769,14 +769,14 @@ describe API::API, api: true do
expect(json_response['message']).to eq('404 Not found')
end
- it "should return 404 for invalid ID" do
+ it "returns 404 for invalid ID" do
get api("/users/emails/ASDF", admin)
expect(response).to have_http_status(404)
end
end
describe "POST /user/emails" do
- it "should create email" do
+ it "creates email" do
email_attrs = attributes_for :email
expect do
post api("/user/emails", user), email_attrs
@@ -784,12 +784,12 @@ describe API::API, api: true do
expect(response).to have_http_status(201)
end
- it "should return a 401 error if unauthorized" do
+ it "returns a 401 error if unauthorized" do
post api("/user/emails"), email: 'some email'
expect(response).to have_http_status(401)
end
- it "should not create email with invalid email" do
+ it "does not create email with invalid email" do
post api("/user/emails", user), {}
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "email" not given')
@@ -797,7 +797,7 @@ describe API::API, api: true do
end
describe "DELETE /user/emails/:id" do
- it "should delete existed email" do
+ it "deletes existed email" do
user.emails << email
user.save
expect do
@@ -806,44 +806,44 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it "should return success if email ID not found" do
+ it "returns success if email ID not found" do
delete api("/user/emails/42", user)
expect(response).to have_http_status(200)
end
- it "should return 401 error if unauthorized" do
+ it "returns 401 error if unauthorized" do
user.emails << email
user.save
delete api("/user/emails/#{email.id}")
expect(response).to have_http_status(401)
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{delete api("/users/emails/ASDF", admin) }.to raise_error(ActionController::RoutingError)
end
end
describe 'PUT /user/:id/block' do
before { admin }
- it 'should block existing user' do
+ it 'blocks existing user' do
put api("/users/#{user.id}/block", admin)
expect(response).to have_http_status(200)
expect(user.reload.state).to eq('blocked')
end
- it 'should not re-block ldap blocked users' do
+ it 'does not re-block ldap blocked users' do
put api("/users/#{ldap_blocked_user.id}/block", admin)
expect(response).to have_http_status(403)
expect(ldap_blocked_user.reload.state).to eq('ldap_blocked')
end
- it 'should not be available for non admin users' do
+ it 'does not be available for non admin users' do
put api("/users/#{user.id}/block", user)
expect(response).to have_http_status(403)
expect(user.reload.state).to eq('active')
end
- it 'should return a 404 error if user id not found' do
+ it 'returns a 404 error if user id not found' do
put api('/users/9999/block', admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
@@ -854,37 +854,37 @@ describe API::API, api: true do
let(:blocked_user) { create(:user, state: 'blocked') }
before { admin }
- it 'should unblock existing user' do
+ it 'unblocks existing user' do
put api("/users/#{user.id}/unblock", admin)
expect(response).to have_http_status(200)
expect(user.reload.state).to eq('active')
end
- it 'should unblock a blocked user' do
+ it 'unblocks a blocked user' do
put api("/users/#{blocked_user.id}/unblock", admin)
expect(response).to have_http_status(200)
expect(blocked_user.reload.state).to eq('active')
end
- it 'should not unblock ldap blocked users' do
+ it 'does not unblock ldap blocked users' do
put api("/users/#{ldap_blocked_user.id}/unblock", admin)
expect(response).to have_http_status(403)
expect(ldap_blocked_user.reload.state).to eq('ldap_blocked')
end
- it 'should not be available for non admin users' do
+ it 'does not be available for non admin users' do
put api("/users/#{user.id}/unblock", user)
expect(response).to have_http_status(403)
expect(user.reload.state).to eq('active')
end
- it 'should return a 404 error if user id not found' do
+ it 'returns a 404 error if user id not found' do
put api('/users/9999/block', admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{put api("/users/ASDF/block", admin) }.to raise_error(ActionController::RoutingError)
end
end
diff --git a/spec/requests/api/variables_spec.rb b/spec/requests/api/variables_spec.rb
index ddba18245f8..05fbdb909dc 100644
--- a/spec/requests/api/variables_spec.rb
+++ b/spec/requests/api/variables_spec.rb
@@ -12,7 +12,7 @@ describe API::API, api: true do
describe 'GET /projects/:id/variables' do
context 'authorized user with proper permissions' do
- it 'should return project variables' do
+ it 'returns project variables' do
get api("/projects/#{project.id}/variables", user)
expect(response).to have_http_status(200)
@@ -21,7 +21,7 @@ describe API::API, api: true do
end
context 'authorized user with invalid permissions' do
- it 'should not return project variables' do
+ it 'does not return project variables' do
get api("/projects/#{project.id}/variables", user2)
expect(response).to have_http_status(403)
@@ -29,7 +29,7 @@ describe API::API, api: true do
end
context 'unauthorized user' do
- it 'should not return project variables' do
+ it 'does not return project variables' do
get api("/projects/#{project.id}/variables")
expect(response).to have_http_status(401)
@@ -39,14 +39,14 @@ describe API::API, api: true do
describe 'GET /projects/:id/variables/:key' do
context 'authorized user with proper permissions' do
- it 'should return project variable details' do
+ it 'returns project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}", user)
expect(response).to have_http_status(200)
expect(json_response['value']).to eq(variable.value)
end
- it 'should respond with 404 Not Found if requesting non-existing variable' do
+ it 'responds with 404 Not Found if requesting non-existing variable' do
get api("/projects/#{project.id}/variables/non_existing_variable", user)
expect(response).to have_http_status(404)
@@ -54,7 +54,7 @@ describe API::API, api: true do
end
context 'authorized user with invalid permissions' do
- it 'should not return project variable details' do
+ it 'does not return project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}", user2)
expect(response).to have_http_status(403)
@@ -62,7 +62,7 @@ describe API::API, api: true do
end
context 'unauthorized user' do
- it 'should not return project variable details' do
+ it 'does not return project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}")
expect(response).to have_http_status(401)
@@ -72,7 +72,7 @@ describe API::API, api: true do
describe 'POST /projects/:id/variables' do
context 'authorized user with proper permissions' do
- it 'should create variable' do
+ it 'creates variable' do
expect do
post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2'
end.to change{project.variables.count}.by(1)
@@ -82,7 +82,7 @@ describe API::API, api: true do
expect(json_response['value']).to eq('VALUE_2')
end
- it 'should not allow to duplicate variable key' do
+ it 'does not allow to duplicate variable key' do
expect do
post api("/projects/#{project.id}/variables", user), key: variable.key, value: 'VALUE_2'
end.to change{project.variables.count}.by(0)
@@ -92,7 +92,7 @@ describe API::API, api: true do
end
context 'authorized user with invalid permissions' do
- it 'should not create variable' do
+ it 'does not create variable' do
post api("/projects/#{project.id}/variables", user2)
expect(response).to have_http_status(403)
@@ -100,7 +100,7 @@ describe API::API, api: true do
end
context 'unauthorized user' do
- it 'should not create variable' do
+ it 'does not create variable' do
post api("/projects/#{project.id}/variables")
expect(response).to have_http_status(401)
@@ -110,7 +110,7 @@ describe API::API, api: true do
describe 'PUT /projects/:id/variables/:key' do
context 'authorized user with proper permissions' do
- it 'should update variable data' do
+ it 'updates variable data' do
initial_variable = project.variables.first
value_before = initial_variable.value
@@ -123,7 +123,7 @@ describe API::API, api: true do
expect(updated_variable.value).to eq('VALUE_1_UP')
end
- it 'should responde with 404 Not Found if requesting non-existing variable' do
+ it 'responds with 404 Not Found if requesting non-existing variable' do
put api("/projects/#{project.id}/variables/non_existing_variable", user)
expect(response).to have_http_status(404)
@@ -131,7 +131,7 @@ describe API::API, api: true do
end
context 'authorized user with invalid permissions' do
- it 'should not update variable' do
+ it 'does not update variable' do
put api("/projects/#{project.id}/variables/#{variable.key}", user2)
expect(response).to have_http_status(403)
@@ -139,7 +139,7 @@ describe API::API, api: true do
end
context 'unauthorized user' do
- it 'should not update variable' do
+ it 'does not update variable' do
put api("/projects/#{project.id}/variables/#{variable.key}")
expect(response).to have_http_status(401)
@@ -149,14 +149,14 @@ describe API::API, api: true do
describe 'DELETE /projects/:id/variables/:key' do
context 'authorized user with proper permissions' do
- it 'should delete variable' do
+ it 'deletes variable' do
expect do
delete api("/projects/#{project.id}/variables/#{variable.key}", user)
end.to change{project.variables.count}.by(-1)
expect(response).to have_http_status(200)
end
- it 'should responde with 404 Not Found if requesting non-existing variable' do
+ it 'responds with 404 Not Found if requesting non-existing variable' do
delete api("/projects/#{project.id}/variables/non_existing_variable", user)
expect(response).to have_http_status(404)
@@ -164,7 +164,7 @@ describe API::API, api: true do
end
context 'authorized user with invalid permissions' do
- it 'should not delete variable' do
+ it 'does not delete variable' do
delete api("/projects/#{project.id}/variables/#{variable.key}", user2)
expect(response).to have_http_status(403)
@@ -172,7 +172,7 @@ describe API::API, api: true do
end
context 'unauthorized user' do
- it 'should not delete variable' do
+ it 'does not delete variable' do
delete api("/projects/#{project.id}/variables/#{variable.key}")
expect(response).to have_http_status(401)
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb
index cf1e8d9b514..05b309096cb 100644
--- a/spec/requests/ci/api/builds_spec.rb
+++ b/spec/requests/ci/api/builds_spec.rb
@@ -19,7 +19,7 @@ describe Ci::API::API do
end
describe "POST /builds/register" do
- it "should start a build" do
+ it "starts a build" do
pipeline = FactoryGirl.create(:ci_pipeline, project: project, ref: 'master')
pipeline.create_builds(nil)
build = pipeline.builds.first
@@ -31,13 +31,13 @@ describe Ci::API::API do
expect(runner.reload.platform).to eq("darwin")
end
- it "should return 404 error if no pending build found" do
+ it "returns 404 error if no pending build found" do
post ci_api("/builds/register"), token: runner.token
expect(response).to have_http_status(404)
end
- it "should return 404 error if no builds for specific runner" do
+ it "returns 404 error if no builds for specific runner" do
pipeline = FactoryGirl.create(:ci_pipeline, project: shared_project)
FactoryGirl.create(:ci_build, pipeline: pipeline, status: 'pending')
@@ -46,7 +46,7 @@ describe Ci::API::API do
expect(response).to have_http_status(404)
end
- it "should return 404 error if no builds for shared runner" do
+ it "returns 404 error if no builds for shared runner" do
pipeline = FactoryGirl.create(:ci_pipeline, project: project)
FactoryGirl.create(:ci_build, pipeline: pipeline, status: 'pending')
@@ -171,18 +171,18 @@ describe Ci::API::API do
put ci_api("/builds/#{build.id}"), token: runner.token
end
- it "should update a running build" do
+ it "updates a running build" do
expect(response).to have_http_status(200)
end
- it 'should not override trace information when no trace is given' do
+ it 'does not override trace information when no trace is given' do
expect(build.reload.trace).to eq 'BUILD TRACE'
end
context 'build has been erased' do
let(:build) { create(:ci_build, runner_id: runner.id, erased_at: Time.now) }
- it 'should respond with forbidden' do
+ it 'responds with forbidden' do
expect(response.status).to eq 403
end
end
@@ -280,7 +280,7 @@ describe Ci::API::API do
context 'authorization token is invalid' do
before { post authorize_url, { token: 'invalid', filesize: 100 } }
- it 'should respond with forbidden' do
+ it 'responds with forbidden' do
expect(response).to have_http_status(403)
end
end
@@ -300,7 +300,7 @@ describe Ci::API::API do
upload_artifacts(file_upload, headers_with_token)
end
- it 'should respond with forbidden' do
+ it 'responds with forbidden' do
expect(response.status).to eq 403
end
end
@@ -342,7 +342,7 @@ describe Ci::API::API do
end
end
- context 'should post artifacts file and metadata file' do
+ context 'posts artifacts file and metadata file' do
let!(:artifacts) { file_upload }
let!(:metadata) { file_upload2 }
@@ -354,7 +354,7 @@ describe Ci::API::API do
post(post_url, post_data, headers_with_token)
end
- context 'post data accelerated by workhorse is correct' do
+ context 'posts data accelerated by workhorse is correct' do
let(:post_data) do
{ 'file.path' => artifacts.path,
'file.name' => artifacts.original_filename,
@@ -422,7 +422,7 @@ describe Ci::API::API do
end
context "artifacts file is too large" do
- it "should fail to post too large artifact" do
+ it "fails to post too large artifact" do
stub_application_setting(max_artifacts_size: 0)
upload_artifacts(file_upload, headers_with_token)
expect(response).to have_http_status(413)
@@ -430,14 +430,14 @@ describe Ci::API::API do
end
context "artifacts post request does not contain file" do
- it "should fail to post artifacts without file" do
+ it "fails to post artifacts without file" do
post post_url, {}, headers_with_token
expect(response).to have_http_status(400)
end
end
context 'GitLab Workhorse is not configured' do
- it "should fail to post artifacts without GitLab-Workhorse" do
+ it "fails to post artifacts without GitLab-Workhorse" do
post post_url, { token: build.token }, {}
expect(response).to have_http_status(403)
end
@@ -456,7 +456,7 @@ describe Ci::API::API do
FileUtils.remove_entry @tmpdir
end
- it "should fail to post artifacts for outside of tmp path" do
+ it "fails to post artifacts for outside of tmp path" do
upload_artifacts(file_upload, headers_with_token)
expect(response).to have_http_status(400)
end
@@ -482,7 +482,7 @@ describe Ci::API::API do
build.reload
end
- it 'should remove build artifacts' do
+ it 'removes build artifacts' do
expect(response).to have_http_status(200)
expect(build.artifacts_file.exists?).to be_falsy
expect(build.artifacts_metadata.exists?).to be_falsy
@@ -500,14 +500,14 @@ describe Ci::API::API do
'Content-Disposition' => 'attachment; filename=ci_build_artifacts.zip' }
end
- it 'should download artifact' do
+ it 'downloads artifact' do
expect(response).to have_http_status(200)
expect(response.headers).to include download_headers
end
end
context 'build does not has artifacts' do
- it 'should respond with not found' do
+ it 'responds with not found' do
expect(response).to have_http_status(404)
end
end
diff --git a/spec/requests/ci/api/triggers_spec.rb b/spec/requests/ci/api/triggers_spec.rb
index f12678e5a8e..3312bd11669 100644
--- a/spec/requests/ci/api/triggers_spec.rb
+++ b/spec/requests/ci/api/triggers_spec.rb
@@ -19,17 +19,17 @@ describe Ci::API::API do
end
context 'Handles errors' do
- it 'should return bad request if token is missing' do
+ it 'returns bad request if token is missing' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger")
expect(response).to have_http_status(400)
end
- it 'should return not found if project is not found' do
+ it 'returns not found if project is not found' do
post ci_api('/projects/0/refs/master/trigger'), options
expect(response).to have_http_status(404)
end
- it 'should return unauthorized if token is for different project' do
+ it 'returns unauthorized if token is for different project' do
post ci_api("/projects/#{project2.ci_id}/refs/master/trigger"), options
expect(response).to have_http_status(401)
end
@@ -38,14 +38,14 @@ describe Ci::API::API do
context 'Have a commit' do
let(:pipeline) { project.pipelines.last }
- it 'should create builds' do
+ it 'creates builds' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options
expect(response).to have_http_status(201)
pipeline.builds.reload
expect(pipeline.builds.size).to eq(2)
end
- it 'should return bad request with no builds created if there\'s no commit for that ref' do
+ it 'returns bad request with no builds created if there\'s no commit for that ref' do
post ci_api("/projects/#{project.ci_id}/refs/other-branch/trigger"), options
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('No builds created')
@@ -56,19 +56,19 @@ describe Ci::API::API do
{ 'TRIGGER_KEY' => 'TRIGGER_VALUE' }
end
- it 'should validate variables to be a hash' do
+ it 'validates variables to be a hash' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: 'value')
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('variables needs to be a hash')
end
- it 'should validate variables needs to be a map of key-valued strings' do
+ it 'validates variables needs to be a map of key-valued strings' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: { key: %w(1 2) })
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('variables needs to be a map of key-valued strings')
end
- it 'create trigger request with variables' do
+ it 'creates trigger request with variables' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: variables)
expect(response).to have_http_status(201)
pipeline.builds.reload