kaui 2.1.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +8 -7
- data/Rakefile +4 -2
- data/app/assets/config/kaui_manifest.js +45 -0
- data/app/assets/javascripts/jquery.spin.js +76 -0
- data/app/assets/javascripts/kaui/kaui.js +76 -0
- data/app/assets/javascripts/kaui_application.js +25 -0
- data/app/assets/javascripts/spin.js +76 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.scss +240 -0
- data/app/assets/stylesheets/kaui/{account.less → account.scss} +4 -0
- data/app/assets/stylesheets/kaui/{audit.less → audit.scss} +5 -1
- data/app/assets/stylesheets/kaui/{common.less → common.scss} +17 -15
- data/app/assets/stylesheets/kaui/{datatable.less → datatable.scss} +6 -3
- data/app/assets/stylesheets/kaui/{header.less → header.scss} +16 -12
- data/app/assets/stylesheets/kaui/{home.less → home.scss} +7 -4
- data/app/assets/stylesheets/kaui/{invoice.less → invoice.scss} +7 -3
- data/app/assets/stylesheets/kaui/kaui.scss +265 -0
- data/app/assets/stylesheets/kaui/kaui_bootstrap.scss +3 -0
- data/app/assets/stylesheets/kaui/{overdue.less → overdue.scss} +3 -1
- data/app/assets/stylesheets/kaui/{payment.less → payment.scss} +3 -0
- data/app/assets/stylesheets/kaui/{subscription.less → subscription.scss} +4 -1
- data/app/assets/stylesheets/kaui/{tags.less → tags.scss} +9 -5
- data/app/assets/stylesheets/kaui/timeline.scss +7 -0
- data/app/assets/stylesheets/kaui/tooltip.scss +15 -0
- data/app/controllers/kaui/account_children_controller.rb +25 -28
- data/app/controllers/kaui/account_custom_fields_controller.rb +16 -15
- data/app/controllers/kaui/account_emails_controller.rb +28 -25
- data/app/controllers/kaui/account_tags_controller.rb +37 -34
- data/app/controllers/kaui/account_timelines_controller.rb +38 -33
- data/app/controllers/kaui/accounts_controller.rb +268 -250
- data/app/controllers/kaui/admin_allowed_users_controller.rb +105 -99
- data/app/controllers/kaui/admin_controller.rb +32 -31
- data/app/controllers/kaui/admin_tenants_controller.rb +434 -388
- data/app/controllers/kaui/audit_logs_controller.rb +86 -83
- data/app/controllers/kaui/bundle_tags_controller.rb +24 -20
- data/app/controllers/kaui/bundles_controller.rb +96 -82
- data/app/controllers/kaui/chargebacks_controller.rb +36 -33
- data/app/controllers/kaui/charges_controller.rb +23 -20
- data/app/controllers/kaui/credits_controller.rb +28 -25
- data/app/controllers/kaui/custom_fields_controller.rb +172 -38
- data/app/controllers/kaui/engine_controller.rb +2 -1
- data/app/controllers/kaui/engine_controller_util.rb +128 -117
- data/app/controllers/kaui/home_controller.rb +230 -217
- data/app/controllers/kaui/invoice_items_controller.rb +43 -39
- data/app/controllers/kaui/invoice_tags_controller.rb +24 -20
- data/app/controllers/kaui/invoices_controller.rb +132 -117
- data/app/controllers/kaui/login_proxy_controller.rb +2 -1
- data/app/controllers/kaui/payment_methods_controller.rb +102 -94
- data/app/controllers/kaui/payments_controller.rb +95 -92
- data/app/controllers/kaui/queues_controller.rb +47 -14
- data/app/controllers/kaui/refunds_controller.rb +36 -33
- data/app/controllers/kaui/registrations_controller.rb +7 -7
- data/app/controllers/kaui/role_definitions_controller.rb +17 -14
- data/app/controllers/kaui/sessions_controller.rb +7 -4
- data/app/controllers/kaui/subscriptions_controller.rb +197 -187
- data/app/controllers/kaui/tag_definitions_controller.rb +28 -27
- data/app/controllers/kaui/tags_controller.rb +25 -22
- data/app/controllers/kaui/tenants_controller.rb +30 -28
- data/app/controllers/kaui/transactions_controller.rb +43 -38
- data/app/helpers/kaui/account_helper.rb +16 -14
- data/app/helpers/kaui/application_helper.rb +8 -3
- data/app/helpers/kaui/date_helper.rb +4 -3
- data/app/helpers/kaui/home_helper.rb +2 -0
- data/app/helpers/kaui/locale_helper.rb +7 -6
- data/app/helpers/kaui/money_helper.rb +2 -1
- data/app/helpers/kaui/object_helper.rb +11 -10
- data/app/helpers/kaui/payment_helper.rb +7 -6
- data/app/helpers/kaui/payment_method_helper.rb +3 -2
- data/app/helpers/kaui/permissions_helper.rb +9 -9
- data/app/helpers/kaui/plugin_helper.rb +25 -23
- data/app/helpers/kaui/subscription_helper.rb +27 -29
- data/app/helpers/kaui/us_states_helper.rb +7 -6
- data/app/helpers/kaui/uuid_helper.rb +8 -6
- data/app/models/kaui/ability.rb +19 -12
- data/app/models/kaui/account.rb +45 -28
- data/app/models/kaui/account_email.rb +23 -20
- data/app/models/kaui/account_timeline.rb +5 -1
- data/app/models/kaui/admin.rb +65 -64
- data/app/models/kaui/admin_tenant.rb +81 -82
- data/app/models/kaui/allowed_user.rb +13 -9
- data/app/models/kaui/allowed_user_tenant.rb +4 -2
- data/app/models/kaui/application_record.rb +2 -0
- data/app/models/kaui/audit_log.rb +6 -3
- data/app/models/kaui/base.rb +13 -7
- data/app/models/kaui/bundle.rb +41 -24
- data/app/models/kaui/catalog.rb +118 -113
- data/app/models/kaui/chargeback.rb +5 -1
- data/app/models/kaui/credit.rb +4 -1
- data/app/models/kaui/custom_field.rb +9 -6
- data/app/models/kaui/invoice.rb +25 -22
- data/app/models/kaui/invoice_item.rb +9 -6
- data/app/models/kaui/invoice_payment.rb +49 -54
- data/app/models/kaui/killbill_authenticatable.rb +14 -8
- data/app/models/kaui/killbill_registerable.rb +7 -0
- data/app/models/kaui/overdue.rb +64 -65
- data/app/models/kaui/payment.rb +22 -19
- data/app/models/kaui/payment_method.rb +48 -39
- data/app/models/kaui/payment_state.rb +41 -38
- data/app/models/kaui/rails_methods.rb +9 -9
- data/app/models/kaui/refund.rb +7 -1
- data/app/models/kaui/role_definition.rb +5 -1
- data/app/models/kaui/simple_plan.rb +5 -3
- data/app/models/kaui/subscription.rb +10 -7
- data/app/models/kaui/tag.rb +25 -22
- data/app/models/kaui/tag_definition.rb +50 -45
- data/app/models/kaui/tenant.rb +6 -5
- data/app/models/kaui/transaction.rb +43 -31
- data/app/models/kaui/user.rb +10 -16
- data/app/models/kaui/user_role.rb +8 -5
- data/app/views/kaui/accounts/_billing_info.html.erb +1 -1
- data/app/views/kaui/accounts/_form.html.erb +2 -2
- data/app/views/kaui/accounts/index.html.erb +2 -0
- data/app/views/kaui/admin_allowed_users/_form.html.erb +3 -3
- data/app/views/kaui/admin_tenants/_form_catalog_translation.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_invoice_template.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_invoice_translation.erb +1 -1
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +11 -5
- data/app/views/kaui/admin_tenants/new_catalog.html.erb +2 -2
- data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +2 -2
- data/app/views/kaui/admin_tenants/new_plan_currency.html.erb +1 -1
- data/app/views/kaui/bundles/index.html.erb +1 -1
- data/app/views/kaui/bundles/transfer.html.erb +13 -5
- data/app/views/kaui/invoices/_invoice_table.html.erb +1 -1
- data/app/views/kaui/layouts/kaui_flash.html.erb +24 -0
- data/app/views/kaui/layouts/kaui_header.html.erb +19 -2
- data/app/views/kaui/payment_methods/_payment_methods_details_table.html.erb +13 -4
- data/app/views/kaui/payments/_payment_table.html.erb +21 -11
- data/app/views/kaui/payments/index.html.erb +9 -9
- data/app/views/kaui/queues/index.html.erb +1 -1
- data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +1 -4
- 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/app/views/kaui/subscriptions/edit_bcd.erb +1 -1
- data/app/views/kaui/tag_definitions/index.html.erb +2 -2
- data/app/views/kaui/tags/index.html.erb +1 -0
- data/config/initializers/bootstrap_datepicker_rails.rb +3 -0
- data/config/initializers/devise.rb +8 -6
- data/config/initializers/js_routes.rb +9 -0
- data/config/initializers/kilbill_client_init.rb +13 -0
- data/config/initializers/killbill_authenticatable.rb +71 -21
- data/config/initializers/killbill_registerable.rb +5 -3
- data/config/initializers/time_formats.rb +6 -4
- data/config/locales/en.yml +78 -1
- data/config/routes.rb +34 -32
- data/db/migrate/20130812155313_devise_create_kaui_users.rb +10 -8
- data/db/migrate/20150109214021_create_kaui_tenants.rb +10 -8
- data/db/migrate/20150112232813_create_kaui_allowed_users.rb +10 -8
- data/lib/generators/kaui/install/install_generator.rb +23 -20
- data/lib/generators/kaui/install/templates/config/initializers/kaui.rb +3 -1
- data/lib/kaui/engine.rb +17 -5
- data/lib/kaui/installer/installer.rb +27 -26
- data/lib/kaui/version.rb +3 -1
- data/lib/kaui.rb +28 -30
- data/lib/tasks/kaui_tasks.rake +1 -0
- metadata +136 -438
- data/app/assets/javascripts/application.js +0 -17
- data/app/assets/javascripts/kaui/bootstrap-tweaks.js +0 -172
- data/app/assets/stylesheets/bootstrap_and_overrides.css.less +0 -44
- data/app/assets/stylesheets/kaui/kaui.less +0 -21
- data/app/assets/stylesheets/kaui/timeline.less +0 -4
- data/config/initializers/asset.rb +0 -1
- data/config/initializers/kilbill-client-init.rb +0 -9
- data/db/schema.rb +0 -15
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -9
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -38
- data/test/dummy/bin/update +0 -29
- data/test/dummy/bin/yarn +0 -11
- data/test/dummy/config/application.rb +0 -18
- data/test/dummy/config/boot.rb +0 -3
- data/test/dummy/config/database.yml +0 -27
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -58
- data/test/dummy/config/environments/production.rb +0 -91
- data/test/dummy/config/environments/test.rb +0 -49
- data/test/dummy/config/initializers/application_controller_renderer.rb +0 -6
- data/test/dummy/config/initializers/assets.rb +0 -14
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/killbill_client.rb +0 -1
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/money.rb +0 -2
- data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +0 -14
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -33
- data/test/dummy/config/routes.rb +0 -3
- data/test/dummy/config/secrets.yml +0 -32
- data/test/dummy/config/symmetric-encryption.yml +0 -135
- data/test/dummy/config.ru +0 -4
- data/test/dummy/db/schema.rb +0 -52
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/fixtures/SpyCarAdvanced.xml +0 -824
- data/test/fixtures/catalog-v1.xml +0 -73
- data/test/fixtures/catalog_translation_fr-v1.properties +0 -1
- data/test/fixtures/invoice_template-v1.html +0 -100
- data/test/fixtures/invoice_translation_fr-v1.properties +0 -23
- data/test/fixtures/overdue-v1.xml +0 -49
- data/test/fixtures/stripe.yml +0 -2
- data/test/functional/kaui/account_children_controller_test.rb +0 -32
- data/test/functional/kaui/account_custom_fields_controller_test.rb +0 -29
- data/test/functional/kaui/account_emails_controller_test.rb +0 -55
- data/test/functional/kaui/account_tags_controller_test.rb +0 -48
- data/test/functional/kaui/account_timelines_controller_test.rb +0 -20
- data/test/functional/kaui/accounts_controller_test.rb +0 -297
- data/test/functional/kaui/admin_allowed_users_controller_test.rb +0 -234
- data/test/functional/kaui/admin_controller_test.rb +0 -45
- data/test/functional/kaui/admin_tenants_controller_test.rb +0 -352
- data/test/functional/kaui/audit_logs_controller_test.rb +0 -71
- data/test/functional/kaui/bundle_tags_controller_test.rb +0 -23
- data/test/functional/kaui/bundles_controller_test.rb +0 -130
- data/test/functional/kaui/chargebacks_controller_test.rb +0 -42
- data/test/functional/kaui/charges_controller_test.rb +0 -60
- data/test/functional/kaui/credits_controller_test.rb +0 -54
- data/test/functional/kaui/custom_fields_controller_test.rb +0 -52
- data/test/functional/kaui/functional_test_helper.rb +0 -13
- data/test/functional/kaui/functional_test_helper_nosetup.rb +0 -120
- data/test/functional/kaui/home_controller_test.rb +0 -407
- data/test/functional/kaui/invoice_items_controller_test.rb +0 -82
- data/test/functional/kaui/invoices_controller_test.rb +0 -88
- data/test/functional/kaui/login_proxy_controller_test.rb +0 -12
- data/test/functional/kaui/payment_methods_controller_test.rb +0 -52
- data/test/functional/kaui/payments_controller_test.rb +0 -59
- data/test/functional/kaui/queues_controller_test.rb +0 -17
- data/test/functional/kaui/refunds_controller_test.rb +0 -63
- data/test/functional/kaui/registrations_controller_test.rb +0 -49
- data/test/functional/kaui/role_definitions_controller_test.rb +0 -47
- data/test/functional/kaui/subscriptions_controller_test.rb +0 -194
- data/test/functional/kaui/tag_definitions_controller_test.rb +0 -29
- data/test/functional/kaui/tags_controller_test.rb +0 -21
- data/test/functional/kaui/tenants_controller_test.rb +0 -60
- data/test/functional/kaui/transactions_controller_test.rb +0 -90
- data/test/integration/kaui/date_helper_integration_test.rb +0 -16
- data/test/integration/kaui/integration_test_helper.rb +0 -32
- data/test/integration/kaui/navigation_test.rb +0 -43
- data/test/killbill_test_helper.rb +0 -219
- data/test/test_helper.rb +0 -22
- data/test/unit/helpers/kaui/admin_allowed_users_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/admin_tenants_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/payment_method_helper_test.rb +0 -17
- data/test/unit/helpers/kaui/tenants_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/uuid_helper_test.rb +0 -16
- data/test/unit/kaui/account_email_test.rb +0 -19
- data/test/unit/kaui/account_test.rb +0 -14
- data/test/unit/kaui/admin_tenant_test.rb +0 -132
- data/test/unit/kaui/allowed_user_test.rb +0 -34
- data/test/unit/kaui/base_test.rb +0 -23
- data/test/unit/kaui/date_helper_test.rb +0 -26
- data/test/unit/kaui/invoice_item_test.rb +0 -11
- data/test/unit/kaui/invoice_payment_test.rb +0 -42
- data/test/unit/kaui/invoice_test.rb +0 -20
- data/test/unit/kaui/money_helper_test.rb +0 -16
- data/test/unit/kaui/payment_test.rb +0 -42
- data/test/unit/kaui/tag_definition_test.rb +0 -11
- data/test/unit/kaui/tenant_test.rb +0 -19
- /data/app/assets/stylesheets/{application.css → kaui_application.css} +0 -0
@@ -1,297 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Kaui::AccountsControllerTest < Kaui::FunctionalTestHelper
|
4
|
-
|
5
|
-
test 'should get index' do
|
6
|
-
get :index
|
7
|
-
assert_response 200
|
8
|
-
end
|
9
|
-
|
10
|
-
test 'should get index one account' do
|
11
|
-
parameters = {
|
12
|
-
:fast => '1',
|
13
|
-
:q => @account.account_id
|
14
|
-
}
|
15
|
-
|
16
|
-
get :index, parameters
|
17
|
-
assert_response :redirect
|
18
|
-
assert_redirected_to account_path(@account.account_id)
|
19
|
-
|
20
|
-
parameters = {
|
21
|
-
:fast => '1',
|
22
|
-
:q => 'THIS_IS_NOT_FOUND_REDIRECT'
|
23
|
-
}
|
24
|
-
|
25
|
-
get :index, parameters
|
26
|
-
assert_response :redirect
|
27
|
-
assert_redirected_to home_path
|
28
|
-
end
|
29
|
-
|
30
|
-
test 'should list accounts' do
|
31
|
-
# Test pagination
|
32
|
-
get :pagination, :format => :json
|
33
|
-
verify_pagination_results!
|
34
|
-
end
|
35
|
-
|
36
|
-
test 'should search accounts' do
|
37
|
-
# Test search
|
38
|
-
get :pagination, :sSearch => 'foo', :format => :json
|
39
|
-
verify_pagination_results!
|
40
|
-
end
|
41
|
-
|
42
|
-
test 'should handle Kill Bill errors when showing account details' do
|
43
|
-
account_id = SecureRandom.uuid.to_s
|
44
|
-
get :show, :account_id => account_id
|
45
|
-
assert_redirected_to home_path
|
46
|
-
assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error]
|
47
|
-
end
|
48
|
-
|
49
|
-
test 'should find account by id' do
|
50
|
-
get :show, :account_id => @account.account_id
|
51
|
-
assert_response 200
|
52
|
-
assert_not_nil assigns(:tags)
|
53
|
-
assert_not_nil assigns(:account_emails)
|
54
|
-
assert_not_nil assigns(:overdue_state)
|
55
|
-
assert_not_nil assigns(:payment_methods)
|
56
|
-
end
|
57
|
-
|
58
|
-
test 'should check that overdue state is Good' do
|
59
|
-
get :show, :account_id => @account.account_id
|
60
|
-
assert_response 200
|
61
|
-
|
62
|
-
overdue_status_proc_count = 0
|
63
|
-
|
64
|
-
assert_select 'table' do |tables|
|
65
|
-
tables.each do |table|
|
66
|
-
assert_select table, 'tr' do |rows|
|
67
|
-
rows.each do |row|
|
68
|
-
# find overdue status in the response
|
69
|
-
is_overdue_state = false
|
70
|
-
assert_select row, 'th' do |col|
|
71
|
-
is_overdue_state = col[0].text.eql?('Overdue status')
|
72
|
-
end
|
73
|
-
|
74
|
-
# if found
|
75
|
-
if is_overdue_state
|
76
|
-
overdue_status_proc_count += 1
|
77
|
-
assert_select row, 'td' do |col|
|
78
|
-
assert_select col, 'span' do |content|
|
79
|
-
assert 'Good', content[0].text
|
80
|
-
overdue_status_proc_count += 1 if content[0].text.eql?('Good')
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# assert that overdue state is found with result equal to Good
|
90
|
-
assert overdue_status_proc_count, 2
|
91
|
-
end
|
92
|
-
|
93
|
-
test 'should handle Kill Bill errors when creating account' do
|
94
|
-
post :create
|
95
|
-
assert_redirected_to home_path
|
96
|
-
assert_equal 'Required parameter missing: account', flash[:error]
|
97
|
-
|
98
|
-
external_key = SecureRandom.uuid.to_s
|
99
|
-
post :create, :account => {:external_key => external_key}
|
100
|
-
assert_redirected_to account_path(assigns(:account).account_id)
|
101
|
-
|
102
|
-
post :create, :account => {:external_key => external_key}
|
103
|
-
assert_template :new
|
104
|
-
assert_equal "Error while creating account: Account already exists for key #{external_key}", flash[:error]
|
105
|
-
end
|
106
|
-
|
107
|
-
test 'should create account' do
|
108
|
-
get :new
|
109
|
-
assert_response 200
|
110
|
-
assert_not_nil assigns(:account)
|
111
|
-
|
112
|
-
post :create,
|
113
|
-
:account => {
|
114
|
-
:name => SecureRandom.uuid.to_s,
|
115
|
-
:external_key => SecureRandom.uuid.to_s,
|
116
|
-
:email => SecureRandom.uuid.to_s + '@example.com',
|
117
|
-
:time_zone => '-06:00',
|
118
|
-
:country => 'AR',
|
119
|
-
:is_migrated => '1'
|
120
|
-
}
|
121
|
-
assert_redirected_to account_path(assigns(:account).account_id)
|
122
|
-
assert_equal 'Account was successfully created', flash[:notice]
|
123
|
-
|
124
|
-
assert_equal '-06:00', assigns(:account).time_zone
|
125
|
-
assert_equal 'AR', assigns(:account).country
|
126
|
-
assert assigns(:account).is_migrated
|
127
|
-
end
|
128
|
-
|
129
|
-
test 'should update account' do
|
130
|
-
get :edit, :account_id => @account.account_id
|
131
|
-
assert_response 200
|
132
|
-
assert_not_nil assigns(:account)
|
133
|
-
|
134
|
-
latest_account_attributes = assigns(:account).to_hash
|
135
|
-
put :update,
|
136
|
-
:account_id => @account.account_id,
|
137
|
-
:account => latest_account_attributes.merge({
|
138
|
-
:name => SecureRandom.uuid.to_s,
|
139
|
-
:email => SecureRandom.uuid.to_s + '@example.com'
|
140
|
-
})
|
141
|
-
assert_redirected_to account_path(assigns(:account).account_id)
|
142
|
-
assert_equal 'Account successfully updated', flash[:notice]
|
143
|
-
end
|
144
|
-
|
145
|
-
test 'should be redirected if no payment_method_id is specified when setting default payment method' do
|
146
|
-
put :set_default_payment_method, :account_id => @account.account_id
|
147
|
-
assert_redirected_to account_path(@account.account_id)
|
148
|
-
assert_equal 'Required parameter missing: payment_method_id', flash[:error]
|
149
|
-
end
|
150
|
-
|
151
|
-
test 'should handle Kill Bill errors when setting default payment method' do
|
152
|
-
account_id = SecureRandom.uuid.to_s
|
153
|
-
put :set_default_payment_method, :account_id => account_id, :payment_method_id => @payment_method.payment_method_id
|
154
|
-
assert_redirected_to home_path
|
155
|
-
assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error]
|
156
|
-
end
|
157
|
-
|
158
|
-
test 'should set default payment method' do
|
159
|
-
put :set_default_payment_method, :account_id => @account.account_id, :payment_method_id => @payment_method.payment_method_id
|
160
|
-
assert_response 302
|
161
|
-
end
|
162
|
-
|
163
|
-
test 'should handle Kill Bill errors when paying all invoices' do
|
164
|
-
account_id = SecureRandom.uuid.to_s
|
165
|
-
post :pay_all_invoices, :account_id => account_id
|
166
|
-
assert_redirected_to home_path
|
167
|
-
assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error]
|
168
|
-
end
|
169
|
-
|
170
|
-
test 'should pay all invoices' do
|
171
|
-
post :pay_all_invoices, :account_id => @account.account_id, :is_external_payment => true
|
172
|
-
assert_response 302
|
173
|
-
end
|
174
|
-
|
175
|
-
test 'should trigger invoice' do
|
176
|
-
account = create_account(@tenant)
|
177
|
-
bundle = create_bundle(account, @tenant)
|
178
|
-
|
179
|
-
parameters = {
|
180
|
-
:account_id => account.account_id,
|
181
|
-
:dry_run => '0'
|
182
|
-
}
|
183
|
-
|
184
|
-
post :trigger_invoice, parameters
|
185
|
-
assert_equal 'Nothing to generate for target date today', flash[:notice]
|
186
|
-
assert_redirected_to account_path(account.account_id)
|
187
|
-
|
188
|
-
today_next_month = (Date.parse(@kb_clock['localDate']) + 31).to_s
|
189
|
-
# generate a dry run invoice
|
190
|
-
parameters = {
|
191
|
-
:account_id => account.account_id,
|
192
|
-
:dry_run => '1',
|
193
|
-
:target_date => today_next_month
|
194
|
-
}
|
195
|
-
|
196
|
-
post :trigger_invoice, parameters
|
197
|
-
assert_response :success
|
198
|
-
assert_select 'table tbody tr:first' do
|
199
|
-
assert_select 'td:first', "sports-monthly-evergreen"
|
200
|
-
assert_select 'td:nth-child(4)', bundle.subscriptions.first.subscription_id
|
201
|
-
end
|
202
|
-
|
203
|
-
|
204
|
-
# persist it
|
205
|
-
parameters[:dry_run] = '0'
|
206
|
-
post :trigger_invoice, parameters
|
207
|
-
assert_response :redirect
|
208
|
-
assert_match(/Generated invoice.*for target date.*/, flash[:notice])
|
209
|
-
a_tag = (/<a.href="(?<href>.*?)">/).match(@response.body)
|
210
|
-
assert_redirected_to a_tag[:href]
|
211
|
-
end
|
212
|
-
|
213
|
-
test 'should get next_invoice_date' do
|
214
|
-
get :next_invoice_date, :account_id => @account.account_id
|
215
|
-
assert_not_nil @response.body
|
216
|
-
end
|
217
|
-
|
218
|
-
test 'should validate external key if found' do
|
219
|
-
get :validate_external_key, :external_key => 'foo'
|
220
|
-
assert_response :success
|
221
|
-
assert_equal JSON[@response.body]['is_found'], false
|
222
|
-
|
223
|
-
external_key = SecureRandom.uuid.to_s
|
224
|
-
post :create, :account => {:external_key => external_key}
|
225
|
-
assert_redirected_to account_path(get_redirected_account_id)
|
226
|
-
|
227
|
-
get :validate_external_key, :external_key => external_key
|
228
|
-
assert_response :success
|
229
|
-
assert_equal JSON[@response.body]['is_found'], true
|
230
|
-
end
|
231
|
-
|
232
|
-
test 'should link and un-link to parent' do
|
233
|
-
parent = create_account(@tenant)
|
234
|
-
child = create_account(@tenant)
|
235
|
-
|
236
|
-
# force an error linking a parent account
|
237
|
-
child.parent_account_id = SecureRandom.uuid.to_s
|
238
|
-
put :link_to_parent, {
|
239
|
-
:account => child.to_hash,
|
240
|
-
:account_id => child.account_id
|
241
|
-
}
|
242
|
-
assert_equal "Parent account id not found: #{child.parent_account_id}",flash[:error]
|
243
|
-
assert_redirected_to account_path(child.account_id)
|
244
|
-
|
245
|
-
# link parent account
|
246
|
-
child.parent_account_id = parent.account_id
|
247
|
-
put :link_to_parent, {
|
248
|
-
:account => child.to_hash,
|
249
|
-
:account_id => child.account_id
|
250
|
-
}
|
251
|
-
assert_equal 'Account successfully updated',flash[:notice]
|
252
|
-
assert_redirected_to account_path(child.account_id)
|
253
|
-
|
254
|
-
# un-link parent account
|
255
|
-
delete :link_to_parent, :account_id => child.account_id
|
256
|
-
assert_equal 'Account successfully updated',flash[:notice]
|
257
|
-
assert_redirected_to account_path(child.account_id)
|
258
|
-
|
259
|
-
end
|
260
|
-
|
261
|
-
test 'should set email notifications configuration if plugin is available' do
|
262
|
-
|
263
|
-
parameters = {
|
264
|
-
:configuration => {
|
265
|
-
:account_id => @account.account_id,
|
266
|
-
:event_types => ['INVOICE_NOTIFICATION']
|
267
|
-
}
|
268
|
-
}
|
269
|
-
|
270
|
-
post :set_email_notifications_configuration, parameters
|
271
|
-
assert_equal('Email notification plugin is not installed',flash[:error]) unless flash[:error].blank?
|
272
|
-
assert_equal("Email notifications for account #{@account.account_id} was successfully updated",flash[:notice]) if flash[:error].blank?
|
273
|
-
assert_redirected_to account_path(@account.account_id)
|
274
|
-
|
275
|
-
end
|
276
|
-
|
277
|
-
test 'should close an account' do
|
278
|
-
account_to_be_closed = create_account(@tenant)
|
279
|
-
|
280
|
-
delete :destroy, :account_id => account_to_be_closed.account_id
|
281
|
-
assert_redirected_to account_path(account_to_be_closed.account_id)
|
282
|
-
assert_equal "Account #{account_to_be_closed.account_id} successfully closed", flash[:notice]
|
283
|
-
|
284
|
-
end
|
285
|
-
|
286
|
-
private
|
287
|
-
|
288
|
-
def get_redirected_account_id
|
289
|
-
|
290
|
-
fields = /<a.href="http:\/.*\/.*?\/(?<id>.*?)">/.match(@response.body) if fields.nil?
|
291
|
-
|
292
|
-
return nil if fields.nil?
|
293
|
-
|
294
|
-
fields.nil? ? nil : fields[:id]
|
295
|
-
end
|
296
|
-
|
297
|
-
end
|
@@ -1,234 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Kaui
|
4
|
-
class AdminAllowedUsersControllerTest < Kaui::FunctionalTestHelper
|
5
|
-
|
6
|
-
test 'should get new' do
|
7
|
-
post :new
|
8
|
-
assert_response :success
|
9
|
-
end
|
10
|
-
|
11
|
-
test 'should get create local only' do
|
12
|
-
parameters = {
|
13
|
-
:allowed_user => {:kb_username => 'Albator', :description => 'My french super hero' },
|
14
|
-
:external => '1' ,
|
15
|
-
:password => 'Albator',
|
16
|
-
:roles => nil,
|
17
|
-
}
|
18
|
-
post :create, parameters
|
19
|
-
assert_equal 'User was successfully configured', flash[:notice]
|
20
|
-
assert_response 302
|
21
|
-
|
22
|
-
# validate redirect path
|
23
|
-
id = get_allowed_id(@response.body)
|
24
|
-
assert response_path.include?(expected_response_path(id)), "#{response_path} is expected to contain #{expected_response_path(id)}"
|
25
|
-
end
|
26
|
-
|
27
|
-
test 'should get create' do
|
28
|
-
parameters = {
|
29
|
-
:allowed_user => {:kb_username => 'Albator', :description => 'My french super hero'},
|
30
|
-
:password => 'Albator',
|
31
|
-
:roles => nil
|
32
|
-
}
|
33
|
-
post :create, parameters
|
34
|
-
assert_equal 'User was successfully configured', flash[:notice]
|
35
|
-
assert_response 302
|
36
|
-
|
37
|
-
# validate redirect path
|
38
|
-
id = get_allowed_id(@response.body)
|
39
|
-
assert response_path.include?(expected_response_path(id)), "#{response_path} is expected to contain #{expected_response_path(id)}"
|
40
|
-
|
41
|
-
# should return an error that the user already exists
|
42
|
-
post :create, parameters
|
43
|
-
assert_equal "User with name #{parameters[:allowed_user][:kb_username]} already exists!", flash[:error]
|
44
|
-
assert_response :success
|
45
|
-
end
|
46
|
-
|
47
|
-
test 'should get index' do
|
48
|
-
get :index
|
49
|
-
assert_response 200
|
50
|
-
end
|
51
|
-
|
52
|
-
test 'should get show' do
|
53
|
-
au = Kaui::AllowedUser.new
|
54
|
-
au.kb_username = 'Mad Max'
|
55
|
-
au.description = 'My super hero'
|
56
|
-
au.save!
|
57
|
-
|
58
|
-
get :show, :id => au.id
|
59
|
-
assert_response :success
|
60
|
-
end
|
61
|
-
|
62
|
-
test 'should get edit' do
|
63
|
-
au = Kaui::AllowedUser.new
|
64
|
-
au.kb_username = 'Mad Max'
|
65
|
-
au.description = 'My super hero'
|
66
|
-
au.save!
|
67
|
-
|
68
|
-
get :edit, :id => au.id
|
69
|
-
|
70
|
-
allowed_username = get_allowed_username
|
71
|
-
assert_equal allowed_username, au.kb_username
|
72
|
-
assert_response :success
|
73
|
-
end
|
74
|
-
|
75
|
-
test 'should update allowed user' do
|
76
|
-
parameters = {
|
77
|
-
:allowed_user => {:kb_username => 'Mad Max', :description => 'My super hero'},
|
78
|
-
:password => 'Batman',
|
79
|
-
:roles => nil
|
80
|
-
}
|
81
|
-
post :create, parameters
|
82
|
-
assert_equal 'User was successfully configured', flash[:notice]
|
83
|
-
assert_response :redirect
|
84
|
-
|
85
|
-
# validate redirect path
|
86
|
-
id = get_allowed_id(@response.body)
|
87
|
-
assert response_path.include?(expected_response_path(id)), "#{response_path} is expected to contain #{expected_response_path(id)}"
|
88
|
-
|
89
|
-
parameters = {
|
90
|
-
:id => id,
|
91
|
-
:allowed_user => { :description => 'An post-apocalyptic super hero' },
|
92
|
-
:roles => 'one,two'
|
93
|
-
}
|
94
|
-
|
95
|
-
put :update, parameters
|
96
|
-
assert_equal 'User was successfully updated', flash[:notice]
|
97
|
-
assert_response :redirect
|
98
|
-
# validate redirect path
|
99
|
-
assert response_path.include?(expected_response_path(id)), "#{response_path} is expected to contain #{expected_response_path(id)}"
|
100
|
-
|
101
|
-
# get the user to verify that the data was actually updated
|
102
|
-
get :edit, :id => id
|
103
|
-
description = get_allowed_description
|
104
|
-
assert_response :success
|
105
|
-
assert_equal parameters[:allowed_user][:description], description
|
106
|
-
|
107
|
-
# delete created user
|
108
|
-
delete :destroy, :id => id
|
109
|
-
assert_equal 'User was successfully deleted', flash[:notice]
|
110
|
-
assert_response :redirect
|
111
|
-
# validate redirect path
|
112
|
-
assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}"
|
113
|
-
end
|
114
|
-
|
115
|
-
test 'should delete allowed user' do
|
116
|
-
parameters = {
|
117
|
-
:allowed_user => {:kb_username => 'Batman', :description => 'Everyone wants to be batman'},
|
118
|
-
:password => 'Batman',
|
119
|
-
:roles => nil
|
120
|
-
}
|
121
|
-
post :create, parameters
|
122
|
-
assert_equal 'User was successfully configured', flash[:notice]
|
123
|
-
assert_response :redirect
|
124
|
-
id = get_allowed_id(@response.body)
|
125
|
-
# validate redirect path
|
126
|
-
assert response_path.include?(expected_response_path(id)), "#{response_path} is expected to contain #{expected_response_path(id)}"
|
127
|
-
|
128
|
-
delete :destroy, :id => id
|
129
|
-
assert_equal 'User was successfully deleted', flash[:notice]
|
130
|
-
assert_response :redirect
|
131
|
-
# validate redirect path
|
132
|
-
assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}"
|
133
|
-
|
134
|
-
# should respond with an error if tried to delete again
|
135
|
-
delete :destroy, :id => id
|
136
|
-
assert_equal "Error: Couldn't find Kaui::AllowedUser with 'id'=#{id}", flash[:error]
|
137
|
-
assert_response :redirect
|
138
|
-
# validate redirect path
|
139
|
-
assert response_path.include?('/kaui/home'), "#{response_path} is expected to contain '/kaui/home'"
|
140
|
-
end
|
141
|
-
|
142
|
-
test 'should add tenant' do
|
143
|
-
allowed_user = {:kb_username => 'Mad Max', :description => 'My super hero'}
|
144
|
-
|
145
|
-
au = Kaui::AllowedUser.new
|
146
|
-
au.kb_username = allowed_user[:kb_username]
|
147
|
-
au.description = allowed_user[:description]
|
148
|
-
au.save!
|
149
|
-
|
150
|
-
allowed_user[:id] = au.id
|
151
|
-
|
152
|
-
put :add_tenant, :allowed_user => allowed_user, :tenant_1 => nil
|
153
|
-
assert_equal 'Successfully set tenants for user', flash[:notice]
|
154
|
-
assert_response :redirect
|
155
|
-
# validate redirect path
|
156
|
-
assert response_path.include?(expected_response_path(au.id)), "#{response_path} is expected to contain #{expected_response_path(au.id)}"
|
157
|
-
end
|
158
|
-
|
159
|
-
test 'should detect if a user is managed externally' do
|
160
|
-
allowed_user = {:kb_username => 'Local', :description => 'adding only locally'}
|
161
|
-
|
162
|
-
# adding only locally will make the user managed externally
|
163
|
-
au = Kaui::AllowedUser.new
|
164
|
-
au.kb_username = allowed_user[:kb_username]
|
165
|
-
au.description = allowed_user[:description]
|
166
|
-
au.save!
|
167
|
-
|
168
|
-
# edit the added user and validate that the checkbox of managed externally is disabled
|
169
|
-
get :edit, :id => au.id
|
170
|
-
assert_response :success
|
171
|
-
assert_select 'form input#external' do |checkbox|
|
172
|
-
assert_equal checkbox[0]['disabled'], 'disabled'
|
173
|
-
end
|
174
|
-
|
175
|
-
# create a user that is managed externally
|
176
|
-
parameters = {
|
177
|
-
:allowed_user => {:kb_username => 'LDAP', :description => 'LDAP' },
|
178
|
-
:external => '1'
|
179
|
-
}
|
180
|
-
post :create, parameters
|
181
|
-
assert_equal 'User was successfully configured', flash[:notice]
|
182
|
-
assert_response 302
|
183
|
-
added_au_id = response_path.gsub('/kaui/admin_allowed_users/','')
|
184
|
-
|
185
|
-
# edit the added user and validate that the checkbox of managed externally is disabled
|
186
|
-
get :edit, :id => added_au_id
|
187
|
-
assert_response :success
|
188
|
-
assert_select 'form input#external' do |checkbox|
|
189
|
-
assert_equal checkbox[0]['disabled'], 'disabled'
|
190
|
-
end
|
191
|
-
|
192
|
-
# create a user that is not managed externally
|
193
|
-
parameters = {
|
194
|
-
:allowed_user => {:kb_username => 'JDBC', :description => 'Kill Bill JDBC Realm' },
|
195
|
-
:external => '0',
|
196
|
-
:password => 'jdbc',
|
197
|
-
:roles => nil
|
198
|
-
}
|
199
|
-
post :create, parameters
|
200
|
-
assert_equal 'User was successfully configured', flash[:notice]
|
201
|
-
assert_response 302
|
202
|
-
added_au_id = response_path.gsub('/kaui/admin_allowed_users/','')
|
203
|
-
|
204
|
-
# edit the added user and validate that the password is not disabled
|
205
|
-
get :edit, :id => added_au_id
|
206
|
-
assert_response :success
|
207
|
-
assert_select 'form input#password' do |input|
|
208
|
-
assert_nil input[0]['disabled']
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
private
|
213
|
-
def expected_response_path(id=nil)
|
214
|
-
"/kaui/admin_allowed_users#{id.nil? ? '' : "/#{id}" }"
|
215
|
-
end
|
216
|
-
|
217
|
-
def get_allowed_username
|
218
|
-
get_value_from_input_field('allowed_user_kb_username')
|
219
|
-
end
|
220
|
-
|
221
|
-
def get_allowed_description
|
222
|
-
get_value_from_input_field('allowed_user_description')
|
223
|
-
end
|
224
|
-
|
225
|
-
def get_allowed_id(response_body)
|
226
|
-
fields = /<form.*action="\/.*\/.*\/(?<id>.*?)".accept-charset=.*method="post">/.match(response_body)
|
227
|
-
fields = /<a.href="http:\/.*\/.*\/(?<id>.*?)">/.match(response_body) if fields.nil?
|
228
|
-
|
229
|
-
fields.nil? ? nil : fields[:id]
|
230
|
-
end
|
231
|
-
|
232
|
-
|
233
|
-
end
|
234
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Kaui::AdminControllerTest < Kaui::FunctionalTestHelper
|
4
|
-
|
5
|
-
test 'should get index' do
|
6
|
-
get :index
|
7
|
-
clock = get_date
|
8
|
-
assert_not_nil clock
|
9
|
-
date = DateTime.parse(clock.to_s.gsub('"','')).strftime('%F')
|
10
|
-
assert_match(/\d{4}-\d{,2}-\d{,2}/, date)
|
11
|
-
assert_response :success
|
12
|
-
end
|
13
|
-
|
14
|
-
test 'should set clock' do
|
15
|
-
|
16
|
-
# retrieve current clock from killbill
|
17
|
-
get :index
|
18
|
-
|
19
|
-
clock = get_date
|
20
|
-
assert_not_nil clock
|
21
|
-
date = DateTime.parse(clock.to_s.gsub('"','')).strftime('%F')
|
22
|
-
assert_match(/\d{4}-\d{,2}-\d{,2}/, date)
|
23
|
-
assert_response :success
|
24
|
-
|
25
|
-
# update killbill clock
|
26
|
-
put :set_clock, :commit => 'Submit', :new_date => clock
|
27
|
-
assert_response :redirect
|
28
|
-
|
29
|
-
# reset killbill clock
|
30
|
-
put :set_clock, :commit => nil
|
31
|
-
assert_response :redirect
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def get_date
|
38
|
-
return nil if @response.nil? || @response.body.nil?
|
39
|
-
|
40
|
-
pattern = Regexp.new('<span.id="kb_clock">(?<clock>.+?)</span>')
|
41
|
-
data = pattern.match(@response.body)
|
42
|
-
data.nil? ? nil : data[:clock]
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|