Skip to content

Commit a9b4c36

Browse files
authored
Merge pull request #1543 from alphagov/DGUK-137-add-notification-banner
DGUK-137 Add survey notification banner
2 parents edd6739 + e479139 commit a9b4c36

5 files changed

Lines changed: 67 additions & 1 deletion

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div class="govuk-notification-banner" role="region" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
2+
<div class="govuk-notification-banner__header">
3+
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
4+
<%= t("pages.home.notification_banner_title") %>
5+
</h2>
6+
</div>
7+
<div class="govuk-notification-banner__content">
8+
<p class="govuk-notification-banner__heading">
9+
<%= t("pages.home.notification_banner_content_html").html_safe %>
10+
</p>
11+
</div>
12+
</div>

app/views/pages/home.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<% content_for :page_title do %><%= t('.find_open_data') %><% end %>
2-
32
<main role="main" id="main-content" class="govuk-main-wrapper">
3+
<%= render 'notification_banner' %>
44
<div class="govuk-grid-row">
55
<div class="govuk-grid-column-two-thirds">
66
<%= render "govuk_publishing_components/components/title", {

config/locales/views/pages/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ en:
3636
home:
3737
find_open_data: "Find open data"
3838
lede: "Find data published by central government, local authorities and public bodies to help you build products and services"
39+
notification_banner_title: Important
40+
notification_banner_content_html: We're planning improvements to this service. Help us learn what to change by <a class="govuk-notification-banner__link" href="https://surveys.publishing.service.gov.uk/s/OSC03D/">completing a short survey</a>.

spec/features/home_page_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
require "rails_helper"
2+
3+
RSpec.feature "Home page", type: :feature do
4+
scenario "User visits the home page" do
5+
given_i_am_on_the_home_page
6+
then_i_can_see_the_title
7+
and_i_can_see_a_notification_banner
8+
and_the_notification_banner_has_a_link
9+
end
10+
11+
def given_i_am_on_the_home_page
12+
visit root_path
13+
end
14+
15+
def then_i_can_see_the_title
16+
expect(page).to have_content("Find open data")
17+
end
18+
19+
def and_i_can_see_a_notification_banner
20+
expect(page).to have_content(I18n.t(".pages.home.notification_banner_title"))
21+
expect(page).to have_css(".govuk-notification-banner", text: "We're planning improvements to this service. Help us learn what to change by completing a short survey.")
22+
end
23+
24+
def and_the_notification_banner_has_a_link
25+
expect(page).to have_link("completing a short survey", href: "https://surveys.publishing.service.gov.uk/s/OSC03D/", count: 1)
26+
end
27+
end

spec/requests/pages_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require "rails_helper"
2+
3+
RSpec.describe "pages", type: :request do
4+
describe "GET /" do
5+
before do
6+
get root_path
7+
end
8+
9+
it "returns success response" do
10+
expect(response).to have_http_status(:ok)
11+
end
12+
13+
it "renders the home page" do
14+
expect(response.body).to include(I18n.t("pages.home.find_open_data"))
15+
end
16+
17+
it "renders a govuk notification banner" do
18+
expect(response.body).to include("govuk-notification-banner-title")
19+
end
20+
21+
it "renders the survey link" do
22+
expect(response.body).to include("https://surveys.publishing.service.gov.uk/s/OSC03D/")
23+
end
24+
end
25+
end

0 commit comments

Comments
 (0)