Skip to content

Commit

Permalink
Merge pull request #3402 from codealchemy/patch/field-names/open-fix
Browse files Browse the repository at this point in the history
Ensure `open` can be used as a field name
  • Loading branch information
mshibuya committed Oct 13, 2021
2 parents 5b9ecb6 + 6f88114 commit 177f32a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/dummy_app/app/mongoid/field_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class FieldTest
field :time_field, type: Time

field :format, type: String
field :open, type: Boolean
field :restricted_field, type: String
field :protected_field, type: String
has_mongoid_attached_file :paperclip_asset, styles: {thumb: '100x100>'}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddBoolFieldOpen < ActiveRecord::Migration[6.0]
def change
add_column :field_tests, :open, :boolean
end
end
16 changes: 16 additions & 0 deletions spec/integration/actions/edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -828,4 +828,20 @@ class HelpTest < Tableless
expect(@record.format).to eq('test for format')
end
end

context "with a field with 'open' as a name" do
it 'is updatable without any error' do
RailsAdmin.config FieldTest do
edit do
field :open
end
end
record = FieldTest.create
visit edit_path(model_name: 'field_test', id: record.id)
expect do
check 'field_test[open]'
click_button 'Save'
end.to change { record.reload.open }.from(nil).to(true)
end
end
end

0 comments on commit 177f32a

Please sign in to comment.