vanity 3.1.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/linting.yml +28 -0
- data/.github/workflows/test.yml +3 -6
- data/.rubocop.yml +114 -0
- data/.rubocop_todo.yml +67 -0
- data/Appraisals +9 -31
- data/CHANGELOG +5 -0
- data/Gemfile +7 -3
- data/Gemfile.lock +31 -3
- data/README.md +4 -9
- data/Rakefile +25 -24
- data/bin/vanity +1 -1
- data/doc/configuring.textile +1 -0
- data/gemfiles/rails52.gemfile +6 -3
- data/gemfiles/rails52.gemfile.lock +34 -9
- data/gemfiles/rails60.gemfile +6 -3
- data/gemfiles/rails60.gemfile.lock +34 -9
- data/gemfiles/rails61.gemfile +6 -3
- data/gemfiles/rails61.gemfile.lock +34 -9
- data/lib/generators/vanity/migration_generator.rb +5 -7
- data/lib/vanity/adapters/abstract_adapter.rb +43 -45
- data/lib/vanity/adapters/active_record_adapter.rb +30 -30
- data/lib/vanity/adapters/mock_adapter.rb +14 -18
- data/lib/vanity/adapters/mongodb_adapter.rb +73 -69
- data/lib/vanity/adapters/redis_adapter.rb +19 -27
- data/lib/vanity/adapters.rb +1 -1
- data/lib/vanity/autoconnect.rb +6 -7
- data/lib/vanity/commands/list.rb +7 -7
- data/lib/vanity/commands/report.rb +18 -22
- data/lib/vanity/configuration.rb +19 -19
- data/lib/vanity/connection.rb +12 -14
- data/lib/vanity/experiment/ab_test.rb +82 -70
- data/lib/vanity/experiment/alternative.rb +3 -5
- data/lib/vanity/experiment/base.rb +24 -19
- data/lib/vanity/experiment/bayesian_bandit_score.rb +7 -13
- data/lib/vanity/experiment/definition.rb +6 -6
- data/lib/vanity/frameworks/rails.rb +39 -39
- data/lib/vanity/frameworks.rb +2 -2
- data/lib/vanity/helpers.rb +1 -1
- data/lib/vanity/metric/active_record.rb +21 -19
- data/lib/vanity/metric/base.rb +22 -23
- data/lib/vanity/metric/google_analytics.rb +6 -9
- data/lib/vanity/metric/remote.rb +3 -5
- data/lib/vanity/playground.rb +3 -6
- data/lib/vanity/vanity.rb +8 -12
- data/lib/vanity/version.rb +1 -1
- data/test/adapters/active_record_adapter_test.rb +1 -5
- data/test/adapters/mock_adapter_test.rb +0 -2
- data/test/adapters/mongodb_adapter_test.rb +1 -5
- data/test/adapters/redis_adapter_test.rb +2 -3
- data/test/adapters/shared_tests.rb +9 -12
- data/test/autoconnect_test.rb +3 -3
- data/test/cli_test.rb +0 -1
- data/test/configuration_test.rb +18 -34
- data/test/connection_test.rb +3 -3
- data/test/dummy/Rakefile +1 -1
- data/test/dummy/app/controllers/use_vanity_controller.rb +12 -8
- data/test/dummy/app/mailers/vanity_mailer.rb +3 -3
- data/test/dummy/config/application.rb +1 -1
- data/test/dummy/config/boot.rb +3 -3
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/development.rb +0 -1
- data/test/dummy/config/environments/test.rb +1 -1
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/dummy/config.ru +1 -1
- data/test/dummy/script/rails +2 -2
- data/test/experiment/ab_test.rb +148 -154
- data/test/experiment/base_test.rb +48 -32
- data/test/frameworks/rails/action_controller_test.rb +25 -25
- data/test/frameworks/rails/action_mailer_test.rb +2 -2
- data/test/frameworks/rails/action_view_test.rb +5 -6
- data/test/frameworks/rails/rails_test.rb +147 -181
- data/test/helper_test.rb +2 -2
- data/test/metric/active_record_test.rb +174 -212
- data/test/metric/base_test.rb +21 -46
- data/test/metric/google_analytics_test.rb +17 -25
- data/test/metric/remote_test.rb +7 -10
- data/test/playground_test.rb +7 -14
- data/test/templates_test.rb +16 -20
- data/test/test_helper.rb +28 -29
- data/test/vanity_test.rb +4 -10
- data/test/web/rails/dashboard_test.rb +21 -21
- data/vanity.gemspec +8 -7
- metadata +28 -30
- data/gemfiles/rails42.gemfile +0 -33
- data/gemfiles/rails42.gemfile.lock +0 -265
- data/gemfiles/rails42_protected_attributes.gemfile +0 -34
- data/gemfiles/rails42_protected_attributes.gemfile.lock +0 -264
- data/gemfiles/rails51.gemfile +0 -33
- data/gemfiles/rails51.gemfile.lock +0 -285
@@ -1,7 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Vanity::Experiment::Base do
|
4
|
-
|
5
4
|
before do
|
6
5
|
metric "Happiness"
|
7
6
|
end
|
@@ -9,28 +8,28 @@ describe Vanity::Experiment::Base do
|
|
9
8
|
# -- Defining experiment --
|
10
9
|
|
11
10
|
it "can access experiment by id" do
|
12
|
-
exp = new_ab_test(:ice_cream_flavor)
|
11
|
+
exp = new_ab_test(:ice_cream_flavor) do
|
12
|
+
metrics :happiness
|
13
|
+
default false
|
14
|
+
end
|
13
15
|
assert_equal exp, experiment(:ice_cream_flavor)
|
14
16
|
end
|
15
17
|
|
16
18
|
it "fails when defining same experiment twice" do
|
17
|
-
File.
|
18
|
-
f.write <<-RUBY
|
19
|
+
File.write("tmp/experiments/ice_cream_flavor.rb", <<-RUBY)
|
19
20
|
ab_test "Ice Cream Flavor" do
|
20
21
|
default false
|
21
22
|
end
|
22
23
|
ab_test "Ice Cream Flavor" do
|
23
24
|
default false
|
24
25
|
end
|
25
|
-
|
26
|
-
end
|
26
|
+
RUBY
|
27
27
|
Vanity.unload!
|
28
28
|
assert_raises NameError do
|
29
29
|
experiment(:ice_cream_flavor)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
33
|
# -- Loading experiments --
|
35
34
|
|
36
35
|
it "fails if cannot load named experiment" do
|
@@ -40,24 +39,20 @@ describe Vanity::Experiment::Base do
|
|
40
39
|
end
|
41
40
|
|
42
41
|
it "loads the experiment" do
|
43
|
-
File.
|
44
|
-
f.write <<-RUBY
|
42
|
+
File.write("tmp/experiments/ice_cream_flavor.rb", <<-RUBY)
|
45
43
|
ab_test "Ice Cream Flavor" do
|
46
44
|
def xmts
|
47
45
|
"x"
|
48
46
|
end
|
49
47
|
default false
|
50
48
|
end
|
51
|
-
|
52
|
-
end
|
49
|
+
RUBY
|
53
50
|
Vanity.unload!
|
54
51
|
assert_equal "x", experiment(:ice_cream_flavor).xmts
|
55
52
|
end
|
56
53
|
|
57
54
|
it "fails if error loading experiment" do
|
58
|
-
File.
|
59
|
-
f.write "fail 'yawn!'"
|
60
|
-
end
|
55
|
+
File.write("tmp/experiments/ice_cream_flavor.rb", "fail 'yawn!'")
|
61
56
|
Vanity.unload!
|
62
57
|
assert_raises NameError do
|
63
58
|
experiment(:ice_cream_flavor)
|
@@ -65,9 +60,7 @@ describe Vanity::Experiment::Base do
|
|
65
60
|
end
|
66
61
|
|
67
62
|
it "complains if not defined where expected" do
|
68
|
-
File.
|
69
|
-
f.write ""
|
70
|
-
end
|
63
|
+
File.write("tmp/experiments/ice_cream_flavor.rb", "")
|
71
64
|
Vanity.unload!
|
72
65
|
assert_raises NameError do
|
73
66
|
experiment(:ice_cream_flavor)
|
@@ -75,37 +68,46 @@ describe Vanity::Experiment::Base do
|
|
75
68
|
end
|
76
69
|
|
77
70
|
it "reloading experiments" do
|
78
|
-
new_ab_test(:ab)
|
79
|
-
|
71
|
+
new_ab_test(:ab) do
|
72
|
+
metrics :happiness
|
73
|
+
default false
|
74
|
+
end
|
75
|
+
new_ab_test(:cd) do
|
76
|
+
metrics :happiness
|
77
|
+
default false
|
78
|
+
end
|
80
79
|
assert_equal 2, Vanity.playground.experiments.size
|
81
80
|
Vanity.playground.reload!
|
82
81
|
assert Vanity.playground.experiments.empty?
|
83
82
|
end
|
84
83
|
|
85
|
-
|
86
84
|
# -- Attributes --
|
87
85
|
|
88
86
|
it "maps the experiment name to id" do
|
89
|
-
experiment = new_ab_test("Ice Cream Flavor/Tastes")
|
87
|
+
experiment = new_ab_test("Ice Cream Flavor/Tastes") do
|
88
|
+
metrics :happiness
|
89
|
+
default false
|
90
|
+
end
|
90
91
|
assert_equal "Ice Cream Flavor/Tastes", experiment.name
|
91
92
|
assert_equal :ice_cream_flavor_tastes, experiment.id
|
92
93
|
end
|
93
94
|
|
94
95
|
it "saves the experiment after definition" do
|
95
|
-
File.
|
96
|
-
f.write <<-RUBY
|
96
|
+
File.write("tmp/experiments/ice_cream_flavor.rb", <<-RUBY)
|
97
97
|
ab_test "Ice Cream Flavor" do
|
98
98
|
default false
|
99
99
|
end
|
100
|
-
|
101
|
-
end
|
100
|
+
RUBY
|
102
101
|
Vanity.unload!
|
103
102
|
metric :happiness
|
104
103
|
Vanity.playground.experiment(:ice_cream_flavor)
|
105
104
|
end
|
106
105
|
|
107
106
|
it "has created timestamp" do
|
108
|
-
new_ab_test(:ice_cream_flavor)
|
107
|
+
new_ab_test(:ice_cream_flavor) do
|
108
|
+
metrics :happiness
|
109
|
+
default false
|
110
|
+
end
|
109
111
|
assert_kind_of Time, experiment(:ice_cream_flavor).created_at
|
110
112
|
assert_in_delta experiment(:ice_cream_flavor).created_at.to_i, Time.now.to_i, 1
|
111
113
|
end
|
@@ -113,12 +115,18 @@ describe Vanity::Experiment::Base do
|
|
113
115
|
it "keeps created timestamp across definitions" do
|
114
116
|
past = Date.today - 1
|
115
117
|
Timecop.freeze past.to_time do
|
116
|
-
new_ab_test(:ice_cream_flavor)
|
118
|
+
new_ab_test(:ice_cream_flavor) do
|
119
|
+
metrics :happiness
|
120
|
+
default false
|
121
|
+
end
|
117
122
|
end
|
118
123
|
|
119
124
|
vanity_reset
|
120
125
|
metric :happiness
|
121
|
-
new_ab_test(:ice_cream_flavor)
|
126
|
+
new_ab_test(:ice_cream_flavor) do
|
127
|
+
metrics :happiness
|
128
|
+
default false
|
129
|
+
end
|
122
130
|
assert_equal past.to_time.to_i, experiment(:ice_cream_flavor).created_at.to_i
|
123
131
|
end
|
124
132
|
|
@@ -133,7 +141,10 @@ describe Vanity::Experiment::Base do
|
|
133
141
|
|
134
142
|
it "stores nothing when collection disabled" do
|
135
143
|
not_collecting!
|
136
|
-
new_ab_test(:ice_cream_flavor)
|
144
|
+
new_ab_test(:ice_cream_flavor) do
|
145
|
+
metrics :happiness
|
146
|
+
default false
|
147
|
+
end
|
137
148
|
experiment(:ice_cream_flavor).complete!
|
138
149
|
end
|
139
150
|
|
@@ -142,7 +153,10 @@ describe Vanity::Experiment::Base do
|
|
142
153
|
# check_completion is called by derived classes, but since it's
|
143
154
|
# part of the base_test I'm testing it here.
|
144
155
|
it "handles error in check completion" do
|
145
|
-
new_ab_test(:ab)
|
156
|
+
new_ab_test(:ab) do
|
157
|
+
metrics :happiness
|
158
|
+
default false
|
159
|
+
end
|
146
160
|
e = experiment(:ab)
|
147
161
|
e.complete_if { true }
|
148
162
|
e.stubs(:complete!).raises(RuntimeError, "A forced error")
|
@@ -152,7 +166,10 @@ describe Vanity::Experiment::Base do
|
|
152
166
|
end
|
153
167
|
|
154
168
|
it "complete updates completed_at" do
|
155
|
-
new_ab_test(:ice_cream_flavor)
|
169
|
+
new_ab_test(:ice_cream_flavor) do
|
170
|
+
metrics :happiness
|
171
|
+
default false
|
172
|
+
end
|
156
173
|
|
157
174
|
time = Time.utc(2008, 9, 1, 12, 0, 0)
|
158
175
|
Timecop.freeze(time) do
|
@@ -160,5 +177,4 @@ describe Vanity::Experiment::Base do
|
|
160
177
|
end
|
161
178
|
assert_equal time, experiment(:ice_cream_flavor).completed_at
|
162
179
|
end
|
163
|
-
|
164
180
|
end
|
@@ -19,9 +19,7 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# Rails 3 configuration for cookies
|
22
|
-
if ::Rails.respond_to?(:application)
|
23
|
-
::Rails.application.config.session_options[:domain] = '.foo.bar'
|
24
|
-
end
|
22
|
+
::Rails.application.config.session_options[:domain] = '.foo.bar' if ::Rails.respond_to?(:application)
|
25
23
|
end
|
26
24
|
|
27
25
|
def teardown
|
@@ -31,25 +29,25 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
31
29
|
def test_render_js_for_tests
|
32
30
|
Vanity.playground.use_js!
|
33
31
|
get :js
|
34
|
-
assert_match
|
32
|
+
assert_match(/script.*v=pie_or_cake=.*script/m, @response.body)
|
35
33
|
end
|
36
34
|
|
37
35
|
def test_view_helper_ab_test_js_for_tests
|
38
36
|
Vanity.playground.use_js!
|
39
37
|
get :view_helper_ab_test_js
|
40
|
-
assert_match
|
38
|
+
assert_match(/script.*v=pie_or_cake=.*script/m, @response.body)
|
41
39
|
end
|
42
40
|
|
43
41
|
def test_global_ab_test_js_for_tests
|
44
42
|
Vanity.playground.use_js!
|
45
43
|
get :global_ab_test_js
|
46
|
-
assert_match
|
44
|
+
assert_match(/script.*v=pie_or_cake=.*script/m, @response.body)
|
47
45
|
end
|
48
46
|
|
49
47
|
def test_render_model_js_for_tests
|
50
48
|
Vanity.playground.use_js!
|
51
49
|
get :model_js
|
52
|
-
assert_match
|
50
|
+
assert_match(/script.*v=pie_or_cake=.*script/m, @response.body)
|
53
51
|
end
|
54
52
|
|
55
53
|
def test_chooses_sets_alternatives_for_rails_tests
|
@@ -77,10 +75,10 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
77
75
|
def test_vanity_cookie_is_persistent
|
78
76
|
get :index
|
79
77
|
cookie = @response["Set-Cookie"].to_s
|
80
|
-
assert_match
|
78
|
+
assert_match(/vanity_id=[a-f0-9]{32};/, cookie)
|
81
79
|
expires = cookie[/expires=(.*)(;|$)/, 1]
|
82
80
|
assert expires
|
83
|
-
assert_in_delta Time.parse(expires), Time.now + 20 * 365 * 24 * 60 * 60, 1.day
|
81
|
+
assert_in_delta Time.parse(expires), Time.now + (20 * 365 * 24 * 60 * 60), 1.day
|
84
82
|
end
|
85
83
|
|
86
84
|
def test_vanity_cookie_default_id
|
@@ -91,7 +89,7 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
91
89
|
def test_vanity_cookie_retains_id
|
92
90
|
@request.cookies["vanity_id"] = "from_last_time"
|
93
91
|
get :index
|
94
|
-
assert_equal "from_last_time",
|
92
|
+
assert_equal "from_last_time", cookies["vanity_id"]
|
95
93
|
end
|
96
94
|
|
97
95
|
def test_vanity_cookie_uses_configuration
|
@@ -107,13 +105,13 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
107
105
|
end
|
108
106
|
|
109
107
|
def test_vanity_identity_set_from_user
|
110
|
-
@controller.current_user = stub("user", :
|
108
|
+
@controller.current_user = stub("user", id: "user_id")
|
111
109
|
get :index
|
112
110
|
assert_equal "user_id", @controller.send(:vanity_identity)
|
113
111
|
end
|
114
112
|
|
115
113
|
def test_vanity_identity_with_null_user_falls_back_to_cookie
|
116
|
-
@controller.current_user = stub("user", :
|
114
|
+
@controller.current_user = stub("user", id: nil)
|
117
115
|
get :index
|
118
116
|
assert cookies["vanity_id"] =~ /^[a-f0-9]{32}$/
|
119
117
|
end
|
@@ -130,6 +128,7 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
130
128
|
def test_vanity_identity_set_with_block
|
131
129
|
UseVanityController.class_eval do
|
132
130
|
attr_accessor :project_id
|
131
|
+
|
133
132
|
use_vanity { |controller| controller.project_id }
|
134
133
|
end
|
135
134
|
@controller.project_id = "576"
|
@@ -138,26 +137,27 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
138
137
|
end
|
139
138
|
|
140
139
|
def test_vanity_identity_set_with_identity_paramater
|
141
|
-
params = { :
|
140
|
+
params = { _identity: "id_from_params" }
|
142
141
|
get :index, params
|
143
142
|
assert_equal "id_from_params", @controller.send(:vanity_identity)
|
144
143
|
end
|
145
144
|
|
146
145
|
def test_vanity_identity_prefers_block_over_symbol
|
147
146
|
UseVanityController.class_eval do
|
148
|
-
attr_accessor :project_id
|
147
|
+
attr_accessor :project_id # rubocop:todo Lint/DuplicateMethods
|
148
|
+
|
149
149
|
use_vanity(:current_user) { |controller| controller.project_id }
|
150
150
|
end
|
151
151
|
@controller.project_id = "576"
|
152
|
-
@controller.current_user = stub(:
|
152
|
+
@controller.current_user = stub(id: "user_id")
|
153
153
|
|
154
154
|
get :index
|
155
155
|
assert_equal "576", @controller.send(:vanity_identity)
|
156
156
|
end
|
157
157
|
|
158
|
-
|
158
|
+
def test_vanity_identity_prefers_parameter_over_cookie
|
159
159
|
@request.cookies['vanity_id'] = "old_id"
|
160
|
-
params = { :
|
160
|
+
params = { _identity: "id_from_params" }
|
161
161
|
get :index, params
|
162
162
|
assert_equal "id_from_params", @controller.send(:vanity_identity)
|
163
163
|
assert cookies['vanity_id'], "id_from_params"
|
@@ -165,7 +165,7 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
165
165
|
|
166
166
|
def test_vanity_identity_prefers_cookie_over_object
|
167
167
|
@request.cookies['vanity_id'] = "from_last_time"
|
168
|
-
@controller.current_user = stub(:
|
168
|
+
@controller.current_user = stub(id: "user_id")
|
169
169
|
get :index
|
170
170
|
assert_equal "from_last_time", @controller.send(:vanity_identity)
|
171
171
|
end
|
@@ -173,7 +173,7 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
173
173
|
# query parameter filter
|
174
174
|
|
175
175
|
def test_redirects_and_loses_vanity_query_parameter
|
176
|
-
params = { :
|
176
|
+
params = { foo: "bar", _vanity: "567" }
|
177
177
|
get :index, params
|
178
178
|
assert_redirected_to "/use_vanity?foo=bar"
|
179
179
|
end
|
@@ -182,8 +182,9 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
182
182
|
first = experiment(:pie_or_cake).alternatives.first
|
183
183
|
fingerprint = experiment(:pie_or_cake).fingerprint(first)
|
184
184
|
10.times do
|
185
|
-
@controller = nil
|
186
|
-
|
185
|
+
@controller = nil
|
186
|
+
setup_controller_request_and_response
|
187
|
+
params = { _vanity: fingerprint }
|
187
188
|
get :index, params
|
188
189
|
assert_equal experiment(:pie_or_cake).choose, experiment(:pie_or_cake).alternatives.first
|
189
190
|
assert experiment(:pie_or_cake).showing?(first)
|
@@ -194,21 +195,20 @@ class UseVanityControllerTest < ActionController::TestCase
|
|
194
195
|
experiment(:pie_or_cake).chooses(experiment(:pie_or_cake).alternatives.last.value)
|
195
196
|
first = experiment(:pie_or_cake).alternatives.first
|
196
197
|
fingerprint = experiment(:pie_or_cake).fingerprint(first)
|
197
|
-
params = { :
|
198
|
+
params = { foo: "bar", _vanity: fingerprint }
|
198
199
|
post :index, params
|
199
200
|
assert_response :success
|
200
201
|
assert !experiment(:pie_or_cake).showing?(first)
|
201
202
|
end
|
202
203
|
|
203
204
|
def test_track_param_tracks_a_metric
|
204
|
-
params = { :
|
205
|
+
params = { _identity: "123", _track: "sugar_high" }
|
205
206
|
get :index, params
|
206
207
|
assert_equal experiment(:pie_or_cake).alternatives[0].converted, 1
|
207
208
|
end
|
208
209
|
|
209
210
|
def test_cookie_domain_from_rails_configuration
|
210
211
|
get :index
|
211
|
-
assert_match
|
212
|
+
assert_match(/domain=.foo.bar/, @response["Set-Cookie"]) if ::Rails.respond_to?(:application)
|
212
213
|
end
|
213
|
-
|
214
214
|
end
|
@@ -15,7 +15,7 @@ class UseVanityMailerTest < ActionMailer::TestCase
|
|
15
15
|
|
16
16
|
def test_js_enabled_still_adds_participant
|
17
17
|
Vanity.playground.use_js!
|
18
|
-
experiment(:pie_or_cake).identify {
|
18
|
+
experiment(:pie_or_cake).identify {} # rubocop:todo Lint/EmptyBlock
|
19
19
|
experiment(:pie_or_cake).chooses(:pie)
|
20
20
|
VanityMailer.ab_test_subject(nil)
|
21
21
|
|
@@ -24,7 +24,7 @@ class UseVanityMailerTest < ActionMailer::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_returns_different_alternatives
|
27
|
-
experiment(:pie_or_cake).identify {
|
27
|
+
experiment(:pie_or_cake).identify {} # rubocop:todo Lint/EmptyBlock
|
28
28
|
|
29
29
|
experiment(:pie_or_cake).chooses(:pie)
|
30
30
|
email = VanityMailer.ab_test_subject(nil)
|
@@ -34,13 +34,13 @@ class RailsHelperTest < ActionView::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_vanity_track_url_for_returns_url_with_identity_and_metrics
|
37
|
-
|
38
|
-
vanity_track_url_for("123", :sugar_high, :
|
37
|
+
expects(:url_for).with(controller: "controller", action: "action", _identity: '123', _track: :sugar_high)
|
38
|
+
vanity_track_url_for("123", :sugar_high, controller: "controller", action: "action")
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_vanity_tracking_image
|
42
|
-
|
43
|
-
assert_equal image_tag("/url", :
|
42
|
+
expects(:url_for).with(controller: :vanity, action: :image, _identity: '123', _track: :sugar_high).returns("/url")
|
43
|
+
assert_equal image_tag("/url", width: "1px", height: "1px", alt: ""), vanity_tracking_image("123", :sugar_high, options = {}) # rubocop:todo Lint/UselessAssignment
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_vanity_experiments
|
@@ -53,7 +53,7 @@ class RailsHelperTest < ActionView::TestCase
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_vanity_experiments_return_is_read_only
|
56
|
-
result = ab_test(:pie_or_cake)
|
56
|
+
result = ab_test(:pie_or_cake) # rubocop:todo Lint/UselessAssignment
|
57
57
|
vanity_experiments_returns = vanity_experiments
|
58
58
|
vanity_experiments_returns[:some_new_key] = 'some new value'
|
59
59
|
assert_equal vanity_experiments.keys.length, 1
|
@@ -62,5 +62,4 @@ class RailsHelperTest < ActionView::TestCase
|
|
62
62
|
def test_vanity_experiments_returns_empty_hash_when_no_experiments
|
63
63
|
assert_equal vanity_experiments, {}
|
64
64
|
end
|
65
|
-
|
66
65
|
end
|