diff options
Diffstat (limited to 'spec')
114 files changed, 1084 insertions, 1083 deletions
diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb index 19d05aef0a6..5e2a8cf3849 100644 --- a/spec/controllers/projects/project_members_controller_spec.rb +++ b/spec/controllers/projects/project_members_controller_spec.rb @@ -167,7 +167,7 @@ describe Projects::ProjectMembersController do sign_in(user) end - it 'does not remove himself from the project' do + it 'cannot remove himself from the project' do delete :leave, namespace_id: project.namespace, project_id: project diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb index 675d9bd18b7..786e1456f5f 100644 --- a/spec/factories_spec.rb +++ b/spec/factories_spec.rb @@ -9,7 +9,7 @@ describe 'factories' do expect { entity }.not_to raise_error end - it 'should be valid', if: factory.build_class < ActiveRecord::Base do + it 'is valid', if: factory.build_class < ActiveRecord::Base do expect(entity).to be_valid end end diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index faecad744c0..9c7c79f57c6 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -46,13 +46,13 @@ describe DiffHelper do expect(diff_options).to include(no_collapse: true) end - it 'should return paths if action name diff_for_path and param old path' do + it 'returns paths if action name diff_for_path and param old path' do allow(controller).to receive(:params) { { old_path: 'lib/wadus.rb' } } allow(controller).to receive(:action_name) { 'diff_for_path' } expect(diff_options[:paths]).to include('lib/wadus.rb') end - it 'should return paths if action name diff_for_path and param new path' do + it 'returns paths if action name diff_for_path and param new path' do allow(controller).to receive(:params) { { new_path: 'lib/wadus.rb' } } allow(controller).to receive(:action_name) { 'diff_for_path' } expect(diff_options[:paths]).to include('lib/wadus.rb') diff --git a/spec/lib/disable_email_interceptor_spec.rb b/spec/lib/disable_email_interceptor_spec.rb index 309a88151cf..8f51474476d 100644 --- a/spec/lib/disable_email_interceptor_spec.rb +++ b/spec/lib/disable_email_interceptor_spec.rb @@ -5,7 +5,7 @@ describe DisableEmailInterceptor, lib: true do Mail.register_interceptor(DisableEmailInterceptor) end - it 'should not send emails' do + it 'does not send emails' do allow(Gitlab.config.gitlab).to receive(:email_enabled).and_return(false) expect { deliver_mail }.not_to change(ActionMailer::Base.deliveries, :count) end diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index 566035c60d0..b12a7b98d4d 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -25,7 +25,7 @@ describe ExtractsPath, lib: true do @project = create(:project) end - it "log tree path should have no escape sequences" do + it "log tree path has no escape sequences" do assign_ref_vars expect(@logs_path).to eq("/#{@project.path_with_namespace}/refs/#{ref}/logs_tree/files/ruby/popen.rb") end @@ -33,7 +33,7 @@ describe ExtractsPath, lib: true do context 'escaped sequences in ref' do let(:ref) { "improve%2Fawesome" } - it "id should have no escape sequences" do + it "id has no escape sequences" do assign_ref_vars expect(@ref).to eq('improve/awesome') expect(@logs_path).to eq("/#{@project.path_with_namespace}/refs/#{ref}/logs_tree/files/ruby/popen.rb") diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index 32ca8239845..4aba783dc33 100644 --- a/spec/lib/gitlab/asciidoc_spec.rb +++ b/spec/lib/gitlab/asciidoc_spec.rb @@ -8,7 +8,7 @@ module Gitlab let(:html) { 'H<sub>2</sub>O' } context "without project" do - it "should convert the input using Asciidoctor and default options" do + it "converts the input using Asciidoctor and default options" do expected_asciidoc_opts = { safe: :secure, backend: :html5, @@ -24,7 +24,7 @@ module Gitlab context "with asciidoc_opts" do let(:asciidoc_opts) { { safe: :safe, attributes: ['foo'] } } - it "should merge the options with default ones" do + it "merges the options with default ones" do expected_asciidoc_opts = { safe: :safe, backend: :html5, diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index 7bec1367156..b0772cad312 100644 --- a/spec/lib/gitlab/auth_spec.rb +++ b/spec/lib/gitlab/auth_spec.rb @@ -51,24 +51,24 @@ describe Gitlab::Auth, lib: true do let(:username) { 'John' } # username isn't lowercase, test this let(:password) { 'my-secret' } - it "should find user by valid login/password" do + it "finds user by valid login/password" do expect( gl_auth.find_with_user_password(username, password) ).to eql user end - it 'should find user by valid email/password with case-insensitive email' do + it 'finds user by valid email/password with case-insensitive email' do expect(gl_auth.find_with_user_password(user.email.upcase, password)).to eql user end - it 'should find user by valid username/password with case-insensitive username' do + it 'finds user by valid username/password with case-insensitive username' do expect(gl_auth.find_with_user_password(username.upcase, password)).to eql user end - it "should not find user with invalid password" do + it "does not find user with invalid password" do password = 'wrong' expect( gl_auth.find_with_user_password(username, password) ).not_to eql user end - it "should not find user with invalid login" do + it "does not find user with invalid login" do user = 'wrong' expect( gl_auth.find_with_user_password(username, password) ).not_to eql user end diff --git a/spec/lib/gitlab/ldap/access_spec.rb b/spec/lib/gitlab/ldap/access_spec.rb index acd5394382c..534bcbf39fe 100644 --- a/spec/lib/gitlab/ldap/access_spec.rb +++ b/spec/lib/gitlab/ldap/access_spec.rb @@ -64,7 +64,7 @@ describe Gitlab::LDAP::Access, lib: true do user.ldap_block end - it 'should unblock user in GitLab' do + it 'unblocks user in GitLab' do access.allowed? expect(user).not_to be_blocked end diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb index 949f6e2b19a..89790c9e1af 100644 --- a/spec/lib/gitlab/ldap/user_spec.rb +++ b/spec/lib/gitlab/ldap/user_spec.rb @@ -36,7 +36,7 @@ describe Gitlab::LDAP::User, lib: true do expect(ldap_user.changed?).to be_truthy end - it "dont marks existing ldap user as changed" do + it "does not mark existing ldap user as changed" do create(:omniauth_user, email: 'john@example.com', extern_uid: 'my-uid', provider: 'ldapmain', ldap_email: true) expect(ldap_user.changed?).to be_falsey end diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb index 1fca8a13037..78c669e8fa5 100644 --- a/spec/lib/gitlab/o_auth/user_spec.rb +++ b/spec/lib/gitlab/o_auth/user_spec.rb @@ -42,7 +42,7 @@ describe Gitlab::OAuth::User, lib: true do describe 'signup' do shared_examples 'to verify compliance with allow_single_sign_on' do context 'provider is marked as external' do - it 'should mark user as external' do + it 'marks user as external' do stub_omniauth_config(allow_single_sign_on: ['twitter'], external_providers: ['twitter']) oauth_user.save expect(gl_user).to be_valid @@ -51,7 +51,7 @@ describe Gitlab::OAuth::User, lib: true do end context 'provider was external, now has been removed' do - it 'should not mark external user as internal' do + it 'does not mark external user as internal' do create(:omniauth_user, extern_uid: 'my-uid', provider: 'twitter', external: true) stub_omniauth_config(allow_single_sign_on: ['twitter'], external_providers: ['facebook']) oauth_user.save @@ -62,7 +62,7 @@ describe Gitlab::OAuth::User, lib: true do context 'provider is not external' do context 'when adding a new OAuth identity' do - it 'should not promote an external user to internal' do + it 'does not promote an external user to internal' do user = create(:user, email: 'john@mail.com', external: true) user.identities.create(provider: provider, extern_uid: uid) diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb index 270b89972d7..29abb4d4d07 100644 --- a/spec/lib/gitlab/project_search_results_spec.rb +++ b/spec/lib/gitlab/project_search_results_spec.rb @@ -33,7 +33,7 @@ describe Gitlab::ProjectSearchResults, lib: true do let!(:security_issue_1) { create(:issue, :confidential, project: project, title: 'Security issue 1', author: author) } let!(:security_issue_2) { create(:issue, :confidential, title: 'Security issue 2', project: project, assignee: assignee) } - it 'should not list project confidential issues for non project members' do + it 'does not list project confidential issues for non project members' do results = described_class.new(non_member, project, query) issues = results.objects('issues') @@ -43,7 +43,7 @@ describe Gitlab::ProjectSearchResults, lib: true do expect(results.issues_count).to eq 1 end - it 'should not list project confidential issues for project members with guest role' do + it 'does not list project confidential issues for project members with guest role' do project.team << [member, :guest] results = described_class.new(member, project, query) @@ -55,7 +55,7 @@ describe Gitlab::ProjectSearchResults, lib: true do expect(results.issues_count).to eq 1 end - it 'should list project confidential issues for author' do + it 'lists project confidential issues for author' do results = described_class.new(author, project, query) issues = results.objects('issues') @@ -65,7 +65,7 @@ describe Gitlab::ProjectSearchResults, lib: true do expect(results.issues_count).to eq 2 end - it 'should list project confidential issues for assignee' do + it 'lists project confidential issues for assignee' do results = described_class.new(assignee, project.id, query) issues = results.objects('issues') @@ -75,7 +75,7 @@ describe Gitlab::ProjectSearchResults, lib: true do expect(results.issues_count).to eq 2 end - it 'should list project confidential issues for project members' do + it 'lists project confidential issues for project members' do project.team << [member, :developer] results = described_class.new(member, project, query) @@ -87,7 +87,7 @@ describe Gitlab::ProjectSearchResults, lib: true do expect(results.issues_count).to eq 3 end - it 'should list all project issues for admin' do + it 'lists all project issues for admin' do results = described_class.new(admin, project, query) issues = results.objects('issues') diff --git a/spec/lib/gitlab/saml/user_spec.rb b/spec/lib/gitlab/saml/user_spec.rb index 56bf08e7041..02c139f1a0d 100644 --- a/spec/lib/gitlab/saml/user_spec.rb +++ b/spec/lib/gitlab/saml/user_spec.rb @@ -67,7 +67,7 @@ describe Gitlab::Saml::User, lib: true do end context 'user was external, now should not be' do - it 'should make user internal' do + it 'makes user internal' do existing_user.update_attribute('external', true) saml_user.save expect(gl_user).to be_valid @@ -94,14 +94,14 @@ describe Gitlab::Saml::User, lib: true do context 'with allow_single_sign_on default (["saml"])' do before { stub_omniauth_config(allow_single_sign_on: ['saml']) } - it 'should not throw an error' do + it 'does not throw an error' do expect{ saml_user.save }.not_to raise_error end end context 'with allow_single_sign_on disabled' do before { stub_omniauth_config(allow_single_sign_on: false) } - it 'should throw an error' do + it 'throws an error' do expect{ saml_user.save }.to raise_error StandardError end end @@ -223,7 +223,7 @@ describe Gitlab::Saml::User, lib: true do context 'dont block on create' do before { stub_omniauth_config(block_auto_created_users: false) } - it 'should not block the user' do + it 'does not block the user' do saml_user.save expect(gl_user).to be_valid expect(gl_user).not_to be_blocked @@ -233,7 +233,7 @@ describe Gitlab::Saml::User, lib: true do context 'block on create' do before { stub_omniauth_config(block_auto_created_users: true) } - it 'should block user' do + it 'blocks user' do saml_user.save expect(gl_user).to be_valid expect(gl_user).to be_blocked diff --git a/spec/lib/gitlab/search_results_spec.rb b/spec/lib/gitlab/search_results_spec.rb index 1bb444bf34f..8a656ab0ee9 100644 --- a/spec/lib/gitlab/search_results_spec.rb +++ b/spec/lib/gitlab/search_results_spec.rb @@ -73,7 +73,7 @@ describe Gitlab::SearchResults do let!(:security_issue_4) { create(:issue, :confidential, project: project_3, title: 'Security issue 4', assignee: assignee) } let!(:security_issue_5) { create(:issue, :confidential, project: project_4, title: 'Security issue 5') } - it 'should not list confidential issues for non project members' do + it 'does not list confidential issues for non project members' do results = described_class.new(non_member, limit_projects, query) issues = results.objects('issues') @@ -86,7 +86,7 @@ describe Gitlab::SearchResults do expect(results.issues_count).to eq 1 end - it 'should not list confidential issues for project members with guest role' do + it 'does not list confidential issues for project members with guest role' do project_1.team << [member, :guest] project_2.team << [member, :guest] @@ -102,7 +102,7 @@ describe Gitlab::SearchResults do expect(results.issues_count).to eq 1 end - it 'should list confidential issues for author' do + it 'lists confidential issues for author' do results = described_class.new(author, limit_projects, query) issues = results.objects('issues') @@ -115,7 +115,7 @@ describe Gitlab::SearchResults do expect(results.issues_count).to eq 3 end - it 'should list confidential issues for assignee' do + it 'lists confidential issues for assignee' do results = described_class.new(assignee, limit_projects, query) issues = results.objects('issues') @@ -128,7 +128,7 @@ describe Gitlab::SearchResults do expect(results.issues_count).to eq 3 end - it 'should list confidential issues for project members' do + it 'lists confidential issues for project members' do project_1.team << [member, :developer] project_2.team << [member, :developer] @@ -144,7 +144,7 @@ describe Gitlab::SearchResults do expect(results.issues_count).to eq 4 end - it 'should list all issues for admin' do + it 'lists all issues for admin' do results = described_class.new(admin, limit_projects, query) issues = results.objects('issues') diff --git a/spec/lib/gitlab/upgrader_spec.rb b/spec/lib/gitlab/upgrader_spec.rb index e958e087a80..edadab043d7 100644 --- a/spec/lib/gitlab/upgrader_spec.rb +++ b/spec/lib/gitlab/upgrader_spec.rb @@ -9,19 +9,19 @@ describe Gitlab::Upgrader, lib: true do end describe 'latest_version?' do - it 'should be true if newest version' do + it 'is true if newest version' do allow(upgrader).to receive(:latest_version_raw).and_return(current_version) expect(upgrader.latest_version?).to be_truthy end end describe 'latest_version_raw' do - it 'should be latest version for GitLab 5' do + it 'is the latest version for GitLab 5' do allow(upgrader).to receive(:current_version_raw).and_return("5.3.0") expect(upgrader.latest_version_raw).to eq("v5.4.2") end - it 'should get the latest version from tags' do + it 'gets the latest version from tags' do allow(upgrader).to receive(:fetch_git_tags).and_return([ '6f0733310546402c15d3ae6128a95052f6c8ea96 refs/tags/v7.1.1', 'facfec4b242ce151af224e20715d58e628aa5e74 refs/tags/v7.1.1^{}', diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb index c6758ccad39..781472d0c00 100644 --- a/spec/mailers/emails/profile_spec.rb +++ b/spec/mailers/emails/profile_spec.rb @@ -48,7 +48,7 @@ describe Notify do it_behaves_like 'it should not have Gmail Actions links' it_behaves_like 'a user cannot unsubscribe through footer link' - it 'should not contain the new user\'s password' do + it 'does not contain the new user\'s password' do is_expected.not_to have_body_text /password/ end end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index e2866ef160c..fa241867858 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -591,7 +591,7 @@ describe Notify do is_expected.to have_body_text /#{note.note}/ end - it 'not contains note author' do + it 'does not contain note author' do is_expected.not_to have_body_text /wrote\:/ end diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index fb040ba82bc..cc215d252f9 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -53,59 +53,59 @@ describe ApplicationSetting, models: true do end context 'restricted signup domains' do - it 'set single domain' do + it 'sets single domain' do setting.domain_whitelist_raw = 'example.com' expect(setting.domain_whitelist).to eq(['example.com']) end - it 'set multiple domains with spaces' do + it 'sets multiple domains with spaces' do setting.domain_whitelist_raw = 'example.com *.example.com' expect(setting.domain_whitelist).to eq(['example.com', '*.example.com']) end - it 'set multiple domains with newlines and a space' do + it 'sets multiple domains with newlines and a space' do setting.domain_whitelist_raw = "example.com\n *.example.com" expect(setting.domain_whitelist).to eq(['example.com', '*.example.com']) end - it 'set multiple domains with commas' do + it 'sets multiple domains with commas' do setting.domain_whitelist_raw = "example.com, *.example.com" expect(setting.domain_whitelist).to eq(['example.com', '*.example.com']) end end context 'blacklisted signup domains' do - it 'set single domain' do + it 'sets single domain' do setting.domain_blacklist_raw = 'example.com' expect(setting.domain_blacklist).to contain_exactly('example.com') end - it 'set multiple domains with spaces' do + it 'sets multiple domains with spaces' do setting.domain_blacklist_raw = 'example.com *.example.com' expect(setting.domain_blacklist).to contain_exactly('example.com', '*.example.com') end - it 'set multiple domains with newlines and a space' do + it 'sets multiple domains with newlines and a space' do setting.domain_blacklist_raw = "example.com\n *.example.com" expect(setting.domain_blacklist).to contain_exactly('example.com', '*.example.com') end - it 'set multiple domains with commas' do + it 'sets multiple domains with commas' do setting.domain_blacklist_raw = "example.com, *.example.com" expect(setting.domain_blacklist).to contain_exactly('example.com', '*.example.com') end - it 'set multiple domains with semicolon' do + it 'sets multiple domains with semicolon' do setting.domain_blacklist_raw = "example.com; *.example.com" expect(setting.domain_blacklist).to contain_exactly('example.com', '*.example.com') end - it 'set multiple domains with mixture of everything' do + it 'sets multiple domains with mixture of everything' do setting.domain_blacklist_raw = "example.com; *.example.com\n test.com\sblock.com yes.com" expect(setting.domain_blacklist).to contain_exactly('example.com', '*.example.com', 'test.com', 'block.com', 'yes.com') end - it 'set multiple domain with file' do + it 'sets multiple domain with file' do setting.domain_blacklist_file = File.open(Rails.root.join('spec/fixtures/', 'domain_blacklist.txt')) expect(setting.domain_blacklist).to contain_exactly('example.com', 'test.com', 'foo.bar') end diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb index 6ad8bfef4f2..72688137f08 100644 --- a/spec/models/broadcast_message_spec.rb +++ b/spec/models/broadcast_message_spec.rb @@ -23,19 +23,19 @@ describe BroadcastMessage, models: true do end describe '.current' do - it "should return last message if time match" do + it "returns last message if time match" do message = create(:broadcast_message) expect(BroadcastMessage.current).to eq message end - it "should return nil if time not come" do + it "returns nil if time not come" do create(:broadcast_message, :future) expect(BroadcastMessage.current).to be_nil end - it "should return nil if time has passed" do + it "returns nil if time has passed" do create(:broadcast_message, :expired) expect(BroadcastMessage.current).to be_nil diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb index dc88697199b..9ecc9aac84b 100644 --- a/spec/models/build_spec.rb +++ b/spec/models/build_spec.rb @@ -32,7 +32,7 @@ describe Ci::Build, models: true do end let(:create_from_build) { Ci::Build.create_from build } - it 'there should be a pending task' do + it 'exists a pending task' do expect(Ci::Build.pending.count(:all)).to eq 0 create_from_build expect(Ci::Build.pending.count(:all)).to be > 0 @@ -573,19 +573,19 @@ describe Ci::Build, models: true do let!(:rubocop_test) { create(:ci_build, pipeline: pipeline, name: 'rubocop', stage_idx: 1, stage: 'test') } let!(:staging) { create(:ci_build, pipeline: pipeline, name: 'staging', stage_idx: 2, stage: 'deploy') } - it 'to have no dependents if this is first build' do + it 'expects to have no dependents if this is first build' do expect(build.depends_on_builds).to be_empty end - it 'to have one dependent if this is test' do + it 'expects to have one dependent if this is test' do expect(rspec_test.depends_on_builds.map(&:id)).to contain_exactly(build.id) end - it 'to have all builds from build and test stage if this is last' do + it 'expects to have all builds from build and test stage if this is last' do expect(staging.depends_on_builds.map(&:id)).to contain_exactly(build.id, rspec_test.id, rubocop_test.id) end - it 'to have retried builds instead the original ones' do + it 'expects to have retried builds instead the original ones' do retried_rspec = Ci::Build.retry(rspec_test) expect(staging.depends_on_builds.map(&:id)).to contain_exactly(build.id, retried_rspec.id, rubocop_test.id) end @@ -655,23 +655,23 @@ describe Ci::Build, models: true do describe 'build erasable' do shared_examples 'erasable' do - it 'should remove artifact file' do + it 'removes artifact file' do expect(build.artifacts_file.exists?).to be_falsy end - it 'should remove artifact metadata file' do + it 'removes artifact metadata file' do expect(build.artifacts_metadata.exists?).to be_falsy end - it 'should erase build trace in trace file' do + it 'erases build trace in trace file' do expect(build.trace).to be_empty end - it 'should set erased to true' do + it 'sets erased to true' do expect(build.erased?).to be true end - it 'should set erase date' do + it 'sets erase date' do expect(build.erased_at).not_to be_falsy end end @@ -704,7 +704,7 @@ describe Ci::Build, models: true do include_examples 'erasable' - it 'should record user who erased a build' do + it 'records user who erased a build' do expect(build.erased_by).to eq user end end @@ -714,7 +714,7 @@ describe Ci::Build, models: true do include_examples 'erasable' - it 'should not set user who erased a build' do + it 'does not set user who erased a build' do expect(build.erased_by).to be_nil end end @@ -750,7 +750,7 @@ describe Ci::Build, models: true do end describe '#erase' do - it 'should not raise error' do + it 'does not raise error' do expect { build.erase }.not_to raise_error end end @@ -900,7 +900,7 @@ describe Ci::Build, models: true do context 'when build is running' do before { build.run! } - it 'should return false' do + it 'returns false' do expect(build.retryable?).to be false end end @@ -908,7 +908,7 @@ describe Ci::Build, models: true do context 'when build is finished' do before { build.success! } - it 'should return true' do + it 'returns true' do expect(build.retryable?).to be true end end diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 0d4c86955ce..ccee591cf7a 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -427,7 +427,7 @@ describe Ci::Pipeline, models: true do end describe '#update_state' do - it 'execute update_state after touching object' do + it 'executes update_state after touching object' do expect(pipeline).to receive(:update_state).and_return(true) pipeline.touch end @@ -435,7 +435,7 @@ describe Ci::Pipeline, models: true do context 'dependent objects' do let(:commit_status) { build :commit_status, pipeline: pipeline } - it 'execute update_state after saving dependent object' do + it 'executes update_state after saving dependent object' do expect(pipeline).to receive(:update_state).and_return(true) commit_status.save end @@ -513,7 +513,7 @@ describe Ci::Pipeline, models: true do create :ci_build, :success, pipeline: pipeline, name: 'rspec' create :ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: 'rubocop' end - + it 'returns true' do is_expected.to be_truthy end @@ -524,7 +524,7 @@ describe Ci::Pipeline, models: true do create :ci_build, :success, pipeline: pipeline, name: 'rspec' create :ci_build, :allowed_to_fail, :success, pipeline: pipeline, name: 'rubocop' end - + it 'returns false' do is_expected.to be_falsey end diff --git a/spec/models/ci/trigger_spec.rb b/spec/models/ci/trigger_spec.rb index 474b0b1621d..3ca9231f58e 100644 --- a/spec/models/ci/trigger_spec.rb +++ b/spec/models/ci/trigger_spec.rb @@ -4,12 +4,12 @@ describe Ci::Trigger, models: true do let(:project) { FactoryGirl.create :empty_project } describe 'before_validation' do - it 'should set an random token if none provided' do + it 'sets an random token if none provided' do trigger = FactoryGirl.create :ci_trigger_without_token, project: project expect(trigger.token).not_to be_nil end - it 'should not set an random token if one provided' do + it 'does not set an random token if one provided' do trigger = FactoryGirl.create :ci_trigger, project: project expect(trigger.token).to eq('token') end diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index ff6371ad685..fcfa3138ce5 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -133,7 +133,7 @@ describe CommitStatus, models: true do @commit5 = FactoryGirl.create :commit_status, pipeline: pipeline, name: 'aa', ref: 'bb', status: 'success' end - it 'return unique statuses' do + it 'returns unique statuses' do is_expected.to eq([@commit4, @commit5]) end end @@ -149,7 +149,7 @@ describe CommitStatus, models: true do @commit5 = FactoryGirl.create :commit_status, pipeline: pipeline, name: 'ee', ref: nil, status: 'canceled' end - it 'return statuses that are running or pending' do + it 'returns statuses that are running or pending' do is_expected.to eq([@commit1, @commit2]) end end @@ -160,7 +160,7 @@ describe CommitStatus, models: true do context 'when no before_sha is set for pipeline' do before { pipeline.before_sha = nil } - it 'return blank sha' do + it 'returns blank sha' do is_expected.to eq(Gitlab::Git::BLANK_SHA) end end @@ -169,7 +169,7 @@ describe CommitStatus, models: true do let(:value) { '1234' } before { pipeline.before_sha = value } - it 'return the set value' do + it 'returns the set value' do is_expected.to eq(value) end end @@ -186,7 +186,7 @@ describe CommitStatus, models: true do context 'stages list' do subject { CommitStatus.where(pipeline: pipeline).stages } - it 'return ordered list of stages' do + it 'returns ordered list of stages' do is_expected.to eq(%w(build test deploy)) end end @@ -194,7 +194,7 @@ describe CommitStatus, models: true do context 'stages with statuses' do subject { CommitStatus.where(pipeline: pipeline).latest.stages_status } - it 'return list of stages with statuses' do + it 'returns list of stages with statuses' do is_expected.to eq({ 'build' => 'failed', 'test' => 'success', diff --git a/spec/models/concerns/milestoneish_spec.rb b/spec/models/concerns/milestoneish_spec.rb index 7e9ab8940cf..b7e973798a3 100644 --- a/spec/models/concerns/milestoneish_spec.rb +++ b/spec/models/concerns/milestoneish_spec.rb @@ -26,53 +26,53 @@ describe Milestone, 'Milestoneish' do end describe '#closed_items_count' do - it 'should not count confidential issues for non project members' do + it 'does not count confidential issues for non project members' do expect(milestone.closed_items_count(non_member)).to eq 2 end - it 'should not count confidential issues for project members with guest role' do + it 'does not count confidential issues for project members with guest role' do expect(milestone.closed_items_count(guest)).to eq 2 end - it 'should count confidential issues for author' do + it 'counts confidential issues for author' do expect(milestone.closed_items_count(author)).to eq 4 end - it 'should count confidential issues for assignee' do + it 'counts confidential issues for assignee' do expect(milestone.closed_items_count(assignee)).to eq 4 end - it 'should count confidential issues for project members' do + it 'counts confidential issues for project members' do expect(milestone.closed_items_count(member)).to eq 6 end - it 'should count all issues for admin' do + it 'counts all issues for admin' do expect(milestone.closed_items_count(admin)).to eq 6 end end describe '#total_items_count' do - it 'should not count confidential issues for non project members' do + it 'does not count confidential issues for non project members' do expect(milestone.total_items_count(non_member)).to eq 4 end - it 'should not count confidential issues for project members with guest role' do + it 'does not count confidential issues for project members with guest role' do expect(milestone.total_items_count(guest)).to eq 4 end - it 'should count confidential issues for author' do + it 'counts confidential issues for author' do expect(milestone.total_items_count(author)).to eq 7 end - it 'should count confidential issues for assignee' do + it 'counts confidential issues for assignee' do expect(milestone.total_items_count(assignee)).to eq 7 end - it 'should count confidential issues for project members' do + it 'counts confidential issues for project members' do expect(milestone.total_items_count(member)).to eq 10 end - it 'should count all issues for admin' do + it 'counts all issues for admin' do expect(milestone.total_items_count(admin)).to eq 10 end end @@ -91,27 +91,27 @@ describe Milestone, 'Milestoneish' do end describe '#percent_complete' do - it 'should not count confidential issues for non project members' do + it 'does not count confidential issues for non project members' do expect(milestone.percent_complete(non_member)).to eq 50 end - it 'should not count confidential issues for project members with guest role' do + it 'does not count confidential issues for project members with guest role' do expect(milestone.percent_complete(guest)).to eq 50 end - it 'should count confidential issues for author' do + it 'counts confidential issues for author' do expect(milestone.percent_complete(author)).to eq 57 end - it 'should count confidential issues for assignee' do + it 'counts confidential issues for assignee' do expect(milestone.percent_complete(assignee)).to eq 57 end - it 'should count confidential issues for project members' do + it 'counts confidential issues for project members' do expect(milestone.percent_complete(member)).to eq 60 end - it 'should count confidential issues for admin' do + it 'counts confidential issues for admin' do expect(milestone.percent_complete(admin)).to eq 60 end end diff --git a/spec/models/concerns/token_authenticatable_spec.rb b/spec/models/concerns/token_authenticatable_spec.rb index 9e8ebc56a31..eb64f3d0c83 100644 --- a/spec/models/concerns/token_authenticatable_spec.rb +++ b/spec/models/concerns/token_authenticatable_spec.rb @@ -41,7 +41,7 @@ describe ApplicationSetting, 'TokenAuthenticatable' do describe 'ensured! token' do subject { described_class.new.send("ensure_#{token_field}!") } - it 'should persist new token' do + it 'persists new token' do expect(subject).to eq described_class.current[token_field] end end diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb index f94987dcaff..9c81d159cdf 100644 --- a/spec/models/forked_project_link_spec.rb +++ b/spec/models/forked_project_link_spec.rb @@ -9,11 +9,11 @@ describe ForkedProjectLink, "add link on fork" do @project_to = fork_project(project_from, user) end - it "project_to should know it is forked" do + it "project_to knows it is forked" do expect(@project_to.forked?).to be_truthy end - it "project should know who it is forked from" do + it "project knows who it is forked from" do expect(@project_to.forked_from_project).to eq(project_from) end end @@ -29,15 +29,15 @@ describe '#forked?' do forked_project_link.save! end - it "project_to should know it is forked" do + it "project_to knows it is forked" do expect(project_to.forked?).to be_truthy end - it "project_from should not be forked" do + it "project_from is not forked" do expect(project_from.forked?).to be_falsey end - it "project_to.destroy should destroy fork_link" do + it "project_to.destroy destroys fork_link" do expect(forked_project_link).to receive(:destroy) project_to.destroy end diff --git a/spec/models/global_milestone_spec.rb b/spec/models/global_milestone_spec.rb index ae77ec5b348..92e0f7f27ce 100644 --- a/spec/models/global_milestone_spec.rb +++ b/spec/models/global_milestone_spec.rb @@ -29,15 +29,15 @@ describe GlobalMilestone, models: true do @global_milestones = GlobalMilestone.build_collection(milestones) end - it 'should have all project milestones' do + it 'has all project milestones' do expect(@global_milestones.count).to eq(2) end - it 'should have all project milestones titles' do + it 'has all project milestones titles' do expect(@global_milestones.map(&:title)).to match_array(['Milestone v1.2', 'VD-123']) end - it 'should have all project milestones' do + it 'has all project milestones' do expect(@global_milestones.map { |group_milestone| group_milestone.milestones.count }.sum).to eq(6) end end @@ -54,11 +54,11 @@ describe GlobalMilestone, models: true do @global_milestone = GlobalMilestone.new(milestone1_project1.title, milestones) end - it 'should have exactly one group milestone' do + it 'has exactly one group milestone' do expect(@global_milestone.title).to eq('Milestone v1.2') end - it 'should have all project milestones with the same title' do + it 'has all project milestones with the same title' do expect(@global_milestone.milestones.count).to eq(3) end end @@ -66,7 +66,7 @@ describe GlobalMilestone, models: true do describe '#safe_title' do let(:milestone) { create(:milestone, title: "git / test", project: project1) } - it 'should strip out slashes and spaces' do + it 'strips out slashes and spaces' do global_milestone = GlobalMilestone.new(milestone.title, [milestone]) expect(global_milestone.safe_title).to eq('git-test') diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 266c46213a6..ea4b59c26b1 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -116,7 +116,7 @@ describe Group, models: true do let(:user) { create(:user) } before { group.add_users([user.id], GroupMember::GUEST) } - it "should update the group permission" do + it "updates the group permission" do expect(group.group_members.guests.map(&:user)).to include(user) group.add_users([user.id], GroupMember::DEVELOPER) expect(group.group_members.developers.map(&:user)).to include(user) @@ -128,12 +128,12 @@ describe Group, models: true do let(:user) { create(:user) } before { group.add_user(user, GroupMember::MASTER) } - it "should be true if avatar is image" do + it "is true if avatar is image" do group.update_attribute(:avatar, 'uploads/avatar.png') expect(group.avatar_type).to be_truthy end - it "should be false if avatar is html page" do + it "is false if avatar is html page" do group.update_attribute(:avatar, 'uploads/avatar.html') expect(group.avatar_type).to eq(["only images allowed"]) end diff --git a/spec/models/hooks/project_hook_spec.rb b/spec/models/hooks/project_hook_spec.rb index 983848392b7..4a457997a4f 100644 --- a/spec/models/hooks/project_hook_spec.rb +++ b/spec/models/hooks/project_hook_spec.rb @@ -24,7 +24,7 @@ describe ProjectHook, models: true do end describe '.push_hooks' do - it 'should return hooks for push events only' do + it 'returns hooks for push events only' do hook = create(:project_hook, push_events: true) create(:project_hook, push_events: false) expect(ProjectHook.push_hooks).to eq([hook]) @@ -32,7 +32,7 @@ describe ProjectHook, models: true do end describe '.tag_push_hooks' do - it 'should return hooks for tag push events only' do + it 'returns hooks for tag push events only' do hook = create(:project_hook, tag_push_events: true) create(:project_hook, tag_push_events: false) expect(ProjectHook.tag_push_hooks).to eq([hook]) diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 6d68e52a822..fd4a2beff58 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -73,13 +73,13 @@ describe Key, models: true do end context 'callbacks' do - it 'should add new key to authorized_file' do + it 'adds new key to authorized_file' do @key = build(:personal_key, id: 7) expect(GitlabShellWorker).to receive(:perform_async).with(:add_key, @key.shell_id, @key.key) @key.save end - it 'should remove key from authorized_file' do + it 'removes key from authorized_file' do @key = create(:personal_key) expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, @key.shell_id, @key.key) @key.destroy diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb index f37f44a608e..2a09063f857 100644 --- a/spec/models/label_spec.rb +++ b/spec/models/label_spec.rb @@ -18,7 +18,7 @@ describe Label, models: true do describe 'validation' do it { is_expected.to validate_presence_of(:project) } - it 'should validate color code' do + it 'validates color code' do expect(label).not_to allow_value('G-ITLAB').for(:color) expect(label).not_to allow_value('AABBCC').for(:color) expect(label).not_to allow_value('#AABBCCEE').for(:color) @@ -30,7 +30,7 @@ describe Label, models: true do expect(label).to allow_value('#abcdef').for(:color) end - it 'should validate title' do + it 'validates title' do expect(label).not_to allow_value('G,ITLAB').for(:title) expect(label).not_to allow_value('').for(:title) diff --git a/spec/models/legacy_diff_note_spec.rb b/spec/models/legacy_diff_note_spec.rb index c8ee656fe3b..2cfd26419ca 100644 --- a/spec/models/legacy_diff_note_spec.rb +++ b/spec/models/legacy_diff_note_spec.rb @@ -5,12 +5,12 @@ describe LegacyDiffNote, models: true do let!(:note) { create(:legacy_diff_note_on_commit, note: "+1 from me") } let!(:commit) { note.noteable } - it "should save a valid note" do + it "saves a valid note" do expect(note.commit_id).to eq(commit.id) expect(note.noteable.id).to eq(commit.id) end - it "should be recognized by #legacy_diff_note?" do + it "is recognized by #legacy_diff_note?" do expect(note).to be_legacy_diff_note end end diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb index 18439cac2a4..4f875fd257a 100644 --- a/spec/models/members/group_member_spec.rb +++ b/spec/models/members/group_member_spec.rb @@ -22,7 +22,7 @@ require 'spec_helper' describe GroupMember, models: true do describe 'notifications' do describe "#after_create" do - it "should send email to user" do + it "sends email to user" do membership = build(:group_member) allow(membership).to receive(:notification_service). @@ -40,7 +40,7 @@ describe GroupMember, models: true do and_return(double('NotificationService').as_null_object) end - it "should send email to user" do + it "sends email to user" do expect(@group_member).to receive(:notification_service) @group_member.update_attribute(:access_level, GroupMember::MASTER) end diff --git a/spec/models/members/project_member_spec.rb b/spec/models/members/project_member_spec.rb index e7c0c506463..28673de3189 100644 --- a/spec/models/members/project_member_spec.rb +++ b/spec/models/members/project_member_spec.rb @@ -52,7 +52,7 @@ describe ProjectMember, models: true do master_todos end - it "destroy itself and delete associated todos" do + it "destroys itself and delete associated todos" do expect(owner.user.todos.size).to eq(2) expect(master.user.todos.size).to eq(3) expect(Todo.count).to eq(5) diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index d793cfd0bde..3270b877c1a 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -188,12 +188,12 @@ describe MergeRequest, models: true do create(:note, noteable: merge_request, project: merge_request.project) end - it "should include notes for commits" do + it "includes notes for commits" do expect(merge_request.commits).not_to be_empty expect(merge_request.mr_and_commit_notes.count).to eq(2) end - it "should include notes for commits from target project as well" do + it "includes notes for commits from target project as well" do create(:note_on_commit, commit_id: merge_request.commits.first.id, project: merge_request.target_project) @@ -304,7 +304,7 @@ describe MergeRequest, models: true do expect(subject.can_remove_source_branch?(user)).to be_falsey end - it "cant remove a root ref" do + it "can't remove a root ref" do subject.source_branch = "master" subject.target_branch = "feature" diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index d661dc0e59a..d64d6cde2b5 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -28,12 +28,12 @@ describe Milestone, models: true do end describe "unique milestone title per project" do - it "shouldn't accept the same title in a project twice" do + it "does not accept the same title in a project twice" do new_milestone = Milestone.new(project: milestone.project, title: milestone.title) expect(new_milestone).not_to be_valid end - it "should accept the same title in another project" do + it "accepts the same title in another project" do project = build(:project) new_milestone = Milestone.new(project: project, title: milestone.title) @@ -42,29 +42,29 @@ describe Milestone, models: true do end describe "#percent_complete" do - it "should not count open issues" do + it "does not count open issues" do milestone.issues << issue expect(milestone.percent_complete(user)).to eq(0) end - it "should count closed issues" do + it "counts closed issues" do issue.close milestone.issues << issue expect(milestone.percent_complete(user)).to eq(100) end - it "should recover from dividing by zero" do + it "recovers from dividing by zero" do expect(milestone.percent_complete(user)).to eq(0) end end describe "#expires_at" do - it "should be nil when due_date is unset" do + it "is nil when due_date is unset" do milestone.update_attributes(due_date: nil) expect(milestone.expires_at).to be_nil end - it "should not be nil when due_date is set" do + it "is not nil when due_date is set" do milestone.update_attributes(due_date: Date.tomorrow) expect(milestone.expires_at).to be_present end @@ -121,7 +121,7 @@ describe Milestone, models: true do create :merge_request, milestone: milestone end - it 'Should return total count of issues and merge requests assigned to milestone' do + it 'returns total count of issues and merge requests assigned to milestone' do expect(milestone.total_items_count(user)).to eq 2 end end @@ -134,11 +134,11 @@ describe Milestone, models: true do create :issue end - it 'should be true if milestone active and all nested issues closed' do + it 'returns true if milestone active and all nested issues closed' do expect(milestone.can_be_closed?).to be_truthy end - it 'should be false if milestone active and not all nested issues closed' do + it 'returns false if milestone active and not all nested issues closed' do issue.milestone = milestone issue.save diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index a162da0208e..544920d1824 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -61,11 +61,11 @@ describe Namespace, models: true do allow(@namespace).to receive(:path_changed?).and_return(true) end - it "should raise error when directory exists" do + it "raises error when directory exists" do expect { @namespace.move_dir }.to raise_error("namespace directory cannot be moved") end - it "should move dir if path changed" do + it "moves dir if path changed" do new_path = @namespace.path + "_new" allow(@namespace).to receive(:path_was).and_return(@namespace.path) allow(@namespace).to receive(:path).and_return(new_path) @@ -93,7 +93,7 @@ describe Namespace, models: true do before { namespace.destroy } - it "should remove its dirs when deleted" do + it "removes its dirs when deleted" do expect(File.exist?(path)).to be(false) end end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 1243f5420a7..53733d253f7 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -56,18 +56,18 @@ describe Note, models: true do let!(:note) { create(:note_on_commit, note: "+1 from me") } let!(:commit) { note.noteable } - it "should be accessible through #noteable" do + it "is accessible through #noteable" do expect(note.commit_id).to eq(commit.id) expect(note.noteable).to be_a(Commit) expect(note.noteable).to eq(commit) end - it "should save a valid note" do + it "saves a valid note" do expect(note.commit_id).to eq(commit.id) note.noteable == commit end - it "should be recognized by #for_commit?" do + it "is recognized by #for_commit?" do expect(note).to be_for_commit end diff --git a/spec/models/project_security_spec.rb b/spec/models/project_security_spec.rb index 2142c7c13ef..36379074ea0 100644 --- a/spec/models/project_security_spec.rb +++ b/spec/models/project_security_spec.rb @@ -21,7 +21,7 @@ describe Project, models: true do let(:owner_actions) { Ability.project_owner_rules } describe "Non member rules" do - it "should deny for non-project users any actions" do + it "denies for non-project users any actions" do owner_actions.each do |action| expect(@abilities.allowed?(@u1, action, @p1)).to be_falsey end @@ -33,7 +33,7 @@ describe Project, models: true do @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::GUEST) end - it "should allow for project user any guest actions" do + it "allows for project user any guest actions" do guest_actions.each do |action| expect(@abilities.allowed?(@u2, action, @p1)).to be_truthy end @@ -45,7 +45,7 @@ describe Project, models: true do @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::REPORTER) end - it "should allow for project user any report actions" do + it "allows for project user any report actions" do report_actions.each do |action| expect(@abilities.allowed?(@u2, action, @p1)).to be_truthy end @@ -58,13 +58,13 @@ describe Project, models: true do @p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::DEVELOPER) end - it "should deny for developer master-specific actions" do + it "denies for developer master-specific actions" do [dev_actions - report_actions].each do |action| expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey end end - it "should allow for project user any dev actions" do + it "allows for project user any dev actions" do dev_actions.each do |action| expect(@abilities.allowed?(@u3, action, @p1)).to be_truthy end @@ -77,13 +77,13 @@ describe Project, models: true do @p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::MASTER) end - it "should deny for developer master-specific actions" do + it "denies for developer master-specific actions" do [master_actions - dev_actions].each do |action| expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey end end - it "should allow for project user any master actions" do + it "allows for project user any master actions" do master_actions.each do |action| expect(@abilities.allowed?(@u3, action, @p1)).to be_truthy end @@ -96,13 +96,13 @@ describe Project, models: true do @p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::MASTER) end - it "should deny for masters admin-specific actions" do + it "denies for masters admin-specific actions" do [owner_actions - master_actions].each do |action| expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey end end - it "should allow for project owner any admin actions" do + it "allows for project owner any admin actions" do owner_actions.each do |action| expect(@abilities.allowed?(@u4, action, @p1)).to be_truthy end diff --git a/spec/models/project_services/asana_service_spec.rb b/spec/models/project_services/asana_service_spec.rb index f3d15f3c1ea..dc702cfc42c 100644 --- a/spec/models/project_services/asana_service_spec.rb +++ b/spec/models/project_services/asana_service_spec.rb @@ -65,7 +65,7 @@ describe AsanaService, models: true do ) end - it 'should call Asana service to create a story' do + it 'calls Asana service to create a story' do data = create_data_for_commits('Message from commit. related to #123456') expected_message = "#{data[:user_name]} pushed to branch #{data[:ref]} of #{project.name_with_namespace} ( #{data[:commits][0][:url]} ): #{data[:commits][0][:message]}" @@ -76,7 +76,7 @@ describe AsanaService, models: true do @asana.execute(data) end - it 'should call Asana service to create a story and close a task' do + it 'calls Asana service to create a story and close a task' do data = create_data_for_commits('fix #456789') d1 = double('Asana::Task') expect(d1).to receive(:add_comment) @@ -86,7 +86,7 @@ describe AsanaService, models: true do @asana.execute(data) end - it 'should be able to close via url' do + it 'is able to close via url' do data = create_data_for_commits('closes https://app.asana.com/19292/956299/42') d1 = double('Asana::Task') expect(d1).to receive(:add_comment) @@ -96,7 +96,7 @@ describe AsanaService, models: true do @asana.execute(data) end - it 'should allow multiple matches per line' do + it 'allows multiple matches per line' do message = <<-EOF minor bigfix, refactoring, fixed #123 and Closes #456 work on #789 ref https://app.asana.com/19292/956299/42 and closing https://app.asana.com/19292/956299/12 diff --git a/spec/models/project_services/assembla_service_spec.rb b/spec/models/project_services/assembla_service_spec.rb index 17e9361dd5c..00c4e0fb64c 100644 --- a/spec/models/project_services/assembla_service_spec.rb +++ b/spec/models/project_services/assembla_service_spec.rb @@ -44,7 +44,7 @@ describe AssemblaService, models: true do WebMock.stub_request(:post, @api_url) end - it "should call Assembla API" do + it "calls Assembla API" do @assembla_service.execute(@sample_data) expect(WebMock).to have_requested(:post, @api_url).with( body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/ diff --git a/spec/models/project_services/external_wiki_service_spec.rb b/spec/models/project_services/external_wiki_service_spec.rb index 5fe5ea7d2df..d7c5ea95d71 100644 --- a/spec/models/project_services/external_wiki_service_spec.rb +++ b/spec/models/project_services/external_wiki_service_spec.rb @@ -56,7 +56,7 @@ describe ExternalWikiService, models: true do @service.destroy! end - it 'should replace the wiki url' do + it 'replaces the wiki url' do wiki_path = get_project_wiki_path(project) expect(wiki_path).to match('https://gitlab.com') end diff --git a/spec/models/project_services/flowdock_service_spec.rb b/spec/models/project_services/flowdock_service_spec.rb index b7e627e6518..6518098ceea 100644 --- a/spec/models/project_services/flowdock_service_spec.rb +++ b/spec/models/project_services/flowdock_service_spec.rb @@ -57,7 +57,7 @@ describe FlowdockService, models: true do WebMock.stub_request(:post, @api_url) end - it "should call FlowDock API" do + it "calls FlowDock API" do @flowdock_service.execute(@sample_data) @sample_data[:commits].each do |commit| # One request to Flowdock per new commit diff --git a/spec/models/project_services/gemnasium_service_spec.rb b/spec/models/project_services/gemnasium_service_spec.rb index a08f1ac229f..2c5583bdaa2 100644 --- a/spec/models/project_services/gemnasium_service_spec.rb +++ b/spec/models/project_services/gemnasium_service_spec.rb @@ -57,7 +57,7 @@ describe GemnasiumService, models: true do ) @sample_data = Gitlab::PushDataBuilder.build_sample(project, user) end - it "should call Gemnasium service" do + it "calls Gemnasium service" do expect(Gemnasium::GitlabService).to receive(:execute).with(an_instance_of(Hash)).once @gemnasium_service.execute(@sample_data) end diff --git a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb index 7a1f106d6e3..8ef79a17d50 100644 --- a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb +++ b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb @@ -54,7 +54,7 @@ describe GitlabIssueTrackerService, models: true do @service.destroy! end - it 'should give the correct path' do + it 'gives the correct path' do expect(@service.project_url).to eq("http://localhost/gitlab/root/#{project.path_with_namespace}/issues") expect(@service.new_issue_url).to eq("http://localhost/gitlab/root/#{project.path_with_namespace}/issues/new") expect(@service.issue_url(432)).to eq("http://localhost/gitlab/root/#{project.path_with_namespace}/issues/432") @@ -71,7 +71,7 @@ describe GitlabIssueTrackerService, models: true do @service.destroy! end - it 'should give the correct path' do + it 'gives the correct path' do expect(@service.project_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues") expect(@service.new_issue_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues/new") expect(@service.issue_path(432)).to eq("/gitlab/root/#{project.path_with_namespace}/issues/432") diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb index 62ae5f6cf74..bf438b26690 100644 --- a/spec/models/project_services/hipchat_service_spec.rb +++ b/spec/models/project_services/hipchat_service_spec.rb @@ -61,7 +61,7 @@ describe HipchatService, models: true do WebMock.stub_request(:post, api_url) end - it 'should test and return errors' do + it 'tests and return errors' do allow(hipchat).to receive(:execute).and_raise(StandardError, 'no such room') result = hipchat.test(push_sample_data) @@ -69,7 +69,7 @@ describe HipchatService, models: true do expect(result[:result].to_s).to eq('no such room') end - it 'should use v1 if version is provided' do + it 'uses v1 if version is provided' do allow(hipchat).to receive(:api_version).and_return('v1') expect(HipChat::Client).to receive(:new).with( token, @@ -79,7 +79,7 @@ describe HipchatService, models: true do hipchat.execute(push_sample_data) end - it 'should use v2 as the version when nothing is provided' do + it 'uses v2 as the version when nothing is provided' do allow(hipchat).to receive(:api_version).and_return('') expect(HipChat::Client).to receive(:new).with( token, @@ -90,13 +90,13 @@ describe HipchatService, models: true do end context 'push events' do - it "should call Hipchat API for push events" do + it "calls Hipchat API for push events" do hipchat.execute(push_sample_data) expect(WebMock).to have_requested(:post, api_url).once end - it "should create a push message" do + it "creates a push message" do message = hipchat.send(:create_push_message, push_sample_data) push_sample_data[:object_attributes] @@ -110,13 +110,13 @@ describe HipchatService, models: true do context 'tag_push events' do let(:push_sample_data) { Gitlab::PushDataBuilder.build(project, user, Gitlab::Git::BLANK_SHA, '1' * 40, 'refs/tags/test', []) } - it "should call Hipchat API for tag push events" do + it "calls Hipchat API for tag push events" do hipchat.execute(push_sample_data) expect(WebMock).to have_requested(:post, api_url).once end - it "should create a tag push message" do + it "creates a tag push message" do message = hipchat.send(:create_push_message, push_sample_data) push_sample_data[:object_attributes] @@ -131,13 +131,13 @@ describe HipchatService, models: true do let(:issue_service) { Issues::CreateService.new(project, user) } let(:issues_sample_data) { issue_service.hook_data(issue, 'open') } - it "should call Hipchat API for issue events" do + it "calls Hipchat API for issue events" do hipchat.execute(issues_sample_data) expect(WebMock).to have_requested(:post, api_url).once end - it "should create an issue message" do + it "creates an issue message" do message = hipchat.send(:create_issue_message, issues_sample_data) obj_attr = issues_sample_data[:object_attributes] @@ -154,13 +154,13 @@ describe HipchatService, models: true do let(:merge_service) { MergeRequests::CreateService.new(project, user) } let(:merge_sample_data) { merge_service.hook_data(merge_request, 'open') } - it "should call Hipchat API for merge requests events" do + it "calls Hipchat API for merge requests events" do hipchat.execute(merge_sample_data) expect(WebMock).to have_requested(:post, api_url).once end - it "should create a merge request message" do + it "creates a merge request message" do message = hipchat.send(:create_merge_request_message, merge_sample_data) @@ -184,7 +184,7 @@ describe HipchatService, models: true do note: 'a comment on a commit') end - it "should call Hipchat API for commit comment events" do + it "calls Hipchat API for commit comment events" do data = Gitlab::NoteDataBuilder.build(commit_note, user) hipchat.execute(data) @@ -216,7 +216,7 @@ describe HipchatService, models: true do note: "merge request note") end - it "should call Hipchat API for merge request comment events" do + it "calls Hipchat API for merge request comment events" do data = Gitlab::NoteDataBuilder.build(merge_request_note, user) hipchat.execute(data) @@ -243,7 +243,7 @@ describe HipchatService, models: true do note: "issue note") end - it "should call Hipchat API for issue comment events" do + it "calls Hipchat API for issue comment events" do data = Gitlab::NoteDataBuilder.build(issue_note, user) hipchat.execute(data) @@ -269,7 +269,7 @@ describe HipchatService, models: true do note: "snippet note") end - it "should call Hipchat API for snippet comment events" do + it "calls Hipchat API for snippet comment events" do data = Gitlab::NoteDataBuilder.build(snippet_note, user) hipchat.execute(data) @@ -297,13 +297,13 @@ describe HipchatService, models: true do context 'for failed' do before { build.drop } - it "should call Hipchat API" do + it "calls Hipchat API" do hipchat.execute(data) expect(WebMock).to have_requested(:post, api_url).once end - it "should create a build message" do + it "creates a build message" do message = hipchat.send(:create_build_message, data) project_url = project.web_url @@ -325,13 +325,13 @@ describe HipchatService, models: true do build.success end - it "should call Hipchat API" do + it "calls Hipchat API" do hipchat.notify_only_broken_builds = false hipchat.execute(data) expect(WebMock).to have_requested(:post, api_url).once end - it "should notify only broken" do + it "notifies only broken" do hipchat.notify_only_broken_builds = true hipchat.execute(data) expect(WebMock).not_to have_requested(:post, api_url).once diff --git a/spec/models/project_services/irker_service_spec.rb b/spec/models/project_services/irker_service_spec.rb index 4ee022a5171..b528baaf15c 100644 --- a/spec/models/project_services/irker_service_spec.rb +++ b/spec/models/project_services/irker_service_spec.rb @@ -71,7 +71,7 @@ describe IrkerService, models: true do @irker_server.close end - it 'should send valid JSON messages to an Irker listener' do + it 'sends valid JSON messages to an Irker listener' do irker.execute(sample_data) conn = @irker_server.accept diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index 5a97cf370da..342403f6354 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -75,7 +75,7 @@ describe JiraService, models: true do WebMock.stub_request(:post, @comment_url) end - it "should call JIRA API" do + it "calls JIRA API" do @jira_service.execute(merge_request, ExternalIssue.new("JIRA-123", project)) expect(WebMock).to have_requested(:post, @comment_url).with( @@ -128,7 +128,7 @@ describe JiraService, models: true do expect(@jira_service.api_url).to eq("http://jira_edited.example.com/rest/api/2") end - it "should reset password if url changed, even if setter called multiple times" do + it "resets password if url changed, even if setter called multiple times" do @jira_service.api_url = 'http://jira1.example.com/rest/api/2' @jira_service.api_url = 'http://jira1.example.com/rest/api/2' @jira_service.save @@ -181,7 +181,7 @@ describe JiraService, models: true do @service.destroy! end - it 'should be initialized' do + it 'is initialized' do expect(@service.title).to eq('JIRA') expect(@service.description).to eq("Jira issue tracker") end @@ -197,7 +197,7 @@ describe JiraService, models: true do @service.destroy! end - it "should be correct" do + it "is correct" do expect(@service.title).to eq('Jira One') expect(@service.description).to eq('Jira One issue tracker') end @@ -225,7 +225,7 @@ describe JiraService, models: true do @service.destroy! end - it 'should be prepopulated with the settings' do + it 'is prepopulated with the settings' do expect(@service.properties["project_url"]).to eq('http://jira.sample/projects/project_a') expect(@service.properties["issues_url"]).to eq("http://jira.sample/issues/:id") expect(@service.properties["new_issue_url"]).to eq("http://jira.sample/projects/project_a/issues/new") diff --git a/spec/models/project_services/pushover_service_spec.rb b/spec/models/project_services/pushover_service_spec.rb index 555d9757b47..19c0270a493 100644 --- a/spec/models/project_services/pushover_service_spec.rb +++ b/spec/models/project_services/pushover_service_spec.rb @@ -72,7 +72,7 @@ describe PushoverService, models: true do WebMock.stub_request(:post, api_url) end - it 'should call Pushover API' do + it 'calls Pushover API' do pushover.execute(sample_data) expect(WebMock).to have_requested(:post, api_url).once diff --git a/spec/models/project_services/slack_service/note_message_spec.rb b/spec/models/project_services/slack_service/note_message_spec.rb index 379c3e1219c..41b93f08050 100644 --- a/spec/models/project_services/slack_service/note_message_spec.rb +++ b/spec/models/project_services/slack_service/note_message_spec.rb @@ -60,6 +60,7 @@ describe SlackService::NoteMessage, models: true do title: "merge request title\ndetails\n" } end + it 'returns a message regarding notes on a merge request' do message = SlackService::NoteMessage.new(@args) expect(message.pretext).to eq("Test User commented on " \ diff --git a/spec/models/project_services/slack_service/wiki_page_message_spec.rb b/spec/models/project_services/slack_service/wiki_page_message_spec.rb index 46dedb66c7c..13aea0b0600 100644 --- a/spec/models/project_services/slack_service/wiki_page_message_spec.rb +++ b/spec/models/project_services/slack_service/wiki_page_message_spec.rb @@ -47,7 +47,7 @@ describe SlackService::WikiPageMessage, models: true do context 'when :action == "create"' do before { args[:object_attributes][:action] = 'create' } - it 'it returns the attachment for a new wiki page' do + it 'returns the attachment for a new wiki page' do expect(subject.attachments).to eq([ { text: "Wiki page description", @@ -60,7 +60,7 @@ describe SlackService::WikiPageMessage, models: true do context 'when :action == "update"' do before { args[:object_attributes][:action] = 'update' } - it 'it returns the attachment for an updated wiki page' do + it 'returns the attachment for an updated wiki page' do expect(subject.attachments).to eq([ { text: "Wiki page description", diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb index df511b1bc4c..45a5f4ef12a 100644 --- a/spec/models/project_services/slack_service_spec.rb +++ b/spec/models/project_services/slack_service_spec.rb @@ -93,31 +93,31 @@ describe SlackService, models: true do @wiki_page_sample_data = wiki_page_service.hook_data(@wiki_page, 'create') end - it "should call Slack API for push events" do + it "calls Slack API for push events" do slack.execute(push_sample_data) expect(WebMock).to have_requested(:post, webhook_url).once end - it "should call Slack API for issue events" do + it "calls Slack API for issue events" do slack.execute(@issues_sample_data) expect(WebMock).to have_requested(:post, webhook_url).once end - it "should call Slack API for merge requests events" do + it "calls Slack API for merge requests events" do slack.execute(@merge_sample_data) expect(WebMock).to have_requested(:post, webhook_url).once end - it "should call Slack API for wiki page events" do + it "calls Slack API for wiki page events" do slack.execute(@wiki_page_sample_data) expect(WebMock).to have_requested(:post, webhook_url).once end - it 'should use the username as an option for slack when configured' do + it 'uses the username as an option for slack when configured' do allow(slack).to receive(:username).and_return(username) expect(Slack::Notifier).to receive(:new). with(webhook_url, username: username). @@ -128,7 +128,7 @@ describe SlackService, models: true do slack.execute(push_sample_data) end - it 'should use the channel as an option when it is configured' do + it 'uses the channel as an option when it is configured' do allow(slack).to receive(:channel).and_return(channel) expect(Slack::Notifier).to receive(:new). with(webhook_url, channel: channel). @@ -234,7 +234,7 @@ describe SlackService, models: true do note: 'a comment on a commit') end - it "should call Slack API for commit comment events" do + it "calls Slack API for commit comment events" do data = Gitlab::NoteDataBuilder.build(commit_note, user) slack.execute(data) @@ -248,7 +248,7 @@ describe SlackService, models: true do note: "merge request note") end - it "should call Slack API for merge request comment events" do + it "calls Slack API for merge request comment events" do data = Gitlab::NoteDataBuilder.build(merge_request_note, user) slack.execute(data) @@ -261,7 +261,7 @@ describe SlackService, models: true do create(:note_on_issue, project: project, note: "issue note") end - it "should call Slack API for issue comment events" do + it "calls Slack API for issue comment events" do data = Gitlab::NoteDataBuilder.build(issue_note, user) slack.execute(data) @@ -275,7 +275,7 @@ describe SlackService, models: true do note: "snippet note") end - it "should call Slack API for snippet comment events" do + it "calls Slack API for snippet comment events" do data = Gitlab::NoteDataBuilder.build(snippet_note, user) slack.execute(data) diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 567f87b9970..1c3d694075a 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -89,7 +89,7 @@ describe Project, models: true do it { is_expected.to validate_presence_of(:namespace) } it { is_expected.to validate_presence_of(:repository_storage) } - it 'should not allow new projects beyond user limits' do + it 'does not allow new projects beyond user limits' do project2 = build(:project) allow(project2).to receive(:creator).and_return(double(can_create_project?: false, projects_limit: 0).as_null_object) expect(project2).not_to be_valid @@ -98,7 +98,7 @@ describe Project, models: true do describe 'wiki path conflict' do context "when the new path has been used by the wiki of other Project" do - it 'should have an error on the name attribute' do + it 'has an error on the name attribute' do new_project = build_stubbed(:project, namespace_id: project.namespace_id, path: "#{project.path}.wiki") expect(new_project).not_to be_valid @@ -107,7 +107,7 @@ describe Project, models: true do end context "when the new wiki path has been used by the path of other Project" do - it 'should have an error on the name attribute' do + it 'has an error on the name attribute' do project_with_wiki_suffix = create(:project, path: 'foo.wiki') new_project = build_stubbed(:project, namespace_id: project_with_wiki_suffix.namespace_id, path: 'foo') @@ -125,7 +125,7 @@ describe Project, models: true do allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) end - it "should not allow repository storages that don't match a label in the configuration" do + it "does not allow repository storages that don't match a label in the configuration" do expect(project2).not_to be_valid expect(project2.errors[:repository_storage].first).to match(/is not included in the list/) end @@ -172,12 +172,12 @@ describe Project, models: true do end describe 'project token' do - it 'should set an random token if none provided' do + it 'sets an random token if none provided' do project = FactoryGirl.create :empty_project, runners_token: '' expect(project.runners_token).not_to eq('') end - it 'should not set an random toke if one provided' do + it 'does not set an random toke if one provided' do project = FactoryGirl.create :empty_project, runners_token: 'my-token' expect(project.runners_token).to eq('my-token') end @@ -225,7 +225,7 @@ describe Project, models: true do end end - it 'should return valid url to repo' do + it 'returns valid url to repo' do project = Project.new(path: 'somewhere') expect(project.url_to_repo).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + 'somewhere.git') end @@ -279,7 +279,7 @@ describe Project, models: true do let(:last_event) { double(created_at: Time.now) } describe 'last_activity' do - it 'should alias last_activity to last_event' do + it 'alias last_activity to last_event' do allow(project).to receive(:last_event).and_return(last_event) expect(project.last_activity).to eq(last_event) end @@ -350,13 +350,13 @@ describe Project, models: true do let(:prev_commit_id) { merge_request.commits.last.id } let(:commit_id) { merge_request.commits.first.id } - it 'should close merge request if last commit from source branch was pushed to target branch' do + it 'closes merge request if last commit from source branch was pushed to target branch' do project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.target_branch}", key.user) merge_request.reload expect(merge_request.merged?).to be_truthy end - it 'should update merge request commits with new one if pushed to source branch' do + it 'updates merge request commits with new one if pushed to source branch' do project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.source_branch}", key.user) merge_request.reload expect(merge_request.diff_head_sha).to eq(commit_id) @@ -433,11 +433,11 @@ describe Project, models: true do let(:project) { create(:project) } let(:ext_project) { create(:redmine_project) } - it "should be true if used internal tracker" do + it "is true if used internal tracker" do expect(project.default_issues_tracker?).to be_truthy end - it "should be false if used other tracker" do + it "is false if used other tracker" do expect(ext_project.default_issues_tracker?).to be_falsey end end @@ -636,12 +636,12 @@ describe Project, models: true do describe '#avatar_type' do let(:project) { create(:project) } - it 'should be true if avatar is image' do + it 'is true if avatar is image' do project.update_attribute(:avatar, 'uploads/avatar.png') expect(project.avatar_type).to be_truthy end - it 'should be false if avatar is html page' do + it 'is false if avatar is html page' do project.update_attribute(:avatar, 'uploads/avatar.html') expect(project.avatar_type).to eq(['only images allowed']) end @@ -814,16 +814,16 @@ describe Project, models: true do context 'for shared runners disabled' do let(:shared_runners_enabled) { false } - it 'there are no runners available' do + it 'has no runners available' do expect(project.any_runners?).to be_falsey end - it 'there is a specific runner' do + it 'has a specific runner' do project.runners << specific_runner expect(project.any_runners?).to be_truthy end - it 'there is a shared runner, but they are prohibited to use' do + it 'has a shared runner, but they are prohibited to use' do shared_runner expect(project.any_runners?).to be_falsey end @@ -837,7 +837,7 @@ describe Project, models: true do context 'for shared runners enabled' do let(:shared_runners_enabled) { true } - it 'there is a shared runner' do + it 'has a shared runner' do shared_runner expect(project.any_runners?).to be_truthy end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 2a053b1804f..f7dbfd712cc 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -340,14 +340,14 @@ describe Repository, models: true do describe '#add_branch' do context 'when pre hooks were successful' do - it 'should run without errors' do + it 'runs without errors' do hook = double(trigger: [true, nil]) expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook) expect { repository.add_branch(user, 'new_feature', 'master') }.not_to raise_error end - it 'should create the branch' do + it 'creates the branch' do allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil]) branch = repository.add_branch(user, 'new_feature', 'master') @@ -363,7 +363,7 @@ describe Repository, models: true do end context 'when pre hooks failed' do - it 'should get an error' do + it 'gets an error' do allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, '']) expect do @@ -371,7 +371,7 @@ describe Repository, models: true do end.to raise_error(GitHooksService::PreReceiveError) end - it 'should not create the branch' do + it 'does not create the branch' do allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, '']) expect do @@ -387,14 +387,14 @@ describe Repository, models: true do let(:blank_sha) { '0000000000000000000000000000000000000000' } context 'when pre hooks were successful' do - it 'should run without errors' do + it 'runs without errors' do expect_any_instance_of(GitHooksService).to receive(:execute). with(user, project.repository.path_to_repo, old_rev, blank_sha, 'refs/heads/feature') expect { repository.rm_branch(user, 'feature') }.not_to raise_error end - it 'should delete the branch' do + it 'deletes the branch' do allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil]) expect { repository.rm_branch(user, 'feature') }.not_to raise_error @@ -404,7 +404,7 @@ describe Repository, models: true do end context 'when pre hooks failed' do - it 'should get an error' do + it 'gets an error' do allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, '']) expect do @@ -412,7 +412,7 @@ describe Repository, models: true do end.to raise_error(GitHooksService::PreReceiveError) end - it 'should not delete the branch' do + it 'does not delete the branch' do allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, '']) expect do @@ -433,13 +433,13 @@ describe Repository, models: true do and_yield.and_return(true) end - it 'should run without errors' do + it 'runs without errors' do expect do repository.commit_with_hooks(user, 'feature') { sample_commit.id } end.not_to raise_error end - it 'should ensure the autocrlf Git option is set to :input' do + it 'ensures the autocrlf Git option is set to :input' do expect(repository).to receive(:update_autocrlf_option) repository.commit_with_hooks(user, 'feature') { sample_commit.id } @@ -455,7 +455,7 @@ describe Repository, models: true do end context 'when pre hooks failed' do - it 'should get an error' do + it 'gets an error' do allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, '']) expect do @@ -715,7 +715,7 @@ describe Repository, models: true do end describe '#merge' do - it 'should merge the code and return the commit id' do + it 'merges the code and return the commit id' do expect(merge_commit).to be_present expect(repository.blob_at(merge_commit.id, 'files/ruby/feature.rb')).to be_present end @@ -726,13 +726,13 @@ describe Repository, models: true do let(:update_image_commit) { repository.commit('2f63565e7aac07bcdadb654e253078b727143ec4') } context 'when there is a conflict' do - it 'should abort the operation' do + it 'aborts the operation' do expect(repository.revert(user, new_image_commit, 'master')).to eq(false) end end context 'when commit was already reverted' do - it 'should abort the operation' do + it 'aborts the operation' do repository.revert(user, update_image_commit, 'master') expect(repository.revert(user, update_image_commit, 'master')).to eq(false) @@ -740,13 +740,13 @@ describe Repository, models: true do end context 'when commit can be reverted' do - it 'should revert the changes' do + it 'reverts the changes' do expect(repository.revert(user, update_image_commit, 'master')).to be_truthy end end context 'reverting a merge commit' do - it 'should revert the changes' do + it 'reverts the changes' do merge_commit expect(repository.blob_at_branch('master', 'files/ruby/feature.rb')).to be_present @@ -762,13 +762,13 @@ describe Repository, models: true do let(:pickable_merge) { repository.commit('e56497bb5f03a90a51293fc6d516788730953899') } context 'when there is a conflict' do - it 'should abort the operation' do + it 'aborts the operation' do expect(repository.cherry_pick(user, conflict_commit, 'master')).to eq(false) end end context 'when commit was already cherry-picked' do - it 'should abort the operation' do + it 'aborts the operation' do repository.cherry_pick(user, pickable_commit, 'master') expect(repository.cherry_pick(user, pickable_commit, 'master')).to eq(false) @@ -776,13 +776,13 @@ describe Repository, models: true do end context 'when commit can be cherry-picked' do - it 'should cherry-pick the changes' do + it 'cherry-picks the changes' do expect(repository.cherry_pick(user, pickable_commit, 'master')).to be_truthy end end context 'cherry-picking a merge commit' do - it 'should cherry-pick the changes' do + it 'cherry-picks the changes' do expect(repository.blob_at_branch('master', 'foo/bar/.gitkeep')).to be_nil repository.cherry_pick(user, pickable_merge, 'master') diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 67b3783d514..05056a4bb47 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -65,13 +65,13 @@ describe Service, models: true do end let(:project) { create(:project) } - describe 'should be prefilled for projects pushover service' do + describe 'is prefilled for projects pushover service' do before do service_template project.build_missing_services end - it "should have all fields prefilled" do + it "has all fields prefilled" do service = project.pushover_service expect(service.template).to eq(false) expect(service.device).to eq('MyDevice') diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9f432501c59..f67acbbef37 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -166,7 +166,7 @@ describe User, models: true do allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return(['*.example.com']) end - it 'should give priority to whitelist and allow info@test.example.com' do + it 'gives priority to whitelist and allow info@test.example.com' do user = build(:user, email: 'info@test.example.com') expect(user).to be_valid end @@ -304,18 +304,18 @@ describe User, models: true do end describe '#generate_password' do - it "should execute callback when force_random_password specified" do + it "executes callback when force_random_password specified" do user = build(:user, force_random_password: true) expect(user).to receive(:generate_password) user.save end - it "should not generate password by default" do + it "does not generate password by default" do user = create(:user, password: 'abcdefghe') expect(user.password).to eq('abcdefghe') end - it "should generate password when forcing random password" do + it "generates password when forcing random password" do allow(Devise).to receive(:friendly_token).and_return('123456789') user = create(:user, password: 'abcdefg', force_random_password: true) expect(user.password).to eq('12345678') @@ -323,7 +323,7 @@ describe User, models: true do end describe 'authentication token' do - it "should have authentication token" do + it "has authentication token" do user = create(:user) expect(user.authentication_token).not_to be_blank end @@ -430,7 +430,7 @@ describe User, models: true do describe 'blocking user' do let(:user) { create(:user, name: 'John Smith') } - it "should block user" do + it "blocks user" do user.block expect(user.blocked?).to be_truthy end @@ -501,7 +501,7 @@ describe User, models: true do describe 'with defaults' do let(:user) { User.new } - it "should apply defaults to user" do + it "applies defaults to user" do expect(user.projects_limit).to eq(Gitlab.config.gitlab.default_projects_limit) expect(user.can_create_group).to eq(Gitlab.config.gitlab.default_can_create_group) expect(user.theme_id).to eq(Gitlab.config.gitlab.default_theme) @@ -512,7 +512,7 @@ describe User, models: true do describe 'with default overrides' do let(:user) { User.new(projects_limit: 123, can_create_group: false, can_create_team: true, theme_id: 1) } - it "should apply defaults to user" do + it "applies defaults to user" do expect(user.projects_limit).to eq(123) expect(user.can_create_group).to be_falsey expect(user.theme_id).to eq(1) @@ -602,7 +602,7 @@ describe User, models: true do describe 'by_username_or_id' do let(:user1) { create(:user, username: 'foo') } - it "should get the correct user" do + it "gets the correct user" do expect(User.by_username_or_id(user1.id)).to eq(user1) expect(User.by_username_or_id('foo')).to eq(user1) expect(User.by_username_or_id(-1)).to be_nil @@ -614,7 +614,7 @@ describe User, models: true do let(:username) { 'John' } let!(:user) { create(:user, username: username) } - it 'should get the correct user' do + it 'gets the correct user' do expect(User.by_login(user.email.upcase)).to eq user expect(User.by_login(user.email)).to eq user expect(User.by_login(username.downcase)).to eq user @@ -639,7 +639,7 @@ describe User, models: true do describe 'all_ssh_keys' do it { is_expected.to have_many(:keys).dependent(:destroy) } - it "should have all ssh keys" do + it "has all ssh keys" do user = create :user key = create :key, key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD33bWLBxu48Sev9Fert1yzEO4WGcWglWF7K/AwblIUFselOt/QdOL9DSjpQGxLagO1s9wl53STIO8qGS4Ms0EJZyIXOEFMjFJ5xmjSy+S37By4sG7SsltQEHMxtbtFOaW5LV2wCrX+rUsRNqLMamZjgjcPO0/EgGCXIGMAYW4O7cwGZdXWYIhQ1Vwy+CsVMDdPkPgBXqK7nR/ey8KMs8ho5fMNgB5hBw/AL9fNGhRw3QTD6Q12Nkhl4VZES2EsZqlpNnJttnPdp847DUsT6yuLRlfiQfz5Cn9ysHFdXObMN5VYIiPFwHeYCZp1X2S4fDZooRE8uOLTfxWHPXwrhqSH", user_id: user.id @@ -650,12 +650,12 @@ describe User, models: true do describe '#avatar_type' do let(:user) { create(:user) } - it "should be true if avatar is image" do + it "is true if avatar is image" do user.update_attribute(:avatar, 'uploads/avatar.png') expect(user.avatar_type).to be_truthy end - it "should be false if avatar is html page" do + it "is false if avatar is html page" do user.update_attribute(:avatar, 'uploads/avatar.html') expect(user.avatar_type).to eq(["only images allowed"]) end diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index ddc49495eda..5c34b1b0a30 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -147,12 +147,12 @@ describe WikiPage, models: true do @page = wiki.find_page("Delete Page") end - it "should delete the page" do + it "deletes the page" do @page.delete expect(wiki.pages).to be_empty end - it "should return true" do + it "returns true" do expect(@page.delete).to eq(true) end end @@ -183,7 +183,7 @@ describe WikiPage, models: true do destroy_page("Title") end - it "should be replace a hyphen to a space" do + it "replaces a hyphen to a space" do @page.title = "Import-existing-repositories-into-GitLab" expect(@page.title).to eq("Import existing repositories into GitLab") end 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 diff --git a/spec/services/create_snippet_service_spec.rb b/spec/services/create_snippet_service_spec.rb index 7a850066bf8..d81d0fd76c9 100644 --- a/spec/services/create_snippet_service_spec.rb +++ b/spec/services/create_snippet_service_spec.rb @@ -19,7 +19,7 @@ describe CreateSnippetService, services: true do @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) end - it 'non-admins should not be able to create a public snippet' do + it 'non-admins are not able to create a public snippet' do snippet = create_snippet(nil, @user, @opts) expect(snippet.errors.messages).to have_key(:visibility_level) expect(snippet.errors.messages[:visibility_level].first).to( @@ -27,7 +27,7 @@ describe CreateSnippetService, services: true do ) end - it 'admins should be able to create a public snippet' do + it 'admins are able to create a public snippet' do snippet = create_snippet(nil, @admin, @opts) expect(snippet.errors.any?).to be_falsey expect(snippet.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC) diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb index 789836f71bb..16a9956fe7f 100644 --- a/spec/services/event_create_service_spec.rb +++ b/spec/services/event_create_service_spec.rb @@ -41,7 +41,7 @@ describe EventCreateService, services: true do it { expect(service.open_mr(merge_request, merge_request.author)).to be_truthy } - it "should create new event" do + it "creates new event" do expect { service.open_mr(merge_request, merge_request.author) }.to change { Event.count } end end @@ -51,7 +51,7 @@ describe EventCreateService, services: true do it { expect(service.close_mr(merge_request, merge_request.author)).to be_truthy } - it "should create new event" do + it "creates new event" do expect { service.close_mr(merge_request, merge_request.author) }.to change { Event.count } end end @@ -61,7 +61,7 @@ describe EventCreateService, services: true do it { expect(service.merge_mr(merge_request, merge_request.author)).to be_truthy } - it "should create new event" do + it "creates new event" do expect { service.merge_mr(merge_request, merge_request.author) }.to change { Event.count } end end @@ -71,7 +71,7 @@ describe EventCreateService, services: true do it { expect(service.reopen_mr(merge_request, merge_request.author)).to be_truthy } - it "should create new event" do + it "creates new event" do expect { service.reopen_mr(merge_request, merge_request.author) }.to change { Event.count } end end @@ -85,7 +85,7 @@ describe EventCreateService, services: true do it { expect(service.open_milestone(milestone, user)).to be_truthy } - it "should create new event" do + it "creates new event" do expect { service.open_milestone(milestone, user) }.to change { Event.count } end end @@ -95,7 +95,7 @@ describe EventCreateService, services: true do it { expect(service.close_milestone(milestone, user)).to be_truthy } - it "should create new event" do + it "creates new event" do expect { service.close_milestone(milestone, user) }.to change { Event.count } end end @@ -105,7 +105,7 @@ describe EventCreateService, services: true do it { expect(service.destroy_milestone(milestone, user)).to be_truthy } - it "should create new event" do + it "creates new event" do expect { service.destroy_milestone(milestone, user) }.to change { Event.count } end end diff --git a/spec/services/git_hooks_service_spec.rb b/spec/services/git_hooks_service_spec.rb index 3fc37a315c0..41b0968b8b4 100644 --- a/spec/services/git_hooks_service_spec.rb +++ b/spec/services/git_hooks_service_spec.rb @@ -17,7 +17,7 @@ describe GitHooksService, services: true do describe '#execute' do context 'when receive hooks were successful' do - it 'should call post-receive hook' do + it 'calls post-receive hook' do hook = double(trigger: [true, nil]) expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook) @@ -26,7 +26,7 @@ describe GitHooksService, services: true do end context 'when pre-receive hook failed' do - it 'should not call post-receive hook' do + it 'does not call post-receive hook' do expect(service).to receive(:run_hook).with('pre-receive').and_return([false, '']) expect(service).not_to receive(:run_hook).with('post-receive') @@ -37,7 +37,7 @@ describe GitHooksService, services: true do end context 'when update hook failed' do - it 'should not call post-receive hook' do + it 'does not call post-receive hook' do expect(service).to receive(:run_hook).with('pre-receive').and_return([true, nil]) expect(service).to receive(:run_hook).with('update').and_return([false, '']) expect(service).not_to receive(:run_hook).with('post-receive') diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index ffa998dffc3..80f6ebac86c 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -420,7 +420,7 @@ describe GitPushService, services: true do context "mentioning an issue" do let(:message) { "this is some work.\n\nrelated to JIRA-1" } - it "should initiate one api call to jira server to mention the issue" do + it "initiates one api call to jira server to mention the issue" do execute_service(project, user, @oldrev, @newrev, @ref ) expect(WebMock).to have_requested(:post, jira_api_comment_url).with( @@ -432,7 +432,7 @@ describe GitPushService, services: true do context "closing an issue" do let(:message) { "this is some work.\n\ncloses JIRA-1" } - it "should initiate one api call to jira server to close the issue" do + it "initiates one api call to jira server to close the issue" do transition_body = { transition: { id: '2' @@ -445,7 +445,7 @@ describe GitPushService, services: true do ).once end - it "should initiate one api call to jira server to comment on the issue" do + it "initiates one api call to jira server to comment on the issue" do comment_body = { body: "Issue solved with [#{closing_commit.id}|http://localhost/#{project.path_with_namespace}/commit/#{closing_commit.id}]." }.to_json diff --git a/spec/services/issues/bulk_update_service_spec.rb b/spec/services/issues/bulk_update_service_spec.rb index 321b54ac39d..ac08aa53b0b 100644 --- a/spec/services/issues/bulk_update_service_spec.rb +++ b/spec/services/issues/bulk_update_service_spec.rb @@ -217,7 +217,7 @@ describe Issues::BulkUpdateService, services: true do let(:labels) { [merge_requests] } let(:remove_labels) { [regression] } - it 'remove the label IDs from all issues passed' do + it 'removes the label IDs from all issues passed' do expect(issues.map(&:reload).map(&:label_ids).flatten).not_to include(regression.id) end diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index 67a919ba8ee..1318607a388 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -23,13 +23,13 @@ describe Issues::CloseService, services: true do it { expect(@issue).to be_valid } it { expect(@issue).to be_closed } - it 'should send email to user2 about assign of new issue' do + it 'sends email to user2 about assign of new issue' do email = ActionMailer::Base.deliveries.last expect(email.to.first).to eq(user2.email) expect(email.subject).to include(issue.title) end - it 'should create system note about issue reassign' do + it 'creates system note about issue reassign' do note = @issue.notes.last expect(note.note).to include "Status changed to closed" end diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index dacbcd8fb46..088c3d48bf7 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -53,7 +53,7 @@ describe Issues::UpdateService, services: true do it { expect(@issue.labels.count).to eq(1) } it { expect(@issue.labels.first.title).to eq(label.name) } - it 'should send email to user2 about assign of new issue and email to user3 about issue unassignment' do + it 'sends email to user2 about assign of new issue and email to user3 about issue unassignment' do deliveries = ActionMailer::Base.deliveries email = deliveries.last recipients = deliveries.last(2).map(&:to).flatten @@ -61,14 +61,14 @@ describe Issues::UpdateService, services: true do expect(email.subject).to include(issue.title) end - it 'should create system note about issue reassign' do + it 'creates system note about issue reassign' do note = find_note('Reassigned to') expect(note).not_to be_nil expect(note.note).to include "Reassigned to \@#{user2.username}" end - it 'should create system note about issue label edit' do + it 'creates system note about issue label edit' do note = find_note('Added ~') expect(note).not_to be_nil @@ -267,7 +267,7 @@ describe Issues::UpdateService, services: true do expect(note).to be_nil end - it 'should not generate a new note at all' do + it 'does not generate a new note at all' do expect do update_issue({ description: "- [ ] One\n- [ ] Two\n- [ ] Three" }) end.not_to change { Note.count } diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb index c1db4f3284b..403533be5d9 100644 --- a/spec/services/merge_requests/close_service_spec.rb +++ b/spec/services/merge_requests/close_service_spec.rb @@ -32,13 +32,13 @@ describe MergeRequests::CloseService, services: true do with(@merge_request, 'close') end - it 'should send email to user2 about assign of new merge_request' do + it 'sends email to user2 about assign of new merge_request' do email = ActionMailer::Base.deliveries.last expect(email.to.first).to eq(user2.email) expect(email.subject).to include(merge_request.title) end - it 'should create system note about merge_request reassign' do + it 'creates system note about merge_request reassign' do note = @merge_request.notes.last expect(note.note).to include 'Status changed to closed' end diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb index d0b55d2d509..b84a580967a 100644 --- a/spec/services/merge_requests/create_service_spec.rb +++ b/spec/services/merge_requests/create_service_spec.rb @@ -32,7 +32,7 @@ describe MergeRequests::CreateService, services: true do it { expect(@merge_request.assignee).to be_nil } it { expect(@merge_request.merge_params['force_remove_source_branch']).to eq('1') } - it 'should execute hooks with default action' do + it 'executes hooks with default action' do expect(service).to have_received(:execute_hooks).with(@merge_request) end diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index 8ffebcac698..159f6817e8d 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -26,13 +26,13 @@ describe MergeRequests::MergeService, services: true do it { expect(merge_request).to be_valid } it { expect(merge_request).to be_merged } - it 'should send email to user2 about merge of new merge_request' do + it 'sends email to user2 about merge of new merge_request' do email = ActionMailer::Base.deliveries.last expect(email.to.first).to eq(user2.email) expect(email.subject).to include(merge_request.title) end - it 'should create system note about merge_request merge' do + it 'creates system note about merge_request merge' do note = merge_request.notes.last expect(note.note).to include 'Status changed to merged' end diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 781ee7ffed3..fff86480c6d 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -55,7 +55,7 @@ describe MergeRequests::RefreshService, services: true do reload_mrs end - it 'should execute hooks with update action' do + it 'executes hooks with update action' do expect(refresh_service).to have_received(:execute_hooks). with(@merge_request, 'update', @oldrev) end @@ -111,7 +111,7 @@ describe MergeRequests::RefreshService, services: true do reload_mrs end - it 'should execute hooks with update action' do + it 'executes hooks with update action' do expect(refresh_service).to have_received(:execute_hooks). with(@fork_merge_request, 'update', @oldrev) end diff --git a/spec/services/merge_requests/reopen_service_spec.rb b/spec/services/merge_requests/reopen_service_spec.rb index 88c9c640514..3419b8bf5e6 100644 --- a/spec/services/merge_requests/reopen_service_spec.rb +++ b/spec/services/merge_requests/reopen_service_spec.rb @@ -27,18 +27,18 @@ describe MergeRequests::ReopenService, services: true do it { expect(merge_request).to be_valid } it { expect(merge_request).to be_reopened } - it 'should execute hooks with reopen action' do + it 'executes hooks with reopen action' do expect(service).to have_received(:execute_hooks). with(merge_request, 'reopen') end - it 'should send email to user2 about reopen of merge_request' do + it 'sends email to user2 about reopen of merge_request' do email = ActionMailer::Base.deliveries.last expect(email.to.first).to eq(user2.email) expect(email.subject).to include(merge_request.title) end - it 'should create system note about merge_request reopen' do + it 'creates system note about merge_request reopen' do note = merge_request.notes.last expect(note.note).to include 'Status changed to reopened' end diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index d4ebe28c276..283a336afd9 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -64,12 +64,12 @@ describe MergeRequests::UpdateService, services: true do it { expect(@merge_request.target_branch).to eq('target') } it { expect(@merge_request.merge_params['force_remove_source_branch']).to eq('1') } - it 'should execute hooks with update action' do + it 'executes hooks with update action' do expect(service).to have_received(:execute_hooks). with(@merge_request, 'update') end - it 'should send email to user2 about assign of new merge request and email to user3 about merge request unassignment' do + it 'sends email to user2 about assign of new merge request and email to user3 about merge request unassignment' do deliveries = ActionMailer::Base.deliveries email = deliveries.last recipients = deliveries.last(2).map(&:to).flatten @@ -77,14 +77,14 @@ describe MergeRequests::UpdateService, services: true do expect(email.subject).to include(merge_request.title) end - it 'should create system note about merge_request reassign' do + it 'creates system note about merge_request reassign' do note = find_note('Reassigned to') expect(note).not_to be_nil expect(note.note).to include "Reassigned to \@#{user2.username}" end - it 'should create system note about merge_request label edit' do + it 'creates system note about merge_request label edit' do note = find_note('Added ~') expect(note).not_to be_nil diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 9fc93f325f7..92b441c28ca 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -15,7 +15,7 @@ describe NotificationService, services: true do it { expect(notification.new_key(key)).to be_truthy } - it 'should sent email to key owner' do + it 'sends email to key owner' do expect{ notification.new_key(key) }.to change{ ActionMailer::Base.deliveries.size }.by(1) end end @@ -27,7 +27,7 @@ describe NotificationService, services: true do it { expect(notification.new_email(email)).to be_truthy } - it 'should send email to email owner' do + it 'sends email to email owner' do expect{ notification.new_email(email) }.to change{ ActionMailer::Base.deliveries.size }.by(1) end end @@ -593,7 +593,7 @@ describe NotificationService, services: true do update_custom_notification(:close_issue, @u_custom_global) end - it 'should sent email to issue assignee and issue author' do + it 'sends email to issue assignee and issue author' do notification.close_issue(issue, @u_disabled) should_email(issue.assignee) @@ -646,7 +646,7 @@ describe NotificationService, services: true do update_custom_notification(:reopen_issue, @u_custom_global) end - it 'should send email to issue assignee and issue author' do + it 'sends email to issue assignee and issue author' do notification.reopen_issue(issue, @u_disabled) should_email(issue.assignee) diff --git a/spec/services/projects/autocomplete_service_spec.rb b/spec/services/projects/autocomplete_service_spec.rb index 0971fec2e9f..7916c2d957c 100644 --- a/spec/services/projects/autocomplete_service_spec.rb +++ b/spec/services/projects/autocomplete_service_spec.rb @@ -13,7 +13,7 @@ describe Projects::AutocompleteService, services: true do let!(:security_issue_1) { create(:issue, :confidential, project: project, title: 'Security issue 1', author: author) } let!(:security_issue_2) { create(:issue, :confidential, title: 'Security issue 2', project: project, assignee: assignee) } - it 'should not list project confidential issues for guests' do + it 'does not list project confidential issues for guests' do autocomplete = described_class.new(project, nil) issues = autocomplete.issues.map(&:iid) @@ -23,7 +23,7 @@ describe Projects::AutocompleteService, services: true do expect(issues.count).to eq 1 end - it 'should not list project confidential issues for non project members' do + it 'does not list project confidential issues for non project members' do autocomplete = described_class.new(project, non_member) issues = autocomplete.issues.map(&:iid) @@ -33,7 +33,7 @@ describe Projects::AutocompleteService, services: true do expect(issues.count).to eq 1 end - it 'should not list project confidential issues for project members with guest role' do + it 'does not list project confidential issues for project members with guest role' do project.team << [member, :guest] autocomplete = described_class.new(project, non_member) @@ -45,7 +45,7 @@ describe Projects::AutocompleteService, services: true do expect(issues.count).to eq 1 end - it 'should list project confidential issues for author' do + it 'lists project confidential issues for author' do autocomplete = described_class.new(project, author) issues = autocomplete.issues.map(&:iid) @@ -55,7 +55,7 @@ describe Projects::AutocompleteService, services: true do expect(issues.count).to eq 2 end - it 'should list project confidential issues for assignee' do + it 'lists project confidential issues for assignee' do autocomplete = described_class.new(project, assignee) issues = autocomplete.issues.map(&:iid) @@ -65,7 +65,7 @@ describe Projects::AutocompleteService, services: true do expect(issues.count).to eq 2 end - it 'should list project confidential issues for project members' do + it 'lists project confidential issues for project members' do project.team << [member, :developer] autocomplete = described_class.new(project, member) @@ -77,7 +77,7 @@ describe Projects::AutocompleteService, services: true do expect(issues.count).to eq 3 end - it 'should list all project issues for admin' do + it 'lists all project issues for admin' do autocomplete = described_class.new(project, admin) issues = autocomplete.issues.map(&:iid) diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index fd114359467..bbced59ff02 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -109,7 +109,7 @@ describe Projects::CreateService, services: true do ) end - it 'should not allow a restricted visibility level for non-admins' do + it 'does not allow a restricted visibility level for non-admins' do project = create_project(@user, @opts) expect(project).to respond_to(:errors) expect(project.errors.messages).to have_key(:visibility_level) @@ -118,7 +118,7 @@ describe Projects::CreateService, services: true do ) end - it 'should allow a restricted visibility level for admins' do + it 'allows a restricted visibility level for admins' do admin = create(:admin) project = create_project(admin, @opts) @@ -128,7 +128,7 @@ describe Projects::CreateService, services: true do end context 'repository creation' do - it 'should synchronously create the repository' do + it 'synchronously creates the repository' do expect_any_instance_of(Project).to receive(:create_repository) project = create_project(@user, @opts) diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb index 31bb7120d84..ef2036c78b1 100644 --- a/spec/services/projects/fork_service_spec.rb +++ b/spec/services/projects/fork_service_spec.rb @@ -26,7 +26,7 @@ describe Projects::ForkService, services: true do end context 'project already exists' do - it "should fail due to validation, not transaction failure" do + it "fails due to validation, not transaction failure" do @existing_project = create(:project, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace) @to_project = fork_project(@from_project, @to_user) expect(@existing_project.persisted?).to be_truthy @@ -36,7 +36,7 @@ describe Projects::ForkService, services: true do end context 'GitLab CI is enabled' do - it "fork and enable CI for fork" do + it "forks and enables CI for fork" do @from_project.enable_ci @to_project = fork_project(@from_project, @to_user) expect(@to_project.builds_enabled?).to be_truthy @@ -97,14 +97,14 @@ describe Projects::ForkService, services: true do end context 'fork project for group when user not owner' do - it 'group developer should fail to fork project into the group' do + it 'group developer fails to fork project into the group' do to_project = fork_project(@project, @developer, @opts) expect(to_project.errors[:namespace]).to eq(['is not valid']) end end context 'project already exists in group' do - it 'should fail due to validation, not transaction failure' do + it 'fails due to validation, not transaction failure' do existing_project = create(:project, name: @project.name, namespace: @group) to_project = fork_project(@project, @group_owner, @opts) diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb index e8b9e6b9238..e139be19140 100644 --- a/spec/services/projects/update_service_spec.rb +++ b/spec/services/projects/update_service_spec.rb @@ -9,7 +9,7 @@ describe Projects::UpdateService, services: true do @opts = {} end - context 'should be private when updated to private' do + context 'is private when updated to private' do before do @created_private = @project.private? @@ -21,7 +21,7 @@ describe Projects::UpdateService, services: true do it { expect(@project.private?).to be_truthy } end - context 'should be internal when updated to internal' do + context 'is internal when updated to internal' do before do @created_private = @project.private? @@ -33,7 +33,7 @@ describe Projects::UpdateService, services: true do it { expect(@project.internal?).to be_truthy } end - context 'should be public when updated to public' do + context 'is public when updated to public' do before do @created_private = @project.private? @@ -50,7 +50,7 @@ describe Projects::UpdateService, services: true do stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC]) end - context 'should be private when updated to private' do + context 'is private when updated to private' do before do @created_private = @project.private? @@ -62,7 +62,7 @@ describe Projects::UpdateService, services: true do it { expect(@project.private?).to be_truthy } end - context 'should be internal when updated to internal' do + context 'is internal when updated to internal' do before do @created_private = @project.private? @@ -74,7 +74,7 @@ describe Projects::UpdateService, services: true do it { expect(@project.internal?).to be_truthy } end - context 'should be private when updated to public' do + context 'is private when updated to public' do before do @created_private = @project.private? @@ -86,7 +86,7 @@ describe Projects::UpdateService, services: true do it { expect(@project.private?).to be_truthy } end - context 'should be public when updated to public by admin' do + context 'is public when updated to public by admin' do before do @created_private = @project.private? @@ -114,7 +114,7 @@ describe Projects::UpdateService, services: true do @fork_created_internal = forked_project.internal? end - context 'should update forks visibility level when parent set to more restrictive' do + context 'updates forks visibility level when parent set to more restrictive' do before do opts.merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) update_project(project, user, opts).inspect @@ -126,7 +126,7 @@ describe Projects::UpdateService, services: true do it { expect(project.forks.first.private?).to be_truthy } end - context 'should not update forks visibility level when parent set to less restrictive' do + context 'does not update forks visibility level when parent set to less restrictive' do before do opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) update_project(project, user, opts).inspect diff --git a/spec/services/repair_ldap_blocked_user_service_spec.rb b/spec/services/repair_ldap_blocked_user_service_spec.rb index ce7d1455975..87192457298 100644 --- a/spec/services/repair_ldap_blocked_user_service_spec.rb +++ b/spec/services/repair_ldap_blocked_user_service_spec.rb @@ -6,14 +6,14 @@ describe RepairLdapBlockedUserService, services: true do subject(:service) { RepairLdapBlockedUserService.new(user) } describe '#execute' do - it 'change to normal block after destroying last ldap identity' do + it 'changes to normal block after destroying last ldap identity' do identity.destroy service.execute expect(user.reload).not_to be_ldap_blocked end - it 'change to normal block after changing last ldap identity to another provider' do + it 'changes to normal block after changing last ldap identity to another provider' do identity.update_attribute(:provider, 'twitter') service.execute diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index 7b3a9a75d7c..bd89c4a7c11 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -16,7 +16,7 @@ describe 'Search::GlobalService', services: true do describe '#execute' do context 'unauthenticated' do - it 'should return public projects only' do + it 'returns public projects only' do context = Search::GlobalService.new(nil, search: "searchable") results = context.execute expect(results.objects('projects')).to match_array [public_project] @@ -24,19 +24,19 @@ describe 'Search::GlobalService', services: true do end context 'authenticated' do - it 'should return public, internal and private projects' do + it 'returns public, internal and private projects' do context = Search::GlobalService.new(user, search: "searchable") results = context.execute expect(results.objects('projects')).to match_array [public_project, found_project, internal_project] end - it 'should return only public & internal projects' do + it 'returns only public & internal projects' do context = Search::GlobalService.new(internal_user, search: "searchable") results = context.execute expect(results.objects('projects')).to match_array [internal_project, public_project] end - it 'namespace name should be searchable' do + it 'namespace name is searchable' do context = Search::GlobalService.new(user, search: found_project.namespace.path) results = context.execute expect(results.objects('projects')).to match_array [found_project] diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 43693441450..00427d6db2a 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -471,15 +471,15 @@ describe SystemNoteService, services: true do shared_examples 'cross project mentionable' do include GitlabMarkdownHelper - it 'should contain cross reference to new noteable' do + it 'contains cross reference to new noteable' do expect(subject.note).to include cross_project_reference(new_project, new_noteable) end - it 'should mention referenced noteable' do + it 'mentions referenced noteable' do expect(subject.note).to include new_noteable.to_reference end - it 'should mention referenced project' do + it 'mentions referenced project' do expect(subject.note).to include new_project.to_reference end end @@ -489,7 +489,7 @@ describe SystemNoteService, services: true do it_behaves_like 'cross project mentionable' - it 'should notify about noteable being moved to' do + it 'notifies about noteable being moved to' do expect(subject.note).to match /Moved to/ end end @@ -499,7 +499,7 @@ describe SystemNoteService, services: true do it_behaves_like 'cross project mentionable' - it 'should notify about noteable being moved from' do + it 'notifies about noteable being moved from' do expect(subject.note).to match /Moved from/ end end @@ -507,7 +507,7 @@ describe SystemNoteService, services: true do context 'invalid direction' do let(:direction) { :invalid } - it 'should raise error' do + it 'raises error' do expect { subject }.to raise_error StandardError, /Invalid direction/ end end diff --git a/spec/services/test_hook_service_spec.rb b/spec/services/test_hook_service_spec.rb index 4f47e89b4b5..4f6dd8c6d3f 100644 --- a/spec/services/test_hook_service_spec.rb +++ b/spec/services/test_hook_service_spec.rb @@ -6,7 +6,7 @@ describe TestHookService, services: true do let(:hook) { create :project_hook, project: project } describe '#execute' do - it "should execute successfully" do + it "executes successfully" do stub_request(:post, hook.url).to_return(status: 200) expect(TestHookService.new.execute(hook, user)).to be_truthy end diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index d2c056d8e14..baf78208ec5 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -53,7 +53,7 @@ describe 'gitlab:app namespace rake task' do let(:gitlab_version) { Gitlab::VERSION } - it 'should fail on mismatch' do + it 'fails on mismatch' do allow(YAML).to receive(:load_file). and_return({ gitlab_version: "not #{gitlab_version}" }) @@ -61,7 +61,7 @@ describe 'gitlab:app namespace rake task' do to raise_error(SystemExit) end - it 'should invoke restoration on match' do + it 'invokes restoration on match' do allow(YAML).to receive(:load_file). and_return({ gitlab_version: gitlab_version }) expect(Rake::Task['gitlab:db:drop_tables']).to receive(:invoke) @@ -107,7 +107,7 @@ describe 'gitlab:app namespace rake task' do end context 'archive file permissions' do - it 'should set correct permissions on the tar file' do + it 'sets correct permissions on the tar file' do expect(File.exist?(@backup_tar)).to be_truthy expect(File::Stat.new(@backup_tar).mode.to_s(8)).to eq('100600') end @@ -127,7 +127,7 @@ describe 'gitlab:app namespace rake task' do end end - it 'should set correct permissions on the tar contents' do + it 'sets correct permissions on the tar contents' do tar_contents, exit_status = Gitlab::Popen.popen( %W{tar -tvf #{@backup_tar} db uploads.tar.gz repositories builds.tar.gz artifacts.tar.gz lfs.tar.gz registry.tar.gz} ) @@ -142,7 +142,7 @@ describe 'gitlab:app namespace rake task' do expect(tar_contents).not_to match(/^.{4,9}[rwx].* (database.sql.gz|uploads.tar.gz|repositories|builds.tar.gz|artifacts.tar.gz|registry.tar.gz)\/$/) end - it 'should delete temp directories' do + it 'deletes temp directories' do temp_dirs = Dir.glob( File.join(Gitlab.config.backup.path, '{db,repositories,uploads,builds,artifacts,lfs,registry}') ) @@ -153,7 +153,7 @@ describe 'gitlab:app namespace rake task' do context 'registry disabled' do let(:enable_registry) { false } - it 'should not create registry.tar.gz' do + it 'does not create registry.tar.gz' do tar_contents, exit_status = Gitlab::Popen.popen( %W{tar -tvf #{@backup_tar}} ) @@ -191,7 +191,7 @@ describe 'gitlab:app namespace rake task' do FileUtils.rm(@backup_tar) end - it 'should include repositories in all repository storages' do + it 'includes repositories in all repository storages' do tar_contents, exit_status = Gitlab::Popen.popen( %W{tar -tvf #{@backup_tar} repositories} ) diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb index 36d03a224e4..fc52c04e78d 100644 --- a/spec/tasks/gitlab/db_rake_spec.rb +++ b/spec/tasks/gitlab/db_rake_spec.rb @@ -19,7 +19,7 @@ describe 'gitlab:db namespace rake task' do end describe 'configure' do - it 'should invoke db:migrate when schema has already been loaded' do + it 'invokes db:migrate when schema has already been loaded' do allow(ActiveRecord::Base.connection).to receive(:tables).and_return(['default']) expect(Rake::Task['db:migrate']).to receive(:invoke) expect(Rake::Task['db:schema:load']).not_to receive(:invoke) @@ -27,7 +27,7 @@ describe 'gitlab:db namespace rake task' do expect { run_rake_task('gitlab:db:configure') }.not_to raise_error end - it 'should invoke db:shema:load and db:seed_fu when schema is not loaded' do + it 'invokes db:shema:load and db:seed_fu when schema is not loaded' do allow(ActiveRecord::Base.connection).to receive(:tables).and_return([]) expect(Rake::Task['db:schema:load']).to receive(:invoke) expect(Rake::Task['db:seed_fu']).to receive(:invoke) @@ -35,7 +35,7 @@ describe 'gitlab:db namespace rake task' do expect { run_rake_task('gitlab:db:configure') }.not_to raise_error end - it 'should not invoke any other rake tasks during an error' do + it 'does not invoke any other rake tasks during an error' do allow(ActiveRecord::Base).to receive(:connection).and_raise(RuntimeError, 'error') expect(Rake::Task['db:migrate']).not_to receive(:invoke) expect(Rake::Task['db:schema:load']).not_to receive(:invoke) @@ -45,7 +45,7 @@ describe 'gitlab:db namespace rake task' do allow(ActiveRecord::Base).to receive(:connection).and_call_original end - it 'should not invoke seed after a failed schema_load' do + it 'does not invoke seed after a failed schema_load' do allow(ActiveRecord::Base.connection).to receive(:tables).and_return([]) allow(Rake::Task['db:schema:load']).to receive(:invoke).and_raise(RuntimeError, 'error') expect(Rake::Task['db:schema:load']).to receive(:invoke) diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index 20b1a343c27..7f803a06902 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -22,7 +22,7 @@ describe PostReceive do context "branches" do let(:changes) { "123456 789012 refs/heads/tést" } - it "should call GitTagPushService" do + it "calls GitTagPushService" do expect_any_instance_of(GitPushService).to receive(:execute).and_return(true) expect_any_instance_of(GitTagPushService).not_to receive(:execute) PostReceive.new.perform(pwd(project), key_id, base64_changes) @@ -32,7 +32,7 @@ describe PostReceive do context "tags" do let(:changes) { "123456 789012 refs/tags/tag" } - it "should call GitTagPushService" do + it "calls GitTagPushService" do expect_any_instance_of(GitPushService).not_to receive(:execute) expect_any_instance_of(GitTagPushService).to receive(:execute).and_return(true) PostReceive.new.perform(pwd(project), key_id, base64_changes) @@ -42,7 +42,7 @@ describe PostReceive do context "merge-requests" do let(:changes) { "123456 789012 refs/merge-requests/123" } - it "should not call any of the services" do + it "does not call any of the services" do expect_any_instance_of(GitPushService).not_to receive(:execute) expect_any_instance_of(GitTagPushService).not_to receive(:execute) PostReceive.new.perform(pwd(project), key_id, base64_changes) |