kaui 0.6.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/Gemfile.lock +51 -37
  4. data/README.md +5 -0
  5. data/Rakefile +1 -1
  6. data/app/controllers/kaui/account_emails_controller.rb +26 -44
  7. data/app/controllers/kaui/account_tags_controller.rb +26 -38
  8. data/app/controllers/kaui/account_timelines_controller.rb +47 -50
  9. data/app/controllers/kaui/accounts_controller.rb +68 -148
  10. data/app/controllers/kaui/bundle_tags_controller.rb +32 -21
  11. data/app/controllers/kaui/bundles_controller.rb +44 -69
  12. data/app/controllers/kaui/chargebacks_controller.rb +31 -61
  13. data/app/controllers/kaui/charges_controller.rb +19 -21
  14. data/app/controllers/kaui/credits_controller.rb +22 -36
  15. data/app/controllers/kaui/custom_fields_controller.rb +15 -13
  16. data/app/controllers/kaui/engine_controller.rb +8 -10
  17. data/app/controllers/kaui/invoice_items_controller.rb +24 -41
  18. data/app/controllers/kaui/invoices_controller.rb +36 -46
  19. data/app/controllers/kaui/payment_methods_controller.rb +84 -28
  20. data/app/controllers/kaui/payments_controller.rb +64 -26
  21. data/app/controllers/kaui/refunds_controller.rb +27 -107
  22. data/app/controllers/kaui/subscriptions_controller.rb +88 -132
  23. data/app/controllers/kaui/tag_definitions_controller.rb +32 -79
  24. data/app/controllers/kaui/tags_controller.rb +16 -14
  25. data/app/controllers/kaui/transactions_controller.rb +25 -0
  26. data/app/helpers/kaui/money_helper.rb +8 -0
  27. data/app/helpers/kaui/subscription_helper.rb +115 -0
  28. data/app/helpers/kaui/uuid_helper.rb +9 -0
  29. data/app/models/kaui/ability.rb +2 -2
  30. data/app/models/kaui/account.rb +25 -42
  31. data/app/models/kaui/account_email.rb +11 -48
  32. data/app/models/kaui/account_timeline.rb +1 -5
  33. data/app/models/kaui/audit_log.rb +1 -15
  34. data/app/models/kaui/base.rb +1 -126
  35. data/app/models/kaui/bundle.rb +47 -14
  36. data/app/models/kaui/catalog.rb +2 -0
  37. data/app/models/kaui/chargeback.rb +24 -36
  38. data/app/models/kaui/credit.rb +5 -20
  39. data/app/models/kaui/custom_field.rb +9 -5
  40. data/app/models/kaui/invoice.rb +9 -53
  41. data/app/models/kaui/invoice_item.rb +8 -18
  42. data/app/models/kaui/invoice_payment.rb +24 -0
  43. data/app/models/kaui/payment.rb +14 -32
  44. data/app/models/kaui/payment_method.rb +36 -0
  45. data/app/models/kaui/rails_methods.rb +7 -9
  46. data/app/models/kaui/refund.rb +5 -20
  47. data/app/models/kaui/subscription.rb +7 -27
  48. data/app/models/kaui/tag.rb +10 -6
  49. data/app/models/kaui/tag_definition.rb +26 -34
  50. data/app/models/kaui/transaction.rb +30 -0
  51. data/app/models/kaui/user.rb +2 -0
  52. data/app/views/kaui/account_emails/_form.html.erb +8 -28
  53. data/app/views/kaui/account_emails/show.html.erb +10 -10
  54. data/app/views/kaui/account_tags/_account_tags_table.html.erb +20 -18
  55. data/app/views/kaui/account_tags/_form.html.erb +42 -0
  56. data/app/views/kaui/account_tags/edit.html.erb +1 -41
  57. data/app/views/kaui/account_tags/show.html.erb +6 -3
  58. data/app/views/kaui/account_timelines/show.html.erb +273 -302
  59. data/app/views/kaui/accounts/_form.html.erb +116 -0
  60. data/app/views/kaui/accounts/index.html.erb +13 -11
  61. data/app/views/kaui/accounts/new.html.erb +5 -0
  62. data/app/views/kaui/accounts/show.html.erb +101 -99
  63. data/app/views/kaui/bundle_tags/_bundle_tags_table.html.erb +29 -9
  64. data/app/views/kaui/bundle_tags/_form.html.erb +41 -0
  65. data/app/views/kaui/bundle_tags/edit.html.erb +2 -34
  66. data/app/views/kaui/bundle_tags/show.html.erb +6 -0
  67. data/app/views/kaui/bundles/index.html.erb +9 -9
  68. data/app/views/kaui/bundles/show.html.erb +17 -15
  69. data/app/views/kaui/bundles/transfer.html.erb +25 -24
  70. data/app/views/kaui/chargebacks/_form.html.erb +44 -0
  71. data/app/views/kaui/chargebacks/new.html.erb +3 -115
  72. data/app/views/kaui/charges/_form.html.erb +73 -0
  73. data/app/views/kaui/charges/new.html.erb +2 -91
  74. data/app/views/kaui/credits/_form.html.erb +73 -0
  75. data/app/views/kaui/credits/new.html.erb +2 -85
  76. data/app/views/kaui/invoice_items/edit.html.erb +77 -78
  77. data/app/views/kaui/invoices/show.html.erb +3 -10
  78. data/app/views/kaui/layouts/kaui_application.html.erb +0 -2
  79. data/app/views/kaui/payment_methods/_form.html.erb +30 -0
  80. data/app/views/kaui/payment_methods/_new_creditcard_payment_method.html.erb +19 -18
  81. data/app/views/kaui/payment_methods/_payment_methods_table.html.erb +8 -5
  82. data/app/views/kaui/payment_methods/index.html.erb +10 -10
  83. data/app/views/kaui/payment_methods/new.html.erb +2 -20
  84. data/app/views/kaui/payment_methods/show.html.erb +2 -1
  85. data/app/views/kaui/payments/_payments_table.html.erb +30 -22
  86. data/app/views/kaui/payments/index.html.erb +1 -1
  87. data/app/views/kaui/payments/new.html.erb +5 -5
  88. data/app/views/kaui/payments/show.html.erb +3 -0
  89. data/app/views/kaui/refunds/new.html.erb +96 -104
  90. data/app/views/kaui/subscriptions/_form.html.erb +36 -0
  91. data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +39 -44
  92. data/app/views/kaui/subscriptions/edit.html.erb +24 -35
  93. data/app/views/kaui/subscriptions/index.html.erb +13 -12
  94. data/app/views/kaui/subscriptions/new.html.erb +6 -43
  95. data/app/views/kaui/subscriptions/show.html.erb +32 -25
  96. data/app/views/kaui/tag_definitions/_form.html.erb +10 -37
  97. data/app/views/kaui/tag_definitions/index.html.erb +3 -5
  98. data/app/views/kaui/tag_definitions/show.html.erb +1 -2
  99. data/app/views/kaui/transactions/_form.html.erb +77 -0
  100. data/app/views/kaui/transactions/new.html.erb +3 -0
  101. data/config/initializers/kilbill-client-init.rb +1 -1
  102. data/config/routes.rb +4 -15
  103. data/kaui.gemspec +8 -6
  104. data/lib/kaui/engine.rb +4 -1
  105. data/lib/kaui/version.rb +1 -1
  106. data/lib/kaui.rb +2 -2
  107. data/test/functional/kaui/account_emails_controller_test.rb +28 -0
  108. data/test/functional/kaui/account_tags_controller_test.rb +29 -0
  109. data/test/functional/kaui/account_timelines_controller_test.rb +21 -0
  110. data/test/functional/kaui/accounts_controller_test.rb +56 -50
  111. data/test/functional/kaui/bundle_tags_controller_test.rb +29 -0
  112. data/test/functional/kaui/bundles_controller_test.rb +58 -13
  113. data/test/functional/kaui/chargebacks_controller_test.rb +16 -5
  114. data/test/functional/kaui/charges_controller_test.rb +39 -0
  115. data/test/functional/kaui/credits_controller_test.rb +35 -0
  116. data/test/functional/kaui/custom_fields_controller_test.rb +21 -0
  117. data/test/functional/kaui/functional_test_helper.rb +61 -0
  118. data/test/functional/kaui/invoice_items_controller_test.rb +24 -10
  119. data/test/functional/kaui/invoices_controller_test.rb +41 -13
  120. data/test/functional/kaui/payment_methods_controller_test.rb +49 -0
  121. data/test/functional/kaui/payments_controller_test.rb +32 -5
  122. data/test/functional/kaui/refunds_controller_test.rb +40 -5
  123. data/test/functional/kaui/subscriptions_controller_test.rb +82 -0
  124. data/test/functional/kaui/tag_definitions_controller_test.rb +27 -53
  125. data/test/functional/kaui/tags_controller_test.rb +21 -0
  126. data/test/functional/kaui/transactions_controller_test.rb +32 -0
  127. data/test/integration/kaui/integration_test_helper.rb +31 -0
  128. data/test/integration/kaui/navigation_test.rb +43 -0
  129. data/test/killbill_test_helper.rb +143 -0
  130. data/test/test_helper.rb +10 -227
  131. data/test/unit/kaui/account_email_test.rb +19 -0
  132. data/test/unit/kaui/account_test.rb +7 -35
  133. data/test/unit/kaui/base_test.rb +5 -46
  134. data/test/unit/kaui/date_helper_test.rb +6 -5
  135. data/test/unit/kaui/invoice_item_test.rb +5 -17
  136. data/test/unit/kaui/invoice_payment_test.rb +42 -0
  137. data/test/unit/kaui/invoice_test.rb +15 -15
  138. data/test/unit/kaui/money_helper_test.rb +10 -0
  139. data/test/unit/kaui/payment_test.rb +42 -0
  140. data/test/unit/kaui/tag_definition_test.rb +5 -28
  141. data/test/unit/kaui/uuid_helper_test.rb +10 -0
  142. metadata +134 -159
  143. data/app/controllers/kaui/analytics_controller.rb +0 -28
  144. data/app/helpers/kaui/killbill_helper.rb +0 -611
  145. data/app/models/kaui/analytics.rb +0 -19
  146. data/app/models/kaui/analytics_sanity.rb +0 -7
  147. data/app/models/kaui/business_account.rb +0 -12
  148. data/app/models/kaui/business_field.rb +0 -6
  149. data/app/models/kaui/business_invoice.rb +0 -31
  150. data/app/models/kaui/business_invoice_item.rb +0 -17
  151. data/app/models/kaui/business_invoice_payment.rb +0 -25
  152. data/app/models/kaui/business_overdue_status.rb +0 -8
  153. data/app/models/kaui/business_snapshot.rb +0 -9
  154. data/app/models/kaui/business_subscription_transition.rb +0 -53
  155. data/app/models/kaui/business_tag.rb +0 -5
  156. data/app/models/kaui/charge.rb +0 -14
  157. data/app/models/kaui/entitlement.rb +0 -2
  158. data/app/models/kaui/event.rb +0 -13
  159. data/app/models/kaui/external_payment.rb +0 -15
  160. data/app/models/kaui/overdue_state.rb +0 -10
  161. data/app/models/kaui/payment_attempt.rb +0 -27
  162. data/app/models/kaui/product.rb +0 -24
  163. data/app/models/kaui/time_series_data.rb +0 -8
  164. data/app/views/kaui/analytics/account_snapshot.html.erb +0 -211
  165. data/app/views/kaui/analytics/index.html.erb +0 -17
  166. data/app/views/kaui/chargebacks/index.html.erb +0 -14
  167. data/app/views/kaui/chargebacks/show.html.erb +0 -19
  168. data/app/views/kaui/credits/index.html.erb +0 -14
  169. data/app/views/kaui/credits/show.html.erb +0 -19
  170. data/app/views/kaui/invoice_items/index.html.erb +0 -20
  171. data/app/views/kaui/invoice_items/show.html.erb +0 -31
  172. data/app/views/kaui/refunds/_refunds_table.html.erb +0 -31
  173. data/app/views/kaui/refunds/index.html.erb +0 -43
  174. data/app/views/kaui/refunds/show.html.erb +0 -33
  175. data/app/views/kaui/tag_definitions/edit.html.erb +0 -3
  176. data/test/dummy/test/fixtures/accounts.yml +0 -32
  177. data/test/dummy/test/fixtures/bill_cycle_days.yml +0 -3
  178. data/test/dummy/test/fixtures/bundles.yml +0 -4
  179. data/test/dummy/test/fixtures/invoice_items.yml +0 -13
  180. data/test/dummy/test/fixtures/invoices.yml +0 -11
  181. data/test/dummy/test/fixtures/overdue_states.yml +0 -8
  182. data/test/dummy/test/fixtures/payment_methods.yml +0 -5
  183. data/test/dummy/test/fixtures/plugin_info_properties.yml +0 -59
  184. data/test/dummy/test/fixtures/plugin_infos.yml +0 -2
  185. data/test/dummy/test/fixtures/refunds.yml +0 -9
  186. data/test/dummy/test/fixtures/tag_definitions.yml +0 -20
  187. data/test/functional/kaui/account_timeline_controller_test.rb +0 -9
  188. data/test/functional/kaui/extpayments_controller_test.rb +0 -9
  189. data/test/functional/kaui/home_controller_test.rb +0 -11
  190. data/test/integration/navigation_test.rb +0 -10
  191. data/test/kaui_test.rb +0 -7
  192. data/test/unit/helpers/kaui/account_timeline_helper_test.rb +0 -6
  193. data/test/unit/helpers/kaui/bundles_helper_test.rb +0 -6
  194. data/test/unit/helpers/kaui/chargebacks_helper_test.rb +0 -6
  195. data/test/unit/helpers/kaui/extpayments_helper_test.rb +0 -6
  196. data/test/unit/helpers/kaui/home_helper_test.rb +0 -6
  197. data/test/unit/helpers/kaui/invoices_helper_test.rb +0 -6
  198. data/test/unit/helpers/kaui/payments_helper_test.rb +0 -6
  199. data/test/unit/helpers/kaui/refunds_helper_test.rb +0 -6
  200. data/test/unit/kaui/overdue_state_test.rb +0 -18
  201. data/test/unit/kaui/refund_test.rb +0 -20
  202. data/test/unit/model_test.rb +0 -151
