mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
rename base to multiparameter attributes
This commit is contained in:
parent
7f1ada4d0e
commit
c283d2eed9
@ -1,9 +1,8 @@
|
||||
module ValidatesTimeliness
|
||||
module Base
|
||||
module MultiparameterAttributes
|
||||
|
||||
def time_array_to_string(time_array)
|
||||
time_array.collect! {|i| i.to_s.rjust(2, '0') }
|
||||
time_array[0..2].join('-') + ' ' + time_array[3..5].join(':')
|
||||
"%04d-%02d-%02d %02d:%02d:%02d" % time_array
|
||||
end
|
||||
|
||||
# Overrides AR method to store multiparameter time and dates as
|
||||
@ -1,7 +1,7 @@
|
||||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
describe ValidatesTimeliness::Base do
|
||||
include ValidatesTimeliness::Base
|
||||
describe ValidatesTimeliness::MultiparameterAttributes do
|
||||
include ValidatesTimeliness::MultiparameterAttributes
|
||||
|
||||
class AttributeAssignmentError; def initialize(*args); end; end
|
||||
class MultiparameterAssignmentErrors; def initialize(*args); end; end
|
||||
@ -11,25 +11,25 @@ describe ValidatesTimeliness::Base do
|
||||
end
|
||||
|
||||
it "should convert time array into string" do
|
||||
time_string = time_array_to_string([2000,1,1,12,12,0])
|
||||
time_string.should == "2000-01-01 12:12:00"
|
||||
time_string = time_array_to_string([2000,2,1,9,10,11])
|
||||
time_string.should == "2000-02-01 09:10:11"
|
||||
end
|
||||
|
||||
describe "execute_callstack_for_multiparameter_attributes" do
|
||||
before do
|
||||
@date_array = [1980,1,1,0,0,0]
|
||||
@date_array = [2000,2,1,9,10,11]
|
||||
end
|
||||
|
||||
it "should store time string for a Time class column" do
|
||||
self.stub!(:column_for_attribute).and_return( mock('Column', :klass => Time) )
|
||||
self.should_receive(:birth_date_and_time=).once.with("1980-01-01 00:00:00")
|
||||
self.should_receive(:birth_date_and_time=).once.with("2000-02-01 09:10:11")
|
||||
callstack = {'birth_date_and_time' => @date_array}
|
||||
execute_callstack_for_multiparameter_attributes(callstack)
|
||||
end
|
||||
|
||||
it "should store time string for a Date class column" do
|
||||
self.stub!(:column_for_attribute).and_return( mock('Column', :klass => Date) )
|
||||
self.should_receive(:birth_date=).once.with("1980-01-01 00:00:00")
|
||||
self.should_receive(:birth_date=).once.with("2000-02-01 09:10:11")
|
||||
callstack = {'birth_date' => @date_array}
|
||||
execute_callstack_for_multiparameter_attributes(callstack)
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user