spree_backend 3.2.9 → 3.3.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend/admin.js +16 -15
  3. data/app/assets/javascripts/spree/backend/checkouts/edit.js +25 -26
  4. data/app/assets/javascripts/spree/backend/general_settings.js.coffee +10 -12
  5. data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +4 -6
  6. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +7 -1
  7. data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +4 -1
  8. data/app/assets/javascripts/spree/backend/user_picker.js +3 -1
  9. data/app/assets/javascripts/spree/backend.js +3 -3
  10. data/app/controllers/spree/admin/countries_controller.rb +1 -0
  11. data/app/controllers/spree/admin/log_entries_controller.rb +2 -2
  12. data/app/controllers/spree/admin/orders/customer_details_controller.rb +5 -6
  13. data/app/controllers/spree/admin/orders_controller.rb +4 -4
  14. data/app/controllers/spree/admin/payments_controller.rb +21 -10
  15. data/app/controllers/spree/admin/products_controller.rb +5 -0
  16. data/app/controllers/spree/admin/promotion_rules_controller.rb +11 -7
  17. data/app/controllers/spree/admin/stock_transfers_controller.rb +1 -1
  18. data/app/controllers/spree/admin/taxons_controller.rb +31 -23
  19. data/app/helpers/spree/admin/base_helper.rb +1 -1
  20. data/app/helpers/spree/admin/navigation_helper.rb +10 -4
  21. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +2 -2
  22. data/app/views/spree/admin/general_settings/edit.html.erb +8 -8
  23. data/app/views/spree/admin/images/_form.html.erb +2 -2
  24. data/app/views/spree/admin/images/edit.html.erb +2 -2
  25. data/app/views/spree/admin/images/new.html.erb +1 -1
  26. data/app/views/spree/admin/option_types/_form.html.erb +2 -2
  27. data/app/views/spree/admin/option_types/index.html.erb +4 -4
  28. data/app/views/spree/admin/orders/_line_items.html.erb +40 -38
  29. data/app/views/spree/admin/orders/_shipment.html.erb +77 -76
  30. data/app/views/spree/admin/orders/customer_details/_form.html.erb +5 -5
  31. data/app/views/spree/admin/orders/index.html.erb +16 -16
  32. data/app/views/spree/admin/payment_methods/_form.html.erb +2 -2
  33. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  34. data/app/views/spree/admin/products/_add_stock_form.html.erb +3 -3
  35. data/app/views/spree/admin/products/_form.html.erb +16 -16
  36. data/app/views/spree/admin/products/index.html.erb +4 -4
  37. data/app/views/spree/admin/products/new.html.erb +8 -8
  38. data/app/views/spree/admin/promotion_categories/index.html.erb +3 -3
  39. data/app/views/spree/admin/promotions/_form.html.erb +3 -3
  40. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +1 -1
  41. data/app/views/spree/admin/promotions/actions/_create_adjustment.html.erb +2 -2
  42. data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +2 -2
  43. data/app/views/spree/admin/promotions/actions/_create_line_items.html.erb +2 -4
  44. data/app/views/spree/admin/promotions/edit.html.erb +3 -3
  45. data/app/views/spree/admin/promotions/index.html.erb +6 -6
  46. data/app/views/spree/admin/promotions/rules/_item_total.html.erb +2 -2
  47. data/app/views/spree/admin/promotions/rules/_option_value.html.erb +4 -4
  48. data/app/views/spree/admin/properties/_form.html.erb +2 -2
  49. data/app/views/spree/admin/properties/index.html.erb +6 -6
  50. data/app/views/spree/admin/prototypes/index.html.erb +4 -4
  51. data/app/views/spree/admin/reimbursement_types/_form.html.erb +4 -4
  52. data/app/views/spree/admin/reimbursements/edit.html.erb +1 -1
  53. data/app/views/spree/admin/return_authorizations/_form.html.erb +13 -1
  54. data/app/views/spree/admin/return_index/customer_returns.html.erb +2 -2
  55. data/app/views/spree/admin/return_index/return_authorizations.html.erb +5 -5
  56. data/app/views/spree/admin/shared/_content_header.html.erb +2 -2
  57. data/app/views/spree/admin/shared/_header.html.erb +2 -2
  58. data/app/views/spree/admin/shared/_index_table_options.html.erb +2 -2
  59. data/app/views/spree/admin/shared/_order_summary.html.erb +1 -1
  60. data/app/views/spree/admin/shared/_table_filter.html.erb +1 -1
  61. data/app/views/spree/admin/shared/_translations.html.erb +0 -1
  62. data/app/views/spree/admin/shared/_update_order_state.js.erb +1 -1
  63. data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -10
  64. data/app/views/spree/admin/state_changes/index.html.erb +3 -3
  65. data/app/views/spree/admin/states/_form.html.erb +2 -2
  66. data/app/views/spree/admin/stock_locations/_form.html.erb +2 -2
  67. data/app/views/spree/admin/stock_locations/_transfer_stock_form.html.erb +4 -4
  68. data/app/views/spree/admin/stock_transfers/index.html.erb +3 -3
  69. data/app/views/spree/admin/stock_transfers/new.html.erb +2 -2
  70. data/app/views/spree/admin/store_credits/index.html.erb +1 -1
  71. data/app/views/spree/admin/tax_rates/_form.html.erb +2 -2
  72. data/app/views/spree/admin/taxonomies/_list.html.erb +2 -2
  73. data/app/views/spree/admin/taxonomies/{edit.erb → edit.html.erb} +0 -0
  74. data/app/views/spree/admin/taxonomies/index.html.erb +2 -2
  75. data/app/views/spree/admin/taxons/_form.html.erb +5 -5
  76. data/app/views/spree/admin/taxons/edit.html.erb +3 -0
  77. data/app/views/spree/admin/trackers/_form.html.erb +2 -2
  78. data/app/views/spree/admin/users/_addresses_form.html.erb +2 -2
  79. data/app/views/spree/admin/users/_form.html.erb +2 -2
  80. data/app/views/spree/admin/users/_user_page_actions.html.erb +1 -1
  81. data/app/views/spree/admin/users/index.html.erb +5 -5
  82. data/app/views/spree/admin/users/items.html.erb +1 -1
  83. data/app/views/spree/admin/users/orders.html.erb +1 -1
  84. data/app/views/spree/admin/variants/_form.html.erb +2 -2
  85. data/app/views/spree/admin/zones/_form.html.erb +2 -2
  86. data/app/views/spree/layouts/admin.html.erb +3 -3
  87. data/config/initializers/assets.rb +1 -1
  88. data/lib/spree/backend/engine.rb +0 -1
  89. data/spec/controllers/spree/admin/base_controller_spec.rb +46 -0
  90. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +185 -0
  91. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +41 -0
  92. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +18 -0
  93. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +199 -0
  94. data/spec/controllers/spree/admin/orders_controller_spec.rb +296 -0
  95. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +64 -0
  96. data/spec/controllers/spree/admin/payments_controller_spec.rb +97 -0
  97. data/spec/controllers/spree/admin/products_controller_spec.rb +137 -0
  98. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +21 -0
  99. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +21 -0
  100. data/spec/controllers/spree/admin/promotions_controller_spec.rb +44 -0
  101. data/spec/controllers/spree/admin/refunds_controller_spec.rb +32 -0
  102. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +74 -0
  103. data/spec/controllers/spree/admin/reports_controller_spec.rb +42 -0
  104. data/spec/controllers/spree/admin/resource_controller_spec.rb +252 -0
  105. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +225 -0
  106. data/spec/controllers/spree/admin/return_index_controller_spec.rb +37 -0
  107. data/spec/controllers/spree/admin/return_items_controller_spec.rb +27 -0
  108. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +14 -0
  109. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +19 -0
  110. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +41 -0
  111. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +41 -0
  112. data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +34 -0
  113. data/spec/controllers/spree/admin/users_controller_spec.rb +161 -0
  114. data/spec/controllers/spree/admin/variants_controller_spec.rb +32 -0
  115. data/spec/features/admin/configuration/analytics_tracker_spec.rb +47 -0
  116. data/spec/features/admin/configuration/countries_spec.rb +24 -0
  117. data/spec/features/admin/configuration/general_settings_spec.rb +44 -0
  118. data/spec/features/admin/configuration/payment_methods_spec.rb +63 -0
  119. data/spec/features/admin/configuration/roles_spec.rb +47 -0
  120. data/spec/features/admin/configuration/shipping_methods_spec.rb +62 -0
  121. data/spec/features/admin/configuration/states_spec.rb +68 -0
  122. data/spec/features/admin/configuration/stock_locations_spec.rb +48 -0
  123. data/spec/features/admin/configuration/store_credit_categories_spec.rb +50 -0
  124. data/spec/features/admin/configuration/tax_categories_spec.rb +56 -0
  125. data/spec/features/admin/configuration/tax_rates_spec.rb +18 -0
  126. data/spec/features/admin/configuration/zones_spec.rb +39 -0
  127. data/spec/features/admin/homepage_spec.rb +89 -0
  128. data/spec/features/admin/locale_spec.rb +31 -0
  129. data/spec/features/admin/orders/adjustments_promotions_spec.rb +53 -0
  130. data/spec/features/admin/orders/adjustments_spec.rb +124 -0
  131. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +47 -0
  132. data/spec/features/admin/orders/customer_details_spec.rb +154 -0
  133. data/spec/features/admin/orders/line_items_spec.rb +51 -0
  134. data/spec/features/admin/orders/listing_spec.rb +224 -0
  135. data/spec/features/admin/orders/log_entries_spec.rb +55 -0
  136. data/spec/features/admin/orders/new_order_spec.rb +186 -0
  137. data/spec/features/admin/orders/order_details_spec.rb +660 -0
  138. data/spec/features/admin/orders/payments_spec.rb +244 -0
  139. data/spec/features/admin/orders/risk_analysis_spec.rb +48 -0
  140. data/spec/features/admin/orders/shipments_spec.rb +64 -0
  141. data/spec/features/admin/orders/state_changes_spec.rb +21 -0
  142. data/spec/features/admin/products/edit/images_spec.rb +86 -0
  143. data/spec/features/admin/products/edit/products_spec.rb +56 -0
  144. data/spec/features/admin/products/edit/taxons_spec.rb +41 -0
  145. data/spec/features/admin/products/edit/variants_spec.rb +56 -0
  146. data/spec/features/admin/products/option_types_spec.rb +114 -0
  147. data/spec/features/admin/products/products_spec.rb +445 -0
  148. data/spec/features/admin/products/properties_spec.rb +147 -0
  149. data/spec/features/admin/products/prototypes_spec.rb +112 -0
  150. data/spec/features/admin/products/stock_management_spec.rb +124 -0
  151. data/spec/features/admin/products/taxonomies_spec.rb +52 -0
  152. data/spec/features/admin/products/variant_spec.rb +50 -0
  153. data/spec/features/admin/promotions/adjustments_spec.rb +258 -0
  154. data/spec/features/admin/promotions/option_value_rule_spec.rb +70 -0
  155. data/spec/features/admin/promotions/tiered_calculator_spec.rb +70 -0
  156. data/spec/features/admin/refund_reasons/refund_reasons_spec.rb +57 -0
  157. data/spec/features/admin/reimbursement_type/edit_reimbursement_type_spec.rb +36 -0
  158. data/spec/features/admin/reimbursement_type/new_reimbursement_type_spec.rb +62 -0
  159. data/spec/features/admin/reports_spec.rb +61 -0
  160. data/spec/features/admin/return_authorization_reasons/return_authorization_reasons_spec.rb +63 -0
  161. data/spec/features/admin/returns/customer_returns_spec.rb +80 -0
  162. data/spec/features/admin/returns/return_authorizations_spec.rb +152 -0
  163. data/spec/features/admin/stock_transfer_spec.rb +91 -0
  164. data/spec/features/admin/store_credits_spec.rb +93 -0
  165. data/spec/features/admin/taxons_spec.rb +53 -0
  166. data/spec/features/admin/users_spec.rb +286 -0
  167. data/spec/helpers/admin/base_helper_spec.rb +30 -0
  168. data/spec/helpers/admin/navigation_helper_spec.rb +111 -0
  169. data/spec/helpers/admin/promotion_rules_helper_spec.rb +12 -0
  170. data/spec/helpers/admin/stock_movements_helper_spec.rb +30 -0
  171. data/spec/models/spree/resource_spec.rb +48 -0
  172. data/spec/routing/admin_path_spec.rb +22 -0
  173. data/spec/spec_helper.rb +144 -0
  174. data/spec/support/appear_before_matcher.rb +8 -0
  175. data/spec/support/ror_ringer.jpeg +0 -0
  176. data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +1 -0
  177. data/spec/test_views/spree/admin/submodule/posts/new.html.erb +1 -0
  178. data/spec/test_views/spree/admin/widgets/edit.html.erb +1 -0
  179. data/spec/test_views/spree/admin/widgets/new.html.erb +1 -0
  180. data/spree_backend.gemspec +4 -4
  181. data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +130 -154
  182. metadata +106 -29
  183. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  184. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_eeeeee_40x100.png +0 -0
  185. data/vendor/assets/images/jquery-ui/ui-bg_flat_55_ffffff_40x100.png +0 -0
  186. data/vendor/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  187. data/vendor/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  188. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_100_f6f6f6_1x100.png +0 -0
  189. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_25_0073ea_1x100.png +0 -0
  190. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
  191. data/vendor/assets/images/jquery-ui/ui-icons_0073ea_256x240.png +0 -0
  192. data/vendor/assets/images/jquery-ui/ui-icons_454545_256x240.png +0 -0
  193. data/vendor/assets/images/jquery-ui/ui-icons_666666_256x240.png +0 -0
  194. data/vendor/assets/images/jquery-ui/ui-icons_ff0084_256x240.png +0 -0
  195. data/vendor/assets/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
  196. data/vendor/assets/stylesheets/jquery-ui.datepicker.css.erb +0 -357
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ feature "Tiered Calculator Promotions" do
4
+ stub_authorization!
5
+
6
+ let(:promotion) { create :promotion }
7
+
8
+ background do
9
+ visit spree.edit_admin_promotion_path(promotion)
10
+ end
11
+
12
+ scenario "adding a tiered percent calculator", js: true do
13
+ select2 "Create whole-order adjustment", from: "Add action of type"
14
+ within('#action_fields') { click_button "Add" }
15
+
16
+ select2 "Tiered Percent", from: "Calculator"
17
+ within('#actions_container') { click_button "Update" }
18
+
19
+ within("#actions_container .settings") do
20
+ expect(page.body).to have_content("Base Percent")
21
+ expect(page.body).to have_content("Tiers")
22
+
23
+ click_button "Add"
24
+ end
25
+
26
+ fill_in "Base Percent", with: 5
27
+
28
+ within(".tier") do
29
+ find(".js-base-input").set(100)
30
+ page.execute_script("$('.js-base-input').change();")
31
+ find(".js-value-input").set(10)
32
+ page.execute_script("$('.js-value-input').change();")
33
+ end
34
+ within('#actions_container') { click_button "Update" }
35
+
36
+ first_action = promotion.actions.first
37
+ expect(first_action.class).to eq Spree::Promotion::Actions::CreateAdjustment
38
+
39
+ first_action_calculator = first_action.calculator
40
+ expect(first_action_calculator.class).to eq Spree::Calculator::TieredPercent
41
+ expect(first_action_calculator.preferred_base_percent).to eq 5
42
+ expect(first_action_calculator.preferred_tiers).to eq Hash[100.0 => 10.0]
43
+ end
44
+
45
+ context "with an existing tiered flat rate calculator" do
46
+ let(:promotion) { create :promotion, :with_order_adjustment }
47
+
48
+ background do
49
+ action = promotion.actions.first
50
+
51
+ action.calculator = Spree::Calculator::TieredFlatRate.new
52
+ action.calculator.preferred_base_amount = 5
53
+ action.calculator.preferred_tiers = Hash[100 => 10, 200 => 15, 300 => 20]
54
+ action.calculator.save!
55
+
56
+ visit spree.edit_admin_promotion_path(promotion)
57
+ end
58
+
59
+ scenario "deleting a tier", js: true do
60
+ within(".tier:nth-child(2)") do
61
+ click_icon :delete
62
+ end
63
+
64
+ within('#actions_container') { click_button "Update" }
65
+
66
+ calculator = promotion.actions.first.calculator
67
+ expect(calculator.preferred_tiers).to eq Hash[100.0 => 10.0, 300.0 => 20.0]
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'RefundReason', type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ let!(:amount) { 100.0 }
7
+ let!(:payment_amount) { amount * 2 }
8
+ let!(:payment_method) { create(:credit_card_payment_method) }
9
+ let!(:payment) { create(:payment, amount: payment_amount, payment_method: payment_method) }
10
+ let!(:refund_reason) { create(:default_refund_reason, name: 'Reason #1', mutable: true) }
11
+ let!(:refund_reason2) { create(:refund_reason, name: 'Reason #2', mutable: true) }
12
+ let!(:refund) { create(:refund, payment: payment, amount: amount, reason: refund_reason, transaction_id: nil) }
13
+
14
+ before { visit spree.admin_refund_reasons_path }
15
+
16
+ describe 'destroy' do
17
+ it 'has refund reasons' do
18
+ within('.table #refund_reasons') do
19
+ expect(page).to have_content(refund_reason.name)
20
+ expect(page).to have_content(refund_reason2.name)
21
+ end
22
+ end
23
+
24
+ context 'should not destroy an associated option type' do
25
+ before { within_row(1) { delete_product_property } }
26
+
27
+ it 'has persisted refund reasons' do
28
+ within('.table #refund_reasons') do
29
+ expect(page).to have_content(refund_reason.name)
30
+ expect(page).to have_content(refund_reason2.name)
31
+ end
32
+ end
33
+
34
+ it(js: false) { expect(Spree::RefundReason.all).to include(refund_reason) }
35
+ it(js: false) { expect(Spree::RefundReason.all).to include(refund_reason2) }
36
+ end
37
+
38
+ context 'should allow an admin to destroy a non associated option type' do
39
+ before { within_row(2) { delete_product_property } }
40
+
41
+ it 'has persisted refund reasons' do
42
+ within('.table #refund_reasons') do
43
+ expect(page).to have_content(refund_reason.name)
44
+ expect(page).not_to have_content(refund_reason2.name)
45
+ end
46
+ end
47
+
48
+ it(js: false) { expect(Spree::RefundReason.all).to include(refund_reason) }
49
+ it(js: false) { expect(Spree::RefundReason.all).not_to include(refund_reason2) }
50
+ end
51
+
52
+ def delete_product_property
53
+ click_icon :delete
54
+ wait_for_ajax
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe "edit reimbursement type", type: :feature do
4
+ stub_authorization!
5
+ let(:r_type) do
6
+ create(:reimbursement_type,
7
+ name: 'Exchange',
8
+ type: 'Spree::ReimbursementType::Exchange',
9
+ active: true,
10
+ mutable: true)
11
+ end
12
+
13
+ before do
14
+ visit "/admin/reimbursement_types/#{r_type.id}/edit"
15
+ end
16
+
17
+ context "with valid attributes" do
18
+ it "change name, active and mutable" do
19
+ fill_in "Name", with: "New Credit"
20
+ uncheck "Mutable"
21
+ uncheck "Active"
22
+
23
+ expect { click_button "Create" }.not_to change(Spree::ReimbursementType, :count)
24
+
25
+ r_type.reload
26
+
27
+ expect(r_type.active).to eq false
28
+ expect(r_type.mutable).to eq false
29
+ expect(page).to have_content("New Credit")
30
+ end
31
+ end
32
+
33
+ it "view should have select field" do
34
+ expect(page).not_to have_css("div#reimbursement_type_type_field.form-group.field")
35
+ end
36
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe "new reimbursement type", type: :feature do
4
+ stub_authorization!
5
+
6
+ before do
7
+ visit "/admin/reimbursement_types/new"
8
+ end
9
+
10
+ it "view should have select field" do
11
+ expect(page).to have_css("div#reimbursement_type_type_field.form-group.field")
12
+ end
13
+
14
+ context "with valid attributes" do
15
+ it "credit type" do
16
+ fill_in "Name", with: "Credit"
17
+ select "Spree::ReimbursementType::Credit", from: "reimbursement_type_type"
18
+
19
+ expect { click_button "Create" }.to change(Spree::ReimbursementType, :count).by(1)
20
+
21
+ expect(page).to have_content("Credit")
22
+ end
23
+
24
+ it "exchange type" do
25
+ fill_in "Name", with: "Exchange"
26
+ select "Spree::ReimbursementType::Exchange", from: "reimbursement_type_type"
27
+
28
+ expect { click_button "Create" }.to change(Spree::ReimbursementType, :count).by(1)
29
+
30
+ expect(page).to have_content("Exchange")
31
+ end
32
+
33
+ it "original payment type" do
34
+ fill_in "Name", with: "OriginalPayment"
35
+ select "Spree::ReimbursementType::OriginalPayment", from: "reimbursement_type_type"
36
+
37
+ expect { click_button "Create" }.to change(Spree::ReimbursementType, :count).by(1)
38
+
39
+ expect(page).to have_content("OriginalPayment")
40
+ end
41
+
42
+ it "store credit type" do
43
+ fill_in "Name", with: "StoreCredit"
44
+ select "Spree::ReimbursementType::StoreCredit", from: "reimbursement_type_type"
45
+
46
+ expect { click_button "Create" }.to change(Spree::ReimbursementType, :count).by(1)
47
+
48
+ expect(page).to have_content("StoreCredit")
49
+ end
50
+ end
51
+
52
+ context "with invalid params" do
53
+ it "without name" do
54
+ fill_in "Name", with: ""
55
+ select "Spree::ReimbursementType::StoreCredit", from: "reimbursement_type_type"
56
+
57
+ expect { click_button "Create" }.not_to change(Spree::ReimbursementType, :count)
58
+
59
+ expect(page).to have_content("Name can't be blank")
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Reports", type: :feature do
4
+ stub_authorization!
5
+
6
+ context "visiting the admin reports page" do
7
+ it "should have the right content" do
8
+ visit spree.admin_path
9
+ click_link "Reports"
10
+ click_link "Sales Total"
11
+
12
+ expect(page).to have_content("Sales Totals")
13
+ expect(page).to have_content("Item Total")
14
+ expect(page).to have_content("Adjustment Total")
15
+ expect(page).to have_content("Sales Total")
16
+ end
17
+ end
18
+
19
+ context "searching the admin reports page" do
20
+ before do
21
+ order = create(:order)
22
+ order.update_columns({adjustment_total: 100})
23
+ order.completed_at = Time.current
24
+ order.save!
25
+
26
+ order = create(:order)
27
+ order.update_columns({adjustment_total: 200})
28
+ order.completed_at = Time.current
29
+ order.save!
30
+
31
+ #incomplete order
32
+ order = create(:order)
33
+ order.update_columns({adjustment_total: 50})
34
+ order.save!
35
+
36
+ order = create(:order)
37
+ order.update_columns({adjustment_total: 200})
38
+ order.completed_at = 3.years.ago
39
+ order.created_at = 3.years.ago
40
+ order.save!
41
+
42
+ order = create(:order)
43
+ order.update_columns({adjustment_total: 200})
44
+ order.completed_at = 3.years.from_now
45
+ order.created_at = 3.years.from_now
46
+ order.save!
47
+ end
48
+
49
+ it "should allow me to search for reports" do
50
+ visit spree.admin_path
51
+ click_link "Reports"
52
+ click_link "Sales Total"
53
+
54
+ fill_in "q_completed_at_gt", with: 1.week.ago
55
+ fill_in "q_completed_at_lt", with: 1.week.from_now
56
+ click_button "Search"
57
+
58
+ expect(page).to have_content("$300.00")
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'ReturnAuthorizationReason', type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ let!(:order) { create(:shipped_order) }
7
+ let!(:stock_location) { create(:stock_location) }
8
+ let!(:rma_reason) { create(:return_authorization_reason, name: 'Defect #1', mutable: true) }
9
+ let!(:rma_reason2) { create(:return_authorization_reason, name: 'Defect #2', mutable: true) }
10
+
11
+ let!(:return_authorization) do
12
+ create(
13
+ :return_authorization,
14
+ order: order,
15
+ stock_location: stock_location,
16
+ reason: rma_reason
17
+ )
18
+ end
19
+
20
+ before { visit spree.admin_return_authorization_reasons_path }
21
+
22
+ describe 'destroy' do
23
+ it 'has return authorization reasons' do
24
+ within('.table #return_authorization_reasons') do
25
+ expect(page).to have_content(rma_reason.name)
26
+ expect(page).to have_content(rma_reason2.name)
27
+ end
28
+ end
29
+
30
+ context 'should not destroy an associated option type' do
31
+ before { within_row(1) { delete_product_property } }
32
+
33
+ it 'has persisted return authorization reasons' do
34
+ within('.table #return_authorization_reasons') do
35
+ expect(page).to have_content(rma_reason.name)
36
+ expect(page).to have_content(rma_reason2.name)
37
+ end
38
+ end
39
+
40
+ it(js: false) { expect(Spree::ReturnAuthorizationReason.all).to include(rma_reason) }
41
+ it(js: false) { expect(Spree::ReturnAuthorizationReason.all).to include(rma_reason2) }
42
+ end
43
+
44
+ context 'should allow an admin to destroy a non associated option type' do
45
+ before { within_row(2) { delete_product_property } }
46
+
47
+ it 'has persisted return authorization reasons' do
48
+ within('.table #return_authorization_reasons') do
49
+ expect(page).to have_content(rma_reason.name)
50
+ expect(page).not_to have_content(rma_reason2.name)
51
+ end
52
+ end
53
+
54
+ it(js: false) { expect(Spree::ReturnAuthorizationReason.all).to include(rma_reason) }
55
+ it(js: false) { expect(Spree::ReturnAuthorizationReason.all).not_to include(rma_reason2) }
56
+ end
57
+
58
+ def delete_product_property
59
+ click_icon :delete
60
+ wait_for_ajax
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,80 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe "Customer Returns", type: :feature do
5
+ stub_authorization!
6
+ let!(:customer_return) { create(:customer_return, created_at: Time.current) }
7
+
8
+ describe "listing" do
9
+ let!(:customer_return_2) { create(:customer_return, created_at: Time.current - 1.day) }
10
+
11
+ before(:each) do
12
+ visit spree.admin_customer_returns_path
13
+ end
14
+
15
+ it "lists sorted by created_at" do
16
+ within_row(1) { expect(page).to have_content(customer_return.number) }
17
+ within_row(2) { expect(page).to have_content(customer_return_2.number) }
18
+ end
19
+
20
+ it "displays pre tax total" do
21
+ within_row(1) { expect(page).to have_content(customer_return.display_pre_tax_total.to_html) }
22
+ end
23
+
24
+ it "displays order number" do
25
+ within_row(1) { expect(page).to have_content(customer_return.order.number) }
26
+ end
27
+
28
+ it "displays customer return number" do
29
+ within_row(1) { expect(page).to have_content(customer_return.number) }
30
+ end
31
+
32
+ it 'displays status' do
33
+ within_row(1) { expect(page).to have_content(Spree.t(:incomplete)) }
34
+ end
35
+
36
+ it 'has edit link' do
37
+ expect(page).to have_css('.icon-edit')
38
+ end
39
+ end
40
+
41
+ describe "searching" do
42
+ let!(:customer_return_2) { create(:customer_return) }
43
+
44
+ it "searches on number" do
45
+ visit spree.admin_customer_returns_path
46
+
47
+ click_on 'Filter'
48
+ fill_in "q_number_cont", with: customer_return.number
49
+ click_on 'Search'
50
+
51
+ expect(page).to have_content(customer_return.number)
52
+ expect(page).not_to have_content(customer_return_2.number)
53
+
54
+ click_on 'Filter'
55
+ fill_in "q_number_cont", with: customer_return_2.number
56
+ click_on 'Search'
57
+
58
+ expect(page).to have_content(customer_return_2.number)
59
+ expect(page).not_to have_content(customer_return.number)
60
+ end
61
+ end
62
+
63
+ describe 'link' do
64
+ describe 'order number' do
65
+ it 'opens orders edit page' do
66
+ visit spree.admin_customer_returns_path
67
+ click_link customer_return.order.number
68
+ expect(page).to have_content("Orders / #{customer_return.order.number}")
69
+ end
70
+ end
71
+
72
+ describe 'customer return number' do
73
+ it 'opens customer return edit page' do
74
+ visit spree.admin_customer_returns_path
75
+ click_link customer_return.number
76
+ expect(page).to have_content("Customer Return ##{customer_return.number}")
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,152 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe "Return Authorizations", type: :feature do
5
+ stub_authorization!
6
+
7
+ describe "listing" do
8
+ let!(:return_authorization) { create(:return_authorization, created_at: Time.current) }
9
+ let!(:return_authorization_2) { create(:return_authorization, created_at: Time.current - 1.day) }
10
+
11
+ before(:each) do
12
+ visit spree.admin_return_authorizations_path
13
+ end
14
+
15
+ it "lists return authorizations sorted by created_at" do
16
+ within_row(1) { expect(page).to have_content(return_authorization.number) }
17
+ within_row(2) { expect(page).to have_content(return_authorization_2.number) }
18
+ end
19
+
20
+ it "displays order number" do
21
+ within_row(1) { expect(page).to have_content(return_authorization.order.number) }
22
+ end
23
+
24
+ it "displays return authorization number" do
25
+ within_row(1) { expect(page).to have_content(return_authorization.number) }
26
+ end
27
+
28
+ it 'displays state' do
29
+ return_authorization_state = Spree.t("return_authorization_states.#{return_authorization.state}")
30
+ within_row(1) { expect(page).to have_content(return_authorization_state) }
31
+ end
32
+
33
+ it 'has edit link' do
34
+ expect(page).to have_css('.icon-edit')
35
+ end
36
+ end
37
+
38
+ describe "searching" do
39
+ let!(:return_authorization) { create(:return_authorization, state: 'authorized') }
40
+ let!(:return_authorization_2) { create(:return_authorization, state: 'canceled') }
41
+
42
+ it "searches on number" do
43
+ visit spree.admin_return_authorizations_path
44
+
45
+ click_on 'Filter'
46
+ fill_in "q_number_cont", with: return_authorization.number
47
+ click_on 'Search'
48
+
49
+ expect(page).to have_content(return_authorization.number)
50
+ expect(page).not_to have_content(return_authorization_2.number)
51
+
52
+ click_on 'Filter'
53
+ fill_in "q_number_cont", with: return_authorization_2.number
54
+ click_on 'Search'
55
+
56
+ expect(page).to have_content(return_authorization_2.number)
57
+ expect(page).not_to have_content(return_authorization.number)
58
+ end
59
+
60
+ it "searches on status" do
61
+ visit spree.admin_return_authorizations_path
62
+
63
+ click_on 'Filter'
64
+ select Spree.t("return_authorization_states.#{return_authorization.state}"), from: 'Status'
65
+ click_on 'Search'
66
+
67
+ expect(page).to have_content(return_authorization.number)
68
+ expect(page).not_to have_content(return_authorization_2.number)
69
+
70
+ click_on 'Filter'
71
+ select Spree.t("return_authorization_states.#{return_authorization_2.state}"), from: 'Status'
72
+ click_on 'Search'
73
+
74
+ expect(page).to have_content(return_authorization_2.number)
75
+ expect(page).not_to have_content(return_authorization.number)
76
+ end
77
+ end
78
+
79
+ describe 'link' do
80
+ let!(:return_authorization) { create(:return_authorization) }
81
+
82
+ describe 'order number' do
83
+ it 'opens orders edit page' do
84
+ visit spree.admin_return_authorizations_path
85
+ click_link return_authorization.order.number
86
+ expect(page).to have_content("Orders / #{return_authorization.order.number}")
87
+ end
88
+ end
89
+
90
+ describe 'return authorization number' do
91
+ it 'opens return authorization edit page' do
92
+ visit spree.admin_return_authorizations_path
93
+ click_link return_authorization.number
94
+ expect(page).to have_content(return_authorization.number)
95
+ end
96
+ end
97
+
98
+ describe 'authorized' do
99
+ let!(:return_authorization) { create(:return_authorization, state: 'authorized') }
100
+ let!(:return_authorization_2) { create(:return_authorization, state: 'canceled') }
101
+
102
+ it 'only shows authorized return authorizations' do
103
+ visit spree.admin_return_authorizations_path
104
+ within('.nav-tabs') do
105
+ click_link 'Authorized'
106
+ end
107
+
108
+ expect(page).to have_content(return_authorization.number)
109
+ expect(page).not_to have_content(return_authorization_2.number)
110
+ end
111
+
112
+ it 'preselects authorized status in filter' do
113
+ visit spree.admin_return_authorizations_path
114
+ within('.nav-tabs') do
115
+ click_link 'Authorized'
116
+ end
117
+
118
+ within('#table-filter') do
119
+ return_authorization_state = Spree.t("return_authorization_states.#{return_authorization.state}")
120
+ expect(page).to have_select("Status", selected: return_authorization_state)
121
+ end
122
+ end
123
+ end
124
+
125
+ describe 'canceled' do
126
+ let!(:return_authorization) { create(:return_authorization, state: 'canceled') }
127
+ let!(:return_authorization_2) { create(:return_authorization, state: 'authorized') }
128
+
129
+ it 'only shows canceled return authorizations' do
130
+ visit spree.admin_return_authorizations_path
131
+ within('.nav-tabs') do
132
+ click_link 'Canceled'
133
+ end
134
+
135
+ expect(page).to have_content(return_authorization.number)
136
+ expect(page).not_to have_content(return_authorization_2.number)
137
+ end
138
+
139
+ it 'preselects canceled status in filter' do
140
+ visit spree.admin_return_authorizations_path
141
+ within('.nav-tabs') do
142
+ click_link 'Canceled'
143
+ end
144
+
145
+ within('#table-filter') do
146
+ return_authorization_state = Spree.t("return_authorization_states.#{return_authorization.state}")
147
+ expect(page).to have_select("Status", selected: return_authorization_state)
148
+ end
149
+ end
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,91 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Stock Transfers', type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ it 'shows variants with options text' do
7
+ create(:stock_location_with_items, name: 'NY')
8
+
9
+ product = Spree::Product.first
10
+ variant = create(:variant, product: product)
11
+ variant.set_option_value('Color', 'Green')
12
+
13
+ visit spree.admin_stock_transfers_path
14
+ click_on 'New Stock Transfer'
15
+
16
+ select2_search variant.sku, from: 'Variant'
17
+
18
+ content = "#{variant.name} - #{variant.sku} (#{variant.options_text})"
19
+ expect(page).to have_content(content)
20
+ end
21
+
22
+ it 'transfer between 2 locations' do
23
+ source_location = create(:stock_location_with_items, name: 'NY')
24
+ destination_location = create(:stock_location, name: 'SF')
25
+ variant = Spree::Variant.last
26
+
27
+ visit spree.admin_stock_transfers_path
28
+ click_on 'New Stock Transfer'
29
+ fill_in 'reference', with: 'PO 666'
30
+
31
+ select2_search variant.name, from: 'Variant'
32
+
33
+ click_button 'Add'
34
+ click_button 'Transfer Stock'
35
+
36
+ expect(page).to have_content('Reference PO 666')
37
+ expect(page).to have_content('NY')
38
+ expect(page).to have_content('SF')
39
+ expect(page).to have_content(variant.name)
40
+
41
+ transfer = Spree::StockTransfer.last
42
+ expect(transfer.stock_movements.size).to eq 2
43
+ end
44
+
45
+ describe 'received stock transfer' do
46
+ def it_is_received_stock_transfer(page)
47
+ expect(page).to have_content('Reference PO 666')
48
+ expect(page).not_to have_selector("#stock-location-source")
49
+ expect(page).to have_selector("#stock-location-destination")
50
+
51
+ transfer = Spree::StockTransfer.last
52
+ expect(transfer.stock_movements.size).to eq 1
53
+ expect(transfer.source_location).to be_nil
54
+ end
55
+
56
+ it 'receive stock to a single location' do
57
+ source_location = create(:stock_location_with_items, name: 'NY')
58
+ destination_location = create(:stock_location, name: 'SF')
59
+ variant = Spree::Variant.last
60
+
61
+ visit spree.new_admin_stock_transfer_path
62
+
63
+ fill_in 'reference', with: 'PO 666'
64
+ check 'transfer_receive_stock'
65
+ select('NY', from: 'transfer_destination_location_id')
66
+ select2_search variant.name, from: 'Variant'
67
+
68
+ click_button 'Add'
69
+ click_button 'Transfer Stock'
70
+
71
+ it_is_received_stock_transfer page
72
+ end
73
+
74
+ it 'forced to only receive there is only one location' do
75
+ source_location = create(:stock_location_with_items, name: 'NY')
76
+ variant = Spree::Variant.last
77
+
78
+ visit spree.new_admin_stock_transfer_path
79
+
80
+ fill_in 'reference', with: 'PO 666'
81
+
82
+ select('NY', from: 'transfer_destination_location_id')
83
+ select2_search variant.name, from: 'Variant'
84
+
85
+ click_button 'Add'
86
+ click_button 'Transfer Stock'
87
+
88
+ it_is_received_stock_transfer page
89
+ end
90
+ end
91
+ end