diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-22 16:50:15 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-02-23 09:33:05 -0600 |
commit | 1fe7501b49f896b74102c4b970310aa9ae34da85 (patch) | |
tree | ce271afb0fbaaa14291c1dc9009cd7815ee25463 /spec/models | |
parent | bdbc7d967a0c3d95d5e4ea19a2a5be41268d3540 (diff) | |
download | gitlab-ce-1fe7501b49f896b74102c4b970310aa9ae34da85.tar.gz |
Revert "Prefer leading style for Style/DotPosition"
This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
Diffstat (limited to 'spec/models')
36 files changed, 400 insertions, 400 deletions
diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index c34e58afaaf..30f8fdf91b2 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -63,8 +63,8 @@ describe Ability, lib: true do project = create(:empty_project, :public) user = build(:user) - expect(described_class.users_that_can_read_project([user], project)) - .to eq([user]) + expect(described_class.users_that_can_read_project([user], project)). + to eq([user]) end end @@ -74,8 +74,8 @@ describe Ability, lib: true do it 'returns users that are administrators' do user = build(:user, admin: true) - expect(described_class.users_that_can_read_project([user], project)) - .to eq([user]) + expect(described_class.users_that_can_read_project([user], project)). + to eq([user]) end it 'returns internal users while skipping external users' do @@ -83,8 +83,8 @@ describe Ability, lib: true do user2 = build(:user, external: true) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)) - .to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([user1]) end it 'returns external users if they are the project owner' do @@ -94,8 +94,8 @@ describe Ability, lib: true do expect(project).to receive(:owner).twice.and_return(user1) - expect(described_class.users_that_can_read_project(users, project)) - .to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([user1]) end it 'returns external users if they are project members' do @@ -105,8 +105,8 @@ describe Ability, lib: true do expect(project.team).to receive(:members).twice.and_return([user1]) - expect(described_class.users_that_can_read_project(users, project)) - .to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([user1]) end it 'returns an empty Array if all users are external users without access' do @@ -114,8 +114,8 @@ describe Ability, lib: true do user2 = build(:user, external: true) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)) - .to eq([]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([]) end end @@ -125,8 +125,8 @@ describe Ability, lib: true do it 'returns users that are administrators' do user = build(:user, admin: true) - expect(described_class.users_that_can_read_project([user], project)) - .to eq([user]) + expect(described_class.users_that_can_read_project([user], project)). + to eq([user]) end it 'returns external users if they are the project owner' do @@ -136,8 +136,8 @@ describe Ability, lib: true do expect(project).to receive(:owner).twice.and_return(user1) - expect(described_class.users_that_can_read_project(users, project)) - .to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([user1]) end it 'returns external users if they are project members' do @@ -147,8 +147,8 @@ describe Ability, lib: true do expect(project.team).to receive(:members).twice.and_return([user1]) - expect(described_class.users_that_can_read_project(users, project)) - .to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([user1]) end it 'returns an empty Array if all users are internal users without access' do @@ -156,8 +156,8 @@ describe Ability, lib: true do user2 = build(:user) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)) - .to eq([]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([]) end it 'returns an empty Array if all users are external users without access' do @@ -165,8 +165,8 @@ describe Ability, lib: true do user2 = build(:user, external: true) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)) - .to eq([]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([]) end end end @@ -204,8 +204,8 @@ describe Ability, lib: true do user = build(:user, admin: true) issue = build(:issue) - expect(described_class.issues_readable_by_user([issue], user)) - .to eq([issue]) + expect(described_class.issues_readable_by_user([issue], user)). + to eq([issue]) end end @@ -216,8 +216,8 @@ describe Ability, lib: true do expect(issue).to receive(:readable_by?).with(user).and_return(true) - expect(described_class.issues_readable_by_user([issue], user)) - .to eq([issue]) + expect(described_class.issues_readable_by_user([issue], user)). + to eq([issue]) end it 'returns an empty Array when no issues are readable' do @@ -238,8 +238,8 @@ describe Ability, lib: true do expect(hidden_issue).to receive(:publicly_visible?).and_return(false) expect(visible_issue).to receive(:publicly_visible?).and_return(true) - issues = described_class - .issues_readable_by_user([hidden_issue, visible_issue]) + issues = described_class. + issues_readable_by_user([hidden_issue, visible_issue]) expect(issues).to eq([visible_issue]) end diff --git a/spec/models/abuse_report_spec.rb b/spec/models/abuse_report_spec.rb index d26e491e548..c4486a32082 100644 --- a/spec/models/abuse_report_spec.rb +++ b/spec/models/abuse_report_spec.rb @@ -37,8 +37,8 @@ RSpec.describe AbuseReport, type: :model do describe '#notify' do it 'delivers' do - expect(AbuseReportMailer).to receive(:notify).with(subject.id) - .and_return(spy) + expect(AbuseReportMailer).to receive(:notify).with(subject.id). + and_return(spy) subject.notify end diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 4086e00e363..8688639168b 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -32,9 +32,9 @@ describe ApplicationSetting, models: true do it { is_expected.to validate_presence_of(:max_attachment_size) } it do - is_expected.to validate_numericality_of(:max_attachment_size) - .only_integer - .is_greater_than(0) + is_expected.to validate_numericality_of(:max_attachment_size). + only_integer. + is_greater_than(0) end it_behaves_like 'an object with email-formated attributes', :admin_notification_email do diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 355b8bf3af8..a173e3aeff6 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -212,15 +212,15 @@ describe Ci::Build, :models do retried_rspec = Ci::Build.retry(rspec_test, user) - expect(staging.depends_on_builds.map(&:id)) - .to contain_exactly(build.id, retried_rspec.id, rubocop_test.id) + expect(staging.depends_on_builds.map(&:id)). + to contain_exactly(build.id, retried_rspec.id, rubocop_test.id) end end describe '#detailed_status' do it 'returns a detailed status' do - expect(build.detailed_status(user)) - .to be_a Gitlab::Ci::Status::Build::Cancelable + expect(build.detailed_status(user)). + to be_a Gitlab::Ci::Status::Build::Cancelable end end @@ -784,8 +784,8 @@ describe Ci::Build, :models do pipeline2 = create(:ci_pipeline, project: project) @build2 = create(:ci_build, pipeline: pipeline2) - allow(@merge_request).to receive(:commits_sha) - .and_return([pipeline.sha, pipeline2.sha]) + allow(@merge_request).to receive(:commits_sha). + and_return([pipeline.sha, pipeline2.sha]) allow(MergeRequest).to receive_message_chain(:includes, :where, :reorder).and_return([@merge_request]) end @@ -1151,8 +1151,8 @@ describe Ci::Build, :models do let!(:build) { create(:ci_build, artifacts_size: 23) } it 'updates project statistics when the artifact size changes' do - expect(ProjectCacheWorker).to receive(:perform_async) - .with(build.project_id, [], [:build_artifacts_size]) + expect(ProjectCacheWorker).to receive(:perform_async). + with(build.project_id, [], [:build_artifacts_size]) build.artifacts_size = 42 build.save! @@ -1166,8 +1166,8 @@ describe Ci::Build, :models do end it 'updates project statistics when the build is destroyed' do - expect(ProjectCacheWorker).to receive(:perform_async) - .with(build.project_id, [], [:build_artifacts_size]) + expect(ProjectCacheWorker).to receive(:perform_async). + with(build.project_id, [], [:build_artifacts_size]) build.destroy end diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 9eff58880e3..c2fc8c02bb3 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -455,8 +455,8 @@ describe Ci::Pipeline, models: true do it 'returns the latest pipeline for the same ref and different sha' do expect(pipelines.map(&:sha)).to contain_exactly('A', 'B', 'C') - expect(pipelines.map(&:status)) - .to contain_exactly('success', 'failed', 'skipped') + expect(pipelines.map(&:status)). + to contain_exactly('success', 'failed', 'skipped') end end @@ -465,8 +465,8 @@ describe Ci::Pipeline, models: true do it 'returns the latest pipeline for ref and different sha' do expect(pipelines.map(&:sha)).to contain_exactly('A', 'B') - expect(pipelines.map(&:status)) - .to contain_exactly('success', 'failed') + expect(pipelines.map(&:status)). + to contain_exactly('success', 'failed') end end end @@ -501,8 +501,8 @@ describe Ci::Pipeline, models: true do end it 'returns the latest successful pipeline' do - expect(described_class.latest_successful_for('ref')) - .to eq(latest_successful_pipeline) + expect(described_class.latest_successful_for('ref')). + to eq(latest_successful_pipeline) end end diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb index 674c52eecb2..bee9f714849 100644 --- a/spec/models/ci/variable_spec.rb +++ b/spec/models/ci/variable_spec.rb @@ -32,8 +32,8 @@ describe Ci::Variable, models: true do it 'fails to decrypt if iv is incorrect' do subject.encrypted_value_iv = SecureRandom.hex subject.instance_variable_set(:@value, nil) - expect { subject.value } - .to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt') + expect { subject.value }. + to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt') end end end diff --git a/spec/models/commit_range_spec.rb b/spec/models/commit_range_spec.rb index ba9c3f66d21..e4bddf67096 100644 --- a/spec/models/commit_range_spec.rb +++ b/spec/models/commit_range_spec.rb @@ -147,9 +147,9 @@ describe CommitRange, models: true do note: commit1.revert_description(user), project: issue.project) - expect_any_instance_of(Commit).to receive(:reverts_commit?) - .with(commit1, user) - .and_return(true) + expect_any_instance_of(Commit).to receive(:reverts_commit?). + with(commit1, user). + and_return(true) expect(commit1.has_been_reverted?(user, issue)).to eq(true) end diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index 36533bdd11e..f770e6a9e34 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -253,8 +253,8 @@ describe CommitStatus, :models do let(:user) { create(:user) } it 'returns a detailed status' do - expect(commit_status.detailed_status(user)) - .to be_a Gitlab::Ci::Status::Success + expect(commit_status.detailed_status(user)). + to be_a Gitlab::Ci::Status::Success end end diff --git a/spec/models/concerns/case_sensitivity_spec.rb b/spec/models/concerns/case_sensitivity_spec.rb index a6fccb668e3..92fdc5cd65d 100644 --- a/spec/models/concerns/case_sensitivity_spec.rb +++ b/spec/models/concerns/case_sensitivity_spec.rb @@ -15,13 +15,13 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:foo) - .and_return('"foo"') + expect(connection).to receive(:quote_table_name). + with(:foo). + and_return('"foo"') - expect(model).to receive(:where) - .with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar') - .and_return(criteria) + expect(model).to receive(:where). + with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar'). + and_return(criteria) expect(model.iwhere(foo: 'bar')).to eq(criteria) end @@ -29,13 +29,13 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column with a table, and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:'foo.bar') - .and_return('"foo"."bar"') + expect(connection).to receive(:quote_table_name). + with(:'foo.bar'). + and_return('"foo"."bar"') - expect(model).to receive(:where) - .with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar') - .and_return(criteria) + expect(model).to receive(:where). + with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar'). + and_return(criteria) expect(model.iwhere('foo.bar'.to_sym => 'bar')).to eq(criteria) end @@ -46,21 +46,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:foo) - .and_return('"foo"') + expect(connection).to receive(:quote_table_name). + with(:foo). + and_return('"foo"') - expect(connection).to receive(:quote_table_name) - .with(:bar) - .and_return('"bar"') + expect(connection).to receive(:quote_table_name). + with(:bar). + and_return('"bar"') - expect(model).to receive(:where) - .with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar') - .and_return(initial) + expect(model).to receive(:where). + with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar'). + and_return(initial) - expect(initial).to receive(:where) - .with(%q{LOWER("bar") = LOWER(:value)}, value: 'baz') - .and_return(final) + expect(initial).to receive(:where). + with(%q{LOWER("bar") = LOWER(:value)}, value: 'baz'). + and_return(final) got = model.iwhere(foo: 'bar', bar: 'baz') @@ -71,21 +71,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:'foo.bar') - .and_return('"foo"."bar"') + expect(connection).to receive(:quote_table_name). + with(:'foo.bar'). + and_return('"foo"."bar"') - expect(connection).to receive(:quote_table_name) - .with(:'foo.baz') - .and_return('"foo"."baz"') + expect(connection).to receive(:quote_table_name). + with(:'foo.baz'). + and_return('"foo"."baz"') - expect(model).to receive(:where) - .with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar') - .and_return(initial) + expect(model).to receive(:where). + with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar'). + and_return(initial) - expect(initial).to receive(:where) - .with(%q{LOWER("foo"."baz") = LOWER(:value)}, value: 'baz') - .and_return(final) + expect(initial).to receive(:where). + with(%q{LOWER("foo"."baz") = LOWER(:value)}, value: 'baz'). + and_return(final) got = model.iwhere('foo.bar'.to_sym => 'bar', 'foo.baz'.to_sym => 'baz') @@ -105,13 +105,13 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:foo) - .and_return('`foo`') + expect(connection).to receive(:quote_table_name). + with(:foo). + and_return('`foo`') - expect(model).to receive(:where) - .with(%q{`foo` = :value}, value: 'bar') - .and_return(criteria) + expect(model).to receive(:where). + with(%q{`foo` = :value}, value: 'bar'). + and_return(criteria) expect(model.iwhere(foo: 'bar')).to eq(criteria) end @@ -119,16 +119,16 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column with a table, and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:'foo.bar') - .and_return('`foo`.`bar`') + expect(connection).to receive(:quote_table_name). + with(:'foo.bar'). + and_return('`foo`.`bar`') - expect(model).to receive(:where) - .with(%q{`foo`.`bar` = :value}, value: 'bar') - .and_return(criteria) + expect(model).to receive(:where). + with(%q{`foo`.`bar` = :value}, value: 'bar'). + and_return(criteria) - expect(model.iwhere('foo.bar'.to_sym => 'bar')) - .to eq(criteria) + expect(model.iwhere('foo.bar'.to_sym => 'bar')). + to eq(criteria) end end @@ -137,21 +137,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:foo) - .and_return('`foo`') + expect(connection).to receive(:quote_table_name). + with(:foo). + and_return('`foo`') - expect(connection).to receive(:quote_table_name) - .with(:bar) - .and_return('`bar`') + expect(connection).to receive(:quote_table_name). + with(:bar). + and_return('`bar`') - expect(model).to receive(:where) - .with(%q{`foo` = :value}, value: 'bar') - .and_return(initial) + expect(model).to receive(:where). + with(%q{`foo` = :value}, value: 'bar'). + and_return(initial) - expect(initial).to receive(:where) - .with(%q{`bar` = :value}, value: 'baz') - .and_return(final) + expect(initial).to receive(:where). + with(%q{`bar` = :value}, value: 'baz'). + and_return(final) got = model.iwhere(foo: 'bar', bar: 'baz') @@ -162,21 +162,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:'foo.bar') - .and_return('`foo`.`bar`') + expect(connection).to receive(:quote_table_name). + with(:'foo.bar'). + and_return('`foo`.`bar`') - expect(connection).to receive(:quote_table_name) - .with(:'foo.baz') - .and_return('`foo`.`baz`') + expect(connection).to receive(:quote_table_name). + with(:'foo.baz'). + and_return('`foo`.`baz`') - expect(model).to receive(:where) - .with(%q{`foo`.`bar` = :value}, value: 'bar') - .and_return(initial) + expect(model).to receive(:where). + with(%q{`foo`.`bar` = :value}, value: 'bar'). + and_return(initial) - expect(initial).to receive(:where) - .with(%q{`foo`.`baz` = :value}, value: 'baz') - .and_return(final) + expect(initial).to receive(:where). + with(%q{`foo`.`baz` = :value}, value: 'baz'). + and_return(final) got = model.iwhere('foo.bar'.to_sym => 'bar', 'foo.baz'.to_sym => 'baz') diff --git a/spec/models/concerns/has_status_spec.rb b/spec/models/concerns/has_status_spec.rb index e6107197368..dbfe3cd2d36 100644 --- a/spec/models/concerns/has_status_spec.rb +++ b/spec/models/concerns/has_status_spec.rb @@ -132,8 +132,8 @@ describe HasStatus do describe ".#{status}" do it 'contains the job' do - expect(CommitStatus.public_send(status).all) - .to contain_exactly(job) + expect(CommitStatus.public_send(status).all). + to contain_exactly(job) end end diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index a372824b6e5..545a11912e3 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -87,8 +87,8 @@ describe Issue, "Issuable" do let!(:searchable_issue) { create(:issue, title: "Searchable issue") } it 'returns notes with a matching title' do - expect(described_class.search(searchable_issue.title)) - .to eq([searchable_issue]) + expect(described_class.search(searchable_issue.title)). + to eq([searchable_issue]) end it 'returns notes with a partially matching title' do @@ -96,8 +96,8 @@ describe Issue, "Issuable" do end it 'returns notes with a matching title regardless of the casing' do - expect(described_class.search(searchable_issue.title.upcase)) - .to eq([searchable_issue]) + expect(described_class.search(searchable_issue.title.upcase)). + to eq([searchable_issue]) end end @@ -107,8 +107,8 @@ describe Issue, "Issuable" do end it 'returns notes with a matching title' do - expect(described_class.full_search(searchable_issue.title)) - .to eq([searchable_issue]) + expect(described_class.full_search(searchable_issue.title)). + to eq([searchable_issue]) end it 'returns notes with a partially matching title' do @@ -116,23 +116,23 @@ describe Issue, "Issuable" do end it 'returns notes with a matching title regardless of the casing' do - expect(described_class.full_search(searchable_issue.title.upcase)) - .to eq([searchable_issue]) + expect(described_class.full_search(searchable_issue.title.upcase)). + to eq([searchable_issue]) end it 'returns notes with a matching description' do - expect(described_class.full_search(searchable_issue.description)) - .to eq([searchable_issue]) + expect(described_class.full_search(searchable_issue.description)). + to eq([searchable_issue]) end it 'returns notes with a partially matching description' do - expect(described_class.full_search(searchable_issue.description)) - .to eq([searchable_issue]) + expect(described_class.full_search(searchable_issue.description)). + to eq([searchable_issue]) end it 'returns notes with a matching description regardless of the casing' do - expect(described_class.full_search(searchable_issue.description.upcase)) - .to eq([searchable_issue]) + expect(described_class.full_search(searchable_issue.description.upcase)). + to eq([searchable_issue]) end end @@ -287,16 +287,16 @@ describe Issue, "Issuable" do allow(issue).to receive(:author).and_return(double(name: 'Robert')) allow(issue).to receive(:assignee).and_return(nil) - expect(issue.card_attributes) - .to eq({ 'Author' => 'Robert', 'Assignee' => nil }) + expect(issue.card_attributes). + to eq({ 'Author' => 'Robert', 'Assignee' => nil }) end it 'includes the assignee name' do allow(issue).to receive(:author).and_return(double(name: 'Robert')) allow(issue).to receive(:assignee).and_return(double(name: 'Douwe')) - expect(issue.card_attributes) - .to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' }) + expect(issue.card_attributes). + to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' }) end end diff --git a/spec/models/discussion_spec.rb b/spec/models/discussion_spec.rb index 47c22a03797..bc32fadd391 100644 --- a/spec/models/discussion_spec.rb +++ b/spec/models/discussion_spec.rb @@ -304,22 +304,22 @@ describe Discussion, model: true do it "doesn't change resolved_at on the resolved note" do expect(first_note.resolved_at).not_to be_nil - expect { subject.resolve!(current_user) } - .not_to change { first_note.reload.resolved_at } + expect { subject.resolve!(current_user) }. + not_to change { first_note.reload.resolved_at } end it "doesn't change resolved_by on the resolved note" do expect(first_note.resolved_by).to eq(user) - expect { subject.resolve!(current_user) } - .not_to change { first_note.reload && first_note.resolved_by } + expect { subject.resolve!(current_user) }. + not_to change { first_note.reload && first_note.resolved_by } end it "doesn't change the resolved state on the resolved note" do expect(first_note.resolved?).to be true - expect { subject.resolve!(current_user) } - .not_to change { first_note.reload && first_note.resolved? } + expect { subject.resolve!(current_user) }. + not_to change { first_note.reload && first_note.resolved? } end it "sets resolved_at on the unresolved note" do diff --git a/spec/models/email_spec.rb b/spec/models/email_spec.rb index fe4de1b2afb..4652af1cb97 100644 --- a/spec/models/email_spec.rb +++ b/spec/models/email_spec.rb @@ -8,7 +8,7 @@ describe Email, models: true do end it 'normalize email value' do - expect(described_class.new(email: ' inFO@exAMPLe.com ').email) - .to eq 'info@example.com' + expect(described_class.new(email: ' inFO@exAMPLe.com ').email). + to eq 'info@example.com' end end diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 3198f67a041..dce18f008f8 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -284,9 +284,9 @@ describe Environment, models: true do before { allow(environment).to receive(:has_terminals?).and_return(true) } it 'returns the terminals from the deployment service' do - expect(project.deployment_service) - .to receive(:terminals).with(environment) - .and_return(:fake_terminals) + expect(project.deployment_service). + to receive(:terminals).with(environment). + and_return(:fake_terminals) is_expected.to eq(:fake_terminals) end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index c5acfceb853..8c90a538f57 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -240,8 +240,8 @@ describe Event, models: true do it 'does not update the project' do project.update(last_activity_at: Time.now) - expect(project).not_to receive(:update_column) - .with(:last_activity_at, a_kind_of(Time)) + expect(project).not_to receive(:update_column). + with(:last_activity_at, a_kind_of(Time)) create_event(project, project.owner) end diff --git a/spec/models/group_label_spec.rb b/spec/models/group_label_spec.rb index 555a876daeb..c8d88022ec7 100644 --- a/spec/models/group_label_spec.rb +++ b/spec/models/group_label_spec.rb @@ -49,8 +49,8 @@ describe GroupLabel, models: true do context 'using invalid format' do it 'raises error' do - expect { label.to_reference(format: :invalid) } - .to raise_error StandardError, /Unknown format/ + expect { label.to_reference(format: :invalid) }. + to raise_error StandardError, /Unknown format/ end end end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 57975d6c70b..a4e6eb4e3a6 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -309,8 +309,8 @@ describe Group, models: true do group.add_user(master, GroupMember::MASTER) group.add_user(developer, GroupMember::DEVELOPER) - expect(group.user_ids_for_project_authorizations) - .to include(master.id, developer.id) + expect(group.user_ids_for_project_authorizations). + to include(master.id, developer.id) end end end diff --git a/spec/models/issue_collection_spec.rb b/spec/models/issue_collection_spec.rb index 79584f94a4c..d8aed25c041 100644 --- a/spec/models/issue_collection_spec.rb +++ b/spec/models/issue_collection_spec.rb @@ -50,8 +50,8 @@ describe IssueCollection do context 'using a user that is the owner of a project' do it 'returns the issues of the project' do - expect(collection.updatable_by_user(project.namespace.owner)) - .to eq([issue1, issue2]) + expect(collection.updatable_by_user(project.namespace.owner)). + to eq([issue1, issue2]) end end end diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 143e84dac96..bba9058f394 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -239,8 +239,8 @@ describe Issue, models: true do let(:user) { build(:admin) } before do - allow(subject.project.repository).to receive(:branch_names) - .and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name, "#{subject.iid}-branch"]) + allow(subject.project.repository).to receive(:branch_names). + and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name, "#{subject.iid}-branch"]) # Without this stub, the `create(:merge_request)` above fails because it can't find # the source branch. This seems like a reasonable compromise, in comparison with @@ -262,8 +262,8 @@ describe Issue, models: true do end it 'excludes stable branches from the related branches' do - allow(subject.project.repository).to receive(:branch_names) - .and_return(["#{subject.iid}-0-stable"]) + allow(subject.project.repository).to receive(:branch_names). + and_return(["#{subject.iid}-0-stable"]) expect(subject.related_branches(user)).to eq [] end diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index f5f7e82480e..7c40cfd8253 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -34,8 +34,8 @@ describe Key, models: true do context 'when key was not updated during the last day' do before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) - .and_return('000000') + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). + and_return('000000') end it 'enqueues a UseKeyWorker job' do @@ -46,8 +46,8 @@ describe Key, models: true do context 'when key was updated during the last day' do before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) - .and_return(false) + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). + and_return(false) end it 'does not enqueue a UseKeyWorker job' do diff --git a/spec/models/lfs_objects_project_spec.rb b/spec/models/lfs_objects_project_spec.rb index 7bc278e350f..a2031beeab2 100644 --- a/spec/models/lfs_objects_project_spec.rb +++ b/spec/models/lfs_objects_project_spec.rb @@ -18,8 +18,8 @@ describe LfsObjectsProject, models: true do describe '#update_project_statistics' do it 'updates project statistics when the object is added' do - expect(ProjectCacheWorker).to receive(:perform_async) - .with(project.id, [], [:lfs_objects_size]) + expect(ProjectCacheWorker).to receive(:perform_async). + with(project.id, [], [:lfs_objects_size]) subject.save! end @@ -27,8 +27,8 @@ describe LfsObjectsProject, models: true do it 'updates project statistics when the object is removed' do subject.save! - expect(ProjectCacheWorker).to receive(:perform_async) - .with(project.id, [], [:lfs_objects_size]) + expect(ProjectCacheWorker).to receive(:perform_async). + with(project.id, [], [:lfs_objects_size]) subject.destroy end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index ec17000d17a..c720cc9f2c2 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -83,8 +83,8 @@ describe Member, models: true do @accepted_invite_member = create(:project_member, :developer, project: project, invite_token: '1234', - invite_email: 'toto2@example.com') - .tap { |u| u.accept_invite!(accepted_invite_user) } + invite_email: 'toto2@example.com'). + tap { |u| u.accept_invite!(accepted_invite_user) } requested_user = create(:user).tap { |u| project.request_access(u) } @requested_member = project.requesters.find_by(user_id: requested_user.id) @@ -265,8 +265,8 @@ describe Member, models: true do expect(source.users).not_to include(user) expect(source.requesters.exists?(user_id: user)).to be_truthy - expect { described_class.add_user(source, user, :master) } - .to raise_error(Gitlab::Access::AccessDeniedError) + expect { described_class.add_user(source, user, :master) }. + to raise_error(Gitlab::Access::AccessDeniedError) expect(source.users.reload).not_to include(user) expect(source.requesters.reload.exists?(user_id: user)).to be_truthy diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb index 4a8ea3b6893..370aeb9e0a9 100644 --- a/spec/models/members/group_member_spec.rb +++ b/spec/models/members/group_member_spec.rb @@ -33,8 +33,8 @@ describe GroupMember, models: true do it "sends email to user" do membership = build(:group_member) - allow(membership).to receive(:notification_service) - .and_return(double('NotificationService').as_null_object) + allow(membership).to receive(:notification_service). + and_return(double('NotificationService').as_null_object) expect(membership).to receive(:notification_service) membership.save @@ -44,8 +44,8 @@ describe GroupMember, models: true do describe "#after_update" do before do @group_member = create :group_member - allow(@group_member).to receive(:notification_service) - .and_return(double('NotificationService').as_null_object) + allow(@group_member).to receive(:notification_service). + and_return(double('NotificationService').as_null_object) end it "sends email to user" do diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb index 0a10ee01506..e74e4ae0e96 100644 --- a/spec/models/merge_request_diff_spec.rb +++ b/spec/models/merge_request_diff_spec.rb @@ -84,8 +84,8 @@ describe MergeRequestDiff, models: true do end it 'saves overflow state' do - allow(Commit).to receive(:max_diff_options) - .and_return(max_lines: 0, max_files: 0) + allow(Commit).to receive(:max_diff_options). + and_return(max_lines: 0, max_files: 0) mr_diff = create(:merge_request).merge_request_diff @@ -93,8 +93,8 @@ describe MergeRequestDiff, models: true do end it 'saves empty state' do - allow_any_instance_of(MergeRequestDiff).to receive(:commits) - .and_return([]) + allow_any_instance_of(MergeRequestDiff).to receive(:commits). + and_return([]) mr_diff = create(:merge_request).merge_request_diff diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 6a1f6cee03f..810c08256dc 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -270,8 +270,8 @@ describe MergeRequest, models: true do end it 'accesses the set of issues that will be closed on acceptance' do - allow(subject.project).to receive(:default_branch) - .and_return(subject.target_branch) + allow(subject.project).to receive(:default_branch). + and_return(subject.target_branch) closed = subject.closes_issues @@ -297,8 +297,8 @@ describe MergeRequest, models: true do subject.description = "Is related to #{mentioned_issue.to_reference} and #{closing_issue.to_reference}" allow(subject).to receive(:commits).and_return([commit]) - allow(subject.project).to receive(:default_branch) - .and_return(subject.target_branch) + allow(subject.project).to receive(:default_branch). + and_return(subject.target_branch) expect(subject.issues_mentioned_but_not_closing(subject.author)).to match_array([mentioned_issue]) end @@ -412,15 +412,15 @@ describe MergeRequest, models: true do it 'includes merge information as the title' do request = build(:merge_request, source_branch: 'source', target_branch: 'target') - expect(request.merge_commit_message) - .to match("Merge branch 'source' into 'target'\n\n") + expect(request.merge_commit_message). + to match("Merge branch 'source' into 'target'\n\n") end it 'includes its title in the body' do request = build(:merge_request, title: 'Remove all technical debt') - expect(request.merge_commit_message) - .to match("Remove all technical debt\n\n") + expect(request.merge_commit_message). + to match("Remove all technical debt\n\n") end it 'includes its closed issues in the body' do @@ -429,18 +429,18 @@ describe MergeRequest, models: true do subject.project.team << [subject.author, :developer] subject.description = "This issue Closes #{issue.to_reference}" - allow(subject.project).to receive(:default_branch) - .and_return(subject.target_branch) + allow(subject.project).to receive(:default_branch). + and_return(subject.target_branch) - expect(subject.merge_commit_message) - .to match("Closes #{issue.to_reference}") + expect(subject.merge_commit_message). + to match("Closes #{issue.to_reference}") end it 'includes its reference in the body' do request = build_stubbed(:merge_request) - expect(request.merge_commit_message) - .to match("See merge request #{request.to_reference}") + expect(request.merge_commit_message). + to match("See merge request #{request.to_reference}") end it 'excludes multiple linebreak runs when description is blank' do @@ -452,15 +452,15 @@ describe MergeRequest, models: true do it 'includes its description in the body' do request = build(:merge_request, description: 'By removing all code') - expect(request.merge_commit_message(include_description: true)) - .to match("By removing all code\n\n") + expect(request.merge_commit_message(include_description: true)). + to match("By removing all code\n\n") end it 'does not includes its description in the body' do request = build(:merge_request, description: 'By removing all code') - expect(request.merge_commit_message) - .not_to match("By removing all code\n\n") + expect(request.merge_commit_message). + not_to match("By removing all code\n\n") end end @@ -551,18 +551,18 @@ describe MergeRequest, models: true do end it 'caches the output' do - expect(subject).to receive(:compute_diverged_commits_count) - .once - .and_return(2) + expect(subject).to receive(:compute_diverged_commits_count). + once. + and_return(2) subject.diverged_commits_count subject.diverged_commits_count end it 'invalidates the cache when the source sha changes' do - expect(subject).to receive(:compute_diverged_commits_count) - .twice - .and_return(2) + expect(subject).to receive(:compute_diverged_commits_count). + twice. + and_return(2) subject.diverged_commits_count allow(subject).to receive(:source_branch_sha).and_return('123abc') @@ -570,9 +570,9 @@ describe MergeRequest, models: true do end it 'invalidates the cache when the target sha changes' do - expect(subject).to receive(:compute_diverged_commits_count) - .twice - .and_return(2) + expect(subject).to receive(:compute_diverged_commits_count). + twice. + and_return(2) subject.diverged_commits_count allow(subject).to receive(:target_branch_sha).and_return('123abc') @@ -594,8 +594,8 @@ describe MergeRequest, models: true do describe '#commits_sha' do before do - allow(subject.merge_request_diff).to receive(:commits_sha) - .and_return(['sha1']) + allow(subject.merge_request_diff).to receive(:commits_sha). + and_return(['sha1']) end it 'delegates to merge request diff' do @@ -610,9 +610,9 @@ describe MergeRequest, models: true do allow(subject).to receive(:diff_head_sha).and_return('123abc') - expect(subject.source_project).to receive(:pipeline_for) - .with('master', '123abc') - .and_return(pipeline) + expect(subject.source_project).to receive(:pipeline_for). + with('master', '123abc'). + and_return(pipeline) expect(subject.head_pipeline).to eq(pipeline) end @@ -1632,8 +1632,8 @@ describe MergeRequest, models: true do describe '#has_commits?' do before do - allow(subject.merge_request_diff).to receive(:commits_count) - .and_return(2) + allow(subject.merge_request_diff).to receive(:commits_count). + and_return(2) end it 'returns true when merge request diff has commits' do @@ -1643,8 +1643,8 @@ describe MergeRequest, models: true do describe '#has_no_commits?' do before do - allow(subject.merge_request_diff).to receive(:commits_count) - .and_return(0) + allow(subject.merge_request_diff).to receive(:commits_count). + and_return(0) end it 'returns true when merge request diff has 0 commits' do diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 0ffcbf7e3f6..3cee2b7714f 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -205,13 +205,13 @@ describe Milestone, models: true do end it 'returns milestones with a partially matching description' do - expect(described_class.search(milestone.description[0..2])) - .to eq([milestone]) + expect(described_class.search(milestone.description[0..2])). + to eq([milestone]) end it 'returns milestones with a matching description regardless of the casing' do - expect(described_class.search(milestone.description.upcase)) - .to eq([milestone]) + expect(described_class.search(milestone.description.upcase)). + to eq([milestone]) end end diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 74fbae07a6f..35d932f1c64 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -216,8 +216,8 @@ describe Namespace, models: true do describe '#user_ids_for_project_authorizations' do it 'returns the user IDs for which to refresh authorizations' do - expect(namespace.user_ids_for_project_authorizations) - .to eq([namespace.owner_id]) + expect(namespace.user_ids_for_project_authorizations). + to eq([namespace.owner_id]) end end end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 973a0b9d592..1cde9e04951 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -148,8 +148,8 @@ describe Note, models: true do let!(:note2) { create(:note_on_issue) } it "reads the rendered note body from the cache" do - expect(Banzai::Renderer).to receive(:cache_collection_render) - .with([{ + expect(Banzai::Renderer).to receive(:cache_collection_render). + with([{ text: note1.note, context: { skip_project_check: false, @@ -160,8 +160,8 @@ describe Note, models: true do } }]).and_call_original - expect(Banzai::Renderer).to receive(:cache_collection_render) - .with([{ + expect(Banzai::Renderer).to receive(:cache_collection_render). + with([{ text: note2.note, context: { skip_project_check: false, @@ -361,8 +361,8 @@ describe Note, models: true do let(:note) { build(:note_on_project_snippet) } before do - expect(Banzai::Renderer).to receive(:cacheless_render_field) - .with(note, :note, { skip_project_check: false }).and_return(html) + expect(Banzai::Renderer).to receive(:cacheless_render_field). + with(note, :note, { skip_project_check: false }).and_return(html) note.save end @@ -376,8 +376,8 @@ describe Note, models: true do let(:note) { build(:note_on_personal_snippet) } before do - expect(Banzai::Renderer).to receive(:cacheless_render_field) - .with(note, :note, { skip_project_check: true }).and_return(html) + expect(Banzai::Renderer).to receive(:cacheless_render_field). + with(note, :note, { skip_project_check: true }).and_return(html) note.save end diff --git a/spec/models/project_authorization_spec.rb b/spec/models/project_authorization_spec.rb index 4001851b9ec..33ef67f97a7 100644 --- a/spec/models/project_authorization_spec.rb +++ b/spec/models/project_authorization_spec.rb @@ -7,8 +7,8 @@ describe ProjectAuthorization do describe '.insert_authorizations' do it 'inserts the authorizations' do - described_class - .insert_authorizations([[user.id, project1.id, Gitlab::Access::MASTER]]) + described_class. + insert_authorizations([[user.id, project1.id, Gitlab::Access::MASTER]]) expect(user.project_authorizations.count).to eq(1) end diff --git a/spec/models/project_label_spec.rb b/spec/models/project_label_spec.rb index 9cdbfa44e5b..3e9dd3758ed 100644 --- a/spec/models/project_label_spec.rb +++ b/spec/models/project_label_spec.rb @@ -94,8 +94,8 @@ describe ProjectLabel, models: true do context 'using invalid format' do it 'raises error' do - expect { label.to_reference(format: :invalid) } - .to raise_error StandardError, /Unknown format/ + expect { label.to_reference(format: :invalid) }. + to raise_error StandardError, /Unknown format/ end end @@ -104,15 +104,15 @@ describe ProjectLabel, models: true do context 'using name' do it 'returns cross reference with label name' do - expect(label.to_reference(project, format: :name)) - .to eq %Q(#{label.project.path_with_namespace}~"#{label.name}") + expect(label.to_reference(project, format: :name)). + to eq %Q(#{label.project.path_with_namespace}~"#{label.name}") end end context 'using id' do it 'returns cross reference with label id' do - expect(label.to_reference(project, format: :id)) - .to eq %Q(#{label.project.path_with_namespace}~#{label.id}) + expect(label.to_reference(project, format: :id)). + to eq %Q(#{label.project.path_with_namespace}~#{label.id}) end end end diff --git a/spec/models/project_services/mattermost_slash_commands_service_spec.rb b/spec/models/project_services/mattermost_slash_commands_service_spec.rb index 9082156788e..598ff232c82 100644 --- a/spec/models/project_services/mattermost_slash_commands_service_spec.rb +++ b/spec/models/project_services/mattermost_slash_commands_service_spec.rb @@ -11,8 +11,8 @@ describe MattermostSlashCommandsService, :models do before do Mattermost::Session.base_uri("http://mattermost.example.com") - allow_any_instance_of(Mattermost::Client).to receive(:with_session) - .and_yield(Mattermost::Session.new(nil)) + allow_any_instance_of(Mattermost::Client).to receive(:with_session). + and_yield(Mattermost::Session.new(nil)) end describe '#configure' do @@ -24,8 +24,8 @@ describe MattermostSlashCommandsService, :models do context 'the requests succeeds' do before do - stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create') - .with(body: { + stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create'). + with(body: { team_id: 'abc', trigger: 'gitlab', url: 'http://trigger.url', @@ -37,8 +37,8 @@ describe MattermostSlashCommandsService, :models do display_name: "GitLab / #{project.name_with_namespace}", method: 'P', username: 'GitLab' - }.to_json) - .to_return( + }.to_json). + to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: { token: 'token' }.to_json @@ -58,8 +58,8 @@ describe MattermostSlashCommandsService, :models do context 'an error is received' do before do - stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create') - .to_return( + stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create'). + to_return( status: 500, headers: { 'Content-Type' => 'application/json' }, body: { @@ -88,8 +88,8 @@ describe MattermostSlashCommandsService, :models do context 'the requests succeeds' do before do - stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all') - .to_return( + stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all'). + to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: ['list'].to_json @@ -103,8 +103,8 @@ describe MattermostSlashCommandsService, :models do context 'an error is received' do before do - stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all') - .to_return( + stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all'). + to_return( status: 500, headers: { 'Content-Type' => 'application/json' }, body: { diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 66e0ea6d9a5..b0087a9e15d 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1150,23 +1150,23 @@ describe Project, models: true do it 'renames a repository' do ns = project.namespace_dir - expect(gitlab_shell).to receive(:mv_repository) - .ordered - .with(project.repository_storage_path, "#{ns}/foo", "#{ns}/#{project.path}") - .and_return(true) + expect(gitlab_shell).to receive(:mv_repository). + ordered. + with(project.repository_storage_path, "#{ns}/foo", "#{ns}/#{project.path}"). + and_return(true) - expect(gitlab_shell).to receive(:mv_repository) - .ordered - .with(project.repository_storage_path, "#{ns}/foo.wiki", "#{ns}/#{project.path}.wiki") - .and_return(true) + expect(gitlab_shell).to receive(:mv_repository). + ordered. + with(project.repository_storage_path, "#{ns}/foo.wiki", "#{ns}/#{project.path}.wiki"). + and_return(true) - expect_any_instance_of(SystemHooksService) - .to receive(:execute_hooks_for) - .with(project, :rename) + expect_any_instance_of(SystemHooksService). + to receive(:execute_hooks_for). + with(project, :rename) - expect_any_instance_of(Gitlab::UploadsTransfer) - .to receive(:rename_project) - .with('foo', project.path, ns) + expect_any_instance_of(Gitlab::UploadsTransfer). + to receive(:rename_project). + with('foo', project.path, ns) expect(project).to receive(:expire_caches_before_rename) @@ -1191,13 +1191,13 @@ describe Project, models: true do let(:wiki) { double(:wiki, exists?: true) } it 'expires the caches of the repository and wiki' do - allow(Repository).to receive(:new) - .with('foo', project) - .and_return(repo) + allow(Repository).to receive(:new). + with('foo', project). + and_return(repo) - allow(Repository).to receive(:new) - .with('foo.wiki', project) - .and_return(wiki) + allow(Repository).to receive(:new). + with('foo.wiki', project). + and_return(wiki) expect(repo).to receive(:before_delete) expect(wiki).to receive(:before_delete) @@ -1248,9 +1248,9 @@ describe Project, models: true do context 'using a regular repository' do it 'creates the repository' do - expect(shell).to receive(:add_repository) - .with(project.repository_storage_path, project.path_with_namespace) - .and_return(true) + expect(shell).to receive(:add_repository). + with(project.repository_storage_path, project.path_with_namespace). + and_return(true) expect(project.repository).to receive(:after_create) @@ -1258,9 +1258,9 @@ describe Project, models: true do end it 'adds an error if the repository could not be created' do - expect(shell).to receive(:add_repository) - .with(project.repository_storage_path, project.path_with_namespace) - .and_return(false) + expect(shell).to receive(:add_repository). + with(project.repository_storage_path, project.path_with_namespace). + and_return(false) expect(project.repository).not_to receive(:after_create) @@ -1536,8 +1536,8 @@ describe Project, models: true do let(:project) { forked_project_link.forked_to_project } it 'schedules a RepositoryForkWorker job' do - expect(RepositoryForkWorker).to receive(:perform_async) - .with(project.id, forked_from_project.repository_storage_path, + expect(RepositoryForkWorker).to receive(:perform_async). + with(project.id, forked_from_project.repository_storage_path, forked_from_project.path_with_namespace, project.namespace.path) project.add_import_job diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb index 8c43937c398..58b57bd4fef 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -143,15 +143,15 @@ describe ProjectWiki, models: true do describe '#find_file' do before do file = Gollum::File.new(subject.wiki) - allow_any_instance_of(Gollum::Wiki) - .to receive(:file).with('image.jpg', 'master', true) - .and_return(file) - allow_any_instance_of(Gollum::File) - .to receive(:mime_type) - .and_return('image/jpeg') - allow_any_instance_of(Gollum::Wiki) - .to receive(:file).with('non-existant', 'master', true) - .and_return(nil) + allow_any_instance_of(Gollum::Wiki). + to receive(:file).with('image.jpg', 'master', true). + and_return(file) + allow_any_instance_of(Gollum::File). + to receive(:mime_type). + and_return('image/jpeg') + allow_any_instance_of(Gollum::Wiki). + to receive(:file).with('non-existant', 'master', true). + and_return(nil) end after do @@ -253,9 +253,9 @@ describe ProjectWiki, models: true do describe '#create_repo!' do it 'creates a repository' do - expect(subject).to receive(:init_repo) - .with(subject.path_with_namespace) - .and_return(true) + expect(subject).to receive(:init_repo). + with(subject.path_with_namespace). + and_return(true) expect(subject.repository).to receive(:after_create) diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index dfa019d28b0..a3fe412b229 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -125,8 +125,8 @@ describe Repository, models: true do describe '#ref_name_for_sha' do context 'ref found' do it 'returns the ref' do - allow_any_instance_of(Gitlab::Popen).to receive(:popen) - .and_return(["b8d95eb4969eefacb0a58f6a28f6803f8070e7b9 commit\trefs/environments/production/77\n", 0]) + allow_any_instance_of(Gitlab::Popen).to receive(:popen). + and_return(["b8d95eb4969eefacb0a58f6a28f6803f8070e7b9 commit\trefs/environments/production/77\n", 0]) expect(repository.ref_name_for_sha('bla', '0' * 40)).to eq 'refs/environments/production/77' end @@ -134,8 +134,8 @@ describe Repository, models: true do context 'ref not found' do it 'returns nil' do - allow_any_instance_of(Gitlab::Popen).to receive(:popen) - .and_return(["", 0]) + allow_any_instance_of(Gitlab::Popen).to receive(:popen). + and_return(["", 0]) expect(repository.ref_name_for_sha('bla', '0' * 40)).to eq nil end @@ -265,8 +265,8 @@ describe Repository, models: true do describe '#commit' do context 'when ref exists' do it 'returns commit object' do - expect(repository.commit('master')) - .to be_an_instance_of Commit + expect(repository.commit('master')). + to be_an_instance_of Commit end end @@ -596,8 +596,8 @@ describe Repository, models: true do user, 'LICENSE', 'Copyright!', message: 'Add LICENSE', branch_name: 'master', update: false) - allow(repository).to receive(:file_on_head) - .and_raise(Rugged::ReferenceError) + allow(repository).to receive(:file_on_head). + and_raise(Rugged::ReferenceError) expect(repository.license_blob).to be_nil end @@ -749,8 +749,8 @@ describe Repository, models: true do context 'when pre hooks were successful' 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_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 @@ -792,14 +792,14 @@ describe Repository, models: true do before do service = GitHooksService.new expect(GitHooksService).to receive(:new).and_return(service) - expect(service).to receive(:execute) - .with( + expect(service).to receive(:execute). + with( user, repository.path_to_repo, old_rev, new_rev, - 'refs/heads/feature') - .and_yield(service).and_return(true) + 'refs/heads/feature'). + and_yield(service).and_return(true) end it 'runs without errors' do @@ -893,8 +893,8 @@ describe Repository, models: true do expect(repository).not_to receive(:expire_emptiness_caches) expect(repository).to receive(:expire_branches_cache) - GitOperationService.new(user, repository) - .with_branch('new-feature') do + GitOperationService.new(user, repository). + with_branch('new-feature') do new_rev end end @@ -978,8 +978,8 @@ describe Repository, models: true do end it 'does nothing' do - expect(repository.raw_repository).not_to receive(:autocrlf=) - .with(:input) + expect(repository.raw_repository).not_to receive(:autocrlf=). + with(:input) GitOperationService.new(nil, repository).send(:update_autocrlf_option) end @@ -998,9 +998,9 @@ describe Repository, models: true do end it 'caches the output' do - expect(repository.raw_repository).to receive(:empty?) - .once - .and_return(false) + expect(repository.raw_repository).to receive(:empty?). + once. + and_return(false) repository.empty? repository.empty? @@ -1013,9 +1013,9 @@ describe Repository, models: true do end it 'caches the output' do - expect(repository.raw_repository).to receive(:root_ref) - .once - .and_return('master') + expect(repository.raw_repository).to receive(:root_ref). + once. + and_return('master') repository.root_ref repository.root_ref @@ -1026,9 +1026,9 @@ describe Repository, models: true do it 'expires the root reference cache' do repository.root_ref - expect(repository.raw_repository).to receive(:root_ref) - .once - .and_return('foo') + expect(repository.raw_repository).to receive(:root_ref). + once. + and_return('foo') repository.expire_root_ref_cache @@ -1042,17 +1042,17 @@ describe Repository, models: true do let(:cache) { repository.send(:cache) } it 'expires the cache for all branches' do - expect(cache).to receive(:expire) - .at_least(repository.branches.length) - .times + expect(cache).to receive(:expire). + at_least(repository.branches.length). + times repository.expire_branch_cache end it 'expires the cache for all branches when the root branch is given' do - expect(cache).to receive(:expire) - .at_least(repository.branches.length) - .times + expect(cache).to receive(:expire). + at_least(repository.branches.length). + times repository.expire_branch_cache(repository.root_ref) end @@ -1314,12 +1314,12 @@ describe Repository, models: true do describe '#after_push_commit' do it 'expires statistics caches' do - expect(repository).to receive(:expire_statistics_caches) - .and_call_original + expect(repository).to receive(:expire_statistics_caches). + and_call_original - expect(repository).to receive(:expire_branch_cache) - .with('master') - .and_call_original + expect(repository).to receive(:expire_branch_cache). + with('master'). + and_call_original repository.after_push_commit('master') end @@ -1394,9 +1394,9 @@ describe Repository, models: true do describe '#expire_branches_cache' do it 'expires the cache' do - expect(repository).to receive(:expire_method_caches) - .with(%i(branch_names branch_count)) - .and_call_original + expect(repository).to receive(:expire_method_caches). + with(%i(branch_names branch_count)). + and_call_original repository.expire_branches_cache end @@ -1404,9 +1404,9 @@ describe Repository, models: true do describe '#expire_tags_cache' do it 'expires the cache' do - expect(repository).to receive(:expire_method_caches) - .with(%i(tag_names tag_count)) - .and_call_original + expect(repository).to receive(:expire_method_caches). + with(%i(tag_names tag_count)). + and_call_original repository.expire_tags_cache end @@ -1417,11 +1417,11 @@ describe Repository, models: true do let(:user) { build_stubbed(:user) } it 'creates the tag using rugged' do - expect(repository.rugged.tags).to receive(:create) - .with('8.5', repository.commit('master').id, + expect(repository.rugged.tags).to receive(:create). + with('8.5', repository.commit('master').id, hash_including(message: 'foo', - tagger: hash_including(name: user.name, email: user.email))) - .and_call_original + tagger: hash_including(name: user.name, email: user.email))). + and_call_original repository.add_tag(user, '8.5', 'master', 'foo') end @@ -1438,8 +1438,8 @@ describe Repository, models: true do update_hook = Gitlab::Git::Hook.new('update', repository.path_to_repo) post_receive_hook = Gitlab::Git::Hook.new('post-receive', repository.path_to_repo) - allow(Gitlab::Git::Hook).to receive(:new) - .and_return(pre_receive_hook, update_hook, post_receive_hook) + allow(Gitlab::Git::Hook).to receive(:new). + and_return(pre_receive_hook, update_hook, post_receive_hook) allow(pre_receive_hook).to receive(:trigger).and_call_original allow(update_hook).to receive(:trigger).and_call_original @@ -1450,12 +1450,12 @@ describe Repository, models: true do commit_sha = repository.commit('master').id tag_sha = tag.target - expect(pre_receive_hook).to have_received(:trigger) - .with(anything, anything, commit_sha, anything) - expect(update_hook).to have_received(:trigger) - .with(anything, anything, commit_sha, anything) - expect(post_receive_hook).to have_received(:trigger) - .with(anything, anything, tag_sha, anything) + expect(pre_receive_hook).to have_received(:trigger). + with(anything, anything, commit_sha, anything) + expect(update_hook).to have_received(:trigger). + with(anything, anything, commit_sha, anything) + expect(post_receive_hook).to have_received(:trigger). + with(anything, anything, tag_sha, anything) end end @@ -1489,25 +1489,25 @@ describe Repository, models: true do describe '#avatar' do it 'returns nil if repo does not exist' do - expect(repository).to receive(:file_on_head) - .and_raise(Rugged::ReferenceError) + expect(repository).to receive(:file_on_head). + and_raise(Rugged::ReferenceError) expect(repository.avatar).to eq(nil) end it 'returns the first avatar file found in the repository' do - expect(repository).to receive(:file_on_head) - .with(:avatar) - .and_return(double(:tree, path: 'logo.png')) + expect(repository).to receive(:file_on_head). + with(:avatar). + and_return(double(:tree, path: 'logo.png')) expect(repository.avatar).to eq('logo.png') end it 'caches the output' do - expect(repository).to receive(:file_on_head) - .with(:avatar) - .once - .and_return(double(:tree, path: 'logo.png')) + expect(repository).to receive(:file_on_head). + with(:avatar). + once. + and_return(double(:tree, path: 'logo.png')) 2.times { expect(repository.avatar).to eq('logo.png') } end @@ -1567,24 +1567,24 @@ describe Repository, models: true do describe '#contribution_guide', caching: true do it 'returns and caches the output' do - expect(repository).to receive(:file_on_head) - .with(:contributing) - .and_return(Gitlab::Git::Tree.new(path: 'CONTRIBUTING.md')) - .once + expect(repository).to receive(:file_on_head). + with(:contributing). + and_return(Gitlab::Git::Tree.new(path: 'CONTRIBUTING.md')). + once 2.times do - expect(repository.contribution_guide) - .to be_an_instance_of(Gitlab::Git::Tree) + expect(repository.contribution_guide). + to be_an_instance_of(Gitlab::Git::Tree) end end end describe '#gitignore', caching: true do it 'returns and caches the output' do - expect(repository).to receive(:file_on_head) - .with(:gitignore) - .and_return(Gitlab::Git::Tree.new(path: '.gitignore')) - .once + expect(repository).to receive(:file_on_head). + with(:gitignore). + and_return(Gitlab::Git::Tree.new(path: '.gitignore')). + once 2.times do expect(repository.gitignore).to be_an_instance_of(Gitlab::Git::Tree) @@ -1594,10 +1594,10 @@ describe Repository, models: true do describe '#koding_yml', caching: true do it 'returns and caches the output' do - expect(repository).to receive(:file_on_head) - .with(:koding) - .and_return(Gitlab::Git::Tree.new(path: '.koding.yml')) - .once + expect(repository).to receive(:file_on_head). + with(:koding). + and_return(Gitlab::Git::Tree.new(path: '.koding.yml')). + once 2.times do expect(repository.koding_yml).to be_an_instance_of(Gitlab::Git::Tree) @@ -1623,8 +1623,8 @@ describe Repository, models: true do describe '#expire_statistics_caches' do it 'expires the caches' do - expect(repository).to receive(:expire_method_caches) - .with(%i(size commit_count)) + expect(repository).to receive(:expire_method_caches). + with(%i(size commit_count)) repository.expire_statistics_caches end @@ -1641,8 +1641,8 @@ describe Repository, models: true do describe '#expire_all_method_caches' do it 'expires the caches of all methods' do - expect(repository).to receive(:expire_method_caches) - .with(Repository::CACHED_METHODS) + expect(repository).to receive(:expire_method_caches). + with(Repository::CACHED_METHODS) repository.expire_all_method_caches end @@ -1667,8 +1667,8 @@ describe Repository, models: true do context 'with an existing repository' do it 'returns a Gitlab::Git::Tree' do - expect(repository.file_on_head(:readme)) - .to be_an_instance_of(Gitlab::Git::Tree) + expect(repository.file_on_head(:readme)). + to be_an_instance_of(Gitlab::Git::Tree) end end end @@ -1783,8 +1783,8 @@ describe Repository, models: true do describe '#refresh_method_caches' do it 'refreshes the caches of the given types' do - expect(repository).to receive(:expire_method_caches) - .with(%i(readme license_blob license_key)) + expect(repository).to receive(:expire_method_caches). + with(%i(readme license_blob license_key)) expect(repository).to receive(:readme) expect(repository).to receive(:license_blob) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2c03a485823..d7aa7754834 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -808,8 +808,8 @@ describe User, models: true do describe '.find_by_username!' do it 'raises RecordNotFound' do - expect { described_class.find_by_username!('JohnDoe') } - .to raise_error(ActiveRecord::RecordNotFound) + expect { described_class.find_by_username!('JohnDoe') }. + to raise_error(ActiveRecord::RecordNotFound) end it 'is case-insensitive' do @@ -1146,8 +1146,8 @@ describe User, models: true do user = create(:user) project = create(:empty_project, :private, namespace: user.namespace) - expect(user.authorized_projects(Gitlab::Access::REPORTER)) - .to contain_exactly(project) + expect(user.authorized_projects(Gitlab::Access::REPORTER)). + to contain_exactly(project) end it 'includes projects for which the user is a master' do @@ -1156,8 +1156,8 @@ describe User, models: true do project.team << [user, Gitlab::Access::MASTER] - expect(user.authorized_projects(Gitlab::Access::REPORTER)) - .to contain_exactly(project) + expect(user.authorized_projects(Gitlab::Access::REPORTER)). + to contain_exactly(project) end end @@ -1385,8 +1385,8 @@ describe User, models: true do end it 'returns the projects when using an ActiveRecord relation' do - projects = user - .projects_with_reporter_access_limited_to(Project.select(:id)) + projects = user. + projects_with_reporter_access_limited_to(Project.select(:id)) expect(projects).to eq([project1]) end diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 4a73552b8a6..753dc938c52 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -61,8 +61,8 @@ describe WikiPage, models: true do actual_order = grouped_entries.map do |page_or_dir| get_slugs(page_or_dir) - end - .flatten + end. + flatten expect(actual_order).to eq(expected_order) end end |