@@ -1,45 +1,18 @@
1
1
  <%= form_for(@tag_definition) do |f| %>
2
- <% if @tag_definition.errors.any? %>
3
- <div class='alert alert-error'>
4
- <h2><%= pluralize(@tag_definition.errors.count, 'error') %> prohibited this tag definition from being saved:</h2>
5
-
6
- <ul>
7
- <% @tag_definition.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <% unless @tag_definition.new_record? %>
2
+ <%= f.hidden_field :id %>
15
3
  <div class='control-group'>
16
- <%= f.label :id, 'Id:', :class => 'control-label' %>
4
+ <%= f.label :name, 'Name:', :class => 'control-label' %>
17
5
  <div class='controls'>
18
- <%= f.text_field :id, :class => 'input-xlarge disabled', :readonly => true %>
6
+ <%= f.text_field :name %>
19
7
  </div>
20
8
  </div>
21
- <% end %>
22
- <div class='control-group'>
23
- <%= f.label :name, 'Name:', :class => 'control-label' %>
24
- <div class='controls'>
25
- <% unless @tag_definition.new_record? %>
26
- <%= f.text_field :name, :class => 'input-large disabled', :readonly => true %>
27
- <% else %>
28
- <%= f.text_field :name %>
29
- <% end %>
9
+ <div class='control-group'>
10
+ <%= f.label :description, 'Description:', :class => 'control-label' %>
11
+ <div class='controls'>
12
+ <%= f.text_field :description, :class => 'input-xxlarge' %>
13
+ </div>
30
14
  </div>
