最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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
发布评论

评论列表(0)

  1. 暂无评论