Project

General

Profile

Patch #30163 ยป remove-unnecessary-tests.diff

Go MAEDA, 2018-12-09 17:37

View differences:

test/unit/initializers/patches_test.rb (working copy)
45 45
  test "ActiveRecord::Base.human_attribute_name should default to humanized value if no translation has been found (useful for custom fields)" do
46 46
    assert_equal 'Patch name', ActiveRecord::Base.human_attribute_name('Patch name')
47 47
  end
48

  
49
  # https://github.com/rails/rails/pull/14198/files
50
  def test_indifferent_select
51
    hash = ActiveSupport::HashWithIndifferentAccess.new(@symbols).select { |_ ,v| v == 1 }
52
    assert_equal({ 'a' => 1 }, hash)
53
    assert_instance_of ((Rails::VERSION::MAJOR < 4 && RUBY_VERSION < "2.1") ?
54
                          Hash : ActiveSupport::HashWithIndifferentAccess),
55
                        hash
56
  end
57

  
58
  def test_indifferent_select_bang
59
    indifferent_strings = ActiveSupport::HashWithIndifferentAccess.new(@symbols)
60
    indifferent_strings.select! { |_, v| v == 1 }
61
    assert_equal({ 'a' => 1 }, indifferent_strings)
62
    assert_instance_of ActiveSupport::HashWithIndifferentAccess, indifferent_strings
63
  end
64

  
65
  def test_indifferent_reject
66
    hash = ActiveSupport::HashWithIndifferentAccess.new(@symbols).reject { |_, v| v != 1 }
67
    assert_equal({ 'a' => 1 }, hash)
68
    assert_instance_of ActiveSupport::HashWithIndifferentAccess, hash
69
  end
70

  
71
  def test_indifferent_reject_bang
72
    indifferent_strings = ActiveSupport::HashWithIndifferentAccess.new(@symbols)
73
    indifferent_strings.reject! { |_, v| v != 1 }
74
    assert_equal({ 'a' => 1 }, indifferent_strings)
75
    assert_instance_of ActiveSupport::HashWithIndifferentAccess, indifferent_strings
76
  end
77

  
78
  def test_select
79
    assert_equal @keys, @ordered_hash.select { true }.map(&:first)
80
    new_ordered_hash = @ordered_hash.select { true }
81
    assert_equal @keys, new_ordered_hash.map(&:first)
82
    assert_instance_of ((Rails::VERSION::MAJOR < 4 && RUBY_VERSION < "2.1") ?
83
                          Hash : ActiveSupport::OrderedHash),
84
                        new_ordered_hash
85
  end
86

  
87
  def test_reject
88
    copy = @ordered_hash.dup
89
    new_ordered_hash = @ordered_hash.reject { |k, _| k == 'pink' }
90
    assert_equal copy, @ordered_hash
91
    assert !new_ordered_hash.keys.include?('pink')
92
    assert @ordered_hash.keys.include?('pink')
93
    assert_instance_of ActiveSupport::OrderedHash, new_ordered_hash
94
  end
95 48
end
    (1-1/1)