spec/user_spec.rb in split-1.4.4 vs spec/user_spec.rb in split-1.4.5

- old
+ new

@@ -42,8 +42,22 @@ it 'removes key if experiment has not started yet' do allow(Split::ExperimentCatalog).to receive(:find).with('link_color').and_return(experiment) allow(experiment).to receive(:has_winner?).and_return(false) @subject.cleanup_old_experiments! expect(@subject.keys).to be_empty - end + end + + context 'with finished key' do + let(:user_keys) { { 'link_color' => 'blue', 'link_color:finished' => true } } + + it 'does not remove finished key for experiment without a winner' do + allow(Split::ExperimentCatalog).to receive(:find).with('link_color').and_return(experiment) + allow(Split::ExperimentCatalog).to receive(:find).with('link_color:finished').and_return(nil) + allow(experiment).to receive(:start_time).and_return(Date.today) + allow(experiment).to receive(:has_winner?).and_return(false) + @subject.cleanup_old_experiments! + expect(@subject.keys).to include("link_color") + expect(@subject.keys).to include("link_color:finished") + end + end end -end \ No newline at end of file +end