admin 管理员组文章数量: 1086019
I want to test if I'm getting status of 301 when user hits old slug and status of 200 when it's new friendlyID slug.
class SubsectionsController < ApplicationController
def show
section = subsection.section
step = enter code heresubsection.steps.order(:position).first
expected_path = course_section_subsection_step_path(course, section, subsection, step)
return redirect_to expected_path, status: :moved_permanently if request.path != expected_path
redirect_to expected_path
end
def course
Course.friendly.find(params[:course_id])
end
def subsection
Subsection.friendly.find(params[:id])
end
end
本文标签: ruby on railsHow to use RSpec with FriendlyID Gem to test for redirectStack Overflow
版权声明:本文标题:ruby on rails - How to use RSpec with FriendlyID Gem to test for redirect - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744040303a2523129.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论