aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation/or_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2017-08-01 17:34:14 -0400
committerRafael Mendonça França <rafaelmfranca@gmail.com>2017-08-01 17:34:14 -0400
commitfeb1ddae021c38174f9c22bbd1298c8b73431b45 (patch)
tree09a38695596cf80dc362dd4d93cf94d6f7415e7b /activerecord/test/cases/relation/or_test.rb
parent3540e60c385286f3517ff56270b31a91ed3024a3 (diff)
parentf9a43f28c087f8ffd35ff7c33a60c938b60f2be2 (diff)
downloadrails-feb1ddae021c38174f9c22bbd1298c8b73431b45.tar.gz
rails-feb1ddae021c38174f9c22bbd1298c8b73431b45.tar.bz2
rails-feb1ddae021c38174f9c22bbd1298c8b73431b45.zip
Merge remote-tracking branch 'origin/master' into unlock-minitest
Diffstat (limited to 'activerecord/test/cases/relation/or_test.rb')
-rw-r--r--activerecord/test/cases/relation/or_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation/or_test.rb b/activerecord/test/cases/relation/or_test.rb
index 61b6601580..b01801b41f 100644
--- a/activerecord/test/cases/relation/or_test.rb
+++ b/activerecord/test/cases/relation/or_test.rb
@@ -1,9 +1,14 @@
+# frozen_string_literal: true
+
require "cases/helper"
+require "models/author"
+require "models/categorization"
require "models/post"
module ActiveRecord
class OrTest < ActiveRecord::TestCase
fixtures :posts
+ fixtures :authors
def test_or_with_relation
expected = Post.where("id = 1 or id = 2").to_a
@@ -113,5 +118,13 @@ module ActiveRecord
Post.where(id: [1, 2, 3]).or(title: "Rails")
end
end
+
+ def test_or_with_references_inequality
+ joined = Post.includes(:author)
+ actual = joined.where(authors: { id: 1 })
+ .or(joined.where(title: "I don't have any comments"))
+ 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
end
end