Sha256: 8c3784113b9d6032df1e836beaf1946f9d1737abae369a18f8caccac64c76d40

Contents?: true

Size: 1.76 KB

Versions: 9

Compression:

Stored size: 1.76 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe Braintree::DisputeSearch do
  it "overrides previous 'is' with new 'is' for the same field" do
    search = Braintree::DisputeSearch.new
    search.id.is "dispute1"
    search.id.is "dispute2"
    expect(search.to_hash).to eq({:id => {:is => "dispute2"}})
  end

  it "overrides previous 'in' with new 'in' for the same field" do
    search = Braintree::DisputeSearch.new
    search.status.in Braintree::Dispute::Status::Open
    search.status.in Braintree::Dispute::Status::Won
    expect(search.to_hash).to eq({:status => [Braintree::Dispute::Status::Won]})
  end

  [
    :amount_disputed,
    :amount_won,
    :case_number,
    :customer_id,
    :disbursement_date,
    :effective_date,
    :id,
    :merchant_account_id,
    :reason_code,
    :received_date,
    :reference_number,
    :reply_by_date,
    :transaction_id,
    :transaction_source,
  ].each do |field|
    it "allows searching on #{field}" do
      search = Braintree::DisputeSearch.new

      expect do
        search.send(field).is "hello"
      end.not_to raise_error
    end
  end

  [
    # NEXT_MAJOR_VERSION Remove this assertion when chargeback_protection_level is removed from the SDK
    :chargeback_protection_level,
    :protection_level,
    :kind,
    :reason,
    :status,
    :pre_dispute_program,
  ].each do |field|
    it "raises if provided an unknown #{field} value" do
      search = Braintree::DisputeSearch.new
      expect do
        search.send(field).is "unknown value"
      end.to raise_error(/Invalid argument/)
    end
  end

  it "raises if no operator is provided" do
    search = Braintree::DisputeSearch.new
    expect do
      search.id "one"
    end.to raise_error(RuntimeError, "An operator is required")
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
braintree-4.23.0 spec/unit/braintree/dispute_search_spec.rb
braintree-4.22.0 spec/unit/braintree/dispute_search_spec.rb
braintree-4.21.0 spec/unit/braintree/dispute_search_spec.rb
braintree-4.20.0 spec/unit/braintree/dispute_search_spec.rb
braintree-4.19.0 spec/unit/braintree/dispute_search_spec.rb
braintree-4.18.0 spec/unit/braintree/dispute_search_spec.rb
braintree-4.17.0 spec/unit/braintree/dispute_search_spec.rb
braintree-4.16.0 spec/unit/braintree/dispute_search_spec.rb
braintree-4.15.0 spec/unit/braintree/dispute_search_spec.rb