mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 15:22:58 +00:00
Fix thread lock on undefine
Move active model methods into active model ORM module to be included manually if not using AR or other ORM
This commit is contained in:
@@ -7,6 +7,7 @@ require 'action_view'
|
||||
require 'timecop'
|
||||
|
||||
require 'validates_timeliness'
|
||||
require 'validates_timeliness/orm/active_model'
|
||||
|
||||
require 'support/test_model'
|
||||
require 'support/model_helpers'
|
||||
@@ -30,14 +31,9 @@ I18n.available_locales = ['en', 'es']
|
||||
module TestModelShim
|
||||
extend ActiveSupport::Concern
|
||||
include ValidatesTimeliness::AttributeMethods
|
||||
include ValidatesTimeliness::ORM::ActiveModel
|
||||
|
||||
module ClassMethods
|
||||
# Hook method for attribute method generation
|
||||
def define_attribute_methods(attr_names)
|
||||
super
|
||||
define_timeliness_methods
|
||||
end
|
||||
|
||||
# Hook into native time zone handling check, if any
|
||||
def timeliness_attribute_timezone_aware?(attr_name)
|
||||
false
|
||||
|
||||
@@ -239,4 +239,10 @@ RSpec.describe ValidatesTimeliness, 'ActiveRecord' do
|
||||
expect(Employee.define_attribute_methods).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
context "undefine_attribute_methods" do
|
||||
it "returns a falsy value if the attribute methods have already been generated" do
|
||||
expect { Employee.undefine_attribute_methods }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user