1

Trying to upgrade from Rails 4.1 to rails 4.2 and in the process devise from 3.0 to 3.4 (due to dependencies of 3.0)

I have a very basic controller:

class BasicController < ActionController::Base
  #purposely not inherited from Application Controller to try and isolate the issue

  before_filter :authenticate_user!

  def index
  end

end

routes.rb contains:

get 'basic/index'

And my spec for this controller is:

#purposely not included spec_helper as I don't want to complicate things.
1.describe BasicController do
2.  it "should be able to get index" do
3.    @request.env['devise.mapping'] = Devise.mappings[:user]
4.    @current_user = FactoryGirl.create(:user)
5.    sign_in :user, @current_user #Also tried sign_in @current_user
6.    get :index
7.    response.should be_success
8.  end 
9.end

This spec errors with ArgumentError: wrong number of arguments (2 for 1) #./spec/controllers/basic_controller_spec.rb:6

Using devise 3.4.1 and rails 4.2.0

If I replace factory girl with simple User.create(....) the error still occurs.

Any ideas why this could be happening?

Yule
  • 9,668
  • 3
  • 51
  • 72

3 Answers3

0

instead of signin :user, @current_user Use

sign_in @current_user
Ajay
  • 4,199
  • 4
  • 27
  • 47
  • I've tried this. Same error. It's not failing at this line, it's failing at the line after. – Yule Jan 13 '15 at 16:45
0

Are you by chance using Squeel? If so there was an issue in 1.2.2 where Rails 4.2 causes this error. Updating to 1.2.3 fixed this error for me.

Specifically the error was coming out of create_binds and they have fixed the implementation, see https://github.com/activerecord-hackery/squeel/issues/352

James Polanco
  • 591
  • 1
  • 7
  • 5
0

Maybe the turbolinks gem is an answer?

Try upgrading or disabling it. For me this was the cause of error. See: Why is there a wrong number of arguments error when using redirect_to in Rails 4.2?

Community
  • 1
  • 1
jmarceli
  • 19,102
  • 6
  • 69
  • 67