31
- </div>
32
- <div class='control-group'>
33
- <%= f.label :description, 'Description:', :class => 'control-label' %>
34
- <div class='controls'>
35
- <%= f.text_field :description, :class => 'input-xxlarge' %>
15
+ <div class='form-actions'>
16
+ <%= f.submit 'Create', :class => 'btn btn-primary' %>
36
17
  </div>
37
- </div>
38
- <div class='form-actions'>
39
- <%= f.submit @tag_definition.new_record? ? 'Create' : 'Update', :class => 'btn btn-primary' %>
40
- <% unless @tag_definition.new_record? %>
41
- <%= link_to 'Show', @tag_definition, :class => 'btn' %>
42
- <% end %>
43
- <%= link_to 'Back', :back, :class => 'btn' %>
44
- </div>
45
18
  <% end %>
@@ -9,23 +9,21 @@
9
9
  <th style='width: 5%'>System tag?</th>
10
10
  <th style='width: 15%'>Applicable types</th>
11
11
  <th style='width: 5%'></th>
12
- <!-- <th style='width: 5%'></th> -->
13
12
  <th style='width: 5%'></th>
14
13
  </tr>
15
14
  </thead>
16
15
  <tbody>
17
16
  <% @tag_definitions.each do |tag_definition| %>
18
17
  <tr>
