diff --git a/rubocop/cop/migration/update_column_in_batches.rb b/rubocop/cop/migration/update_column_in_batches.rb index 5461abc5ee00fdf20d82fa74f0b9795a256eed62..b1c43393f6a907e92b243d6aaedec3286f81bb57 100644 --- a/rubocop/cop/migration/update_column_in_batches.rb +++ b/rubocop/cop/migration/update_column_in_batches.rb @@ -28,7 +28,7 @@ def spec_filename(node) source_name = node.location.expression.source_buffer.name path = Pathname.new(source_name).relative_path_from(rails_root) dirname = File.dirname(path) - .sub(%r{\Adb/(migrate|post_migrate)}, 'spec/migrations') + .sub(%r{db/(migrate|post_migrate)}, 'spec/migrations') filename = File.basename(source_name, '.rb').sub(/\A\d+_/, '') File.join(dirname, "#{filename}_spec.rb") diff --git a/spec/rubocop/cop/migration/update_column_in_batches_spec.rb b/spec/rubocop/cop/migration/update_column_in_batches_spec.rb index 1c8ab0ad5d2fcadd16eed40079444b25f8a765d9..cba01400d85ebb4c6006cc2aa50ec3436cb77999 100644 --- a/spec/rubocop/cop/migration/update_column_in_batches_spec.rb +++ b/spec/rubocop/cop/migration/update_column_in_batches_spec.rb @@ -93,4 +93,22 @@ def up it_behaves_like 'a migration file with no spec file' it_behaves_like 'a migration file with a spec file' end + + context 'EE migrations' do + let(:spec_filepath) { tmp_rails_root.join('ee', 'spec', 'migrations', 'my_super_migration_spec.rb') } + + context 'in a migration' do + let(:migration_filepath) { tmp_rails_root.join('ee', 'db', 'migrate', '20121220064453_my_super_migration.rb') } + + it_behaves_like 'a migration file with no spec file' + it_behaves_like 'a migration file with a spec file' + end + + context 'in a post migration' do + let(:migration_filepath) { tmp_rails_root.join('ee', 'db', 'post_migrate', '20121220064453_my_super_migration.rb') } + + it_behaves_like 'a migration file with no spec file' + it_behaves_like 'a migration file with a spec file' + end + end end