Sha256: d9cb629c4735866b998363da5c53aacd7decfbc077fee5a30d9b8d12330ec0c8

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

require 'test_helper'

class Kaui::ChargebacksControllerTest < Kaui::FunctionalTestHelper

  test 'should handle Kill Bill errors in new screen' do
    payment_id = SecureRandom.uuid.to_s
    get :new, :account_id => @account.account_id, :payment_id => payment_id
    assert_redirected_to account_path(@account.account_id)
    assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{payment_id} type=PAYMENT doesn't exist!", flash[:error]
  end

  test 'should get new' do
    get :new, :account_id => @account.account_id, :payment_id => @payment.payment_id
    assert_response 200
  end

  test 'should handle Kill Bill errors during create' do
    payment_id = SecureRandom.uuid.to_s
    post :create,
         :account_id => @payment.account_id,
         :chargeback => {
             :payment_id => payment_id,
             :amount => @payment.paid_amount_to_money.to_f,
             :currency => @payment.currency
         }
    assert_template :new
    assert_equal "Error while creating a new chargeback: Error 404: Object id=#{payment_id} type=PAYMENT doesn't exist!", flash[:error]
  end

  test 'should create chargeback' do
    post :create,
         :account_id => @payment.account_id,
         :chargeback => {
             :payment_id => @payment.payment_id,
             :amount => @payment.paid_amount_to_money.to_f,
             :currency => @payment.currency
         },
         :cancel_all_subs => '1'
    assert_redirected_to account_payment_path(@payment.account_id, @payment.payment_id)
    assert_equal 'Chargeback created', flash[:notice]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kaui-0.15.5 test/functional/kaui/chargebacks_controller_test.rb
kaui-0.15.4 test/functional/kaui/chargebacks_controller_test.rb
kaui-0.15.3 test/functional/kaui/chargebacks_controller_test.rb
kaui-0.15.2 test/functional/kaui/chargebacks_controller_test.rb
kaui-0.15.1 test/functional/kaui/chargebacks_controller_test.rb
kaui-0.15.0 test/functional/kaui/chargebacks_controller_test.rb