kaui 2.0.4 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +8 -23
  3. data/Rakefile +4 -2
  4. data/app/assets/config/kaui_manifest.js +45 -0
  5. data/app/assets/javascripts/jquery.spin.js +76 -0
  6. data/app/assets/javascripts/kaui/kaui.js +76 -0
  7. data/app/assets/javascripts/kaui_application.js +25 -0
  8. data/app/assets/javascripts/spin.js +76 -0
  9. data/app/assets/stylesheets/bootstrap_and_overrides.scss +240 -0
  10. data/app/assets/stylesheets/kaui/{account.less → account.scss} +13 -1
  11. data/app/assets/stylesheets/kaui/{audit.less → audit.scss} +5 -1
  12. data/app/assets/stylesheets/kaui/{common.less → common.scss} +19 -17
  13. data/app/assets/stylesheets/kaui/{datatable.less → datatable.scss} +6 -3
  14. data/app/assets/stylesheets/kaui/{header.less → header.scss} +16 -12
  15. data/app/assets/stylesheets/kaui/{home.less → home.scss} +7 -4
  16. data/app/assets/stylesheets/kaui/{invoice.less → invoice.scss} +7 -3
  17. data/app/assets/stylesheets/kaui/kaui.scss +265 -0
  18. data/app/assets/stylesheets/kaui/kaui_bootstrap.scss +3 -0
  19. data/app/assets/stylesheets/kaui/{overdue.less → overdue.scss} +3 -1
  20. data/app/assets/stylesheets/kaui/{payment.less → payment.scss} +3 -0
  21. data/app/assets/stylesheets/kaui/{subscription.less → subscription.scss} +4 -1
  22. data/app/assets/stylesheets/kaui/{tags.less → tags.scss} +9 -5
  23. data/app/assets/stylesheets/kaui/timeline.scss +7 -0
  24. data/app/assets/stylesheets/kaui/tooltip.scss +15 -0
  25. data/app/controllers/kaui/account_children_controller.rb +25 -28
  26. data/app/controllers/kaui/account_custom_fields_controller.rb +16 -15
  27. data/app/controllers/kaui/account_emails_controller.rb +28 -25
  28. data/app/controllers/kaui/account_tags_controller.rb +37 -34
  29. data/app/controllers/kaui/account_timelines_controller.rb +38 -33
  30. data/app/controllers/kaui/accounts_controller.rb +269 -255
  31. data/app/controllers/kaui/admin_allowed_users_controller.rb +105 -99
  32. data/app/controllers/kaui/admin_controller.rb +32 -31
  33. data/app/controllers/kaui/admin_tenants_controller.rb +434 -388
  34. data/app/controllers/kaui/audit_logs_controller.rb +87 -84
  35. data/app/controllers/kaui/bundle_tags_controller.rb +24 -20
  36. data/app/controllers/kaui/bundles_controller.rb +96 -82
  37. data/app/controllers/kaui/chargebacks_controller.rb +36 -33
  38. data/app/controllers/kaui/charges_controller.rb +23 -20
  39. data/app/controllers/kaui/credits_controller.rb +28 -25
  40. data/app/controllers/kaui/custom_fields_controller.rb +172 -38
  41. data/app/controllers/kaui/engine_controller.rb +2 -1
  42. data/app/controllers/kaui/engine_controller_util.rb +134 -114
  43. data/app/controllers/kaui/home_controller.rb +230 -217
  44. data/app/controllers/kaui/invoice_items_controller.rb +43 -39
  45. data/app/controllers/kaui/invoice_tags_controller.rb +32 -0
  46. data/app/controllers/kaui/invoices_controller.rb +134 -88
  47. data/app/controllers/kaui/login_proxy_controller.rb +2 -1
  48. data/app/controllers/kaui/payment_methods_controller.rb +103 -90
  49. data/app/controllers/kaui/payments_controller.rb +95 -92
  50. data/app/controllers/kaui/queues_controller.rb +47 -14
  51. data/app/controllers/kaui/refunds_controller.rb +36 -33
  52. data/app/controllers/kaui/registrations_controller.rb +7 -7
  53. data/app/controllers/kaui/role_definitions_controller.rb +17 -14
  54. data/app/controllers/kaui/sessions_controller.rb +7 -4
  55. data/app/controllers/kaui/subscriptions_controller.rb +197 -187
  56. data/app/controllers/kaui/tag_definitions_controller.rb +28 -27
  57. data/app/controllers/kaui/tags_controller.rb +25 -22
  58. data/app/controllers/kaui/tenants_controller.rb +30 -28
  59. data/app/controllers/kaui/transactions_controller.rb +43 -38
  60. data/app/helpers/kaui/account_helper.rb +22 -12
  61. data/app/helpers/kaui/application_helper.rb +8 -3
  62. data/app/helpers/kaui/date_helper.rb +3 -2
  63. data/app/helpers/kaui/home_helper.rb +2 -0
  64. data/app/helpers/kaui/locale_helper.rb +7 -6
  65. data/app/helpers/kaui/money_helper.rb +2 -1
  66. data/app/helpers/kaui/object_helper.rb +11 -10
  67. data/app/helpers/kaui/payment_helper.rb +7 -6
  68. data/app/helpers/kaui/payment_method_helper.rb +3 -2
  69. data/app/helpers/kaui/permissions_helper.rb +9 -9
  70. data/app/helpers/kaui/plugin_helper.rb +25 -23
  71. data/app/helpers/kaui/subscription_helper.rb +27 -29
  72. data/app/helpers/kaui/us_states_helper.rb +7 -6
  73. data/app/helpers/kaui/uuid_helper.rb +8 -5
  74. data/app/models/kaui/ability.rb +19 -12
  75. data/app/models/kaui/account.rb +45 -28
  76. data/app/models/kaui/account_email.rb +23 -20
  77. data/app/models/kaui/account_timeline.rb +5 -1
  78. data/app/models/kaui/admin.rb +65 -64
  79. data/app/models/kaui/admin_tenant.rb +81 -82
  80. data/app/models/kaui/allowed_user.rb +13 -9
  81. data/app/models/kaui/allowed_user_tenant.rb +4 -2
  82. data/app/models/kaui/application_record.rb +2 -0
  83. data/app/models/kaui/audit_log.rb +6 -3
  84. data/app/models/kaui/base.rb +13 -7
  85. data/app/models/kaui/bundle.rb +41 -24
  86. data/app/models/kaui/catalog.rb +118 -113
  87. data/app/models/kaui/chargeback.rb +5 -1
  88. data/app/models/kaui/credit.rb +4 -1
  89. data/app/models/kaui/custom_field.rb +9 -6
  90. data/app/models/kaui/invoice.rb +25 -22
  91. data/app/models/kaui/invoice_item.rb +9 -6
  92. data/app/models/kaui/invoice_payment.rb +49 -54
  93. data/app/models/kaui/killbill_authenticatable.rb +14 -8
  94. data/app/models/kaui/killbill_registerable.rb +7 -0
  95. data/app/models/kaui/overdue.rb +64 -65
  96. data/app/models/kaui/payment.rb +22 -19
  97. data/app/models/kaui/payment_method.rb +48 -39
  98. data/app/models/kaui/payment_state.rb +41 -38
  99. data/app/models/kaui/rails_methods.rb +9 -9
  100. data/app/models/kaui/refund.rb +7 -1
  101. data/app/models/kaui/role_definition.rb +5 -1
  102. data/app/models/kaui/simple_plan.rb +5 -3
  103. data/app/models/kaui/subscription.rb +10 -7
  104. data/app/models/kaui/tag.rb +25 -22
  105. data/app/models/kaui/tag_definition.rb +50 -45
  106. data/app/models/kaui/tenant.rb +6 -5
  107. data/app/models/kaui/transaction.rb +43 -31
  108. data/app/models/kaui/user.rb +10 -16
  109. data/app/models/kaui/user_role.rb +8 -5
  110. data/app/views/kaui/accounts/_billing_info.html.erb +5 -1
  111. data/app/views/kaui/accounts/_form.html.erb +2 -2
  112. data/app/views/kaui/accounts/_payment_methods.html.erb +3 -0
  113. data/app/views/kaui/accounts/index.html.erb +9 -4
  114. data/app/views/kaui/admin_allowed_users/_form.html.erb +3 -3
  115. data/app/views/kaui/admin_tenants/_form_catalog_translation.erb +1 -1
  116. data/app/views/kaui/admin_tenants/_form_invoice_template.erb +1 -1
  117. data/app/views/kaui/admin_tenants/_form_invoice_translation.erb +1 -1
  118. data/app/views/kaui/admin_tenants/_form_plugin_config.erb +13 -3
  119. data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +11 -5
  120. data/app/views/kaui/admin_tenants/new_catalog.html.erb +2 -2
  121. data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +2 -2
  122. data/app/views/kaui/admin_tenants/new_plan_currency.html.erb +1 -1
  123. data/app/views/kaui/bundles/_bundle_details.html.erb +12 -0
  124. data/app/views/kaui/bundles/index.html.erb +3 -14
  125. data/app/views/kaui/bundles/transfer.html.erb +13 -5
  126. data/app/views/kaui/invoice_tags/_form.html.erb +33 -0
  127. data/app/views/kaui/invoice_tags/_form_bar.html.erb +21 -0
  128. data/app/views/kaui/invoice_tags/edit.html.erb +10 -0
  129. data/app/views/kaui/invoices/_invoice_table.html.erb +29 -8
  130. data/app/views/kaui/invoices/index.html.erb +6 -4
  131. data/app/views/kaui/invoices/show.html.erb +10 -1
  132. data/app/views/kaui/layouts/kaui_flash.html.erb +32 -1
  133. data/app/views/kaui/layouts/kaui_header.html.erb +19 -2
  134. data/app/views/kaui/payment_methods/_payment_methods_details_table.html.erb +13 -4
  135. data/app/views/kaui/payments/_payment_table.html.erb +21 -11
  136. data/app/views/kaui/payments/index.html.erb +12 -10
  137. data/app/views/kaui/queues/index.html.erb +1 -1
  138. data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +1 -4
  139. data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
  140. data/app/views/kaui/subscriptions/_form.html.erb +1 -1
  141. data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +3 -3
  142. data/app/views/kaui/subscriptions/edit_bcd.erb +1 -1
  143. data/app/views/kaui/tag_definitions/index.html.erb +2 -2
  144. data/app/views/kaui/tags/index.html.erb +1 -0
  145. data/config/initializers/bootstrap_datepicker_rails.rb +3 -0
  146. data/config/initializers/devise.rb +8 -6
  147. data/config/initializers/js_routes.rb +9 -0
  148. data/config/initializers/kilbill_client_init.rb +13 -0
  149. data/config/initializers/killbill_authenticatable.rb +71 -21
  150. data/config/initializers/killbill_registerable.rb +5 -3
  151. data/config/initializers/time_formats.rb +6 -4
  152. data/config/locales/en.yml +78 -1
  153. data/config/routes.rb +40 -32
  154. data/db/migrate/20130812155313_devise_create_kaui_users.rb +10 -8
  155. data/db/migrate/20150109214021_create_kaui_tenants.rb +10 -8
  156. data/db/migrate/20150112232813_create_kaui_allowed_users.rb +10 -8
  157. data/lib/generators/kaui/install/install_generator.rb +23 -20
  158. data/lib/generators/kaui/install/templates/config/initializers/kaui.rb +3 -1
  159. data/lib/kaui/engine.rb +17 -5
  160. data/lib/kaui/installer/installer.rb +27 -26
  161. data/lib/kaui/version.rb +3 -1
  162. data/lib/kaui.rb +74 -30
  163. data/lib/tasks/kaui_tasks.rake +1 -0
  164. metadata +145 -440
  165. data/app/assets/javascripts/application.js +0 -17
  166. data/app/assets/javascripts/kaui/bootstrap-tweaks.js +0 -172
  167. data/app/assets/stylesheets/bootstrap_and_overrides.css.less +0 -44
  168. data/app/assets/stylesheets/kaui/kaui.less +0 -21
  169. data/app/assets/stylesheets/kaui/timeline.less +0 -4
  170. data/config/initializers/asset.rb +0 -1
  171. data/config/initializers/kilbill-client-init.rb +0 -9
  172. data/db/schema.rb +0 -15
  173. data/test/dummy/README.rdoc +0 -261
  174. data/test/dummy/Rakefile +0 -7
  175. data/test/dummy/app/controllers/application_controller.rb +0 -9
  176. data/test/dummy/app/helpers/application_helper.rb +0 -2
  177. data/test/dummy/bin/bundle +0 -3
  178. data/test/dummy/bin/rails +0 -4
  179. data/test/dummy/bin/rake +0 -4
  180. data/test/dummy/bin/setup +0 -38
  181. data/test/dummy/bin/update +0 -29
  182. data/test/dummy/bin/yarn +0 -11
  183. data/test/dummy/config/application.rb +0 -18
  184. data/test/dummy/config/boot.rb +0 -3
  185. data/test/dummy/config/database.yml +0 -27
  186. data/test/dummy/config/environment.rb +0 -5
  187. data/test/dummy/config/environments/development.rb +0 -58
  188. data/test/dummy/config/environments/production.rb +0 -91
  189. data/test/dummy/config/environments/test.rb +0 -49
  190. data/test/dummy/config/initializers/application_controller_renderer.rb +0 -6
  191. data/test/dummy/config/initializers/assets.rb +0 -14
  192. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  193. data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  194. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  195. data/test/dummy/config/initializers/inflections.rb +0 -16
  196. data/test/dummy/config/initializers/killbill_client.rb +0 -1
  197. data/test/dummy/config/initializers/mime_types.rb +0 -4
  198. data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +0 -14
  199. data/test/dummy/config/initializers/secret_token.rb +0 -7
  200. data/test/dummy/config/initializers/session_store.rb +0 -8
  201. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  202. data/test/dummy/config/locales/en.yml +0 -33
  203. data/test/dummy/config/routes.rb +0 -3
  204. data/test/dummy/config/secrets.yml +0 -32
  205. data/test/dummy/config/symmetric-encryption.yml +0 -135
  206. data/test/dummy/config.ru +0 -4
  207. data/test/dummy/db/schema.rb +0 -52
  208. data/test/dummy/public/404.html +0 -26
  209. data/test/dummy/public/422.html +0 -26
  210. data/test/dummy/public/500.html +0 -25
  211. data/test/dummy/public/favicon.ico +0 -0
  212. data/test/dummy/script/rails +0 -6
  213. data/test/fixtures/SpyCarAdvanced.xml +0 -824
  214. data/test/fixtures/catalog-v1.xml +0 -73
  215. data/test/fixtures/catalog_translation_fr-v1.properties +0 -1
  216. data/test/fixtures/invoice_template-v1.html +0 -100
  217. data/test/fixtures/invoice_translation_fr-v1.properties +0 -23
  218. data/test/fixtures/overdue-v1.xml +0 -49
  219. data/test/fixtures/stripe.yml +0 -2
  220. data/test/functional/kaui/account_children_controller_test.rb +0 -32
  221. data/test/functional/kaui/account_custom_fields_controller_test.rb +0 -29
  222. data/test/functional/kaui/account_emails_controller_test.rb +0 -55
  223. data/test/functional/kaui/account_tags_controller_test.rb +0 -48
  224. data/test/functional/kaui/account_timelines_controller_test.rb +0 -20
  225. data/test/functional/kaui/accounts_controller_test.rb +0 -297
  226. data/test/functional/kaui/admin_allowed_users_controller_test.rb +0 -234
  227. data/test/functional/kaui/admin_controller_test.rb +0 -45
  228. data/test/functional/kaui/admin_tenants_controller_test.rb +0 -352
  229. data/test/functional/kaui/audit_logs_controller_test.rb +0 -71
  230. data/test/functional/kaui/bundle_tags_controller_test.rb +0 -23
  231. data/test/functional/kaui/bundles_controller_test.rb +0 -130
  232. data/test/functional/kaui/chargebacks_controller_test.rb +0 -42
  233. data/test/functional/kaui/charges_controller_test.rb +0 -60
  234. data/test/functional/kaui/credits_controller_test.rb +0 -54
  235. data/test/functional/kaui/custom_fields_controller_test.rb +0 -52
  236. data/test/functional/kaui/functional_test_helper.rb +0 -13
  237. data/test/functional/kaui/functional_test_helper_nosetup.rb +0 -120
  238. data/test/functional/kaui/home_controller_test.rb +0 -407
  239. data/test/functional/kaui/invoice_items_controller_test.rb +0 -82
  240. data/test/functional/kaui/invoices_controller_test.rb +0 -88
  241. data/test/functional/kaui/login_proxy_controller_test.rb +0 -12
  242. data/test/functional/kaui/payment_methods_controller_test.rb +0 -52
  243. data/test/functional/kaui/payments_controller_test.rb +0 -59
  244. data/test/functional/kaui/queues_controller_test.rb +0 -17
  245. data/test/functional/kaui/refunds_controller_test.rb +0 -63
  246. data/test/functional/kaui/registrations_controller_test.rb +0 -49
  247. data/test/functional/kaui/role_definitions_controller_test.rb +0 -47
  248. data/test/functional/kaui/subscriptions_controller_test.rb +0 -194
  249. data/test/functional/kaui/tag_definitions_controller_test.rb +0 -29
  250. data/test/functional/kaui/tags_controller_test.rb +0 -21
  251. data/test/functional/kaui/tenants_controller_test.rb +0 -60
  252. data/test/functional/kaui/transactions_controller_test.rb +0 -90
  253. data/test/integration/kaui/date_helper_integration_test.rb +0 -16
  254. data/test/integration/kaui/integration_test_helper.rb +0 -32
  255. data/test/integration/kaui/navigation_test.rb +0 -43
  256. data/test/killbill_test_helper.rb +0 -217
  257. data/test/test_helper.rb +0 -22
  258. data/test/unit/helpers/kaui/admin_allowed_users_helper_test.rb +0 -6
  259. data/test/unit/helpers/kaui/admin_tenants_helper_test.rb +0 -6
  260. data/test/unit/helpers/kaui/payment_method_helper_test.rb +0 -17
  261. data/test/unit/helpers/kaui/tenants_helper_test.rb +0 -6
  262. data/test/unit/helpers/kaui/uuid_helper_test.rb +0 -16
  263. data/test/unit/kaui/account_email_test.rb +0 -19
  264. data/test/unit/kaui/account_test.rb +0 -14
  265. data/test/unit/kaui/admin_tenant_test.rb +0 -132
  266. data/test/unit/kaui/allowed_user_test.rb +0 -34
  267. data/test/unit/kaui/base_test.rb +0 -23
  268. data/test/unit/kaui/date_helper_test.rb +0 -26
  269. data/test/unit/kaui/invoice_item_test.rb +0 -11
  270. data/test/unit/kaui/invoice_payment_test.rb +0 -42
  271. data/test/unit/kaui/invoice_test.rb +0 -20
  272. data/test/unit/kaui/money_helper_test.rb +0 -16
  273. data/test/unit/kaui/payment_test.rb +0 -42
  274. data/test/unit/kaui/tag_definition_test.rb +0 -11
  275. data/test/unit/kaui/tenant_test.rb +0 -19
  276. /data/app/assets/stylesheets/{application.css → kaui_application.css} +0 -0
