diff --git a/Gemfile.lock b/Gemfile.lock index 0a97478..ccb7b7e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,49 +8,49 @@ GEM specs: ast (2.4.2) backport (1.2.0) - benchmark (0.1.1) - bundler-audit (0.8.0) + benchmark (0.2.0) + bundler-audit (0.9.0.1) bundler (>= 1.2.0, < 3) thor (~> 1.0) byebug (11.1.3) - diff-lcs (1.4.4) + diff-lcs (1.5.0) e2mmap (0.1.0) jaro_winkler (1.5.4) kramdown (2.3.1) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - mini_portile2 (2.6.1) - minitest (5.14.4) - nokogiri (1.12.3) - mini_portile2 (~> 2.6.1) + mini_portile2 (2.7.1) + minitest (5.15.0) + nokogiri (1.13.1) + mini_portile2 (~> 2.7.0) racc (~> 1.4) - parallel (1.20.1) - parser (3.0.2.0) + parallel (1.21.0) + parser (3.1.0.0) ast (~> 2.4.1) - racc (1.5.2) - rainbow (3.0.0) + racc (1.6.0) + rainbow (3.1.1) rake (12.3.3) - redis (4.4.0) + redis (4.6.0) redis-namespace (1.8.1) redis (>= 3.0.4) - regexp_parser (2.1.1) - reverse_markdown (2.0.0) + regexp_parser (2.2.1) + reverse_markdown (2.1.1) nokogiri rexml (3.2.5) - rubocop (1.19.0) + rubocop (1.25.1) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.9.1, < 2.0) + rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.9.1) + rubocop-ast (1.15.2) parser (>= 3.0.1.1) ruby-progressbar (1.11.0) - solargraph (0.43.0) + solargraph (0.44.3) backport (~> 1.2) benchmark bundler (>= 1.17.2) @@ -65,10 +65,12 @@ GEM thor (~> 1.0) tilt (~> 2.0) yard (~> 0.9, >= 0.9.24) - thor (1.1.0) + thor (1.2.1) tilt (2.0.10) - unicode-display_width (2.0.0) - yard (0.9.26) + unicode-display_width (2.1.0) + webrick (1.7.0) + yard (0.9.27) + webrick (~> 1.7.0) PLATFORMS ruby diff --git a/README.md b/README.md index 7667185..3a38294 100644 --- a/README.md +++ b/README.md @@ -136,11 +136,19 @@ FEATURE_FLAGS.active?(:feature_name) #=> false FEATURE_FLAGS.active_globally?(:feature_name) #=> false FEATURE_FLAGS.active_partially?(:feature_name) #=> false +FEATURE_FLAGS.inactive?(:feature_name) #=> true +FEATURE_FLAGS.inactive_globally?(:feature_name) #=> true +FEATURE_FLAGS.inactive_partially?(:feature_name) #=> true + FEATURE_FLAGS.activate(:feature_name) # or FEATURE_FLAGS.activate_globally(:feature_name) FEATURE_FLAGS.active?(:feature_name) #=> true FEATURE_FLAGS.active_globally?(:feature_name) #=> true FEATURE_FLAGS.active_partially?(:feature_name) #=> false + +FEATURE_FLAGS.inactive?(:feature_name) #=> false +FEATURE_FLAGS.inactive_globally?(:feature_name) #=> false +FEATURE_FLAGS.inactive_partially?(:feature_name) #=> true ``` #### Deactivate a feature @@ -149,10 +157,12 @@ Deactivates a feature in the global scope ```ruby FEATURE_FLAGS.active?(:feature_name) #=> true +FEATURE_FLAGS.inactive?(:feature_name) #=> false FEATURE_FLAGS.deactivate(:feature_name) FEATURE_FLAGS.active?(:feature_name) #=> false +FEATURE_FLAGS.inactive?(:feature_name) #=> true ``` #### Activate a feature for a particular record/object @@ -162,11 +172,19 @@ FEATURE_FLAGS.active_partially?(:feature_name) #=> true FEATURE_FLAGS.active_for?(:feature_name, User.first) #=> false FEATURE_FLAGS.active_for?(:feature_name, User.last) #=> false +FEATURE_FLAGS.inactive_partially?(:feature_name) #=> false +FEATURE_FLAGS.inactive_for?(:feature_name, User.first) #=> true +FEATURE_FLAGS.inactive_for?(:feature_name, User.last) #=> true + FEATURE_FLAGS.activate_for(:feature_name, User.first) #=> true FEATURE_FLAGS.active_partially?(:feature_name) #=> true FEATURE_FLAGS.active_for?(:feature_name, User.first) #=> true FEATURE_FLAGS.active_for?(:feature_name, User.last) #=> false + +FEATURE_FLAGS.inactive_partially?(:feature_name) #=> false +FEATURE_FLAGS.inactive_for?(:feature_name, User.first) #=> false +FEATURE_FLAGS.inactive_for?(:feature_name, User.last) #=> true ``` Note that the flag itself has to be active `partially` for any record/object specific settings to work. @@ -299,6 +317,10 @@ if FEATURE_FLAGS.active?(:feature_name) number += 1 end +if FEATURE_FLAGS.inactive?(:feature_name) + number += 1 +end + # or using a block # this code will run only when the :feature_name flag is active (either partially or globally) @@ -306,27 +328,52 @@ FEATURE_FLAGS.when_active(:feature_name) do number += 1 end +# the opposite +FEATURE_FLAGS.when_inactive(:feature_name) do + number += 1 +end + # this code will run only when the :feature_name flag is active globally FEATURE_FLAGS.when_active_globally(:feature_name) do number += 1 end +# the opposite +FEATURE_FLAGS.when_inactive_globally(:feature_name) do + number += 1 +end + # this code will run only when the :feature_name flag is active partially (only for specific records/users) FEATURE_FLAGS.when_active_partially(:feature_name) do number += 1 end -# this code will run only if the :feature_name flag is active partially for the first User +# the opposite +FEATURE_FLAGS.when_inactive_partially(:feature_name) do + number += 1 +end + +# this code will run only if the :feature_name flag is active for the first User FEATURE_FLAGS.when_active_for(:feature_name, User.first) do number += 1 end +# the opposite +FEATURE_FLAGS.when_inactive_for(:feature_name, User.first) do + number += 1 +end + # feature flags that don't exist will return false FEATURE_FLAGS.active?(:non_existant) #=> false +FEATURE_FLAGS.inactive?(:non_existant) #=> true if FEATURE_FLAGS.active_for?(:feature_name, User.first) number += 1 end + +if FEATURE_FLAGS.inactive_for?(:feature_name, User.first) + number += 1 +end ``` #### Adding feature flags @@ -340,7 +387,7 @@ FEATURE_FLAGS.add(:feature_name, 'Description') FEATURE_FLAGS.active?(:feature_name) #=> false FEATURE_FLAGS.active_partially?(:feature_name) #=> false FEATURE_FLAGS.active_globally?(:feature_name) #=> false -FEATURE_FLAGS.active_for?(:feature_active_partially, User.first) #=> false +FEATURE_FLAGS.active_for?(:feature_name, User.first) #=> false # add a new globally active flag FEATURE_FLAGS.add(:active_feature, 'Description', :globally) @@ -370,6 +417,10 @@ FEATURE_FLAGS.remove(:feature_name) FEATURE_FLAGS.active?(:feature_name) #=> false FEATURE_FLAGS.active_partially?(:feature_name) #=> false FEATURE_FLAGS.active_globally?(:feature_name) #=> false + +FEATURE_FLAGS.inactive?(:feature_name) #=> true +FEATURE_FLAGS.inactive_partially?(:feature_name) #=> true +FEATURE_FLAGS.inactive_globally?(:feature_name) #=> true ``` diff --git a/lib/simple_feature_flags.rb b/lib/simple_feature_flags.rb index d03e6d7..033807c 100644 --- a/lib/simple_feature_flags.rb +++ b/lib/simple_feature_flags.rb @@ -10,8 +10,8 @@ module SimpleFeatureFlags UI_CLASS_NAME = '::SimpleFeatureFlags::Ui' WEB_UI_CLASS_NAME = '::SimpleFeatureFlags::Ui::Web' - ACTIVE_GLOBALLY = ['globally', :globally, 'true', true].freeze - ACTIVE_PARTIALLY = ['partially', :partially].freeze + ACTIVE_GLOBALLY = ::Set['globally', :globally, 'true', true].freeze + ACTIVE_PARTIALLY = ::Set['partially', :partially].freeze class NoSuchCommandError < StandardError; end diff --git a/lib/simple_feature_flags/ram_storage.rb b/lib/simple_feature_flags/ram_storage.rb index 4da3a2e..7d7dfcb 100644 --- a/lib/simple_feature_flags/ram_storage.rb +++ b/lib/simple_feature_flags/ram_storage.rb @@ -34,14 +34,26 @@ def active?(feature) false end + def inactive?(feature) + !active?(feature) + end + def active_globally?(feature) ACTIVE_GLOBALLY.include? flags.dig(feature.to_sym, 'active') end + def inactive_globally?(feature) + !active_globally?(feature) + end + def active_partially?(feature) ACTIVE_PARTIALLY.include? flags.dig(feature.to_sym, 'active') end + def inactive_partially?(feature) + !active_partially?(feature) + end + def active_for?(feature, object, object_id_method = CONFIG.default_id_method) return false unless active?(feature) return true if active_globally?(feature) @@ -54,6 +66,10 @@ def active_for?(feature, object, object_id_method = CONFIG.default_id_method) active_ids.include? object.public_send(object_id_method) end + def inactive_for?(feature, object, object_id_method = CONFIG.default_id_method) + !active_for?(feature, object, object_id_method) + end + def exists?(feature) return false if [nil, ''].include? flags[feature.to_sym] @@ -64,28 +80,52 @@ def description(feature) flags.dig(feature.to_sym, 'description') end - def when_active(feature, &block) + def when_active(feature) return unless active?(feature) - block.call + yield + end + + def when_inactive(feature) + return unless inactive?(feature) + + yield end - def when_active_globally(feature, &block) + def when_active_globally(feature) return unless active_globally?(feature) - block.call + yield end - def when_active_partially(feature, &block) + def when_inactive_globally(feature) + return unless inactive_globally?(feature) + + yield + end + + def when_active_partially(feature) return unless active_partially?(feature) - block.call + yield + end + + def when_inactive_partially(feature) + return unless inactive_partially?(feature) + + yield end - def when_active_for(feature, object, object_id_method = CONFIG.default_id_method, &block) + def when_active_for(feature, object, object_id_method = CONFIG.default_id_method) return unless active_for?(feature, object, object_id_method) - block.call + yield + end + + def when_inactive_for(feature, object, object_id_method = CONFIG.default_id_method) + return unless inactive_for?(feature, object, object_id_method) + + yield end def activate(feature) diff --git a/lib/simple_feature_flags/redis_storage.rb b/lib/simple_feature_flags/redis_storage.rb index d7b5675..89e4910 100644 --- a/lib/simple_feature_flags/redis_storage.rb +++ b/lib/simple_feature_flags/redis_storage.rb @@ -33,14 +33,26 @@ def active?(feature) false end + def inactive?(feature) + !active?(feature) + end + def active_globally?(feature) ACTIVE_GLOBALLY.include? redis.hget(feature.to_s, 'active') end + def inactive_globally?(feature) + !active_globally?(feature) + end + def active_partially?(feature) ACTIVE_PARTIALLY.include? redis.hget(feature.to_s, 'active') end + def inactive_partially?(feature) + !active_partially?(feature) + end + def active_for?(feature, object, object_id_method = CONFIG.default_id_method) return false unless active?(feature) return true if active_globally?(feature) @@ -53,6 +65,10 @@ def active_for?(feature, object, object_id_method = CONFIG.default_id_method) active_ids.include? object.public_send(object_id_method) end + def inactive_for?(feature, object, object_id_method = CONFIG.default_id_method) + !active_for?(feature, object, object_id_method) + end + def exists?(feature) return false if [nil, ''].include? redis.hget(feature.to_s, 'name') @@ -63,28 +79,52 @@ def description(feature) redis.hget(feature.to_s, 'description') end - def when_active(feature, &block) + def when_active(feature) return unless active?(feature) - block.call + yield + end + + def when_inactive(feature) + return unless inactive?(feature) + + yield end - def when_active_globally(feature, &block) + def when_active_globally(feature) return unless active_globally?(feature) - block.call + yield end - def when_active_partially(feature, &block) + def when_inactive_globally(feature) + return unless inactive_globally?(feature) + + yield + end + + def when_active_partially(feature) return unless active_partially?(feature) - block.call + yield + end + + def when_inactive_partially(feature) + return unless inactive_partially?(feature) + + yield end - def when_active_for(feature, object, object_id_method = CONFIG.default_id_method, &block) + def when_active_for(feature, object, object_id_method = CONFIG.default_id_method) return unless active_for?(feature, object, object_id_method) - block.call + yield + end + + def when_inactive_for(feature, object, object_id_method = CONFIG.default_id_method) + return unless inactive_for?(feature, object, object_id_method) + + yield end def activate(feature) diff --git a/test/support/universal_storage_tests.rb b/test/support/universal_storage_tests.rb index 47ca6de..8651508 100644 --- a/test/support/universal_storage_tests.rb +++ b/test/support/universal_storage_tests.rb @@ -6,7 +6,10 @@ class TestObject def test_correctly_import_flags_from_yaml assert @feature_flags.active?('feature_one') + assert !@feature_flags.inactive?('feature_one') + assert !@feature_flags.active?('feature_two') + assert @feature_flags.inactive?('feature_two') assert !@feature_flags.exists?('feature_remove') @@ -18,17 +21,32 @@ def test_correctly_import_flags_from_yaml end assert_equal 3, number - @feature_flags.when_active('feature_two') do + @feature_flags.when_inactive('feature_one') do number += 1 end assert_equal 3, number + @feature_flags.when_active('feature_two') do + number += 1 + end assert_equal 3, number + @feature_flags.when_inactive('feature_two') do + number += 1 + end + assert_equal 4, number + + assert_equal 4, number + @feature_flags.when_active('feature_three') do number += 1 end - assert_equal 3, number + assert_equal 4, number + + @feature_flags.when_inactive('feature_three') do + number += 1 + end + assert_equal 5, number end def test_add_a_new_feature @@ -36,6 +54,7 @@ def test_add_a_new_feature assert @feature_flags.add('feature_three', 'Some new description') assert !@feature_flags.active?('feature_three') + assert @feature_flags.inactive?('feature_three') assert_equal 'Some new description', @feature_flags.description('feature_three') @@ -43,6 +62,7 @@ def test_add_a_new_feature assert @feature_flags.add('feature_four', 'Some other new description', true) assert @feature_flags.active?('feature_four') + assert !@feature_flags.inactive?('feature_four') assert_equal 'Some other new description', @feature_flags.description('feature_four') @@ -54,6 +74,7 @@ def test_not_add_a_new_feature_when_it_exists assert !@feature_flags.add('feature_one', 'Some new description') assert @feature_flags.active?('feature_one') + assert !@feature_flags.inactive?('feature_one') assert_equal 'Some description', @feature_flags.description('feature_one') assert_equal 3, @feature_flags.all.size @@ -65,6 +86,8 @@ def test_remove_a_feature assert @feature_flags.remove(:feature_one) assert !@feature_flags.active?('feature_one') assert !@feature_flags.active?(:feature_one) + assert @feature_flags.inactive?('feature_one') + assert @feature_flags.inactive?(:feature_one) assert !@feature_flags.exists?(:feature_one) assert !@feature_flags.exists?('feature_one') @@ -76,6 +99,7 @@ def test_not_remove_a_feature_when_it_does_not_exist assert !@feature_flags.remove('feature_three') assert !@feature_flags.active?('feature_three') + assert @feature_flags.inactive?('feature_three') assert_equal 3, @feature_flags.all.size end @@ -86,6 +110,8 @@ def test_activate_a_feature @feature_flags.activate(:feature_two) assert @feature_flags.active?('feature_two') assert @feature_flags.active?(:feature_two) + assert !@feature_flags.inactive?('feature_two') + assert !@feature_flags.inactive?(:feature_two) assert_equal 3, @feature_flags.all.size end @@ -95,6 +121,7 @@ def test_not_activate_a_feature_when_it_does_not_exist assert !@feature_flags.activate('feature_three') assert !@feature_flags.active?('feature_three') + assert @feature_flags.inactive?('feature_three') assert_equal 3, @feature_flags.all.size end @@ -104,6 +131,7 @@ def test_deactivate_a_feature assert @feature_flags.deactivate(:feature_one) assert !@feature_flags.active?('feature_one') + assert @feature_flags.inactive?('feature_one') assert_equal 3, @feature_flags.all.size end @@ -113,6 +141,7 @@ def test_not_deactivate_a_feature_when_it_does_not_exist assert !@feature_flags.deactivate('feature_three') assert !@feature_flags.active?('feature_three') + assert @feature_flags.inactive?('feature_three') assert_equal 3, @feature_flags.all.size end @@ -128,30 +157,52 @@ def test_activate_an_active_flag_for_a_model assert @feature_flags.activate_partially(:feature_one) assert @feature_flags.active?(:feature_one) + assert !@feature_flags.inactive?(:feature_one) + assert !@feature_flags.active_globally?(:feature_one) + assert @feature_flags.inactive_globally?(:feature_one) assert @feature_flags.active_partially?(:feature_one) + assert !@feature_flags.inactive_partially?(:feature_one) + assert !@feature_flags.active_for?(:feature_one, test_object) assert !@feature_flags.active_for?(:feature_one, test_object_two) + assert @feature_flags.inactive_for?(:feature_one, test_object) + assert @feature_flags.inactive_for?(:feature_one, test_object_two) @feature_flags.when_active_for(:feature_one, test_object) do test_value += 1 end - assert_equal 1, test_value + @feature_flags.when_inactive_for(:feature_one, test_object) do + test_value += 1 + end + assert_equal 2, test_value + assert @feature_flags.activate_for(:feature_one, test_object) assert @feature_flags.active?(:feature_one) + assert !@feature_flags.inactive?(:feature_one) + assert !@feature_flags.active_globally?(:feature_one) assert @feature_flags.active_partially?(:feature_one) + assert @feature_flags.inactive_globally?(:feature_one) + assert !@feature_flags.inactive_partially?(:feature_one) + assert @feature_flags.active_for?(:feature_one, test_object) assert !@feature_flags.active_for?(:feature_one, test_object_two) + assert !@feature_flags.inactive_for?(:feature_one, test_object) + assert @feature_flags.inactive_for?(:feature_one, test_object_two) @feature_flags.when_active_for(:feature_one, test_object) do test_value += 1 end + assert_equal 3, test_value - assert_equal 2, test_value + @feature_flags.when_inactive_for(:feature_one, test_object) do + test_value += 1 + end + assert_equal 3, test_value end def test_not_activate_a_deactivated_flag_for_a_model @@ -161,15 +212,23 @@ def test_not_activate_a_deactivated_flag_for_a_model test_value = 1 assert !@feature_flags.active?(:feature_two) + assert @feature_flags.inactive?(:feature_two) + assert !@feature_flags.active_for?(:feature_two, test_object) assert !@feature_flags.active_for?(:feature_two, test_object_two) + assert @feature_flags.inactive_for?(:feature_two, test_object) + assert @feature_flags.inactive_for?(:feature_two, test_object_two) @feature_flags.when_active_for(:feature_two, test_object) do test_value += 1 end - assert_equal 1, test_value + @feature_flags.when_inactive_for(:feature_two, test_object) do + test_value += 1 + end + assert_equal 2, test_value + assert @feature_flags.activate_for(:feature_two, test_object) assert !@feature_flags.active?(:feature_two) assert !@feature_flags.active_for?(:feature_two, test_object) @@ -178,8 +237,12 @@ def test_not_activate_a_deactivated_flag_for_a_model @feature_flags.when_active_for(:feature_two, test_object) do test_value += 1 end + assert_equal 2, test_value - assert_equal 1, test_value + @feature_flags.when_inactive_for(:feature_two, test_object) do + test_value += 1 + end + assert_equal 3, test_value assert @feature_flags.activate_partially(:feature_two) assert @feature_flags.active?(:feature_two) @@ -191,12 +254,22 @@ def test_not_activate_a_deactivated_flag_for_a_model @feature_flags.when_active_for(:feature_two, test_object) do test_value += 1 end + assert_equal 4, test_value + + @feature_flags.when_inactive_for(:feature_two, test_object) do + test_value += 1 + end + assert_equal 4, test_value @feature_flags.when_active_partially(:feature_two) do test_value += 1 end + assert_equal 5, test_value - assert_equal 3, test_value + @feature_flags.when_inactive_partially(:feature_two) do + test_value += 1 + end + assert_equal 5, test_value end def test_activate_a_flag_globally @@ -207,6 +280,10 @@ def test_activate_a_flag_globally assert !@feature_flags.active_for?(:feature_two, test_object) assert !@feature_flags.active_for?(:feature_two, test_object_two) + assert @feature_flags.inactive?(:feature_two) + assert @feature_flags.inactive_for?(:feature_two, test_object) + assert @feature_flags.inactive_for?(:feature_two, test_object_two) + assert @feature_flags.activate(:feature_two) assert @feature_flags.active?(:feature_two) @@ -214,6 +291,12 @@ def test_activate_a_flag_globally assert !@feature_flags.active_partially?(:feature_two) assert @feature_flags.active_for?(:feature_two, test_object) assert @feature_flags.active_for?(:feature_two, test_object_two) + + assert !@feature_flags.inactive?(:feature_two) + assert !@feature_flags.inactive_globally?(:feature_two) + assert @feature_flags.inactive_partially?(:feature_two) + assert !@feature_flags.inactive_for?(:feature_two, test_object) + assert !@feature_flags.inactive_for?(:feature_two, test_object_two) end def test_activate_an_active_flag_for_model_with_custom_id_method @@ -228,11 +311,20 @@ def test_activate_an_active_flag_for_model_with_custom_id_method assert !@feature_flags.active_for?(:feature_one, test_object, :object_id) assert !@feature_flags.active_for?(:feature_one, test_object_two, :object_id) + assert !@feature_flags.inactive?(:feature_one) + assert !@feature_flags.inactive_partially?(:feature_one) + assert @feature_flags.inactive_for?(:feature_one, test_object, :object_id) + assert @feature_flags.inactive_for?(:feature_one, test_object_two, :object_id) + assert @feature_flags.activate_for(:feature_one, test_object, :object_id) assert @feature_flags.active?(:feature_one) assert @feature_flags.active_for?(:feature_one, test_object, :object_id) assert !@feature_flags.active_for?(:feature_one, test_object_two, :object_id) + + assert !@feature_flags.inactive?(:feature_one) + assert !@feature_flags.inactive_for?(:feature_one, test_object, :object_id) + assert @feature_flags.inactive_for?(:feature_one, test_object_two, :object_id) end def test_activate_a_flag_for_multiple_models @@ -247,10 +339,19 @@ def test_activate_a_flag_for_multiple_models assert !@feature_flags.active_for?(:feature_one, test_object_two) assert !@feature_flags.active_for?(:feature_one, test_object_three) + assert @feature_flags.inactive_for?(:feature_one, test_object) + assert @feature_flags.inactive_for?(:feature_one, test_object_two) + assert @feature_flags.inactive_for?(:feature_one, test_object_three) + assert @feature_flags.activate_for(:feature_one, [test_object, test_object_two]) + assert @feature_flags.active_for?(:feature_one, test_object) assert @feature_flags.active_for?(:feature_one, test_object_two) assert !@feature_flags.active_for?(:feature_one, test_object_three) + + assert !@feature_flags.inactive_for?(:feature_one, test_object) + assert !@feature_flags.inactive_for?(:feature_one, test_object_two) + assert @feature_flags.inactive_for?(:feature_one, test_object_three) end def test_deactivate_a_flag_for_a_model @@ -265,14 +366,22 @@ def test_deactivate_a_flag_for_a_model assert @feature_flags.active_for?(:feature_one, test_object) assert !@feature_flags.active_for?(:feature_one, test_object_two) + assert !@feature_flags.inactive?(:feature_one) + assert !@feature_flags.inactive_for?(:feature_one, test_object) + assert @feature_flags.inactive_for?(:feature_one, test_object_two) + assert @feature_flags.deactivate_for(:feature_one, test_object) assert @feature_flags.active?(:feature_one) assert !@feature_flags.active_for?(:feature_one, test_object) assert !@feature_flags.active_for?(:feature_one, test_object_two) + + assert !@feature_flags.inactive?(:feature_one) + assert @feature_flags.inactive_for?(:feature_one, test_object) + assert @feature_flags.inactive_for?(:feature_one, test_object_two) end - def test_deactivate_a_flag_for_multiple_model + def test_deactivate_a_flag_for_multiple_models test_object = TestObject.new test_object_two = TestObject.new test_object_three = TestObject.new @@ -286,12 +395,22 @@ def test_deactivate_a_flag_for_multiple_model assert @feature_flags.active_for?(:feature_one, test_object_two) assert !@feature_flags.active_for?(:feature_one, test_object_three) + assert !@feature_flags.inactive?(:feature_one) + assert !@feature_flags.inactive_for?(:feature_one, test_object) + assert !@feature_flags.inactive_for?(:feature_one, test_object_two) + assert @feature_flags.inactive_for?(:feature_one, test_object_three) + assert @feature_flags.deactivate_for(:feature_one, [test_object, test_object_two]) assert @feature_flags.active?(:feature_one) assert !@feature_flags.active_for?(:feature_one, test_object) assert !@feature_flags.active_for?(:feature_one, test_object_two) assert !@feature_flags.active_for?(:feature_one, test_object_three) + + assert !@feature_flags.inactive?(:feature_one) + assert @feature_flags.inactive_for?(:feature_one, test_object) + assert @feature_flags.inactive_for?(:feature_one, test_object_two) + assert @feature_flags.inactive_for?(:feature_one, test_object_three) end def test_deactivate_globally @@ -310,6 +429,13 @@ def test_deactivate_globally assert @feature_flags.active_for?(:feature_one, test_object_two) assert !@feature_flags.active_for?(:feature_one, test_object_three) + assert !@feature_flags.inactive?(:feature_one) + assert !@feature_flags.inactive_partially?(:feature_one) + assert @feature_flags.inactive_globally?(:feature_one) + assert !@feature_flags.inactive_for?(:feature_one, test_object) + assert !@feature_flags.inactive_for?(:feature_one, test_object_two) + assert @feature_flags.inactive_for?(:feature_one, test_object_three) + assert @feature_flags.deactivate(:feature_one) assert !@feature_flags.active?(:feature_one) @@ -318,6 +444,13 @@ def test_deactivate_globally assert !@feature_flags.active_for?(:feature_one, test_object) assert !@feature_flags.active_for?(:feature_one, test_object_two) assert !@feature_flags.active_for?(:feature_one, test_object_three) + + assert @feature_flags.inactive?(:feature_one) + assert @feature_flags.inactive_partially?(:feature_one) + assert @feature_flags.inactive_globally?(:feature_one) + assert @feature_flags.inactive_for?(:feature_one, test_object) + assert @feature_flags.inactive_for?(:feature_one, test_object_two) + assert @feature_flags.inactive_for?(:feature_one, test_object_three) end end end \ No newline at end of file