这是我在 ParticipationConsent 控制器中的创建操作。
参与同意#create
def create
@participation_consent = @project.participation_consent.new(params[:participation_consent])
@participation_consent.user = current_user
@participation_consent.confirmed = true
@participation_consent.save!
end
这是我对创建方法的测试
context 'get :create' do
it 'should be success for approved creative' do
sign_in @approved_creative
expect{
get :create, :project => @project.id, :participation_consent => { :project_id => @project.id, :user_id => @approved_creative.id, :confirmed_in => false }
}.to change(ParticipationConsent, :count).by(1)
response.should redirect_to project_path(@project)
end
当我运行测试文件时,我遇到了这个错误。
Failure/Error: get :create, :project => @project.id, :participation_consent => { :project_id => @project.id, :user_id => @approved_creative.id, :confirmed_in => false }
ActionController::RoutingError:
No route matches {:project=>1, :participation_consent => {:project_id=>1, :user_id=>2, :confirmed_in=>false}, :controller=>"participation_consents", :action=>"create"}
你知道我该怎么处理吗?
编辑-1:
路线.rb
project_participation_consents POST /projects/:project_id/participation_consents(.:format) {:action=>"create", :controller=>"participation_consents"}