19
- <td><%= tag_definition.id %></td>
18
+ <td><%= truncate_uuid(tag_definition.id) %></td>
20
19
  <td><%= tag_definition.name %></td>
21
20
  <td><%= tag_definition.description %></td>
22
21
  <td><%= tag_definition.is_system_tag? %></td>
23
22
  <td><%= !tag_definition.is_system_tag? ? 'Any' : tag_definition.applicable_object_types.join(', ') %></td>
24
- <td><%= link_to 'Show', tag_definition %></td>
25
- <!-- ><td><%= link_to 'Edit', edit_tag_definition_path(tag_definition) %></td> -->
23
+ <td><%= link_to 'Show', kaui_engine.tag_definition_path(tag_definition.id) %></td>
26
24
  <td>
27
25
  <% unless tag_definition.is_system_tag? %>
28
- <%= link_to 'Destroy', tag_definition, :confirm => 'Are you sure?', :method => :delete %>
26
+ <%= link_to 'Destroy', kaui_engine.tag_definition_path(tag_definition.id), :confirm => 'Are you sure?', :method => :delete %>
29
27
  <% end %>
30
28
  </td>
31
29
  </tr>
@@ -12,5 +12,4 @@
12
12
  <dd><%= @tag_definition.applicable_object_types.join(', ') %>&nbsp;</dd>
13
13
  </dl>
14
14
 
15
- <!-- <%= link_to 'Edit', kaui_engine.edit_tag_definition_path(@tag_definition), :class => 'btn btn-primary' %> -->
16
- <%= link_to 'Back', kaui_engine.tag_definitions_path, :class => 'btn' %>
15
+ <%= link_to 'Tag definitions', kaui_engine.tag_definitions_path, :class => 'btn' %>
@@ -0,0 +1,77 @@
1
+ <%= form_for(@transaction) do |f| %>
2
+ <fieldset>
3
+ <% if @account_id.present? %>
4
+ <div class="control-group">
5
+ <%= label_tag :account_id, 'Account id:', :class => 'control-label' %>
6
+ <div class="controls">
7
+ <%= text_field_tag :account_id, @account_id, :class => 'input-xlarge disabled', :readonly => true %>
8
+ </div>
9
+ </div>
10
+ <% end %>
11
+ <% if @payment_method_id.present? %>
12
+ <div class="control-group">
13
+ <%= label_tag :payment_method_id, 'Payment method id:', :class => 'control-label' %>
14
+ <div class="controls">
15
+ <%= text_field_tag :payment_method_id, @payment_method_id, :class => 'input-xlarge disabled', :readonly => true %>
16
+ </div>
17
+ </div>
18
+ <% end %>
19
+ <% if @transaction.payment_id.present? %>
20
+ <div class="control-group">
21
+ <%= f.label :payment_id, 'Payment id:', :class => 'control-label' %>
22
+ <div class="controls">
23
+ <%= f.text_field :payment_id, :class => 'input-xlarge disabled', :readonly => true %>
24
+ </div>
25
+ </div>
26
+ <% end %>
27
+ <div class="control-group">
28
+ <%= f.label :transaction_type, 'Transaction type', :class => 'control-label' %>
29
+ <div class="controls">
30
+ <%= f.select :transaction_type, %w(AUTHORIZE CAPTURE CHARGEBACK CREDIT PURCHASE REFUND VOID), {}, :class => 'input-medium' %>
31
+ </div>
32
+ </div>
33
+ <% unless @transaction.transaction_type == 'VOID' %>
34
+ <div class="control-group">
35
+ <%= f.label :amount, 'Amount', :class => 'control-label' %>
36
+ <div class="controls">
37
+ <%= f.text_field :amount, :id => 'amount', :class => 'input-small' %>
38
+ </div>
39
+ </div>
40
+ <div class="control-group">
41
+ <%= f.label :currency, 'Currency', :class => 'control-label' %>
42
+ <div class="controls">
43
+ <%= f.select :currency, currencies, {}, :class => 'input-small' %>
44
+ </div>
45
+ </div>
46
+ <% end %>
47
+ <% unless @transaction.payment_id.present? %>
48
+ <div class="control-group">
49
+ <%= f.label :payment_external_key, 'Payment external key', :class => 'control-label' %>
50
+ <div class="controls">
51
+ <%= f.text_field :payment_external_key, :class => 'input-medium' %>
52
+ </div>
53
+ </div>
54
+ <% end %>
55
+ <div class="control-group">
56
+ <%= f.label :transaction_external_key, 'Transaction external key', :class => 'control-label' %>
57
+ <div class="controls">
58
+ <%= f.text_field :transaction_external_key, :class => 'input-medium' %>
59
+ </div>
60
+ </div>
61
+ <div class="control-group">
62
+ <%= label_tag :reason, 'Reason', :class => 'control-label' %>
63
+ <div class="controls">
64
+ <%= select_tag :reason, options_for_select(Kaui::Payment::SAMPLE_REASON_CODES) %>
65
+ </div>
66
+ </div>
67
+ <div class="control-group">
68
+ <%= label_tag :comment, 'Comment', :class => 'control-label' %>
69
+ <div class="controls">
70
+ <%= text_area_tag :comment, '', :rows => 3, :class => 'input-xlarge' %>
71
+ </div>
72
+ </div>
73
+ <div class='form-actions'>
74
+ <%= f.submit 'Create', :class => 'btn btn-primary' %>
75
+ </div>
76
+ </fieldset>
77
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <h1>New transaction</h1>
2
+
3
+ <%= render 'form' %>
@@ -1,4 +1,4 @@
1
- # hack to make the killbillclient models work as rails models
1
+ # hack to make the killbill client models work as rails models
2
2
 
