Skip to content

Commit

Permalink
Allow count removal by setting the value to nil
Browse files Browse the repository at this point in the history
[#94]
  • Loading branch information
seejohnrun committed Oct 11, 2012
1 parent 6a65ccf commit 50a17a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/ice_cube/validated_rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ def validations_for(key)

# Fully replace validations
def replace_validations_for(key, arr)
@validations[key] = arr
if arr.nil?
@validations.delete(key)
else
@validations[key] = arr
end
end

# Remove the specified base validations
Expand Down
14 changes: 13 additions & 1 deletion spec/examples/ice_cube_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,18 @@
rule.occurrence_count.should == 5
end

it 'should be able to remove a count validation from a rule' do
rule = IceCube::Rule.daily.count(5)
rule.occurrence_count.should == 5
rule.count nil
rule.occurrence_count.should raise_error
end

end
it 'should be able to remove a count validation from a rule' do
rule = IceCube::Rule.daily.count(5)
rule.to_hash[:count].should == 5
rule.count nil
rule.to_hash[:count].should be_nil
end

end

0 comments on commit 50a17a5

Please sign in to comment.