Sha256: 0f6473c01d1f50dff313ae8d24b3ff7b27194238887a102d5afae103e61ad414

Contents?: true

Size: 842 Bytes

Versions: 22

Compression:

Stored size: 842 Bytes

Contents

require 'test_helper'

class ActiveRecordTest < MiniTest::Test
  def setup
    @record = ModelStub.new
  end

  def test_to_label
    # without anything defined, it'll use the to_s method (e.g. #<ModelStub:0xb7379300>)
    assert_match(/^#<[a-z]+:0x[0-9a-f]+>$/i, @record.to_label)

    class << @record
      def to_s
        'to_s'
      end
    end
    RequestStore.clear!
    assert_equal 'to_s', @record.to_label

    class << @record
      def title
        'title'
      end
    end
    RequestStore.clear!
    assert_equal 'title', @record.to_label

    class << @record
      def label
        'label'
      end
    end
    RequestStore.clear!
    assert_equal 'label', @record.to_label

    class << @record
      def name
        'name'
      end
    end
    RequestStore.clear!
    assert_equal 'name', @record.to_label
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
active_scaffold-3.6.20 test/extensions/active_record_test.rb
active_scaffold-3.6.19 test/extensions/active_record_test.rb
active_scaffold-3.6.17 test/extensions/active_record_test.rb
active_scaffold-3.6.15 test/extensions/active_record_test.rb
active_scaffold-3.6.14 test/extensions/active_record_test.rb
active_scaffold-3.6.13 test/extensions/active_record_test.rb
active_scaffold-3.6.12 test/extensions/active_record_test.rb
active_scaffold-3.6.11.1 test/extensions/active_record_test.rb
active_scaffold-3.6.11 test/extensions/active_record_test.rb
active_scaffold-3.6.10 test/extensions/active_record_test.rb
active_scaffold-3.6.9 test/extensions/active_record_test.rb
active_scaffold-3.6.8 test/extensions/active_record_test.rb
active_scaffold-3.6.6 test/extensions/active_record_test.rb
active_scaffold-3.6.5 test/extensions/active_record_test.rb
active_scaffold-3.6.4.1 test/extensions/active_record_test.rb
active_scaffold-3.6.4 test/extensions/active_record_test.rb
active_scaffold-3.6.3 test/extensions/active_record_test.rb
active_scaffold-3.6.2 test/extensions/active_record_test.rb
active_scaffold-3.6.1 test/extensions/active_record_test.rb
active_scaffold-3.6.0 test/extensions/active_record_test.rb