Skip to content

Commit

Permalink
Fix HABTM test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
malomalo committed Jun 26, 2017
1 parent 905e594 commit 33db969
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .tm_properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exclude = '{$exclude,.tm_properties,coverage}'
exclude = '{$exclude,log,tmp,.tm_properties,public/system,coverage}'
10 changes: 10 additions & 0 deletions lib/cached_at/associations/collection_proxy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module CachedAt
module CollectionProxy
def delete(*records)
@association.touch_records_cached_at(records, Time.now) unless @association.owner.new_record?
super
end
end
end

ActiveRecord::Associations::CollectionProxy.prepend(CachedAt::CollectionProxy)
1 change: 1 addition & 0 deletions lib/cached_at/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require File.expand_path(File.join(__FILE__, '../associations/has_one_association'))
require File.expand_path(File.join(__FILE__, '../associations/belongs_to_association'))
require File.expand_path(File.join(__FILE__, '../associations/collection_association'))
require File.expand_path(File.join(__FILE__, '../associations/collection_proxy'))
require File.expand_path(File.join(__FILE__, '../associations/has_many_through_association'))

require File.expand_path(File.join(__FILE__, '../reflections/abstract_reflection'))
Expand Down
2 changes: 0 additions & 2 deletions test/has_and_belongs_to_many_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ class EmailMessage < ActiveRecord::Base

time2 = Time.now + 60
travel_to(time2) {
debug do
assert_queries(2) { message.emails.delete(email1) }
end
}

assert_in_memory_and_persisted(email1, :email_messages_cached_at, time2)
Expand Down

0 comments on commit 33db969

Please sign in to comment.