我想利用rails 3.1rc4 中的force_ssl功能.
class ApplicationController < ActionController::Base
force_ssl
end
Run Code Online (Sandbox Code Playgroud)
问题是这打破了我现有的RSpec控制器规格的大部分/全部.例如,这失败了:
describe "GET 'index'" do
it "renders the Start page" do
get :index
response.should render_template 'index'
end
end
Run Code Online (Sandbox Code Playgroud)
而不是呈现页面的响应是301重定向到https://test.host/.
如何更改我的规范以模拟HTTPS GET/POST?
我是否必须手动更改每个测试或是否有更简单的方法?(我意识到我force_ssl只能在生产中调用,但这并不理想.真的,我应该测试force_ssl确实会在预期时重定向到https://.)