kaui 0.16.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/assets/javascripts/application.js +1 -1
- data/app/assets/javascripts/kaui/kaui.js +78 -1
- data/app/assets/stylesheets/bootstrap_and_overrides.css.less +5 -0
- data/app/assets/stylesheets/kaui/account.less +20 -0
- data/app/assets/stylesheets/kaui/audit.less +38 -0
- data/app/assets/stylesheets/kaui/common.less +103 -0
- data/app/assets/stylesheets/kaui/datatable.less +19 -0
- data/app/assets/stylesheets/kaui/kaui.less +3 -1
- data/app/assets/stylesheets/kaui/subscription.less +15 -0
- data/app/assets/stylesheets/kaui/tags.less +30 -1
- data/app/controllers/kaui/account_custom_fields_controller.rb +24 -0
- data/app/controllers/kaui/account_tags_controller.rb +21 -0
- data/app/controllers/kaui/accounts_controller.rb +43 -16
- data/app/controllers/kaui/admin_tenants_controller.rb +152 -11
- data/app/controllers/kaui/audit_logs_controller.rb +93 -0
- data/app/controllers/kaui/bundles_controller.rb +15 -3
- data/app/controllers/kaui/custom_fields_controller.rb +2 -0
- data/app/controllers/kaui/engine_controller_util.rb +14 -0
- data/app/controllers/kaui/invoice_items_controller.rb +17 -0
- data/app/controllers/kaui/invoices_controller.rb +22 -5
- data/app/controllers/kaui/payment_methods_controller.rb +10 -9
- data/app/controllers/kaui/subscriptions_controller.rb +54 -7
- data/app/controllers/kaui/tag_definitions_controller.rb +1 -0
- data/app/helpers/kaui/account_helper.rb +28 -0
- data/app/helpers/kaui/object_helper.rb +4 -0
- data/app/helpers/kaui/permissions_helper.rb +15 -0
- data/app/helpers/kaui/plugin_helper.rb +58 -0
- data/app/helpers/kaui/subscription_helper.rb +9 -7
- data/app/models/kaui/admin_tenant.rb +20 -6
- data/app/models/kaui/catalog.rb +4 -4
- data/app/models/kaui/tag.rb +1 -1
- data/app/models/kaui/tag_definition.rb +1 -1
- data/app/views/kaui/account_custom_fields/index.html.erb +35 -0
- data/app/views/kaui/account_tags/index.html.erb +35 -0
- data/app/views/kaui/accounts/_account_info.html.erb +5 -0
- data/app/views/kaui/accounts/_billing_info.html.erb +1 -1
- data/app/views/kaui/accounts/_close_account_modal.html.erb +98 -0
- data/app/views/kaui/accounts/index.html.erb +0 -7
- data/app/views/kaui/accounts/show.html.erb +4 -0
- data/app/views/kaui/admin_tenants/_add_allowed_user_modal.html.erb +64 -0
- data/app/views/kaui/admin_tenants/_form_plugin_config.erb +257 -151
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +133 -48
- data/app/views/kaui/admin_tenants/_show_catalog_xml.erb +3 -2
- data/app/views/kaui/admin_tenants/show.html.erb +6 -1
- data/app/views/kaui/audit_logs/_show_history_modal.html.erb +177 -0
- data/app/views/kaui/audit_logs/index.html.erb +52 -0
- data/app/views/kaui/bundle_tags/_form_bar.html.erb +4 -2
- data/app/views/kaui/bundles/index.html.erb +21 -14
- data/app/views/kaui/chargebacks/_form.html.erb +1 -9
- data/app/views/kaui/charges/_form.html.erb +2 -10
- data/app/views/kaui/credits/_form.html.erb +1 -9
- data/app/views/kaui/custom_fields/_form.html.erb +1 -1
- data/app/views/kaui/custom_fields/_list_bar.html.erb +1 -1
- data/app/views/kaui/invoices/_invoice_table.html.erb +30 -2
- data/app/views/kaui/layouts/kaui_account_navbar.html.erb +7 -0
- data/app/views/kaui/layouts/kaui_flash.html.erb +13 -2
- data/app/views/kaui/payment_methods/_new_creditcard_payment_method.html.erb +11 -11
- data/app/views/kaui/payment_methods/_plugin_properties.html.erb +1 -1
- data/app/views/kaui/payments/_form.html.erb +1 -9
- data/app/views/kaui/refunds/_form.html.erb +4 -6
- data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +62 -0
- data/app/views/kaui/subscriptions/_form.html.erb +7 -13
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +50 -11
- data/app/views/kaui/subscriptions/new.html.erb +3 -1
- data/app/views/kaui/tag_definitions/_form.html.erb +139 -0
- data/app/views/kaui/tags/index.html.erb +1 -1
- data/app/views/kaui/transactions/_control_plugin_names.html.erb +1 -1
- data/config/routes.rb +18 -2
- data/db/migrate/20130812155313_devise_create_kaui_users.rb +9 -7
- data/db/migrate/20150109214021_create_kaui_tenants.rb +8 -6
- data/db/migrate/20150112232813_create_kaui_allowed_users.rb +15 -11
- data/lib/kaui/engine.rb +1 -0
- data/lib/kaui/version.rb +1 -1
- data/test/dummy/config/database.yml +6 -1
- data/test/fixtures/SpyCarAdvanced.xml +824 -0
- data/test/functional/kaui/account_children_controller_test.rb +1 -1
- data/test/functional/kaui/account_custom_fields_controller_test.rb +29 -0
- data/test/functional/kaui/account_tags_controller_test.rb +19 -0
- data/test/functional/kaui/accounts_controller_test.rb +23 -6
- data/test/functional/kaui/admin_controller_test.rb +2 -2
- data/test/functional/kaui/admin_tenants_controller_test.rb +76 -5
- data/test/functional/kaui/audit_logs_controller_test.rb +71 -0
- data/test/functional/kaui/bundles_controller_test.rb +2 -1
- data/test/functional/kaui/payments_controller_test.rb +1 -1
- data/test/functional/kaui/subscriptions_controller_test.rb +1 -2
- data/test/functional/kaui/tag_definitions_controller_test.rb +2 -1
- data/test/killbill_test_helper.rb +5 -2
- data/test/unit/kaui/admin_tenant_test.rb +100 -0
- data/test/unit/kaui/money_helper_test.rb +1 -1
- metadata +58 -13
- data/app/assets/javascripts/kaui/validation.js +0 -21
- data/test/dummy/log/test.log +0 -0
@@ -11,7 +11,7 @@ class Kaui::AccountChildrenControllerTest < Kaui::FunctionalTestHelper
|
|
11
11
|
children_size = 3
|
12
12
|
# create children
|
13
13
|
for i in 1..children_size
|
14
|
-
create_account(@tenant,USERNAME,PASSWORD,
|
14
|
+
create_account(@tenant,USERNAME,PASSWORD,"Kaui test#{i}",nil,nil,@account.account_id)
|
15
15
|
end
|
16
16
|
|
17
17
|
parameters = {
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Kaui::AccountCustomFieldsControllerTest < Kaui::FunctionalTestHelper
|
4
|
+
|
5
|
+
test 'should list all account custom fields' do
|
6
|
+
new_account = create_account(@tenant)
|
7
|
+
|
8
|
+
# set a custom field
|
9
|
+
created_custom_field = Kaui::CustomField.new
|
10
|
+
created_custom_field.object_id = new_account.account_id
|
11
|
+
created_custom_field.object_type = 'ACCOUNT'
|
12
|
+
created_custom_field.name = 'test'
|
13
|
+
created_custom_field.value = 'value'
|
14
|
+
|
15
|
+
new_account.add_custom_field(created_custom_field, 'Kaui test', nil, nil, build_options(@tenant, USERNAME, PASSWORD))
|
16
|
+
|
17
|
+
|
18
|
+
# get custom field list
|
19
|
+
get :index, :account_id => new_account.account_id
|
20
|
+
assert_response :success
|
21
|
+
custom_fields_from_response = get_value_from_input_field('custom-fields').gsub!('"','"');
|
22
|
+
assert_not_nil custom_fields_from_response
|
23
|
+
custom_fields = JSON.parse(custom_fields_from_response)
|
24
|
+
assert_equal 1, custom_fields.count
|
25
|
+
assert_equal 'ACCOUNT', custom_fields[0][1]
|
26
|
+
assert_equal 'test', custom_fields[0][2]
|
27
|
+
assert_equal 'value', custom_fields[0][3]
|
28
|
+
end
|
29
|
+
end
|
@@ -26,4 +26,23 @@ class Kaui::AccountTagsControllerTest < Kaui::FunctionalTestHelper
|
|
26
26
|
assert_redirected_to account_path(@account.account_id)
|
27
27
|
assert_equal 'Account tags successfully set', flash[:notice]
|
28
28
|
end
|
29
|
+
|
30
|
+
test 'should list all account tags' do
|
31
|
+
new_account = create_account(@tenant)
|
32
|
+
# set some tags
|
33
|
+
post :update,
|
34
|
+
:account_id => new_account.account_id,
|
35
|
+
:'tag_00000000-0000-0000-0000-000000000001' => 'AUTO_PAY_OFF',
|
36
|
+
:'tag_00000000-0000-0000-0000-000000000005' => 'MANUAL_PAY',
|
37
|
+
:'tag_00000000-0000-0000-0000-000000000003' => 'OVERDUE_ENFORCEMENT_OFF'
|
38
|
+
assert_redirected_to account_path(new_account.account_id)
|
39
|
+
assert_equal 'Account tags successfully set', flash[:notice]
|
40
|
+
|
41
|
+
# get tag list
|
42
|
+
get :index, :account_id => new_account.account_id
|
43
|
+
assert_response :success
|
44
|
+
tags_from_response = get_value_from_input_field('tags').gsub!('"','"');
|
45
|
+
assert_not_nil tags_from_response
|
46
|
+
assert_equal 3, JSON.parse(tags_from_response).count
|
47
|
+
end
|
29
48
|
end
|
@@ -139,32 +139,40 @@ class Kaui::AccountsControllerTest < Kaui::FunctionalTestHelper
|
|
139
139
|
end
|
140
140
|
|
141
141
|
test 'should trigger invoice' do
|
142
|
+
account = create_account(@tenant)
|
143
|
+
bundle = create_bundle(account, @tenant)
|
144
|
+
|
142
145
|
parameters = {
|
143
|
-
:account_id =>
|
146
|
+
:account_id => account.account_id,
|
144
147
|
:dry_run => '0'
|
145
148
|
}
|
146
149
|
|
147
150
|
post :trigger_invoice, parameters
|
148
151
|
assert_equal 'Nothing to generate for target date today', flash[:notice]
|
149
|
-
assert_redirected_to account_path(
|
152
|
+
assert_redirected_to account_path(account.account_id)
|
150
153
|
|
151
|
-
today_next_month = (Date.parse(@kb_clock['localDate'])
|
154
|
+
today_next_month = (Date.parse(@kb_clock['localDate']) + 31).to_s
|
152
155
|
# generate a dry run invoice
|
153
156
|
parameters = {
|
154
|
-
:account_id =>
|
157
|
+
:account_id => account.account_id,
|
155
158
|
:dry_run => '1',
|
156
159
|
:target_date => today_next_month
|
157
160
|
}
|
158
161
|
|
159
162
|
post :trigger_invoice, parameters
|
160
163
|
assert_response :success
|
164
|
+
assert_select 'table tbody tr:first' do
|
165
|
+
assert_select 'td:first', "sports-monthly-evergreen"
|
166
|
+
assert_select 'td:nth-child(4)', bundle.subscriptions.first.subscription_id
|
167
|
+
end
|
168
|
+
|
161
169
|
|
162
170
|
# persist it
|
163
171
|
parameters[:dry_run] = '0'
|
164
172
|
post :trigger_invoice, parameters
|
165
173
|
assert_response :redirect
|
166
|
-
assert_match
|
167
|
-
a_tag = /<a.href="(?<href>.*?)"
|
174
|
+
assert_match(/Generated invoice.*for target date.*/, flash[:notice])
|
175
|
+
a_tag = (/<a.href="(?<href>.*?)">/).match(@response.body)
|
168
176
|
assert_redirected_to a_tag[:href]
|
169
177
|
end
|
170
178
|
|
@@ -232,6 +240,15 @@ class Kaui::AccountsControllerTest < Kaui::FunctionalTestHelper
|
|
232
240
|
|
233
241
|
end
|
234
242
|
|
243
|
+
test 'should close an account' do
|
244
|
+
account_to_be_closed = create_account(@tenant)
|
245
|
+
|
246
|
+
delete :destroy, :account_id => account_to_be_closed.account_id
|
247
|
+
assert_redirected_to account_path(account_to_be_closed.account_id)
|
248
|
+
assert_equal "Account #{account_to_be_closed.account_id} successfully closed", flash[:notice]
|
249
|
+
|
250
|
+
end
|
251
|
+
|
235
252
|
private
|
236
253
|
|
237
254
|
def get_redirected_account_id
|
@@ -7,7 +7,7 @@ class Kaui::AdminControllerTest < Kaui::FunctionalTestHelper
|
|
7
7
|
clock = get_date
|
8
8
|
assert_not_nil clock
|
9
9
|
date = DateTime.parse(clock.to_s.gsub('"','')).strftime('%F')
|
10
|
-
assert_match
|
10
|
+
assert_match(/\d{4}-\d{,2}-\d{,2}/, date)
|
11
11
|
assert_response :success
|
12
12
|
end
|
13
13
|
|
@@ -19,7 +19,7 @@ class Kaui::AdminControllerTest < Kaui::FunctionalTestHelper
|
|
19
19
|
clock = get_date
|
20
20
|
assert_not_nil clock
|
21
21
|
date = DateTime.parse(clock.to_s.gsub('"','')).strftime('%F')
|
22
|
-
assert_match
|
22
|
+
assert_match(/\d{4}-\d{,2}-\d{,2}/, date)
|
23
23
|
assert_response :success
|
24
24
|
|
25
25
|
# update killbill clock
|
@@ -26,7 +26,7 @@ class Kaui::AdminTenantsControllerTest < Kaui::FunctionalTestHelper
|
|
26
26
|
tenant.kb_tenant_id = 'kb_tenant_id'
|
27
27
|
tenant.save!
|
28
28
|
|
29
|
-
|
29
|
+
# Add an allowed user that will verify that we can only
|
30
30
|
au = Kaui::AllowedUser.find_by_kb_username('admin')
|
31
31
|
au.kaui_tenants << tenant
|
32
32
|
|
@@ -92,7 +92,7 @@ class Kaui::AdminTenantsControllerTest < Kaui::FunctionalTestHelper
|
|
92
92
|
stripe_yml = YAML.load_file(File.join(self.class.fixture_path, 'stripe.yml'))[:stripe]
|
93
93
|
stripe_yml.stringify_keys!
|
94
94
|
stripe_yml.each { |k, v| stripe_yml[k] = v.to_s }
|
95
|
-
post :upload_plugin_config, :id => tenant.id, :plugin_name => 'killbill-stripe', :plugin_type => 'ruby', :plugin_properties => stripe_yml
|
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
97
|
assert_redirected_to admin_tenant_path(tenant.id)
|
98
98
|
assert_equal 'Config for plugin was successfully uploaded', flash[:notice]
|
@@ -212,10 +212,22 @@ class Kaui::AdminTenantsControllerTest < Kaui::FunctionalTestHelper
|
|
212
212
|
end
|
213
213
|
|
214
214
|
test 'should display catalog xml' do
|
215
|
-
|
216
|
-
|
215
|
+
effective_date = '2013-02-08T00:00:00+00:00'
|
216
|
+
tenant = create_kaui_tenant
|
217
|
+
post :upload_catalog, :id => tenant.id, :catalog => fixture_file_upload('catalog-v1.xml')
|
218
|
+
|
219
|
+
assert_redirected_to admin_tenant_path(tenant.id)
|
220
|
+
assert_equal 'Catalog was successfully uploaded', flash[:notice]
|
221
|
+
|
222
|
+
post :display_catalog_xml, :effective_date => effective_date, :id => tenant.id
|
223
|
+
|
224
|
+
doc = nil
|
225
|
+
assert_nothing_raised { doc = Nokogiri::XML(@response.body) { |config| config.strict } }
|
217
226
|
|
218
|
-
|
227
|
+
catalog = doc.xpath("//catalog")
|
228
|
+
expected_effective_date = Date.parse(catalog[0].search("effectiveDate").text)
|
229
|
+
|
230
|
+
assert_equal Date.parse(effective_date), expected_effective_date
|
219
231
|
end
|
220
232
|
|
221
233
|
test 'should display overdue xml' do
|
@@ -225,6 +237,65 @@ class Kaui::AdminTenantsControllerTest < Kaui::FunctionalTestHelper
|
|
225
237
|
assert_equal @response.body, overdue_xml
|
226
238
|
end
|
227
239
|
|
240
|
+
test 'should get a catalog by effective date' do
|
241
|
+
effective_date = '2013-02-08T00:00:00+00:00'
|
242
|
+
tenant = create_kaui_tenant
|
243
|
+
post :upload_catalog, :id => tenant.id, :catalog => fixture_file_upload('catalog-v1.xml')
|
244
|
+
|
245
|
+
get :catalog_by_effective_date, :id => tenant.id, :effective_date => effective_date
|
246
|
+
assert_response :success
|
247
|
+
|
248
|
+
result = nil
|
249
|
+
assert_nothing_raised { result = JSON.parse(@response.body) }
|
250
|
+
assert_not_nil(result)
|
251
|
+
assert_equal 1, result['catalog'].size
|
252
|
+
assert_equal Date.parse(effective_date), Date.parse(result['catalog'][0]['version_date'])
|
253
|
+
end
|
254
|
+
|
255
|
+
test 'should add an allowed user' do
|
256
|
+
tenant = Kaui::Tenant.new
|
257
|
+
tenant.name = 'foo'
|
258
|
+
tenant.api_key = 'api_key'
|
259
|
+
tenant.api_secret = 'api_secret'
|
260
|
+
tenant.kb_tenant_id = 'kb_tenant_id'
|
261
|
+
tenant.save!
|
262
|
+
|
263
|
+
# create a new user
|
264
|
+
au = Kaui::AllowedUser.new(:kb_username => 'Hulk', :description => "He is green")
|
265
|
+
au.save
|
266
|
+
|
267
|
+
# add user to allowed list
|
268
|
+
parameters = {
|
269
|
+
:allowed_user => {:kb_username => au.kb_username},
|
270
|
+
:tenant_id => tenant.id
|
271
|
+
}
|
272
|
+
put :add_allowed_user, parameters
|
273
|
+
assert_redirected_to admin_tenant_path(tenant.id)
|
274
|
+
assert_equal 'Allowed user was successfully added', flash[:notice]
|
275
|
+
|
276
|
+
# try to add non existent user
|
277
|
+
parameters = {
|
278
|
+
:allowed_user => {:kb_username => 'Steve Rogers'},
|
279
|
+
:tenant_id => tenant.id
|
280
|
+
}
|
281
|
+
put :add_allowed_user, parameters
|
282
|
+
assert_redirected_to admin_tenant_path(tenant.id)
|
283
|
+
assert_equal "User #{parameters[:allowed_user][:kb_username]} does not exist!", flash[:error]
|
284
|
+
|
285
|
+
end
|
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\" href=\"#\">killbill-paypal-express</a>'"
|
289
|
+
|
290
|
+
get :validate_plugin_name, :plugin_name => 'paypal-express'
|
291
|
+
assert_response :success
|
292
|
+
assert_equal JSON[@response.body]['suggestion'], "Similar plugin already installed: #{plugin_anchor}"
|
293
|
+
|
294
|
+
get :validate_plugin_name, :plugin_name => 'pypl'
|
295
|
+
assert_response :success
|
296
|
+
assert_equal JSON[@response.body]['suggestion'], "Did you mean #{plugin_anchor}?"
|
297
|
+
end
|
298
|
+
|
228
299
|
private
|
229
300
|
|
230
301
|
def create_kaui_tenant
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
class Kaui::AuditLogsControllerTest < Kaui::FunctionalTestHelper
|
5
|
+
OBJECT_WITH_HISTORY = %w[ACCOUNT ACCOUNT_EMAIL CUSTOM_FIELD PAYMENT_ATTEMPT PAYMENT PAYMENT_METHOD TRANSACTION TAG]
|
6
|
+
|
7
|
+
test 'should list all account audit logs' do
|
8
|
+
new_account = create_account(@tenant)
|
9
|
+
|
10
|
+
get :index, :account_id => new_account.account_id
|
11
|
+
assert_response :success
|
12
|
+
audit_logs_from_response = get_value_from_input_field('audit-logs').gsub!('"','"');
|
13
|
+
assert_not_nil audit_logs_from_response
|
14
|
+
audit_logs = JSON.parse(audit_logs_from_response)
|
15
|
+
assert_equal 1, audit_logs.count
|
16
|
+
assert_equal 'ACCOUNT', audit_logs[0][2]
|
17
|
+
assert_equal 'INSERT', audit_logs[0][3]
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'should get audit logs with history' do
|
21
|
+
new_account = create_account(@tenant)
|
22
|
+
add_a_note(new_account)
|
23
|
+
create_payment_method(true, new_account, @tenant)
|
24
|
+
create_payment(nil, new_account, @tenant)
|
25
|
+
|
26
|
+
get :index, :account_id => new_account.account_id
|
27
|
+
assert_response :success
|
28
|
+
audit_logs_from_response = get_value_from_input_field('audit-logs').gsub!('"','"');
|
29
|
+
assert_not_nil audit_logs_from_response
|
30
|
+
audit_logs = JSON.parse(audit_logs_from_response)
|
31
|
+
|
32
|
+
audit_logs.each do |audit_log|
|
33
|
+
if OBJECT_WITH_HISTORY.include?(audit_log[2])
|
34
|
+
anchor = Nokogiri::HTML(audit_log[1]).css('a')
|
35
|
+
get :history, :account_id => new_account.account_id, :object_id => anchor[0]['data-object-id'], :object_type => audit_log[2]
|
36
|
+
assert_response :success
|
37
|
+
|
38
|
+
audit_logs_with_history = JSON.parse(@response.body)['audits']
|
39
|
+
|
40
|
+
if audit_log[2] == 'ACCOUNT'
|
41
|
+
assert_equal 3, audit_logs_with_history.count
|
42
|
+
assert_equal 'INSERT', audit_logs_with_history[0]['changeType']
|
43
|
+
assert_nil audit_logs_with_history[0]['history']['notes']
|
44
|
+
assert_equal 'UPDATE', audit_logs_with_history[1]['changeType']
|
45
|
+
assert_not_nil audit_logs_with_history[1]['history']['notes']
|
46
|
+
assert_equal 'UPDATE', audit_logs_with_history[1]['changeType']
|
47
|
+
assert_not_nil audit_logs_with_history[2]['history']['paymentMethodId']
|
48
|
+
elsif audit_log[2] == 'PAYMENT'
|
49
|
+
assert_equal 2, audit_logs_with_history.count
|
50
|
+
assert_equal 'INSERT', audit_logs_with_history[0]['changeType']
|
51
|
+
assert_equal 'UPDATE', audit_logs_with_history[1]['changeType']
|
52
|
+
elsif audit_log[2] == 'PAYMENT_METHOD'
|
53
|
+
assert_equal 1, audit_logs_with_history.count
|
54
|
+
assert_equal 'INSERT', audit_logs_with_history[0]['changeType']
|
55
|
+
elsif audit_log[2] == 'TRANSACTION'
|
56
|
+
assert_equal 2, audit_logs_with_history.count
|
57
|
+
assert_equal 'INSERT', audit_logs_with_history[0]['changeType']
|
58
|
+
assert_equal 'UPDATE', audit_logs_with_history[1]['changeType']
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
def add_a_note(account)
|
68
|
+
account.notes = 'I am a note'
|
69
|
+
account.update(false, 'Kaui log test', nil, nil, build_options(@tenant, USERNAME, PASSWORD))
|
70
|
+
end
|
71
|
+
end
|
@@ -115,6 +115,7 @@ class Kaui::BundlesControllerTest < Kaui::FunctionalTestHelper
|
|
115
115
|
input = Kaui::TagDefinition.new(tag_definition_name)
|
116
116
|
input.name = tag_definition_name
|
117
117
|
input.description = 'something'
|
118
|
+
input.applicable_object_types = ['BUNDLE']
|
118
119
|
tag_def = input.create(username, reason, comment, build_options(tenant, username, password))
|
119
120
|
tag_def.id
|
120
121
|
end
|
@@ -122,7 +123,7 @@ class Kaui::BundlesControllerTest < Kaui::FunctionalTestHelper
|
|
122
123
|
def add_tags(bundle, tag_definition_ids, tenant, username = USERNAME, password = PASSWORD, reason = nil, comment = nil)
|
123
124
|
bundle.set_tags(tag_definition_ids, username, reason, comment, build_options(tenant, username, password))
|
124
125
|
end
|
125
|
-
|
126
|
+
|
126
127
|
def check_bundle_owner(new_owner)
|
127
128
|
assert_equal new_owner, Kaui::Bundle.find_by_external_key(@bundle.external_key, false, options).account_id
|
128
129
|
end
|
@@ -45,7 +45,7 @@ class Kaui::PaymentsControllerTest < Kaui::FunctionalTestHelper
|
|
45
45
|
|
46
46
|
test 'should cancel scheduled payment' do
|
47
47
|
delete :cancel_scheduled_payment, :id => @payment.payment_id, :account_id => @payment.account_id
|
48
|
-
assert_match
|
48
|
+
assert_match(/Error deleting payment attempt retry:/, flash[:error])
|
49
49
|
expected_response_path = "/accounts/#{@payment.account_id}"
|
50
50
|
assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}"
|
51
51
|
|
@@ -53,7 +53,6 @@ class Kaui::SubscriptionsControllerTest < Kaui::FunctionalTestHelper
|
|
53
53
|
:subscription => {
|
54
54
|
:account_id => @account.account_id,
|
55
55
|
:external_key => SecureRandom.uuid,
|
56
|
-
:product_category => 'BASE'
|
57
56
|
},
|
58
57
|
:plan_name => 'standard-monthly'
|
59
58
|
assert_response 302
|
@@ -143,7 +142,7 @@ class Kaui::SubscriptionsControllerTest < Kaui::FunctionalTestHelper
|
|
143
142
|
assert_response :success
|
144
143
|
assert_equal get_value_from_input_field('subscription_account_id'), @bundle.subscriptions.first.account_id
|
145
144
|
assert_equal get_value_from_input_field('subscription_bill_cycle_day_local'), @bundle.subscriptions.first.bill_cycle_day_local.to_s
|
146
|
-
assert_equal get_value_from_input_field('effective_from_date'),
|
145
|
+
assert_equal get_value_from_input_field('effective_from_date'), Date.parse(Time.now.to_s).to_s
|
147
146
|
end
|
148
147
|
|
149
148
|
test 'should update bcd' do
|
@@ -16,7 +16,8 @@ class Kaui::TagDefinitionsControllerTest < Kaui::FunctionalTestHelper
|
|
16
16
|
post :create,
|
17
17
|
:tag_definition => {
|
18
18
|
:name => tag_definition,
|
19
|
-
:description => SecureRandom.uuid
|
19
|
+
:description => SecureRandom.uuid,
|
20
|
+
:applicable_object_types => {"0" => "ACCOUNT"}
|
20
21
|
}
|
21
22
|
assert_redirected_to tag_definitions_path
|
22
23
|
assert_equal 'Tag definition successfully created', flash[:notice]
|
@@ -56,8 +56,7 @@ module Kaui
|
|
56
56
|
end
|
57
57
|
|
58
58
|
# Setup AllowedUser
|
59
|
-
au = Kaui::AllowedUser
|
60
|
-
.find_or_create_by(kb_username: 'admin', description: 'Admin User')
|
59
|
+
au = Kaui::AllowedUser.find_or_create_by(kb_username: 'admin')
|
61
60
|
|
62
61
|
# Create the tenant with Kill Bill
|
63
62
|
all_tenants = []
|
@@ -196,6 +195,10 @@ module Kaui
|
|
196
195
|
# Re-hydrate the secret, which is not returned
|
197
196
|
tenant.api_secret = api_secret
|
198
197
|
|
198
|
+
# Upload the default SpyCarAdvanced.xml catalog
|
199
|
+
catalog_xml = File.read("test/fixtures/SpyCarAdvanced.xml")
|
200
|
+
Kaui::AdminTenant.upload_catalog(catalog_xml, user, reason, comment, build_options(tenant))
|
201
|
+
|
199
202
|
tenant
|
200
203
|
end
|
201
204
|
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Kaui::AdminTenantTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
PLUGIN_REPO = '[{"plugin_key":"analytics","plugin_name":"killbill-analytics","plugin_type":"java","installed":true},{"plugin_key":"kpm","plugin_name":"killbill-kpm","plugin_type":"ruby","installed":true},{"plugin_key":"paypal-express","plugin_name":"killbill-paypal-express","plugin_type":"ruby","installed":true},
|
6
|
+
{"plugin_key":"killbill-email-notifications","plugin_name":"killbill-email-notifications","plugin_type":null,"installed":true},{"plugin_key":"accertify","plugin_name":"killbill-accertify","plugin_type":"java","installed":false},{"plugin_key":"adyen","plugin_name":"killbill-adyen","plugin_type":"java","installed":false},
|
7
|
+
{"plugin_key":"avatax","plugin_name":"killbill-avatax","plugin_type":"java","installed":false},{"plugin_key":"braintree_blue","plugin_name":"killbill-braintree_blue","plugin_type":"ruby","installed":false},{"plugin_key":"currency","plugin_name":"killbill-currency","plugin_type":"ruby","installed":false},
|
8
|
+
{"plugin_key":"cybersource","plugin_name":"killbill-cybersource","plugin_type":"ruby","installed":false},{"plugin_key":"dwolla","plugin_name":"killbill-dwolla","plugin_type":"java","installed":false},
|
9
|
+
{"plugin_key":"email-notifications","plugin_name":"killbill-email-notifications","plugin_type":"java","installed":false},{"plugin_key":"firstdata-e4","plugin_name":"killbill-firstdata-e4","plugin_type":"ruby","installed":false},{"plugin_key":"forte","plugin_name":"killbill-forte","plugin_type":"java","installed":false},
|
10
|
+
{"plugin_key":"litle","plugin_name":"killbill-litle","plugin_type":"ruby","installed":false},{"plugin_key":"logging","plugin_name":"killbill-logging","plugin_type":"ruby","installed":false},{"plugin_key":"orbital","plugin_name":"killbill-orbital","plugin_type":"ruby","installed":false},
|
11
|
+
{"plugin_key":"bridge","plugin_name":"killbill-bridge","plugin_type":"java","installed":false},{"plugin_key":"payeezy","plugin_name":"killbill-payeezy","plugin_type":"java","installed":false},{"plugin_key":"payment-retries","plugin_name":"killbill-payment-retries","plugin_type":"java","installed":false},
|
12
|
+
{"plugin_key":"payu-latam","plugin_name":"killbill-payu-latam","plugin_type":"ruby","installed":false},{"plugin_key":"payment-test","plugin_name":"killbill-payment-test","plugin_type":"ruby","installed":false},
|
13
|
+
{"plugin_key":"securenet","plugin_name":"killbill-securenet","plugin_type":"ruby","installed":false},{"plugin_key":"stripe","plugin_name":"killbill-stripe","plugin_type":"ruby","installed":false},{"plugin_key":"zendesk","plugin_name":"killbill-zendesk","plugin_type":"ruby","installed":false}]'
|
14
|
+
|
15
|
+
test 'can split camel dash underscore space strings' do
|
16
|
+
adminTenantController = Kaui::AdminTenantsController.new
|
17
|
+
|
18
|
+
string = 'camelCaseString'
|
19
|
+
splitted = adminTenantController.send(:split_camel_dash_underscore_space, string)
|
20
|
+
assert_equal 3, splitted.count
|
21
|
+
|
22
|
+
string = 'this-is-a-string-to-split'
|
23
|
+
splitted = adminTenantController.send(:split_camel_dash_underscore_space, string)
|
24
|
+
assert_split(splitted)
|
25
|
+
|
26
|
+
string = 'this_is_a_string_to_split'
|
27
|
+
splitted = adminTenantController.send(:split_camel_dash_underscore_space, string)
|
28
|
+
assert_split(splitted)
|
29
|
+
|
30
|
+
string = 'this is a string to split'
|
31
|
+
splitted = adminTenantController.send(:split_camel_dash_underscore_space, string)
|
32
|
+
assert_split(splitted)
|
33
|
+
|
34
|
+
string = 'this-IsA string_to-split'
|
35
|
+
splitted = adminTenantController.send(:split_camel_dash_underscore_space, string)
|
36
|
+
assert_split(splitted)
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
test 'can do a fuzzy match of a plugin to suggest a plugin' do
|
41
|
+
plugins_info = plugins_repo
|
42
|
+
adminTenantController = Kaui::AdminTenantsController.new
|
43
|
+
|
44
|
+
%w(killbill-paypal express paypal pay).each do |plugin_name|
|
45
|
+
found_plugin, weights = adminTenantController.send(:fuzzy_match, plugin_name, plugins_info)
|
46
|
+
assert_nil(found_plugin)
|
47
|
+
assert_equal weights[0][:plugin_name], 'killbill-paypal-express'
|
48
|
+
end
|
49
|
+
|
50
|
+
plugin_name = 'email'
|
51
|
+
found_plugin, weights = adminTenantController.send(:fuzzy_match, plugin_name, plugins_info)
|
52
|
+
assert_nil(found_plugin)
|
53
|
+
assert_equal weights[0][:plugin_name], 'killbill-email-notifications'
|
54
|
+
|
55
|
+
%w(first firstdata firstdata_e4).each do |plugin_name|
|
56
|
+
found_plugin, weights = adminTenantController.send(:fuzzy_match, plugin_name, plugins_info)
|
57
|
+
assert_nil(found_plugin)
|
58
|
+
assert_equal weights[0][:plugin_name], 'killbill-firstdata-e4'
|
59
|
+
end
|
60
|
+
|
61
|
+
%w(braintree brain).each do |plugin_name|
|
62
|
+
found_plugin, weights = adminTenantController.send(:fuzzy_match, plugin_name, plugins_info)
|
63
|
+
assert_nil(found_plugin)
|
64
|
+
assert_equal weights[0][:plugin_name], 'killbill-braintree_blue'
|
65
|
+
end
|
66
|
+
|
67
|
+
# if found weights should be empty
|
68
|
+
plugin_name = 'avatax'
|
69
|
+
found_plugin, weights = adminTenantController.send(:fuzzy_match, plugin_name, plugins_info)
|
70
|
+
assert_equal weights.size, 0
|
71
|
+
assert_equal found_plugin[:plugin_name], 'killbill-avatax'
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def plugins_repo
|
78
|
+
plugins_info = []
|
79
|
+
hash_plugin_info = JSON.parse(PLUGIN_REPO)
|
80
|
+
hash_plugin_info.each do |plugin|
|
81
|
+
plugins_info << {
|
82
|
+
plugin_key: plugin['plugin_key'],
|
83
|
+
plugin_name: plugin['plugin_name'],
|
84
|
+
plugin_type: nil,
|
85
|
+
installed: true
|
86
|
+
}
|
87
|
+
end
|
88
|
+
plugins_info
|
89
|
+
end
|
90
|
+
|
91
|
+
def assert_split(splitted)
|
92
|
+
assert_equal 6, splitted.count
|
93
|
+
assert_equal 'this', splitted[0]
|
94
|
+
assert_equal 'is', splitted[1]
|
95
|
+
assert_equal 'a', splitted[2]
|
96
|
+
assert_equal 'string', splitted[3]
|
97
|
+
assert_equal 'to', splitted[4]
|
98
|
+
assert_equal 'split', splitted[5]
|
99
|
+
end
|
100
|
+
end
|