diff options
author | Graham Turner <turnertgraham@gmail.com> | 2018-04-25 04:36:27 -0400 |
---|---|---|
committer | Graham Turner <turnertgraham@gmail.com> | 2018-04-25 06:29:03 -0400 |
commit | bc62f2a3bec27497e6963af42f49857926d6d860 (patch) | |
tree | bee97a9afb3f1c3ec7a1232ee0dfffec463893d0 /activerecord | |
parent | 03721d9379c0eeb8b0c93c92301ba7a9caa436a2 (diff) | |
download | rails-bc62f2a3bec27497e6963af42f49857926d6d860.tar.gz rails-bc62f2a3bec27497e6963af42f49857926d6d860.tar.bz2 rails-bc62f2a3bec27497e6963af42f49857926d6d860.zip |
`get_value` needs to be a public method
Adds test case for failing issue
Moves set_value back to protected
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 9 | ||||
-rw-r--r-- | activerecord/test/cases/relation/or_test.rb | 7 | ||||
-rw-r--r-- | activerecord/test/models/author.rb | 3 |
3 files changed, 15 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index a180b0f0d3..db9101a168 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -909,11 +909,12 @@ module ActiveRecord @arel ||= build_arel(aliases) end + # Returns a relation value with a given name + def get_value(name) # :nodoc: + @values.fetch(name, DEFAULT_VALUES[name]) + end + protected - # Returns a relation value with a given name - def get_value(name) # :nodoc: - @values.fetch(name, DEFAULT_VALUES[name]) - end # Sets the relation value with the given name def set_value(name, value) # :nodoc: diff --git a/activerecord/test/cases/relation/or_test.rb b/activerecord/test/cases/relation/or_test.rb index 7e418f9c7d..065819e0f1 100644 --- a/activerecord/test/cases/relation/or_test.rb +++ b/activerecord/test/cases/relation/or_test.rb @@ -126,5 +126,12 @@ module ActiveRecord expected = Author.find(1).posts + Post.where(title: "I don't have any comments") assert_equal expected.sort_by(&:id), actual.sort_by(&:id) end + + def test_or_with_scope_on_association + author = Author.first + assert_nothing_raised do + author.top_posts.or(author.other_top_posts) + end + end end end diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index bd12cdf7ef..75932c7eb6 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -162,6 +162,9 @@ class Author < ActiveRecord::Base def extension_method; end end + has_many :top_posts, -> { order(id: :asc) }, class_name: "Post" + has_many :other_top_posts, -> { order(id: :asc) }, class_name: "Post" + attr_accessor :post_log after_initialize :set_post_log |