diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 05f73e5a5e..8bc34c8083 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,9 +1,13 @@ class PostsController < ApplicationController def index + return not_found if params[:section] == "transcripts" + @subcategories = MarkdownDocument.all_subcategories(params[:section]) end def subcategory + return not_found if params[:section] == "transcripts" + @posts = MarkdownDocument.all(params[:section], params[:subcategory]) render :subcategory end diff --git a/app/views/posts/show.html.slim b/app/views/posts/show.html.slim index fff447ccd7..64a6ad3370 100644 --- a/app/views/posts/show.html.slim +++ b/app/views/posts/show.html.slim @@ -2,12 +2,13 @@ - content_for :page_title_prefix, @post.title - content_for :page_description, @post.meta_description -- content_for :breadcrumbs do - nav aria-label="breadcrumb" role="navigation" - = govuk_breadcrumbs breadcrumbs: { t("breadcrumbs.home") => root_path, - params[:section].titleize.capitalize => posts_path(section: params[:section]), - formatted_subcategory => subcategory_path(section: params[:section], subcategory: params[:subcategory]), - @post.title => "" } +- unless params[:section] == "transcripts" + - content_for :breadcrumbs do + nav aria-label="breadcrumb" role="navigation" + = govuk_breadcrumbs breadcrumbs: { t("breadcrumbs.home") => root_path, + params[:section].titleize.capitalize => posts_path(section: params[:section]), + formatted_subcategory => subcategory_path(section: params[:section], subcategory: params[:subcategory]), + @post.title => "" } .govuk-grid-row.post .govuk-grid-column-two-thirds diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 0af5cbd12a..7bcd737ab3 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -27,6 +27,14 @@ expect(response).to render_template("index") end + + context "when section is 'transcripts'" do + it "responds with a 404 not found" do + get :index, params: { section: "transcripts" } + + expect(response).to have_http_status(:not_found) + end + end end describe "#subcategory" do @@ -99,6 +107,14 @@ expect(assigns(:posts).map(&:post_name).sort).to eq(post_names.sort) end end + + context "when section is 'transcripts'" do + it "responds with a 404 not found" do + get :subcategory, params: { section: "transcripts", subcategory: "jobseekers" } + + expect(response).to have_http_status(:not_found) + end + end end it "renders the subcategory template" do