aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation/select_test.rb
blob: 586aaadd0a1962fc1637952851ef2bfda2674e22 (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 "cases/helper"
require "models/post"

module ActiveRecord
  class SelectTest < ActiveRecord::TestCase
    fixtures :posts

    def test_select_with_nil_argument
      expected = Post.select(:title).to_sql
      assert_equal expected, Post.select(nil).select(:title).to_sql
    end

    def test_reselect
      expected = Post.select(:title).to_sql
      assert_equal expected, Post.select(:title, :body).reselect(:title).to_sql
    end

    def test_reselect_with_default_scope_select
      expected = Post.select(:title).to_sql
      actual   = PostWithDefaultSelect.reselect(:title).to_sql

      assert_equal expected, actual
    end
  end
end