Skip to content

Commit d0d474c

Browse files
committed
Pass multiple_branches_enabled to summary cards
The step_summary_card_service needs to know if the group for a given form has the multiple_branches_enabled flag set, so it has to be passed in through the chain of things that make use of it.
1 parent 4b1e0db commit d0d474c

10 files changed

Lines changed: 17 additions & 12 deletions

app/controllers/forms/archived_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def show_pages
1515
return redirect_to live_form_pages_path if current_form.is_live?
1616
raise NotFoundError unless current_form.is_archived?
1717

18-
render :show_pages, locals: { form_document: current_archived_form, welsh_form_document: }
18+
render :show_pages, locals: { form_document: current_archived_form, welsh_form_document:, current_form: }
1919
end
2020

2121
private

app/controllers/forms/live_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def show_pages
1515
return redirect_to archived_form_pages_path if current_form.is_archived?
1616
raise NotFoundError unless current_form.is_live?
1717

18-
render :show_pages, locals: { form_document: current_live_form, welsh_form_document: }
18+
render :show_pages, locals: { form_document: current_live_form, welsh_form_document:, current_form: }
1919
end
2020

2121
private

app/services/step_summary_card_presenter.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ def call(**args)
55
end
66
end
77

8-
def initialize(step:, steps:, welsh_steps: nil)
8+
def initialize(step:, steps:, welsh_steps: nil, multiple_branches_enabled: false)
99
@step = step
1010
@steps = steps
1111
@welsh_steps = welsh_steps
12+
@multiple_branches_enabled = multiple_branches_enabled
1213
end
1314

1415
def build_card
@@ -20,7 +21,7 @@ def build_card
2021

2122
def build_summary_list
2223
{
23-
rows: StepSummaryCardService.call(step: @step, steps: @steps).all_options_for_answer_type,
24+
rows: StepSummaryCardService.call(step: @step, steps: @steps, multiple_branches_enabled: @multiple_branches_enabled).all_options_for_answer_type,
2425
}
2526
end
2627

app/views/forms/_made_live_form_pages.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<%= StepSummaryCardPresenter.call(step:, steps: form_document.steps, welsh_steps: welsh_form_document.steps).build_untranslated_content[:text] %>
3232
<% end %>
3333
<% else %>
34-
<%= govuk_summary_list(**StepSummaryCardPresenter.call(step:, steps: form_document.steps).build_summary_list)%>
34+
<%= govuk_summary_list(**StepSummaryCardPresenter.call(step:, steps: form_document.steps, multiple_branches_enabled: FeatureService.new(group: current_form.group).enabled?(:multiple_branches)).build_summary_list)%>
3535
<% end %>
3636
<% end %>
3737
<% end %>

app/views/forms/archived/show_pages.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
welsh_form_document:,
33
status: :archived,
44
show_form_path: archived_form_path(form_document.id),
5+
current_form:,
56
} %>

app/views/forms/live/show_pages.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
welsh_form_document:,
33
status: :live,
44
show_form_path: live_form_path(form_document.id),
5+
current_form:,
56
} %>

spec/services/step_summary_card_presenter_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
let(:steps) do
77
[step, *build_list(:form_document_step, 5)]
88
end
9-
let(:presenter) { described_class.call(step:, steps:) }
9+
let(:multiple_branches_enabled) { false }
10+
let(:presenter) { described_class.call(step:, steps:, multiple_branches_enabled:) }
1011

1112
describe "#build_card" do
1213
before do

spec/views/forms/_made_live_form_pages.html.erb_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require "rails_helper"
22

33
describe "forms/_made_live_form_pages.html.erb" do
4-
let(:form) { create :form, :live }
4+
let(:form) { create :form, :with_group, :live }
55
let(:form_document) { FormDocument::Content.from_form_document(form.live_form_document) }
66
let(:welsh_form_document) { nil }
77
let(:status) { :live }
@@ -13,6 +13,7 @@
1313
welsh_form_document:,
1414
status:,
1515
show_form_path:,
16+
current_form: form
1617
})
1718
end
1819

spec/views/forms/archived/show_pages.html.erb_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
require "rails_helper"
22

33
describe "forms/archived/show_pages.html.erb" do
4-
let(:form_metadata) { create :form, :archived }
5-
let(:form_document) { FormDocument::Content.from_form_document(form_metadata.archived_form_document) }
4+
let(:form) { create :form, :with_group, :archived }
5+
let(:form_document) { FormDocument::Content.from_form_document(form.archived_form_document) }
66
let(:welsh_form_document) { nil }
77

88
before do
9-
render(template: "forms/archived/show_pages", locals: { form_document:, welsh_form_document: })
9+
render(template: "forms/archived/show_pages", locals: { form_document:, welsh_form_document:, current_form: form })
1010
end
1111

1212
it "renders the made_live_form_pages partial" do

spec/views/forms/live/show_pages.html.erb_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
require "rails_helper"
22

33
describe "forms/live/show_pages.html.erb" do
4-
let(:form) { create :form, :live }
4+
let(:form) { create :form, :with_group, :live }
55
let(:form_document) { FormDocument::Content.from_form_document(form.live_form_document) }
66
let(:welsh_form_document) { nil }
77

88
before do
9-
render(template: "forms/live/show_pages", locals: { form_document:, welsh_form_document: })
9+
render(template: "forms/live/show_pages", locals: { form_document:, welsh_form_document:, current_form: form })
1010
end
1111

1212
it "renders the made_live_form_pages partial" do

0 commit comments

Comments
 (0)