Sha256: f0ba525a7c27920dfdc61ba761e06d1e74f6cc03b7670722eae026a830642064

Contents?: true

Size: 1.62 KB

Versions: 31

Compression:

Stored size: 1.62 KB

Contents

require 'core/spec_helper'

describe ZendeskAPI::Topic::TopicComment do
  def valid_attributes
    { :body => "Texty-text, text." }
  end

  under topic do
    it_should_be_creatable
    it_should_be_updatable :body
    it_should_be_deletable
    it_should_be_readable topic, :comments
  end

  describe ".import" do
    it "can import" do
      VCR.use_cassette("topic_comment_import_can_import") do
        old = Time.now - 4*365*24*60*60
        comment = ZendeskAPI::Topic::TopicComment.import(client, valid_attributes.merge(:created_at => old, :topic_id => topic.id))
        expect(ZendeskAPI::Topic::TopicComment.find(client, comment).created_at.year).to eq(old.year)
      end
    end

    it "returns nothing if import fails" do
      VCR.use_cassette("topic_comment_import_cannot_import") do
        silence_logger { expect(ZendeskAPI::Topic::TopicComment.import(client, {})).to eq(nil) }
      end
    end
  end

  it "can upload while creating" do
    VCR.use_cassette("topic_comment_inline_uploads") do
      comment = ZendeskAPI::Topic::TopicComment.new(client, valid_attributes.merge(:topic_id => topic.id))
      comment.uploads << "spec/fixtures/Argentina.gif"
      comment.uploads << File.new("spec/fixtures/Argentina.gif")

      comment.save!
      expect(comment.changes).to eq({}) # uploads were set before save
      expect(comment.attributes[:uploads].map(&:class)).to eq([String, String]) # upload was sent as tokens
    end
  end
end

describe ZendeskAPI::User::TopicComment do
  def valid_attributes
    { :body => "Texty-text, text."}
  end

  under current_user do
    it_should_be_readable current_user, :topic_comments
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
zendesk_api-1.13.1 spec/live/topic_comment_spec.rb
zendesk_api-1.12.1 spec/live/topic_comment_spec.rb
zendesk_api-1.12.0 spec/live/topic_comment_spec.rb
zendesk_api-1.11.7 spec/live/topic_comment_spec.rb
zendesk_api-1.11.6 spec/live/topic_comment_spec.rb
zendesk_api-1.11.5 spec/live/topic_comment_spec.rb
zendesk_api-1.11.4 spec/live/topic_comment_spec.rb
zendesk_api-1.11.3 spec/live/topic_comment_spec.rb
zendesk_api-1.11.2 spec/live/topic_comment_spec.rb
zendesk_api-1.11.1 spec/live/topic_comment_spec.rb
zendesk_api-1.11.0 spec/live/topic_comment_spec.rb
zendesk_api-1.10.0 spec/live/topic_comment_spec.rb
zendesk_api-1.9.6 spec/live/topic_comment_spec.rb
zendesk_api-1.9.5 spec/live/topic_comment_spec.rb
zendesk_api-1.9.4 spec/live/topic_comment_spec.rb
zendesk_api-1.9.3 spec/live/topic_comment_spec.rb
zendesk_api-1.9.2 spec/live/topic_comment_spec.rb
zendesk_api-1.9.1 spec/live/topic_comment_spec.rb
zendesk_api-1.9.0 spec/live/topic_comment_spec.rb
zendesk_api-1.8.0 spec/live/topic_comment_spec.rb