kaui 2.1.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +8 -7
  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} +4 -0
  11. data/app/assets/stylesheets/kaui/{audit.less → audit.scss} +5 -1
  12. data/app/assets/stylesheets/kaui/{common.less → common.scss} +17 -15
  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 +268 -250
  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 +86 -83
  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 +130 -117
  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 +24 -20
  46. data/app/controllers/kaui/invoices_controller.rb +132 -117
  47. data/app/controllers/kaui/login_proxy_controller.rb +2 -1
  48. data/app/controllers/kaui/payment_methods_controller.rb +102 -94
  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 +16 -14
  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 +7 -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 +1 -1
  111. data/app/views/kaui/accounts/_form.html.erb +2 -2
  112. data/app/views/kaui/accounts/index.html.erb +2 -0
  113. data/app/views/kaui/admin_allowed_users/_form.html.erb +3 -3
  114. data/app/views/kaui/admin_tenants/_form_catalog_translation.erb +1 -1
  115. data/app/views/kaui/admin_tenants/_form_invoice_template.erb +1 -1
  116. data/app/views/kaui/admin_tenants/_form_invoice_translation.erb +1 -1
  117. data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +11 -5
  118. data/app/views/kaui/admin_tenants/new_catalog.html.erb +2 -2
  119. data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +2 -2
  120. data/app/views/kaui/admin_tenants/new_plan_currency.html.erb +1 -1
  121. data/app/views/kaui/bundles/index.html.erb +1 -1
  122. data/app/views/kaui/bundles/transfer.html.erb +13 -5
  123. data/app/views/kaui/invoices/_invoice_table.html.erb +1 -1
  124. data/app/views/kaui/layouts/kaui_flash.html.erb +24 -0
  125. data/app/views/kaui/layouts/kaui_header.html.erb +19 -2
  126. data/app/views/kaui/payment_methods/_payment_methods_details_table.html.erb +13 -4
  127. data/app/views/kaui/payments/_payment_table.html.erb +21 -11
  128. data/app/views/kaui/payments/index.html.erb +9 -9
  129. data/app/views/kaui/queues/index.html.erb +1 -1
  130. data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +1 -4
  131. data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
  132. data/app/views/kaui/subscriptions/_form.html.erb +1 -1
  133. data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +3 -3
  134. data/app/views/kaui/subscriptions/edit_bcd.erb +1 -1
  135. data/app/views/kaui/tag_definitions/index.html.erb +2 -2
  136. data/app/views/kaui/tags/index.html.erb +1 -0
  137. data/config/initializers/bootstrap_datepicker_rails.rb +3 -0
  138. data/config/initializers/devise.rb +8 -6
  139. data/config/initializers/js_routes.rb +9 -0
  140. data/config/initializers/kilbill_client_init.rb +13 -0
  141. data/config/initializers/killbill_authenticatable.rb +71 -21
  142. data/config/initializers/killbill_registerable.rb +5 -3
  143. data/config/initializers/time_formats.rb +6 -4
  144. data/config/locales/en.yml +78 -1
  145. data/config/routes.rb +34 -32
  146. data/db/migrate/20130812155313_devise_create_kaui_users.rb +10 -8
  147. data/db/migrate/20150109214021_create_kaui_tenants.rb +10 -8
  148. data/db/migrate/20150112232813_create_kaui_allowed_users.rb +10 -8
  149. data/lib/generators/kaui/install/install_generator.rb +23 -20
  150. data/lib/generators/kaui/install/templates/config/initializers/kaui.rb +3 -1
  151. data/lib/kaui/engine.rb +17 -5
  152. data/lib/kaui/installer/installer.rb +27 -26
  153. data/lib/kaui/version.rb +3 -1
  154. data/lib/kaui.rb +26 -37
  155. data/lib/tasks/kaui_tasks.rake +1 -0
  156. metadata +140 -442
  157. data/app/assets/javascripts/application.js +0 -17
  158. data/app/assets/javascripts/kaui/bootstrap-tweaks.js +0 -172
  159. data/app/assets/stylesheets/bootstrap_and_overrides.css.less +0 -44
  160. data/app/assets/stylesheets/kaui/kaui.less +0 -21
  161. data/app/assets/stylesheets/kaui/timeline.less +0 -4
  162. data/config/initializers/asset.rb +0 -1
  163. data/config/initializers/kilbill-client-init.rb +0 -9
  164. data/db/schema.rb +0 -15
  165. data/test/dummy/README.rdoc +0 -261
  166. data/test/dummy/Rakefile +0 -7
  167. data/test/dummy/app/controllers/application_controller.rb +0 -9
  168. data/test/dummy/app/helpers/application_helper.rb +0 -2
  169. data/test/dummy/bin/bundle +0 -3
  170. data/test/dummy/bin/rails +0 -4
  171. data/test/dummy/bin/rake +0 -4
  172. data/test/dummy/bin/setup +0 -38
  173. data/test/dummy/bin/update +0 -29
  174. data/test/dummy/bin/yarn +0 -11
  175. data/test/dummy/config/application.rb +0 -18
  176. data/test/dummy/config/boot.rb +0 -3
  177. data/test/dummy/config/database.yml +0 -27
  178. data/test/dummy/config/environment.rb +0 -5
  179. data/test/dummy/config/environments/development.rb +0 -58
  180. data/test/dummy/config/environments/production.rb +0 -91
  181. data/test/dummy/config/environments/test.rb +0 -49
  182. data/test/dummy/config/initializers/application_controller_renderer.rb +0 -6
  183. data/test/dummy/config/initializers/assets.rb +0 -14
  184. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  185. data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  186. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  187. data/test/dummy/config/initializers/inflections.rb +0 -16
  188. data/test/dummy/config/initializers/killbill_client.rb +0 -1
  189. data/test/dummy/config/initializers/mime_types.rb +0 -4
  190. data/test/dummy/config/initializers/money.rb +0 -2
  191. data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +0 -14
  192. data/test/dummy/config/initializers/secret_token.rb +0 -7
  193. data/test/dummy/config/initializers/session_store.rb +0 -8
  194. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  195. data/test/dummy/config/locales/en.yml +0 -33
  196. data/test/dummy/config/routes.rb +0 -3
  197. data/test/dummy/config/secrets.yml +0 -32
  198. data/test/dummy/config/symmetric-encryption.yml +0 -135
  199. data/test/dummy/config.ru +0 -4
  200. data/test/dummy/db/schema.rb +0 -52
  201. data/test/dummy/public/404.html +0 -26
  202. data/test/dummy/public/422.html +0 -26
  203. data/test/dummy/public/500.html +0 -25
  204. data/test/dummy/public/favicon.ico +0 -0
  205. data/test/dummy/script/rails +0 -6
  206. data/test/fixtures/SpyCarAdvanced.xml +0 -824
  207. data/test/fixtures/catalog-v1.xml +0 -73
  208. data/test/fixtures/catalog_translation_fr-v1.properties +0 -1
  209. data/test/fixtures/invoice_template-v1.html +0 -100
  210. data/test/fixtures/invoice_translation_fr-v1.properties +0 -23
  211. data/test/fixtures/overdue-v1.xml +0 -49
  212. data/test/fixtures/stripe.yml +0 -2
  213. data/test/functional/kaui/account_children_controller_test.rb +0 -32
  214. data/test/functional/kaui/account_custom_fields_controller_test.rb +0 -29
  215. data/test/functional/kaui/account_emails_controller_test.rb +0 -55
  216. data/test/functional/kaui/account_tags_controller_test.rb +0 -48
  217. data/test/functional/kaui/account_timelines_controller_test.rb +0 -20
  218. data/test/functional/kaui/accounts_controller_test.rb +0 -297
  219. data/test/functional/kaui/admin_allowed_users_controller_test.rb +0 -234
  220. data/test/functional/kaui/admin_controller_test.rb +0 -45
  221. data/test/functional/kaui/admin_tenants_controller_test.rb +0 -352
  222. data/test/functional/kaui/audit_logs_controller_test.rb +0 -71
  223. data/test/functional/kaui/bundle_tags_controller_test.rb +0 -23
  224. data/test/functional/kaui/bundles_controller_test.rb +0 -130
  225. data/test/functional/kaui/chargebacks_controller_test.rb +0 -42
  226. data/test/functional/kaui/charges_controller_test.rb +0 -60
  227. data/test/functional/kaui/credits_controller_test.rb +0 -54
  228. data/test/functional/kaui/custom_fields_controller_test.rb +0 -52
  229. data/test/functional/kaui/functional_test_helper.rb +0 -13
  230. data/test/functional/kaui/functional_test_helper_nosetup.rb +0 -120
  231. data/test/functional/kaui/home_controller_test.rb +0 -407
  232. data/test/functional/kaui/invoice_items_controller_test.rb +0 -82
  233. data/test/functional/kaui/invoices_controller_test.rb +0 -88
  234. data/test/functional/kaui/login_proxy_controller_test.rb +0 -12
  235. data/test/functional/kaui/payment_methods_controller_test.rb +0 -52
  236. data/test/functional/kaui/payments_controller_test.rb +0 -59
  237. data/test/functional/kaui/queues_controller_test.rb +0 -17
  238. data/test/functional/kaui/refunds_controller_test.rb +0 -63
  239. data/test/functional/kaui/registrations_controller_test.rb +0 -49
  240. data/test/functional/kaui/role_definitions_controller_test.rb +0 -47
  241. data/test/functional/kaui/subscriptions_controller_test.rb +0 -194
  242. data/test/functional/kaui/tag_definitions_controller_test.rb +0 -29
  243. data/test/functional/kaui/tags_controller_test.rb +0 -21
  244. data/test/functional/kaui/tenants_controller_test.rb +0 -60
  245. data/test/functional/kaui/transactions_controller_test.rb +0 -90
  246. data/test/integration/kaui/date_helper_integration_test.rb +0 -16
  247. data/test/integration/kaui/integration_test_helper.rb +0 -32
  248. data/test/integration/kaui/navigation_test.rb +0 -43
  249. data/test/killbill_test_helper.rb +0 -219
  250. data/test/test_helper.rb +0 -22
  251. data/test/unit/helpers/kaui/admin_allowed_users_helper_test.rb +0 -6
  252. data/test/unit/helpers/kaui/admin_tenants_helper_test.rb +0 -6
  253. data/test/unit/helpers/kaui/payment_method_helper_test.rb +0 -17
  254. data/test/unit/helpers/kaui/tenants_helper_test.rb +0 -6
  255. data/test/unit/helpers/kaui/uuid_helper_test.rb +0 -16
  256. data/test/unit/kaui/account_email_test.rb +0 -19
  257. data/test/unit/kaui/account_test.rb +0 -14
  258. data/test/unit/kaui/admin_tenant_test.rb +0 -132
  259. data/test/unit/kaui/allowed_user_test.rb +0 -34
  260. data/test/unit/kaui/base_test.rb +0 -23
  261. data/test/unit/kaui/date_helper_test.rb +0 -26
  262. data/test/unit/kaui/invoice_item_test.rb +0 -11
  263. data/test/unit/kaui/invoice_payment_test.rb +0 -42
  264. data/test/unit/kaui/invoice_test.rb +0 -20
  265. data/test/unit/kaui/money_helper_test.rb +0 -16
  266. data/test/unit/kaui/payment_test.rb +0 -42
  267. data/test/unit/kaui/tag_definition_test.rb +0 -11
  268. data/test/unit/kaui/tenant_test.rb +0 -19
  269. /data/app/assets/stylesheets/{application.css → kaui_application.css} +0 -0
