mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
fix interpolation_values examples for rails version without i18n
This commit is contained in:
parent
b632093ce2
commit
011ea070db
@ -123,7 +123,8 @@ module Spec
|
||||
restriction = [restriction] unless restriction.is_a?(Array)
|
||||
restriction.map! {|r| @validator.send(:type_cast_value, r) }
|
||||
interpolate = @validator.send(:interpolation_values, option, restriction )
|
||||
if defined?(I18n)
|
||||
# get I18n message if defined and has interpolation keys in msg
|
||||
if defined?(I18n) && msg.match(/\{\{/)
|
||||
msg = @record.errors.generate_message(@expected, option, interpolate)
|
||||
else
|
||||
msg = msg % interpolate
|
||||
|
||||
@ -376,16 +376,24 @@ describe ValidatesTimeliness::Validator do
|
||||
end
|
||||
|
||||
describe "interpolation_values" do
|
||||
it "should return hash of interpolation keys with restriction values" do
|
||||
before = '1900-01-01'
|
||||
configure_validator(:type => :date, :before => before)
|
||||
validator.send(:interpolation_values, :before, before.to_date).should == {:restriction => before}
|
||||
end
|
||||
if defined?(I18n)
|
||||
it "should return hash of interpolation keys with restriction values" do
|
||||
before = '1900-01-01'
|
||||
configure_validator(:type => :date, :before => before)
|
||||
validator.send(:interpolation_values, :before, before.to_date).should == {:restriction => before}
|
||||
end
|
||||
|
||||
it "should return empty hash if no interpolation keys are in message" do
|
||||
before = '1900-01-01'
|
||||
configure_validator(:type => :date, :before => before, :before_message => 'too late')
|
||||
validator.send(:interpolation_values, :before, before.to_date).should be_empty
|
||||
it "should return empty hash if no interpolation keys are in message" do
|
||||
before = '1900-01-01'
|
||||
configure_validator(:type => :date, :before => before, :before_message => 'too late')
|
||||
validator.send(:interpolation_values, :before, before.to_date).should be_empty
|
||||
end
|
||||
else
|
||||
it "should return array of interpolation values" do
|
||||
before = '1900-01-01'
|
||||
configure_validator(:type => :date, :before => before)
|
||||
validator.send(:interpolation_values, :before, before.to_date).should == [before]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user