Sha256: ec2dc41f4193a8a556ca4afcea1068d0f4d6b0c9b91e894d1ade3275779ef8f1

Contents?: true

Size: 902 Bytes

Versions: 11

Compression:

Stored size: 902 Bytes

Contents

require 'spec_helper'

module Alchemy
  describe Tag do
    
    describe '.replace' do
      let(:picture) { Picture.new }
      let(:element) { Element.new }
      let(:tag)     { Tag.new(name: 'red') }
      let(:new_tag) { Tag.new(name: 'green') }

      before do
        picture.stub!(:tag_list).and_return(['red'])
        element.stub!(:tag_list).and_return(['red'])
        picture.stub!(:save).and_return(true)
        element.stub!(:save).and_return(true)
        tag.stub!(:taggings).and_return([
          mock_model(ActsAsTaggableOn::Tagging, taggable: picture),
          mock_model(ActsAsTaggableOn::Tagging, taggable: element)
        ])
      end

      it "should replace given tag with new one on all models tagged with tag" do
        Tag.replace(tag, new_tag)
        picture.tag_list.should eq(['green'])
        element.tag_list.should eq(['green'])
      end
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
alchemy_cms-2.9.1 spec/models/tag_spec.rb
alchemy_cms-2.9.0 spec/models/tag_spec.rb
alchemy_cms-2.8.3 spec/models/tag_spec.rb
alchemy_cms-2.7.5 spec/models/tag_spec.rb
alchemy_cms-2.7.4 spec/models/tag_spec.rb
alchemy_cms-2.8.2 spec/models/tag_spec.rb
alchemy_cms-2.8.1 spec/models/tag_spec.rb
alchemy_cms-2.7.3 spec/models/tag_spec.rb
alchemy_cms-2.7.2 spec/models/tag_spec.rb
alchemy_cms-2.7.1 spec/models/tag_spec.rb
alchemy_cms-2.7.0 spec/models/tag_spec.rb