diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-29 00:08:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-29 00:08:22 +0300 |
commit | d7b136d5471b5925ff784f78b9c11ec63c2a3549 (patch) | |
tree | 6c4417fb367459613e84a2d34625abccd13e6405 /spec/rubocop | |
parent | 1ec60cf53bc498b12c597ff0d91434a1bdb7cba9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
14 files changed, 55 insertions, 55 deletions
diff --git a/spec/rubocop/cop/active_record_association_reload_spec.rb b/spec/rubocop/cop/active_record_association_reload_spec.rb index 3cd7a35f12f..d9c8069f0c3 100644 --- a/spec/rubocop/cop/active_record_association_reload_spec.rb +++ b/spec/rubocop/cop/active_record_association_reload_spec.rb @@ -11,7 +11,7 @@ describe RuboCop::Cop::ActiveRecordAssociationReload do context 'when using ActiveRecord::Base' do it 'registers an offense on reload usage' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) users = User.all users.reload ^^^^^^ Use reset instead of reload. For more details check the https://gitlab.com/gitlab-org/gitlab-foss/issues/60218. @@ -19,7 +19,7 @@ describe RuboCop::Cop::ActiveRecordAssociationReload do end it 'does not register an offense on reset usage' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) users = User.all users.reset PATTERN @@ -28,7 +28,7 @@ describe RuboCop::Cop::ActiveRecordAssociationReload do context 'when using ActiveRecord::Relation' do it 'registers an offense on reload usage' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) user = User.new user.reload ^^^^^^ Use reset instead of reload. For more details check the https://gitlab.com/gitlab-org/gitlab-foss/issues/60218. @@ -36,7 +36,7 @@ describe RuboCop::Cop::ActiveRecordAssociationReload do end it 'does not register an offense on reset usage' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) user = User.new user.reset PATTERN @@ -45,14 +45,14 @@ describe RuboCop::Cop::ActiveRecordAssociationReload do context 'when using on self' do it 'registers an offense on reload usage' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) reload ^^^^^^ Use reset instead of reload. For more details check the https://gitlab.com/gitlab-org/gitlab-foss/issues/60218. PATTERN end it 'does not register an offense on reset usage' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) reset PATTERN end diff --git a/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb b/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb index c9eb61ccc72..207c3420fbd 100644 --- a/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb +++ b/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb @@ -14,14 +14,14 @@ describe RuboCop::Cop::AvoidRouteRedirectLeadingSlash do end it 'registers an offense when redirect has a leading slash' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) root to: redirect("/-/route") ^^^^^^^^^^^^^^^^^^^^ Do not use a leading "/" in route redirects PATTERN end it 'does not register an offense when redirect does not have a leading slash' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) root to: redirect("-/route") PATTERN end diff --git a/spec/rubocop/cop/destroy_all_spec.rb b/spec/rubocop/cop/destroy_all_spec.rb index ac8aa56e040..d06c0b2f3cf 100644 --- a/spec/rubocop/cop/destroy_all_spec.rb +++ b/spec/rubocop/cop/destroy_all_spec.rb @@ -11,13 +11,13 @@ describe RuboCop::Cop::DestroyAll do subject(:cop) { described_class.new } it 'flags the use of destroy_all with a send receiver' do - inspect_source('foo.destroy_all # rubocop: disable DestroyAll') + inspect_source('foo.destroy_all # rubocop: disable Cop/DestroyAll') expect(cop.offenses.size).to eq(1) end it 'flags the use of destroy_all with a constant receiver' do - inspect_source('User.destroy_all # rubocop: disable DestroyAll') + inspect_source('User.destroy_all # rubocop: disable Cop/DestroyAll') expect(cop.offenses.size).to eq(1) end @@ -31,7 +31,7 @@ describe RuboCop::Cop::DestroyAll do it 'flags the use of destroy_all with a local variable receiver' do inspect_source(<<~RUBY) users = User.all - users.destroy_all # rubocop: disable DestroyAll + users.destroy_all # rubocop: disable Cop/DestroyAll RUBY expect(cop.offenses.size).to eq(1) diff --git a/spec/rubocop/cop/gitlab/change_timezone_spec.rb b/spec/rubocop/cop/gitlab/change_timezone_spec.rb index af76559a9fa..1e4b4048cf4 100644 --- a/spec/rubocop/cop/gitlab/change_timezone_spec.rb +++ b/spec/rubocop/cop/gitlab/change_timezone_spec.rb @@ -12,7 +12,7 @@ describe RuboCop::Cop::Gitlab::ChangeTimezone do context 'Time.zone=' do it 'registers an offense with no 2nd argument' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) Time.zone = 'Awkland' ^^^^^^^^^^^^^^^^^^^^^ Do not change timezone in the runtime (application or rspec), it could result in silently modifying other behavior. PATTERN diff --git a/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb b/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb index 0ff06b431eb..bf0434e7afe 100644 --- a/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb +++ b/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb @@ -12,7 +12,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'Object.const_get' do it 'registers an offense with no 2nd argument' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) Object.const_get(:CONSTANT) ^^^^^^^^^ Use inherit=false when using const_get. PATTERN @@ -24,7 +24,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'inherit=false' do it 'does not register an offense' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) Object.const_get(:CONSTANT, false) PATTERN end @@ -32,7 +32,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'inherit=true' do it 'registers an offense' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) Object.const_get(:CONSTANT, true) ^^^^^^^^^ Use inherit=false when using const_get. PATTERN @@ -46,7 +46,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'const_get for a nested class' do it 'registers an offense on reload usage' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) Nested::Blog.const_get(:CONSTANT) ^^^^^^^^^ Use inherit=false when using const_get. PATTERN @@ -58,7 +58,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'inherit=false' do it 'does not register an offense' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) Nested::Blog.const_get(:CONSTANT, false) PATTERN end @@ -66,7 +66,7 @@ describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do context 'inherit=true' do it 'registers an offense if inherit is true' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) Nested::Blog.const_get(:CONSTANT, true) ^^^^^^^^^ Use inherit=false when using const_get. PATTERN diff --git a/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb b/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb index 87dd2f14b31..3a0a74a4713 100644 --- a/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb +++ b/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb @@ -20,7 +20,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do context 'Non-EE spec file' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, full_path('spec/foo_spec.rb')) + expect_no_offenses(<<~SOURCE, full_path('spec/foo_spec.rb')) describe 'Foo' do end SOURCE @@ -29,7 +29,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do context 'Non-EE application file' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, full_path('app/models/blog_post.rb')) + expect_no_offenses(<<~SOURCE, full_path('app/models/blog_post.rb')) class BlogPost end SOURCE @@ -38,7 +38,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do context 'EE application file' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, full_path('ee/app/models/blog_post.rb')) + expect_no_offenses(<<~SOURCE, full_path('ee/app/models/blog_post.rb')) class BlogPost end SOURCE @@ -49,7 +49,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do let(:spec_file_path) { full_path('ee/spec/controllers/foo_spec.rb') } it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, spec_file_path) + expect_no_offenses(<<~SOURCE, spec_file_path) describe 'Foo' do end SOURCE @@ -65,7 +65,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do end it 'marks the describe as offending' do - expect_offense(<<~SOURCE.strip_indent, spec_file_path) + expect_offense(<<~SOURCE, spec_file_path) describe 'Foo' do ^^^^^^^^^^^^^^ Duplicate spec location in `ee/spec/controllers/ee/foo_spec.rb`. end @@ -78,7 +78,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do let(:spec_file_path) { full_path('ee/spec/controllers/ee/foo_spec.rb') } it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, spec_file_path) + expect_no_offenses(<<~SOURCE, spec_file_path) describe 'Foo' do end SOURCE @@ -94,7 +94,7 @@ describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do end it 'marks the describe as offending' do - expect_offense(<<~SOURCE.strip_indent, spec_file_path) + expect_offense(<<~SOURCE, spec_file_path) describe 'Foo' do ^^^^^^^^^^^^^^ Duplicate spec location in `ee/spec/controllers/foo_spec.rb`. end diff --git a/spec/rubocop/cop/migration/add_index_spec.rb b/spec/rubocop/cop/migration/add_index_spec.rb index 0c3f87e5bf8..ca1aadb381b 100644 --- a/spec/rubocop/cop/migration/add_index_spec.rb +++ b/spec/rubocop/cop/migration/add_index_spec.rb @@ -18,7 +18,7 @@ describe RuboCop::Cop::Migration::AddIndex do end it 'registers an offense when add_index is used' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) def change add_index :table, :column ^^^^^^^^^ `add_index` requires downtime, use `add_concurrent_index` instead @@ -29,7 +29,7 @@ describe RuboCop::Cop::Migration::AddIndex do context 'outside of migration' do it 'registers no offense' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) def change add_index :table, :column end diff --git a/spec/rubocop/cop/put_group_routes_under_scope_spec.rb b/spec/rubocop/cop/put_group_routes_under_scope_spec.rb index fc4d0015dde..c77412f91b4 100644 --- a/spec/rubocop/cop/put_group_routes_under_scope_spec.rb +++ b/spec/rubocop/cop/put_group_routes_under_scope_spec.rb @@ -14,7 +14,7 @@ describe RuboCop::Cop::PutGroupRoutesUnderScope do end it 'registers an offense when route is outside scope' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) scope(path: 'groups/*group_id/-', module: :groups) do resource :issues end @@ -25,7 +25,7 @@ describe RuboCop::Cop::PutGroupRoutesUnderScope do end it 'does not register an offense when resource inside the scope' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) scope(path: 'groups/*group_id/-', module: :groups) do resource :issues resource :notes @@ -34,7 +34,7 @@ describe RuboCop::Cop::PutGroupRoutesUnderScope do end it 'does not register an offense when resource is deep inside the scope' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) scope(path: 'groups/*group_id/-', module: :groups) do resource :issues resource :projects do diff --git a/spec/rubocop/cop/put_project_routes_under_scope_spec.rb b/spec/rubocop/cop/put_project_routes_under_scope_spec.rb index b0f1e52f397..80ac4cc52e9 100644 --- a/spec/rubocop/cop/put_project_routes_under_scope_spec.rb +++ b/spec/rubocop/cop/put_project_routes_under_scope_spec.rb @@ -14,7 +14,7 @@ describe RuboCop::Cop::PutProjectRoutesUnderScope do end it 'registers an offense when route is outside scope' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) scope '-' do resource :issues end @@ -25,7 +25,7 @@ describe RuboCop::Cop::PutProjectRoutesUnderScope do end it 'does not register an offense when resource inside the scope' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) scope '-' do resource :issues resource :notes @@ -34,7 +34,7 @@ describe RuboCop::Cop::PutProjectRoutesUnderScope do end it 'does not register an offense when resource is deep inside the scope' do - expect_no_offenses(<<~PATTERN.strip_indent) + expect_no_offenses(<<~PATTERN) scope '-' do resource :issues resource :projects do diff --git a/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb b/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb index 258144d4000..ee6b6d39cb4 100644 --- a/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb +++ b/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb @@ -15,7 +15,7 @@ describe RuboCop::Cop::RSpec::TopLevelDescribePath do context 'when the file ends in _spec.rb' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, 'spec/foo_spec.rb') + expect_no_offenses(<<~SOURCE, 'spec/foo_spec.rb') describe 'Foo' do end SOURCE @@ -24,7 +24,7 @@ describe RuboCop::Cop::RSpec::TopLevelDescribePath do context 'when the file is a frontend fixture' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, 'spec/frontend/fixtures/foo.rb') + expect_no_offenses(<<~SOURCE, 'spec/frontend/fixtures/foo.rb') describe 'Foo' do end SOURCE @@ -34,7 +34,7 @@ describe RuboCop::Cop::RSpec::TopLevelDescribePath do context 'when the describe is in a shared example' do context 'with shared_examples' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, 'spec/foo.rb') + expect_no_offenses(<<~SOURCE, 'spec/foo.rb') shared_examples 'Foo' do describe '#bar' do end @@ -45,7 +45,7 @@ describe RuboCop::Cop::RSpec::TopLevelDescribePath do context 'with shared_examples_for' do it 'registers no offenses' do - expect_no_offenses(<<~SOURCE.strip_indent, 'spec/foo.rb') + expect_no_offenses(<<~SOURCE, 'spec/foo.rb') shared_examples_for 'Foo' do describe '#bar' do end @@ -57,7 +57,7 @@ describe RuboCop::Cop::RSpec::TopLevelDescribePath do context 'when the describe is at the top level' do it 'marks the describe as offending' do - expect_offense(<<~SOURCE.strip_indent, 'spec/foo.rb') + expect_offense(<<~SOURCE, 'spec/foo.rb') describe 'Foo' do ^^^^^^^^^^^^^^ #{described_class::MESSAGE} end diff --git a/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb b/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb index 8107cfa8957..3c78a158836 100644 --- a/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb +++ b/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb @@ -12,7 +12,7 @@ describe RuboCop::Cop::Scalability::BulkPerformWithContext do subject(:cop) { described_class.new } it "adds an offense when calling bulk_perform_async" do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) Worker.bulk_perform_async(args) CODE @@ -20,7 +20,7 @@ describe RuboCop::Cop::Scalability::BulkPerformWithContext do end it "adds an offense when calling bulk_perform_in" do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) diffs.each_batch(of: BATCH_SIZE) do |relation, index| ids = relation.pluck_primary_key.map { |id| [id] } DeleteDiffFilesWorker.bulk_perform_in(index * 5.minutes, ids) @@ -33,7 +33,7 @@ describe RuboCop::Cop::Scalability::BulkPerformWithContext do it "does not add an offense for migrations" do allow(cop).to receive(:in_migration?).and_return(true) - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) Worker.bulk_perform_in(args) CODE @@ -43,7 +43,7 @@ describe RuboCop::Cop::Scalability::BulkPerformWithContext do it "does not add an offence for specs" do allow(cop).to receive(:in_spec?).and_return(true) - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) Worker.bulk_perform_in(args) CODE @@ -51,7 +51,7 @@ describe RuboCop::Cop::Scalability::BulkPerformWithContext do end it "does not add an offense for scheduling BackgroundMigrations" do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) BackgroundMigrationWorker.bulk_perform_in(args) CODE diff --git a/spec/rubocop/cop/scalability/cron_worker_context_spec.rb b/spec/rubocop/cop/scalability/cron_worker_context_spec.rb index 460514d9bed..aab32c7331f 100644 --- a/spec/rubocop/cop/scalability/cron_worker_context_spec.rb +++ b/spec/rubocop/cop/scalability/cron_worker_context_spec.rb @@ -12,7 +12,7 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do subject(:cop) { described_class.new } it 'adds an offense when including CronjobQueue' do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) class SomeWorker include CronjobQueue end @@ -22,14 +22,14 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do end it 'does not add offenses for other workers' do - expect_no_offenses(<<~CODE.strip_indent) + expect_no_offenses(<<~CODE) class SomeWorker end CODE end it 'does not add an offense when the class defines a context' do - expect_no_offenses(<<~CODE.strip_indent) + expect_no_offenses(<<~CODE) class SomeWorker include CronjobQueue @@ -39,7 +39,7 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do end it 'does not add an offense when the worker calls `with_context`' do - expect_no_offenses(<<~CODE.strip_indent) + expect_no_offenses(<<~CODE) class SomeWorker include CronjobQueue @@ -53,7 +53,7 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do end it 'does not add an offense when the worker calls `bulk_perform_async_with_contexts`' do - expect_no_offenses(<<~CODE.strip_indent) + expect_no_offenses(<<~CODE) class SomeWorker include CronjobQueue @@ -67,7 +67,7 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do end it 'does not add an offense when the worker calls `bulk_perform_in_with_contexts`' do - expect_no_offenses(<<~CODE.strip_indent) + expect_no_offenses(<<~CODE) class SomeWorker include CronjobQueue diff --git a/spec/rubocop/cop/scalability/file_uploads_spec.rb b/spec/rubocop/cop/scalability/file_uploads_spec.rb index a35d423581c..5bfc2d48fb8 100644 --- a/spec/rubocop/cop/scalability/file_uploads_spec.rb +++ b/spec/rubocop/cop/scalability/file_uploads_spec.rb @@ -15,7 +15,7 @@ describe RuboCop::Cop::Scalability::FileUploads do context 'with required params' do it 'detects File in types array' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) params do requires :certificate, allow_blank: false, types: [String, File] ^^^^ #{message} @@ -24,7 +24,7 @@ describe RuboCop::Cop::Scalability::FileUploads do end it 'detects File as type argument' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) params do requires :attachment, type: File ^^^^ #{message} @@ -35,7 +35,7 @@ describe RuboCop::Cop::Scalability::FileUploads do context 'with optional params' do it 'detects File in types array' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) params do optional :certificate, allow_blank: false, types: [String, File] ^^^^ #{message} @@ -44,7 +44,7 @@ describe RuboCop::Cop::Scalability::FileUploads do end it 'detects File as type argument' do - expect_offense(<<~PATTERN.strip_indent) + expect_offense(<<~PATTERN) params do optional :attachment, type: File ^^^^ #{message} diff --git a/spec/rubocop/cop/scalability/idempotent_worker_spec.rb b/spec/rubocop/cop/scalability/idempotent_worker_spec.rb index 7abd602f8bc..4551ec75e9f 100644 --- a/spec/rubocop/cop/scalability/idempotent_worker_spec.rb +++ b/spec/rubocop/cop/scalability/idempotent_worker_spec.rb @@ -18,7 +18,7 @@ describe RuboCop::Cop::Scalability::IdempotentWorker do end it 'adds an offense when not defining idempotent method' do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) class SomeWorker end CODE @@ -27,7 +27,7 @@ describe RuboCop::Cop::Scalability::IdempotentWorker do end it 'adds an offense when not defining idempotent method' do - inspect_source(<<~CODE.strip_indent) + inspect_source(<<~CODE) class SomeWorker idempotent! end |