Sha256: e43d4b103ff74512a226c9cc1af1918bd04761a565cb9ad875f1a183962b8966

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

require 'core/spec_helper'

describe ZendeskAPI::Tag, :vcr, :not_findable do
  it_should_be_readable :tags

  [organization, topic, ticket].each do |object|
    under object do
      before(:each) do
        parent.tags = %w{tag2 tag3}
        parent.tags.save!
      end

      it "can be set" do
        expect(tags).to eq(%w{tag2 tag3})
      end

      it "should be removable" do
        parent.tags.destroy!(:id => "tag2")

        expect(tags).to eq(%w{tag3})
      end

      it "shouldn't re-save destroyed tags" do
        parent.tags.first.destroy!
        parent.tags.save!

        expect(tags).to eq(%w{tag3})
      end

      it "should be updatable" do
        parent.tags.update!(:id => "tag4")

        expect(tags).to eq(%w{tag2 tag3 tag4})
      end

      it "should be savable" do
        parent.tags << "tag4"
        parent.tags.save!

        expect(tags).to eq(%w{tag2 tag3 tag4})
      end

      it "should be modifiable" do
        parent.tags.delete(ZendeskAPI::Tag.new(nil, :id => "tag2"))
        parent.tags.save!

        expect(tags).to eq(%w{tag3})

        parent.tags.delete_if {|tag| tag.id == "tag3"}
        parent.tags.save!

        expect(tags).to be_empty
      end
    end
  end

  def tags
    parent.tags.fetch!(:reload).map(&:id).sort
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zendesk_api-1.4.3 spec/live/tag_spec.rb
zendesk_api-1.4.2 spec/live/tag_spec.rb
zendesk_api-1.4.0 spec/live/tag_spec.rb