3
3
  module KillBillClient
4
4
  module Model
data/config/routes.rb CHANGED
@@ -11,12 +11,9 @@ Kaui::Engine.routes.draw do
11
11
  scope "/accounts" do
12
12
  match "/pagination" => "accounts#pagination", :via => :get, :as => "accounts_pagination"
13
13
  end
14
- resources :accounts, :only => [ :index, :show ] do
14
+ resources :accounts, :only => [ :index, :new, :create, :show ] do
15
15
  member do
16
- get :payment_methods
17
16
  put :set_default_payment_method
18
- get :add_payment_method
19
- post :do_add_payment_method
20
17
  delete :delete_payment_method
21
18
  post :toggle_email_notifications
22
19
  post :pay_all_invoices
@@ -35,7 +32,7 @@ Kaui::Engine.routes.draw do
35
32
  end
36
33
  end
37
34
 
38
- resources :chargebacks, :only => [ :show, :create, :new ]
35
+ resources :chargebacks, :only => [ :create, :new ]
39
36
 
40
37
  resources :credits, :only => [ :create, :new ]
41
38
 
@@ -47,11 +44,12 @@ Kaui::Engine.routes.draw do
47
44
  match "/pagination" => "payments#pagination", :via => :get, :as => "payments_pagination"
48
45
  end
49
46
  resources :payments, :only => [ :create, :new, :index, :show ]
47
+ resources :transactions, :only => [ :create, :new ]
50
48
 
51
49
  scope "/payment_methods" do
52
50
  match "/pagination" => "payment_methods#pagination", :via => :get, :as => "payment_methods_pagination"
53
51
  end
54
- resources :payment_methods, :only => [ :index, :show, :destroy ]
52
+ resources :payment_methods, :only => [ :index, :new, :create, :show, :destroy ]
55
53
 
56
54
  scope "/refunds" do
57
55
  match "/pagination" => "refunds#pagination", :via => :get, :as => "refunds_pagination"
@@ -85,15 +83,6 @@ Kaui::Engine.routes.draw do
85
83
  end
86
84
  end
87
85
 
88
- scope "/analytics" do
89
- match "/" => "analytics#index", :via => :get, :as => "analytics"
90
- match "/account_snapshot" => "analytics#account_snapshot", :via => :get, :as => "account_snapshot"
91
- match "/refresh_account" => "analytics#refresh_account", :via => :post, :as => "refresh_account"
92
- match "/accounts_over_time" => "analytics#accounts_over_time", :via => :get, :as => "analytics_accounts_over_time"
93
- match "/subscriptions_over_time" => "analytics#subscriptions_over_time", :via => :get, :as => "analytics_subscriptions_over_time"
94
- match "/sanity" => "analytics#sanity", :via => :get, :as => "analytics_sanity"
95
- end
96
-
97
86
  scope "/account_tags" do
98
87
  match "/" => "account_tags#show", :via => :get, :as => "account_tags"
99
88
  match "/edit" => "account_tags#edit", :via => :get, :as => "edit_account_tags"
data/kaui.gemspec CHANGED
@@ -24,19 +24,21 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_dependency 'rails', '~> 3.2.14'
26
26
  s.add_dependency 'jquery-rails', '~> 3.0.4'
27
- s.add_dependency 'rest-client', '~> 1.6.7'
28
27
  s.add_dependency 'money-rails', '~> 0.8.1'
29
28
  s.add_dependency 'd3_rails', '~> 3.2.8'
