diff --git a/app/assets/stylesheets/notifications.scss b/app/assets/stylesheets/notifications.scss index b4e48f9fc..a11b34e89 100644 --- a/app/assets/stylesheets/notifications.scss +++ b/app/assets/stylesheets/notifications.scss @@ -43,60 +43,3 @@ background: #b10e1e; } } - -#campaign-notification { - clear:both; - background-color: $grey-6; - color: #fff; - padding: 2em; - - h1 { - @include core-80; - } - - p { - @include core-24; - padding-right: 25%; - margin-bottom: 0; - } - - a { - color: #fff; - - &.right { - @include core-24; - text-align: right; - padding: 0 0 0 75%; - margin-top: (25 / 19) * -1em; - display: block; - } - } - - @include ie-lte(7){ - width: 960px; - } - - &.green { - background: #fff; - border: 10px solid #28a197; - color: #28a197; - - a { - color: #28a197; - } - } - - &.red { - background: #b10e1e; - } - - &.black { - background: #fff; - border: 10px solid $black; - color: $black; - - a { - color: $black; - } - } -} diff --git a/app/helpers/notification_helper.rb b/app/helpers/notification_helper.rb index 668bfe735..c45b6ec62 100644 --- a/app/helpers/notification_helper.rb +++ b/app/helpers/notification_helper.rb @@ -4,20 +4,9 @@ module NotificationHelper include ActionView::Helpers::TagHelper def banner_notification - node_replacement_notification(NotificationFileLookup.instance.banner, "banner") - end - - # Only used to replace homepage campaigns for urgent matters. - def campaign_replacement_notification - node_replacement_notification(NotificationFileLookup.instance.campaign, "campaign") - end - - private - - def node_replacement_notification(node, type) - if node + if node = NotificationFileLookup.instance.banner content_tag(:section, "
Your message goes here
-This is the second line of your message!
-This is the third line!
Green notification
') - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_red.erb") - .returns('') - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_black.erb") - .returns('') - end - - should "show a green campaign notification on the page" do - visit "/templates/campaign.html.erb" - assert page.has_selector? "#campaign-notification.green" - assert_match 'Green notification
', page.body - end - end - - context "given view files are present for a red notification" do - setup do - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_green.erb") - .returns('') - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_red.erb") - .returns('Red campaign
') - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_black.erb") - .returns('') - end - - should "show a red notification on the page" do - visit "/templates/campaign.html.erb" - assert page.has_selector? "#campaign-notification.red" - assert_match 'Red campaign
', page.body - end - end - - context "given view files are present for a black notification" do - setup do - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_green.erb") - .returns('') - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_red.erb") - .returns('') - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_black.erb") - .returns('Black campaign
') - end - - should "show a black notification on the page" do - visit "/templates/campaign.html.erb" - assert page.has_selector? "#campaign-notification.black" - assert_match 'Black campaign
', page.body - end - end - end end diff --git a/test/unit/notification_file_lookup_test.rb b/test/unit/notification_file_lookup_test.rb index 184d2fa6f..f798a9da6 100644 --- a/test/unit/notification_file_lookup_test.rb +++ b/test/unit/notification_file_lookup_test.rb @@ -55,66 +55,4 @@ assert_equal expected, NotificationFileLookup.instance.banner end end - - describe "campaign" do - before do - NotificationFileLookup.instance.campaign = nil - end - - it "returns nil if all three campaign content files are empty" do - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_green.erb") - .returns('') - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_red.erb") - .returns('') - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_black.erb") - .returns('') - - assert_nil NotificationFileLookup.instance.campaign - end - - it "returns the black campaign content if present" do - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_black.erb") - .returns('Black message.
') - - expected = {:file => "Black message.
", :colour => :black} - assert_equal expected, NotificationFileLookup.instance.campaign - end - - it "opens each campaign content file only once" do - File.expects(:read).with("#{Rails.root}/app/views/notifications/campaign_green.erb") - .returns('Test') - File.expects(:read).with("#{Rails.root}/app/views/notifications/campaign_red.erb") - .returns('') - File.expects(:read).with("#{Rails.root}/app/views/notifications/campaign_black.erb") - .returns('') - - expected = {:file => "Test", :colour => :green} - 3.times do - assert_equal expected, NotificationFileLookup.instance.campaign - end - end - - it "returns nil if the campaign content only contains whitespace" do - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_green.erb") - .returns("\n\n\r\n\r\n\n\n") - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_red.erb") - .returns('') - File.stubs(:read).with("#{Rails.root}/app/views/notifications/campaign_black.erb") - .returns("\n\n\r\n\r\n\n\n") - - assert_nil NotificationFileLookup.instance.campaign - end - - it "falls back to green if the red and black files are empty" do - File.expects(:read).with("#{Rails.root}/app/views/notifications/campaign_green.erb") - .returns('Nothing to see here.
') - File.expects(:read).with("#{Rails.root}/app/views/notifications/campaign_red.erb") - .returns('') - File.expects(:read).with("#{Rails.root}/app/views/notifications/campaign_black.erb") - .returns('') - - expected = {:file => "Nothing to see here.
", :colour => :green} - assert_equal expected, NotificationFileLookup.instance.campaign - end - end end diff --git a/test/unit/notification_helper_test.rb b/test/unit/notification_helper_test.rb index 19e35335f..2d532eada 100644 --- a/test/unit/notification_helper_test.rb +++ b/test/unit/notification_helper_test.rb @@ -11,65 +11,26 @@ describe "when a banner is present" do it "should return a banner notification" do - campaign = {:file => "You've got notifications!
", :colour => :green} - NotificationFileLookup.any_instance.stubs(:banner).returns(campaign) + banner = {:file => "You've got notifications!
", :colour => :green} + NotificationFileLookup.any_instance.stubs(:banner).returns(banner) assert_match "You've got notifications!
", banner_notification end it "should have a section wrapper with the banner colour for a green notification" do - campaign = {:file => "You've got notifications!
", :colour => :green} - NotificationFileLookup.any_instance.stubs(:banner).returns(campaign) + banner = {:file => "You've got notifications!
", :colour => :green} + NotificationFileLookup.any_instance.stubs(:banner).returns(banner) assert_equal "You've got notifications!
You've got notifications!
", :colour => :red} - NotificationFileLookup.any_instance.stubs(:banner).returns(campaign) + banner = {:file => "You've got notifications!
", :colour => :red} + NotificationFileLookup.any_instance.stubs(:banner).returns(banner) assert_equal "You've got notifications!
You've got notifications!
", :colour => :green} - NotificationFileLookup.any_instance.stubs(:campaign).returns(campaign) - assert_match "You've got notifications!
", campaign_replacement_notification - end - - it "should have a section wrapper with the campaign colour for a green notification" do - campaign = {:file => "You've got notifications!
", :colour => :green} - NotificationFileLookup.any_instance.stubs(:campaign).returns(campaign) - - assert_equal "You've got notifications!
You've got notifications!
", :colour => :red} - NotificationFileLookup.any_instance.stubs(:campaign).returns(campaign) - - assert_equal "You've got notifications!
You've got notifications!
", :colour => :black} - NotificationFileLookup.any_instance.stubs(:campaign).returns(campaign) - - assert_equal "You've got notifications!