Skip to content

Commit

Permalink
Merge pull request #7310 from DFE-Digital/transcripts-bug
Browse files Browse the repository at this point in the history
Fix transcript bug on guidance pages
  • Loading branch information
KyleMacPherson authored Nov 26, 2024
2 parents e721ff4 + a7f070c commit 84f672f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 7 additions & 6 deletions app/views/posts/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions spec/controllers/posts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 84f672f

Please sign in to comment.