30
- s.add_dependency 'killbill-client', '~> 0.6.1'
29
+ s.add_dependency 'killbill-client', '~> 0.7.3'
31
30
  s.add_dependency 'devise', '~> 3.0.2'
32
31
  s.add_dependency 'cancan', '~> 1.6.10'
32
+ s.add_dependency 'carmen-rails', '~> 1.0.0'
33
33
 
34
- s.add_development_dependency "fakeweb", '~> 1.3'
34
+ s.add_development_dependency 'fakeweb', '~> 1.3'
35
+ s.add_development_dependency 'rake', '>= 0.8.7'
36
+ s.add_development_dependency 'simplecov'
35
37
 
36
38
  if defined?(JRUBY_VERSION)
37
- s.add_development_dependency 'activerecord-jdbc-adapter', '~> 1.2.2'
38
- s.add_development_dependency 'activerecord-jdbcmysql-adapter', '~> 1.2.2'
39
- s.add_development_dependency 'activerecord-jdbcsqlite3-adapter', '~> 1.2.2'
39
+ s.add_development_dependency 'activerecord-jdbc-adapter', '~> 1.3.9'
40
+ s.add_development_dependency 'activerecord-jdbcmysql-adapter', '~> 1.3.9'
41
+ s.add_development_dependency 'activerecord-jdbcsqlite3-adapter', '~> 1.3.9'
40
42
  s.add_development_dependency 'jdbc-mysql', '~> 5.1.25'
41
43
  else
42
44
  s.add_development_dependency 'sqlite3'
data/lib/kaui/engine.rb CHANGED
@@ -8,10 +8,10 @@ require 'jquery-rails'
8
8
  require 'd3_rails'
9
9
  require 'json'
10
10
  require 'money-rails'
11
- require 'rest_client'
12
11
  require 'killbill_client'
13
12
  require 'devise'
14
13
  require 'cancan'
14
+ require 'carmen-rails'
15
15
 
16
16
  module Kaui
17
17
  class Engine < ::Rails::Engine
@@ -20,6 +20,9 @@ module Kaui
20
20
  initializer 'kaui_engine.action_controller' do |app|
21
21
  ActiveSupport.on_load :action_controller do
22
22
  helper Kaui::DateHelper
23
+ helper Kaui::MoneyHelper
24
+ helper Kaui::SubscriptionHelper
25
+ helper Kaui::UuidHelper
23
26
  end
24
27
  end
25
28
  end
data/lib/kaui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = "0.6.6"
2
+ VERSION = '0.7.0'
3
3
  end
data/lib/kaui.rb CHANGED
@@ -10,7 +10,6 @@ module Kaui
10
10
  mattr_accessor :invoice_home_path
11
11
  mattr_accessor :bundle_key_display_string
12
12
  mattr_accessor :creditcard_plugin_name
13
- mattr_accessor :default_current_user
14
13
  mattr_accessor :layout
15
14
  mattr_accessor :killbill_url
16
15
 
@@ -24,11 +23,12 @@ module Kaui
24
23
  def self.config(&block)
25
24
  # TODO
26
25
  {
27
- :default_current_user => default_current_user || 'Kaui admin user',
28
26
  :layout => layout || 'kaui/layouts/kaui_application',
29
27
  :killbill_url => killbill_url || ENV['KILLBILL_URL'] || 'http://127.0.0.1:8080'
30
28
  }
31
29
  end
30
+
31
+ KillBillClient.url = Kaui.killbill_finder.call
32
32
  end
33
33
 
34
34
  # ruby-1.8 compatibility
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ class Kaui::AccountEmailsControllerTest < Kaui::FunctionalTestHelper
4
+
5
+ test 'should list emails' do
6
+ get :show, :id => @account.account_id
7
+ assert_response 200
8
+ end
9
+
10
+ test 'should add and destroy email' do
11
+ get :new, :account_id => @account.account_id
12
+ assert_response 200
13
+ assert_not_nil assigns(:account_email)
14
+
15
+ email = SecureRandom.uuid.to_s + '@example.com'
16
+ post :create,
17
+ :account_email => {
18
+ :account_id => @account.account_id,
19
+ :email => email
20
+ }
21
+ assert_redirected_to account_email_path(@account.account_id)
22
+ assert_equal 'Account email was successfully added', flash[:notice]
23
+
24
+ delete :destroy, :id => @account.account_id, :email => email
25
+ assert_redirected_to account_email_path(@account.account_id)
26
+ assert_equal 'Account email was successfully deleted', flash[:notice]
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+
3
+ class Kaui::AccountTagsControllerTest < Kaui::FunctionalTestHelper
4
+
5
+ test 'should show tags' do
6
+ get :show, :account_id => @account.account_id
7
+ assert_response 200
8
+ assert_not_nil assigns(:account)
9
+ assert_not_nil assigns(:tags)
10
+ end
11
+
12
+ test 'should get edit' do
13
+ get :edit, :account_id => @account.account_id
14
+ assert_response 200
15
+ assert_not_nil assigns(:account)
16
+ assert_not_nil assigns(:tag_names)
17
+ assert_not_nil assigns(:available_tags)
18
+ end
19
+
20
+ test 'should update tags' do
21
+ post :update,
22
+ :account_id => @account.account_id,
23
+ 'tag_00000000-0000-0000-0000-000000000001' => 'AUTO_PAY_OFF',
24
+ 'tag_00000000-0000-0000-0000-000000000005' => 'MANUAL_PAY',
25
+ 'tag_00000000-0000-0000-0000-000000000003' => 'OVERDUE_ENFORCEMENT_OFF'
26
+ assert_redirected_to account_tags_path(:account_id => @account.account_id)
27
+ assert_equal 'Account tags successfully set', flash[:notice]
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class Kaui::AccountTimelinesControllerTest < Kaui::FunctionalTestHelper
4
+
5
+ test 'should show the lookup page' do
6
+ get :index
7
+ assert_response 200
8
+ end
9
+
10
+ test 'should show the timeline page' do
11
+ get :show, :id => @account.account_id
12
+ assert_response 200
13
+
14
+ assert_not_nil assigns(:account)
15
+ assert_not_nil assigns(:timeline)
16
+ assert_not_nil assigns(:invoices_by_id)
17
+
18
+ assert_equal @account.account_id, assigns(:account).account_id
19
+ assert_equal @invoice_item.invoice_id, assigns(:invoices_by_id)[@invoice_item.invoice_id].invoice_id
20
+ end
21
+ end
@@ -1,63 +1,69 @@
1
1
  require 'test_helper'
