Sha256: d2ce701e535eadd6cb0a6434c5a6fc336ab2db719194c30d53ad57fe757a1b8c

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe "Tags" do
  with_models
  login_as :user
  
  it "should create tags with constructor initializer (from error)" do
    item = Models::Item.new name: 'item', tags: ['a', 'b']
    item.save!
    
    item.reload
    item.tags.should == ['a', 'b']
    Models::Tag.count.should == 2
    Models::Tag.all.collect(&:name).sort.should == ['a', 'b']
  end
  
  it "should create tags" do
    item = Factory.create :item, tags_as_string: 'a, b'
    Models::Item.count.should == 1
    item.reload
    item.tags.should == ['a', 'b']
      
    Models::Tag.count.should == 2
    Models::Tag.all.collect(&:name).sort.should == ['a', 'b']
  end
  
  it "should update tags after item update" do
    item = Factory.create :item, tags_as_string: 'a, b'
    Models::Tag.count.should == 2
    
    item.tags = ['a', 'c']
    item.save!

    Models::Tag.count.should == 2
    Models::Tag.all.collect(&:name).sort.should == ['a', 'c']
  end
  
  it "should update tags after item deletion" do
    item = Factory.create :item, tags_as_string: 'a, b'
    Models::Tag.count.should == 2
    item.destroy
    Models::Tag.count.should == 0
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rad_kit-0.0.8 spec/models/tags_spec.rb
rad_kit-0.0.7 spec/models/tags_spec.rb
rad_kit-0.0.6 spec/models/tags_spec.rb
rad_kit-0.0.5 spec/models/tags_spec.rb
rad_kit-0.0.4 spec/models/tags_spec.rb
rad_kit-0.0.3 spec/models/tags_spec.rb
rad_kit-0.0.2 spec/models/tags_spec.rb
rad_kit-0.0.1 spec/models/tags_spec.rb