Commit 2a1bc50f authored by Dallas Reedy's avatar Dallas Reedy Committed by Patrick Bajao

Move lengthy data attributes from view into helper

Adds a new helper method, data_attributes_for_progress_bar, and tests it
Removes the onboarding_issues_experiment_enabled variable from the view
parent ab9e43cb
......@@ -57,8 +57,11 @@ module EE
onboarding_issues_experiment_enabled? ? continue : get_started
end
def onboarding_issues_experiment_enabled?
experiment_enabled?(:onboarding_issues)
def data_attributes_for_progress_bar_js_component
{
is_in_subscription_flow: in_subscription_flow?.to_s,
is_onboarding_issues_experiment_enabled: onboarding_issues_experiment_enabled?.to_s
}
end
def skip_setup_for_company?
......@@ -73,5 +76,9 @@ module EE
URI.parse(redirect_to).path if redirect_to
end
end
def onboarding_issues_experiment_enabled?
experiment_enabled?(:onboarding_issues)
end
end
end
- if show_signup_flow_progress_bar?
#progress-bar{ data: { is_in_subscription_flow: in_subscription_flow?.to_s, is_onboarding_issues_experiment_enabled: onboarding_issues_experiment_enabled?.to_s } }
#progress-bar{ data: data_attributes_for_progress_bar_js_component }
......@@ -245,6 +245,26 @@ RSpec.describe EE::RegistrationsHelper do
end
end
describe '#data_attributes_for_progress_bar_js_component' do
before do
allow(helper).to receive(:in_subscription_flow?).and_return(options_enabled)
allow(helper).to receive(:onboarding_issues_experiment_enabled?).and_return(options_enabled)
end
subject { helper.tag(:div, data: helper.data_attributes_for_progress_bar_js_component) }
where(:options_enabled, :attr_values) do
true | 'true'
false | 'false'
end
with_them do
it 'always includes both attributes with stringified boolean values' do
is_expected.to eq(%{<div data-is-in-subscription-flow="#{attr_values}" data-is-onboarding-issues-experiment-enabled="#{attr_values}" />})
end
end
end
describe '#skip_setup_for_company?' do
let(:user) { create(:user) }
......
......@@ -10,7 +10,7 @@ RSpec.describe 'registrations/welcome' do
before do
allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:redirect_path).and_return(redirect_path)
allow(view).to receive(:experiment_enabled?).with(:onboarding_issues).and_return(onboarding_issues_experiment_enabled)
allow(view).to receive(:onboarding_issues_experiment_enabled?).and_return(onboarding_issues_experiment_enabled)
allow(Gitlab).to receive(:com?).and_return(true)
render
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment