| ... | @@ -17,7 +17,7 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do |
... | @@ -17,7 +17,7 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do |
|
|
allow(cop).to receive(:in_migration?).and_return(true)
|
|
allow(cop).to receive(:in_migration?).and_return(true)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
described_class::SMALL_TABLES.each do |table|
|
|
described_class::WHITELISTED_TABLES.each do |table|
|
|
|
context "for the #{table} table" do
|
|
context "for the #{table} table" do
|
|
|
sources_and_offense = [
|
|
sources_and_offense = [
|
|
|
["add_column :#{table}, :column, :boolean, default: true", 'should disallow nulls'],
|
|
["add_column :#{table}, :column, :boolean, default: true", 'should disallow nulls'],
|
| ... | @@ -62,14 +62,14 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do |
... | @@ -62,14 +62,14 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do |
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'registers no offense for tables not listed in SMALL_TABLES' do
|
|
it 'registers no offense for tables not listed in WHITELISTED_TABLES' do
|
|
|
inspect_source("add_column :large_table, :column, :boolean")
|
|
inspect_source("add_column :large_table, :column, :boolean")
|
|
|
|
|
|
|
|
expect(cop.offenses).to be_empty
|
|
expect(cop.offenses).to be_empty
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'registers no offense for non-boolean columns' do
|
|
it 'registers no offense for non-boolean columns' do
|
|
|
table = described_class::SMALL_TABLES.sample
|
|
table = described_class::WHITELISTED_TABLES.sample
|
|
|
inspect_source("add_column :#{table}, :column, :string")
|
|
inspect_source("add_column :#{table}, :column, :string")
|
|
|
|
|
|
|
|
expect(cop.offenses).to be_empty
|
|
expect(cop.offenses).to be_empty
|
| ... | @@ -78,7 +78,7 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do |
... | @@ -78,7 +78,7 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do |
|
|
|
|
|
|
|
context 'outside of migration' do
|
|
context 'outside of migration' do
|
|
|
it 'registers no offense' do
|
|
it 'registers no offense' do
|
|
|
table = described_class::SMALL_TABLES.sample
|
|
table = described_class::WHITELISTED_TABLES.sample
|
|
|
inspect_source("add_column :#{table}, :column, :boolean")
|
|
inspect_source("add_column :#{table}, :column, :boolean")
|
|
|
|
|
|
|
|
expect(cop.offenses).to be_empty
|
|
expect(cop.offenses).to be_empty
|
| ... | |
... | |
| ... | | ... | |