-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1949ec
commit d99cbbb
Showing
9 changed files
with
184 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module RecruitmentBannerHelper | ||
def recruitment_banner | ||
return false if recruitment_banners.nil? | ||
|
||
current_path = request.path | ||
|
||
recruitment_banners.find do |banner| | ||
next unless valid?(banner) | ||
|
||
banner["page_paths"]&.include?(current_path) | ||
end | ||
end | ||
|
||
def recruitment_banners | ||
recruitment_banners_urls_file_path = Rails.root.join("lib/data/recruitment_banners.yml") | ||
recruitment_banners_data = YAML.load_file(recruitment_banners_urls_file_path) | ||
recruitment_banners_data["banners"] | ||
end | ||
|
||
def valid?(banner) | ||
required_fields.select { |field| banner[field].present? } == required_fields | ||
end | ||
|
||
def required_fields | ||
%w[survey_url suggestion_text suggestion_link_text page_paths] | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<% if recruitment_banner.present? %> | ||
<div class="govuk-width-container govuk-!-margin-top-4"> | ||
<%= render "govuk_publishing_components/components/intervention", { | ||
new_tab: true, | ||
suggestion_text: recruitment_banner["suggestion_text"], | ||
suggestion_link_text: recruitment_banner["suggestion_link_text"], | ||
suggestion_link_url: recruitment_banner["survey_url"], | ||
} %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Example usage of adding a banner to the banners list: | ||
|
||
# - name: Banner 1 | ||
# suggestion_text: "Help improve GOV.UK" | ||
# suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
# survey_url: https://google.com | ||
# page_paths: | ||
# - / | ||
# - /foreign-travel-advice | ||
|
||
banners: | ||
- name: HMRC Team Banner | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_CEST_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=577 | ||
page_paths: | ||
- /guidance/check-employment-status-for-tax | ||
|
||
- name: HMRC Team Banner | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Corp_Tax_trading_and_non_trading_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=578 | ||
page_paths: | ||
- /guidance/corporation-tax-trading-and-non-trading | ||
|
||
- name: HMRC Team Banner | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Fill_and_submit_VAT_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=579 | ||
page_paths: | ||
- /guidance/how-to-fill-in-and-submit-your-vat-return-vat-notice-70012 | ||
|
||
- name: HMRC Team Banner | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Sign_in_BTA_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=580 | ||
page_paths: | ||
- /guidance/sign-in-to-your-hmrc-business-tax-account | ||
|
||
- name: HMRC Team Banner | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_VAT_on_goods_and_services_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=581 | ||
page_paths: | ||
- /guidance/rates-of-vat-on-different-goods-and-services | ||
|
||
- name: HMRC Team Banner | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_CIS_refund_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=582 | ||
page_paths: | ||
- /guidance/claim-a-refund-of-construction-industry-scheme-deductions-if-youre-a-limited-company | ||
|
||
- name: HMRC Team Banner | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_IR35_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=583 | ||
page_paths: | ||
- /guidance/understanding-off-payroll-working-ir35 | ||
|
||
- name: HMRC Team Banner | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Tax_reliefs_and_allowances_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=584 | ||
page_paths: | ||
- /guidance/tax-reliefs-and-allowances-for-businesses-employers-and-the-self-employed | ||
|
||
- name: HMRC Team Banner | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Corp_Tax_selling_or_closing_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=585 | ||
page_paths: | ||
- /guidance/corporation-tax-selling-or-closing-your-company | ||
|
||
- name: HMRC Team Banner | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" | ||
survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Expect_a_reply_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=586 | ||
page_paths: | ||
- /guidance/check-when-you-can-expect-a-reply-from-hmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
banners: | ||
- name: Banner 1 | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Take part in user research" | ||
survey_url: https://google.com | ||
page_paths: | ||
- / | ||
|
||
- name: Banner 2 | ||
suggestion_text: "Help improve GOV.UK" | ||
suggestion_link_text: "Take part in user research" | ||
survey_url: https://google.com | ||
page_paths: | ||
- /some_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require "test_helper" | ||
|
||
class RecruitmentBannerHelperTest < ActionView::TestCase | ||
include RecruitmentBannerHelper | ||
|
||
def setup | ||
@recruitment_banners_data = YAML.load_file(Rails.root.join("test/fixtures/recruitment_banners.yml")) | ||
end | ||
|
||
def request | ||
OpenStruct.new(path: "/") | ||
end | ||
|
||
def recruitment_banners | ||
@recruitment_banners_data["banners"] | ||
end | ||
|
||
test "recruitment_banner returns banners that include the current url" do | ||
actual_banners = recruitment_banner | ||
|
||
expected_banners = | ||
{ | ||
"name" => "Banner 1", | ||
"suggestion_text" => "Help improve GOV.UK", | ||
"suggestion_link_text" => "Take part in user research", | ||
"survey_url" => "https://google.com", | ||
"page_paths" => ["/"], | ||
} | ||
assert_equal expected_banners, actual_banners | ||
end | ||
|
||
test "recruitment_banners yaml structure is valid" do | ||
@recruitment_banners_data = YAML.load_file(Rails.root.join("lib/data/recruitment_banners.yml")) | ||
|
||
if @recruitment_banners_data["banners"].present? | ||
recruitment_banners.each do |banner| | ||
assert banner.key?("suggestion_text"), "Banner is missing 'suggestion_text' key" | ||
assert_not banner["suggestion_text"].blank?, "'suggestion_text' key should not be blank" | ||
|
||
assert banner.key?("suggestion_link_text"), "Banner is missing 'suggestion_link_text' key" | ||
assert_not banner["suggestion_link_text"].blank?, "'suggestion_link_text' key should not be blank" | ||
|
||
assert banner.key?("survey_url"), "Banner is missing 'survey_url' key" | ||
assert_not banner["survey_url"].blank?, "'survey_url' key should not be blank" | ||
|
||
assert banner.key?("page_paths"), "Banner is missing 'page_paths' key" | ||
assert_not banner["page_paths"].blank?, "'page_paths' key should not be blank" | ||
end | ||
end | ||
end | ||
end |