Sha256: e28962327c8e34903d1ccdd762bb3323e999f8ad38bc064759629c8878bb0ae3

Contents?: true

Size: 1.72 KB

Versions: 11

Compression:

Stored size: 1.72 KB

Contents

require 'test_helper'

class MetaTagTest < ActiveSupport::TestCase
  # called before every single test
  def setup
    @tag = MetaTag.new(:name => 'somename')
    @tag.taggable_type = 'Category'
    @tag.taggable_id = 1
    @tag.content = 'some content'
  end
  
  test "truth" do
    assert_kind_of Class, MetaTag
  end
  
  test 'should create new record with valid attributes' do
    @tag.save!
  end
  
  test 'should not be valid with empty name' do
    @tag.name = nil
    assert !@tag.valid?
  end
  
  test 'should not be valid with not uniq name' do
    @tag.update_attribute(:name, 'test')
    
    @next_tag = MetaTag.new(:name => 'test')
    @next_tag.taggable_type = 'Category'
    @next_tag.taggable_id = 1
    
    assert !@next_tag.valid?
  end
  
  test 'should be valid with not uniq name but dynamic' do
    @tag.update_attribute(:name, 'test')
    
    @next_tag = MetaTag.new(:name => 'test', :is_dynamic => true)
    @next_tag.taggable_type = 'Category'
    @next_tag.taggable_id = 1
    @next_tag.content = 'content'
    
    assert @next_tag.valid?
  end
  
  test 'should not be valid with not uniq name both dynamic' do
    @tag.update_attribute(:is_dynamic, true)
    
    @next_tag = MetaTag.new(:name => 'somename', :is_dynamic => true)
    @next_tag.taggable_type = 'Category'
    @next_tag.taggable_id = 1
    
    assert !@next_tag.valid?
  end
  
  test 'should be valid with not uniq name in other parent record' do
    @tag.update_attribute(:name, 'test')
    
    @next_tag = MetaTag.new(:name => 'test')
    @next_tag.taggable_type = 'Category'
    @next_tag.taggable_id = 2
    @next_tag.content = 'content'
    
    assert @next_tag.valid?
  end
  
  test 'should return valid dynamic content' do
    assert true
  end
end

Version data entries

11 entries across 10 versions & 2 rubygems

Version Path
meta_manager-0.3.0 test/models/meta_tag_test.rb
meta_manager-0.2.3 test/models/meta_tag_test.rb
meta_manager-0.2.2 test/models/meta_tag_test.rb
meta_manager-0.2.1 test/models/meta_tag_test.rb
meta_manager-0.2.0 test/models/meta_tag_test.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/meta_manager-0.1.1/test/models/meta_tag_test.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/meta_manager-0.0.8/test/models/meta_tag_test.rb
meta_manager-0.1.1 test/models/meta_tag_test.rb
meta_manager-0.1.0 test/models/meta_tag_test.rb
meta_manager-0.0.8 test/models/meta_tag_test.rb
meta_manager-0.0.7 test/models/meta_tag_test.rb