Skip to content

Commit

Permalink
Merge pull request #2168 from alphagov/dependabot/bundler/rubocop-gov…
Browse files Browse the repository at this point in the history
…uk-3.10.0

Bump rubocop-govuk from 3.9.0 to 3.10.0
  • Loading branch information
benthorner authored May 15, 2020
2 parents 3186959 + dbb7e81 commit c6df1ca
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 56 deletions.
8 changes: 3 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ GEM
progress (~> 3.0, >= 3.0.1)
image_size (2.0.2)
in_threads (1.5.3)
jaro_winkler (1.5.4)
jasmine-core (2.99.2)
jasmine-rails (0.15.0)
jasmine-core (>= 1.3, < 4.0)
Expand Down Expand Up @@ -237,16 +236,15 @@ GEM
netrc (~> 0.8)
rexml (3.2.4)
rouge (3.19.0)
rubocop (0.82.0)
jaro_winkler (~> 1.5.1)
rubocop (0.83.0)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-govuk (3.9.0)
rubocop (= 0.82.0)
rubocop-govuk (3.10.0)
rubocop (= 0.83.0)
rubocop-rails (~> 2)
rubocop-rake (~> 0.5.1)
rubocop-rspec (~> 1.28)
Expand Down
19 changes: 13 additions & 6 deletions lib/emergency_banner/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ module EmergencyBanner
class Deploy
def run(campaign_class, heading, short_description = "", link = "", link_text = "")
redis = Redis.new
redis.hmset(:emergency_banner,
:campaign_class, campaign_class,
:heading, heading,
:short_description, short_description,
:link, link,
:link_text, link_text)
redis.hmset(
:emergency_banner,
:campaign_class,
campaign_class,
:heading,
heading,
:short_description,
short_description,
:link,
link,
:link_text,
link_text,
)
end
end
end
2 changes: 1 addition & 1 deletion script/copy_component_translations_from_whitehall
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "yaml"

class Hash
def dig_by_path path
def dig_by_path(path)
dig(*path.split("."))
end

Expand Down
38 changes: 24 additions & 14 deletions test/integration/notifications_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ def stub_redis_response(hash)
end

should "render the more information link" do
stub_redis_response(campaign_class: "notable-death",
heading: "Alas poor Yorick",
link: "https://yoricks.gov")
stub_redis_response(
campaign_class: "notable-death",
heading: "Alas poor Yorick",
link: "https://yoricks.gov",
)

visit "/templates/wrapper.html.erb"

Expand All @@ -45,19 +47,23 @@ def stub_redis_response(hash)
end

should "render the more information link with specified text" do
stub_redis_response(campaign_class: "notable-death",
heading: "Alas poor Yorick",
link: "https://yoricks.gov",
link_text: "Some specified text for more information")
stub_redis_response(
campaign_class: "notable-death",
heading: "Alas poor Yorick",
link: "https://yoricks.gov",
link_text: "Some specified text for more information",
)

visit "/templates/wrapper.html.erb"

assert_match "Some specified text for more information", page.body
end

should "not render the more information link if it does not exist" do
stub_redis_response(campaign_class: "notable-death",
heading: "Alas poor Yorick")
stub_redis_response(
campaign_class: "notable-death",
heading: "Alas poor Yorick",
)

visit "/templates/wrapper.html.erb"

Expand All @@ -66,18 +72,22 @@ def stub_redis_response(hash)
end

should "render the extra information" do
stub_redis_response(campaign_class: "notable-death",
heading: "Alas poor Yorick",
short_description: "I knew him well")
stub_redis_response(
campaign_class: "notable-death",
heading: "Alas poor Yorick",
short_description: "I knew him well",
)

visit "/templates/wrapper.html.erb"

assert_match "I knew him well", page.body
end

should "does not render the extra information if it does not exist" do
stub_redis_response(campaign_class: "notable-death",
heading: "Alas poor Yorick")
stub_redis_response(
campaign_class: "notable-death",
heading: "Alas poor Yorick",
)

visit "/templates/wrapper.html.erb"

Expand Down
95 changes: 65 additions & 30 deletions test/unit/emergency_banner/deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,91 @@
describe "Emergency Banner::Deploy" do
context "#run" do
should "create an emergency_banner hash in Redis with a campaign_class and a heading" do
Redis.any_instance.expects(:hmset).with(:emergency_banner,
:campaign_class, "notable-death",
:heading, "A title",
:short_description, "",
:link, "",
:link_text, "")
Redis.any_instance.expects(:hmset).with(
:emergency_banner,
:campaign_class,
"notable-death",
:heading,
"A title",
:short_description,
"",
:link,
"",
:link_text,
"",
)

EmergencyBanner::Deploy.new.run("notable-death", "A title")
end

should "create an emergency_banner with a campaign_class, heading and short_description" do
Redis.any_instance.expects(:hmset).with(:emergency_banner,
:campaign_class, "notable-death",
:heading, "A title",
:short_description, "A short description of the event",
:link, "",
:link_text, "")
Redis.any_instance.expects(:hmset).with(
:emergency_banner,
:campaign_class,
"notable-death",
:heading,
"A title",
:short_description,
"A short description of the event",
:link,
"",
:link_text,
"",
)

EmergencyBanner::Deploy.new.run("notable-death", "A title", "A short description of the event")
end

should "create an emergency_banner with a campaign_class, heading and link" do
Redis.any_instance.expects(:hmset).with(:emergency_banner,
:campaign_class, "notable-death",
:heading, "A title",
:short_description, "",
:link, "https://www.gov.uk",
:link_text, "")
Redis.any_instance.expects(:hmset).with(
:emergency_banner,
:campaign_class,
"notable-death",
:heading,
"A title",
:short_description,
"",
:link,
"https://www.gov.uk",
:link_text,
"",
)

EmergencyBanner::Deploy.new.run("notable-death", "A title", "", "https://www.gov.uk")
end

should "create an emergency_banner with a campaign_class, heading, short_description and link" do
Redis.any_instance.expects(:hmset).with(:emergency_banner,
:campaign_class, "notable-death",
:heading, "A title",
:short_description, "A short description of the event",
:link, "https://www.gov.uk",
:link_text, "")
Redis.any_instance.expects(:hmset).with(
:emergency_banner,
:campaign_class,
"notable-death",
:heading,
"A title",
:short_description,
"A short description of the event",
:link,
"https://www.gov.uk",
:link_text,
"",
)

EmergencyBanner::Deploy.new.run("notable-death", "A title", "A short description of the event", "https://www.gov.uk")
end

should "create an emergency_banner with a campaign_class, heading, short_description, link and link_text" do
Redis.any_instance.expects(:hmset).with(:emergency_banner,
:campaign_class, "notable-death",
:heading, "A title",
:short_description, "A short description of the event",
:link, "https://www.gov.uk",
:link_text, "Text for hyperlink")
Redis.any_instance.expects(:hmset).with(
:emergency_banner,
:campaign_class,
"notable-death",
:heading,
"A title",
:short_description,
"A short description of the event",
:link,
"https://www.gov.uk",
:link_text,
"Text for hyperlink",
)

EmergencyBanner::Deploy.new.run("notable-death", "A title", "A short description of the event", "https://www.gov.uk", "Text for hyperlink")
end
Expand Down

0 comments on commit c6df1ca

Please sign in to comment.