Commit 93883dba authored by jejacks0n's avatar jejacks0n

Assign key as variable

- With some minor spec adjustments
parent 55810a99
......@@ -43,12 +43,12 @@ class ApplicationExperiment < Gitlab::Experiment
# Clears the entire cache for a given experiment. Be careful with this
# since it would reset all resolved variants for the entire experiment.
def clear(key:)
key = hkey(key)[0] # extract only the first part of the key
pool do |redis|
unless %w[hash none].include?(redis.type(hkey(key)[0]))
raise ArgumentError, 'invalid call to clear a non-hash cache key'
case redis.type(key)
when 'hash', 'none' then redis.del(key)
else raise ArgumentError, 'invalid call to clear a non-hash cache key'
end
redis.del(hkey(key)[0])
end
end
......
......@@ -14,7 +14,7 @@ RSpec.describe ApplicationExperiment::Cache do
shared_state.with { |r| r.del(key_name) }
end
it "allows reading, writing and deleting" do
it "allows reading, writing and deleting", :aggregate_failures do
# we test them all together because they are largely interdependent
expect(subject.read(key_field)).to be_nil
......
......@@ -69,7 +69,7 @@ RSpec.describe ApplicationExperiment do
expect(subject.variant.name).to eq('control')
end
context "when the rollout out to 100%" do
context "when rolled out to 100%" do
it "returns the first variant name" do
subject.try(:variant1) {}
subject.try(:variant2) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment