【发布时间】:2012-01-24 15:25:13
【问题描述】:
rails 3.1 中的 force_ssl 函数被硬编码以忽略开发环境,但不测试。这在我的(最小测试)测试中给了我重定向错误。设置我的测试服务器以支持 ssl 的解决方案是什么(如果是,如何?)。如果没有,我应该修补 force_ssl 以忽略测试中的请求吗?
def force_ssl(options = {})
host = options.delete(:host)
before_filter(options) do
if !request.ssl? && !Rails.env.development?
redirect_options = {:protocol => 'https://', :status => :moved_permanently}
redirect_options.merge!(:host => host) if host
flash.keep
redirect_to redirect_options
end
end
end
编辑找到了这条链,这证实了其他人认为这是一个问题,但看起来还没有提交的修复:https://github.com/rails/rails/pull/2630
【问题讨论】:
标签: ruby-on-rails testing ruby-on-rails-3.1