diff --git a/app/views/pages/custom_page.html.erb b/app/views/pages/custom_page.html.erb index f14eba7d9..bdd85ab30 100644 --- a/app/views/pages/custom_page.html.erb +++ b/app/views/pages/custom_page.html.erb @@ -4,12 +4,16 @@

<%= @custom_page.title %>

-

<%= @custom_page.subtitle %>

+ <% if @custom_page.subtitle.present? %> +

<%= @custom_page.subtitle%>

+ <% end %> - <%= raw @custom_page.content %> + <%= text_with_links @custom_page.content %>
-
- <%= render '/shared/print' if @custom_page.print_content_flag %> -
+ <% if @custom_page.print_content_flag %> +
+ <%= render '/shared/print' %> +
+ <% end %> diff --git a/spec/features/site_customization/custom_pages_spec.rb b/spec/features/site_customization/custom_pages_spec.rb index 09ad797dc..85e50841d 100644 --- a/spec/features/site_customization/custom_pages_spec.rb +++ b/spec/features/site_customization/custom_pages_spec.rb @@ -72,6 +72,45 @@ feature "Custom Pages" do expect(page).not_to have_content("Print this info") end + scenario "Show all fields and text with links" do + custom_page = create(:site_customization_page, :published, + slug: "slug-with-all-fields-filled", + title: "Custom page", + subtitle: "This is my new custom page", + content: "Text for new custom page with a link to https://consul.dev", + print_content_flag: true, + locale: "en" + ) + + visit custom_page.url + + expect(page).to have_title("Custom page") + expect(page).to have_selector("h1", text: "Custom page") + expect(page).to have_selector("h2", text: "This is my new custom page") + expect(page).to have_content("Text for new custom page with a link to https://consul.dev") + expect(page).to have_link("https://consul.dev") + expect(page).to have_content("Print this info") + end + + scenario "Don't show subtitle if its blank" do + custom_page = create(:site_customization_page, :published, + slug: "slug-without-subtitle", + title: "Custom page", + subtitle: "", + content: "Text for new custom page", + print_content_flag: false, + locale: "en" + ) + + visit custom_page.url + + expect(page).to have_title("Custom page") + expect(page).to have_selector("h1", text: "Custom page") + expect(page).to have_content("Text for new custom page") + expect(page).not_to have_selector("h2") + expect(page).not_to have_content("Print this info") + end + scenario "Listed in more information page" do custom_page = create(:site_customization_page, :published, slug: "another-slug", title: "Another custom page",