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,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe "States", type: :feature do
4
+ stub_authorization!
5
+
6
+ let!(:country) { create(:country) }
7
+
8
+ before(:each) do
9
+ @hungary = Spree::Country.create!(name: "Hungary", iso_name: "Hungary")
10
+ end
11
+
12
+ def go_to_states_page
13
+ visit spree.admin_country_states_path(country)
14
+ expect(page).to have_selector('#new_state_link')
15
+ page.execute_script('$.fx.off = true')
16
+ end
17
+
18
+ context "admin visiting states listing" do
19
+ let!(:state) { create(:state, country: country) }
20
+
21
+ it "should correctly display the states" do
22
+ visit spree.admin_country_states_path(country)
23
+ expect(page).to have_content(state.name)
24
+ end
25
+ end
26
+
27
+ context "creating and editing states" do
28
+ it "should allow an admin to edit existing states", js: true do
29
+ go_to_states_page
30
+ set_select2_field("country", country.id)
31
+
32
+ click_link "new_state_link"
33
+ fill_in "state_name", with: "Calgary"
34
+ fill_in "Abbreviation", with: "CL"
35
+ click_button "Create"
36
+ expect(page).to have_content("successfully created!")
37
+ expect(page).to have_content("Calgary")
38
+ end
39
+
40
+ it "should allow an admin to create states for non default countries", js: true do
41
+ go_to_states_page
42
+ set_select2_field "#country", @hungary.id
43
+ # Just so the change event actually gets triggered in this spec
44
+ # It is definitely triggered in the "real world"
45
+ page.execute_script("$('#country').change();")
46
+
47
+ click_link "new_state_link"
48
+ fill_in "state_name", with: "Pest megye"
49
+ fill_in "Abbreviation", with: "PE"
50
+ click_button "Create"
51
+ expect(page).to have_content("successfully created!")
52
+ expect(page).to have_content("Pest megye")
53
+ expect(find("#s2id_country span").text).to eq("Hungary")
54
+ end
55
+
56
+ it "should show validation errors", js: true do
57
+ go_to_states_page
58
+ set_select2_field("country", country.id)
59
+
60
+ click_link "new_state_link"
61
+
62
+ fill_in "state_name", with: ""
63
+ fill_in "Abbreviation", with: ""
64
+ click_button "Create"
65
+ expect(page).to have_content("Name can't be blank")
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Stock Locations", type: :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ country = create(:country)
8
+ visit spree.admin_stock_locations_path
9
+ end
10
+
11
+ it "can create a new stock location" do
12
+ click_link "New Stock Location"
13
+ fill_in "Name", with: "London"
14
+ check "Active"
15
+ click_button "Create"
16
+
17
+ expect(page).to have_content("successfully created")
18
+ expect(page).to have_content("London")
19
+ end
20
+
21
+ it "can delete an existing stock location", js: true do
22
+ location = create(:stock_location)
23
+ visit current_path
24
+
25
+ expect(find('#listing_stock_locations')).to have_content("NY Warehouse")
26
+ accept_alert do
27
+ click_icon :delete
28
+ end
29
+ # Wait for API request to complete.
30
+ wait_for_ajax
31
+ visit current_path
32
+ expect(page).to have_content("No Stock Locations found")
33
+ end
34
+
35
+ it "can update an existing stock location", js: true do
36
+ create(:stock_location)
37
+ visit current_path
38
+
39
+ expect(page).to have_content("NY Warehouse")
40
+
41
+ click_icon :edit
42
+ fill_in "Name", with: "London"
43
+ click_button "Update"
44
+
45
+ expect(page).to have_content("successfully updated")
46
+ expect(page).to have_content("London")
47
+ end
48
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Store Credit Categories", type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ visit spree.admin_path
8
+ click_link "Configuration"
9
+ end
10
+
11
+ context "admin visiting store credit categories list" do
12
+ it "should display existing store credit categories" do
13
+ create(:store_credit_category)
14
+ click_link "Store Credit Categories"
15
+
16
+ within_row(1) { expect(page).to have_content("Exchange") }
17
+ end
18
+ end
19
+
20
+ context "admin creating a new store credit category" do
21
+ before(:each) do
22
+ click_link "Store Credit Categories"
23
+ click_link "admin_new_store_credit_category_link"
24
+ end
25
+
26
+ it "should be able to create a new store credit category" do
27
+ expect(page).to have_content("New Store Credit Category")
28
+ fill_in "store_credit_category_name", with: "Return"
29
+ click_button "Create"
30
+ expect(page).to have_content("successfully created!")
31
+ end
32
+
33
+ it "should show validation errors if there are any" do
34
+ click_button "Create"
35
+ expect(page).to have_content("Name can't be blank")
36
+ end
37
+ end
38
+
39
+ context "admin editing a store credit category" do
40
+ it "should be able to update an existing store credit category" do
41
+ create(:store_credit_category)
42
+ click_link "Store Credit Categories"
43
+ within_row(1) { click_icon :edit }
44
+ fill_in "store_credit_category_name", with: "Return"
45
+ click_button "Update"
46
+ expect(page).to have_content("successfully updated!")
47
+ expect(page).to have_content("Return")
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Tax Categories", type: :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ visit spree.admin_path
8
+ click_link "Configuration"
9
+ end
10
+
11
+ context "admin visiting tax categories list" do
12
+ it "should display the existing tax categories" do
13
+ create(:tax_category, name: "Clothing", tax_code: "CL001", description: "For Clothing")
14
+ click_link "Tax Categories"
15
+ within("h1") { expect(page).to have_content("Tax Categories") }
16
+ within_row(1) do
17
+ expect(column_text(1)).to eq("Clothing")
18
+ expect(column_text(2)).to eq("CL001")
19
+ expect(column_text(3)).to eq("For Clothing")
20
+ expect(column_text(4)).to eq("No")
21
+ end
22
+ end
23
+ end
24
+
25
+ context "admin creating new tax category" do
26
+ before(:each) do
27
+ click_link "Tax Categories"
28
+ click_link "admin_new_tax_categories_link"
29
+ end
30
+
31
+ it "should be able to create new tax category" do
32
+ expect(page).to have_content("New Tax Category")
33
+ fill_in "tax_category_name", with: "sports goods"
34
+ fill_in "tax_category_description", with: "sports goods desc"
35
+ click_button "Create"
36
+ expect(page).to have_content("successfully created!")
37
+ end
38
+
39
+ it "should show validation errors if there are any" do
40
+ click_button "Create"
41
+ expect(page).to have_content("Name can't be blank")
42
+ end
43
+ end
44
+
45
+ context "admin editing a tax category" do
46
+ it "should be able to update an existing tax category", js: true do
47
+ create(:tax_category)
48
+ click_link "Tax Categories"
49
+ within_row(1) { click_icon :edit }
50
+ fill_in "tax_category_description", with: "desc 99"
51
+ click_button "Update"
52
+ expect(page).to have_content("successfully updated!")
53
+ expect(page).to have_content("desc 99")
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Tax Rates", type: :feature do
4
+ stub_authorization!
5
+
6
+ let!(:tax_rate) { create(:tax_rate, calculator: stub_model(Spree::Calculator)) }
7
+
8
+ # Regression test for #1422
9
+ it "can create a new tax rate" do
10
+ visit spree.admin_path
11
+ click_link "Configuration"
12
+ click_link "Tax Rates"
13
+ click_link "New Tax Rate"
14
+ fill_in "Rate", with: "0.05"
15
+ click_button "Create"
16
+ expect(page).to have_content("Tax Rate has been successfully created!")
17
+ end
18
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Zones", type: :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ Spree::Zone.delete_all
8
+ visit spree.admin_path
9
+ click_link "Configuration"
10
+ end
11
+
12
+ context "show" do
13
+ it "should display existing zones" do
14
+ create(:zone, name: "eastern", description: "zone is eastern")
15
+ create(:zone, name: "western", description: "cool san fran")
16
+ click_link "Zones"
17
+
18
+ within_row(1) { expect(page).to have_content("eastern") }
19
+ within_row(2) { expect(page).to have_content("western") }
20
+
21
+ click_link "zones_order_by_description_title"
22
+
23
+ within_row(1) { expect(page).to have_content("western") }
24
+ within_row(2) { expect(page).to have_content("eastern") }
25
+ end
26
+ end
27
+
28
+ context "create" do
29
+ it "should allow an admin to create a new zone" do
30
+ click_link "Zones"
31
+ click_link "admin_new_zone_link"
32
+ expect(page).to have_content("New Zone")
33
+ fill_in "zone_name", with: "japan"
34
+ fill_in "zone_description", with: "japanese time zone"
35
+ click_button "Create"
36
+ expect(page).to have_content("successfully created!")
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Homepage", type: :feature do
4
+
5
+ context 'as admin user' do
6
+ stub_authorization!
7
+
8
+ context "visiting the homepage" do
9
+ before(:each) do
10
+ visit spree.admin_path
11
+ end
12
+
13
+ it "has header text 'Orders'" do
14
+ within('h1') { expect(page).to have_content("Orders") }
15
+ end
16
+
17
+ it "has a link to overview" do
18
+ within("header") { page.find(:xpath, "//a[@href='/admin']") }
19
+ end
20
+
21
+ it "has a link to orders" do
22
+ page.find_link("Orders")['/admin/orders']
23
+ end
24
+
25
+ it "has a link to products" do
26
+ page.find_link("Products")['/admin/products']
27
+ end
28
+
29
+ it "has a link to reports" do
30
+ page.find_link("Reports")['/admin/reports']
31
+ end
32
+
33
+ it "has a link to configuration" do
34
+ page.find_link("Configuration")['/admin/configurations']
35
+ end
36
+
37
+ it "has a link to return authorizations" do
38
+ within('.sidebar') { page.find_link("Return Authorizations")['/admin/return_authorizations'] }
39
+ end
40
+
41
+ it "has a link to customer returns" do
42
+ within('.sidebar') { page.find_link("Customer Returns")['/admin/customer_returns'] }
43
+ end
44
+ end
45
+
46
+ context "visiting the products tab" do
47
+ before(:each) do
48
+ visit spree.admin_products_path
49
+ end
50
+
51
+ it "has a link to products" do
52
+ within('.sidebar') { page.find_link("Products")['/admin/products'] }
53
+ end
54
+
55
+ it "has a link to option types" do
56
+ within('.sidebar') { page.find_link("Option Types")['/admin/option_types'] }
57
+ end
58
+
59
+ it "has a link to properties" do
60
+ within('.sidebar') { page.find_link("Properties")['/admin/properties'] }
61
+ end
62
+
63
+ it "has a link to prototypes" do
64
+ within('.sidebar') { page.find_link("Prototypes")['/admin/prototypes'] }
65
+ end
66
+ end
67
+ end
68
+
69
+ context 'as fakedispatch user' do
70
+
71
+ before do
72
+ allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
73
+ end
74
+
75
+ custom_authorization! do |user|
76
+ can [:admin, :edit, :index, :read], Spree::Order
77
+ end
78
+
79
+ it 'only displays tabs fakedispatch has access to' do
80
+ visit spree.admin_path
81
+ expect(page).to have_link('Orders')
82
+ expect(page).not_to have_link('Products')
83
+ expect(page).not_to have_link('Promotions')
84
+ expect(page).not_to have_link('Reports')
85
+ expect(page).not_to have_link('Configurations')
86
+ end
87
+ end
88
+
89
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe "setting locale", type: :feature do
4
+ stub_authorization!
5
+
6
+ before do
7
+ I18n.locale = I18n.default_locale
8
+ I18n.backend.store_translations(:fr,
9
+ date: {
10
+ month_names: [],
11
+ },
12
+ spree: {
13
+ admin: {
14
+ tab: { orders: "Ordres" }
15
+ },
16
+ listing_orders: "Ordres",
17
+ })
18
+ Spree::Backend::Config[:locale] = "fr"
19
+ end
20
+
21
+ after do
22
+ I18n.locale = I18n.default_locale
23
+ Spree::Backend::Config[:locale] = "en"
24
+ end
25
+
26
+ it "should be in french" do
27
+ visit spree.admin_path
28
+ click_link "Ordres"
29
+ expect(page).to have_content("Ordres")
30
+ end
31
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Adjustments Promotions", type: :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ promotion = create(:promotion_with_item_adjustment,
8
+ name: "$10 off",
9
+ path: 'test',
10
+ code: "10_off",
11
+ starts_at: 1.day.ago,
12
+ expires_at: 1.day.from_now,
13
+ adjustment_rate: 10)
14
+
15
+ order = create(:order_with_totals)
16
+ line_item = order.line_items.first
17
+ # so we can be sure of a determinate price in our assertions
18
+ line_item.update_column(:price, 10)
19
+
20
+ visit spree.admin_order_adjustments_path(order)
21
+ end
22
+
23
+ context "admin adding a promotion" do
24
+ context "successfully" do
25
+ it "should create a new adjustment", js: true do
26
+ fill_in "coupon_code", with: "10_off"
27
+ click_button "Add Coupon Code"
28
+ expect(page).to have_content("$10 off")
29
+ expect(page).to have_content("-$10.00")
30
+ end
31
+ end
32
+
33
+ context "for non-existing promotion" do
34
+ it "should show an error message", js: true do
35
+ fill_in "coupon_code", with: "does_not_exist"
36
+ click_button "Add Coupon Code"
37
+ expect(page).to have_content("doesn't exist.")
38
+ end
39
+ end
40
+
41
+ context "for already applied promotion" do
42
+ it "should show an error message", js: true do
43
+ fill_in "coupon_code", with: "10_off"
44
+ click_button "Add Coupon Code"
45
+ expect(page).to have_content('-$10.00')
46
+
47
+ fill_in "coupon_code", with: "10_off"
48
+ click_button "Add Coupon Code"
49
+ expect(page).to have_content("already been applied")
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,124 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Adjustments", type: :feature do
4
+ stub_authorization!
5
+
6
+ let!(:order) { create(:completed_order_with_totals, line_items_count: 5) }
7
+ let!(:line_item) do
8
+ line_item = order.line_items.first
9
+ # so we can be sure of a determinate price in our assertions
10
+ line_item.update_column(:price, 10)
11
+ line_item
12
+ end
13
+
14
+ let!(:tax_adjustment) do
15
+ create(:tax_adjustment,
16
+ adjustable: line_item,
17
+ state: 'closed',
18
+ order: order,
19
+ label: "VAT 5%",
20
+ amount: 10)
21
+ end
22
+
23
+ let!(:adjustment) { order.adjustments.create!(order: order, label: 'Rebate', amount: 10) }
24
+
25
+ before(:each) do
26
+ # To ensure the order totals are correct
27
+ order.update_totals
28
+ order.persist_totals
29
+
30
+ visit spree.admin_orders_path
31
+ within_row(1) { click_on order.number }
32
+ click_on "Adjustments"
33
+ end
34
+
35
+ after :each do
36
+ order.reload.all_adjustments.each do |adjustment|
37
+ expect(adjustment.order_id).to equal(order.id)
38
+ end
39
+ end
40
+
41
+ context "admin managing adjustments" do
42
+ it "should display the correct values for existing order adjustments" do
43
+ within_row(1) do
44
+ expect(column_text(2)).to eq("VAT 5%")
45
+ expect(column_text(3)).to eq("$10.00")
46
+ end
47
+ end
48
+
49
+ it "only shows eligible adjustments" do
50
+ expect(page).not_to have_content("ineligible")
51
+ end
52
+ end
53
+
54
+ context "admin creating a new adjustment" do
55
+ before(:each) do
56
+ click_link "New Adjustment"
57
+ end
58
+
59
+ context "successfully" do
60
+ it "should create a new adjustment" do
61
+ fill_in "adjustment_amount", with: "10"
62
+ fill_in "adjustment_label", with: "rebate"
63
+ click_button "Continue"
64
+ expect(page).to have_content("successfully created!")
65
+ expect(page).to have_content("Total: $80.00")
66
+ end
67
+ end
68
+
69
+ context "with validation errors" do
70
+ it "should not create a new adjustment" do
71
+ fill_in "adjustment_amount", with: ""
72
+ fill_in "adjustment_label", with: ""
73
+ click_button "Continue"
74
+ expect(page).to have_content("Label can't be blank")
75
+ expect(page).to have_content("Amount is not a number")
76
+ end
77
+ end
78
+ end
79
+
80
+ context "admin editing an adjustment", js: true do
81
+
82
+ before(:each) do
83
+ within_row(2) { click_icon :edit }
84
+ end
85
+
86
+ context "successfully" do
87
+ it "should update the adjustment" do
88
+ fill_in "adjustment_amount", with: "99"
89
+ fill_in "adjustment_label", with: "rebate 99"
90
+ click_button "Continue"
91
+ expect(page).to have_content("successfully updated!")
92
+ expect(page).to have_content("rebate 99")
93
+ within(".adjustments") do
94
+ expect(page).to have_content("$99.00")
95
+ end
96
+
97
+ expect(page).to have_content("Total: $159.00")
98
+ end
99
+ end
100
+
101
+ context "with validation errors" do
102
+ it "should not update the adjustment" do
103
+ fill_in "adjustment_amount", with: ""
104
+ fill_in "adjustment_label", with: ""
105
+ click_button "Continue"
106
+ expect(page).to have_content("Label can't be blank")
107
+ expect(page).to have_content("Amount is not a number")
108
+ end
109
+ end
110
+ end
111
+
112
+ context "deleting an adjustment" do
113
+ it "should update the total", js: true do
114
+ accept_alert do
115
+ within_row(2) do
116
+ click_icon(:delete)
117
+ end
118
+ end
119
+
120
+ wait_for_ajax
121
+ expect(page).to have_content(/Total: ?\$170\.00/)
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Cancelling + Resuming", type: :feature do
4
+
5
+ stub_authorization!
6
+
7
+ let(:user) { double(id: 123, has_spree_role?: true, spree_api_key: 'fake') }
8
+
9
+ before do
10
+ allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(user)
11
+ end
12
+
13
+ let(:order) do
14
+ order = create(:order)
15
+ order.update_columns({
16
+ state: 'complete',
17
+ completed_at: Time.current
18
+ })
19
+ order
20
+ end
21
+
22
+ it "can cancel an order" do
23
+ visit spree.edit_admin_order_path(order.number)
24
+ click_button 'Cancel'
25
+ within(".additional-info") do
26
+ within(".state") do
27
+ expect(page).to have_content("canceled")
28
+ end
29
+ end
30
+ end
31
+
32
+ context "with a cancelled order" do
33
+ before do
34
+ order.update_column(:state, 'canceled')
35
+ end
36
+
37
+ it "can resume an order" do
38
+ visit spree.edit_admin_order_path(order.number)
39
+ click_button 'Resume'
40
+ within(".additional-info") do
41
+ within(".state") do
42
+ expect(page).to have_content("resumed")
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end