Add FeatureFlag.all (#16496)
This commit is contained in:
parent
12b9aa4fc8
commit
a91e505051
2 changed files with 18 additions and 0 deletions
|
|
@ -44,5 +44,13 @@ module FeatureFlag
|
|||
|
||||
enabled?(feature_flag_name, *args)
|
||||
end
|
||||
|
||||
# Retrieve a list of all currently defined flags and their status. This is
|
||||
# primarily intended for development and wraps +Flipper.features+.
|
||||
#
|
||||
# @return [Hash<Symbol, Symbol>] the defined flags with their status (+:on+ or +:off+).
|
||||
def all
|
||||
Flipper.features.to_h { |feature| [feature.name.to_sym, feature.state] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -99,4 +99,14 @@ describe FeatureFlag, type: :service do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe ".all", :aggregate_failures do
|
||||
it "returns a hash with all feature flags and their status" do
|
||||
described_class.enable(:flag1)
|
||||
expect(described_class.all).to eq({ flag1: :on })
|
||||
|
||||
described_class.disable(:flag2)
|
||||
expect(described_class.all).to eq({ flag1: :on, flag2: :off })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue