verdict 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/CHANGELOG.md +3 -0
- data/lib/verdict/experiment.rb +13 -2
- data/lib/verdict/version.rb +1 -1
- data/test/experiment_test.rb +18 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50c44fd8fcc0cf5605c9d21fd5eefcd4dddeffeb03c48e7ec046639d7154715b
|
4
|
+
data.tar.gz: d55759fff1145aa793f9ae42232518130ba93efcb5fb62a2f7cbfa24d0322a0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ed63a2aaf52ebffe454da41e3022e87df834b80130cb0ab14902466ea6d630ce9d046e1b202e32fc6491a2dc9974f4f825f50aaa14aa862103888f31d5c3df6
|
7
|
+
data.tar.gz: 12c379615c6593caf46749157ebca884d91fb17a97d81b7fc60c53cd3531785a0a0c078e79e4b387cd21676f26d55962e0a2ab1ba0caeacb5d99208c3f1e8f8d
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## v0.15.2
|
2
|
+
* Fix edge case where inheriting from `Verdict::Experiment` and overriding `subject_qualifies?` resulted in an error.
|
3
|
+
|
1
4
|
## v0.15.1
|
2
5
|
* Make the `dynamic_qualifies` parameter in `Verdict::Experiment#subject_qualifies?` optional. This fixes a bug where users that were previously calling this method directly experienced issues after v0.15.0
|
3
6
|
|
data/lib/verdict/experiment.rb
CHANGED
@@ -148,7 +148,7 @@ class Verdict::Experiment
|
|
148
148
|
subject_identifier = retrieve_subject_identifier(subject)
|
149
149
|
assignment = if previous_assignment
|
150
150
|
previous_assignment
|
151
|
-
elsif
|
151
|
+
elsif dynamic_subject_qualifies?(subject, dynamic_qualifiers, context) && is_make_new_assignments?
|
152
152
|
group = segmenter.assign(subject_identifier, subject, context)
|
153
153
|
subject_assignment(subject, group, nil, group.nil?)
|
154
154
|
else
|
@@ -243,7 +243,7 @@ class Verdict::Experiment
|
|
243
243
|
@disqualify_empty_identifier
|
244
244
|
end
|
245
245
|
|
246
|
-
def subject_qualifies?(subject,
|
246
|
+
def subject_qualifies?(subject, context = nil, dynamic_qualifiers: [])
|
247
247
|
ensure_experiment_has_started
|
248
248
|
return false unless dynamic_qualifiers.all? { |qualifier| qualifier.call(subject) }
|
249
249
|
everybody_qualifies? || @qualifiers.all? { |qualifier| qualifier.call(subject, context) }
|
@@ -295,4 +295,15 @@ class Verdict::Experiment
|
|
295
295
|
def is_make_new_assignments?
|
296
296
|
return !(@schedule_stop_new_assignment_timestamp && @schedule_stop_new_assignment_timestamp <= Time.now)
|
297
297
|
end
|
298
|
+
|
299
|
+
# Used when a Experiment class has overridden the subject_qualifies? method prior to v0.15.0
|
300
|
+
# The previous version of subject_qualifies did not accept dynamic qualifiers, thus this is used to
|
301
|
+
# determine how many parameters to pass
|
302
|
+
def dynamic_subject_qualifies?(subject, dynamic_qualifiers, context)
|
303
|
+
if method(:subject_qualifies?).parameters.include?([:key, :dynamic_qualifiers])
|
304
|
+
subject_qualifies?(subject, context, dynamic_qualifiers: dynamic_qualifiers)
|
305
|
+
else
|
306
|
+
subject_qualifies?(subject, context)
|
307
|
+
end
|
308
|
+
end
|
298
309
|
end
|
data/lib/verdict/version.rb
CHANGED
data/test/experiment_test.rb
CHANGED
@@ -668,15 +668,31 @@ class ExperimentTest < Minitest::Test
|
|
668
668
|
custom_qualifier_a = Proc.new { |subject| subject.even? }
|
669
669
|
custom_qualifier_b = Proc.new { |subject| subject > 0 }
|
670
670
|
|
671
|
-
e.switch(subject, qualifiers: [custom_qualifier_a, custom_qualifier_b])
|
672
|
-
|
673
671
|
group = e.switch(subject, qualifiers: [custom_qualifier_a, custom_qualifier_b])
|
674
672
|
assert_nil group
|
675
673
|
end
|
676
674
|
|
675
|
+
def test_dynamic_subject_qualifies_call_overridden_method
|
676
|
+
e = MyExperiment.new('test') do
|
677
|
+
groups do
|
678
|
+
group :all, 100
|
679
|
+
end
|
680
|
+
end
|
681
|
+
|
682
|
+
group = e.switch(4)
|
683
|
+
assert_nil group
|
684
|
+
end
|
685
|
+
|
677
686
|
private
|
678
687
|
|
679
688
|
def redis
|
680
689
|
@redis ||= ::Redis.new(host: REDIS_HOST, port: REDIS_PORT)
|
681
690
|
end
|
682
691
|
end
|
692
|
+
|
693
|
+
class MyExperiment < Verdict::Experiment
|
694
|
+
def subject_qualifies?(subject, context = nil)
|
695
|
+
return false if subject.even?
|
696
|
+
super
|
697
|
+
end
|
698
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: verdict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|