From f3cb4238d2e0fc30c0f761defb8bb4ccf55f169c Mon Sep 17 00:00:00 2001 From: Ridhwana Date: Mon, 17 Jan 2022 16:46:38 +0200 Subject: [PATCH] Launch creator Onboarding with the Feature Flag [ To merge only on January 17 ] (#16090) * feat: add the DUS script * feat: enable the Feature Flag --- ..._enable_creator_onboarding_feature_flag.rb | 8 ++++ ...le_creator_onboarding_feature_flag_spec.rb | 38 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 lib/data_update_scripts/20220113085122_enable_creator_onboarding_feature_flag.rb create mode 100644 spec/lib/data_update_scripts/enable_creator_onboarding_feature_flag_spec.rb diff --git a/lib/data_update_scripts/20220113085122_enable_creator_onboarding_feature_flag.rb b/lib/data_update_scripts/20220113085122_enable_creator_onboarding_feature_flag.rb new file mode 100644 index 000000000..86d0493e3 --- /dev/null +++ b/lib/data_update_scripts/20220113085122_enable_creator_onboarding_feature_flag.rb @@ -0,0 +1,8 @@ +module DataUpdateScripts + class EnableCreatorOnboardingFeatureFlag + def run + FeatureFlag.add(:creator_onboarding) + FeatureFlag.enable(:creator_onboarding) + end + end +end diff --git a/spec/lib/data_update_scripts/enable_creator_onboarding_feature_flag_spec.rb b/spec/lib/data_update_scripts/enable_creator_onboarding_feature_flag_spec.rb new file mode 100644 index 000000000..5c7e58d47 --- /dev/null +++ b/spec/lib/data_update_scripts/enable_creator_onboarding_feature_flag_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" +require Rails.root.join( + "lib/data_update_scripts/20220113085122_enable_creator_onboarding_feature_flag.rb", +) + +describe DataUpdateScripts::EnableCreatorOnboardingFeatureFlag do + after do + FeatureFlag.remove(:creator_onboarding) + end + + it "adds the :creator_onboarding flag" do + expect do + described_class.new.run + end.to change { FeatureFlag.exist?(:creator_onboarding) }.from(false).to(true) + end + + it "enables the :creator_onboarding flag" do + expect do + described_class.new.run + end.to change { FeatureFlag.enabled?(:creator_onboarding) }.from(false).to(true) + end + + it "works if the flag is already available" do + FeatureFlag.add(:creator_onboarding) + + expect do + described_class.new.run + end.not_to change { FeatureFlag.exist?(:creator_onboarding) } + end + + it "works if the flag is already enabled" do + FeatureFlag.enable(:creator_onboarding) + + expect do + described_class.new.run + end.not_to change { FeatureFlag.enabled?(:creator_onboarding) } + end +end