mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
add validation methods as instance methods as well per AM
This commit is contained in:
parent
34379e1e15
commit
6bed71152a
@ -2,7 +2,12 @@ module ValidatesTimeliness
|
|||||||
module HelperMethods
|
module HelperMethods
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
module ClassMethods
|
included do
|
||||||
|
include ValidationMethods
|
||||||
|
extend ValidationMethods
|
||||||
|
end
|
||||||
|
|
||||||
|
module ValidationMethods
|
||||||
def validates_date(*attr_names)
|
def validates_date(*attr_names)
|
||||||
validates_with Validator, _merge_attributes(attr_names).merge(:type => :date)
|
validates_with Validator, _merge_attributes(attr_names).merge(:type => :date)
|
||||||
end
|
end
|
||||||
|
|||||||
15
spec/validates_timeliness/helper_methods_spec.rb
Normal file
15
spec/validates_timeliness/helper_methods_spec.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe ValidatesTimeliness::HelperMethods do
|
||||||
|
it 'should define class validation methods on extended classes' do
|
||||||
|
ActiveRecord::Base.should respond_to(:validates_date)
|
||||||
|
ActiveRecord::Base.should respond_to(:validates_time)
|
||||||
|
ActiveRecord::Base.should respond_to(:validates_datetime)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should define instance validation methods on extended classes' do
|
||||||
|
ActiveRecord::Base.instance_methods.should include('validates_date')
|
||||||
|
ActiveRecord::Base.instance_methods.should include('validates_time')
|
||||||
|
ActiveRecord::Base.instance_methods.should include('validates_datetime')
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue
Block a user