aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/association_scope_test.rb
blob: dd26a85e442a71bab15d5c398dc3763d3ca35131 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'cases/helper'
require 'models/post'
require 'models/author'

module ActiveRecord
  module Associations
    class AssociationScopeTest < ActiveRecord::TestCase
      test 'does not duplicate conditions' do
        scope = AssociationScope.scope(Author.new.association(:welcome_posts),
                                        Author.connection)
        wheres = scope.where_clause.predicates.map(&:right)
        binds = scope.where_clause.binds.map(&:last)
        wheres.reject! { |node|
          Arel::Nodes::BindParam === node
        }
        assert_equal wheres.uniq, wheres
        assert_equal binds.uniq, binds
      end
    end
  end
end