Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions spec/lib/tasks/annotate_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,29 @@
it { is_expected.to be_truthy }
end
end

context 'when column_type is frozen' do
let(:klass) do
Class.new(ActiveRecord::Base) do
self.table_name = 'users'
end
end

before do
allow(klass).to receive(:columns).and_return([
instance_double('Column', name: 'id', type: 'integer'.freeze, sql_type: 'integer', limit: nil, null: false, default: nil, comment: nil)
])
allow(klass).to receive(:table_exists?).and_return(true)
allow(klass).to receive(:primary_key).and_return('id')
end

it 'does not raise an error when modifying column_type' do
expect { AnnotateModels.get_schema_info(klass, 'Schema Info', {}) }.not_to raise_error
end

it 'includes the column information in the schema info' do
schema_info = AnnotateModels.get_schema_info(klass, 'Schema Info', {})
expect(schema_info).to include('id :integer')
end
end
end
Loading