mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
added tests
This commit is contained in:
parent
005a888f50
commit
f22f16d720
7 changed files with 81 additions and 2 deletions
|
@ -7,7 +7,7 @@ module EisBilling
|
|||
# irb(main):048:0> decrypted_back = crypt.decrypt_and_verify(encrypted_data)
|
||||
# => "PLEASE CREATE INVOICE"
|
||||
TOKEN = "Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw==".freeze
|
||||
BASE_URL = "http://eis_billing_system:3000".freeze
|
||||
BASE_URL = ENV['eis_billing_system_base_url']
|
||||
|
||||
protected
|
||||
|
||||
|
|
|
@ -235,3 +235,4 @@ registry_demo_accredited_users_url: 'http://registry.test/api/v1/accreditation_c
|
|||
a_and_aaaa_validation_timeout: '1'
|
||||
nameserver_validation_timeout: '1'
|
||||
|
||||
eis_billing_system_base_url: 'http://eis_billing_system:3000'
|
||||
|
|
25
test/system/registrar_area/add_deposits_test.rb
Normal file
25
test/system/registrar_area/add_deposits_test.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class AddDepositsTest < ApplicationSystemTestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
sign_in users(:api_bestnames)
|
||||
@invoice = invoices(:one)
|
||||
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
def test_should_send_request_for_creating_invoice_to_eis_system
|
||||
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
|
||||
Spy.on_instance_method(EisBilling::GetInvoiceLink, :send_request).and_return(eis_response)
|
||||
|
||||
Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
|
||||
|
||||
visit new_registrar_deposit_url
|
||||
fill_in 'Amount', with: '100.0'
|
||||
click_button text: 'Add'
|
||||
|
||||
assert_text 'Everypay link'
|
||||
end
|
||||
end
|
|
@ -4,6 +4,11 @@ class BalanceTopUpTest < ApplicationSystemTestCase
|
|||
setup do
|
||||
sign_in users(:api_bestnames)
|
||||
@original_registry_vat_rate = Setting.registry_vat_prc
|
||||
|
||||
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
|
||||
Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
|
||||
Spy.on_instance_method(EisBilling::GetInvoiceLink, :send_request).and_return(eis_response)
|
||||
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
|
|
@ -3,6 +3,9 @@ require 'application_system_test_case'
|
|||
class NewInvoicePaymentTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
|
||||
Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
|
||||
Spy.on_instance_method(EisBilling::GetInvoiceLink, :send_request).and_return(eis_response)
|
||||
|
||||
@original_vat_prc = Setting.registry_vat_prc
|
||||
Setting.registry_vat_prc = 0.2
|
||||
|
|
|
@ -6,6 +6,10 @@ class NewInvoiceTest < ApplicationSystemTestCase
|
|||
|
||||
@user = users(:api_bestnames)
|
||||
sign_in @user
|
||||
|
||||
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
|
||||
Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
|
||||
Spy.on_instance_method(EisBilling::GetInvoiceLink, :send_request).and_return(eis_response)
|
||||
end
|
||||
|
||||
def test_show_balance
|
||||
|
|
|
@ -8,9 +8,14 @@ class RegistrarAreaInvoicesTest < ApplicationSystemTestCase
|
|||
@invoice = invoices(:one)
|
||||
|
||||
ActionMailer::Base.deliveries.clear
|
||||
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
|
||||
Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
|
||||
end
|
||||
|
||||
def test_cancels_an_invoice
|
||||
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
|
||||
Spy.on_instance_method(EisBilling::GetInvoiceLink, :send_request).and_return(eis_response)
|
||||
|
||||
@invoice.account_activity = nil
|
||||
assert @invoice.cancellable?
|
||||
|
||||
|
@ -23,12 +28,18 @@ class RegistrarAreaInvoicesTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_invoice_delivery_form_is_pre_populated_with_billing_email_of_a_registrar
|
||||
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
|
||||
Spy.on_instance_method(EisBilling::GetInvoiceLink, :send_request).and_return(eis_response)
|
||||
|
||||
assert_equal 'billing@bestnames.test', @invoice.buyer.billing_email
|
||||
visit new_registrar_invoice_delivery_url(@invoice)
|
||||
assert_field 'Recipient', with: 'billing@bestnames.test'
|
||||
end
|
||||
|
||||
def test_delivers_an_invoice
|
||||
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
|
||||
Spy.on_instance_method(EisBilling::GetInvoiceLink, :send_request).and_return(eis_response)
|
||||
|
||||
visit registrar_invoice_url(@invoice)
|
||||
click_on 'Send'
|
||||
fill_in 'Recipient', with: 'billing@registrar.test'
|
||||
|
@ -40,4 +51,34 @@ class RegistrarAreaInvoicesTest < ApplicationSystemTestCase
|
|||
assert_current_path registrar_invoice_path(@invoice)
|
||||
assert_text 'Invoice has been sent'
|
||||
end
|
||||
end
|
||||
|
||||
def test_if_invoice_unpaid_should_be_present_everypay_link
|
||||
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
|
||||
Spy.on_instance_method(EisBilling::GetInvoiceLink, :send_request).and_return(eis_response)
|
||||
|
||||
invoice = invoices(:unpaid)
|
||||
visit registrar_invoice_url(invoice)
|
||||
|
||||
assert_text 'Everypay link'
|
||||
end
|
||||
|
||||
def test_if_invoice_unpaid_and_not_generated_link_comes_then_should_render_no_everypay_link
|
||||
eis_response = OpenStruct.new(body: "{\"error\":\"Invoice not found\", \"status\":\"no_found\"}")
|
||||
Spy.on_instance_method(EisBilling::GetInvoiceLink, :send_request).and_return(eis_response)
|
||||
|
||||
invoice = invoices(:unpaid)
|
||||
visit registrar_invoice_url(invoice)
|
||||
|
||||
assert_text 'No everypay link'
|
||||
end
|
||||
|
||||
def test_if_invoice_aldready_paid_there_should_not_any_everypay_link
|
||||
eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
|
||||
Spy.on_instance_method(EisBilling::GetInvoiceLink, :send_request).and_return(eis_response)
|
||||
|
||||
visit registrar_invoice_url(@invoice)
|
||||
|
||||
assert_no_text 'No everypay link'
|
||||
assert_no_text 'Everypay link'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue