Sha256: 6242d674dd9c215766bd7d1503b8a123d340a9b1763fcc3074e706aa603c2947

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'helper'

class AxleAttributes::ProvidedTest < ActiveSupport::TestCase
  test 'provided on write' do
    business = Business.new
    assert_equal [], business.provided

    business.name = "foo"
    assert_equal ['name'].to_set, business.provided_set
    assert_equal ['name'], business.provided
    assert business.name_provided?
    assert business.provided?('name')
    refute business.street_provided?
    refute business.provided?('street')
  end

  test 'without_provided_tracking' do
    business = Business.new

    Business.without_provided_tracking do
      business.name = "foo"
    end

    refute business.name_provided?
  end

  test 'provided cleared' do
    Business.new(name: 'foo').tap do |business|
      business.name = 'bar'
      business.save
      assert_equal [], business.provided
    end

    Business.new(name: 'foo').tap do |business|
      business.name = 'bar'
      business.save!
      assert_equal [], business.provided
    end

    Business.create(name: 'foo').tap do |business|
      business.name = 'bar'
      business.reload
      assert_equal [], business.provided
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axle_attributes-1.13.2 test/lib/provided_test.rb