explicit-parameters icon indicating copy to clipboard operation
explicit-parameters copied to clipboard

`parameters[action_name]` not available while running the specs

Open jeromegn opened this issue 9 years ago • 2 comments

Not sure where the issue is coming from (maybe rspec-rails) but this line https://github.com/byroot/explicit-parameters/blob/master/lib/explicit_parameters/controller.rb#L31 is causing issues when running rspec on a Rails app.

This was my fix: https://github.com/jeromegn/explicit-parameters/blob/master/lib/explicit_parameters/controller.rb#L31

However, I'm pretty sure there's a better way to do it.

jeromegn avatar May 11 '15 13:05 jeromegn

I failed to reproduce the issue from a new app. Could you give me more informations please?

  • Rails version
  • rspec-rails version
  • rspec version
  • the order of those gems and explicit parameters in your gemfile.

Thanks!

byroot avatar May 11 '15 13:05 byroot

Sure,

rails 4.2.0 rspec-rails 3.2.1 (rspec-core 3.2.0)

Order:

  • rails
  • explicit-parameters
  • rspec-rails

I'm also using a small spec helper to apply default params to all my requests, that could be at fault...

require 'active_support/concern'
require 'active_support/core_ext/module/aliasing'

module DefaultParams
  extend ActiveSupport::Concern

  def process_with_default_params(action, method, parameters={}, session={}, flash=nil)
    process_without_default_params(action, method, default_params.merge(parameters || {}), session, flash)
  end

  included do
    let(:default_params) { {} }
    alias_method_chain :process, :default_params
  end
end

RSpec.configure do |config|
  config.include(DefaultParams, :type => :controller)
end

jeromegn avatar May 11 '15 13:05 jeromegn