1

尝试从 Rails 4.1 升级到 rails 4.2 并在此过程中从 3.0 设计到 3.4(由于 3.0 的依赖关系)

我有一个非常基本的控制器:

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 包含:

get 'basic/index'

我对这个控制器的规格是:

#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

此规范错误ArgumentError: wrong number of arguments (2 for 1) #./spec/controllers/basic_controller_spec.rb:6

使用 devise 3.4.1 和 rails 4.2.0

如果我用简单的 User.create(....) 替换工厂女孩,错误仍然会发生。

任何想法为什么会发生这种情况?

4

3 回答 3

0

而不是signin :user, @current_user 使用

sign_in @current_user
于 2015-01-13T16:42:49.327 回答
0

您是偶然使用 Squeel 的吗?如果是这样1.2.2,Rails 4.2 会导致此错误。更新1.2.3为我修复了这个错误。

具体来说,错误出现了,create_binds他们已经修复了实现,请参阅https://github.com/activerecord-hackery/squeel/issues/352

于 2015-02-23T21:59:02.910 回答
0

也许 turbolinks gem 是一个答案?

尝试升级或禁用它。对我来说,这是错误的原因。请参阅:为什么在 Rails 4.2 中使用 redirect_to 时出现错误数量的参数错误?

于 2015-03-18T13:36:32.790 回答