如何编写显示强制重定向到https的rails规范



我想展示一种行为,基本上表明路径"/"在http域上工作,转到路径"/users/sign_in"会强制重定向到https。你怎么能说出这个?这属于控制器、请求或路由规范吗?

规格看起来像:

describe "https redirection" do
  context "when http" do
    it "forces a permanent redirect to /users/sign_in on https when path is /users/sign_in" do
    end
    it "returns status of 200 when path is /"
    end
  end
  context "when https" do
    it "returns status of 200 when path is /users/sign_in"
    end
  end
end

使用request.env['HTTPS'] = 'on'激活https。

在集成测试中,您可以检查http是否与current_url.should match /^https:/ 处于活动状态

相关内容

  • 没有找到相关文章

最新更新