このリクエスト仕様が正常に機能するのはなぜですか。
require "spec_helper"
describe "POST on a GET route" do
it "should not allow this" do
post "/applicants/new"
assert_response :missing
end
end
ただし、このコントローラーの仕様では、GET、POST、PUT、およびDELETEはすべて、次の場合と同じように機能します。
require 'spec_helper'
describe ApplicantsController do
it "should not allow this" do
post :new
should respond_with :missing # but it responds with 200
end
end
更新:ApplicantsControllerコードとルート定義を追加しました:
class ApplicantsController < InheritedResources::Base
respond_to :html
actions :index, :new, :create
def new
if current_user
redirect_to resume_application_path and return
end
@applicant = Applicant.new
@applicant.applications.build
@applicant.build_user_detail
new!
end
end
ルート:
resources :applicants
更新:APIを詳しく調べて調べた結果、コントローラーの仕様はActionController :: TestCaseから継承され、リクエストの仕様はActionDispatch :: IntegrationTestから継承されるため、これは仕様によるものだと思います。コントローラ仕様の場合、HTTP動詞は単に説明的なものになります。
誰かがこれが仕様によるものであることを確認できますか?または、バグレポートを提出する必要がありますか?
ありがとうございました!