Skip to content

Commit

Permalink
Fix Audience headers rendering without content
Browse files Browse the repository at this point in the history
  • Loading branch information
huwd committed Nov 5, 2019
1 parent f87dd5b commit be3b86a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 19 deletions.
24 changes: 13 additions & 11 deletions app/views/brexit_checker/_action_audiences.html.erb
@@ -1,17 +1,19 @@
<% if audiences.any? %>
<% audiences.each.with_index do |audience, index| %>
<div class="govuk-grid-row govuk-!-margin-bottom-6">
<div class="govuk-grid-column-full">
<h2 class="govuk-heading-l action-audience__heading"><%= audience[:heading] %></h2>
<% if audience[:actions].any? %>
<div class="govuk-grid-row govuk-!-margin-bottom-6">
<div class="govuk-grid-column-full">
<h2 class="govuk-heading-l action-audience__heading"><%= audience[:heading] %></h2>
</div>
<div class="govuk-grid-column-full">
<%= render "action_list", {
audience_heading: audience[:heading],
audience_index: index + 1,
items: audience[:actions]
} %>
</div>
</div>
<div class="govuk-grid-column-full">
<%= render "action_list", {
audience_heading: audience[:heading],
audience_index: index + 1,
items: audience[:actions]
} %>
</div>
</div>
<% end %>
<% end %>
<p class="govuk-body brexit-checker-actions__description">
<%= action_based_description %>
Expand Down
61 changes: 53 additions & 8 deletions spec/features/brexit_checker/question_results_spec.rb
Expand Up @@ -3,22 +3,25 @@
RSpec.feature "Brexit Checker workflow", type: :feature do
include BrexitCheckerHelper

scenario "business questions" do
scenario "business and citizen questions" do
when_i_visit_the_brexit_checker_flow
and_i_answer_citizen_questions
and_i_answer_business_questions
then_i_should_see_the_results_page
and_i_should_see_a_pet_action
and_i_should_see_a_tourism_action
then_i_see_citizen_and_business_results
end

scenario "citizen questions" do
scenario "business questions only" do
when_i_visit_the_brexit_checker_flow
and_i_do_not_answer_citizen_questions
and_i_answer_business_questions
then_i_see_business_results_only
end

scenario "citizen questions only" do
when_i_visit_the_brexit_checker_flow
and_i_answer_citizen_questions
and_i_do_not_answer_business_questions
then_i_should_see_the_results_page
and_i_should_see_a_pet_action
and_i_should_not_see_a_tourism_action
then_i_see_citizens_results_only
end

scenario "skip all questions" do
Expand All @@ -27,10 +30,48 @@
then_i_should_see_the_no_results_page
end

def then_i_see_citizen_and_business_results
then_i_should_see_the_results_page
and_i_should_see_the_citizens_action_header
and_i_should_see_the_business_action_header
and_i_should_see_a_pet_action
and_i_should_see_a_tourism_action
end

def then_i_see_business_results_only
then_i_should_see_the_results_page
expect(page).to_not have_content I18n.t!("brexit_checker.results.audiences.citizen.heading")
and_i_should_see_the_business_action_header
and_i_should_see_a_ce_mark_action
end

def then_i_see_citizens_results_only
then_i_should_see_the_results_page
and_i_should_see_the_citizens_action_header
expect(page).to_not have_content I18n.t!("brexit_checker.results.audiences.business.heading")
and_i_should_see_a_pet_action
and_i_should_not_see_a_tourism_action
end

def and_i_should_see_the_citizens_action_header
expect(page).to have_content I18n.t!("brexit_checker.results.audiences.citizen.heading")
end

def and_i_should_see_the_business_action_header
expect(page).to have_content I18n.t!("brexit_checker.results.audiences.business.heading")
end

def when_i_visit_the_brexit_checker_flow
visit brexit_checker_questions_path
end

def and_i_do_not_answer_citizen_questions
answer_question("nationality")
answer_question("living")
answer_question("employment")
answer_question("travelling")
end

def and_i_do_not_answer_business_questions
answer_question("do-you-own-a-business", "No")
end
Expand Down Expand Up @@ -83,6 +124,10 @@ def and_i_should_see_a_tourism_action
action_is_shown("T063")
end

def and_i_should_see_a_ce_mark_action
action_is_shown("T001")
end

def action_not_shown(key)
action = BrexitChecker::Action.find_by_id(key)
expect(page).to_not have_link(action.title, href: action.title_url)
Expand Down

0 comments on commit be3b86a

Please sign in to comment.