aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation/delegation_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/relation/delegation_test.rb')
-rw-r--r--activerecord/test/cases/relation/delegation_test.rb37
1 files changed, 9 insertions, 28 deletions
diff --git a/activerecord/test/cases/relation/delegation_test.rb b/activerecord/test/cases/relation/delegation_test.rb
index d2382b9bb2..cb6e4d76d3 100644
--- a/activerecord/test/cases/relation/delegation_test.rb
+++ b/activerecord/test/cases/relation/delegation_test.rb
@@ -3,36 +3,15 @@ require "models/post"
require "models/comment"
module ActiveRecord
- class DelegationTest < ActiveRecord::TestCase
- fixtures :posts
-
- def call_method(target, method)
- method_arity = target.to_a.method(method).arity
-
- if method_arity.zero?
- target.public_send(method)
- elsif method_arity < 0
- if method == :shuffle!
- target.public_send(method)
- else
- target.public_send(method, 1)
- end
- elsif method_arity == 1
- target.public_send(method, 1)
- else
- raise NotImplementedError
- end
- end
- end
-
- module DelegationWhitelistBlacklistTests
+ module DelegationWhitelistTests
ARRAY_DELEGATES = [
:+, :-, :|, :&, :[], :shuffle,
:all?, :collect, :compact, :detect, :each, :each_cons, :each_with_index,
:exclude?, :find_all, :flat_map, :group_by, :include?, :length,
:map, :none?, :one?, :partition, :reject, :reverse,
:sample, :second, :sort, :sort_by, :third,
- :to_ary, :to_set, :to_xml, :to_yaml, :join
+ :to_ary, :to_set, :to_xml, :to_yaml, :join,
+ :in_groups, :in_groups_of, :to_sentence, :to_formatted_s, :as_json
]
ARRAY_DELEGATES.each do |method|
@@ -42,16 +21,18 @@ module ActiveRecord
end
end
- class DelegationAssociationTest < DelegationTest
- include DelegationWhitelistBlacklistTests
+ class DelegationAssociationTest < ActiveRecord::TestCase
+ include DelegationWhitelistTests
+
+ fixtures :posts
def target
Post.first.comments
end
end
- class DelegationRelationTest < DelegationTest
- include DelegationWhitelistBlacklistTests
+ class DelegationRelationTest < ActiveRecord::TestCase
+ include DelegationWhitelistTests
fixtures :comments