1)错误: SummariesControllerTest#test_should_get_edit: ActionController :: UrlGenerationError:没有路由匹配{:action =>"编辑",:controller =>"摘要",:summary =>" 298486374" ,:summary_id =>" 298486374"} test / controllers / summaries_controller_test.rb:23:在`block in'
这是导致错误的测试
test "should update summary" do
xhr :patch, :udpate, id: @summary.id, summary: { text: @summary.text }
assert_response :success
end
控制器动作:
def update
@listing = Listing.find(summary_params[:listing_id])
@summary = Summary.find(params[:id])
@summary.update_attributes(listing_id: summary_params[:listing_id], text: summary_params[:text], id: params[:id])
end
和路线:
Rails.application.routes.draw do
resources :listings
resources :summaries
resources :highlights
end
路线在那里,动作也出现了错误,是否有人看到我的错误?谢谢你的帮助。
答案 0 :(得分:0)
你有一个拼写错误(在单词" update"):
xhr :patch, :udpate, id: @summary.id, summary: { text: @summary.text }
应该是:
xhr :patch, :update, id: @summary.id, summary: { text: @summary.text }
答案 1 :(得分:0)
test "should update summary" do
xhr :patch, :udpate, id: @summary.id, summary: { text: @summary.text }
assert_response :success
end
嘿谢谢你的回复,路线没有问题,但我确实要传递id:@ summary.id,因为它需要列表。我改变了测试并且通过了。