@@ -1,82 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::InvoiceItemsControllerTest < Kaui::FunctionalTestHelper
4
-
5
- test 'should handle errors in edit screen' do
6
- get :edit, :account_id => @account.account_id, :id => @invoice_item.invoice_item_id
7
- assert_redirected_to account_path(@account.account_id)
8
- assert_equal 'Required parameter missing: invoice_id', flash[:error]
9
-
10
- invoice_id = SecureRandom.uuid.to_s
11
- get :edit, :account_id => @account.account_id, :id => @invoice_item.invoice_item_id, :invoice_id => invoice_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=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
14
-
15
- invoice_item_id = SecureRandom.uuid.to_s
16
- get :edit, :account_id => @account.account_id, :id => invoice_item_id, :invoice_id => @invoice_item.invoice_id
17
- assert_redirected_to account_invoice_path(@account.account_id, @invoice_item.invoice_id)
18
- assert_equal "Unable to find invoice item #{invoice_item_id}", flash[:error]
19
- end
20
-
21
- test 'should get edit' do
22
- get :edit, :account_id => @account.account_id, :invoice_id => @invoice_item.invoice_id, :id => @invoice_item.invoice_item_id
23
- assert_response 200
24
- assert_equal @invoice_item.invoice_item_id, assigns(:invoice_item).invoice_item_id
25
- end
26
-
27
- test 'should handle errors during update' do
28
- invoice_id = SecureRandom.uuid.to_s
29
- put :update,
30
- :id => @invoice_item.invoice_item_id,
31
- :invoice_item => {
32
- :account_id => @account.account_id,
33
- :invoice_id => invoice_id,
34
- :invoice_item_id => @invoice_item.invoice_item_id,
35
- :amount => 5.34,
36
- :currency => :USD
37
- }
38
- assert_template :edit
39
- assert_equal "Error while adjusting invoice item: Error 404: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
40
- end
41
-
42
- test 'should adjust invoice item' do
43
- put :update,
44
- :id => @invoice_item.invoice_item_id,
45
- :invoice_item => {
46
- :account_id => @account.account_id,
47
- :invoice_id => @invoice_item.invoice_id,
48
- :invoice_item_id => @invoice_item.invoice_item_id,
49
- :amount => 5.34,
50
- :currency => :USD
51
- }
52
- assert_redirected_to account_invoice_path(@account.account_id, assigns(:invoice_item).invoice_id)
53
- assert_equal 'Adjustment item was successfully created', flash[:notice]
54
- end
55
-
56
- test 'should handle errors during destroy' do
57
- delete :destroy, :id => @cba.invoice_item_id
58
- assert_redirected_to home_path
59
- assert_equal 'Required parameter missing: invoice_id', flash[:error]
60
-
61
- delete :destroy, :id => @cba.invoice_item_id, :invoice_id => @cba.invoice_id
62
- assert_redirected_to home_path
63
- assert_equal 'Required parameter missing: account_id', flash[:error]
64
-
65
- invoice_id = SecureRandom.uuid.to_s
66
- delete :destroy,
67
- :id => @cba.invoice_item_id,
68
- :invoice_id => invoice_id,
69
- :account_id => @account.account_id
70
- assert_redirected_to account_path(@account.account_id)
71
- assert_equal "Error while communicating with the Kill Bill server: Error 404: No invoice could be found for id #{invoice_id}.", flash[:error]
72
- end
73
-
74
- test 'should delete CBA' do
75
- delete :destroy,
76
- :id => @cba.invoice_item_id,
77
- :invoice_id => @cba.invoice_id,
78
- :account_id => @account.account_id
79
- assert_redirected_to account_invoice_path(@account.account_id, @cba.invoice_id)
80
- assert_equal 'CBA item was successfully deleted', flash[:notice]
81
- end
82
- end
@@ -1,88 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::InvoicesControllerTest < Kaui::FunctionalTestHelper
4
-
5
- test 'should get index' do
6
- get :index, :account_id => @invoice_item.account_id
7
- assert_response 200
8
- end
9
-
10
- test 'should list invoices' do
11
- # Test pagination
12
- get :pagination, :format => :json
13
- verify_pagination_results!
14
- end
15
-
16
- test 'should search invoices' do
17
- # Test search
18
- get :pagination, :search => {:search => 'foo'}, :format => :json
19
- verify_pagination_results!
20
- end
21
-
22
- test 'should handle Kill Bill errors in show screen' do
23
- invoice_id = SecureRandom.uuid.to_s
24
- get :show, :account_id => @invoice_item.account_id, :id => invoice_id
25
- assert_redirected_to account_path(@invoice_item.account_id)
26
- assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
27
- end
28
-
29
- test 'should find unpaid invoice by id' do
30
- get :show, :account_id => @invoice_item.account_id, :id => @invoice_item.invoice_id
31
- assert_response 200
32
-
33
- assert_not_nil assigns(:account)
34
- assert_not_nil assigns(:invoice)
35
-
36
- assert_equal assigns(:account).account_id, @invoice_item.account_id
37
- assert_equal assigns(:invoice).invoice_id, @invoice_item.invoice_id
38
- end
39
-
40
- # Test bundles and subscriptions retrieval
41
- test 'should find invoice by id' do
42
- get :show, :account_id => @bundle_invoice.account_id, :id => @bundle_invoice.invoice_id
43
- assert_response 200
44
-
45
- assert_not_nil assigns(:account)
46
- assert_not_nil assigns(:invoice)
47
-
48
- assert_equal assigns(:account).account_id, @bundle_invoice.account_id
49
- assert_equal assigns(:invoice).invoice_id, @bundle_invoice.invoice_id
50
- end
51
-
52
- # Test the rendering of the partials
53
- test 'should find paid invoice by id' do
54
- get :show, :account_id => @paid_invoice_item.account_id, :id => @paid_invoice_item.invoice_id
55
- assert_response 200
56
-
57
- assert_not_nil assigns(:account)
58
- assert_not_nil assigns(:invoice)
59
-
60
- assert_equal assigns(:account).account_id, @paid_invoice_item.account_id
61
- assert_equal assigns(:invoice).invoice_id, @paid_invoice_item.invoice_id
62
- end
63
-
64
- test 'should handle Kill Bill errors in show_html screen' do
65
- invoice_id = SecureRandom.uuid.to_s
66
- get :show_html, :id => invoice_id
67
- assert_redirected_to home_path
68
- assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
69
- end
70
-
71
- test 'should expose restful endpoint' do
72
- get :restful_show, :id => @invoice_item.invoice_id
73
- assert_redirected_to account_invoice_path(@invoice_item.account_id, @invoice_item.invoice_id)
74
- end
75
-
76
- test 'should render HTML invoice' do
77
- get :show_html, :id => @invoice_item.invoice_id
78
- assert_response 200
79
- end
80
-
81
- test 'should commit invoice' do
82
- invoice_id = create_charge(@account, @tenant).invoice_id
83
-
84
- post :commit_invoice, :id => invoice_id
85
- assert_redirected_to account_invoice_path(@account.account_id, invoice_id)
86
- assert_equal 'Invoice successfully committed', flash[:notice]
87
- end
88
- end
@@ -1,12 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Kaui
4
- class LoginProxyControllerTest < Kaui::FunctionalTestHelper
5
-
6
- test 'should redirect to' do
7
- get :check_login, :path => home_path
8
- assert_redirected_to home_path
9
- end
10
-
11
- end
12
- end
@@ -1,52 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::PaymentMethodsControllerTest < Kaui::FunctionalTestHelper
4
-
5
- test 'should get new' do
6
- get :new, :account_id => @account2.account_id
7
- assert_response :success
8
- assert_equal get_value_from_input_field('payment_method_plugin_name'), '__EXTERNAL_PAYMENT__'
9
- assert_equal get_value_from_input_field('payment_method_account_id'), @account2.account_id
10
- end
11
-
12
- test 'should get show' do
13
- get :show, :id => @payment_method.payment_method_id
14
- assert_response :redirect
15
- assert_redirected_to account_path(@payment_method.account_id)
16
- end
17
-
18
- test 'should create payment methods' do
19
- post :create,
20
- :payment_method => {
21
- # Note that @account already has an external payment method
22
- :account_id => @account2.account_id,
23
- :is_default => true
24
- },
25
- :card_type => SecureRandom.uuid.to_s,
26
- :card_holder_name => SecureRandom.uuid.to_s,
27
- :expiration_year => 2020,
28
- :expiration_month => 12,
29
- :credit_card_number => 4111111111111111,
30
- :address1 => SecureRandom.uuid.to_s,
31
- :city => SecureRandom.uuid.to_s,
32
- :postal_code => SecureRandom.uuid.to_s,
33
- :state => SecureRandom.uuid.to_s,
34
- :country => SecureRandom.uuid.to_s
35
- assert_response 302
36
- end
37
-
38
- test 'should delete payment methods' do
39
- delete :destroy, :id => @payment_method.payment_method_id, :set_auto_pay_off => true
40
- assert_response 302
41
- end
42
-
43
- test 'should validate external key if found' do
44
- get :validate_external_key, :external_key => 'foo'
45
- assert_response :success
46
- assert_equal JSON[@response.body]['is_found'], false
47
-
48
- get :validate_external_key, :external_key => @payment_method.external_key
49
- assert_response :success
50
- assert_equal JSON[@response.body]['is_found'], true
51
- end
52
- end
@@ -1,59 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::PaymentsControllerTest < Kaui::FunctionalTestHelper
4
-
5
- test 'should get index' do
6
- get :index, :account_id => @invoice_item.account_id
7
- assert_response 200
8
- end
9
-
10
- test 'should list payments' do
11
- # Test pagination
12
- get :pagination, :format => :json
13
- verify_pagination_results!
14
- end
15
-
16
- test 'should search payments' do
17
- # Test search
18
- get :pagination, :search => {:value => 'PENDING'}, :format => :json
19
- verify_pagination_results!
20
- end
21
-
22
- test 'should create payments' do
23
- # Verify we can pre-populate the payment
24
- get :new, :account_id => @invoice_item.account_id, :invoice_id => @invoice_item.invoice_id
25
- assert_response 200
26
- assert_not_nil assigns(:payment)
27
-
28
- # Create the payment
29
- post :create, :account_id => @invoice_item.account_id, :invoice_payment => {:account_id => @invoice_item.account_id, :target_invoice_id => @invoice_item.invoice_id, :purchased_amount => 10}, :external => 1
30
- assert_response 302
31
-
32
- # Test pagination
33
- get :pagination, :format => :json
34
- verify_pagination_results!(1)
35
- end
36
-
37
- test 'should expose restful endpoint' do
38
- get :restful_show, :id => @payment.payment_id
39
- assert_redirected_to account_payment_path(@payment.account_id, @payment.payment_id)
40
-
41
- # Search by external_key
42
- get :restful_show, :id => @payment.payment_external_key
43
- assert_redirected_to account_payment_path(@payment.account_id, @payment.payment_id)
44
- end
45
-
46
- test 'should cancel scheduled payment' do
47
- delete :cancel_scheduled_payment, :id => @payment.payment_id, :account_id => @payment.account_id
48
- assert_match(/Error deleting payment attempt retry:/, flash[:error])
49
- expected_response_path = "/accounts/#{@payment.account_id}"
50
- assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}"
51
-
52
- delete :cancel_scheduled_payment, :id => @payment.payment_id, :account_id => @payment.account_id,
53
- :transaction_external_key => @payment.transactions[0].transaction_external_key
54
- assert_equal 'Payment attempt retry successfully deleted', flash[:notice]
55
- expected_response_path = "/accounts/#{@payment.account_id}/payments/#{@payment.payment_id}"
56
- assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}"
57
-
58
- end
59
- end
@@ -1,17 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::QueuesControllerTest < Kaui::FunctionalTestHelper
4
-
5
- test 'should get queues' do
6
- get :index, :account_id => @account.account_id, :with_history => true
7
- now = assigns(:now)
8
- queues_entries = assigns(:queues_entries)
9
-
10
- assert_not_nil now
11
- assert_not_nil queues_entries
12
- assert queues_entries['busEvents'].size > 0
13
-
14
- assert_response :success
15
- end
16
-
17
- end
@@ -1,63 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::RefundsControllerTest < 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, :payment_id => @payment.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=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
10
-
11
- payment_id = SecureRandom.uuid.to_s
12
- get :new, :account_id => @account.account_id, :invoice_id => @paid_invoice_item.invoice_id, :payment_id => payment_id
13
- assert_redirected_to account_path(@account.account_id)
14
- assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{payment_id} type=PAYMENT doesn't exist!", flash[:error]
15
- end
16
-
17
- test 'should get new' do
18
- get :new, :account_id => @account.account_id, :invoice_id => @paid_invoice_item.invoice_id, :payment_id => @payment.payment_id
19
- assert_response 200
20
- assert_not_nil assigns(:invoice)
21
- assert_not_nil assigns(:payment)
22
- assert_not_nil assigns(:refund)
23
- end
24
-
25
- test 'should create refund without adjustment' do
26
- refund_amount = @payment.purchased_amount.to_f / 3.0
27
-
28
- post :create,
29
- :account_id => @account.account_id,
30
- :invoice_id => @paid_invoice_item.invoice_id,
31
- :payment_id => @payment.payment_id,
32
- :amount => refund_amount,
33
- :adjustment_type => 'noInvoiceAdjustment'
34
- assert_redirected_to account_invoice_path(@account.account_id, @paid_invoice_item.invoice_id)
35
- end
36
-
37
- test 'should create refund with invoice adjustment' do
38
- refund_amount = @payment.purchased_amount.to_f / 3.0
39
-
40
- post :create,
41
- :account_id => @account.account_id,
42
- :invoice_id => @paid_invoice_item.invoice_id,
43
- :payment_id => @payment.payment_id,
44
- :amount => refund_amount,
45
- :adjustment_type => 'invoiceAdjustment'
46
- assert_redirected_to account_invoice_path(@account.account_id, @paid_invoice_item.invoice_id)
47
- end
48
-
49
- test 'should create refund with invoice item adjustment' do
50
- refund_amount = @payment.purchased_amount.to_f / 3.0
51
-
52
- post :create,
53
- :account_id => @account.account_id,
54
- :invoice_id => @paid_invoice_item.invoice_id,
55
- :payment_id => @payment.payment_id,
56
- :amount => refund_amount,
57
- :adjustment_type => 'invoiceItemAdjustment',
58
- :adjustments => {
59
- @paid_invoice_item.invoice_item_id => refund_amount
60
- }
61
- assert_redirected_to account_invoice_path(@account.account_id, @paid_invoice_item.invoice_id)
62
- end
63
- end
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Kaui
4
- class RegistrationsControllerTest < Kaui::FunctionalTestHelper
5
-
6
- test 'should get new' do
7
- logout
8
-
9
- get :new
10
- assert_response :success
11
- assert has_input_field('user_kb_username'), 'Expected input with id user_kb_username not found'
12
- assert has_input_field('user_password'), 'Expected input with id user_password not found'
13
- end
14
-
15
- test 'should get create' do
16
- logout
17
-
18
- # enable the option of registration
19
- Kaui.disable_sign_up_link = false
20
-
21
- parameters = {
22
- :user => {
23
- :kb_username => 'Voltron',
24
- :password => 'Voltron'
25
- }
26
- }
27
- post :create, parameters
28
- assert_equal "User #{parameters[:user][:kb_username]} successfully created, please login", flash[:notice]
29
- assert_response :redirect
30
- # validate redirect path
31
- assert response_path.include?('/users/sign_in'), "#{response_path} is expected to contain /users/sign_in"
32
-
33
- # should return an error that the user already exists
34
- post :create, parameters
35
- assert_equal "User with name #{parameters[:user][:kb_username]} already exists!", flash[:error]
36
- assert_response :success
37
-
38
- # disable the option of registration
39
- Kaui.disable_sign_up_link = true
40
-
41
- post :create, parameters
42
- assert_equal 'You need to sign in before adding a user!', flash[:error]
43
- assert_response :redirect
44
- # validate redirect path
45
- assert response_path.include?('/users/sign_in'), "#{response_path} is expected to contain /users/sign_in"
46
- end
47
-
48
- end
49
- end
@@ -1,47 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::RoleDefinitionsControllerTest < Kaui::FunctionalTestHelper
4
-
5
- test 'should instantiate RoleDefinition class' do
6
- get :new
7
- role_definition = assigns(:role_definition)
8
-
9
- assert_not_nil role_definition
10
- assert_instance_of Kaui::RoleDefinition, role_definition
11
- assert_response :success
12
- end
13
-
14
- test 'should return an error if no parameter role definition is passed' do
15
- post :create
16
-
17
- role_definition = assigns(:role_definition)
18
-
19
- assert_nil role_definition
20
- assert_equal 'Required parameter missing: role_definition', flash[:error]
21
- assert_response :redirect
22
- end
23
-
24
- test 'should create a new role definition' do
25
- role_definition = Hash.new
26
-
27
- role_definition['role'] = 'test' + SecureRandom.base64(9).gsub(/[\/+=]/,'')
28
- role_definition['permissions'] = 'account:delete_emails,account:add_emails'
29
-
30
- post :create, :role_definition => role_definition
31
-
32
- assert_equal 'Role was successfully created', flash[:notice]
33
- assert_response :redirect
34
- end
35
-
36
- test 'should return an error if there is a error while creating role' do
37
- role_definition = Hash.new
38
-
39
- role_definition['role'] = 'test' + SecureRandom.base64(9).gsub(/[\/+=]/,'')
40
- role_definition['permissions'] = 'account:delete_emails,account:add_emails'
41
-
42
- post :create, :role_definition => role_definition, :reason => SecureRandom.base64(4000), :comment => SecureRandom.base64(4000)
43
- assert_match 'Error while creating role', flash[:error]
44
- assert_response :success
45
- end
46
-
47
- end
@@ -1,194 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::SubscriptionsControllerTest < Kaui::FunctionalTestHelper
4
-
5
- test 'should handle Kill Bill errors in new screen' do
6
- bundle_id = SecureRandom.uuid.to_s
7
- get :new, :bundle_id => bundle_id, :account_id => @account.account_id, :product_category => 'ADD_ON'
8
- assert_redirected_to account_path(@account.account_id)
9
- assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{bundle_id} type=BUNDLE doesn't exist!", flash[:error]
10
- end
11
-
12
- test 'should get new page for base plan' do
13
- get :new,
14
- :account_id => @account.account_id,
15
- :product_category => 'BASE'
16
- assert assigns(:plans).size > 0
17
- end
18
-
19
- test 'should get new page for base addon' do
20
- get :new,
21
- :base_product_name => 'Sports',
22
- :bundle_id => @bundle.bundle_id,
23
- :account_id => @account.account_id,
24
- :product_category => 'ADD_ON'
25
- assert assigns(:plans).size > 0, 'Plans were not created'
26
- end
27
-
28
- test 'should handle errors during creation' do
29
- post :create,
30
- :subscription => {
31
- :bundle_id => @bundle.bundle_id,
32
- :account_id => @account.account_id,
33
- :product_category => 'ADD_ON'
34
- },
35
- :base_product_name => 'Sports'
36
- assert_redirected_to account_path(@account.account_id)
37
- assert_equal 'Required parameter missing: plan_name', flash[:error]
38
-
39
- post :create,
40
- :subscription => {
41
- :bundle_id => @bundle.bundle_id,
42
- :account_id => @account.account_id,
43
- :product_category => 'ADD_ON'
44
- },
45
- :base_product_name => 'Sports',
46
- :plan_name => 'not-exists'
47
- assert_template :new
48
- assert_equal 'Error while creating the subscription: Unable to find plan not-exists', flash[:error]
49
- end
50
-
51
- test 'should create a new base subscription' do
52
- post :create,
53
- :subscription => {
54
- :account_id => @account.account_id,
55
- :external_key => SecureRandom.uuid,
56
- },
57
- :plan_name => 'standard-monthly'
58
- assert_response 302
59
- end
60
-
61
- test 'should create a new addon subscription' do
62
- post :create,
63
- :subscription => {
64
- :bundle_id => @bundle.bundle_id,
65
- :account_id => @account.account_id,
66
- :product_category => 'ADD_ON'
67
- },
68
- :base_product_name => 'Sports',
69
- :plan_name => 'oilslick-monthly'
70
- assert_includes((200..399), response.code.to_i)
71
- end
72
-
73
- test 'should handle Kill Bill errors in edit screen' do
74
- subscription_id = SecureRandom.uuid.to_s
75
- get :edit, :id => subscription_id
76
- assert_redirected_to home_path
77
- assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{subscription_id} type=SUBSCRIPTION doesn't exist!", flash[:error]
78
- end
79
-
80
- test 'should get edit page' do
81
- get :edit, :id => @bundle.subscriptions.first.subscription_id
82
- assert_response 200
83
- assert_not_nil assigns(:subscription)
84
- assert_not_nil assigns(:plans)
85
- end
86
-
87
- test 'should handle errors during update' do
88
- post :update, :id => @bundle.subscriptions.first.subscription_id
89
- assert_redirected_to edit_subscription_path(@bundle.subscriptions.first.subscription_id)
90
- assert_equal 'Error while changing subscription: param is missing or the value is empty: plan_name', flash[:error]
91
-
92
- subscription_id = SecureRandom.uuid.to_s
93
- post :update, :id => subscription_id, :plan_name => 'super-monthly'
94
- assert_redirected_to edit_subscription_path(subscription_id)
95
- assert_equal "Error while changing subscription: Error 404: Object id=#{subscription_id} type=SUBSCRIPTION doesn't exist!", flash[:error]
96
-
97
- post :update, :id => @bundle.subscriptions.first.subscription_id, :plan_name => 'not-exists'
98
- assert_redirected_to edit_subscription_path(@bundle.subscriptions.first.subscription_id)
99
- assert_equal "Error while changing subscription: Error 400: Could not find any plans named 'not-exists'", flash[:error]
100
- end
101
-
102
- test 'should update' do
103
- post :update,
104
- :id => @bundle.subscriptions.first.subscription_id,
105
- :plan_name => 'super-monthly'
106
- assert_response 302
107
- end
108
-
109
- test 'should handle errors during destroy' do
110
- subscription_id = SecureRandom.uuid.to_s
111
- delete :destroy, :id => subscription_id, :plan_name => 'super-monthly'
112
- assert_redirected_to home_path
113
- assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{subscription_id} type=SUBSCRIPTION doesn't exist!", flash[:error]
114
- end
115
-
116
- test 'should handle errors during reinstate' do
117
- subscription_id = SecureRandom.uuid.to_s
118
- put :reinstate, :id => subscription_id
119
- assert_redirected_to home_path
120
- assert_equal "Error while communicating with the Kill Bill server: Error 404: Object id=#{subscription_id} type=SUBSCRIPTION doesn't exist!", flash[:error]
121
- end
122
-
123
- test 'should cancel and reinstate subscription' do
124
- delete :destroy,
125
- :id => @bundle.subscriptions.first.subscription_id,
126
- :requested_date => (Date.today >> 1).to_time.utc.iso8601,
127
- :use_requested_date_for_billing => '1'
128
- assert_response 302
129
-
130
- put :reinstate, :id => @bundle.subscriptions.first.subscription_id
131
- assert_response 302
132
- end
133
-
134
- test 'should get show' do
135
- get :show, :id => @bundle.subscriptions.first.subscription_id
136
- assert_redirected_to account_bundles_path(@bundle.subscriptions.first.account_id)
137
- end
138
-
139
- test 'should get edit bcd' do
140
- get :edit_bcd, :id => @bundle.subscriptions.first.subscription_id
141
- assert_response :success
142
- assert_equal get_value_from_input_field('subscription_account_id'), @bundle.subscriptions.first.account_id
143
- assert_equal get_value_from_input_field('subscription_bill_cycle_day_local'), @bundle.subscriptions.first.bill_cycle_day_local.to_s
144
- assert_equal get_value_from_input_field('effective_from_date'), Date.parse(Time.now.to_s).to_s
145
- end
146
-
147
- test 'should update bcd' do
148
- bundle = create_bundle(@account, @tenant)
149
- parameters = {
150
- :id => bundle.subscriptions.first.subscription_id,
151
- :subscription => { :account_id => bundle.subscriptions.first.account_id,
152
- :bill_cycle_day_local => bundle.subscriptions.first.bill_cycle_day_local
153
- },
154
- :effective_from_date => (Date.today >> 1).to_s
155
- }
156
-
157
- put :update_bcd, parameters
158
- assert_redirected_to account_bundles_path(bundle.subscriptions.first.account_id)
159
- assert_equal 'Subscription BCD was successfully changed', flash[:notice]
160
- end
161
-
162
- test 'should validate external key if found' do
163
- get :validate_external_key, :external_key => 'foo'
164
- assert_response :success
165
- assert_equal JSON[@response.body]['is_found'], false
166
-
167
- get :validate_external_key, :external_key => @bundle.subscriptions.first.external_key
168
- assert_response :success
169
- assert_equal JSON[@response.body]['is_found'], true
170
- end
171
-
172
- test 'should update with price override' do
173
- post :update,
174
- :id => @bundle.subscriptions.first.subscription_id,
175
- :plan_name => 'super-monthly',
176
- :price_override => 500
177
- assert_redirected_to account_bundles_path(@bundle.subscriptions.first.account_id)
178
- assert_equal 'Subscription plan successfully changed', flash[:notice]
179
- end
180
-
181
- test 'should create with price override' do
182
- post :create,
183
- :subscription => {
184
- :account_id => @account.account_id,
185
- :external_key => SecureRandom.uuid,
186
- },
187
- :price_override => 500,
188
- :plan_name => 'standard-monthly'
189
-
190
- assert_redirected_to account_bundles_path(@account.account_id)
191
- assert_equal 'Subscription was successfully created', flash[:notice]
192
- end
193
-
194
- end