kaui 2.0.4 → 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 -23
- 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} +13 -1
- data/app/assets/stylesheets/kaui/{audit.less → audit.scss} +5 -1
- data/app/assets/stylesheets/kaui/{common.less → common.scss} +19 -17
- 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 +269 -255
- 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 +87 -84
- 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 +132 -114
- 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 +32 -0
- data/app/controllers/kaui/invoices_controller.rb +134 -88
- data/app/controllers/kaui/login_proxy_controller.rb +2 -1
- data/app/controllers/kaui/payment_methods_controller.rb +103 -90
- 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 +22 -12
- 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 +9 -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 +5 -1
- data/app/views/kaui/accounts/_form.html.erb +2 -2
- data/app/views/kaui/accounts/_payment_methods.html.erb +3 -0
- data/app/views/kaui/accounts/index.html.erb +9 -4
- 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/_form_plugin_config.erb +13 -3
- 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/_bundle_details.html.erb +12 -0
- data/app/views/kaui/bundles/index.html.erb +3 -14
- data/app/views/kaui/bundles/transfer.html.erb +13 -5
- 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 +29 -8
- data/app/views/kaui/invoices/index.html.erb +6 -4
- data/app/views/kaui/invoices/show.html.erb +10 -1
- data/app/views/kaui/layouts/kaui_flash.html.erb +32 -1
- 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 +12 -10
- 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 +40 -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 +76 -23
- data/lib/tasks/kaui_tasks.rake +1 -0
- metadata +141 -436
- 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/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 -217
- 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,352 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Kaui::AdminTenantsControllerTest < Kaui::FunctionalTestHelper
|
4
|
-
|
5
|
-
test 'should get new' do
|
6
|
-
post :new
|
7
|
-
assert_response :success
|
8
|
-
end
|
9
|
-
|
10
|
-
test 'should get create' do
|
11
|
-
now = Time.now.to_s
|
12
|
-
post :create, :tenant => {:name => 'Goldorak_' + now, :api_key => '12345_' + now, :api_secret => 'ItH@st0beComplic@ted'}, :create_tenant => true
|
13
|
-
assert_response 302
|
14
|
-
end
|
15
|
-
|
16
|
-
test 'should get index' do
|
17
|
-
get :index
|
18
|
-
assert_response :success
|
19
|
-
end
|
20
|
-
|
21
|
-
test 'should get show with allowed user' do
|
22
|
-
tenant = Kaui::Tenant.new
|
23
|
-
tenant.name = 'foo'
|
24
|
-
tenant.api_key = 'api_key'
|
25
|
-
tenant.api_secret = 'api_secret'
|
26
|
-
tenant.kb_tenant_id = 'kb_tenant_id'
|
27
|
-
tenant.save!
|
28
|
-
|
29
|
-
# Add an allowed user that will verify that we can only
|
30
|
-
au = Kaui::AllowedUser.find_by_kb_username('admin')
|
31
|
-
au.kaui_tenants << tenant
|
32
|
-
|
33
|
-
get :show, :id => tenant.id
|
34
|
-
assert_response :success
|
35
|
-
end
|
36
|
-
|
37
|
-
test 'should get show with NO allowed user' do
|
38
|
-
tenant = Kaui::Tenant.new
|
39
|
-
tenant.name = 'foo'
|
40
|
-
tenant.api_key = 'api_key'
|
41
|
-
tenant.api_secret = 'api_secret'
|
42
|
-
tenant.kb_tenant_id = 'kb_tenant_id'
|
43
|
-
tenant.save!
|
44
|
-
|
45
|
-
get :show, :id => tenant.id
|
46
|
-
assert_response 200
|
47
|
-
end
|
48
|
-
|
49
|
-
test 'should upload catalog' do
|
50
|
-
tenant = create_kaui_tenant
|
51
|
-
post :upload_catalog, :id => tenant.id, :catalog => fixture_file_upload('catalog-v1.xml')
|
52
|
-
|
53
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
54
|
-
assert_equal 'Catalog was successfully uploaded', flash[:notice]
|
55
|
-
end
|
56
|
-
|
57
|
-
test 'should upload overdue config' do
|
58
|
-
tenant = create_kaui_tenant
|
59
|
-
post :upload_overdue_config, :id => tenant.id, :overdue => fixture_file_upload('overdue-v1.xml')
|
60
|
-
|
61
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
62
|
-
assert_equal 'Overdue config was successfully uploaded', flash[:notice]
|
63
|
-
end
|
64
|
-
|
65
|
-
test 'should upload invoice template' do
|
66
|
-
tenant = create_kaui_tenant
|
67
|
-
post :upload_invoice_template, :id => tenant.id, :invoice_template => fixture_file_upload('invoice_template-v1.html')
|
68
|
-
|
69
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
70
|
-
assert_equal 'Invoice template was successfully uploaded', flash[:notice]
|
71
|
-
end
|
72
|
-
|
73
|
-
test 'should upload invoice translation' do
|
74
|
-
tenant = create_kaui_tenant
|
75
|
-
post :upload_invoice_translation, :id => tenant.id, :invoice_translation => fixture_file_upload('invoice_translation_fr-v1.properties'), :translation_locale => 'fr_FR'
|
76
|
-
|
77
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
78
|
-
assert_equal 'Invoice translation was successfully uploaded', flash[:notice]
|
79
|
-
end
|
80
|
-
|
81
|
-
test 'should upload catalog translation' do
|
82
|
-
tenant = create_kaui_tenant
|
83
|
-
post :upload_catalog_translation, :id => tenant.id, :catalog_translation => fixture_file_upload('catalog_translation_fr-v1.properties'), :translation_locale => 'fr_FR'
|
84
|
-
|
85
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
86
|
-
assert_equal 'Catalog translation was successfully uploaded', flash[:notice]
|
87
|
-
end
|
88
|
-
|
89
|
-
test 'should upload plugin config' do
|
90
|
-
tenant = create_kaui_tenant
|
91
|
-
|
92
|
-
stripe_yml = YAML.load_file(File.join(self.class.fixture_path, 'stripe.yml'))[:stripe]
|
93
|
-
stripe_yml.stringify_keys!
|
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_key => 'stripe', :plugin_type => 'ruby', :plugin_properties => stripe_yml
|
96
|
-
|
97
|
-
assert_redirected_to admin_tenant_path(tenant.id, :active_tab => 'PluginConfig')
|
98
|
-
assert_equal 'Config for plugin was successfully uploaded', flash[:notice]
|
99
|
-
end
|
100
|
-
|
101
|
-
test 'should get new catalog' do
|
102
|
-
tenant = create_kaui_tenant
|
103
|
-
|
104
|
-
get :new_catalog, :id => tenant.id
|
105
|
-
assert_response :success
|
106
|
-
assert has_input_field('simple_plan_product_name')
|
107
|
-
end
|
108
|
-
|
109
|
-
test 'should get new plan currency' do
|
110
|
-
tenant = create_kaui_tenant
|
111
|
-
|
112
|
-
# retrieve plan id from catalog xml
|
113
|
-
catalog_xml = File.open(File.join(self.class.fixture_path, 'catalog-v1.xml'),'r'){|io| io.read}
|
114
|
-
doc = Nokogiri::XML(catalog_xml)
|
115
|
-
plan_id = doc.css('plan').first['name']
|
116
|
-
|
117
|
-
# upload catalog first
|
118
|
-
post :upload_catalog, :id => tenant.id, :catalog => fixture_file_upload('catalog-v1.xml')
|
119
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
120
|
-
assert_equal 'Catalog was successfully uploaded', flash[:notice]
|
121
|
-
|
122
|
-
get :new_plan_currency, :id => tenant.id, :plan_id => plan_id
|
123
|
-
assert_response :success
|
124
|
-
assert_equal get_value_from_input_field('simple_plan_plan_id'), plan_id
|
125
|
-
|
126
|
-
# test for invalid plan id
|
127
|
-
get :new_plan_currency, :id => tenant.id, :plan_id => 'DUMMY'
|
128
|
-
assert_response :redirect
|
129
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
130
|
-
assert_equal flash[:error], 'Plan id DUMMY was not found.'
|
131
|
-
|
132
|
-
end
|
133
|
-
|
134
|
-
test 'should create and delete a catalog' do
|
135
|
-
tenant = create_kaui_tenant
|
136
|
-
|
137
|
-
parameters = {
|
138
|
-
:id => tenant.id,
|
139
|
-
:simple_plan => {
|
140
|
-
:product_category => 'STANDALONE',
|
141
|
-
:product_name => 'Boat Rental',
|
142
|
-
:plan_id => 'boat12345678910',
|
143
|
-
:amount => 10,
|
144
|
-
:currency => 'USD',
|
145
|
-
:billing_period => 'MONTHLY',
|
146
|
-
:trial_length => 0,
|
147
|
-
:trial_time_unit => 'UNLIMITED'
|
148
|
-
}
|
149
|
-
}
|
150
|
-
post :create_simple_plan, parameters
|
151
|
-
assert_response :redirect
|
152
|
-
expected_response_path = "/admin_tenants/#{tenant.id}"
|
153
|
-
assert_equal 'Catalog plan was successfully added', flash[:notice]
|
154
|
-
assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}"
|
155
|
-
|
156
|
-
|
157
|
-
delete :delete_catalog, :id => tenant.id
|
158
|
-
assert_response :redirect
|
159
|
-
|
160
|
-
if !flash[:error].nil? && flash[:error].to_s.eql?('Failed to delete catalog: only available in KB 0.19+ versions')
|
161
|
-
assert response_path.include?('/admin_tenants'), "#{response_path} is expected to contain /admin_tenants"
|
162
|
-
else
|
163
|
-
assert_equal 'Catalog was successfully deleted', flash[:notice]
|
164
|
-
assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}"
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
test 'should remove allowed user' do
|
170
|
-
tenant = create_kaui_tenant
|
171
|
-
|
172
|
-
au = Kaui::AllowedUser.new
|
173
|
-
au.kb_username = 'Voltron'
|
174
|
-
au.description = 'Defender of the Universe'
|
175
|
-
au.save!
|
176
|
-
|
177
|
-
parameters = {
|
178
|
-
:id => tenant.id,
|
179
|
-
:allowed_user => { :id => au.id }
|
180
|
-
}
|
181
|
-
|
182
|
-
delete :remove_allowed_user, parameters
|
183
|
-
assert_response :success
|
184
|
-
end
|
185
|
-
|
186
|
-
test 'should modify overdue config' do
|
187
|
-
tenant = create_kaui_tenant
|
188
|
-
|
189
|
-
parameters = {
|
190
|
-
:id => tenant.id,
|
191
|
-
:kill_bill_client_model_overdue => {
|
192
|
-
:states => { '0' => {
|
193
|
-
:name => 'Overdue_test',
|
194
|
-
:external_message => 'Overdue_Test_Ya',
|
195
|
-
:is_block_changes => true,
|
196
|
-
:subscription_cancellation_policy => 'NONE',
|
197
|
-
:condition => {
|
198
|
-
:time_since_earliest_unpaid_invoice_equals_or_exceeds => 1,
|
199
|
-
:control_tag_inclusion => 'NONE',
|
200
|
-
:control_tag_exclusion => 'NONE',
|
201
|
-
:number_of_unpaid_invoices_equals_or_exceeds => 0,
|
202
|
-
:total_unpaid_invoice_balance_equals_or_exceeds => 0
|
203
|
-
}
|
204
|
-
}}
|
205
|
-
}
|
206
|
-
}
|
207
|
-
|
208
|
-
post :modify_overdue_config, parameters
|
209
|
-
assert_response :redirect
|
210
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
211
|
-
assert_equal 'Overdue config was successfully added', flash[:notice].to_s.strip
|
212
|
-
end
|
213
|
-
|
214
|
-
test 'should display catalog xml' do
|
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 } }
|
226
|
-
|
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
|
231
|
-
end
|
232
|
-
|
233
|
-
test 'should display overdue xml' do
|
234
|
-
overdue_xml = File.open(File.join(self.class.fixture_path, 'overdue-v1.xml'),'r'){|io| io.read}
|
235
|
-
post :display_overdue_xml, :xml => overdue_xml
|
236
|
-
|
237
|
-
assert_equal @response.body, overdue_xml
|
238
|
-
end
|
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 switch tenant' do
|
288
|
-
other_tenant = setup_and_create_test_tenant(1)
|
289
|
-
other_tenant_kaui = Kaui::Tenant.find_by_kb_tenant_id(other_tenant.tenant_id)
|
290
|
-
|
291
|
-
get :switch_tenant, :kb_tenant_id => other_tenant.tenant_id
|
292
|
-
assert_redirected_to admin_tenant_path(other_tenant_kaui.id)
|
293
|
-
assert_equal flash[:notice], "Tenant was switched to #{other_tenant_kaui.name}"
|
294
|
-
|
295
|
-
# switch back
|
296
|
-
tenant_kaui = Kaui::Tenant.find_by_kb_tenant_id(@tenant.tenant_id)
|
297
|
-
get :switch_tenant, :kb_tenant_id => @tenant.tenant_id
|
298
|
-
assert_redirected_to admin_tenant_path(tenant_kaui.id)
|
299
|
-
assert_equal flash[:notice], "Tenant was switched to #{tenant_kaui.name}"
|
300
|
-
end
|
301
|
-
|
302
|
-
test 'should download a catalog' do
|
303
|
-
effective_date = '2013-02-08T00:00:00+00:00'
|
304
|
-
tenant = create_kaui_tenant
|
305
|
-
post :upload_catalog, :id => tenant.id, :catalog => fixture_file_upload('catalog-v1.xml')
|
306
|
-
|
307
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
308
|
-
assert_equal 'Catalog was successfully uploaded', flash[:notice]
|
309
|
-
|
310
|
-
get :download_catalog_xml, :effective_date => effective_date, :id => tenant.id
|
311
|
-
assert_response :success
|
312
|
-
assert_equal 'application/xml', @response.header['Content-Type']
|
313
|
-
assert_equal "attachment; filename=\"catalog_#{effective_date}.xml\"", @response.header['Content-Disposition']
|
314
|
-
|
315
|
-
doc = nil
|
316
|
-
assert_nothing_raised { doc = Nokogiri::XML(@response.body) { |config| config.strict } }
|
317
|
-
|
318
|
-
catalog = doc.xpath("//catalog")
|
319
|
-
expected_effective_date = Date.parse(catalog[0].search("effectiveDate").text)
|
320
|
-
|
321
|
-
assert_equal Date.parse(effective_date), expected_effective_date
|
322
|
-
end
|
323
|
-
|
324
|
-
private
|
325
|
-
|
326
|
-
def create_kaui_tenant
|
327
|
-
post :create,
|
328
|
-
:tenant => {:name => SecureRandom.uuid.to_s, :api_key => SecureRandom.uuid.to_s, :api_secret => SecureRandom.uuid.to_s},
|
329
|
-
:create_tenant => true
|
330
|
-
|
331
|
-
tenant = Kaui::Tenant.last
|
332
|
-
assert_redirected_to admin_tenant_path(tenant.id)
|
333
|
-
assert_equal 'Tenant was successfully configured', flash[:notice]
|
334
|
-
tenant
|
335
|
-
end
|
336
|
-
|
337
|
-
def installed_plugins
|
338
|
-
installed_plugins = []
|
339
|
-
nodes_info = KillBillClient::Model::NodesInfo.nodes_info(build_options(@tenant, USERNAME, PASSWORD)) || []
|
340
|
-
plugins_info = nodes_info.first.plugins_info || []
|
341
|
-
plugins_info.each do |plugin|
|
342
|
-
next if plugin.plugin_key.nil? || plugin.version.nil?
|
343
|
-
next if installed_plugins.any? { |p| p[:plugin_name].eql?(plugin.plugin_name) }
|
344
|
-
installed_plugins << {
|
345
|
-
plugin_key: plugin.plugin_key,
|
346
|
-
plugin_name: plugin.plugin_name
|
347
|
-
}
|
348
|
-
end
|
349
|
-
|
350
|
-
installed_plugins
|
351
|
-
end
|
352
|
-
end
|
@@ -1,71 +0,0 @@
|
|
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
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Kaui::BundleTagsControllerTest < Kaui::FunctionalTestHelper
|
4
|
-
|
5
|
-
test 'should handle Kill Bill errors when getting edit screen' do
|
6
|
-
get :edit, :account_id => @account.account_id
|
7
|
-
assert_redirected_to account_path(@account.account_id)
|
8
|
-
assert_equal 'Required parameter missing: bundle_id', flash[:error]
|
9
|
-
|
10
|
-
bundle_id = SecureRandom.uuid.to_s
|
11
|
-
get :edit, :account_id => @account.account_id, :bundle_id => bundle_id
|
12
|
-
assert_redirected_to account_path(@account.account_id)
|
13
|
-
assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{bundle_id} type=BUNDLE doesn't exist!", flash[:error]
|
14
|
-
end
|
15
|
-
|
16
|
-
test 'should get edit' do
|
17
|
-
get :edit, :account_id => @account.account_id, :bundle_id => @bundle.bundle_id
|
18
|
-
assert_response 200
|
19
|
-
assert_not_nil assigns(:bundle_id)
|
20
|
-
assert_not_nil assigns(:tag_names)
|
21
|
-
assert_not_nil assigns(:available_tags)
|
22
|
-
end
|
23
|
-
end
|
@@ -1,130 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Kaui::BundlesControllerTest < Kaui::FunctionalTestHelper
|
4
|
-
|
5
|
-
test 'should be redirected if an invalid account id was specified in index screen' do
|
6
|
-
account_id = SecureRandom.uuid.to_s
|
7
|
-
get :index, :account_id => account_id
|
8
|
-
assert_redirected_to account_path(account_id)
|
9
|
-
assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error]
|
10
|
-
end
|
11
|
-
|
12
|
-
test 'should get index with existing tags' do
|
13
|
-
|
14
|
-
tag_definition_ids = []
|
15
|
-
def1 = create_tag_definition(SecureRandom.uuid.to_s[0..19], @tenant);
|
16
|
-
tag_definition_ids << def1
|
17
|
-
tag_definition_ids << def1
|
18
|
-
def2 = create_tag_definition(SecureRandom.uuid.to_s[0..19], @tenant);
|
19
|
-
tag_definition_ids << def2
|
20
|
-
|
21
|
-
add_tags(@bundle, tag_definition_ids, @tenant);
|
22
|
-
get :index, :account_id => @bundle.account_id
|
23
|
-
assert_response 200
|
24
|
-
assert_not_nil assigns(:account)
|
25
|
-
assert_not_nil assigns(:bundles)
|
26
|
-
assert_not_nil assigns(:tags_per_bundle)
|
27
|
-
assert_equal 2, assigns(:tags_per_bundle)[@bundle.bundle_id].size
|
28
|
-
end
|
29
|
-
|
30
|
-
test 'should handle Kill Bill errors during transfer' do
|
31
|
-
post :do_transfer, :id => @bundle.bundle_id
|
32
|
-
assert_redirected_to home_path
|
33
|
-
assert_equal 'Required parameter missing: new_account_key', flash[:error]
|
34
|
-
|
35
|
-
new_account_key = SecureRandom.uuid.to_s
|
36
|
-
post :do_transfer, :id => @bundle.bundle_id, :new_account_key => new_account_key
|
37
|
-
assert_redirected_to home_path
|
38
|
-
assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{new_account_key} type=ACCOUNT doesn't exist!", flash[:error]
|
39
|
-
|
40
|
-
bundle_id = SecureRandom.uuid.to_s
|
41
|
-
post :do_transfer, :id => bundle_id, :new_account_key => @account2.external_key
|
42
|
-
assert_redirected_to home_path
|
43
|
-
assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{bundle_id} type=BUNDLE doesn't exist!", flash[:error]
|
44
|
-
end
|
45
|
-
|
46
|
-
test 'should get transfer' do
|
47
|
-
get :transfer, :id => @bundle.bundle_id
|
48
|
-
assert_response 200
|
49
|
-
assert_not_nil assigns(:bundle_id)
|
50
|
-
end
|
51
|
-
|
52
|
-
test 'should transfer bundle default policy' do
|
53
|
-
check_bundle_owner(@account.account_id)
|
54
|
-
|
55
|
-
post :do_transfer,
|
56
|
-
:id => @bundle.bundle_id,
|
57
|
-
:new_account_key => @account2.external_key
|
58
|
-
assert_redirected_to account_bundles_path(@account2.account_id)
|
59
|
-
assert_equal 'Bundle was successfully transferred', flash[:notice]
|
60
|
-
|
61
|
-
check_bundle_owner(@account2.account_id)
|
62
|
-
end
|
63
|
-
|
64
|
-
test 'should transfer bundle immediately' do
|
65
|
-
check_bundle_owner(@account.account_id)
|
66
|
-
|
67
|
-
post :do_transfer,
|
68
|
-
:id => @bundle.bundle_id,
|
69
|
-
:new_account_key => @account2.external_key,
|
70
|
-
:billing_policy => 'IMMEDIATE'
|
71
|
-
assert_redirected_to account_bundles_path(@account2.account_id)
|
72
|
-
assert_equal 'Bundle was successfully transferred', flash[:notice]
|
73
|
-
|
74
|
-
check_bundle_owner(@account2.account_id)
|
75
|
-
end
|
76
|
-
|
77
|
-
test 'should expose restful endpoint' do
|
78
|
-
get :restful_show, :id => @bundle.bundle_id
|
79
|
-
assert_redirected_to account_bundles_path(@bundle.account_id)
|
80
|
-
|
81
|
-
get :restful_show, :id => @bundle.external_key
|
82
|
-
assert_redirected_to account_bundles_path(@bundle.account_id)
|
83
|
-
end
|
84
|
-
|
85
|
-
test 'should get pause_resume ' do
|
86
|
-
get :pause_resume, :id => @bundle.bundle_id
|
87
|
-
assert_response :success
|
88
|
-
assert has_input_field('pause_requested_date')
|
89
|
-
assert has_input_field('resume_requested_date')
|
90
|
-
end
|
91
|
-
|
92
|
-
test 'should put bundle on pause and resume' do
|
93
|
-
expected_response_path = "/accounts/#{@account.account_id}/bundles"
|
94
|
-
bundle = create_bundle(@account, @tenant)
|
95
|
-
|
96
|
-
# put bundle on pause
|
97
|
-
put :do_pause_resume, :id => bundle.bundle_id,:account_id => @account.account_id, :pause_requested_date => DateTime.now.strftime('%F')
|
98
|
-
assert_response :redirect
|
99
|
-
assert_equal 'Bundle was successfully paused', flash[:notice]
|
100
|
-
# validate redirect path
|
101
|
-
assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}"
|
102
|
-
|
103
|
-
# resume bundle on pause
|
104
|
-
put :do_pause_resume, :id => bundle.bundle_id,:account_id => @account.account_id, :resume_requested_date => DateTime.now.strftime('%F')
|
105
|
-
assert_response :redirect
|
106
|
-
assert_equal 'Bundle was successfully resumed', flash[:notice]
|
107
|
-
# validate redirect path
|
108
|
-
assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}"
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
private
|
113
|
-
|
114
|
-
def create_tag_definition(tag_definition_name, tenant, username = USERNAME, password = PASSWORD, reason = nil, comment = nil)
|
115
|
-
input = Kaui::TagDefinition.new(tag_definition_name)
|
116
|
-
input.name = tag_definition_name
|
117
|
-
input.description = 'something'
|
118
|
-
input.applicable_object_types = ['BUNDLE']
|
119
|
-
tag_def = input.create(username, reason, comment, build_options(tenant, username, password))
|
120
|
-
tag_def.id
|
121
|
-
end
|
122
|
-
|
123
|
-
def add_tags(bundle, tag_definition_ids, tenant, username = USERNAME, password = PASSWORD, reason = nil, comment = nil)
|
124
|
-
bundle.set_tags(tag_definition_ids, username, reason, comment, build_options(tenant, username, password))
|
125
|
-
end
|
126
|
-
|
127
|
-
def check_bundle_owner(new_owner)
|
128
|
-
assert_equal new_owner, Kaui::Bundle.find_by_external_key(@bundle.external_key, false, options).account_id
|
129
|
-
end
|
130
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Kaui::ChargebacksControllerTest < Kaui::FunctionalTestHelper
|
4
|
-
|
5
|
-
test 'should handle Kill Bill errors in new screen' do
|
6
|
-
payment_id = SecureRandom.uuid.to_s
|
7
|
-
get :new, :account_id => @account.account_id, :payment_id => payment_id
|
8
|
-
assert_redirected_to account_path(@account.account_id)
|
9
|
-
assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{payment_id} type=PAYMENT doesn't exist!", flash[:error]
|
10
|
-
end
|
11
|
-
|
12
|
-
test 'should get new' do
|
13
|
-
get :new, :account_id => @account.account_id, :payment_id => @payment.payment_id
|
14
|
-
assert_response 200
|
15
|
-
end
|
16
|
-
|
17
|
-
test 'should handle Kill Bill errors during create' do
|
18
|
-
payment_id = SecureRandom.uuid.to_s
|
19
|
-
post :create,
|
20
|
-
:account_id => @account.account_id,
|
21
|
-
:chargeback => {
|
22
|
-
:payment_id => payment_id,
|
23
|
-
:amount => @payment.paid_amount_to_money.to_f,
|
24
|
-
:currency => @payment.currency
|
25
|
-
}
|
26
|
-
assert_template :new
|
27
|
-
assert_equal "Error while creating a new chargeback: Error 404: Object id=#{payment_id} type=PAYMENT doesn't exist!", flash[:error]
|
28
|
-
end
|
29
|
-
|
30
|
-
test 'should create chargeback' do
|
31
|
-
post :create,
|
32
|
-
:account_id => @payment.account_id,
|
33
|
-
:chargeback => {
|
34
|
-
:payment_id => @payment.payment_id,
|
35
|
-
:amount => @payment.paid_amount_to_money.to_f,
|
36
|
-
:currency => @payment.currency
|
37
|
-
},
|
38
|
-
:cancel_all_subs => '1'
|
39
|
-
assert_redirected_to account_payment_path(@payment.account_id, @payment.payment_id)
|
40
|
-
assert_equal 'Chargeback created', flash[:notice]
|
41
|
-
end
|
42
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Kaui::ChargesControllerTest < Kaui::FunctionalTestHelper
|
4
|
-
|
5
|
-
test 'should handle Kill Bill errors in new screen' do
|
6
|
-
invoice_id = SecureRandom.uuid.to_s
|
7
|
-
get :new, :account_id => @account.account_id, :invoice_id => invoice_id
|
8
|
-
assert_redirected_to account_path(@account.account_id)
|
9
|
-
assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
10
|
-
end
|
11
|
-
|
12
|
-
test 'should get new for new invoice' do
|
13
|
-
get :new, :account_id => @account.account_id
|
14
|
-
assert_response 200
|
15
|
-
end
|
16
|
-
|
17
|
-
test 'should get new for existing invoice' do
|
18
|
-
get :new, :account_id => @account.account_id, :invoice_id => @invoice_item.invoice_id
|
19
|
-
assert_response 200
|
20
|
-
end
|
21
|
-
|
22
|
-
test 'should handle Kill Bill errors during creation' do
|
23
|
-
invoice_id = SecureRandom.uuid.to_s
|
24
|
-
post :create,
|
25
|
-
:account_id => @account.account_id,
|
26
|
-
:invoice_item => {
|
27
|
-
:invoice_id => invoice_id,
|
28
|
-
:amount => 5.34,
|
29
|
-
:currency => 'USD',
|
30
|
-
:description => SecureRandom.uuid
|
31
|
-
}
|
32
|
-
assert_redirected_to account_path(@account.account_id)
|
33
|
-
assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
34
|
-
end
|
35
|
-
|
36
|
-
test 'should create charge' do
|
37
|
-
post :create,
|
38
|
-
:account_id => @account.account_id,
|
39
|
-
:invoice_item => {
|
40
|
-
:amount => 5.34,
|
41
|
-
:currency => 'USD',
|
42
|
-
:description => SecureRandom.uuid
|
43
|
-
}
|
44
|
-
assert_response :redirect
|
45
|
-
assert_equal 'Charge was successfully created', flash[:notice]
|
46
|
-
end
|
47
|
-
|
48
|
-
test 'should create charge for existing invoice' do
|
49
|
-
post :create,
|
50
|
-
:account_id => @account.account_id,
|
51
|
-
:invoice_item => {
|
52
|
-
:invoice_id => @invoice_item.invoice_id,
|
53
|
-
:amount => 5.34,
|
54
|
-
:currency => 'USD',
|
55
|
-
:description => SecureRandom.uuid
|
56
|
-
}
|
57
|
-
assert_redirected_to account_invoice_path(@account.account_id, @invoice_item.invoice_id)
|
58
|
-
assert_equal 'Charge was successfully created', flash[:notice]
|
59
|
-
end
|
60
|
-
end
|