Permalink
Browse files

Deleting an experiment should also increment the version

  • Loading branch information...
1 parent 3ee0b33 commit 63175df663d651b707babaf36139679504791fe4 @andrew andrew committed Jun 26, 2011
Showing with 17 additions and 7 deletions.
  1. +1 −0 lib/split/experiment.rb
  2. +16 −7 spec/experiment_spec.rb
View
@@ -67,6 +67,7 @@ def delete
reset_winner
Split.redis.srem(:experiments, name)
Split.redis.del(name)
+ increment_version
end
def new_record?
View
@@ -27,14 +27,23 @@
Split.redis.exists('basket_text').should be true
Split.redis.lrange('basket_text', 0, -1).should eql(['Basket', "Cart"])
end
-
- it 'should delete itself' do
- experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
- experiment.save
+
+ describe 'deleting' do
+ it 'should delete itself' do
+ experiment = Split::Experiment.new('basket_text', 'Basket', "Cart")
+ experiment.save
+
+ experiment.delete
+ Split.redis.exists('basket_text').should be false
+ lambda { Split::Experiment.find('link_color') }.should raise_error
+ end
- experiment.delete
- Split.redis.exists('basket_text').should be false
- lambda { Split::Experiment.find('link_color') }.should raise_error
+ it "should increment the version" do
+ experiment = Split::Experiment.find_or_create('link_color', 'blue', 'red', 'green')
+ experiment.version.should eql(0)
+ experiment.delete
+ experiment.version.should eql(1)
+ end
end
describe 'new record?' do

0 comments on commit 63175df

Please sign in to comment.