summaryrefslogtreecommitdiff
path: root/lib/feature.rb
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2018-08-20 20:52:56 +0200
committerGabriel Mazetto <brodock@gmail.com>2018-08-22 05:41:15 +0200
commit61c35b6ca1840507f5da3aa4d951e4273e612d66 (patch)
tree7c248fec944fd3a4604086ec8ccfaf313c85f0a1 /lib/feature.rb
parenta440c2be018e79ee671543c2c96cc1f741336fde (diff)
downloadgitlab-ce-61c35b6ca1840507f5da3aa4d951e4273e612d66.tar.gz
Fixed `stub_feature_flag behavior` for `disabled?` flags.
Previous code would not work with `disabled?` because that method would send two parameters (second always `nil`) which we are not mocking. Instead of mock yet another state, I decide to fix it where it belongs.
Diffstat (limited to 'lib/feature.rb')
-rw-r--r--lib/feature.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/feature.rb b/lib/feature.rb
index 09c5ef3ad94..24dbcb32fc0 100644
--- a/lib/feature.rb
+++ b/lib/feature.rb
@@ -47,7 +47,8 @@ class Feature
end
def disabled?(key, thing = nil)
- !enabled?(key, thing)
+ # we need to make different method calls to make it easy to mock / define expectations in test mode
+ thing.nil? ? !enabled?(key) : !enabled?(key, thing)
end
def enable(key, thing = true)