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,66 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- describe 'Product Details', :type => :feature do
5
- stub_authorization!
6
-
7
- context 'editing a product' do
8
- it 'should list the product details' do
9
- create(:product, :name => 'Bún thịt nướng', :sku => 'A100',
10
- :description => 'lorem ipsum', :available_on => '2013-08-14 01:02:03')
11
-
12
- visit spree.admin_path
13
- click_link 'Products'
14
- within_row(1) { click_icon :edit }
15
-
16
- click_link 'Product Details'
17
-
18
- expect(find('.page-title').text.strip).to eq('Editing Product “Bún thịt nướng”')
19
- expect(find('input#product_name').value).to eq('Bún thịt nướng')
20
- expect(find('input#product_slug').value).to eq('bun-th-t-n-ng')
21
- expect(find('textarea#product_description').text.strip).to eq('lorem ipsum')
22
- expect(find('input#product_price').value).to eq('19.99')
23
- expect(find('input#product_cost_price').value).to eq('17.00')
24
- expect(find('input#product_available_on').value).to eq("2013/08/14")
25
- expect(find('input#product_sku').value).to eq('A100')
26
- end
27
-
28
- it "should handle slug changes" do
29
- create(:product, :name => 'Bún thịt nướng', :sku => 'A100',
30
- :description => 'lorem ipsum', :available_on => '2011-01-01 01:01:01')
31
-
32
- visit spree.admin_path
33
- click_link 'Products'
34
- within('table.index tbody tr:nth-child(1)') do
35
- click_icon(:edit)
36
- end
37
-
38
- fill_in "product_slug", :with => 'random-slug-value'
39
- click_button "Update"
40
- expect(page).to have_content("successfully updated!")
41
-
42
- fill_in "product_slug", :with => ''
43
- click_button "Update"
44
- within('#product_slug_field') { expect(page).to have_content("is too short") }
45
-
46
- fill_in "product_slug", :with => 'another-random-slug-value'
47
- click_button "Update"
48
- expect(page).to have_content("successfully updated!")
49
- end
50
- end
51
-
52
- # Regression test for #3385
53
- context "deleting a product", :js => true do
54
- it "is still able to find the master variant" do
55
- create(:product)
56
-
57
- visit spree.admin_products_path
58
- within_row(1) do
59
- accept_alert do
60
- click_icon :trash
61
- end
62
- end
63
- wait_for_ajax
64
- end
65
- end
66
- end
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Product Taxons", :type => :feature do
4
- stub_authorization!
5
-
6
- after do
7
- Capybara.ignore_hidden_elements = true
8
- end
9
-
10
- before do
11
- Capybara.ignore_hidden_elements = false
12
- end
13
-
14
- context "managing taxons", js: true do
15
- def selected_taxons
16
- find("#product_taxon_ids").value.split(',').map(&:to_i).uniq
17
- end
18
-
19
- let(:product) { create(:product) }
20
-
21
- it "should allow an admin to manage taxons" do
22
- taxon_1 = create(:taxon)
23
- taxon_2 = create(:taxon, name: 'Clothing')
24
- product.taxons << taxon_1
25
-
26
- visit spree.admin_path
27
- click_link "Products"
28
- within("table.index") do
29
- click_icon :edit
30
- end
31
-
32
- expect(find(".select2-search-choice").text).to eq(taxon_1.name)
33
- expect(selected_taxons).to match_array([taxon_1.id])
34
-
35
- select2_search "Clothing", :from => "Taxons"
36
- click_button "Update"
37
- expect(selected_taxons).to match_array([taxon_1.id, taxon_2.id])
38
-
39
- # Regression test for #2139
40
- expect(page).to have_css(".select2-search-choice", text: taxon_1.name)
41
- expect(page).to have_css(".select2-search-choice", text: taxon_2.name)
42
- end
43
-
44
- context "with an XSS attempt" do
45
- let(:taxon_name) { %(<script>throw("XSS")</script>) }
46
- let!(:taxon) { create(:taxon, name: taxon_name) }
47
- it "displays the escaped HTML without executing it" do
48
- visit spree.edit_admin_product_path(product)
49
-
50
- select2_search "<script>", from: "Taxons"
51
-
52
- expect(page).to have_content(taxon_name)
53
- end
54
- end
55
- end
56
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Product Variants", :type => :feature do
4
- stub_authorization!
5
-
6
- before(:each) do
7
- visit spree.admin_path
8
- end
9
-
10
- context "editing variant option types", :js => true do
11
- let!(:product) { create(:product) }
12
-
13
- it "should allow an admin to create option types for a variant" do
14
- click_link "Products"
15
-
16
- within_row(1) { click_icon :edit }
17
-
18
- within('#sidebar') { click_link "Variants" }
19
- expect(page).to have_content("TO ADD VARIANTS, YOU MUST FIRST DEFINE")
20
- end
21
-
22
- it "allows admin to create a variant if there are option types" do
23
- click_link "Products"
24
- click_link "Option Types"
25
- click_link "new_option_type_link"
26
- fill_in "option_type_name", :with => "shirt colors"
27
- fill_in "option_type_presentation", :with => "colors"
28
- click_button "Create"
29
- expect(page).to have_content("successfully created!")
30
-
31
- page.find('#option_type_option_values_attributes_0_name').set('color')
32
- page.find('#option_type_option_values_attributes_0_presentation').set('black')
33
- click_button "Update"
34
- expect(page).to have_content("successfully updated!")
35
-
36
- visit spree.admin_path
37
- click_link "Products"
38
- within('table.index tbody tr:nth-child(1)') do
39
- click_icon :edit
40
- end
41
-
42
- select2_search "shirt", :from => "Option Types"
43
- click_button "Update"
44
- expect(page).to have_content("successfully updated!")
45
-
46
- within('#sidebar') { click_link "Variants" }
47
- click_link "New Variant"
48
-
49
- targetted_select2 "black", :from => "#s2id_variant_option_value_ids"
50
- fill_in "variant_sku", :with => "A100"
51
- click_button "Create"
52
- expect(page).to have_content("successfully created!")
53
-
54
- within(".index") do
55
- expect(page).to have_content("19.99")
56
- expect(page).to have_content("black")
57
- expect(page).to have_content("A100")
58
- end
59
- end
60
- end
61
- end
@@ -1,114 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Option Types", :type => :feature do
4
- stub_authorization!
5
-
6
- before(:each) do
7
- visit spree.admin_path
8
- click_link "Products"
9
- end
10
-
11
- context "listing option types" do
12
- it "should list existing option types" do
13
- create(:option_type, :name => "tshirt-color", :presentation => "Color")
14
- create(:option_type, :name => "tshirt-size", :presentation => "Size")
15
-
16
- click_link "Option Types"
17
- within("table#listing_option_types") do
18
- expect(page).to have_content("Color")
19
- expect(page).to have_content("tshirt-color")
20
- expect(page).to have_content("Size")
21
- expect(page).to have_content("tshirt-size")
22
- end
23
- end
24
- end
25
-
26
- context "creating a new option type" do
27
- it "should allow an admin to create a new option type", :js => true do
28
- click_link "Option Types"
29
- click_link "new_option_type_link"
30
- expect(page).to have_content("NEW OPTION TYPE")
31
- fill_in "option_type_name", :with => "shirt colors"
32
- fill_in "option_type_presentation", :with => "colors"
33
- click_button "Create"
34
- expect(page).to have_content("successfully created!")
35
-
36
- page.find('#option_type_option_values_attributes_0_name').set('color')
37
- page.find('#option_type_option_values_attributes_0_presentation').set('black')
38
-
39
- click_button "Update"
40
- expect(page).to have_content("successfully updated!")
41
- end
42
- end
43
-
44
- context "editing an existing option type" do
45
- it "should allow an admin to update an existing option type" do
46
- create(:option_type, :name => "tshirt-color", :presentation => "Color")
47
- create(:option_type, :name => "tshirt-size", :presentation => "Size")
48
- click_link "Option Types"
49
- within('table#listing_option_types') { click_link "Edit" }
50
- fill_in "option_type_name", :with => "foo-size 99"
51
- click_button "Update"
52
- expect(page).to have_content("successfully updated!")
53
- expect(page).to have_content("foo-size 99")
54
- end
55
- end
56
-
57
- # Regression test for #2277
58
- it "can remove an option value from an option type", :js => true do
59
- create(:option_value)
60
- click_link "Option Types"
61
- within('table#listing_option_types') { click_icon :edit }
62
- expect(page).to have_content("Editing Option Type")
63
- expect(all("tbody#option_values tr").count).to eq(1)
64
- within("tbody#option_values") do
65
- find('.spree_remove_fields').click
66
- end
67
- # Assert that the field is hidden automatically
68
- expect(all("tbody#option_values tr").select(&:visible?).count).to eq(0)
69
-
70
- # Then assert that on a page refresh that it's still not visible
71
- visit page.current_url
72
- # What *is* visible is a new option value field, with blank values
73
- # Sometimes the page doesn't load before the all check is done
74
- # lazily finding the element gives the page 10 seconds
75
- expect(page).to have_css("tbody#option_values")
76
- all("tbody#option_values tr input").all? { |input| input.value.blank? }
77
- end
78
-
79
- # Regression test for #3204
80
- it "can remove a non-persisted option value from an option type", :js => true do
81
- create(:option_type)
82
- click_link "Option Types"
83
- within('table#listing_option_types') { click_icon :edit }
84
-
85
- wait_for_ajax
86
- page.find("tbody#option_values", :visible => true)
87
-
88
- expect(all("tbody#option_values tr").select(&:visible?).count).to eq(1)
89
-
90
- # Add a new option type
91
- click_link "Add Option Value"
92
- expect(all("tbody#option_values tr").select(&:visible?).count).to eq(2)
93
-
94
- # Remove default option type
95
- within("tbody#option_values") do
96
- find('.fa-trash').click
97
- end
98
- # Check that there was no HTTP request
99
- expect(all("div#progress[style]").count).to eq(0)
100
- # Assert that the field is hidden automatically
101
- expect(all("tbody#option_values tr").select(&:visible?).count).to eq(1)
102
-
103
- # Remove added option type
104
- within("tbody#option_values") do
105
- find('.fa-trash').click
106
- end
107
- # Check that there was no HTTP request
108
- expect(all("div#progress[style]").count).to eq(0)
109
- # Assert that the field is hidden automatically
110
- expect(all("tbody#option_values tr").select(&:visible?).count).to eq(0)
111
-
112
- end
113
-
114
- end
@@ -1,392 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe "Products", :type => :feature do
5
- context "as admin user" do
6
- stub_authorization!
7
-
8
- before(:each) do
9
- visit spree.admin_path
10
- end
11
-
12
- def build_option_type_with_values(name, values)
13
- ot = FactoryGirl.create(:option_type, :name => name)
14
- values.each do |val|
15
- ot.option_values.create(:name => val.downcase, :presentation => val)
16
- end
17
- ot
18
- end
19
-
20
- context "listing products" do
21
- context "sorting" do
22
- before do
23
- create(:product, :name => 'apache baseball cap', :price => 10)
24
- create(:product, :name => 'zomg shirt', :price => 5)
25
- end
26
-
27
- it "should list existing products with correct sorting by name" do
28
- click_link "Products"
29
- # Name ASC
30
- within_row(1) { expect(page).to have_content('apache baseball cap') }
31
- within_row(2) { expect(page).to have_content("zomg shirt") }
32
-
33
- # Name DESC
34
- click_link "admin_products_listing_name_title"
35
- within_row(1) { expect(page).to have_content("zomg shirt") }
36
- within_row(2) { expect(page).to have_content('apache baseball cap') }
37
- end
38
-
39
- it "should list existing products with correct sorting by price" do
40
- click_link "Products"
41
-
42
- # Name ASC (default)
43
- within_row(1) { expect(page).to have_content('apache baseball cap') }
44
- within_row(2) { expect(page).to have_content("zomg shirt") }
45
-
46
- # Price DESC
47
- click_link "admin_products_listing_price_title"
48
- within_row(1) { expect(page).to have_content("zomg shirt") }
49
- within_row(2) { expect(page).to have_content('apache baseball cap') }
50
- end
51
- end
52
-
53
- context "currency displaying" do
54
- context "using Russian Rubles" do
55
- before do
56
- Spree::Config[:currency] = "RUB"
57
- end
58
-
59
- let!(:product) do
60
- create(:product, :name => "Just a product", :price => 19.99)
61
- end
62
-
63
- # Regression test for #2737
64
- context "uses руб as the currency symbol" do
65
- it "on the products listing page" do
66
- visit spree.admin_products_path
67
- within_row(1) { expect(page).to have_content("19.99 ₽") }
68
- end
69
- end
70
- end
71
- end
72
- end
73
-
74
- context "searching products" do
75
- it "should be able to search deleted products", :js => true do
76
- create(:product, :name => 'apache baseball cap', :deleted_at => "2011-01-06 18:21:13")
77
- create(:product, :name => 'zomg shirt')
78
-
79
- click_link "Products"
80
- expect(page).to have_content("zomg shirt")
81
- expect(page).not_to have_content("apache baseball cap")
82
- check "Show Deleted"
83
- click_icon :search
84
- expect(page).to have_content("zomg shirt")
85
- expect(page).to have_content("apache baseball cap")
86
- uncheck "Show Deleted"
87
- click_icon :search
88
- expect(page).to have_content("zomg shirt")
89
- expect(page).not_to have_content("apache baseball cap")
90
- end
91
-
92
- it "should be able to search products by their properties" do
93
- create(:product, :name => 'apache baseball cap', :sku => "A100")
94
- create(:product, :name => 'apache baseball cap2', :sku => "B100")
95
- create(:product, :name => 'zomg shirt')
96
-
97
- click_link "Products"
98
- fill_in "q_name_cont", :with => "ap"
99
- click_icon :search
100
- expect(page).to have_content("apache baseball cap")
101
- expect(page).to have_content("apache baseball cap2")
102
- expect(page).not_to have_content("zomg shirt")
103
-
104
- fill_in "q_variants_including_master_sku_cont", :with => "A1"
105
- click_icon :search
106
- expect(page).to have_content("apache baseball cap")
107
- expect(page).not_to have_content("apache baseball cap2")
108
- expect(page).not_to have_content("zomg shirt")
109
- end
110
- end
111
-
112
- context "creating a new product from a prototype" do
113
- def build_option_type_with_values(name, values)
114
- ot = FactoryGirl.create(:option_type, :name => name)
115
- values.each do |val|
116
- ot.option_values.create(:name => val.downcase, :presentation => val)
117
- end
118
- ot
119
- end
120
-
121
- let(:product_attributes) do
122
- # FactoryGirl.attributes_for is un-deprecated!
123
- # https://github.com/thoughtbot/factory_girl/issues/274#issuecomment-3592054
124
- FactoryGirl.attributes_for(:simple_product)
125
- end
126
-
127
- let(:prototype) do
128
- size = build_option_type_with_values("size", %w(Small Medium Large))
129
- FactoryGirl.create(:prototype, :name => "Size", :option_types => [ size ])
130
- end
131
-
132
- let(:option_values_hash) do
133
- hash = {}
134
- prototype.option_types.each do |i|
135
- hash[i.id.to_s] = i.option_value_ids
136
- end
137
- hash
138
- end
139
-
140
- before(:each) do
141
- @option_type_prototype = prototype
142
- @property_prototype = create(:prototype, :name => "Random")
143
- @shipping_category = create(:shipping_category)
144
- click_link "Products"
145
- click_link "admin_new_product"
146
- within('#new_product') do
147
- expect(page).to have_content("SKU")
148
- end
149
- end
150
-
151
- it "should allow an admin to create a new product and variants from a prototype", :js => true do
152
- fill_in "product_name", :with => "Baseball Cap"
153
- fill_in "product_sku", :with => "B100"
154
- fill_in "product_price", :with => "100"
155
- fill_in "product_available_on", :with => "2012/01/24"
156
- select "Size", :from => "Prototype"
157
- check "Large"
158
- select @shipping_category.name, from: "product_shipping_category_id"
159
- click_button "Create"
160
- expect(page).to have_content("successfully created!")
161
- expect(Spree::Product.last.variants.length).to eq(1)
162
- end
163
-
164
- it "should not display variants when prototype does not contain option types", :js => true do
165
- select "Random", :from => "Prototype"
166
-
167
- fill_in "product_name", :with => "Baseball Cap"
168
-
169
- expect(page).not_to have_content("Variants")
170
- end
171
-
172
- it "should keep option values selected if validation fails", :js => true do
173
- fill_in "product_name", :with => "Baseball Cap"
174
- fill_in "product_sku", :with => "B100"
175
- fill_in "product_price", :with => "100"
176
- select "Size", :from => "Prototype"
177
- check "Large"
178
- click_button "Create"
179
- expect(page).to have_content("Shipping category can't be blank")
180
- expect(field_labeled("Size")).to be_checked
181
- expect(field_labeled("Large")).to be_checked
182
- expect(field_labeled("Small")).not_to be_checked
183
- end
184
- end
185
-
186
- context "creating a new product" do
187
- before(:each) do
188
- @shipping_category = create(:shipping_category)
189
- click_link "Products"
190
- click_link "admin_new_product"
191
- within('#new_product') do
192
- expect(page).to have_content("SKU")
193
- end
194
- end
195
-
196
- it "should allow an admin to create a new product", :js => true do
197
- fill_in "product_name", :with => "Baseball Cap"
198
- fill_in "product_sku", :with => "B100"
199
- fill_in "product_price", :with => "100"
200
- fill_in "product_available_on", :with => "2012/01/24"
201
- select @shipping_category.name, from: "product_shipping_category_id"
202
- click_button "Create"
203
- expect(page).to have_content("successfully created!")
204
- click_button "Update"
205
- expect(page).to have_content("successfully updated!")
206
- end
207
-
208
- it "should show validation errors", :js => true do
209
- fill_in "product_name", :with => "Baseball Cap"
210
- fill_in "product_sku", :with => "B100"
211
- fill_in "product_price", :with => "100"
212
- click_button "Create"
213
- expect(page).to have_content("Shipping category can't be blank")
214
- end
215
-
216
- context "using a locale with a different decimal format " do
217
- before do
218
- # change English locale’s separator and delimiter to match 19,99 format
219
- I18n.backend.store_translations(:en,
220
- :number => {
221
- :currency => {
222
- :format => {
223
- :separator => ",",
224
- :delimiter => "."
225
- }
226
- }
227
- })
228
- end
229
-
230
- after do
231
- # revert changes to English locale
232
- I18n.backend.store_translations(:en,
233
- :number => {
234
- :currency => {
235
- :format => {
236
- :separator => ".",
237
- :delimiter => ","
238
- }
239
- }
240
- })
241
- end
242
-
243
- it "should show localized price value on validation errors", :js => true do
244
- fill_in "product_price", :with => "19,99"
245
- click_button "Create"
246
- expect(find('input#product_price').value).to eq('19,99')
247
- end
248
- end
249
-
250
- # Regression test for #2097
251
- it "can set the count on hand to a null value", :js => true do
252
- fill_in "product_name", :with => "Baseball Cap"
253
- fill_in "product_price", :with => "100"
254
- select @shipping_category.name, from: "product_shipping_category_id"
255
- click_button "Create"
256
- expect(page).to have_content("successfully created!")
257
- click_button "Update"
258
- expect(page).to have_content("successfully updated!")
259
- end
260
- end
261
-
262
-
263
- context "cloning a product", :js => true do
264
- it "should allow an admin to clone a product" do
265
- create(:product)
266
-
267
- click_link "Products"
268
- within_row(1) do
269
- click_icon :copy
270
- end
271
-
272
- expect(page).to have_content("Product has been cloned")
273
- end
274
-
275
- context "cloning a deleted product" do
276
- it "should allow an admin to clone a deleted product" do
277
- create(:product, :name => "apache baseball cap")
278
-
279
- click_link "Products"
280
- check "Show Deleted"
281
- click_button "Search"
282
-
283
- expect(page).to have_content("apache baseball cap")
284
-
285
- within_row(1) do
286
- click_icon :copy
287
- end
288
-
289
- expect(page).to have_content("Product has been cloned")
290
- end
291
- end
292
- end
293
-
294
- context 'updating a product', :js => true do
295
- let(:product) { create(:product) }
296
-
297
- let(:prototype) do
298
- size = build_option_type_with_values("size", %w(Small Medium Large))
299
- FactoryGirl.create(:prototype, :name => "Size", :option_types => [ size ])
300
- end
301
-
302
- before(:each) do
303
- @option_type_prototype = prototype
304
- @property_prototype = create(:prototype, :name => "Random")
305
- end
306
-
307
- it 'should parse correctly available_on' do
308
- visit spree.admin_product_path(product)
309
- fill_in "product_available_on", :with => "2012/12/25"
310
- click_button "Update"
311
- expect(page).to have_content("successfully updated!")
312
- expect(Spree::Product.last.available_on).to eq('Tue, 25 Dec 2012 00:00:00 UTC +00:00')
313
- end
314
-
315
- it 'should add option_types when selecting a prototype' do
316
- visit spree.admin_product_path(product)
317
- click_link 'Product Properties'
318
- expect(page).to have_content("SELECT FROM PROTOTYPE")
319
- click_link "Select From Prototype"
320
-
321
- within(:css, "#prototypes tr#row_1") do
322
- click_link 'Select'
323
- wait_for_ajax
324
- end
325
-
326
- within(:css, "tr.product_property:first-child") do
327
- expect(first('input[type=text]').value).to eq('baseball_cap_color')
328
- end
329
- end
330
- end
331
-
332
- context 'deleting a product', :js => true do
333
- let!(:product) { create(:product) }
334
-
335
- it "is still viewable" do
336
- visit spree.admin_products_path
337
-
338
- expect(page).to have_content(product.name)
339
- accept_alert do
340
- click_icon :trash
341
- end
342
-
343
- expect(page).to have_no_content(product.name)
344
-
345
- # This will show our deleted product
346
- check "Show Deleted"
347
- click_icon :search
348
- click_link product.name
349
- expect(page).to have_field('Master Price', with: product.price.to_f)
350
- end
351
- end
352
- end
353
-
354
- context 'with only product permissions' do
355
-
356
- before do
357
- allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
358
- end
359
-
360
- custom_authorization! do |user|
361
- can [:admin, :update, :index, :read], Spree::Product
362
- end
363
- let!(:product) { create(:product) }
364
-
365
- it "should only display accessible links on index" do
366
- visit spree.admin_products_path
367
- expect(page).to have_link('Products')
368
- expect(page).not_to have_link('Option Types')
369
- expect(page).not_to have_link('Properties')
370
- expect(page).not_to have_link('Prototypes')
371
-
372
- expect(page).not_to have_link('New Product')
373
- expect(page).not_to have_css('a.clone')
374
- expect(page).to have_css('a.edit')
375
- expect(page).not_to have_css('a.delete-resource')
376
- end
377
-
378
- it "should only display accessible links on edit" do
379
- visit spree.admin_product_path(product)
380
-
381
- # product tabs should be hidden
382
- expect(page).to have_link('Product Details')
383
- expect(page).not_to have_link('Images')
384
- expect(page).not_to have_link('Variants')
385
- expect(page).not_to have_link('Product Properties')
386
- expect(page).not_to have_link('Stock Management')
387
-
388
- # no create permission
389
- expect(page).not_to have_link('New Product')
390
- end
391
- end
392
- end