aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/arel/attributes_test.rb
blob: 1712633ae9cfda445e0f377c4dc12ad9153ae02a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

require_relative "helper"

module Arel
  describe "Attributes" do
    it "responds to lower" do
      relation  = Table.new(:users)
      attribute = relation[:foo]
      node      = attribute.lower
      assert_equal "LOWER", node.name
      assert_equal [attribute], node.expressions
    end

    describe "equality" do
      it "is equal with equal ivars" do
        array = [Attribute.new("foo", "bar"), Attribute.new("foo", "bar")]
        assert_equal 1, array.uniq.size
      end

      it "is not equal with different ivars" do
        array = [Attribute.new("foo", "bar"), Attribute.new("foo", "baz")]
        assert_equal 2, array.uniq.size
      end
    end
  end
end