Skip to content

Commit 7ae7541

Browse files
add tests proving that frozen columns work and undo checking for frozen records
1 parent 95327bd commit 7ae7541

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

lib/annotate/annotate_models.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,8 +940,6 @@ def get_attributes(column, column_type, klass, options)
940940
attrs << 'not null' unless column.null
941941
attrs << 'primary key' if klass.primary_key && (klass.primary_key.is_a?(Array) ? klass.primary_key.collect(&:to_sym).include?(column.name.to_sym) : column.name.to_sym == klass.primary_key.to_sym)
942942

943-
column_type = column_type.dup if column_type.frozen?
944-
945943
if column_type == 'decimal'
946944
column_type << "(#{column.precision}, #{column.scale})"
947945
elsif !%w[spatial geometry geography].include?(column_type)

spec/lib/tasks/annotate_models_spec.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,18 @@
4343

4444
before do
4545
allow(klass).to receive(:columns).and_return([
46-
double('Column', name: 'id', type: 'integer'.freeze, sql_type: 'integer', limit: nil, null: false, default: nil, comment: nil)
46+
instance_double('Column', name: 'id', type: 'integer'.freeze, sql_type: 'integer', limit: nil, null: false, default: nil, comment: nil)
4747
])
4848
allow(klass).to receive(:table_exists?).and_return(true)
4949
allow(klass).to receive(:primary_key).and_return('id')
5050
end
5151

5252
it 'does not raise an error when modifying column_type' do
53-
expect {
54-
AnnotateModels.get_schema_info(klass, "Schema Info", {})
55-
}.not_to raise_error
53+
expect { AnnotateModels.get_schema_info(klass, 'Schema Info', {}) }.not_to raise_error
5654
end
5755

5856
it 'includes the column information in the schema info' do
59-
schema_info = AnnotateModels.get_schema_info(klass, "Schema Info", {})
57+
schema_info = AnnotateModels.get_schema_info(klass, 'Schema Info', {})
6058
expect(schema_info).to include('id :integer')
6159
end
6260
end

0 commit comments

Comments
 (0)