Sha256: 32d7b04847d67d23475e0b115de2101c5ea184f7b16991f1477a49524fb5430f

Contents?: true

Size: 893 Bytes

Versions: 9

Compression:

Stored size: 893 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

9 entries across 9 versions & 1 rubygems

Version Path
alchemy_cms-3.0.4 spec/models/tag_spec.rb
alchemy_cms-3.0.3 spec/models/tag_spec.rb
alchemy_cms-3.0.2 spec/models/tag_spec.rb
alchemy_cms-3.0.1 spec/models/tag_spec.rb
alchemy_cms-3.0.0 spec/models/tag_spec.rb
alchemy_cms-3.0.0.rc8 spec/models/tag_spec.rb
alchemy_cms-3.0.0.rc7 spec/models/tag_spec.rb
alchemy_cms-3.0.0.rc6 spec/models/tag_spec.rb
alchemy_cms-3.0.0.rc5 spec/models/tag_spec.rb