Skip to content

Commit e155521

Browse files
committed
Change calls to FeatureService with branch_routing
Every call to check if the branch_routing feature is enabled now includes the current form's group. This change will allow us to set the feature flag to be enabled per group rather than for every environment.
1 parent 0df3b0e commit e155521

File tree

6 files changed

+10
-5
lines changed

6 files changed

+10
-5
lines changed

app/controllers/pages/secondary_skip_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def delete_secondary_skip_input_params
7979
end
8080

8181
def ensure_branch_routing_feature_enabled
82-
raise ActionController::RoutingError, "branch_routing feature not enabled" unless Settings.features.branch_routing
82+
raise ActionController::RoutingError, "branch_routing feature not enabled" unless FeatureService.new(group: current_form.group).enabled?(:branch_routing)
8383
end
8484

8585
def ensure_page_has_skip_condition

app/presenters/route_summary_card_data_presenter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def conditional_route_card(routing_condition, index)
6464
def default_route_card(index)
6565
continue_to_name = page.has_next_page? ? page_name(page.next_page) : end_page_name
6666

67-
actions = if FeatureService.enabled?(:branch_routing) && all_routes.find(&:secondary_skip?).present?
67+
actions = if FeatureService.new(group: form.group).enabled?(:branch_routing) && all_routes.find(&:secondary_skip?).present?
6868
[
6969
edit_secondary_skip_link,
7070
delete_secondary_skip_link,
@@ -101,7 +101,7 @@ def secondary_skip_rows
101101
secondary_skip = all_routes.find(&:secondary_skip?)
102102

103103
if secondary_skip.blank?
104-
if FeatureService.enabled?(:branch_routing)
104+
if FeatureService.new(group: form.group).enabled?(:branch_routing)
105105
return [
106106
{
107107
key: { text: I18n.t("page_route_card.then") },

app/views/pages/conditions/_routing_options.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<%= t("routing_page.body_routing_text") %>
1212
</p>
1313

14-
<% if FeatureService.enabled?(:branch_routing) %>
14+
<% if FeatureService.new(group: form.group).enabled?(:branch_routing) %>
1515
<p>
1616
<%= t("routing_page.body_branching_text") %>
1717
</p>

app/views/pages/conditions/routing_page.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<%= t("routing_page.body_routing_text") %>
1616
</p>
1717

18-
<% if FeatureService.enabled?(:branch_routing) %>
18+
<% if FeatureService.new(group: form.group).enabled?(:branch_routing) %>
1919
<p>
2020
<%= t("routing_page.body_branching_text") %>
2121
</p>

spec/presenters/route_summary_card_data_presenter_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
let(:next_page_routing_conditions) { [] }
2727

28+
before do
29+
allow(form).to receive(:group).and_return(build(:group))
30+
end
31+
2832
describe ".call" do
2933
it "instantiates and returns a new instance" do
3034
service = described_class.call(form:, page: current_page, pages:)

spec/views/pages/conditions/routing_page.html.erb_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
allow(view).to receive_messages(form_pages_path: "/forms/1/pages", routing_page_path: "/forms/1/new-condition", set_routing_page_path: "/forms/1/new-condition")
1616
allow(form).to receive_messages(qualifying_route_pages: pages, has_no_remaining_routes_available?: all_routes_created)
17+
allow(form).to receive(:group).and_return(build(:group))
1718

1819
render template: "pages/conditions/routing_page", locals: { form:, routing_page_input: }
1920
end

0 commit comments

Comments
 (0)