Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/forms/welsh_translation_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def render_preview
private

def preview_html
return t("guidance.no_guidance_added_html") if params[:markdown].blank?
return t("markdown_editor.no_markdown_content_html") if params[:markdown].blank?

GovukFormsMarkdown.render(params[:markdown], locale: "cy")
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/forms/what_happens_next_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def what_happens_next_input_params
end

def preview_html(what_happens_next_input)
return t("guidance.no_guidance_added_html") if what_happens_next_input.what_happens_next_markdown.blank?
return t("markdown_editor.no_markdown_content_html") if what_happens_next_input.what_happens_next_markdown.blank?

GovukFormsMarkdown.render(what_happens_next_input.what_happens_next_markdown, allow_headings: false, locale: "en")
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/pages/guidance_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def route_to
end

def preview_html(guidance_input)
return t("guidance.no_guidance_added_html") if guidance_input.guidance_markdown.blank?
return t("markdown_editor.no_markdown_content_html") if guidance_input.guidance_markdown.blank?

GovukFormsMarkdown.render(guidance_input.guidance_markdown, locale: "en")
end
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,6 @@ en:
preview_tab_text: Preview guidance
update_preview: Update preview
write_tab_text: Write guidance
no_guidance_added_html: "<p>No guidance added</p>"
when_to_use_guidance_html: |
<p>
Use guidance if you need to:
Expand Down Expand Up @@ -1242,6 +1241,7 @@ en:
example: "### This is a third-level heading"
heading: Third-level headings
instructions: 'To add a third-level heading (H3), use 3 hashtags followed by a space. For example:'
no_markdown_content_html: "<p>No content added</p>"
preview:
description: Below is a preview of how your markdown content will be shown to the person completing your form.
heading: Preview your markdown below
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/forms/welsh_translation_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@

it "returns a JSON object containing the converted HTML" do
expect(response).to have_http_status(:ok)
expect(response.body).to eq({ preview_html: I18n.t("guidance.no_guidance_added_html"), errors: [] }.to_json)
expect(response.body).to eq({ preview_html: I18n.t("markdown_editor.no_markdown_content_html"), errors: [] }.to_json)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/forms/what_happens_next_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@

it "returns a JSON object containing the converted HTML" do
expect(response).to have_http_status(:ok)
expect(response.body).to eq({ preview_html: I18n.t("guidance.no_guidance_added_html"), errors: [] }.to_json)
expect(response.body).to eq({ preview_html: I18n.t("markdown_editor.no_markdown_content_html"), errors: [] }.to_json)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/requests/pages/guidance_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
it "renders the default HTML" do
expect(response).to have_http_status(:ok)
expect(response).to have_rendered("pages/guidance")
expect(response.body).to include(I18n.t("guidance.no_guidance_added_html"))
expect(response.body).to include(I18n.t("markdown_editor.no_markdown_content_html"))

Check failure on line 64 in spec/requests/pages/guidance_controller_spec.rb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "markdown_editor.no_markdown_content_html" 3 times.

See more on https://sonarcloud.io/project/issues?id=alphagov_forms-admin&issues=AZzc_1gLOxwlIhin-0Qy&open=AZzc_1gLOxwlIhin-0Qy&pullRequest=2621
end
end
end
Expand Down Expand Up @@ -125,7 +125,7 @@
it "renders the default HTML" do
expect(response).to have_http_status(:ok)
expect(response).to have_rendered("pages/guidance")
expect(response.body).to include(I18n.t("guidance.no_guidance_added_html"))
expect(response.body).to include(I18n.t("markdown_editor.no_markdown_content_html"))
end
end
end
Expand Down Expand Up @@ -170,7 +170,7 @@

it "returns a JSON object containing the converted HTML" do
expect(response).to have_http_status(:ok)
expect(response.body).to eq({ preview_html: I18n.t("guidance.no_guidance_added_html"), errors: [] }.to_json)
expect(response.body).to eq({ preview_html: I18n.t("markdown_editor.no_markdown_content_html"), errors: [] }.to_json)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/views/pages/guidance.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:form) { create :form }
let(:page) { OpenStruct.new(conditions: [], answer_type: "number") }
let(:guidance_input) { Pages::GuidanceInput.new }
let(:preview_html) { I18n.t("guidance.no_guidance_added_html") }
let(:preview_html) { I18n.t("markdown_editor.no_markdown_content_html") }
let(:back_link) { "/forms/1/pages/new" }
let(:question_number) { 1 }
let(:is_new_page) { true }
Expand Down
Loading