mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Only add the whitelist_attributes option if ActiveRecord is present
Conflicts: railties/test/generators/app_generator_test.rb railties/test/isolation/abstract_unit.rb
This commit is contained in:
@@ -58,7 +58,7 @@ module <%= app_const_base %>
|
||||
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
||||
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
||||
# parameters by using an attr_accessible or attr_protected declaration.
|
||||
config.active_record.whitelist_attributes = true
|
||||
<%= comment_if :skip_active_record %>config.active_record.whitelist_attributes = true
|
||||
|
||||
<% unless options.skip_sprockets? -%>
|
||||
# Enable the asset pipeline
|
||||
|
||||
@@ -210,6 +210,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
||||
run_generator [destination_root, "--skip-active-record"]
|
||||
assert_no_file "config/database.yml"
|
||||
assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/
|
||||
assert_file "config/application.rb", /#\s+config\.active_record\.whitelist_attributes = true/
|
||||
assert_file "test/test_helper.rb" do |helper_content|
|
||||
assert_no_match(/fixtures :all/, helper_content)
|
||||
end
|
||||
@@ -375,6 +376,11 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_active_record_whitelist_attributes_is_present_application_config
|
||||
run_generator
|
||||
assert_file "config/application.rb", /config\.active_record\.whitelist_attributes = true/
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def action(*args, &block)
|
||||
|
||||
@@ -260,7 +260,7 @@ module TestHelpers
|
||||
:activemodel,
|
||||
:activerecord,
|
||||
:activeresource] - arr
|
||||
remove_from_config "config.active_record.identity_map = true" if to_remove.include? :activerecord
|
||||
remove_from_config "config.active_record.whitelist_attributes = true" if to_remove.include? :activerecord
|
||||
$:.reject! {|path| path =~ %r'/(#{to_remove.join('|')})/' }
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user