|
229 | 229 |
|
230 | 230 | context "when user already has experiment" do |
231 | 231 | let(:mock_user){ Split::User.new(self, {'test_0' => 'test-alt'}) } |
232 | | - before{ |
| 232 | + |
| 233 | + before do |
233 | 234 | Split.configure do |config| |
234 | 235 | config.allow_multiple_experiments = 'control' |
235 | 236 | end |
| 237 | + |
236 | 238 | Split::ExperimentCatalog.find_or_initialize('test_0', 'control', 'test-alt').save |
237 | 239 | Split::ExperimentCatalog.find_or_initialize('test_1', 'control', 'test-alt').save |
238 | | - } |
| 240 | + end |
239 | 241 |
|
240 | 242 | it "should restore previously selected alternative" do |
241 | 243 | expect(ab_user.active_experiments.size).to eq 1 |
242 | 244 | expect(ab_test(:test_0, {'control' => 100}, {"test-alt" => 1})).to eq 'test-alt' |
243 | 245 | expect(ab_test(:test_0, {'control' => 1}, {"test-alt" => 100})).to eq 'test-alt' |
244 | 246 | end |
245 | 247 |
|
| 248 | + it "should select the correct alternatives after experiment resets" do |
| 249 | + experiment = Split::ExperimentCatalog.find(:test_0) |
| 250 | + experiment.reset |
| 251 | + mock_user[experiment.key] = 'test-alt' |
| 252 | + |
| 253 | + expect(ab_user.active_experiments.size).to eq 1 |
| 254 | + expect(ab_test(:test_0, {'control' => 100}, {"test-alt" => 1})).to eq 'test-alt' |
| 255 | + expect(ab_test(:test_0, {'control' => 0}, {"test-alt" => 100})).to eq 'test-alt' |
| 256 | + end |
| 257 | + |
246 | 258 | it "lets override existing choice" do |
247 | 259 | pending "this requires user store reset on first call not depending on whelther it is current trial" |
248 | 260 | @params = { 'ab_test' => { 'test_1' => 'test-alt' } } |
|
0 commit comments