mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 04:07:33 +02:00
Rename #create_with_type to #new_with_type
This commit is contained in:
parent
fe8d1d1f0b
commit
5d8e78f3c6
4 changed files with 16 additions and 14 deletions
|
@ -12,13 +12,15 @@ class Registrar
|
|||
invoice = Invoice.find(params[:invoice_id])
|
||||
channel = params[:bank]
|
||||
|
||||
@payment_order = PaymentOrder.create_with_type(type: channel, invoice: invoice)
|
||||
@payment_order.save && @payment_order.reload
|
||||
@payment_order = PaymentOrder.new_with_type(type: channel, invoice: invoice)
|
||||
@payment_order.save
|
||||
@payment_order.reload
|
||||
|
||||
@payment_order.return_url = registrar_return_payment_with_url(@payment_order)
|
||||
@payment_order.response_url = registrar_response_payment_with_url(@payment_order)
|
||||
|
||||
@payment_order.save && @payment_order.reload
|
||||
@payment_order.save
|
||||
@payment_order.reload
|
||||
end
|
||||
|
||||
def back
|
||||
|
|
|
@ -53,7 +53,7 @@ class BankTransaction < ApplicationRecord
|
|||
return
|
||||
end
|
||||
|
||||
payment_order = PaymentOrder.create_with_type(type: channel, invoice: invoice)
|
||||
payment_order = PaymentOrder.new_with_type(type: channel, invoice: invoice)
|
||||
payment_order.save!
|
||||
|
||||
if create_activity(registrar, invoice)
|
||||
|
|
|
@ -32,7 +32,7 @@ class PaymentOrder < ApplicationRecord
|
|||
supported
|
||||
end
|
||||
|
||||
def self.create_with_type(type:, invoice:)
|
||||
def self.new_with_type(type:, invoice:)
|
||||
channel = ('PaymentOrders::' + type.camelize).constantize
|
||||
|
||||
PaymentOrder.new(type: channel, invoice: invoice)
|
||||
|
|
|
@ -44,34 +44,34 @@ class PaymentOrdersTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_correct_channel_is_assigned
|
||||
everypay_channel = PaymentOrder.create_with_type(type: 'every_pay', invoice: @invoice)
|
||||
everypay_channel = PaymentOrder.new_with_type(type: 'every_pay', invoice: @invoice)
|
||||
assert_equal everypay_channel.channel, 'EveryPay'
|
||||
assert_equal everypay_channel.class.config_namespace_name, 'every_pay'
|
||||
|
||||
swed_channel = PaymentOrder.create_with_type(type: 'swed', invoice: @invoice)
|
||||
swed_channel = PaymentOrder.new_with_type(type: 'swed', invoice: @invoice)
|
||||
assert_equal swed_channel.channel, 'Swed'
|
||||
assert_equal swed_channel.class.config_namespace_name, 'swed'
|
||||
|
||||
seb_channel = PaymentOrder.create_with_type(type: 'seb', invoice: @invoice)
|
||||
seb_channel = PaymentOrder.new_with_type(type: 'seb', invoice: @invoice)
|
||||
assert_equal seb_channel.channel, 'Seb'
|
||||
assert_equal seb_channel.class.config_namespace_name, 'seb'
|
||||
|
||||
lhv_channel = PaymentOrder.create_with_type(type: 'lhv', invoice: @invoice)
|
||||
lhv_channel = PaymentOrder.new_with_type(type: 'lhv', invoice: @invoice)
|
||||
assert_equal lhv_channel.channel, 'Lhv'
|
||||
assert_equal lhv_channel.class.config_namespace_name, 'lhv'
|
||||
|
||||
admin_channel = PaymentOrder.create_with_type(type: 'admin_payment', invoice: @invoice)
|
||||
admin_channel = PaymentOrder.new_with_type(type: 'admin_payment', invoice: @invoice)
|
||||
assert_equal admin_channel.channel, 'AdminPayment'
|
||||
assert_equal admin_channel.class.config_namespace_name, 'admin_payment'
|
||||
|
||||
system_channel = PaymentOrder.create_with_type(type: 'system_payment', invoice: @invoice)
|
||||
system_channel = PaymentOrder.new_with_type(type: 'system_payment', invoice: @invoice)
|
||||
assert_equal system_channel.channel, 'SystemPayment'
|
||||
assert_equal system_channel.class.config_namespace_name, 'system_payment'
|
||||
end
|
||||
|
||||
def test_can_not_create_order_for_paid_invoice
|
||||
invoice = invoices(:one)
|
||||
payment_order = PaymentOrder.create_with_type(type: 'every_pay', invoice: invoice)
|
||||
payment_order = PaymentOrder.new_with_type(type: 'every_pay', invoice: invoice)
|
||||
assert payment_order.invalid?
|
||||
assert_includes payment_order.errors[:invoice], 'is already paid'
|
||||
end
|
||||
|
@ -84,7 +84,7 @@ class PaymentOrdersTest < ActiveSupport::TestCase
|
|||
|
||||
def test_can_not_create_order_with_invalid_type
|
||||
assert_raise NameError do
|
||||
PaymentOrder.create_with_type(type: 'not_implemented', invoice: Invoice.new)
|
||||
PaymentOrder.new_with_type(type: 'not_implemented', invoice: Invoice.new)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -97,7 +97,7 @@ class PaymentOrdersTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_can_create_with_correct_subclass
|
||||
payment = PaymentOrder.create_with_type(type: 'seb', invoice: Invoice.new)
|
||||
payment = PaymentOrder.new_with_type(type: 'seb', invoice: Invoice.new)
|
||||
assert_equal PaymentOrders::Seb, payment.class
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue