From 655fe887f9a04864d700472f84227f49896d2ae1 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Thu, 4 Feb 2021 13:19:04 +0100 Subject: [PATCH] Distinguish user not present and list empty This is a bit more thorough. --- spec/initializers/feature_toggles_spec.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/initializers/feature_toggles_spec.rb b/spec/initializers/feature_toggles_spec.rb index 0051c084a4..0433d4508b 100644 --- a/spec/initializers/feature_toggles_spec.rb +++ b/spec/initializers/feature_toggles_spec.rb @@ -27,8 +27,9 @@ describe 'config/initializers/feature_toggles.rb' do end context 'when beta_testers is a list of emails' do + let(:other_user) { build(:user) } + context 'and the user is in the list' do - let(:other_user) { build(:user) } before { ENV['BETA_TESTERS'] = "#{user.email}, #{other_user.email}" } it 'enables the feature' do @@ -40,6 +41,17 @@ describe 'config/initializers/feature_toggles.rb' do end context 'and the user is not in the list' do + before { ENV['BETA_TESTERS'] = "#{other_user.email}" } + + it 'disables the feature' do + execute_initializer + + enabled = OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, user) + expect(enabled).to eq(false) + end + end + + context 'and the list is empty' do before { ENV['BETA_TESTERS'] = '' } it 'disables the feature' do