solidus_backend 1.0.7 → 1.1.0.beta1

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 (201) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +3 -0
  3. data/app/assets/javascripts/spree/backend/admin.js.erb +17 -24
  4. data/app/assets/javascripts/spree/backend/checkouts/edit.js +3 -5
  5. data/app/assets/javascripts/spree/backend/flash.coffee +17 -0
  6. data/app/assets/javascripts/spree/backend/handlebars_extensions.coffee +9 -0
  7. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb +6 -6
  8. data/app/assets/javascripts/spree/backend/option_value_picker.js +43 -0
  9. data/app/assets/javascripts/spree/backend/product_picker.js +10 -8
  10. data/app/assets/javascripts/spree/backend/promotions.js.coffee +101 -0
  11. data/app/assets/javascripts/spree/backend/routes.js +2 -1
  12. data/app/assets/javascripts/spree/backend/shipments.js.erb +1 -1
  13. data/app/assets/javascripts/spree/backend/stock_management/index_add_forms.coffee +1 -1
  14. data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +2 -2
  15. data/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee +1 -1
  16. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb +6 -6
  17. data/app/assets/javascripts/spree/backend/taxons.js.coffee +6 -7
  18. data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +17 -0
  19. data/app/assets/javascripts/spree/backend/templates/products/sortable.hbs +5 -0
  20. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_flat_rate.hbs +17 -0
  21. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_percent.hbs +17 -0
  22. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values.hbs +10 -0
  23. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values_select.hbs +1 -0
  24. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +19 -0
  25. data/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs.erb +52 -0
  26. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs.erb +23 -0
  27. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +51 -0
  28. data/app/assets/javascripts/spree/backend/templates/variants/line_items_autocomplete_stock.hbs +67 -0
  29. data/app/assets/javascripts/spree/backend/templates/variants/split.hbs +27 -0
  30. data/app/assets/javascripts/spree/backend/user_picker.js +8 -8
  31. data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee.erb +6 -8
  32. data/app/assets/stylesheets/spree/backend/components/_messages.scss +6 -3
  33. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +16 -0
  34. data/app/controllers/spree/admin/base_controller.rb +1 -1
  35. data/app/controllers/spree/admin/option_types_controller.rb +1 -3
  36. data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
  37. data/app/controllers/spree/admin/orders_controller.rb +6 -11
  38. data/app/controllers/spree/admin/product_properties_controller.rb +9 -0
  39. data/app/controllers/spree/admin/products_controller.rb +20 -5
  40. data/app/controllers/spree/admin/promotions_controller.rb +2 -1
  41. data/app/controllers/spree/admin/reimbursements_controller.rb +20 -0
  42. data/app/controllers/spree/admin/resource_controller.rb +1 -1
  43. data/app/controllers/spree/admin/return_authorizations_controller.rb +5 -0
  44. data/app/controllers/spree/admin/root_controller.rb +1 -1
  45. data/app/controllers/spree/admin/search_controller.rb +2 -4
  46. data/app/controllers/spree/admin/states_controller.rb +1 -1
  47. data/app/controllers/spree/admin/stock_items_controller.rb +1 -1
  48. data/app/controllers/spree/admin/stock_transfers_controller.rb +3 -14
  49. data/app/controllers/spree/admin/users_controller.rb +2 -3
  50. data/app/controllers/spree/admin/variant_property_rule_values_controller.rb +7 -0
  51. data/app/controllers/spree/admin/variants_controller.rb +1 -1
  52. data/app/controllers/spree/admin/zones_controller.rb +1 -1
  53. data/app/helpers/spree/admin/adjustments_helper.rb +4 -9
  54. data/app/helpers/spree/admin/base_helper.rb +7 -6
  55. data/app/helpers/spree/admin/navigation_helper.rb +8 -2
  56. data/app/helpers/spree/admin/orders_helper.rb +1 -1
  57. data/app/helpers/spree/admin/products_helper.rb +2 -4
  58. data/app/helpers/spree/admin/stock_movements_helper.rb +3 -3
  59. data/app/views/spree/admin/adjustments/_adjustment.html.erb +1 -1
  60. data/app/views/spree/admin/orders/_add_line_item.html.erb +0 -5
  61. data/app/views/spree/admin/orders/_add_product.html.erb +0 -3
  62. data/app/views/spree/admin/orders/_carton.html.erb +0 -1
  63. data/app/views/spree/admin/orders/_shipment.html.erb +0 -1
  64. data/app/views/spree/admin/orders/confirm/_shipment.html.erb +0 -1
  65. data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
  66. data/app/views/spree/admin/orders/customer_details/edit.html.erb +0 -1
  67. data/app/views/spree/admin/orders/index.html.erb +1 -2
  68. data/app/views/spree/admin/payment_methods/_form.html.erb +0 -4
  69. data/app/views/spree/admin/payment_methods/index.html.erb +0 -2
  70. data/app/views/spree/admin/payments/source_views/_gateway.html.erb +3 -0
  71. data/app/views/spree/admin/product_properties/index.html.erb +52 -2
  72. data/app/views/spree/admin/promotions/_actions.html.erb +14 -10
  73. data/app/views/spree/admin/promotions/_promotion_action.html.erb +5 -3
  74. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +5 -3
  75. data/app/views/spree/admin/promotions/_rules.html.erb +18 -14
  76. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +5 -28
  77. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +5 -27
  78. data/app/views/spree/admin/promotions/edit.html.erb +6 -4
  79. data/app/views/spree/admin/promotions/index.html.erb +1 -1
  80. data/app/views/spree/admin/promotions/rules/_option_value.html.erb +13 -0
  81. data/app/views/spree/admin/refund_reasons/index.html.erb +2 -2
  82. data/app/views/spree/admin/reimbursements/edit.html.erb +1 -1
  83. data/app/views/spree/admin/return_authorizations/_form.html.erb +2 -2
  84. data/app/views/spree/admin/search/users.rabl +1 -1
  85. data/app/views/spree/admin/shared/_order_summary.html.erb +6 -0
  86. data/app/views/spree/admin/shared/_tabs.html.erb +2 -2
  87. data/app/views/spree/admin/shared/_translations.html.erb +16 -46
  88. data/app/views/spree/admin/shared/named_types/_index.html.erb +2 -2
  89. data/app/views/spree/admin/stock_items/_stock_management.html.erb +0 -2
  90. data/app/views/spree/admin/stock_movements/_form.html.erb +0 -2
  91. data/app/views/spree/admin/stock_transfers/edit.html.erb +0 -3
  92. data/app/views/spree/admin/stock_transfers/receive.html.erb +0 -2
  93. data/app/views/spree/admin/stock_transfers/show.html.erb +1 -1
  94. data/app/views/spree/admin/taxons/index.html.erb +0 -1
  95. data/app/views/spree/admin/users/_addresses_form.html.erb +4 -4
  96. data/app/views/spree/layouts/admin.html.erb +11 -9
  97. data/config/routes.rb +5 -0
  98. data/lib/spree/backend.rb +1 -2
  99. metadata +41 -139
  100. data/CHANGELOG.md +0 -1
  101. data/Gemfile +0 -6
  102. data/Rakefile +0 -15
  103. data/app/assets/javascripts/spree/backend/handlebar_extensions.js +0 -9
  104. data/app/assets/javascripts/spree/backend/promotions.js +0 -73
  105. data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +0 -196
  106. data/app/views/spree/admin/products/_autocomplete.js.erb +0 -14
  107. data/app/views/spree/admin/products/_sortable.html +0 -7
  108. data/app/views/spree/admin/stock_items/_stock_location_stock_item_template.html.erb +0 -21
  109. data/app/views/spree/admin/stock_transfers/_transfer_item_template.html.erb +0 -54
  110. data/app/views/spree/admin/variants/_autocomplete.js.erb +0 -25
  111. data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +0 -69
  112. data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +0 -53
  113. data/app/views/spree/admin/variants/_split.js.erb +0 -29
  114. data/script/rails +0 -9
  115. data/solidus_backend.gemspec +0 -30
  116. data/spec/controllers/spree/admin/base_controller_spec.rb +0 -24
  117. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +0 -77
  118. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -234
  119. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
  120. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
  121. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -80
  122. data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -472
  123. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -49
  124. data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -175
  125. data/spec/controllers/spree/admin/products_controller_spec.rb +0 -45
  126. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
  127. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +0 -18
  128. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
  129. data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -122
  130. data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
  131. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -75
  132. data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -134
  133. data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -166
  134. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -226
  135. data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
  136. data/spec/controllers/spree/admin/root_controller_spec.rb +0 -41
  137. data/spec/controllers/spree/admin/search_controller_spec.rb +0 -104
  138. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
  139. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -50
  140. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
  141. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -331
  142. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +0 -309
  143. data/spec/controllers/spree/admin/users_controller_spec.rb +0 -236
  144. data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
  145. data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -54
  146. data/spec/features/admin/configuration/countries_spec.rb +0 -22
  147. data/spec/features/admin/configuration/general_settings_spec.rb +0 -45
  148. data/spec/features/admin/configuration/payment_methods_spec.rb +0 -125
  149. data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -64
  150. data/spec/features/admin/configuration/states_spec.rb +0 -64
  151. data/spec/features/admin/configuration/stock_locations_spec.rb +0 -50
  152. data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
  153. data/spec/features/admin/configuration/tax_rates_spec.rb +0 -30
  154. data/spec/features/admin/configuration/taxonomies_spec.rb +0 -52
  155. data/spec/features/admin/configuration/zones_spec.rb +0 -39
  156. data/spec/features/admin/homepage_spec.rb +0 -78
  157. data/spec/features/admin/locale_spec.rb +0 -30
  158. data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
  159. data/spec/features/admin/orders/adjustments_spec.rb +0 -126
  160. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -48
  161. data/spec/features/admin/orders/cancelling_inventory_spec.rb +0 -48
  162. data/spec/features/admin/orders/customer_details_spec.rb +0 -163
  163. data/spec/features/admin/orders/line_items_spec.rb +0 -50
  164. data/spec/features/admin/orders/listing_spec.rb +0 -130
  165. data/spec/features/admin/orders/log_entries_spec.rb +0 -55
  166. data/spec/features/admin/orders/new_order_spec.rb +0 -197
  167. data/spec/features/admin/orders/order_details_spec.rb +0 -533
  168. data/spec/features/admin/orders/payments_spec.rb +0 -228
  169. data/spec/features/admin/orders/risk_analysis_spec.rb +0 -47
  170. data/spec/features/admin/orders/shipments_spec.rb +0 -65
  171. data/spec/features/admin/payments/store_credits_spec.rb +0 -21
  172. data/spec/features/admin/products/edit/images_spec.rb +0 -87
  173. data/spec/features/admin/products/edit/products_spec.rb +0 -66
  174. data/spec/features/admin/products/edit/taxons_spec.rb +0 -56
  175. data/spec/features/admin/products/edit/variants_spec.rb +0 -61
  176. data/spec/features/admin/products/option_types_spec.rb +0 -114
  177. data/spec/features/admin/products/products_spec.rb +0 -392
  178. data/spec/features/admin/products/properties_spec.rb +0 -139
  179. data/spec/features/admin/products/prototypes_spec.rb +0 -110
  180. data/spec/features/admin/products/stock_management_spec.rb +0 -82
  181. data/spec/features/admin/products/variant_spec.rb +0 -51
  182. data/spec/features/admin/promotion_adjustments_spec.rb +0 -220
  183. data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -69
  184. data/spec/features/admin/promotions/user_rule_spec.rb +0 -25
  185. data/spec/features/admin/reports_spec.rb +0 -61
  186. data/spec/features/admin/stock_transfer_spec.rb +0 -86
  187. data/spec/features/admin/store_credits_spec.rb +0 -82
  188. data/spec/features/admin/taxons_spec.rb +0 -31
  189. data/spec/features/admin/users_spec.rb +0 -270
  190. data/spec/helpers/admin/base_helper_spec.rb +0 -24
  191. data/spec/helpers/admin/navigation_helper_spec.rb +0 -73
  192. data/spec/helpers/admin/reimbursements_helper_spec.rb +0 -34
  193. data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -29
  194. data/spec/helpers/admin/store_credit_events_helper_spec.rb +0 -95
  195. data/spec/helpers/promotion_rules_helper_spec.rb +0 -12
  196. data/spec/spec_helper.rb +0 -108
  197. data/spec/support/appear_before_matcher.rb +0 -8
  198. data/spec/support/ror_ringer.jpeg +0 -0
  199. data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
  200. data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
  201. data/vendor/assets/javascripts/handlebars.js +0 -2746
