rubocop_canvas: fix add_reference non-transactional logic
we don't need to suggest `disable_ddl_transaction!` when adding a non-indexed reference fixes FOO-3298 test plan: specs Change-Id: I33ca47954e5760bf3f14d8b240891713f735eeda Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/308301 Reviewed-by: Jacob Burroughs <jburroughs@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
1e0ee0640e
commit
2502fd32ce
|
@ -104,11 +104,12 @@ module RuboCop
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_add_reference(node)
|
def check_add_reference(node)
|
||||||
check_non_transactional
|
|
||||||
|
|
||||||
arg = index_argument(node).first
|
arg = index_argument(node).first
|
||||||
if arg.nil? || (!false?(arg) && !algorithm_concurrently?(arg))
|
if arg.nil? || !false?(arg)
|
||||||
add_offense arg || node, message: INDEX_ALGORITHM_CONCURRENTLY_MSG, severity: :warning
|
check_non_transactional
|
||||||
|
if arg.nil? || !algorithm_concurrently?(arg)
|
||||||
|
add_offense arg || node, message: INDEX_ALGORITHM_CONCURRENTLY_MSG, severity: :warning
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,6 @@ describe RuboCop::Cop::Migration::AddIndex do
|
||||||
it "doesn't complain if not indexed" do
|
it "doesn't complain if not indexed" do
|
||||||
inspect_source(<<~RUBY)
|
inspect_source(<<~RUBY)
|
||||||
class TestMigration < ActiveRecord::Migration
|
class TestMigration < ActiveRecord::Migration
|
||||||
disable_ddl_transaction!
|
|
||||||
def up
|
def up
|
||||||
add_reference :users, :organizations, index: false
|
add_reference :users, :organizations, index: false
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue