From ad389286bbce5a43de34dc2df3968fa1f47181e1 Mon Sep 17 00:00:00 2001 From: Rob Looby Date: Fri, 8 May 2015 13:52:33 -0500 Subject: put dynamic matchers on the GeneratedAssociationMethods instead of model --- activerecord/test/models/electron.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/electron.rb b/activerecord/test/models/electron.rb index 6fc270673f..aacdaa71b7 100644 --- a/activerecord/test/models/electron.rb +++ b/activerecord/test/models/electron.rb @@ -2,4 +2,12 @@ class Electron < ActiveRecord::Base belongs_to :molecule validates_presence_of :name + + cattr_reader :times_called_find_by_name + @@times_called_find_by_name = 0 + + def self.find_by_name(name) + @@times_called_find_by_name += 1 + super(name) + end end -- cgit v1.2.3