0

このようなコントローラーがあります

class RegistrationsController < Devise::RegistrationsController
  before_filter :authenticate_user!, :only => [ :finalize ]
  prepend_before_filter :require_no_authentication, :only => [ :complete ]

  def complete
    #blah
  end

  def finalize
    #blah
  end
end

ルートでは次のようになります。

Blah::Application.routes.draw do
  root to: "requests#index"

  devise_for :users, :path => '', :path_names  => { :sign_in => 'login', :sign_out => 'logout' }, :controllers => { :passwords => "passwords", confirmations: 'confirmations' }

  #blahblah

  devise_scope :user do
    get '/register/:id/:token' => 'registrations#new', as: 'register'
    put '/register/:id/:token' => 'registrations#complete', as: 'complete_user'
    match "/finalize" => 'registrations#finalize', :as => :finalize
  end

end

complete今、テストからこのアクションにアクセスしたいと思います:

let(:params) {
  {
    id: 1, 
    invitation_token: "INVITATION_TOKEN", 
    email: 'email@reporter.com', 
    name: 'Name', 
    surname: 'Surname', 
    title: 'Title', 
    password: 'asdasdasd'
  }
}

it 'should be redirected to the page with information about sending confirmation email' do
  put :complete, params

  response.should redirect_to(verification_path)
end

そして、それは失敗します:

  1) RegistrationsController#complete when invited email isn't on a whitelist should be redirected to the page with information about sending confirmation email
     Failure/Error: put :complete, params
     ActionController::RoutingError:
       No route matches {:id=>"1", :invitation_token=>"INVITATION_TOKEN", :email=>"email@reporter.com", :name=>"Name", :surname=>"Surname", :title=>"Title", :password=>"asdasdasd", :controller=>"registrations", :action=>"complete"}
     # ./spec/controllers/registrations_controller_spec.rb:29:in `block (4 levels) in <top (required)>'

completeRSpec テストからこのアクションにアクセスするにはどうすればよいですか?

4

1 に答える 1