@@ -1,29 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::TagDefinitionsControllerTest < Kaui::FunctionalTestHelper
4
-
5
- test 'should list tag definitions' do
6
- get :index
7
- assert_response 200
8
- end
9
-
10
- test 'should add and destroy tag definition' do
11
- get :new
12
- assert_response 200
13
- assert_not_nil assigns(:tag_definition)
14
-
15
- tag_definition = SecureRandom.uuid[0..5]
16
- post :create,
17
- :tag_definition => {
18
- :name => tag_definition,
19
- :description => SecureRandom.uuid,
20
- :applicable_object_types => {"0" => "ACCOUNT"}
21
- }
22
- assert_redirected_to tag_definitions_path
23
- assert_equal 'Tag definition successfully created', flash[:notice]
24
-
25
- delete :destroy, :id => assigns(:tag_definition).id
26
- assert_redirected_to tag_definitions_path
27
- assert_equal 'Tag definition successfully deleted', flash[:notice]
28
- end
29
- end
@@ -1,21 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::TagsControllerTest < Kaui::FunctionalTestHelper
4
-
5
- test 'should get index' do
6
- get :index
7
- assert_response 200
8
- end
9
-
10
- test 'should list tags' do
11
- # Test pagination
12
- get :pagination, :format => :json
13
- verify_pagination_results!
14
- end
15
-
16
- test 'should search tags' do
17
- # Test search
18
- get :pagination, :search => {:search => 'foo'}, :format => :json
19
- verify_pagination_results!
20
- end
21
- end
@@ -1,60 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::TenantsControllerTest < Kaui::FunctionalTestHelperNoSetup
4
-
5
- setup do
6
- # Do nothing and let the test initialize with correct # tenants
7
- end
8
-
9
- teardown do
10
- # Do nothing and let the test initialize with correct # tenants
11
- end
12
-
13
- #
14
- # We don't configure the tenants in 'kaui_tenants' and don't set KillBillClient.api_key
15
- #
16
- test 'should get index with 0 tenant with NO KillBillClient.api_key set' do
17
- setup_functional_test(0, false)
18
- get :index, :use_route => 'kaui'
19
- # Sign-up flow
20
- assert_redirected_to new_admin_tenant_path
21
- end
22
-
23
- #
24
- # We don't configure the tenants in 'kaui_tenants' but we set KillBillClient.api_key (default use case for non multi-tenant UI)
25
- #
26
- test 'should get index with 0 tenant with KillBillClient.api_key set' do
27
- setup_functional_test(0)
28
- get :index, :use_route => 'kaui'
29
- assert_response 302
30
- assert_redirected_to Kaui::IntegrationTestHelper::HOME_PATH
31
- assert_equal 'Signed in successfully.', flash[:notice]
32
- end
33
-
34
- #
35
- # We configure 1 tenant in 'kaui_tenants' (the one we created with Kill Bill) and verify we skip the tenant screen
36
- #
37
- test 'should get index with 1 tenant' do
38
- setup_functional_test(1)
39
- get :index, :use_route => 'kaui'
40
- assert_includes (200..399), response.code.to_i
41
- assert_equal 'Signed in successfully.', flash[:notice]
42
- end
43
-
44
- #
45
- # We configure 2 tenants in 'kaui_tenants' (the one we created with Kill Bill and another one) and verify we land on the view for the
46
- # user to chose his tenant.
47
- #
48
- test 'should get index with 2 tenant' do
49
- setup_functional_test(2)
50
- get :index, :use_route => 'kaui'
51
- assert_response :success
52
- assert_equal 'Signed in successfully.', flash[:notice]
53
- end
54
-
55
- test 'should select a tenant' do
56
- setup_functional_test
57
- post :select_tenant, :kb_tenant_id => session[:kb_tenant_id]
58
- assert_redirected_to Kaui::IntegrationTestHelper::HOME_PATH
59
- end
60
- end
@@ -1,90 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::TransactionsControllerTest < Kaui::FunctionalTestHelper
4
-
5
- test 'should get restful endpoint' do
6
- get :restful_show, :id => @payment.transactions[0].transaction_id
7
- assert_response :redirect
8
- expected_response_path = "/accounts/#{@payment.account_id}/payments/#{@payment.payment_id}"
9
- assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}"
10
- end
11
-
12
- test 'should get new' do
13
- get :new,
14
- :account_id => @account.account_id,
15
- :payment_method_id => @payment_method.payment_method_id,
16
- :payment_id => @payment.payment_id,
17
- :amount => 12,
18
- :currency => 'USD',
19
- :transaction_type => 'CAPTURE'
20
- assert_response 200
21
- assert_equal get_value_from_input_field('account_id'), @account.account_id
22
- assert_equal get_value_from_input_field('payment_method_id'), @payment_method.payment_method_id
23
- assert has_input_field('transaction_transaction_id')
24
-
25
-
26
- get :new, :account_id => @account.account_id,
27
- :payment_method_id => @payment_method.payment_method_id, :transaction_id => @payment.transactions[0].transaction_id
28
- assert_response :success
29
- assert_equal get_value_from_input_field('account_id'), @account.account_id
30
- assert_equal get_value_from_input_field('payment_method_id'), @payment_method.payment_method_id
31
- assert_equal get_value_from_input_field('transaction_transaction_id'), @payment.transactions[0].transaction_id
32
- assert_equal get_value_from_input_field('transaction_payment_id'), @payment.payment_id
33
- end
34
-
35
- test 'should create new transaction' do
36
- payments = []
37
- %w(AUTHORIZE AUTHORIZE PURCHASE PURCHASE CREDIT).each do |transaction_type|
38
- post :create,
39
- :account_id => @account.account_id,
40
- :payment_method_id => @payment_method.payment_method_id,
41
- :transaction => {
42
- :payment_external_key => SecureRandom.uuid,
43
- :amount => 12,
44
- :currency => 'USD',
45
- :transaction_type => transaction_type
46
- }
47
-
48
- payments << created_payment_id
49
- assert_redirected_to account_payment_path(@account.account_id, payments[-1])
50
- assert_equal 'Transaction successfully created', flash[:notice]
51
- end
52
-
53
- %w(CAPTURE VOID REFUND CHARGEBACK).each do |transaction_type|
54
- payment_id = payments.shift
55
- post :create,
56
- :account_id => @account.account_id,
57
- :transaction => {
58
- :payment_id => payment_id,
59
- :amount => 12,
60
- :currency => 'USD',
61
- :transaction_type => transaction_type
62
- }
63
- assert_redirected_to account_payment_path(@account.account_id, payment_id)
64
- assert_equal 'Transaction successfully created', flash[:notice]
65
- end
66
- end
67
-
68
- test 'should fix transaction state' do
69
- payment = create_payment(nil,nil,@tenant)
70
- parameters = {
71
- :account_id => payment.account_id,
72
- :transaction => {
73
- :payment_id => payment.payment_id,
74
- :transaction_id => payment.transactions[0].transaction_id,
75
- :status => 'PENDING'
76
- }
77
- }
78
-
79
- put :fix_transaction_state, parameters
80
- assert_response :redirect
81
- assert_redirected_to account_payment_path(payment.account_id,payment.payment_id)
82
- assert_equal "Transaction successfully transitioned to #{parameters[:transaction][:status]}", flash[:notice]
83
- end
84
-
85
- private
86
-
87
- def created_payment_id
88
- response.header['Location'].split('/')[-1]
89
- end
90
- end
@@ -1,16 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Kaui
4
- class DateHelperIntegrationTest < IntegrationTestHelper
5
-
6
- include Kaui::DateHelper
7
-
8
- test 'can get killbill server current time depending of time zone' do
9
- current_time_fiji = current_time('America/Puerto_Rico',options)
10
- utc_offset_fiji = '-0400'
11
-
12
- assert_equal utc_offset_fiji, current_time_fiji.strftime('%z')
13
- end
14
-
15
- end
16
- end
@@ -1,32 +0,0 @@
1
- module Kaui
2
- class IntegrationTestHelper < ActionDispatch::IntegrationTest
3
-
4
- BASE_PATH = '/kaui'
5
- TENANTS_PATH = '/kaui/tenants'
6
- HOME_PATH = '/kaui/home'
7
- SIGN_IN_PATH = BASE_PATH + '/users/sign_in'
8
- SIGN_OUT_PATH = BASE_PATH + '/users/sign_out'
9
- ACCOUNTS_PATH = BASE_PATH + '/accounts'
10
-
11
- include KillbillTestHelper
12
-
13
- # Called before every single test
14
- setup do
15
- setup_integration_test
16
- end
17
-
18
- # Called after every single test
19
- teardown do
20
- teardown_integration_test
21
- end
22
-
23
- protected
24
-
25
- def setup_integration_test
26
- setup_test_data
27
- end
28
-
29
- def teardown_integration_test
30
- end
31
- end
32
- end
@@ -1,43 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Kaui
4
- class NavigationTest < IntegrationTestHelper
5
-
6
- test 'Browse one account' do
7
- get ACCOUNTS_PATH + '/' + @account.account_id
8
- assert_redirected_to SIGN_IN_PATH
9
-
10
- # Verify log-in and redirect to the original page
11
- post SIGN_IN_PATH, :params => {:user => {:kb_username => USERNAME, :password => PASSWORD}}
12
- assert_redirected_to ACCOUNTS_PATH + '/' + @account.account_id
13
-
14
- # User goes to search for the account
15
- get ACCOUNTS_PATH
16
- assert_response :success
17
-
18
- # Assumes he found it on the listing
19
- get ACCOUNTS_PATH + '/' + @account.account_id
20
- assert_response :success
21
- check_no_flash_error
22
- assert_not_nil assigns(:tags)
23
- assert_not_nil assigns(:account_emails)
24
- assert_not_nil assigns(:overdue_state)
25
- assert_not_nil assigns(:payment_methods)
26
-
27
- # He now clicks on the timeline link
28
- get ACCOUNTS_PATH + '/' + @account.account_id + '/timeline'
29
- assert_response :success
30
- check_no_flash_error
31
- assert_not_nil assigns(:account)
32
-
33
- # Verify log-out
34
- delete SIGN_OUT_PATH
35
- assert_redirected_to BASE_PATH + '/'
36
-
37
- get BASE_PATH
38
- assert_redirected_to SIGN_IN_PATH
39
- assert_equal 'You need to sign in before continuing.', flash[:alert]
40
- end
41
- end
42
- end
43
-
@@ -1,219 +0,0 @@
1
- module Kaui
2
- module KillbillTestHelper
3
-
4
- USERNAME = 'admin'
5
- PASSWORD = 'password'
6
-
7
- #
8
- # Rails helpers
9
- #
10
-
11
- def check_no_flash_error
12
- unless flash.now.nil?
13
- assert_nil flash.now[:alert], 'Found flash alert: ' + flash.now[:alert].to_s
14
- assert_nil flash.now[:error], 'Found flash error: ' + flash.now[:error].to_s
15
- end
16
- assert_nil flash[:alert]
17
- assert_nil flash[:error]
18
- end
19
-
20
- #
21
- # Kill Bill specific helpers
22
- #
23
-
24
- def setup_test_data(nb_configured_tenants = 1, setup_tenant_key_secret = true)
25
- @tenant = setup_and_create_test_tenant(nb_configured_tenants)
26
- @account = create_account(@tenant)
27
- @account2 = create_account(@tenant)
28
- @bundle = create_bundle(@account, @tenant)
29
- @invoice_item = create_charge(@account, @tenant)
30
- @paid_invoice_item = create_charge(@account, @tenant, true)
31
- @bundle_invoice = @account.invoices(build_options(@tenant)).first
32
- @payment_method = create_payment_method(true, @account, @tenant)
33
- @payment = create_payment(@paid_invoice_item, @account, @tenant)
34
-
35
- invoice_id_for_cba = create_charge(@account, @tenant).invoice_id
36
- @cba = create_cba(invoice_id_for_cba, @account, @tenant, true)
37
- commit_invoice(invoice_id_for_cba, @tenant)
38
-
39
- if setup_tenant_key_secret
40
- KillBillClient.api_key = @tenant.api_key
41
- KillBillClient.api_secret = @tenant.api_secret
42
- else
43
- KillBillClient.api_key = nil
44
- KillBillClient.api_secret = nil
45
- end
46
- KillBillClient.username = USERNAME
47
- KillBillClient.password = PASSWORD
48
- @tenant
49
- end
50
-
51
- def setup_and_create_test_tenant(nb_configured_tenants)
52
-
53
- # If we need to configure 0 tenant, we still create one with Kill Bill but add nothing in the kaui_tenants and kaui_allowed_users tables
54
- if nb_configured_tenants == 0
55
- return create_tenant
56
- end
57
-
58
- # Setup AllowedUser
59
- au = Kaui::AllowedUser.find_or_create_by(kb_username: 'admin')
60
-
61
- # Create the tenant with Kill Bill
62
- all_tenants = []
63
- test_tenant = nil
64
- (1..nb_configured_tenants).each do |i|
65
- cur_tenant = create_tenant
66
- test_tenant = cur_tenant if test_tenant.nil?
67
-
68
- t = Kaui::Tenant.new
69
- t.kb_tenant_id = cur_tenant.tenant_id
70
- t.name = SecureRandom.uuid.to_s
71
- t.api_key = cur_tenant.api_key
72
- t.api_secret = cur_tenant.api_secret
73
- t.save
74
- all_tenants << t
75
- end
76
-
77
- # setup kaui_tenants
78
- all_tenants.each { |e| au.kaui_tenants << e } if all_tenants.size > 0
79
- test_tenant
80
- end
81
-
82
- # Return a new test account
83
- def create_account(tenant = nil, username = USERNAME, password = PASSWORD, user = 'Kaui test', reason = nil, comment = nil, parent_account_id = nil)
84
- tenant = create_tenant if tenant.nil?
85
- external_key = SecureRandom.uuid.to_s
86
-
87
- account = KillBillClient::Model::Account.new
88
- account.name = 'Kaui'
89
- account.external_key = external_key
90
- account.email = 'kill@bill.com'
91
- account.currency = 'USD'
92
- account.time_zone = 'UTC'
93
- account.address1 = '5, ruby road'
94
- account.address2 = 'Apt 4'
95
- account.postal_code = 10293
96
- account.company = 'KillBill, Inc.'
97
- account.city = 'SnakeCase'
98
- account.state = 'Awesome'
99
- account.country = 'LalaLand'
100
- account.locale = 'fr_FR'
101
- account.parent_account_id = parent_account_id
102
- account.is_payment_delegated_to_parent = !parent_account_id.nil?
103
-
104
- account.create(user, reason, comment, build_options(tenant, username, password))
105
- end
106
-
107
- # Return the killbill server clock
108
- def get_clock(tenant = nil)
109
- tenant = create_tenant(user, reason, comment) if tenant.nil?
110
- Kaui::Admin.get_clock(nil, build_options(tenant, USERNAME, PASSWORD))
111
- end
112
-
113
- # reset killbill server clock
114
- def reset_clock
115
- Kaui::Admin.set_clock(nil, nil, build_options(@tenant, USERNAME, PASSWORD))
116
- end
117
-
118
- # Return the created bundle
119
- def create_bundle(account = nil, tenant = nil, username = USERNAME, password = PASSWORD, user = 'Kaui test', reason = nil, comment = nil)
120
- tenant = create_tenant(user, reason, comment) if tenant.nil?
121
- account = create_account(tenant, username, password, user, reason, comment) if account.nil?
122
-
123
- entitlement = KillBillClient::Model::Subscription.new(:account_id => account.account_id,
124
- :external_key => SecureRandom.uuid,
125
- :product_name => 'Sports', # Sports, so we can add addons
126
- :product_category => 'BASE',
127
- :billing_period => 'MONTHLY',
128
- :price_list => 'DEFAULT')
129
- entitlement = entitlement.create(user, reason, comment, nil, false, build_options(tenant, username, password))
130
-
131
- KillBillClient::Model::Bundle.find_by_id(entitlement.bundle_id, build_options(tenant, username, password))
132
- end
133
-
134
- # Return a new test payment method
135
- def create_payment_method(set_default = false, account = nil, tenant = nil, username = USERNAME, password = PASSWORD, user = 'Kaui test', reason = nil, comment = nil)
136
- account = create_account(tenant, username, password, user, reason, comment) if account.nil?
137
-
138
- payment_method = Kaui::PaymentMethod.new(:account_id => account.account_id, :plugin_name => '__EXTERNAL_PAYMENT__', :is_default => set_default)
139
- payment_method.create(true, user, reason, comment, build_options(tenant, username, password))
140
- end
141
-
142
- # Return the created external charge
143
- def create_charge(account = nil, tenant = nil, auto_commit=false, username = USERNAME, password = PASSWORD, user = 'Kaui test', reason = nil, comment = nil)
144
- tenant = create_tenant(user, reason, comment) if tenant.nil?
145
- account = create_account(tenant, username, password, user, reason, comment) if account.nil?
146
-
147
- invoice_item = KillBillClient::Model::InvoiceItem.new
148
- invoice_item.account_id = account.account_id
149
- invoice_item.currency = account.currency
150
- invoice_item.amount = 123.98
151
-
152
- invoice_item.create(auto_commit, user, reason, comment, build_options(tenant, username, password))
153
- rescue
154
- nil
155
- end
156
-
157
- # Return the created credit
158
- def create_cba(invoice_id = nil, account = nil, tenant = nil, auto_commit=false, username = USERNAME, password = PASSWORD, user = 'Kaui test', reason = nil, comment = nil)
159
- tenant = create_tenant(user, reason, comment) if tenant.nil?
160
- account = create_account(tenant, username, password, user, reason, comment) if account.nil?
161
-
162
- credit = KillBillClient::Model::Credit.new(:invoice_id => invoice_id, :account_id => account.account_id, :amount => 23.22)
163
- credit = credit.create(true, user, reason, comment, build_options(tenant, username, password)).first
164
-
165
- invoice = KillBillClient::Model::Invoice.find_by_id(credit.invoice_id, 'NONE', build_options(tenant, username, password))
166
- invoice.items.find { |ii| ii.amount == -credit.amount }
167
- end
168
-
169
- def commit_invoice(invoice_id, tenant, username = USERNAME, password = PASSWORD, user = 'Kaui test', reason = nil, comment = nil)
170
- invoice = KillBillClient::Model::Invoice.find_by_id(invoice_id, 'NONE', build_options(tenant, username, password))
171
- invoice.commit(user, reason, comment, build_options(tenant, username, password))
172
- end
173
-
174
- def create_payment(invoice_item = nil, account = nil, tenant = nil, username = USERNAME, password = PASSWORD, user = 'Kaui test', reason = nil, comment = nil)
175
- tenant = create_tenant(user, reason, comment) if tenant.nil?
176
- account = create_account(tenant, username, password, user, reason, comment) if account.nil?
177
- invoice_item = create_charge(account, tenant, true, username, password, user, reason, comment) if invoice_item.nil?
178
-
179
- assert_not_nil invoice_item
180
-
181
- payment = Kaui::InvoicePayment.new({:account_id => account.account_id, :target_invoice_id => invoice_item.invoice_id, :purchased_amount => invoice_item.amount})
182
- payment.create(true, user, reason, comment, build_options(tenant, username, password))
183
- end
184
-
185
- # Return a new test tenant
186
- def create_tenant(user = 'Kaui test', reason = nil, comment = nil)
187
- api_key = SecureRandom.uuid.to_s
188
- api_secret = 'S4cr3333333t!!!!!!lolz'
189
-
190
- tenant = KillBillClient::Model::Tenant.new
191
- tenant.api_key = api_key
192
- tenant.api_secret = api_secret
193
-
194
- tenant = tenant.create(true, user, reason, comment, build_options)
195
-
196
- # Re-hydrate the secret, which is not returned
197
- tenant.api_secret = api_secret
198
-
199
- # Upload the default SpyCarAdvanced.xml catalog
200
- catalog_xml = File.read("test/fixtures/SpyCarAdvanced.xml")
201
- Kaui::AdminTenant.upload_catalog(catalog_xml, user, reason, comment, build_options(tenant))
202
-
203
- tenant
204
- end
205
-
206
- def build_options(tenant = nil, username = USERNAME, password = PASSWORD)
207
- {
208
- :api_key => tenant.nil? ? nil : tenant.api_key,
209
- :api_secret => tenant.nil? ? nil : tenant.api_secret,
210
- :username => username,
211
- :password => password
212
- }
213
- end
214
-
215
- def options
216
- build_options(@tenant)
217
- end
218
- end
219
- end
data/test/test_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'simplecov'
2
- require 'pry'
3
- SimpleCov.start 'rails'
4
-
5
- # Configure the Rails Environment
6
- ENV['RAILS_ENV'] = 'test'
7
-
8
- require 'rails-controller-testing'
9
- Rails::Controller::Testing.install
10
-
11
- require File.expand_path('../dummy/config/environment.rb', __FILE__)
12
- require 'rails/test_help'
13
-
14
- Rails.backtrace_cleaner.remove_silencers!
15
-
16
- require 'multi_json'
17
-
18
- # Include helpers
19
- require 'killbill_test_helper'
20
- require 'functional/kaui/functional_test_helper_nosetup'
21
- require 'functional/kaui/functional_test_helper'
22
- require 'integration/kaui/integration_test_helper'
@@ -1,6 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Kaui
4
- class AdminAllowedUsersHelperTest < ActionView::TestCase
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Kaui
4
- class AdminTenantsHelperTest < ActionView::TestCase
5
- end
6
- end
@@ -1,17 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PaymentMethodHelperTest < ActionView::TestCase
4
-
5
- include Kaui::PaymentMethodHelper
6
-
7
- test 'is_json?' do
8
- assert !is_json?(5)
9
- assert !is_json?('true')
10
- assert !is_json?(false)
11
- assert !is_json?("")
12
- assert !is_json?(nil)
13
- assert is_json?('[1, 2, 3]')
14
- assert is_json?('{"value": "New", "onclick": "CreateNewDoc()"}')
15
- assert !is_json?('{"value" => "New", "onclick": "CreateNewDoc()"}')
16
- end
17
- end
@@ -1,6 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Kaui
4
- class TenantsHelperTest < ActionView::TestCase
5
- end
6
- end
@@ -1,16 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::UuidHelperTest < ActionView::TestCase
4
-
5
- #include Kaui::UuidHelper
6
-
7
- test 'can truncate' do
8
- assert_equal '04bdf7b6-...-ab062d33c425', truncate_uuid('04bdf7b6-a95d-4a08-9990-ab062d33c425')
9
- end
10
-
11
- test 'can create a popover' do
12
- object_id = SecureRandom.uuid
13
- expected_markup = %{<span id="#{object_id}-popover" class="object-id-popover" data-id="#{object_id}" data-placement="right">#{truncate_uuid(object_id)}</span}
14
- assert_dom_equal expected_markup, object_id_popover(object_id)
15
- end
16
- end
@@ -1,19 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::AccountEmailTest < ActiveSupport::TestCase
4
-
5
- test 'can compare emails' do
6
- email1 = Kaui::AccountEmail.new(:account_id => SecureRandom.uuid, :email => 'abc@bar.com')
7
- email2 = Kaui::AccountEmail.new(:account_id => SecureRandom.uuid, :email => 'bcd@bar.com')
8
- email3 = Kaui::AccountEmail.new(:account_id => SecureRandom.uuid, :email => nil)
9
-
10
- assert_equal (-1), email1 <=> email2
11
- assert_equal 1, email2 <=> email1
12
- assert_equal 0, email1 <=> email1
13
- assert_equal 0, email2 <=> email2
14
- assert_equal 0, email3 <=> email3
15
- assert_equal 1, email1 <=> email3
16
- assert_equal (-1), email3 <=> email1
17
- assert_equal (-1), email1 <=> nil
18
- end
19
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Kaui::AccountTest < ActiveSupport::TestCase
4
-
5
- test 'can convert to money' do
6
- account = Kaui::Account.new(:account_balance => 12.42, :account_cba => 54.32, :currency => 'USD')
7
-
8
- assert_equal 1242, account.balance_to_money.cents
9
- assert_equal 'USD', account.balance_to_money.currency.to_s
10
-
11
- assert_equal 5432, account.cba_to_money.cents
12
- assert_equal 'USD', account.cba_to_money.currency.to_s
13
- end
14
- end