Sha256: d0fcc3f75d5ddcfc411cba8af98ca4f98040616ac3277c297ea3836f5f470597

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

require "test_helper"

module PushType
  describe Taxonomy do
    let(:taxonomy) { Taxonomy.new }

    it { taxonomy.wont_be :valid? }

    it 'should be valid with required attributes' do
      taxonomy.attributes = FactoryGirl.attributes_for :taxonomy
      taxonomy.must_be :valid?
    end

    describe '.base_slug' do
      it 'should by default be the class name' do
        taxonomy.base_slug.must_equal 'push_type/taxonomy'
      end
      describe 'setting the base_slug' do
        before  { Taxonomy.base_slug :foo_bar }
        after   { Taxonomy.base_slug nil }
        it { Taxonomy.base_slug.must_equal 'foo_bar' }
      end
    end

    describe '#permalink' do
      before do
        Taxonomy.base_slug :cat
        %w(one two three).each { |slug| @tax = FactoryGirl.create :taxonomy, slug: slug, parent: @tax }
      end
      after   { Taxonomy.base_slug nil }
      it { @tax.permalink.must_equal 'one/two/three' }
      it { @tax.permalink(true).must_equal 'cat/one/two/three' }
      it { @tax.full_permalink.must_equal 'cat/one/two/three' }
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
push_type_core-0.5.1 test/models/push_type/taxonomy_test.rb
push_type_core-0.5.0 test/models/push_type/taxonomy_test.rb
push_type_core-0.5.0.alpha.5 test/models/push_type/taxonomy_test.rb
push_type_core-0.5.0.alpha.4 test/models/push_type/taxonomy_test.rb
push_type_core-0.5.0.alpha.3 test/models/push_type/taxonomy_test.rb
push_type_core-0.5.0.alpha.2 test/models/push_type/taxonomy_test.rb
push_type_core-0.5.0.alpha.1 test/models/push_type/taxonomy_test.rb
push_type_core-0.4.0 test/models/push_type/taxonomy_test.rb