Just wanted to follow-up on this thread, even though it was answered in
another.
A feature addition to disable SP, somewhat similar to how whitelisting was
enabled/disabled in Rails 3 was turned down (who knows- maybe that will be
reconsidered at some point, but dhh said no). But for SP, in your tests
that use Rails 3.2, you may just be able to have models that and some that
don''t include ActiveModel::ForbiddenAttributesProtection:
include ::ActiveModel::ForbiddenAttributesProtection
or something that was suggested was to use the appraisal gem:
https://github.com/thoughtbot/appraisal
And some projects like ActiveAdmin also have their own method to test with
different gemsets by including logic in the Gemfile, e.g. in v0.5.0''s
Gemfile (in https://github.com/gregbell/active_admin/tree/v0.5.0):
ACTIVE_ADMIN_PATH = File.dirname(__FILE__) unless defined?(ACTIVE_ADMIN_PATH)
require File.expand_path(''spec/support/detect_rails_version'',
ACTIVE_ADMIN_PATH)
rails_version = detect_rails_version
gem ''rails'', rails_version
#...
case rails_version
when /^3\.0/
# Do nothing, bundler should figure it out
when /^3\.(1|2)/
# These are the gems you have to have for Rails 3.1 to be happy
gem ''sass-rails''
gem ''uglifier''
else
raise "Rails #{rails_version} is not supported yet"
end
On Monday, October 22, 2012 4:38:53 PM UTC-4, Gary Weaver
wrote:>
> Recently integrated a patch for strong_parameters into a fork of
> active_admin and wanted to add tests for it, but I''m not sure what
the best
> way of adding tests is for something that can optionally support
> strong_parameters.
>
> For those that are trying to write tests that support controller
> functionality with and without strong_parameters in their gem, how do you
> do that? (I guess this question will apply to those wanting to support both
> rails 3 and 4 in a gem and be able to test controller additions without
> having to have a separate fork for rails 4).
>
> Is there a switch for enabling and disabling strong_parameters such that
> it could be disabled and then just enable it for a single test?
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-core/-/_ST4z5jNHlYJ.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.