kaui 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +5 -29
- data/app/assets/javascripts/kaui/kaui.js +1 -1
- data/app/assets/stylesheets/kaui/account.less +9 -1
- data/app/assets/stylesheets/kaui/common.less +46 -3
- data/app/controllers/kaui/accounts_controller.rb +11 -15
- data/app/controllers/kaui/admin_tenants_controller.rb +77 -106
- data/app/controllers/kaui/audit_logs_controller.rb +3 -3
- data/app/controllers/kaui/bundles_controller.rb +4 -0
- data/app/controllers/kaui/engine_controller_util.rb +25 -17
- data/app/controllers/kaui/invoice_tags_controller.rb +28 -0
- data/app/controllers/kaui/invoices_controller.rb +65 -14
- data/app/controllers/kaui/payment_methods_controller.rb +14 -3
- data/app/controllers/kaui/sessions_controller.rb +6 -0
- data/app/controllers/kaui/subscriptions_controller.rb +13 -4
- data/app/helpers/kaui/account_helper.rb +10 -2
- data/app/helpers/kaui/payment_method_helper.rb +5 -3
- data/app/helpers/kaui/plugin_helper.rb +10 -49
- data/app/helpers/kaui/subscription_helper.rb +26 -9
- data/app/helpers/kaui/uuid_helper.rb +1 -0
- data/app/models/kaui/admin_tenant.rb +8 -84
- data/app/models/kaui/catalog.rb +28 -2
- data/app/models/kaui/tag.rb +1 -1
- data/app/views/kaui/account_emails/_form.html.erb +1 -1
- data/app/views/kaui/accounts/_billing_info.html.erb +4 -0
- data/app/views/kaui/accounts/_form.html.erb +1 -1
- data/app/views/kaui/accounts/_payment_methods.html.erb +3 -0
- data/app/views/kaui/accounts/index.html.erb +7 -4
- data/app/views/kaui/admin_tenants/_form_plugin_config.erb +59 -241
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +2 -2
- data/app/views/kaui/admin_tenants/new_catalog.html.erb +16 -15
- data/app/views/kaui/bundles/_bundle_details.html.erb +12 -0
- data/app/views/kaui/bundles/index.html.erb +3 -14
- data/app/views/kaui/chargebacks/_form.html.erb +1 -1
- data/app/views/kaui/charges/_form.html.erb +1 -1
- data/app/views/kaui/invoice_tags/_form.html.erb +33 -0
- data/app/views/kaui/invoice_tags/_form_bar.html.erb +21 -0
- data/app/views/kaui/invoice_tags/edit.html.erb +10 -0
- data/app/views/kaui/invoices/_invoice_table.html.erb +30 -9
- data/app/views/kaui/invoices/index.html.erb +6 -4
- data/app/views/kaui/invoices/show.html.erb +11 -2
- data/app/views/kaui/layouts/kaui_flash.html.erb +8 -1
- data/app/views/kaui/payments/_form.html.erb +1 -1
- data/app/views/kaui/payments/_payment_table.html.erb +2 -2
- data/app/views/kaui/payments/index.html.erb +3 -1
- data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +3 -3
- data/config/routes.rb +6 -1
- data/lib/kaui.rb +55 -0
- data/lib/kaui/version.rb +1 -1
- data/test/dummy/config/database.yml +2 -2
- data/test/dummy/config/initializers/cookies_serializer.rb +1 -1
- data/test/dummy/config/initializers/money.rb +2 -0
- data/test/functional/kaui/account_emails_controller_test.rb +2 -2
- data/test/functional/kaui/account_tags_controller_test.rb +1 -1
- data/test/functional/kaui/accounts_controller_test.rb +4 -4
- data/test/functional/kaui/admin_tenants_controller_test.rb +3 -23
- data/test/functional/kaui/bundle_tags_controller_test.rb +1 -1
- data/test/functional/kaui/bundles_controller_test.rb +3 -3
- data/test/functional/kaui/chargebacks_controller_test.rb +2 -2
- data/test/functional/kaui/charges_controller_test.rb +2 -2
- data/test/functional/kaui/credits_controller_test.rb +5 -5
- data/test/functional/kaui/home_controller_test.rb +5 -5
- data/test/functional/kaui/invoice_items_controller_test.rb +3 -3
- data/test/functional/kaui/invoices_controller_test.rb +2 -2
- data/test/functional/kaui/refunds_controller_test.rb +2 -2
- data/test/functional/kaui/subscriptions_controller_test.rb +6 -6
- data/test/killbill_test_helper.rb +8 -6
- data/test/unit/helpers/kaui/payment_method_helper_test.rb +17 -0
- data/test/unit/kaui/account_test.rb +2 -2
- data/test/unit/kaui/admin_tenant_test.rb +10 -47
- data/test/unit/kaui/invoice_item_test.rb +1 -1
- data/test/unit/kaui/invoice_payment_test.rb +7 -7
- data/test/unit/kaui/invoice_test.rb +4 -4
- data/test/unit/kaui/payment_test.rb +7 -7
- metadata +110 -86
data/config/routes.rb
CHANGED
@@ -46,6 +46,10 @@ Kaui::Engine.routes.draw do
|
|
46
46
|
match '/edit' => 'bundle_tags#edit', :via => :get, :as => 'edit_bundle_tags'
|
47
47
|
match '/edit' => 'bundle_tags#update', :via => :post, :as => 'update_bundle_tags'
|
48
48
|
end
|
49
|
+
scope '/invoice_tags' do
|
50
|
+
match '/edit' => 'invoice_tags#edit', :via => :get, :as => 'edit_invoice_tags'
|
51
|
+
match '/edit' => 'invoice_tags#update', :via => :post, :as => 'update_invoice_tags'
|
52
|
+
end
|
49
53
|
scope '/timeline' do
|
50
54
|
match '/' => 'account_timelines#show', :via => :get, :as => 'account_timeline'
|
51
55
|
end
|
@@ -86,6 +90,7 @@ Kaui::Engine.routes.draw do
|
|
86
90
|
|
87
91
|
scope '/payment_methods' do
|
88
92
|
match '/validate_external_key' => 'payment_methods#validate_external_key', :via => :get, :as => 'payment_methods_validate_external_key'
|
93
|
+
match '/refresh' => 'payment_methods#refresh', :via => :post, :as => 'refresh_payment_methods'
|
89
94
|
end
|
90
95
|
resources :payment_methods, :only => [:new, :create, :show, :destroy]
|
91
96
|
|
@@ -94,6 +99,7 @@ Kaui::Engine.routes.draw do
|
|
94
99
|
match '/:id/show_html' => 'invoices#show_html', :via => :get, :as => 'show_html_invoice'
|
95
100
|
match '/:id' => 'invoices#restful_show', :via => :get, :as => 'invoice'
|
96
101
|
match '/commit' => 'invoices#commit_invoice', :via => :post, :as => 'commit_invoice'
|
102
|
+
match '/void' => 'invoices#void_invoice', :via => :delete, :as => 'void_invoice'
|
97
103
|
end
|
98
104
|
resources :invoices, :only => [ :index ]
|
99
105
|
|
@@ -186,7 +192,6 @@ Kaui::Engine.routes.draw do
|
|
186
192
|
match '/add_allowed_user' => 'admin_tenants#add_allowed_user', :via => :put, :as => 'add_allowed_user'
|
187
193
|
match '/allowed_users' => 'admin_tenants#allowed_users', :via => :get, :as => 'admin_tenant_allowed_users'
|
188
194
|
match '/catalog_by_effective_date' => 'admin_tenants#catalog_by_effective_date', :via => :get, :as => 'catalog_by_effective_date'
|
189
|
-
match '/suggest_plugin_name' => 'admin_tenants#suggest_plugin_name', :via => :get, :as => 'suggest_plugin_name'
|
190
195
|
match '/switch' => 'admin_tenants#switch_tenant', :via => :get, :as => 'switch_tenant'
|
191
196
|
match '/:id/download_catalog' => 'admin_tenants#download_catalog_xml', :via => :get, :as => 'download_catalog_xml'
|
192
197
|
end
|
data/lib/kaui.rb
CHANGED
@@ -10,8 +10,18 @@ module Kaui
|
|
10
10
|
mattr_accessor :new_user_session_path
|
11
11
|
mattr_accessor :destroy_user_session_path
|
12
12
|
|
13
|
+
mattr_accessor :bundle_details_partial
|
14
|
+
|
15
|
+
mattr_accessor :pretty_account_identifier
|
13
16
|
mattr_accessor :bundle_key_display_string
|
14
17
|
mattr_accessor :creditcard_plugin_name
|
18
|
+
|
19
|
+
mattr_accessor :account_search_columns
|
20
|
+
mattr_accessor :invoice_search_columns
|
21
|
+
mattr_accessor :account_invoices_columns
|
22
|
+
|
23
|
+
mattr_accessor :customer_invoice_link
|
24
|
+
|
15
25
|
mattr_accessor :layout
|
16
26
|
|
17
27
|
mattr_accessor :thread_pool
|
@@ -39,9 +49,54 @@ module Kaui
|
|
39
49
|
self.home_path = lambda { Kaui::Engine.routes.url_helpers.home_path }
|
40
50
|
self.tenant_home_path = lambda { Kaui::Engine.routes.url_helpers.tenants_path }
|
41
51
|
|
52
|
+
self.bundle_details_partial = 'kaui/bundles/bundle_details'
|
53
|
+
|
54
|
+
self.pretty_account_identifier = lambda { |account| account.name.presence || account.email.presence || Kaui::UuidHelper.truncate_uuid(account.external_key) }
|
42
55
|
self.bundle_key_display_string = lambda {|bundle_key| bundle_key }
|
43
56
|
self.creditcard_plugin_name = lambda { '__EXTERNAL_PAYMENT__' }
|
44
57
|
|
58
|
+
self.account_search_columns = lambda do |account=nil, view_context=nil|
|
59
|
+
[
|
60
|
+
['External key', 'Balance'],
|
61
|
+
[
|
62
|
+
account&.external_key,
|
63
|
+
account.nil? || view_context.nil? ? nil : view_context.humanized_money_with_symbol(account.balance_to_money)
|
64
|
+
]
|
65
|
+
]
|
66
|
+
end
|
67
|
+
|
68
|
+
self.invoice_search_columns = lambda do |invoice=nil, view_context=nil|
|
69
|
+
default_label = 'label-info'
|
70
|
+
default_label = 'label-default' if invoice&.status == 'DRAFT'
|
71
|
+
default_label = 'label-success' if invoice&.status == 'COMMITTED'
|
72
|
+
default_label = 'label-danger' if invoice&.status == 'VOID'
|
73
|
+
[
|
74
|
+
['Date', 'Status'],
|
75
|
+
[
|
76
|
+
invoice&.invoice_date,
|
77
|
+
invoice.nil? || view_context.nil? ? nil : view_context.content_tag(:span, invoice.status, class: ['label', default_label])
|
78
|
+
]
|
79
|
+
]
|
80
|
+
end
|
81
|
+
|
82
|
+
self.account_invoices_columns = lambda do |invoice=nil, view_context=nil|
|
83
|
+
default_label = 'label-info'
|
84
|
+
default_label = 'label-default' if invoice&.status == 'DRAFT'
|
85
|
+
default_label = 'label-success' if invoice&.status == 'COMMITTED'
|
86
|
+
default_label = 'label-danger' if invoice&.status == 'VOID'
|
87
|
+
[
|
88
|
+
['Date', 'Amount', 'Balance', 'Status'],
|
89
|
+
[
|
90
|
+
invoice&.invoice_date,
|
91
|
+
invoice.nil? || view_context.nil? ? nil : view_context.humanized_money_with_symbol(invoice.amount_to_money),
|
92
|
+
invoice.nil? || view_context.nil? ? nil : view_context.humanized_money_with_symbol(invoice.balance_to_money),
|
93
|
+
invoice.nil? || view_context.nil? ? nil : view_context.content_tag(:span, invoice.status, class: ['label', default_label])
|
94
|
+
]
|
95
|
+
]
|
96
|
+
end
|
97
|
+
|
98
|
+
self.customer_invoice_link = lambda { |invoice, ctx| ctx.link_to 'View customer invoice html', ctx.kaui_engine.show_html_invoice_path(invoice.invoice_id), :class => 'btn', :target => '_blank' }
|
99
|
+
|
45
100
|
self.demo_mode = false
|
46
101
|
|
47
102
|
# Root credentials for SaaS operations
|
data/lib/kaui/version.rb
CHANGED
@@ -3,7 +3,7 @@ default: &default
|
|
3
3
|
encoding: utf8
|
4
4
|
username: <%= ENV.fetch('DB_USER', 'root') %>
|
5
5
|
password: <%= ENV.fetch('DB_PASSWORD', 'root') %>
|
6
|
-
host: 127.0.0.1
|
6
|
+
host: <%= ENV.fetch('DB_HOST', '127.0.0.1') %>
|
7
7
|
port: <%= ENV.fetch('DB_PORT', '3306') %>
|
8
8
|
pool: 25
|
9
9
|
timeout: 5000
|
@@ -17,7 +17,7 @@ default: &default
|
|
17
17
|
|
18
18
|
development:
|
19
19
|
<<: *default
|
20
|
-
database: kaui
|
20
|
+
database: <%= ENV.fetch('DB_NAME', 'kaui') %>
|
21
21
|
|
22
22
|
# Warning: The database defined as "test" will be erased and
|
23
23
|
# re-generated from your development database when you run "rake".
|
@@ -24,14 +24,14 @@ class Kaui::AccountEmailsControllerTest < Kaui::FunctionalTestHelper
|
|
24
24
|
:email => 'toto@example.com'
|
25
25
|
}
|
26
26
|
assert_redirected_to account_path(account_id)
|
27
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
27
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error]
|
28
28
|
end
|
29
29
|
|
30
30
|
test 'should handle Kill Bill errors during deletion' do
|
31
31
|
account_id = 'invalid-id'
|
32
32
|
delete :destroy, :account_id => account_id, :id => 'toto@example.com'
|
33
33
|
assert_redirected_to account_path(account_id)
|
34
|
-
assert_equal 'Error while communicating with the Kill Bill server:
|
34
|
+
assert_equal 'Error while communicating with the Kill Bill server: ', flash[:error]
|
35
35
|
end
|
36
36
|
|
37
37
|
test 'should add and destroy email' do
|
@@ -6,7 +6,7 @@ class Kaui::AccountTagsControllerTest < Kaui::FunctionalTestHelper
|
|
6
6
|
account_id = '1234'
|
7
7
|
get :edit, :account_id => account_id
|
8
8
|
assert_redirected_to account_path(account_id)
|
9
|
-
assert_equal 'Error while communicating with the Kill Bill server:
|
9
|
+
assert_equal 'Error while communicating with the Kill Bill server: ', flash[:error]
|
10
10
|
end
|
11
11
|
|
12
12
|
test 'should get edit' do
|
@@ -43,7 +43,7 @@ class Kaui::AccountsControllerTest < Kaui::FunctionalTestHelper
|
|
43
43
|
account_id = SecureRandom.uuid.to_s
|
44
44
|
get :show, :account_id => account_id
|
45
45
|
assert_redirected_to home_path
|
46
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
46
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error]
|
47
47
|
end
|
48
48
|
|
49
49
|
test 'should find account by id' do
|
@@ -101,7 +101,7 @@ class Kaui::AccountsControllerTest < Kaui::FunctionalTestHelper
|
|
101
101
|
|
102
102
|
post :create, :account => {:external_key => external_key}
|
103
103
|
assert_template :new
|
104
|
-
assert_equal "Error while creating account:
|
104
|
+
assert_equal "Error while creating account: Account already exists for key #{external_key}", flash[:error]
|
105
105
|
end
|
106
106
|
|
107
107
|
test 'should create account' do
|
@@ -152,7 +152,7 @@ class Kaui::AccountsControllerTest < Kaui::FunctionalTestHelper
|
|
152
152
|
account_id = SecureRandom.uuid.to_s
|
153
153
|
put :set_default_payment_method, :account_id => account_id, :payment_method_id => @payment_method.payment_method_id
|
154
154
|
assert_redirected_to home_path
|
155
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
155
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error]
|
156
156
|
end
|
157
157
|
|
158
158
|
test 'should set default payment method' do
|
@@ -164,7 +164,7 @@ class Kaui::AccountsControllerTest < Kaui::FunctionalTestHelper
|
|
164
164
|
account_id = SecureRandom.uuid.to_s
|
165
165
|
post :pay_all_invoices, :account_id => account_id
|
166
166
|
assert_redirected_to home_path
|
167
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
167
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error]
|
168
168
|
end
|
169
169
|
|
170
170
|
test 'should pay all invoices' do
|
@@ -94,7 +94,7 @@ class Kaui::AdminTenantsControllerTest < Kaui::FunctionalTestHelper
|
|
94
94
|
stripe_yml.each { |k, v| stripe_yml[k] = v.to_s }
|
95
95
|
post :upload_plugin_config, :id => tenant.id, :plugin_name => 'killbill-stripe', :plugin_key => 'stripe', :plugin_type => 'ruby', :plugin_properties => stripe_yml
|
96
96
|
|
97
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
97
|
+
assert_redirected_to admin_tenant_path(tenant.id, :active_tab => 'PluginConfig')
|
98
98
|
assert_equal 'Config for plugin was successfully uploaded', flash[:notice]
|
99
99
|
end
|
100
100
|
|
@@ -138,7 +138,7 @@ class Kaui::AdminTenantsControllerTest < Kaui::FunctionalTestHelper
|
|
138
138
|
:id => tenant.id,
|
139
139
|
:simple_plan => {
|
140
140
|
:product_category => 'STANDALONE',
|
141
|
-
:product_name => '
|
141
|
+
:product_name => 'Boat_Rental',
|
142
142
|
:plan_id => 'boat12345678910',
|
143
143
|
:amount => 10,
|
144
144
|
:currency => 'USD',
|
@@ -284,26 +284,6 @@ class Kaui::AdminTenantsControllerTest < Kaui::FunctionalTestHelper
|
|
284
284
|
|
285
285
|
end
|
286
286
|
|
287
|
-
test 'should suggest a plugin name' do
|
288
|
-
plugin_anchor = "'<a id=\"suggested\" data-plugin-name=\"killbill-paypal-express\" data-plugin-key=\"paypal_express\" data-plugin-type=\"ruby\" href=\"#\">killbill-paypal-express</a>'"
|
289
|
-
|
290
|
-
# Similar plugin already installed test will run, if there are plugin installed
|
291
|
-
installed_plugins = installed_plugins()
|
292
|
-
unless installed_plugins.blank?
|
293
|
-
installed_plugins.each do |plugin|
|
294
|
-
installed_plugin_anchor = "'<a id=\"suggested\" data-plugin-name=\"#{plugin[:plugin_name]}\" data-plugin-key=\"#{plugin[:plugin_key]}\".*href=\"#\">#{plugin[:plugin_name]}</a>'"
|
295
|
-
|
296
|
-
get :suggest_plugin_name, :plugin_name => plugin[:plugin_name][0, plugin[:plugin_name].length - 1]
|
297
|
-
assert_response :success
|
298
|
-
assert_match /Similar plugin already installed: #{installed_plugin_anchor}/, JSON[@response.body]['suggestion']
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
get :suggest_plugin_name, :plugin_name => 'pypl'
|
303
|
-
assert_response :success
|
304
|
-
assert_equal "Did you mean #{plugin_anchor}?", JSON[@response.body]['suggestion']
|
305
|
-
end
|
306
|
-
|
307
287
|
test 'should switch tenant' do
|
308
288
|
other_tenant = setup_and_create_test_tenant(1)
|
309
289
|
other_tenant_kaui = Kaui::Tenant.find_by_kb_tenant_id(other_tenant.tenant_id)
|
@@ -362,7 +342,7 @@ class Kaui::AdminTenantsControllerTest < Kaui::FunctionalTestHelper
|
|
362
342
|
next if plugin.plugin_key.nil? || plugin.version.nil?
|
363
343
|
next if installed_plugins.any? { |p| p[:plugin_name].eql?(plugin.plugin_name) }
|
364
344
|
installed_plugins << {
|
365
|
-
plugin_key:
|
345
|
+
plugin_key: plugin.plugin_key,
|
366
346
|
plugin_name: plugin.plugin_name
|
367
347
|
}
|
368
348
|
end
|
@@ -10,7 +10,7 @@ class Kaui::BundleTagsControllerTest < Kaui::FunctionalTestHelper
|
|
10
10
|
bundle_id = SecureRandom.uuid.to_s
|
11
11
|
get :edit, :account_id => @account.account_id, :bundle_id => bundle_id
|
12
12
|
assert_redirected_to account_path(@account.account_id)
|
13
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
13
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{bundle_id} type=BUNDLE doesn't exist!", flash[:error]
|
14
14
|
end
|
15
15
|
|
16
16
|
test 'should get edit' do
|
@@ -6,7 +6,7 @@ class Kaui::BundlesControllerTest < Kaui::FunctionalTestHelper
|
|
6
6
|
account_id = SecureRandom.uuid.to_s
|
7
7
|
get :index, :account_id => account_id
|
8
8
|
assert_redirected_to account_path(account_id)
|
9
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
9
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error]
|
10
10
|
end
|
11
11
|
|
12
12
|
test 'should get index with existing tags' do
|
@@ -35,12 +35,12 @@ class Kaui::BundlesControllerTest < Kaui::FunctionalTestHelper
|
|
35
35
|
new_account_key = SecureRandom.uuid.to_s
|
36
36
|
post :do_transfer, :id => @bundle.bundle_id, :new_account_key => new_account_key
|
37
37
|
assert_redirected_to home_path
|
38
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
38
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{new_account_key} type=ACCOUNT doesn't exist!", flash[:error]
|
39
39
|
|
40
40
|
bundle_id = SecureRandom.uuid.to_s
|
41
41
|
post :do_transfer, :id => bundle_id, :new_account_key => @account2.external_key
|
42
42
|
assert_redirected_to home_path
|
43
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
43
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{bundle_id} type=BUNDLE doesn't exist!", flash[:error]
|
44
44
|
end
|
45
45
|
|
46
46
|
test 'should get transfer' do
|
@@ -6,7 +6,7 @@ class Kaui::ChargebacksControllerTest < Kaui::FunctionalTestHelper
|
|
6
6
|
payment_id = SecureRandom.uuid.to_s
|
7
7
|
get :new, :account_id => @account.account_id, :payment_id => payment_id
|
8
8
|
assert_redirected_to account_path(@account.account_id)
|
9
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
9
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{payment_id} type=PAYMENT doesn't exist!", flash[:error]
|
10
10
|
end
|
11
11
|
|
12
12
|
test 'should get new' do
|
@@ -24,7 +24,7 @@ class Kaui::ChargebacksControllerTest < Kaui::FunctionalTestHelper
|
|
24
24
|
:currency => @payment.currency
|
25
25
|
}
|
26
26
|
assert_template :new
|
27
|
-
assert_equal "Error while creating a new chargeback:
|
27
|
+
assert_equal "Error while creating a new chargeback: Object id=#{payment_id} type=PAYMENT doesn't exist!", flash[:error]
|
28
28
|
end
|
29
29
|
|
30
30
|
test 'should create chargeback' do
|
@@ -6,7 +6,7 @@ class Kaui::ChargesControllerTest < Kaui::FunctionalTestHelper
|
|
6
6
|
invoice_id = SecureRandom.uuid.to_s
|
7
7
|
get :new, :account_id => @account.account_id, :invoice_id => invoice_id
|
8
8
|
assert_redirected_to account_path(@account.account_id)
|
9
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
9
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
10
10
|
end
|
11
11
|
|
12
12
|
test 'should get new for new invoice' do
|
@@ -30,7 +30,7 @@ class Kaui::ChargesControllerTest < Kaui::FunctionalTestHelper
|
|
30
30
|
:description => SecureRandom.uuid
|
31
31
|
}
|
32
32
|
assert_redirected_to account_path(@account.account_id)
|
33
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
33
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
34
34
|
end
|
35
35
|
|
36
36
|
test 'should create charge' do
|
@@ -6,7 +6,7 @@ class Kaui::CreditsControllerTest < Kaui::FunctionalTestHelper
|
|
6
6
|
invoice_id = SecureRandom.uuid.to_s
|
7
7
|
get :new, :account_id => @account.account_id, :invoice_id => invoice_id
|
8
8
|
assert_redirected_to account_path(@account.account_id)
|
9
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
9
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
10
10
|
end
|
11
11
|
|
12
12
|
test 'should get new for new invoice' do
|
@@ -25,17 +25,17 @@ class Kaui::CreditsControllerTest < Kaui::FunctionalTestHelper
|
|
25
25
|
:account_id => @account.account_id,
|
26
26
|
:credit => {
|
27
27
|
:invoice_id => invoice_id,
|
28
|
-
:
|
28
|
+
:amount => 5.34
|
29
29
|
}
|
30
30
|
assert_redirected_to account_path(@account.account_id)
|
31
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
31
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
32
32
|
end
|
33
33
|
|
34
34
|
test 'should create credit' do
|
35
35
|
post :create,
|
36
36
|
:account_id => @account.account_id,
|
37
37
|
:credit => {
|
38
|
-
:
|
38
|
+
:amount => 5.34
|
39
39
|
}
|
40
40
|
assert_redirected_to account_path(@account.account_id)
|
41
41
|
assert_equal 'Credit was successfully created', flash[:notice]
|
@@ -46,7 +46,7 @@ class Kaui::CreditsControllerTest < Kaui::FunctionalTestHelper
|
|
46
46
|
:account_id => @account.account_id,
|
47
47
|
:credit => {
|
48
48
|
:invoice_id => @invoice_item.invoice_id,
|
49
|
-
:
|
49
|
+
:amount => 5.34
|
50
50
|
}
|
51
51
|
assert_redirected_to account_invoice_path(@account.account_id, @invoice_item.invoice_id)
|
52
52
|
assert_equal 'Credit was successfully created', flash[:notice]
|
@@ -188,7 +188,7 @@ class Kaui::HomeControllerTest < Kaui::FunctionalTestHelper
|
|
188
188
|
dummy_uuid = SecureRandom.uuid.to_s
|
189
189
|
credit = create_credit
|
190
190
|
# search by ID
|
191
|
-
get :search, :q => query_builder('CREDIT',credit.
|
191
|
+
get :search, :q => query_builder('CREDIT',credit.invoice_item_id, 'ID')
|
192
192
|
assert_redirected_to account_invoice_path(credit.account_id, credit.invoice_id)
|
193
193
|
|
194
194
|
# search by ID and fails
|
@@ -202,11 +202,11 @@ class Kaui::HomeControllerTest < Kaui::FunctionalTestHelper
|
|
202
202
|
assert_equal "\"CREDIT\": Search by \"EXTERNAL KEY\" is not supported.", flash[:error]
|
203
203
|
|
204
204
|
# search by BLANK only first
|
205
|
-
get :search, :q => query_builder('CREDIT',credit.
|
205
|
+
get :search, :q => query_builder('CREDIT',credit.invoice_item_id, nil, '1')
|
206
206
|
assert_redirected_to account_invoice_path(credit.account_id, credit.invoice_id)
|
207
207
|
|
208
208
|
# search by BLANK
|
209
|
-
get :search, :q => query_builder('CREDIT',credit.
|
209
|
+
get :search, :q => query_builder('CREDIT',credit.invoice_item_id)
|
210
210
|
assert_redirected_to account_invoice_path(credit.account_id, credit.invoice_id)
|
211
211
|
|
212
212
|
# search by BLANK and fails
|
@@ -376,9 +376,9 @@ class Kaui::HomeControllerTest < Kaui::FunctionalTestHelper
|
|
376
376
|
end
|
377
377
|
|
378
378
|
def create_credit
|
379
|
-
credit = KillBillClient::Model::Credit.new(:invoice_id => nil, :account_id => @account.account_id, :
|
379
|
+
credit = KillBillClient::Model::Credit.new(:invoice_id => nil, :account_id => @account.account_id, :amount => 2.22)
|
380
380
|
credit = credit.create(true, 'kaui search test', nil, nil, build_options(@tenant, USERNAME, PASSWORD))
|
381
|
-
credit
|
381
|
+
credit.first
|
382
382
|
end
|
383
383
|
|
384
384
|
def create_custom_field
|
@@ -10,7 +10,7 @@ class Kaui::InvoiceItemsControllerTest < Kaui::FunctionalTestHelper
|
|
10
10
|
invoice_id = SecureRandom.uuid.to_s
|
11
11
|
get :edit, :account_id => @account.account_id, :id => @invoice_item.invoice_item_id, :invoice_id => invoice_id
|
12
12
|
assert_redirected_to account_path(@account.account_id)
|
13
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
13
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
14
14
|
|
15
15
|
invoice_item_id = SecureRandom.uuid.to_s
|
16
16
|
get :edit, :account_id => @account.account_id, :id => invoice_item_id, :invoice_id => @invoice_item.invoice_id
|
@@ -36,7 +36,7 @@ class Kaui::InvoiceItemsControllerTest < Kaui::FunctionalTestHelper
|
|
36
36
|
:currency => :USD
|
37
37
|
}
|
38
38
|
assert_template :edit
|
39
|
-
assert_equal "Error while adjusting invoice item:
|
39
|
+
assert_equal "Error while adjusting invoice item: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
40
40
|
end
|
41
41
|
|
42
42
|
test 'should adjust invoice item' do
|
@@ -68,7 +68,7 @@ class Kaui::InvoiceItemsControllerTest < Kaui::FunctionalTestHelper
|
|
68
68
|
:invoice_id => invoice_id,
|
69
69
|
:account_id => @account.account_id
|
70
70
|
assert_redirected_to account_path(@account.account_id)
|
71
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
71
|
+
assert_equal "Error while communicating with the Kill Bill server: No invoice could be found for id #{invoice_id}.", flash[:error]
|
72
72
|
end
|
73
73
|
|
74
74
|
test 'should delete CBA' do
|
@@ -23,7 +23,7 @@ class Kaui::InvoicesControllerTest < Kaui::FunctionalTestHelper
|
|
23
23
|
invoice_id = SecureRandom.uuid.to_s
|
24
24
|
get :show, :account_id => @invoice_item.account_id, :id => invoice_id
|
25
25
|
assert_redirected_to account_path(@invoice_item.account_id)
|
26
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
26
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
27
27
|
end
|
28
28
|
|
29
29
|
test 'should find unpaid invoice by id' do
|
@@ -65,7 +65,7 @@ class Kaui::InvoicesControllerTest < Kaui::FunctionalTestHelper
|
|
65
65
|
invoice_id = SecureRandom.uuid.to_s
|
66
66
|
get :show_html, :id => invoice_id
|
67
67
|
assert_redirected_to home_path
|
68
|
-
assert_equal "Error while communicating with the Kill Bill server:
|
68
|
+
assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
69
69
|
end
|
70
70
|
|
71
71
|
test 'should expose restful endpoint' do
|