Sha256: f004860bae4b9b793a9dc5de1010750368dc146ee747c51923a44e4ef03fe74c

Contents?: true

Size: 1.18 KB

Versions: 21

Compression:

Stored size: 1.18 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

module TaxonHelper
  def valid_taxon_attributes
    {
      :name => "A Taxon",
      :position => 1
    }
  end
end

describe Taxon do
  include TaxonHelper

  before(:each) do
    @taxonomy = Taxonomy.create(:name => "Test")
    @taxon = Taxon.new
  end

  it "should not be valid when empty" do
    pending "Can it really be valid when empty?"
    @taxon.should_not be_valid
  end

  ['name'].each do |field|
    it "should require #{field}" do
      pending "Is this field mandatory?"
      @taxon.should_not be_valid
      @taxon.errors.full_messages.should include("#{field.intern.l(field).humanize} #{:error_message_blank.l}")
    end
  end
  
  it "should be valid when having correct information" do
    @taxon.attributes = valid_taxon_attributes

    @taxon.should be_valid
  end
  
  it "should set the permalink on create" do
    @taxon = Taxon.create(:name => "foo", :taxonomy => @taxonomy)
    @taxon.permalink.should == "foo/"
  end
  
  it "should update the permalink on update" do
    @taxon = Taxon.create(:name => "foo", :taxonomy => @taxonomy)
    @taxon.update_attribute("name", "fooz")
    @taxon.permalink.should == "fooz/"
  end
  
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
kdmny-spree-0.0.1 spec/models/taxon_spec.rb
spree-0.11.0 spec/models/taxon_spec.rb
spree-0.10.2 spec/models/taxon_spec.rb
spree-0.10.1 spec/models/taxon_spec.rb
spree-0.10.0 spec/models/taxon_spec.rb
spree-0.10.0.beta spec/models/taxon_spec.rb
spree-enriquez-0.9.4 spec/models/taxon_spec.rb
spree-0.9.4 spec/models/taxon_spec.rb
spree-0.9.3 spec/models/taxon_spec.rb
spree-0.9.2 spec/models/taxon_spec.rb
spree-0.9.1 spec/models/taxon_spec.rb
spree-0.9.0 spec/models/taxon_spec.rb
spree-0.8.4 spec/models/taxon_spec.rb
spree-0.8.5 spec/models/taxon_spec.rb
spree-0.6.0 spec/models/taxon_spec.rb
spree-0.7.1 spec/models/taxon_spec.rb
spree-0.7.0 spec/models/taxon_spec.rb
spree-0.8.0 spec/models/taxon_spec.rb
spree-0.8.1 spec/models/taxon_spec.rb
spree-0.8.2 spec/models/taxon_spec.rb