Skip to content

Commit

Permalink
Add not nullable foreign key in dummy application
Browse files Browse the repository at this point in the history
  • Loading branch information
jibidus committed Oct 27, 2015
1 parent 60c277b commit 317ad17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeFieldTestIdToNestedFieldTests < ActiveRecord::Migration
def change
change_column :nested_field_tests, :field_test_id, :integer, null: false
end
end
7 changes: 4 additions & 3 deletions spec/integration/config/edit/rails_admin_config_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,8 @@ class HelpTest < Tableless
describe 'nested form' do
it 'works', js: true do
@record = FactoryGirl.create :field_test
@record.nested_field_tests = [NestedFieldTest.create!(title: 'title 1'), NestedFieldTest.create!(title: 'title 2')]
NestedFieldTest.create! title: 'title 1', field_test: @record
NestedFieldTest.create! title: 'title 2', field_test: @record
visit edit_path(model_name: 'field_test', id: @record.id)

find('#field_test_comment_attributes_field .add_nested_fields').click
Expand Down Expand Up @@ -743,7 +744,7 @@ class HelpTest < Tableless
end
end
@record = FieldTest.create
@record.nested_field_tests << NestedFieldTest.create!(title: 'title 1')
NestedFieldTest.create! title: 'title 1', field_test: @record
visit edit_path(model_name: 'field_test', id: @record.id)
expect(find('#field_test_nested_field_tests_attributes_0_title_field')).to have_content('NestedFieldTest')
end
Expand Down Expand Up @@ -776,7 +777,7 @@ class HelpTest < Tableless

it 'does not show destroy button except for newly created when :allow_destroy is false' do
@record = FieldTest.create
@record.nested_field_tests << NestedFieldTest.create!(title: 'nested title 1')
NestedFieldTest.create! title: 'nested title 1', field_test: @record
allow(FieldTest.nested_attributes_options).to receive(:[]).with(:nested_field_tests).
and_return(allow_destroy: false, update_only: false)
visit edit_path(model_name: 'field_test', id: @record.id)
Expand Down

0 comments on commit 317ad17

Please sign in to comment.