Skip to content
This repository
Browse code

Only add the whitelist_attributes option if ActiveRecord is present

Conflicts:

	railties/test/generators/app_generator_test.rb
	railties/test/isolation/abstract_unit.rb
  • Loading branch information...
commit f604a6368b3a39b0035d6fe964802a4c35eb958a 1 parent 06a3a8a
Rafael Mendonça França rafaelfranca authored
2  railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -58,7 +58,7 @@ class Application < Rails::Application
58 58 # This will create an empty whitelist of attributes available for mass-assignment for all models
59 59 # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
60 60 # parameters by using an attr_accessible or attr_protected declaration.
61   - config.active_record.whitelist_attributes = true
  61 + <%= comment_if :skip_active_record %>config.active_record.whitelist_attributes = true
62 62
63 63 <% unless options.skip_sprockets? -%>
64 64 # Enable the asset pipeline
6 railties/test/generators/app_generator_test.rb
@@ -210,6 +210,7 @@ def test_generator_if_skip_active_record_is_given
210 210 run_generator [destination_root, "--skip-active-record"]
211 211 assert_no_file "config/database.yml"
212 212 assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/
  213 + assert_file "config/application.rb", /#\s+config\.active_record\.whitelist_attributes = true/
213 214 assert_file "test/test_helper.rb" do |helper_content|
214 215 assert_no_match(/fixtures :all/, helper_content)
215 216 end
@@ -375,6 +376,11 @@ def test_generated_environments_file_for_auto_explain
375 376 end
376 377 end
377 378
  379 + def test_active_record_whitelist_attributes_is_present_application_config
  380 + run_generator
  381 + assert_file "config/application.rb", /config\.active_record\.whitelist_attributes = true/
  382 + end
  383 +
378 384 protected
379 385
380 386 def action(*args, &block)
2  railties/test/isolation/abstract_unit.rb
@@ -260,7 +260,7 @@ def use_frameworks(arr)
260 260 :activemodel,
261 261 :activerecord,
262 262 :activeresource] - arr
263   - remove_from_config "config.active_record.identity_map = true" if to_remove.include? :activerecord
  263 + remove_from_config "config.active_record.whitelist_attributes = true" if to_remove.include? :activerecord
264 264 $:.reject! {|path| path =~ %r'/(#{to_remove.join('|')})/' }
265 265 end
266 266

0 comments on commit f604a63

Please sign in to comment.
Something went wrong with that request. Please try again.