Commit eaf8a006 by Prem Sichanugrist

Update test helpers

* Force column reset in Rails >= 3.1
* Reuse another helper method
parent 3831498f
...@@ -65,6 +65,9 @@ def reset_class class_name ...@@ -65,6 +65,9 @@ def reset_class class_name
include Paperclip::Glue include Paperclip::Glue
end end
klass.reset_column_information
klass.connection_pool.clear_table_cache!(klass.table_name) if klass.connection_pool.respond_to?(:clear_table_cache!)
klass.connection.schema_cache.clear_table_cache!(klass.table_name) if klass.connection.respond_to?(:schema_cache)
klass klass
end end
...@@ -91,15 +94,10 @@ def rebuild_model options = {} ...@@ -91,15 +94,10 @@ def rebuild_model options = {}
end end
def rebuild_class options = {} def rebuild_class options = {}
ActiveRecord::Base.send(:include, Paperclip::Glue) reset_class("Dummy").tap do |klass|
Object.send(:remove_const, "Dummy") rescue nil klass.has_attached_file :avatar, options
Object.const_set("Dummy", Class.new(ActiveRecord::Base))
Paperclip.reset_duplicate_clash_check! Paperclip.reset_duplicate_clash_check!
Dummy.class_eval do
include Paperclip::Glue
has_attached_file :avatar, options
end end
Dummy.reset_column_information
end end
class FakeModel class FakeModel
...@@ -116,7 +114,6 @@ class FakeModel ...@@ -116,7 +114,6 @@ class FakeModel
def run_paperclip_callbacks name, *args def run_paperclip_callbacks name, *args
end end
end end
def attachment(options={}) def attachment(options={})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment