Sha256: 8414f64af37ed8e052616d4f5f5514337313f961b79b3d08d35ddbfe81556a0d

Contents?: true

Size: 1.18 KB

Versions: 24

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe TaxRate do
  fixtures :all

  it { should validate_presence_of :title  }
  it { should validate_presence_of :rate }
  it { should validate_presence_of :country }
  it { should validate_numericality_of :rate }


  # sanity check
  it "should be sane" do
    tax_rate = tax_rates(:valid)
    tax_rate.valid?.should_not == nil
  end

  it "should have unique country+province" do
    tr1 = TaxRate.new(:title => "Test1", :rate => 1.0, :country_id => countries(:us).id)
    tr1.save

    tr2 = TaxRate.new(:title => "Test2", :rate => 1.0, :country_id => countries(:us).id)
    tr2.valid?.should_not == true
    tr2.errors[:base].include?("There is already a tax rate for that country and province/state").should_not == nil

    tr3 = TaxRate.new(:title => "Test3", :rate => 1.0, :country_id => countries(:us).id, :province_id => provinces(:ny).id)
    tr3.valid?.should_not == nil
    tr3.save

    tr4 = TaxRate.new(:title => "Test3", :rate => 1.0, :country_id => countries(:us).id, :province_id => provinces(:ny).id)
    tr4.valid?.should_not == true
    tr4.errors[:base].include?("There is already a tax rate for that country and province/state").should_not == nil
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
forge-cli-0.1.10 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.1.9 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.1.8 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.1.7 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.1.6 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.1.5 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.1.4 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.1.3 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.1.2 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.1.1 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.1.0 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.0.18 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.0.17 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.0.16 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.0.15 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.0.14 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.0.13 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.0.12 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.0.11 lib/forge/spec/models/tax_rate_spec.rb
forge-cli-0.0.10 lib/forge/spec/models/tax_rate_spec.rb