@@ -1,69 +0,0 @@
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).to have_content("BASE PERCENT")
21
- expect(page).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("input:last-child").set(100)
30
- find("input:first-child").set(10)
31
- end
32
-
33
- within('#actions_container') { click_button "Update" }
34
-
35
- first_action = promotion.actions.first
36
- expect(first_action.class).to eq Spree::Promotion::Actions::CreateAdjustment
37
-
38
- first_action_calculator = first_action.calculator
39
- expect(first_action_calculator.class).to eq Spree::Calculator::TieredPercent
40
- expect(first_action_calculator.preferred_base_percent).to eq 5
41
- expect(first_action_calculator.preferred_tiers).to eq Hash[100.0 => 10.0]
42
- end
43
-
44
- context "with an existing tiered flat rate calculator" do
45
- let(:promotion) { create :promotion, :with_order_adjustment }
46
-
47
- background do
48
- action = promotion.actions.first
49
-
50
- action.calculator = Spree::Calculator::TieredFlatRate.new
51
- action.calculator.preferred_base_amount = 5
52
- action.calculator.preferred_tiers = Hash[100 => 10, 200 => 15, 300 => 20]
53
- action.calculator.save!
54
-
55
- visit spree.edit_admin_promotion_path(promotion)
56
- end
57
-
58
- scenario "deleting a tier", js: true do
59
- within(".tier:nth-child(2)") do
60
- find(".remove").click
61
- end
62
-
63
- within('#actions_container') { click_button "Update" }
64
-
65
- calculator = promotion.actions.first.calculator
66
- expect(calculator.preferred_tiers).to eq Hash[100.0 => 10.0, 300.0 => 20.0]
67
- end
68
- end
69
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature 'Promotion with user rule', js: true do
4
- stub_authorization!
5
-
6
- given(:promotion) { create :promotion }
7
-
8
- background do
9
- visit spree.edit_admin_promotion_path(promotion)
10
- end
11
-
12
- context "with an attempted XSS" do
13
- let(:xss_string) { %(<script>throw("XSS")</script>) }
14
- given!(:user) { create(:user, email: xss_string) }
15
-
16
- scenario "adding an option value rule" do
17
- select2 "User", from: "Add rule of type"
18
- within("#rules_container") { click_button "Add" }
19
-
20
- select2_search "<script>", from: "Choose users"
21
-
22
- expect(page).to have_content(xss_string)
23
- end
24
- end
25
- end
@@ -1,61 +0,0 @@
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.now
24
- order.save!
25
-
26
- order = create(:order)
27
- order.update_columns({:adjustment_total => 200})
28
- order.completed_at = Time.now
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
@@ -1,86 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Stock Transfers', :type => :feature, :js => true do
4
- stub_authorization!
5
-
6
- let(:admin_user) { create(:admin_user) }
7
- let(:description) { 'Test stock transfer' }
8
-
9
- before do
10
- allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(admin_user)
11
- end
12
-
13
- describe 'create stock transfer' do
14
- it 'can create a stock transfer' do
15
- source_location = create(:stock_location_with_items, :name => 'NY')
16
- destination_location = create(:stock_location, :name => 'SF')
17
-
18
- visit spree.new_admin_stock_transfer_path
19
- select "SF", from: 'stock_transfer[source_location_id]'
20
- fill_in 'stock_transfer_description', with: description
21
- click_button 'Continue'
22
-
23
- expect(page.find('#stock_transfer_description').value).to eq description
24
-
25
- select "NY", from: 'stock_transfer[destination_location_id]'
26
- within "form.edit_stock_transfer" do
27
- page.find('button').trigger('click')
28
- end
29
-
30
- expect(page).to have_content('Stock Transfer has been successfully updated')
31
- expect(page).to have_css(:div, '#finalize-stock-transfer-warning')
32
- expect(page).to have_content("NY")
33
- end
34
- end
35
-
36
- describe 'ship stock transfer' do
37
- let(:stock_transfer) { create(:stock_transfer_with_items) }
38
-
39
- before do
40
- stock_transfer.transfer_items do |item|
41
- item.update_attributes(expected_quantity: 1)
42
- end
43
- end
44
-
45
- describe "tracking info" do
46
- it 'adds tracking number' do
47
- visit spree.tracking_info_admin_stock_transfer_path(stock_transfer)
48
-
49
- fill_in 'stock_transfer_tracking_number', :with => "12345"
50
- click_button 'Save'
51
-
52
- expect(page).to have_content('Stock Transfer has been successfully updated')
53
- expect(stock_transfer.reload.tracking_number).to eq '12345'
54
- end
55
- end
56
-
57
- describe 'with enough stock' do
58
- it 'ships stock transfer' do
59
- visit spree.tracking_info_admin_stock_transfer_path(stock_transfer)
60
- click_link 'ship'
61
-
62
- first('#confirm-ship-link', visible: false).click
63
- expect(current_path).to eq spree.admin_stock_transfers_path
64
- expect(stock_transfer.reload.shipped_at).to_not be_nil
65
- end
66
- end
67
-
68
- describe 'without enough stock' do
69
- before do
70
- stock_transfer.transfer_items.each do |item|
71
- stock_transfer.source_location.stock_item(item.variant).set_count_on_hand(0)
72
- end
73
- end
74
-
75
- it 'does not ship stock transfer' do
76
- visit spree.tracking_info_admin_stock_transfer_path(stock_transfer)
77
-
78
- click_link 'ship'
79
-
80
- first('#confirm-ship-link', visible: false).click
81
- expect(current_path).to eq spree.tracking_info_admin_stock_transfer_path(stock_transfer)
82
- expect(stock_transfer.reload.shipped_at).to be_nil
83
- end
84
- end
85
- end
86
- end
@@ -1,82 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Store credits admin" do
4
- stub_authorization!
5
- let!(:admin_user) { create(:admin_user) }
6
- let!(:store_credit) { create(:store_credit) }
7
- let(:user) { store_credit.user }
8
-
9
- before do
10
- allow(Spree.user_class).to receive(:find_by).
11
- with(hash_including(:id)).
12
- and_return(store_credit.user)
13
- end
14
-
15
- describe "visiting the store credits page" do
16
- before do
17
- visit spree.admin_path
18
- click_link "Users"
19
- end
20
-
21
- it "should be on the store credits page" do
22
- click_link store_credit.user.email
23
- click_link "Store Credit"
24
- expect(page.current_path).to eq spree.admin_user_store_credits_path(store_credit.user)
25
-
26
- store_credit_table = page.find(".twelve.columns > table")
27
- expect(store_credit_table.all('tr').count).to eq 1
28
- expect(store_credit_table).to have_content(Spree::Money.new(store_credit.amount).to_s)
29
- expect(store_credit_table).to have_content(Spree::Money.new(store_credit.amount_used).to_s)
30
- expect(store_credit_table).to have_content(store_credit.category_name)
31
- expect(store_credit_table).to have_content(store_credit.created_by_email)
32
- end
33
- end
34
-
35
- describe "creating store credit" do
36
- before do
37
- visit spree.admin_path
38
- click_link "Users"
39
- click_link store_credit.user.email
40
- click_link "Store Credit"
41
- allow_any_instance_of(Spree::Admin::StoreCreditsController).to receive_messages(try_spree_current_user: admin_user)
42
- end
43
-
44
- it "should create store credit and associate it with the user" do
45
- click_link "Add store credit"
46
- page.fill_in "store_credit_amount", with: "102.00"
47
- select "Exchange", from: "store_credit_category_id"
48
- click_button "Create"
49
-
50
- expect(page.current_path).to eq spree.admin_user_store_credits_path(store_credit.user)
51
- store_credit_table = page.find(".twelve.columns > table")
52
- expect(store_credit_table.all('tr').count).to eq 2
53
- expect(Spree::StoreCredit.count).to eq 2
54
- end
55
- end
56
-
57
- describe "updating store credit" do
58
- let(:updated_amount) { "99.0" }
59
- let!(:update_reason) { create(:store_credit_update_reason) }
60
-
61
- before do
62
- visit spree.admin_path
63
- click_link "Users"
64
- click_link store_credit.user.email
65
- click_link "Store Credit"
66
- allow_any_instance_of(Spree::Admin::StoreCreditsController).to receive_messages(try_spree_current_user: admin_user)
67
- end
68
-
69
- it "updates the store credit's amount" do
70
- page.find(".twelve.columns > table td.actions a.fa-edit").click
71
- expect(page).to have_content 'Store credit history'
72
- click_link "Change amount"
73
- expect(page).to have_content 'Editing store credit amount'
74
- page.fill_in 'store_credit_amount', with: updated_amount
75
- page.select update_reason.name, from: 'update_reason_id'
76
- click_button "Update"
77
- expect(page.find('#sc-detail-table')).to have_content "$99.00"
78
- expect(store_credit.reload.amount.to_f).to eq updated_amount.to_f
79
- end
80
- end
81
-
82
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Taxonomies and taxons", :type => :feature do
4
- stub_authorization!
5
-
6
- it "admin should be able to edit taxon" do
7
-
8
- visit spree.new_admin_taxonomy_path
9
-
10
- fill_in "Name", :with => "Hello"
11
- click_button "Create"
12
-
13
- @taxonomy = Spree::Taxonomy.last
14
-
15
- visit spree.edit_admin_taxonomy_taxon_path(@taxonomy, @taxonomy.root.id)
16
-
17
- fill_in "taxon_name", :with => "Shirt"
18
- fill_in "taxon_description", :with => "Discover our new rails shirts"
19
-
20
- fill_in "permalink_part", :with => "shirt-rails"
21
- click_button "Update"
22
- expect(page).to have_content("Taxon \"Shirt\" has been successfully updated!")
23
- end
24
-
25
- it "can see taxon tree", js: true do
26
- taxonomy = create :taxonomy
27
-
28
- visit spree.edit_admin_taxonomy_path(taxonomy)
29
- expect(page).to have_content('Brand')
30
- end
31
- end
@@ -1,270 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Users', :type => :feature do
4
- stub_authorization!
5
- let!(:country) { create(:country) }
6
- let!(:user_a) { create(:user_with_addreses, email: 'a@example.com') }
7
- let!(:user_b) { create(:user_with_addreses, email: 'b@example.com') }
8
-
9
- let(:order) { create(:completed_order_with_totals, user: user_a, number: "R123") }
10
-
11
- let(:order_2) do
12
- create(:completed_order_with_totals, user: user_a, number: "R456").tap do |o|
13
- li = o.line_items.last
14
- li.update_column(:price, li.price + 10)
15
- end
16
- end
17
-
18
- let(:orders) { [order, order_2] }
19
-
20
- shared_examples_for 'a user page' do
21
- it 'has lifetime stats' do
22
- orders
23
- visit current_url # need to refresh after creating the orders for specs that did not require orders
24
- within("#user-lifetime-stats") do
25
- [:total_sales, :num_orders, :average_order_value, :member_since].each do |stat_name|
26
- expect(page).to have_content Spree.t(stat_name)
27
- end
28
- expect(page).to have_content (order.total + order_2.total)
29
- expect(page).to have_content orders.count
30
- expect(page).to have_content (orders.sum(&:total) / orders.count)
31
- expect(page).to have_content I18n.l(user_a.created_at.to_date)
32
- end
33
- end
34
-
35
- it 'can go back to the users list' do
36
- expect(page).to have_link Spree.t(:back_to_users_list), href: spree.admin_users_path
37
- end
38
-
39
- it 'can navigate to the account page' do
40
- expect(page).to have_link Spree.t(:"admin.user.account"), href: spree.edit_admin_user_path(user_a)
41
- end
42
-
43
- it 'can navigate to the order history' do
44
- expect(page).to have_link Spree.t(:"admin.user.orders"), href: spree.orders_admin_user_path(user_a)
45
- end
46
-
47
- it 'can navigate to the items purchased' do
48
- expect(page).to have_link Spree.t(:"admin.user.items"), href: spree.items_admin_user_path(user_a)
49
- end
50
- end
51
-
52
- shared_examples_for 'a sortable attribute' do
53
- before { click_link sort_link }
54
-
55
- it "can sort asc" do
56
- within_table(table_id) do
57
- expect(page).to have_text text_match_1
58
- expect(page).to have_text text_match_2
59
- expect(text_match_1).to appear_before text_match_2
60
- end
61
- end
62
-
63
- it "can sort desc" do
64
- within_table(table_id) do
65
- click_link sort_link
66
-
67
- expect(page).to have_text text_match_1
68
- expect(page).to have_text text_match_2
69
- expect(text_match_2).to appear_before text_match_1
70
- end
71
- end
72
- end
73
-
74
- before do
75
- visit spree.admin_path
76
- click_link 'Users'
77
- end
78
-
79
- context 'users index' do
80
-
81
- context "email" do
82
- it_behaves_like "a sortable attribute" do
83
- let(:text_match_1) { user_a.email }
84
- let(:text_match_2) { user_b.email }
85
- let(:table_id) { "listing_users" }
86
- let(:sort_link) { "users_email_title" }
87
- end
88
- end
89
-
90
- it 'displays the correct results for a user search' do
91
- fill_in 'q_email_cont', with: user_a.email
92
- click_button 'Search'
93
- within_table('listing_users') do
94
- expect(page).to have_text user_a.email
95
- expect(page).not_to have_text user_b.email
96
- end
97
- end
98
- end
99
-
100
- context 'editing users' do
101
- before { click_link user_a.email }
102
-
103
- it_behaves_like 'a user page'
104
-
105
- it 'can edit the user email' do
106
- fill_in 'user_email', with: 'a@example.com99'
107
- click_button 'Update'
108
-
109
- expect(user_a.reload.email).to eq 'a@example.com99'
110
- expect(page).to have_text 'Account updated'
111
- expect(find_field('user_email').value).to eq 'a@example.com99'
112
- end
113
-
114
- it 'can edit the user password' do
115
- fill_in 'user_password', with: 'welcome'
116
- fill_in 'user_password_confirmation', with: 'welcome'
117
- click_button 'Update'
118
-
119
- expect(page).to have_text 'Account updated'
120
- end
121
-
122
- it 'can edit user roles' do
123
- Spree::Role.create name: "admin"
124
- click_link user_a.email
125
-
126
- check 'user_spree_role_admin'
127
- click_button 'Update'
128
- expect(page).to have_text 'Account updated'
129
- expect(find_field('user_spree_role_admin')['checked']).to be true
130
- end
131
-
132
- it 'can edit user shipping address' do
133
- click_link "Addresses"
134
-
135
- within("#admin_user_edit_addresses") do
136
- fill_in "user_ship_address_attributes_address1", with: "1313 Mockingbird Ln"
137
- click_button 'Update'
138
- expect(find_field('user_ship_address_attributes_address1').value).to eq "1313 Mockingbird Ln"
139
- end
140
-
141
- expect(user_a.reload.ship_address.address1).to eq "1313 Mockingbird Ln"
142
- end
143
-
144
- it 'can edit user billing address' do
145
- click_link "Addresses"
146
-
147
- within("#admin_user_edit_addresses") do
148
- fill_in "user_bill_address_attributes_address1", with: "1313 Mockingbird Ln"
149
- click_button 'Update'
150
- expect(find_field('user_bill_address_attributes_address1').value).to eq "1313 Mockingbird Ln"
151
- end
152
-
153
- expect(user_a.reload.bill_address.address1).to eq "1313 Mockingbird Ln"
154
- end
155
-
156
- context 'no api key exists' do
157
- it 'can generate a new api key' do
158
- within("#admin_user_edit_api_key") do
159
- expect(user_a.spree_api_key).to be_blank
160
- click_button Spree.t('generate_key', :scope => 'api')
161
- end
162
-
163
- expect(user_a.reload.spree_api_key).to be_present
164
- end
165
- end
166
-
167
- context 'an api key exists' do
168
- before do
169
- user_a.generate_spree_api_key!
170
- expect(user_a.reload.spree_api_key).to be_present
171
- visit current_path
172
- end
173
-
174
- it 'can clear an api key' do
175
- within("#admin_user_edit_api_key") do
176
- click_button Spree.t('clear_key', :scope => 'api')
177
- end
178
-
179
- expect(user_a.reload.spree_api_key).to be_blank
180
- expect { find("#current-api-key") }.to raise_error Capybara::ElementNotFound
181
- end
182
-
183
- it 'can regenerate an api key' do
184
- old_key = user_a.spree_api_key
185
-
186
- within("#admin_user_edit_api_key") do
187
- click_button Spree.t('regenerate_key', :scope => 'api')
188
- end
189
-
190
- expect(user_a.reload.spree_api_key).to be_present
191
- expect(user_a.reload.spree_api_key).not_to eq old_key
192
- end
193
- end
194
- end
195
-
196
- context 'order history with sorting' do
197
-
198
- before do
199
- orders
200
- click_link user_a.email
201
- within("#sidebar") { click_link Spree.t(:"admin.user.orders") }
202
- end
203
-
204
- it_behaves_like 'a user page'
205
-
206
- context "completed_at" do
207
- it_behaves_like "a sortable attribute" do
208
- let(:text_match_1) { I18n.l(order.completed_at.to_date) }
209
- let(:text_match_2) { I18n.l(order_2.completed_at.to_date) }
210
- let(:table_id) { "listing_orders" }
211
- let(:sort_link) { "orders_completed_at_title" }
212
- end
213
- end
214
-
215
- [:number, :state, :total].each do |attr|
216
- context attr do
217
- it_behaves_like "a sortable attribute" do
218
- let(:text_match_1) { order.send(attr).to_s }
219
- let(:text_match_2) { order_2.send(attr).to_s }
220
- let(:table_id) { "listing_orders" }
221
- let(:sort_link) { "orders_#{attr}_title" }
222
- end
223
- end
224
- end
225
- end
226
-
227
- context 'items purchased with sorting' do
228
-
229
- before do
230
- orders
231
- click_link user_a.email
232
- within("#sidebar") { click_link Spree.t(:"admin.user.items") }
233
- end
234
-
235
- it_behaves_like 'a user page'
236
-
237
- context "completed_at" do
238
- it_behaves_like "a sortable attribute" do
239
- let(:text_match_1) { I18n.l(order.completed_at.to_date) }
240
- let(:text_match_2) { I18n.l(order_2.completed_at.to_date) }
241
- let(:table_id) { "listing_items" }
242
- let(:sort_link) { "orders_completed_at_title" }
243
- end
244
- end
245
-
246
- [:number, :state].each do |attr|
247
- context attr do
248
- it_behaves_like "a sortable attribute" do
249
- let(:text_match_1) { order.send(attr).to_s }
250
- let(:text_match_2) { order_2.send(attr).to_s }
251
- let(:table_id) { "listing_items" }
252
- let(:sort_link) { "orders_#{attr}_title" }
253
- end
254
- end
255
- end
256
-
257
- it "has item attributes" do
258
- items = order.line_items | order_2.line_items
259
- expect(page).to have_table 'listing_items'
260
- within_table('listing_items') do
261
- items.each do |item|
262
- expect(page).to have_selector(".item-name", text: item.product.name)
263
- expect(page).to have_selector(".item-price", text: item.single_money.to_html)
264
- expect(page).to have_selector(".item-quantity", text: item.quantity)
265
- expect(page).to have_selector(".item-total", text: item.money.to_html)
266
- end
267
- end
268
- end
269
- end
270
- end