Commit 1d268a89 authored by tiagonbotelho's avatar tiagonbotelho

adds second batch of tests changed to active tense

parent 519275c1
......@@ -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
......
......@@ -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
......
......@@ -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')
......
......@@ -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
......
......@@ -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")
......
......@@ -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,
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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')
......
......@@ -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
......
......@@ -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')
......
......@@ -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^{}',
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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',
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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')
......
......@@ -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
......
......@@ -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])
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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"
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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}/
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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")
......
......@@ -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
......
......@@ -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
......
......@@ -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")
......
......@@ -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
......
......@@ -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 " \
......
......@@ -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",
......
......@@ -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)
......
......@@ -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
......
......@@ -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')
......
......@@ -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')
......
......@@ -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
......
......@@ -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
......
......@@ -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')
......
......@@ -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)
......
......@@ -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')
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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')
......
......@@ -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
......
......@@ -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
......
This diff is collapsed.
......@@ -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)
......
......@@ -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)
......
This diff is collapsed.
......@@ -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
......
......@@ -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
......
......@@ -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!"
......
......@@ -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]
......
......@@ -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)
......
......@@ -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]
......
This diff is collapsed.
......@@ -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
......
This diff is collapsed.
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -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)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment