aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-07-11 07:40:26 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-07-11 07:43:05 +0900
commit23300f4440ae35ba7604476496e7867f5eff9dab (patch)
treed270e08bf599aaee4e490d60899472ef6717231d /activerecord/test/models
parentbfbae885b290d35d7cbdcdf7f6b6c157bacac392 (diff)
downloadrails-23300f4440ae35ba7604476496e7867f5eff9dab.tar.gz
rails-23300f4440ae35ba7604476496e7867f5eff9dab.tar.bz2
rails-23300f4440ae35ba7604476496e7867f5eff9dab.zip
Extract `FakeKlass` in `relation_test.rb` and `relation/mutation_test.rb`
`FakeKlass` in `relation_test.rb` and `relation/mutation_test.rb` are almost the same.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/post.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index ed64e0ee52..a99ab12b19 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -276,3 +276,35 @@ end
class SubConditionalStiPost < ConditionalStiPost
end
+
+class FakeKlass
+ extend ActiveRecord::Delegation::DelegateCache
+
+ inherited self
+
+ class << self
+ def connection
+ Post.connection
+ end
+
+ def table_name
+ "posts"
+ end
+
+ def attribute_alias?(name)
+ false
+ end
+
+ def sanitize_sql(sql)
+ sql
+ end
+
+ def sanitize_sql_for_order(sql)
+ sql
+ end
+
+ def arel_attribute(name, table)
+ table[name]
+ end
+ end
+end