Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running annotate for when the columns are frozen #1030

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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