kaui 2.1.0 → 3.0.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 +128 -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 +4 -3
  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 -6
  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 +28 -30
  155. data/lib/tasks/kaui_tasks.rake +1 -0
  156. metadata +136 -438
  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,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!('&quot;','"');
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!('&quot;','"');
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: 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: 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: 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: 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: 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: 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: 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: 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