Sha256: 2f1833427955babf0181ac12e147859c574cdd395a2f44abdcc0ea085131edd1

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require "support"

class TestDispute < Omise::Test
  setup do
    @dispute = Omise::Dispute.retrieve("dspt_test_5089off452g5m5te7xs")
  end

  def test_that_we_can_list_all_disputes
    disputes = Omise::Dispute.list

    assert_instance_of Omise::List, disputes
  end

  def test_that_we_can_list_all_open_disputes
    disputes = Omise::Dispute.list(status: :open)

    assert_instance_of Omise::List, disputes
  end

  def test_that_we_can_list_all_pending_disputes
    disputes = Omise::Dispute.list(status: :pending)

    assert_instance_of Omise::List, disputes
  end

  def test_that_we_can_list_all_closed_disputes
    disputes = Omise::Dispute.list(status: :closed)

    assert_instance_of Omise::List, disputes
  end

  def test_that_we_can_retrieve_a_dispute
    assert_instance_of Omise::Dispute, @dispute
    assert_equal "dspt_test_5089off452g5m5te7xs", @dispute.id
  end

  def test_that_we_can_reload_a_dispute
    @dispute.attributes.taint
    @dispute.reload

    refute @dispute.attributes.tainted?
  end

  def test_that_we_can_update_a_dispute
    @dispute.update(message: "Your dispute message")

    assert_equal @dispute.message, "Your dispute message"
  end

  def test_that_we_can_accept_a_dispute
    @dispute.attributes.taint

    assert_equal @dispute.status, "open"

    @dispute.accept

    assert_equal @dispute.status, "lost"
    refute @dispute.attributes.tainted?
  end

  def test_that_we_can_retrieve_a_list_of_documents
    assert_instance_of Omise::DocumentList, @dispute.documents
  end

  def test_that_search_returns_a_scoped_search
    assert_instance_of Omise::SearchScope, Omise::Dispute.search
    assert_equal "dispute", Omise::Dispute.search.scope
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omise-0.10.0 test/omise/test_dispute.rb