Skip to content

Commit 177f32a

Browse files
authored
Merge pull request #3402 from codealchemy/patch/field-names/open-fix
Ensure `open` can be used as a field name
2 parents 5b9ecb6 + 6f88114 commit 177f32a

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

spec/dummy_app/app/mongoid/field_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class FieldTest
3131
field :time_field, type: Time
3232

3333
field :format, type: String
34+
field :open, type: Boolean
3435
field :restricted_field, type: String
3536
field :protected_field, type: String
3637
has_mongoid_attached_file :paperclip_asset, styles: {thumb: '100x100>'}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddBoolFieldOpen < ActiveRecord::Migration[6.0]
2+
def change
3+
add_column :field_tests, :open, :boolean
4+
end
5+
end

spec/integration/actions/edit_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,4 +828,20 @@ class HelpTest < Tableless
828828
expect(@record.format).to eq('test for format')
829829
end
830830
end
831+
832+
context "with a field with 'open' as a name" do
833+
it 'is updatable without any error' do
834+
RailsAdmin.config FieldTest do
835+
edit do
836+
field :open
837+
end
838+
end
839+
record = FieldTest.create
840+
visit edit_path(model_name: 'field_test', id: record.id)
841+
expect do
842+
check 'field_test[open]'
843+
click_button 'Save'
844+
end.to change { record.reload.open }.from(nil).to(true)
845+
end
846+
end
831847
end

0 commit comments

Comments
 (0)