Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Nil parameter won't yield errors.

  • Loading branch information...
commit a9ce280fc472dcc22bfd48330adf2af87ec27546 1 parent a74a0d4
Federico Ravasio authored
Showing with 10 additions and 1 deletion.
  1. +1 −1  lib/formulas.rb
  2. +9 −0 spec/formulas_spec.rb
2  lib/formulas.rb
View
@@ -11,7 +11,7 @@ def self.included(base)
module ClassMethods
def calculated_field(field)
define_method("#{field}_calc") do
- code = send(field)
+ code = send(field).to_s
sandbox_run(field, code)
end
9 spec/formulas_spec.rb
View
@@ -86,5 +86,14 @@ def initialize(params = {})
subject.attr1_error.should == 'SyntaxError'
end
end
+
+ context 'nil parameter' do
+ subject{ SimpleAttributes.new(attr1: nil) }
+
+ it 'should not store any errors' do
+ subject.attr1_calc.should be_nil
+ subject.attr1_error.should be_nil
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.