2
2
 
3
+ class Kaui::AccountsControllerTest < Kaui::FunctionalTestHelper
3
4
 
4
- def test_regex(str)
5
- /Account balance/.match(str)
6
- end
7
-
8
- test_regex("<dt>Account balance:</dt>")
9
-
10
-
11
- class Kaui::AccountsControllerTest < ActionController::TestCase
12
- fixtures :accounts
13
-
14
- test "should get index" do
15
- get :index, :use_route => 'kaui'
16
- assert_response :success
5
+ test 'should get index' do
6
+ get :index
7
+ assert_response 200
17
8
  end
18
9
 
19
- test "should find account by id" do
20
- pierre = accounts(:pierre)
21
-
22
- get :show, :id => pierre["accountId"], :use_route => 'kaui'
23
- assert_response :success
24
- assert_equal assigns(:account).account_id, pierre["accountId"]
10
+ test 'should list accounts' do
11
+ # Test pagination
12
+ get :pagination, :format => :json
13
+ verify_pagination_results!
25
14
  end
26
15
 
16
+ test 'should search accounts' do
17
+ # Test search
18
+ get :pagination, :sSearch => 'foo', :format => :json
19
+ verify_pagination_results!
20
+ end
27
21
 
28
- test "should find correct positive balance" do
29
- accnt = accounts(:account_with_positive_balance)
30
-
31
- get :show, :id => accnt["accountId"], :use_route => 'kaui'
32
- assert_response :success
33
- assert assigns(:account).balance > 0
34
-
35
- #puts @response.body
36
-
37
- assert_select "dd" do |elements|
38
- elements.each do |element|
39
- if /span/.match(element.to_s)
40
- assert_select "span" do |inner|
41
- assert /"label label-important"/.match(inner[0].to_s)
42
- end
43
- end
44
- end
45
- end
46
- end
22
+ test 'should find account by id' do
23
+ get :show, :id => @account.account_id
24
+ assert_response 200
25
+ assert_not_nil assigns(:tags)
26
+ assert_not_nil assigns(:account_emails)
27
+ assert_not_nil assigns(:overdue_state)
28
+ assert_not_nil assigns(:payment_methods)
29
+ assert_not_nil assigns(:bundles)
30
+ end
47
31
 
48
- test "should find correct negative balance" do
49
- accnt = accounts(:account_with_negative_balance)
32
+ test 'should create account' do
33
+ get :new
34
+ assert_response 200
35
+ assert_not_nil assigns(:account)
36
+
37
+ post :create,
38
+ :account => {
39
+ :name => SecureRandom.uuid.to_s,
40
+ :external_key => SecureRandom.uuid.to_s,
41
+ :email => SecureRandom.uuid.to_s + '@example.com',
42
+ :time_zone => '-06:00',
43
+ :country => 'AR',
44
+ :is_migrated => '1'
45
+ }
46
+ assert_redirected_to account_path(assigns(:account).account_id)
47
+ assert_equal 'Account was successfully created', flash[:notice]
48
+
49
+ assert_equal '-06:00', assigns(:account).time_zone
50
+ assert_equal 'AR', assigns(:account).country
51
+ assert assigns(:account).is_migrated
52
+ assert !assigns(:account).is_notified_for_invoices
53
+ end
50
54
 
51
- get :show, :id => accnt["accountId"], :use_route => 'kaui'
52
- assert_response :success
53
- assert assigns(:account).balance < 0
54
- end
55
+ test 'should set default payment method' do
56
+ put :set_default_payment_method, :id => @account.account_id, :payment_method_id => @payment_method.payment_method_id
57
+ assert_response 302
58
+ end
55
59
 
56
- test "should find correct zero balance" do
57
- accnt = accounts(:account_with_zero_balance)
58
- get :show, :id => accnt["accountId"], :use_route => 'kaui'
59
- assert_response :success
60
- assert assigns(:account).balance == 0
61
- end
60
+ test 'should toggle email notifications' do
61
+ put :toggle_email_notifications, :id => @account.account_id, :is_notified => true
62
+ assert_response 302
63
+ end
62
64
 
