solidus_backend 2.7.4 → 2.9.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_backend might be problematic. Click here for more details.

Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -8
  3. data/app/assets/images/favicon.ico +0 -0
  4. data/app/assets/javascripts/spree/backend.js +0 -2
  5. data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
  6. data/app/assets/javascripts/spree/backend/components/sortable_table.js +1 -0
  7. data/app/assets/javascripts/spree/backend/components/tabs.js +1 -0
  8. data/app/assets/javascripts/spree/backend/components/tooltips.js +21 -17
  9. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
  10. data/app/assets/javascripts/spree/backend/product_picker.js +1 -1
  11. data/app/assets/javascripts/spree/backend/shipments.js +7 -1
  12. data/app/assets/javascripts/spree/backend/stock_management.js +18 -0
  13. data/app/assets/javascripts/spree/backend/store_credits.js +18 -2
  14. data/app/assets/javascripts/spree/backend/taxons.js +1 -1
  15. data/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +1 -1
  16. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +24 -25
  17. data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
  18. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +1 -1
  19. data/app/assets/javascripts/spree/backend/views/order/customer_select.js +1 -1
  20. data/app/assets/javascripts/spree/backend/views/order/summary.js +2 -2
  21. data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +15 -4
  22. data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +46 -10
  23. data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +24 -16
  24. data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +12 -0
  25. data/app/assets/stylesheets/spree/backend/components/_buttons.scss +18 -0
  26. data/app/assets/stylesheets/spree/backend/components/_image_placeholder.scss +2 -2
  27. data/app/assets/stylesheets/spree/backend/components/_list_group.scss +2 -2
  28. data/app/assets/stylesheets/spree/backend/components/_messages.scss +20 -12
  29. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +45 -11
  30. data/app/assets/stylesheets/spree/backend/components/_progress.scss +3 -3
  31. data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +1 -2
  32. data/app/assets/stylesheets/spree/backend/components/_tabs.scss +14 -13
  33. data/app/assets/stylesheets/spree/backend/globals/_deprecated_variables.scss +24 -0
  34. data/app/assets/stylesheets/spree/backend/globals/_deprecation.scss +10 -1
  35. data/app/assets/stylesheets/spree/backend/globals/_functions.scss +2 -0
  36. data/app/assets/stylesheets/spree/backend/globals/_variables.scss +88 -57
  37. data/app/assets/stylesheets/spree/backend/globals/_variables_override.scss +1 -0
  38. data/app/assets/stylesheets/spree/backend/globals/mixins/_caret.scss +1 -1
  39. data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +1 -1
  40. data/app/assets/stylesheets/spree/backend/sections/_log_entries.scss +8 -2
  41. data/app/assets/stylesheets/spree/backend/sections/_orders.scss +25 -6
  42. data/app/assets/stylesheets/spree/backend/sections/_products.scss +3 -1
  43. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +5 -5
  44. data/app/assets/stylesheets/spree/backend/sections/_stock_management.scss +77 -2
  45. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -4
  46. data/app/assets/stylesheets/spree/backend/sections/_taxonomies.scss +1 -1
  47. data/app/assets/stylesheets/spree/backend/shared/_fonts.scss +15 -0
  48. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +27 -7
  49. data/app/assets/stylesheets/spree/backend/shared/_header.scss +2 -2
  50. data/app/assets/stylesheets/spree/backend/shared/_icons.scss +5 -1
  51. data/app/assets/stylesheets/spree/backend/shared/_layout.scss +5 -4
  52. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +11 -6
  53. data/app/assets/stylesheets/spree/backend/shared/_typography.scss +10 -6
  54. data/app/assets/stylesheets/spree/backend/spree_admin.scss +3 -1
  55. data/app/controllers/spree/admin/cancellations_controller.rb +2 -2
  56. data/app/controllers/spree/admin/customer_returns_controller.rb +8 -1
  57. data/app/controllers/spree/admin/locale_controller.rb +1 -1
  58. data/app/controllers/spree/admin/log_entries_controller.rb +3 -0
  59. data/app/controllers/spree/admin/orders/customer_details_controller.rb +8 -1
  60. data/app/controllers/spree/admin/orders_controller.rb +1 -12
  61. data/app/controllers/spree/admin/products_controller.rb +10 -6
  62. data/app/controllers/spree/admin/promotion_codes_controller.rb +19 -1
  63. data/app/controllers/spree/admin/promotions_controller.rb +1 -1
  64. data/app/controllers/spree/admin/reimbursements_controller.rb +7 -2
  65. data/app/controllers/spree/admin/resource_controller.rb +1 -0
  66. data/app/controllers/spree/admin/store_credit_reasons_controller.rb +8 -0
  67. data/app/controllers/spree/admin/store_credits_controller.rb +11 -11
  68. data/app/controllers/spree/admin/users_controller.rb +4 -2
  69. data/app/helpers/spree/admin/base_helper.rb +9 -3
  70. data/app/helpers/spree/admin/navigation_helper.rb +1 -1
  71. data/app/helpers/spree/admin/promotions_helper.rb +15 -0
  72. data/app/models/spree/backend_configuration.rb +38 -21
  73. data/app/views/spree/admin/cancellations/index.html.erb +3 -1
  74. data/app/views/spree/admin/images/_image_row.html.erb +1 -1
  75. data/app/views/spree/admin/images/edit.html.erb +3 -3
  76. data/app/views/spree/admin/images/index.html.erb +3 -3
  77. data/app/views/spree/admin/log_entries/index.html.erb +1 -19
  78. data/app/views/spree/admin/option_types/edit.html.erb +1 -1
  79. data/app/views/spree/admin/orders/_carton_manifest.html.erb +3 -1
  80. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -1
  81. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
  82. data/app/views/spree/admin/orders/confirm/_line_items.html.erb +3 -2
  83. data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +3 -1
  84. data/app/views/spree/admin/orders/index.html.erb +1 -1
  85. data/app/views/spree/admin/payments/_capture_events.html.erb +15 -18
  86. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  87. data/app/views/spree/admin/payments/_log_entries.html.erb +29 -0
  88. data/app/views/spree/admin/payments/show.html.erb +13 -6
  89. data/app/views/spree/admin/payments/source_forms/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
  90. data/app/views/spree/admin/payments/source_views/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
  91. data/app/views/spree/admin/prices/_form.html.erb +1 -1
  92. data/app/views/spree/admin/product_properties/index.html.erb +1 -1
  93. data/app/views/spree/admin/products/_form.html.erb +23 -12
  94. data/app/views/spree/admin/products/edit.html.erb +5 -0
  95. data/app/views/spree/admin/products/index.html.erb +3 -1
  96. data/app/views/spree/admin/promotion_categories/index.html.erb +1 -1
  97. data/app/views/spree/admin/promotion_code_batches/index.html.erb +1 -1
  98. data/app/views/spree/admin/promotion_codes/index.html.erb +5 -1
  99. data/app/views/spree/admin/promotion_codes/new.html.erb +31 -0
  100. data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
  101. data/app/views/spree/admin/promotions/_activations_edit.html.erb +1 -1
  102. data/app/views/spree/admin/promotions/_form.html.erb +6 -5
  103. data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
  104. data/app/views/spree/admin/promotions/edit.html.erb +3 -1
  105. data/app/views/spree/admin/promotions/index.html.erb +4 -4
  106. data/app/views/spree/admin/refunds/new.html.erb +1 -1
  107. data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
  108. data/app/views/spree/admin/shared/_address_form.html.erb +10 -3
  109. data/app/views/spree/admin/shared/_edit_resource_links.html.erb +1 -1
  110. data/app/views/spree/admin/shared/_head.html.erb +1 -3
  111. data/app/views/spree/admin/shared/_image.html.erb +2 -2
  112. data/app/views/spree/admin/shared/_modal.html.erb +1 -1
  113. data/app/views/spree/admin/shared/_product_sub_menu.html.erb +1 -1
  114. data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +4 -0
  115. data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +3 -3
  116. data/app/views/spree/admin/shared/_tabs.html.erb +3 -2
  117. data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
  118. data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -10
  119. data/app/views/spree/admin/stock_items/_stock_management.html.erb +56 -38
  120. data/app/views/spree/admin/stock_locations/_form.html.erb +133 -121
  121. data/app/views/spree/admin/stock_locations/edit.html.erb +4 -2
  122. data/app/views/spree/admin/store_credit_reasons/edit.html.erb +15 -0
  123. data/app/views/spree/admin/store_credit_reasons/index.html.erb +56 -0
  124. data/app/views/spree/admin/store_credit_reasons/new.html.erb +18 -0
  125. data/app/views/spree/admin/store_credit_reasons/shared/_form.html.erb +15 -0
  126. data/app/views/spree/admin/store_credits/_store_credit_reason_field.html.erb +7 -0
  127. data/app/views/spree/admin/store_credits/edit_amount.html.erb +1 -1
  128. data/app/views/spree/admin/store_credits/edit_validity.html.erb +2 -2
  129. data/app/views/spree/admin/store_credits/index.html.erb +1 -1
  130. data/app/views/spree/admin/store_credits/show.html.erb +3 -3
  131. data/app/views/spree/admin/stores/_form.html.erb +1 -0
  132. data/app/views/spree/admin/style_guide/topics/typography/_colors.html.erb +30 -20
  133. data/app/views/spree/admin/style_guide/topics/typography/_fonts.html.erb +1 -1
  134. data/app/views/spree/admin/taxonomies/edit.html.erb +1 -1
  135. data/app/views/spree/admin/taxons/_form.html.erb +1 -1
  136. data/app/views/spree/admin/taxons/edit.html.erb +2 -2
  137. data/app/views/spree/admin/users/edit.html.erb +2 -2
  138. data/app/views/spree/admin/users/index.html.erb +2 -2
  139. data/app/views/spree/admin/users/items.html.erb +3 -1
  140. data/app/views/spree/admin/users/orders.html.erb +1 -1
  141. data/app/views/spree/admin/variants/_form.html.erb +1 -1
  142. data/app/views/spree/admin/variants/index.html.erb +1 -1
  143. data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
  144. data/config/routes.rb +2 -8
  145. data/lib/spree/backend.rb +1 -1
  146. data/solidus_backend.gemspec +3 -4
  147. data/spec/controllers/spree/admin/base_controller_spec.rb +1 -1
  148. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +7 -3
  149. data/spec/controllers/spree/admin/locale_controller_spec.rb +45 -0
  150. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +50 -2
  151. data/spec/controllers/spree/admin/orders_controller_spec.rb +25 -13
  152. data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
  153. data/spec/controllers/spree/admin/products_controller_spec.rb +72 -0
  154. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +13 -1
  155. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +11 -0
  156. data/spec/controllers/spree/admin/resource_controller_spec.rb +22 -0
  157. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +1 -1
  158. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +1 -1
  159. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +7 -7
  160. data/spec/features/admin/configuration/payment_methods_spec.rb +2 -2
  161. data/spec/features/admin/configuration/shipping_methods_spec.rb +2 -2
  162. data/spec/features/admin/homepage_spec.rb +1 -6
  163. data/spec/features/admin/locale_spec.rb +1 -2
  164. data/spec/features/admin/orders/adjustments_spec.rb +1 -1
  165. data/spec/features/admin/orders/customer_details_spec.rb +5 -7
  166. data/spec/features/admin/orders/customer_returns_spec.rb +28 -0
  167. data/spec/features/admin/orders/listing_spec.rb +2 -7
  168. data/spec/features/admin/orders/log_entries_spec.rb +2 -2
  169. data/spec/features/admin/orders/new_order_spec.rb +117 -0
  170. data/spec/features/admin/orders/new_refund_spec.rb +35 -0
  171. data/spec/features/admin/orders/order_details_spec.rb +10 -5
  172. data/spec/features/admin/orders/payments_spec.rb +82 -41
  173. data/spec/features/admin/orders/return_payment_state_spec.rb +3 -0
  174. data/spec/features/admin/orders/shipments_spec.rb +28 -0
  175. data/spec/features/admin/products/edit/products_spec.rb +25 -0
  176. data/spec/features/admin/products/edit/taxons_spec.rb +4 -0
  177. data/spec/features/admin/products/pricing_spec.rb +24 -6
  178. data/spec/features/admin/products/products_spec.rb +5 -5
  179. data/spec/features/admin/products/stock_management_spec.rb +27 -13
  180. data/spec/features/admin/products/variant_spec.rb +1 -1
  181. data/spec/features/admin/promotion_adjustments_spec.rb +12 -12
  182. data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
  183. data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
  184. data/spec/features/admin/promotions/promotion_spec.rb +52 -0
  185. data/spec/features/admin/promotions/tiered_calculator_spec.rb +1 -1
  186. data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
  187. data/spec/features/admin/reimbursements_spec.rb +1 -1
  188. data/spec/features/admin/store_credits_spec.rb +51 -2
  189. data/spec/features/admin/taxons_spec.rb +35 -0
  190. data/spec/features/admin/users_spec.rb +44 -11
  191. data/spec/helpers/admin/navigation_helper_spec.rb +4 -2
  192. data/spec/helpers/admin/store_credit_events_helper_spec.rb +2 -2
  193. data/spec/javascripts/spec_helper.js +2 -0
  194. data/spec/models/spree/backend_configuration/menu_item_spec.rb +17 -0
  195. data/spec/models/spree/backend_configuration_spec.rb +22 -0
  196. data/spec/spec_helper.rb +2 -2
  197. data/spec/support/appear_before_matcher.rb +1 -1
  198. data/spec/support/feature/order_feature_helper.rb +1 -1
  199. data/spec/views/spree/admin/shared/navigation_footer_spec.rb +1 -1
  200. data/vendor/assets/fonts/inter/Inter-Regular.woff +0 -0
  201. data/vendor/assets/fonts/inter/Inter-Regular.woff2 +0 -0
  202. data/vendor/assets/fonts/inter/Inter-SemiBold.woff +0 -0
  203. data/vendor/assets/fonts/inter/Inter-SemiBold.woff2 +0 -0
  204. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_en-US.js +10 -0
  205. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_pagination.scss +4 -0
  206. metadata +38 -36
  207. data/.eslintrc +0 -21
  208. data/app/controllers/spree/admin/reports_controller.rb +0 -82
  209. data/app/views/spree/admin/reports/index.html.erb +0 -19
  210. data/app/views/spree/admin/reports/sales_total.html.erb +0 -35
  211. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -19
  212. data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +0 -7
  213. data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -133
  214. data/spec/features/admin/reports_spec.rb +0 -63
