Sha256: b2fe2a85da89a0681420435e12f7c824ce104330c93963f9a4df233621e55336

Contents?: true

Size: 1.92 KB

Versions: 16

Compression:

Stored size: 1.92 KB

Contents

require 'test_helper'

class Kaui::CreditsControllerTest < Kaui::FunctionalTestHelper

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

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

  test 'should get new for existing invoice' do
    get :new, :account_id => @account.account_id, :invoice_id => @invoice_item.invoice_id
    assert_response 200
  end

  test 'should handle Kill Bill errors during creation' do
    invoice_id = SecureRandom.uuid.to_s
    post :create,
         :account_id => @account.account_id,
         :credit => {
             :invoice_id => invoice_id,
             :credit_amount => 5.34
         }
    assert_redirected_to account_path(@account.account_id)
    assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
  end

  test 'should create credit' do
    post :create,
         :account_id => @account.account_id,
         :credit => {
             :credit_amount => 5.34
         }
    assert_redirected_to account_path(@account.account_id)
    assert_equal 'Credit was successfully created', flash[:notice]
  end

  test 'should create credit for existing invoice' do
    post :create,
         :account_id => @account.account_id,
         :credit => {
             :invoice_id => @invoice_item.invoice_id,
             :credit_amount => 5.34
         }
    assert_redirected_to account_invoice_path(@account.account_id, @invoice_item.invoice_id)
    assert_equal 'Credit was successfully created', flash[:notice]
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
kaui-2.0.0 test/functional/kaui/credits_controller_test.rb
kaui-1.4.1 test/functional/kaui/credits_controller_test.rb
kaui-1.4.0 test/functional/kaui/credits_controller_test.rb
kaui-1.3.0 test/functional/kaui/credits_controller_test.rb
kaui-1.2.0 test/functional/kaui/credits_controller_test.rb
kaui-1.1.0 test/functional/kaui/credits_controller_test.rb
kaui-1.0.0 test/functional/kaui/credits_controller_test.rb
kaui-0.16.2 test/functional/kaui/credits_controller_test.rb
kaui-0.16.1 test/functional/kaui/credits_controller_test.rb
kaui-0.16.0 test/functional/kaui/credits_controller_test.rb
kaui-0.15.5 test/functional/kaui/credits_controller_test.rb
kaui-0.15.4 test/functional/kaui/credits_controller_test.rb
kaui-0.15.3 test/functional/kaui/credits_controller_test.rb
kaui-0.15.2 test/functional/kaui/credits_controller_test.rb
kaui-0.15.1 test/functional/kaui/credits_controller_test.rb
kaui-0.15.0 test/functional/kaui/credits_controller_test.rb