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:
Adam Meehan
2016-01-06 22:18:54 +11:00
parent ff131415f7
commit 321834b5ff
5 changed files with 31 additions and 15 deletions

View File

@@ -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

View File

@@ -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