data/.eslintrc DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "rules": {
3
- "no-unused-vars": ["error", { "vars": "all", "args": "none" }],
4
- "linebreak-style": ["error", "unix"]
5
- },
6
- "env": {
7
- "es6": false,
8
- "browser": true,
9
- "jquery": true
10
- },
11
- "globals": {
12
- "Spree": true,
13
- "Backbone": true,
14
- "HandlebarsTemplates": true,
15
- "_": true,
16
- "Select2": true,
17
- "show_flash": true,
18
- "update_state": true,
19
- },
20
- "extends": "eslint:recommended"
21
- }
@@ -1,82 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Spree
4
- module Admin
5
- class ReportsController < Spree::Admin::BaseController
6
- respond_to :html
7
-
8
- class << self
9
- def available_reports
10
- @@available_reports
11
- end
12
-
13
- def add_available_report!(report_key, report_description_key = nil)
14
- if report_description_key.nil?
15
- report_description_key = "#{report_key}_description"
16
- end
17
-
18
- @@available_reports[report_key] = {
19
- name: report_key,
20
- description: report_description_key,
21
- }
22
- end
23
- end
24
-
25
- def initialize
26
- super
27
- ReportsController.add_available_report!(:sales_total)
28
- end
29
-
30
- def index
31
- @reports = ReportsController.available_reports
32
- end
33
-
34
- def sales_total
35
- params[:q] = search_params
36
-
37
- @search = Order.complete.not_canceled.ransack(params[:q])
38
- @orders = @search.result
39
-
40
- @totals = {}
41
- @orders.each do |order|
42
- unless @totals[order.currency]
43
- @totals[order.currency] = {
44
- item_total: ::Money.new(0, order.currency),
45
- adjustment_total: ::Money.new(0, order.currency),
46
- sales_total: ::Money.new(0, order.currency)
47
- }
48
- end
49
-
50
- @totals[order.currency][:item_total] += order.display_item_total.money
51
- @totals[order.currency][:adjustment_total] += order.display_adjustment_total.money
52
- @totals[order.currency][:sales_total] += order.display_total.money
53
- end
54
- end
55
-
56
- @@available_reports = {}
57
-
58
- private
59
-
60
- def search_params
61
- params.fetch(:q, {}).tap do |q|
62
- q[:completed_at_gt] = adjust_start_date q[:completed_at_gt]
63
- q[:completed_at_lt] = adjust_end_date(q[:completed_at_lt]) if q[:completed_at_lt].present?
64
- q[:s] ||= 'completed_at desc'
65
- end
66
- end
67
-
68
- def adjust_start_date(string_date = nil)
69
- return Time.current.beginning_of_month if string_date.blank?
70
- Time.zone.parse(string_date).beginning_of_day
71
- rescue ArgumentError
72
- Time.current.beginning_of_month
73
- end
74
-
75
- def adjust_end_date(string_date)
76
- Time.zone.parse(string_date).end_of_day
77
- rescue ArgumentError
78
- ""
79
- end
80
- end
81
- end
82
- end
@@ -1,19 +0,0 @@
1
- <% admin_breadcrumb(t('spree.reports')) %>
2
-
3
-
4
- <table class="index">
5
- <thead>
6
- <tr data-hook="reports_header">
7
- <th><%= t('spree.name') %></th>
8
- <th><%= t('spree.description') %></th>
9
- </tr>
10
- </thead>
11
- <tbody>
12
- <% @reports.each do |key, value| %>
13
- <tr data-hook="reports_row">
14
- <td><%= link_to t(value[:name], scope: 'spree'), send("#{key}_admin_reports_url".to_sym) %></td>
15
- <td><%= t(value[:description], scope: 'spree') %></td>
16
- </tr>
17
- <% end %>
18
- </tbody>
19
- </table>
@@ -1,35 +0,0 @@
1
- <% admin_breadcrumb(link_to t('spree.reports'), spree.admin_reports_path) %>
2
- <% admin_breadcrumb(t('spree.sales_total')) %>
3
-
4
- <% content_for :page_actions do %>
5
- <% end %>
6
-
7
-
8
- <% content_for :table_filter_title do %>
9
- <%= t('spree.date_range') %>
10
- <% end %>
11
-
12
- <% content_for :table_filter do %>
13
- <%= render partial: 'spree/admin/shared/report_order_criteria', locals: { action: :sales_total } %>
14
- <% end %>
15
-
16
- <table class="admin-report" data-hook="sales_total">
17
- <thead>
18
- <tr>
19
- <th><%= t('spree.currency') %></th>
20
- <th><%= t('spree.item_total') %></th>
21
- <th><%= t('spree.adjustment_total') %></th>
22
- <th><%= t('spree.sales_total') %></th>
23
- </tr>
24
- </thead>
25
- <tbody>
26
- <% @totals.each do |key, row| %>
27
- <tr>
28
- <td><%= key %></td>
29
- <td><%= row[:item_total].format %></td>
30
- <td><%= row[:adjustment_total].format %></td>
31
- <td><%= row[:sales_total].format %></td>
32
- </tr>
33
- <% end %>
34
- </tbody>
35
- </table>
@@ -1,19 +0,0 @@
1
- <%= search_form_for @search, url: spree.url_for(controller: 'admin/reports', action: action) do |s| %>
2
- <div class="date-range-filter field">
3
- <div class="date-range-fields input-group">
4
- <%= s.text_field :completed_at_gt, class: 'datepicker datepicker-from form-control', value: datepicker_field_value(params[:q][:completed_at_gt]), placeholder: t('spree.start') %>
5
-
6
- <div class="input-group-prepend input-group-append">
7
- <span class="input-group-text range-divider">
8
- <i class="fa fa-arrow-right"></i>
9
- </span>
10
- </div>
11
-
12
- <%= s.text_field :completed_at_lt, class: 'datepicker datepicker-to form-control', value: datepicker_field_value(params[:q][:completed_at_lt]), placeholder: t('spree.end') %>
13
- </div>
14
- </div>
15
-
16
- <div class="actions filter-actions">
17
- <%= button_tag t('spree.search'), class: 'btn btn-primary' %>
18
- </div>
19
- <% end %>
@@ -1,7 +0,0 @@
1
- <%= f.field_container :reason do %>
2
- <%= f.label :reason, t('spree.reason'), class: 'required' %>
3
- <%= select_tag :update_reason_id, options_from_collection_for_select(@update_reasons, :id, :name),
4
- include_blank: t('spree.choose_reason'), class: 'custom-select fullwidth',
5
- placeholder: t('spree.admin.store_credits.select_amount_update_reason') %>
6
- <%= f.error_message_on :reason %>
7
- <% end %>
@@ -1,133 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Spree::Admin::ReportsController, type: :controller do
6
- stub_authorization!
7
-
8
- describe 'ReportsController.available_reports' do
9
- it 'should contain sales_total' do
10
- expect(Spree::Admin::ReportsController.available_reports.keys.include?(:sales_total)).to be true
11
- end
12
- end
13
-
14
- describe 'ReportsController.add_available_report!' do
15
- context 'when adding the report name' do
16
- it 'should contain the report' do
17
- Spree::Admin::ReportsController.add_available_report!(:some_report)
18
- expect(Spree::Admin::ReportsController.available_reports.keys.include?(:some_report)).to be true
19
- expect(Spree::Admin::ReportsController.available_reports[:some_report]).to eq(
20
- name: :some_report,
21
- description: 'some_report_description'
22
- )
23
- end
24
- end
25
- end
26
-
27
- describe 'GET sales_total' do
28
- let!(:order_complete_start_of_month) { create(:completed_order_with_totals) }
29
- let!(:order_complete_mid_month) { create(:completed_order_with_totals) }
30
- let!(:order_non_complete) { create(:order, completed_at: nil) }
31
-
32
- before do
33
- # can't set completed_at during factory creation
34
- order_complete_start_of_month.completed_at = Time.current.beginning_of_month + 1.minute
35
- order_complete_start_of_month.save!
36
-
37
- order_complete_mid_month.completed_at = Time.current.beginning_of_month + 15.days
38
- order_complete_mid_month.save!
39
- end
40
-
41
- subject { get :sales_total, params: params }
42
-
43
- shared_examples 'sales total report' do
44
- it 'should respond with success' do
45
- expect(response).to be_successful
46
- end
47
-
48
- it 'should set search to be a ransack search' do
49
- subject
50
- expect(assigns(:search)).to be_a Ransack::Search
51
- end
52
-
53
- it 'should set orders correctly for date parameters' do
54
- subject
55
- expect(assigns(:orders)).to eq expected_returned_orders
56
- end
57
-
58
- it 'does not include non-complete orders' do
59
- subject
60
- expect(assigns(:orders)).to_not include(order_non_complete)
61
- end
62
-
63
- it 'should correctly set the totals hash' do
64
- subject
65
- expect(assigns(:totals)).to eq expected_totals
66
- end
67
- end
68
-
69
- context 'when no dates are specified' do
70
- let(:params) { {} }
71
-
72
- it_behaves_like 'sales total report' do
73
- let(:expected_returned_orders) { [order_complete_mid_month, order_complete_start_of_month] }
74
- let(:expected_totals) {
75
- {
76
- 'USD' => {
77
- item_total: Money.new(2000, 'USD'),
78
- adjustment_total: Money.new(0, 'USD'),
79
- sales_total: Money.new(22_000, 'USD')
80
- }
81
- }
82
- }
83
- end
84
- end
85
-
86
- context 'when params has a completed_at_gt' do
87
- let(:params) { { q: { completed_at_gt: Time.current.beginning_of_month + 1.day } } }
88
-
89
- it_behaves_like 'sales total report' do
90
- let(:expected_returned_orders) { [order_complete_mid_month] }
91
- let(:expected_totals) {
92
- {
93
- 'USD' => {
94
- item_total: Money.new(1000, 'USD'),
95
- adjustment_total: Money.new(0, 'USD'),
96
- sales_total: Money.new(11_000, 'USD')
97
- }
98
- }
99
- }
100
- end
101
- end
102
-
103
- context 'when params has a compeleted_at_lt' do
104
- let(:params) { { q: { completed_at_lt: Time.current.beginning_of_month } } }
105
-
106
- it_behaves_like 'sales total report' do
107
- let(:expected_returned_orders) { [order_complete_start_of_month] }
108
- let(:expected_totals) {
109
- {
110
- 'USD' => {
111
- item_total: Money.new(1000, 'USD'),
112
- adjustment_total: Money.new(0, 'USD'),
113
- sales_total: Money.new(11_000, 'USD')
114
- }
115
- }
116
- }
117
- end
118
- end
119
- end
120
-
121
- describe 'GET index' do
122
- it 'should be ok' do
123
- get :index
124
- expect(response).to be_ok
125
- end
126
- end
127
-
128
- after(:each) do
129
- Spree::Admin::ReportsController.available_reports.delete_if do |key, _value|
130
- key != :sales_total
131
- end
132
- end
133
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe "Reports", type: :feature do
6
- stub_authorization!
7
-
8
- context "visiting the admin reports page" do
9
- it "should have the right content" do
10
- visit spree.admin_path
11
- click_link "Reports"
12
- click_link "Sales Total"
13
-
14
- expect(page).to have_content("ReportsSales Total")
15
- expect(page).to have_content("Item Total")
16
- expect(page).to have_content("Adjustment Total")
17
- expect(page).to have_content("Sales Total")
18
- end
19
- end
20
-
21
- context "searching the admin reports page" do
22
- before do
23
- order = create(:order)
24
- order.update_columns({ adjustment_total: 100 })
25
- order.completed_at = Time.current
26
- order.save!
27
-
28
- order = create(:order)
29
- order.update_columns({ adjustment_total: 200 })
30
- order.completed_at = Time.current
31
- order.save!
32
-
33
- # incomplete order
34
- order = create(:order)
35
- order.update_columns({ adjustment_total: 50 })
36
- order.save!
37
-
38
- order = create(:order)
39
- order.update_columns({ adjustment_total: 200 })
40
- order.completed_at = 3.years.ago
41
- order.created_at = 3.years.ago
42
- order.save!
43
-
44
- order = create(:order)
45
- order.update_columns({ adjustment_total: 200 })
46
- order.completed_at = 3.years.from_now
47
- order.created_at = 3.years.from_now
48
- order.save!
49
- end
50
-
51
- it "should allow me to search for reports" do
52
- visit spree.admin_path
53
- click_link "Reports"
54
- click_link "Sales Total"
55
-
56
- fill_in "q_completed_at_gt", with: 1.week.ago
57
- fill_in "q_completed_at_lt", with: 1.week.from_now
58
- click_button "Search"
59
-
60
- expect(page).to have_content("$300.00")
61
- end
62
- end
63
- end