Skip to content

Commit

Permalink
Merge pull request #1018 from alphagov/remove-old-emergency-banner
Browse files Browse the repository at this point in the history
Remove old emergency banner
  • Loading branch information
bevanloon authored May 5, 2017
2 parents 6eca0b4 + 50c191a commit bc5eaf2
Show file tree
Hide file tree
Showing 13 changed files with 2 additions and 261 deletions.
12 changes: 0 additions & 12 deletions app/helpers/notification_helper.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
require "notification_file_lookup"
require "emergency_banner/display"

module NotificationHelper
include ActionView::Helpers::TagHelper

def banner_notification
if node = Static.banner
content_tag(:section, "<div>#{node[:file]}</div>",
{ id: "banner-notification", class: node[:colour].to_s }, false)
else
''
end
end

def emergency_banner_notification
emergency_banner = EmergencyBanner::Display.new
return emergency_banner if emergency_banner.enabled?
Expand Down
13 changes: 0 additions & 13 deletions app/views/notifications/banner.erb.example

This file was deleted.

1 change: 0 additions & 1 deletion app/views/notifications/banner_black.erb

This file was deleted.

Empty file.
Empty file.
8 changes: 1 addition & 7 deletions app/views/root/_base.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<% content_for :homepage_url, Plek.new.website_root %>
<% content_for :page_title, content_for?(:title) ? yield(:title) : "GOV.UK - The best place to find government services and information" %>
<% @banner_notification = banner_notification unless local_assigns[:hide_banner_notification] %>
<% @emergency_banner = emergency_banner_notification %>
<% @is_home_page = local_assigns[:is_home_page] %>

Expand Down Expand Up @@ -29,10 +28,6 @@

<% content_for :after_header do %>
<div id="user-satisfaction-survey-container"></div>
<% if @banner_notification.present? %>
<%= @banner_notification %>
<% end %>

<% if @emergency_banner %>
<% if @is_home_page %>
<%= render "notifications/homepage_emergency_banner", banner: @emergency_banner %>
Expand All @@ -44,8 +39,7 @@

<% content_for :content do %>
<% unless @emergency_banner %>
<% show_global_bar = @banner_notification.blank? && !local_assigns[:hide_banner_notification] && !@emergency_banner %>
<%= render partial: "promo_banner" if show_global_bar %>
<%= render partial: "promo_banner" %>
<% end %>

<div id="wrapper" class="group">
Expand Down
2 changes: 1 addition & 1 deletion app/views/root/homepage.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
# template on frontend due to the way slimmer would not copy over the
# comment
%>
<%= render partial: 'base', locals: { hide_nav: true, hide_banner_notification: true, is_home_page: true } %>
<%= render partial: 'base', locals: { hide_nav: true, is_home_page: true } %>
<%= render :file => 'layouts/govuk_template' %>
<!-- Thanks Martha -->
4 changes: 0 additions & 4 deletions config/initializers/notification_banner.rb

This file was deleted.

24 changes: 0 additions & 24 deletions lib/notification_file_lookup.rb

This file was deleted.

1 change: 0 additions & 1 deletion lib/static.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
module Static
mattr_accessor :banner
end
91 changes: 0 additions & 91 deletions test/integration/notifications_test.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
require 'integration_test_helper'

class NotificationsTest < ActionDispatch::IntegrationTest
setup do
@original_banner = Static.banner
end

teardown do
Static.banner = @original_banner
end

context "emergency banner file" do
should "have an emergency banner file" do
assert File.exist? "#{Rails.root}/app/views/notifications/_emergency_banner.html.erb"
Expand Down Expand Up @@ -133,87 +125,4 @@ class NotificationsTest < ActionDispatch::IntegrationTest
refute page.has_selector? ".global-bar-message"
end
end

context "banner files" do
should "have a green file" do
assert File.exist? "#{Rails.root}/app/views/notifications/banner_green.erb"
end

should "have a red file" do
assert File.exist? "#{Rails.root}/app/views/notifications/banner_red.erb"
end

should "have a black file" do
assert File.exist? "#{Rails.root}/app/views/notifications/banner_black.erb"
end
end

context "banner notifications" do
teardown do
clean_up_test_files
end

context "given view files are empty" do
setup do
create_test_file(filename: "banner_green.erb", content: '')
create_test_file(filename: "banner_red.erb", content: '')
create_test_file(filename: "banner_black.erb", content: '')

Static.banner = NotificationFileLookup.new(location_of_test_files).banner
end

should "not show a banner notification on the page" do
visit "/templates/wrapper.html.erb"
refute page.has_selector? "#banner-notification"
end
end

context "given view files are present for a green notification" do
setup do
create_test_file(filename: "banner_green.erb", content: '<p>Everything is fine</p>')
create_test_file(filename: "banner_red.erb", content: '')
create_test_file(filename: "banner_black.erb", content: '')

Static.banner = NotificationFileLookup.new(location_of_test_files).banner
end

should "show a banner notification on the page" do
visit "/templates/wrapper.html.erb"
assert page.has_selector? "#banner-notification.green"
assert_match '<p>Everything is fine</p>', page.body
end
end

context "given view files are present for a red notification" do
setup do
create_test_file(filename: "banner_green.erb", content: '')
create_test_file(filename: "banner_red.erb", content: '<p>Everything is not fine</p>')
create_test_file(filename: "banner_black.erb", content: '')

Static.banner = NotificationFileLookup.new(location_of_test_files).banner
end

should "show a banner notification on the page" do
visit "/templates/wrapper.html.erb"
assert page.has_selector? "#banner-notification.red"
assert_match '<p>Everything is not fine</p>', page.body
end
end

context "given view files are present for a black notification" do
setup do
create_test_file(filename: "banner_green.erb", content: '')
create_test_file(filename: "banner_red.erb", content: '')
create_test_file(filename: "banner_black.erb", content: '<p>RIP John Doe</p>')

Static.banner = NotificationFileLookup.new(location_of_test_files).banner
end

should "show a banner notification on the page" do
visit "/templates/wrapper.html.erb"
assert page.has_selector? "#banner-notification.black"
assert_match '<p>RIP John Doe</p>', page.body
end
end
end
end
62 changes: 0 additions & 62 deletions test/unit/notification_file_lookup_test.rb

This file was deleted.

45 changes: 0 additions & 45 deletions test/unit/notification_helper_test.rb

This file was deleted.

0 comments on commit bc5eaf2

Please sign in to comment.