ruby on rails - How to use RSpec with FriendlyID Gem to test for redirect - Stack Overflow

I want to test if I'm getting status of 301 when user hits old slug and status of 200 when it'

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744040301a4548186.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信