class ActiveRecord::WhereChainTest
Public Instance Methods
setup()
click to toggle source
Calls superclass method
# File activerecord/test/cases/relation/where_chain_test.rb, line 11 def setup super @name = "title" end
test_association_not_eq()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 29 def test_association_not_eq expected = Comment.arel_table[@name].not_eq(Arel::Nodes::BindParam.new(1)) relation = Post.joins(:comments).where.not(comments: { title: "hello" }) assert_equal(expected.to_sql, relation.where_clause.ast.to_sql) end
test_chaining_multiple()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 53 def test_chaining_multiple relation = Post.where.not(author_id: [1, 2]).where.not(title: "ruby on quails") expected_where_clause = Post.where(author_id: [1, 2]).where_clause.invert + Post.where(title: "ruby on quails").where_clause.invert assert_equal expected_where_clause, relation.where_clause end
test_not_eq_with_preceding_where()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 35 def test_not_eq_with_preceding_where relation = Post.where(title: "hello").where.not(title: "world") expected_where_clause = Post.where(title: "hello").where_clause + Post.where(title: "world").where_clause.invert assert_equal expected_where_clause, relation.where_clause end
test_not_eq_with_succeeding_where()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 44 def test_not_eq_with_succeeding_where relation = Post.where.not(title: "hello").where(title: "world") expected_where_clause = Post.where(title: "hello").where_clause.invert + Post.where(title: "world").where_clause assert_equal expected_where_clause, relation.where_clause end
test_not_inverts_where_clause()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 16 def test_not_inverts_where_clause relation = Post.where.not(title: "hello") expected_where_clause = Post.where(title: "hello").where_clause.invert assert_equal expected_where_clause, relation.where_clause end
test_not_with_nil()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 23 def test_not_with_nil assert_raise ArgumentError do Post.where.not(nil) end end
test_rewhere_with_infinite_lower_bound_range()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 95 def test_rewhere_with_infinite_lower_bound_range relation = Post.where(comments_count: -Float::INFINITY..1).rewhere(comments_count: 3..5) assert_equal Post.where(comments_count: 3..5), relation end
test_rewhere_with_infinite_range()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 101 def test_rewhere_with_infinite_range relation = Post.where(comments_count: -Float::INFINITY..Float::INFINITY).rewhere(comments_count: 3..5) assert_equal Post.where(comments_count: 3..5), relation end
test_rewhere_with_infinite_upper_bound_range()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 89 def test_rewhere_with_infinite_upper_bound_range relation = Post.where(comments_count: 1..Float::INFINITY).rewhere(comments_count: 3..5) assert_equal Post.where(comments_count: 3..5), relation end
test_rewhere_with_multiple_overwriting_conditions()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 69 def test_rewhere_with_multiple_overwriting_conditions relation = Post.where(title: "hello").where(body: "world").rewhere(title: "alone", body: "again") expected = Post.where(title: "alone", body: "again") assert_equal expected.where_clause, relation.where_clause end
test_rewhere_with_one_condition()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 62 def test_rewhere_with_one_condition relation = Post.where(title: "hello").where(title: "world").rewhere(title: "alone") expected = Post.where(title: "alone") assert_equal expected.where_clause, relation.where_clause end
test_rewhere_with_range()
click to toggle source
# File activerecord/test/cases/relation/where_chain_test.rb, line 83 def test_rewhere_with_range relation = Post.where(comments_count: 1..3).rewhere(comments_count: 3..5) assert_equal Post.where(comments_count: 3..5), relation end