65
+ test 'should pay all invoices' do
66
+ post :pay_all_invoices, :id => @account.account_id, :is_external_payment => true
67
+ assert_response 302
68
+ end
63
69
  end
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+
3
+ class Kaui::BundleTagsControllerTest < Kaui::FunctionalTestHelper
4
+
5
+ test 'should show tags' do
6
+ get :show, :bundle_id => @bundle.bundle_id
7
+ assert_response 200
8
+ assert_not_nil assigns(:bundle)
9
+ assert_not_nil assigns(:tags)
10
+ end
11
+
12
+ test 'should get edit' do
13
+ get :edit, :bundle_id => @bundle.bundle_id
14
+ assert_response 200
15
+ assert_not_nil assigns(:bundle)
16
+ assert_not_nil assigns(:tag_names)
17
+ assert_not_nil assigns(:available_tags)
18
+ end
19
+
20
+ test 'should update tags' do
21
+ post :update,
22
+ :bundle_id => @bundle.bundle_id,
23
+ 'tag_00000000-0000-0000-0000-000000000001' => 'AUTO_PAY_OFF',
24
+ 'tag_00000000-0000-0000-0000-000000000005' => 'MANUAL_PAY',
25
+ 'tag_00000000-0000-0000-0000-000000000003' => 'OVERDUE_ENFORCEMENT_OFF'
26
+ assert_redirected_to bundle_tags_path(:bundle_id => @bundle.bundle_id)
27
+ assert_equal 'Bundle tags successfully set', flash[:notice]
28
+ end
29
+ end
@@ -1,21 +1,66 @@
1
1
  require 'test_helper'
2
2
 
3
- class Kaui::BundlesControllerTest < ActionController::TestCase
4
- fixtures :accounts, :bundles
3
+ class Kaui::BundlesControllerTest < Kaui::FunctionalTestHelper
5
4
 
6
- test "should get index" do
7
- get :index, :use_route => 'kaui'
8
- assert_response :success
5
+ test 'should get index' do
6
+ get :index
7
+ assert_response 200
9
8
  end
10
9
 
11
- test "should find bundle by id" do
12
- pierre = accounts(:pierre)
13
- bundle = bundles(:bundle_for_pierre)
10
+ test 'should list bundles' do
11
+ # Test pagination
12
+ get :pagination, :format => :json
13
+ verify_pagination_results!
14
+ end
15
+
16
+ test 'should search bundles' do
17
+ # Test search
18
+ get :pagination, :sSearch => 'foo', :format => :json
19
+ verify_pagination_results!
20
+ end
21
+
22
+ test 'should find bundle by id' do
23
+ get :show, :id => @bundle.bundle_id
24
+ assert_response 200
25
+ assert_not_nil assigns(:bundle)
26
+ assert_not_nil assigns(:account)
27
+ end
28
+
29
+ test 'should get transfer' do
30
+ get :transfer, :id => @bundle.bundle_id
31
+ assert_response 200
32
+ assert_not_nil assigns(:bundle)
33
+ assert_not_nil assigns(:account)
34
+ end
35
+
36
+ test 'should transfer bundle default policy' do
37
+ check_bundle_owner(@account.account_id)
38
+
39
+ post :do_transfer,
40
+ :id => @bundle.bundle_id,
41
+ :new_account_key => @account2.external_key
42
+ assert_response 302
43
+ assert_equal 'Bundle was successfully transferred', flash[:notice]
44
+
45
+ check_bundle_owner(@account2.account_id)
46
+ end
47
+
48
+ test 'should transfer bundle immediately' do
49
+ check_bundle_owner(@account.account_id)
50
+
51
+ post :do_transfer,
52
+ :id => @bundle.bundle_id,
53
+ :new_account_key => @account2.external_key,
54
+ :billing_policy => 'IMMEDIATE'
55
+ assert_response 302
56
+ assert_equal 'Bundle was successfully transferred', flash[:notice]
57
+
58
+ check_bundle_owner(@account2.account_id)
59
+ end
60
+
61
+ private
14
62
 
15
- get :show, :id => bundle["bundleId"], :use_route => 'kaui'
16
- assert_response :success
17
- assert_equal assigns(:account).account_id, pierre["accountId"]
18
- assert_equal assigns(:bundle).bundle_id, bundle["bundleId"]
19
- assert_equal assigns(:bundle).account_id, pierre["accountId"]
63
+ def check_bundle_owner(new_owner)
64
+ assert_equal new_owner, Kaui::Bundle.find_by_external_key(@bundle.external_key, options).account_id
20
65
  end
21
66
  end
@@ -1,9 +1,20 @@
1
1
  require 'test_helper'
2
2
 
3
- module Kaui
4
- class ChargebacksControllerTest < ActionController::TestCase
5
- # test "the truth" do
6
- # assert true
7
- # end
3
+ class Kaui::ChargebacksControllerTest < Kaui::FunctionalTestHelper
4
+
5
+ test 'should get index' do
6
+ get :new, :payment_id => @payment.payment_id
7
+ assert_response 200
8
+ end
9
+
10
+ test 'should create payment methods' do
11
+ post :create,
12
+ :chargeback => {
13
+ :payment_id => @payment.payment_id,
14
+ :amount => @payment.paid_amount_to_money.to_f,
15
+ :currency => @payment.currency
16
+ },
17
+ :cancel_all_subs => '1'
18
+ assert_response 302
8
19
  end
9
20
  end