Skip to content

Commit

Permalink
Merge 4aeee76 into 7f42543
Browse files Browse the repository at this point in the history
  • Loading branch information
lazebny committed Feb 11, 2017
2 parents 7f42543 + 4aeee76 commit f7f49ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rails_admin/config/actions/new.rb
Expand Up @@ -20,7 +20,7 @@ class New < RailsAdmin::Config::Actions::Base
@authorization_adapter && @authorization_adapter.attributes_for(:new, @abstract_model).each do |name, value|
@object.send("#{name}=", value)
end
if object_params = params[@abstract_model.to_param]
if object_params = params[@abstract_model.param_key]
sanitize_params_for!(request.xhr? ? :modal : :create)
@object.set_attributes(@object.attributes.merge(object_params.to_h))
end
Expand Down
Expand Up @@ -16,15 +16,23 @@
end

describe 'GET /admin/cms_basic_page/new' do
before do
it 'has correct input field names' do
visit new_path(model_name: 'cms~basic_page')
end

it 'has correct input field names' do
is_expected.to have_selector('label[for=cms_basic_page_title]')
is_expected.to have_selector("input#cms_basic_page_title[name='cms_basic_page[title]']")
is_expected.to have_selector('label[for=cms_basic_page_content]')
is_expected.to have_selector("textarea#cms_basic_page_content[name='cms_basic_page[content]']")
end

it 'has default values' do
content = '4123lkj1sdlfjasdfjsdkfjsdfk'

visit new_path(model_name: 'cms~basic_page', cms_basic_page: {content: content})

within('#cms_basic_page_content_field') do
is_expected.to have_content(content)
end
end
end
end

0 comments on commit f7f49ef

Please sign in to comment.