spree_backend 3.1.5 → 3.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/admin/orders_controller.rb +1 -3
  3. data/app/controllers/spree/admin/products_controller.rb +1 -1
  4. data/app/views/spree/admin/products/_form.html.erb +8 -8
  5. data/app/views/spree/admin/products/index.html.erb +1 -1
  6. data/app/views/spree/admin/shared/_product_tabs.html.erb +4 -4
  7. data/app/views/spree/admin/taxons/edit.html.erb +1 -1
  8. data/spree_backend.gemspec +1 -1
  9. metadata +7 -98
  10. data/spec/controllers/spree/admin/base_controller_spec.rb +0 -46
  11. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -185
  12. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
  13. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
  14. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -197
  15. data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -254
  16. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -49
  17. data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -97
  18. data/spec/controllers/spree/admin/products_controller_spec.rb +0 -99
  19. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
  20. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
  21. data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -44
  22. data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
  23. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -74
  24. data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -42
  25. data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -252
  26. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -225
  27. data/spec/controllers/spree/admin/return_index_controller_spec.rb +0 -37
  28. data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
  29. data/spec/controllers/spree/admin/root_controller_spec.rb +0 -35
  30. data/spec/controllers/spree/admin/search_controller_spec.rb +0 -56
  31. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
  32. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -19
  33. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
  34. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -41
  35. data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +0 -34
  36. data/spec/controllers/spree/admin/users_controller_spec.rb +0 -161
  37. data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
  38. data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -47
  39. data/spec/features/admin/configuration/countries_spec.rb +0 -24
  40. data/spec/features/admin/configuration/general_settings_spec.rb +0 -44
  41. data/spec/features/admin/configuration/payment_methods_spec.rb +0 -63
  42. data/spec/features/admin/configuration/roles_spec.rb +0 -47
  43. data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -62
  44. data/spec/features/admin/configuration/states_spec.rb +0 -68
  45. data/spec/features/admin/configuration/stock_locations_spec.rb +0 -48
  46. data/spec/features/admin/configuration/store_credit_categories_spec.rb +0 -50
  47. data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
  48. data/spec/features/admin/configuration/tax_rates_spec.rb +0 -18
  49. data/spec/features/admin/configuration/zones_spec.rb +0 -39
  50. data/spec/features/admin/homepage_spec.rb +0 -89
  51. data/spec/features/admin/locale_spec.rb +0 -31
  52. data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
  53. data/spec/features/admin/orders/adjustments_spec.rb +0 -129
  54. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -47
  55. data/spec/features/admin/orders/customer_details_spec.rb +0 -154
  56. data/spec/features/admin/orders/line_items_spec.rb +0 -51
  57. data/spec/features/admin/orders/listing_spec.rb +0 -222
  58. data/spec/features/admin/orders/log_entries_spec.rb +0 -55
  59. data/spec/features/admin/orders/new_order_spec.rb +0 -160
  60. data/spec/features/admin/orders/order_details_spec.rb +0 -662
  61. data/spec/features/admin/orders/payments_spec.rb +0 -230
  62. data/spec/features/admin/orders/risk_analysis_spec.rb +0 -48
  63. data/spec/features/admin/orders/shipments_spec.rb +0 -64
  64. data/spec/features/admin/orders/state_changes_spec.rb +0 -21
  65. data/spec/features/admin/products/edit/images_spec.rb +0 -86
  66. data/spec/features/admin/products/edit/products_spec.rb +0 -64
  67. data/spec/features/admin/products/edit/taxons_spec.rb +0 -41
  68. data/spec/features/admin/products/edit/variants_spec.rb +0 -56
  69. data/spec/features/admin/products/option_types_spec.rb +0 -114
  70. data/spec/features/admin/products/products_spec.rb +0 -445
  71. data/spec/features/admin/products/properties_spec.rb +0 -147
  72. data/spec/features/admin/products/prototypes_spec.rb +0 -112
  73. data/spec/features/admin/products/stock_management_spec.rb +0 -124
  74. data/spec/features/admin/products/taxonomies_spec.rb +0 -52
  75. data/spec/features/admin/products/variant_spec.rb +0 -50
  76. data/spec/features/admin/promotions/adjustments_spec.rb +0 -259
  77. data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -70
  78. data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -70
  79. data/spec/features/admin/refund_reasons/refund_reasons_spec.rb +0 -57
  80. data/spec/features/admin/reports_spec.rb +0 -61
  81. data/spec/features/admin/return_authorization_reasons/return_authorization_reasons_spec.rb +0 -63
  82. data/spec/features/admin/returns/customer_returns_spec.rb +0 -80
  83. data/spec/features/admin/returns/return_authorizations_spec.rb +0 -152
  84. data/spec/features/admin/stock_transfer_spec.rb +0 -75
  85. data/spec/features/admin/store_credits_spec.rb +0 -93
  86. data/spec/features/admin/taxons_spec.rb +0 -47
  87. data/spec/features/admin/users_spec.rb +0 -286
  88. data/spec/helpers/admin/base_helper_spec.rb +0 -30
  89. data/spec/helpers/admin/navigation_helper_spec.rb +0 -106
  90. data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -30
  91. data/spec/helpers/promotion_rules_helper_spec.rb +0 -12
  92. data/spec/models/spree/resource_spec.rb +0 -48
  93. data/spec/routing/admin_path_spec.rb +0 -22
  94. data/spec/spec_helper.rb +0 -134
  95. data/spec/support/appear_before_matcher.rb +0 -8
  96. data/spec/support/ror_ringer.jpeg +0 -0
  97. data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +0 -1
  98. data/spec/test_views/spree/admin/submodule/posts/new.html.erb +0 -1
  99. data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
  100. data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
@@ -1,64 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- describe 'Product Details', type: :feature, js: true 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_products_path
13
- within_row(1) { click_icon :edit }
14
-
15
- click_link 'Details'
16
-
17
- expect(find('.content-header h1').text.strip).to eq('Products / Bún thịt nướng')
18
- expect(find('input#product_name').value).to eq('Bún thịt nướng')
19
- expect(find('input#product_slug').value).to eq('bun-th-t-n-ng')
20
- expect(find('textarea#product_description').text.strip).to eq('lorem ipsum')
21
- expect(find('input#product_price').value).to eq('19.99')
22
- expect(find('input#product_cost_price').value).to eq('17.00')
23
- expect(find('input#product_available_on').value).to eq("2013/08/14")
24
- expect(find('input#product_sku').value).to eq('A100')
25
- end
26
-
27
- it "should handle slug changes" do
28
- create(:product, name: 'Bún thịt nướng', sku: 'A100',
29
- description: 'lorem ipsum', available_on: '2011-01-01 01:01:01')
30
-
31
- visit spree.admin_products_path
32
- within('table.table tbody tr:nth-child(1)') do
33
- click_icon(:edit)
34
- end
35
-
36
- fill_in "product_slug", with: 'random-slug-value'
37
- click_button "Update"
38
- expect(page).to have_content("successfully updated!")
39
-
40
- fill_in "product_slug", with: 'a'
41
- click_button "Update"
42
- within('#product_slug_field') { expect(page).to have_content("is too short") }
43
-
44
- fill_in "product_slug", with: 'another-random-slug-value'
45
- click_button "Update"
46
- expect(page).to have_content("successfully updated!")
47
- end
48
- end
49
-
50
- # Regression test for #3385
51
- context "deleting a product" do
52
- it "is still able to find the master variant" do
53
- create(:product)
54
-
55
- visit spree.admin_products_path
56
- within_row(1) do
57
- accept_alert do
58
- click_icon :delete
59
- end
60
- end
61
- wait_for_ajax
62
- end
63
- end
64
- end
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Product Taxons", type: :feature, js: true 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" do
15
- def selected_taxons
16
- find("#product_taxon_ids").value.split(',').map(&:to_i).uniq
17
- end
18
-
19
- it "should allow an admin to manage taxons" do
20
- taxon_1 = create(:taxon)
21
- taxon_2 = create(:taxon, name: 'Clothing')
22
- product = create(:product)
23
- product.taxons << taxon_1
24
-
25
- visit spree.admin_products_path
26
- within_row(1) { click_icon :edit }
27
-
28
- expect(find(".select2-search-choice").text).to eq(taxon_1.name)
29
- expect(selected_taxons).to match_array([taxon_1.id])
30
-
31
- select2_search "Clothing", from: "Taxons"
32
- click_button "Update"
33
- expect(selected_taxons).to match_array([taxon_1.id, taxon_2.id])
34
-
35
- # Regression test for #2139
36
- sleep(1)
37
- expect(first(".select2-search-choice", text: taxon_1.name)).to be_present
38
- expect(first(".select2-search-choice", text: taxon_2.name)).to be_present
39
- end
40
- end
41
- end
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Product Variants", type: :feature, js: true do
4
- stub_authorization!
5
-
6
- let!(:product) { create(:product) }
7
-
8
- before(:each) do
9
- visit spree.admin_products_path
10
- end
11
-
12
- context "editing variant option types" do
13
- it "should allow an admin to create option types for a variant" do
14
- within_row(1) { click_icon :edit }
15
-
16
- within('#sidebar') { click_link "Variants" }
17
- expect(page).to have_content("To add variants, you must first define")
18
- end
19
-
20
- it "allows admin to create a variant if there are option types" do
21
- click_link "Products"
22
- click_link "Option Types"
23
- click_link "new_option_type_link"
24
- fill_in "option_type_name", with: "shirt colors"
25
- fill_in "option_type_presentation", with: "colors"
26
- click_button "Create"
27
- expect(page).to have_content("successfully created!")
28
-
29
- page.find('#option_type_option_values_attributes_0_name').set('color')
30
- page.find('#option_type_option_values_attributes_0_presentation').set('black')
31
- click_button "Update"
32
- expect(page).to have_content("successfully updated!")
33
-
34
- visit spree.admin_products_path
35
- within_row(1) { click_icon :edit }
36
-
37
- select2_search "shirt", from: "Option Types"
38
- click_button "Update"
39
- expect(page).to have_content("successfully updated!")
40
-
41
- within('#sidebar') { click_link "Variants" }
42
- click_link "New Variant"
43
-
44
- targetted_select2 "black", from: "#s2id_variant_option_value_ids"
45
- fill_in "variant_sku", with: "A100"
46
- click_button "Create"
47
- expect(page).to have_content("successfully created!")
48
-
49
- within(".table") do
50
- expect(page).to have_content("19.99")
51
- expect(page).to have_content("black")
52
- expect(page).to have_content("A100")
53
- end
54
- end
55
- end
56
- end
@@ -1,114 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Option Types", type: :feature, js: true 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
- click_link "Option Types"
16
- within("table#listing_option_types") do
17
- expect(page).to have_content("Color")
18
- expect(page).to have_content("tshirt-color")
19
- expect(page).to have_content("Size")
20
- expect(page).to have_content("tshirt-size")
21
- end
22
- end
23
- end
24
-
25
- context "creating a new option type" do
26
- it "should allow an admin to create a new option type" do
27
- click_link "Option Types"
28
- click_link "new_option_type_link"
29
- expect(page).to have_content("New Option Type")
30
- fill_in "option_type_name", with: "shirt colors"
31
- fill_in "option_type_presentation", with: "colors"
32
- click_button "Create"
33
- expect(page).to have_content("successfully created!")
34
-
35
- page.find('#option_type_option_values_attributes_0_name').set('color')
36
- page.find('#option_type_option_values_attributes_0_presentation').set('black')
37
-
38
- click_button "Update"
39
- expect(page).to have_content("successfully updated!")
40
- end
41
- end
42
-
43
- context "editing an existing option type" do
44
- it "should allow an admin to update an existing option type" do
45
- create(:option_type, name: "tshirt-color", presentation: "Color")
46
- create(:option_type, name: "tshirt-size", presentation: "Size")
47
- click_link "Option Types"
48
- within('table#listing_option_types') { click_icon :edit }
49
- fill_in "option_type_name", with: "foo-size 99"
50
- click_button "Update"
51
- expect(page).to have_content("successfully updated!")
52
- expect(page).to have_content("foo-size 99")
53
- end
54
- end
55
-
56
- # Regression test for #2277
57
- it "can remove an option value from an option type" do
58
- option_type = create(:option_type)
59
- create(:option_value, option_type: option_type)
60
- click_link "Option Types"
61
- within('table#listing_option_types') { click_icon :edit }
62
- expect(page).to have_content(option_type.name)
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" 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
- click_icon :delete
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
- click_icon :delete
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,445 +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
- def build_option_type_with_values(name, values)
9
- ot = FactoryGirl.create(:option_type, name: name)
10
- values.each do |val|
11
- ot.option_values.create(name: val.downcase, presentation: val)
12
- end
13
- ot
14
- end
15
-
16
- context "listing products" do
17
- context "sorting" do
18
- before do
19
- create(:product, name: 'apache baseball cap', price: 10)
20
- create(:product, name: 'zomg shirt', price: 5)
21
- end
22
-
23
- it "should list existing products with correct sorting by name" do
24
- visit spree.admin_products_path
25
- # Name ASC
26
- within_row(1) { expect(page).to have_content('apache baseball cap') }
27
- within_row(2) { expect(page).to have_content("zomg shirt") }
28
-
29
- # Name DESC
30
- click_link "admin_products_listing_name_title"
31
- within_row(1) { expect(page).to have_content("zomg shirt") }
32
- within_row(2) { expect(page).to have_content('apache baseball cap') }
33
- end
34
-
35
- it "should list existing products with correct sorting by price" do
36
- visit spree.admin_products_path
37
- # Name ASC (default)
38
- within_row(1) { expect(page).to have_content('apache baseball cap') }
39
- within_row(2) { expect(page).to have_content("zomg shirt") }
40
-
41
- # Price DESC
42
- click_link "admin_products_listing_price_title"
43
- within_row(1) { expect(page).to have_content("zomg shirt") }
44
- within_row(2) { expect(page).to have_content('apache baseball cap') }
45
- end
46
- end
47
-
48
- context "currency displaying" do
49
- context "using Russian Rubles" do
50
- before do
51
- Spree::Config[:currency] = "RUB"
52
- end
53
-
54
- let!(:product) do
55
- create(:product, name: "Just a product", price: 19.99)
56
- end
57
-
58
- # Regression test for #2737
59
- context "uses руб as the currency symbol" do
60
- it "on the products listing page" do
61
- visit spree.admin_products_path
62
- within_row(1) { expect(page).to have_content("19.99 ₽") }
63
- end
64
- end
65
- end
66
- end
67
- end
68
-
69
- context "searching products" do
70
- it "should be able to search deleted products" do
71
- create(:product, name: 'apache baseball cap', deleted_at: "2011-01-06 18:21:13")
72
- create(:product, name: 'zomg shirt')
73
-
74
- visit spree.admin_products_path
75
- expect(page).to have_content("zomg shirt")
76
- expect(page).not_to have_content("apache baseball cap")
77
-
78
- check "Show Deleted"
79
- click_on 'Search'
80
-
81
- expect(page).to have_content("zomg shirt")
82
- expect(page).to have_content("apache baseball cap")
83
-
84
- uncheck "Show Deleted"
85
- click_on 'Search'
86
-
87
- expect(page).to have_content("zomg shirt")
88
- expect(page).not_to have_content("apache baseball cap")
89
- end
90
-
91
- it "should be able to search products by their properties" do
92
- create(:product, name: 'apache baseball cap', sku: "A100")
93
- create(:product, name: 'apache baseball cap2', sku: "B100")
94
- create(:product, name: 'zomg shirt')
95
-
96
- visit spree.admin_products_path
97
- fill_in "q_name_cont", with: "ap"
98
- click_on 'Search'
99
-
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_on 'Search'
106
-
107
- expect(page).to have_content("apache baseball cap")
108
- expect(page).not_to have_content("apache baseball cap2")
109
- expect(page).not_to have_content("zomg shirt")
110
- end
111
- end
112
-
113
- context "creating a new product from a prototype", js: true do
114
- def build_option_type_with_values(name, values)
115
- ot = FactoryGirl.create(:option_type, name: name)
116
- values.each do |val|
117
- ot.option_values.create(name: val.downcase, presentation: val)
118
- end
119
- ot
120
- end
121
-
122
- let(:product_attributes) do
123
- # FactoryGirl.attributes_for is un-deprecated!
124
- # https://github.com/thoughtbot/factory_girl/issues/274#issuecomment-3592054
125
- FactoryGirl.attributes_for(:simple_product)
126
- end
127
-
128
- let(:prototype) do
129
- size = build_option_type_with_values("size", %w(Small Medium Large))
130
- FactoryGirl.create(:prototype, name: "Size", option_types: [ size ])
131
- end
132
-
133
- let(:option_values_hash) do
134
- hash = {}
135
- prototype.option_types.each do |i|
136
- hash[i.id.to_s] = i.option_value_ids
137
- end
138
- hash
139
- end
140
-
141
- before(:each) do
142
- @option_type_prototype = prototype
143
- @property_prototype = create(:prototype, name: "Random")
144
- @shipping_category = create(:shipping_category)
145
- visit spree.admin_products_path
146
- click_link "admin_new_product"
147
- within('#new_product') do
148
- expect(page).to have_content("SKU")
149
- end
150
- end
151
-
152
- it "should allow an admin to create a new product and variants from a prototype" do
153
- fill_in "product_name", with: "Baseball Cap"
154
- fill_in "product_sku", with: "B100"
155
- fill_in "product_price", with: "100"
156
- fill_in "product_available_on", with: "2012/01/24"
157
- # Just so the datepicker gets out of poltergeists way.
158
- page.execute_script("$('#ui-datepicker-div').hide();")
159
- select "Size", from: "Prototype"
160
- wait_for_ajax
161
- check "Large"
162
- select @shipping_category.name, from: "product_shipping_category_id"
163
- click_button "Create"
164
- expect(page).to have_content("successfully created!")
165
- expect(Spree::Product.last.variants.length).to eq(1)
166
- end
167
-
168
- it "should not display variants when prototype does not contain option types" do
169
- select "Random", from: "Prototype"
170
-
171
- fill_in "product_name", with: "Baseball Cap"
172
-
173
- expect(page).not_to have_content("Variants")
174
- end
175
-
176
- it "should keep option values selected if validation fails" do
177
- fill_in "product_name", with: "Baseball Cap"
178
- fill_in "product_sku", with: "B100"
179
- fill_in "product_price", with: "100"
180
- select "Size", from: "Prototype"
181
- wait_for_ajax
182
- check "Large"
183
- click_button "Create"
184
- expect(page).to have_content("Shipping Category can't be blank")
185
- expect(field_labeled("Size")).to be_checked
186
- expect(field_labeled("Large")).to be_checked
187
- expect(field_labeled("Small")).not_to be_checked
188
- end
189
- end
190
-
191
- context "creating a new product" do
192
- before(:each) do
193
- @shipping_category = create(:shipping_category)
194
- visit spree.admin_products_path
195
- click_link "admin_new_product"
196
- within('#new_product') do
197
- expect(page).to have_content("SKU")
198
- end
199
- end
200
-
201
- it "should allow an admin to create a new product" do
202
- fill_in "product_name", with: "Baseball Cap"
203
- fill_in "product_sku", with: "B100"
204
- fill_in "product_price", with: "100"
205
- fill_in "product_available_on", with: "2012/01/24"
206
- select @shipping_category.name, from: "product_shipping_category_id"
207
- click_button "Create"
208
- expect(page).to have_content("successfully created!")
209
- click_button "Update"
210
- expect(page).to have_content("successfully updated!")
211
- end
212
-
213
- it "should show validation errors" do
214
- fill_in "product_name", with: "Baseball Cap"
215
- fill_in "product_sku", with: "B100"
216
- fill_in "product_price", with: "100"
217
- click_button "Create"
218
- expect(page).to have_content("Shipping Category can't be blank")
219
- end
220
-
221
- context "using a locale with a different decimal format " do
222
- before do
223
- # change English locale’s separator and delimiter to match 19,99 format
224
- I18n.backend.store_translations(:en,
225
- :number => {
226
- :currency => {
227
- :format => {
228
- :separator => ",",
229
- :delimiter => "."
230
- }
231
- }
232
- })
233
- end
234
-
235
- after do
236
- # revert changes to English locale
237
- I18n.backend.store_translations(:en,
238
- :number => {
239
- :currency => {
240
- :format => {
241
- :separator => ".",
242
- :delimiter => ","
243
- }
244
- }
245
- })
246
- end
247
-
248
- it "should show localized price value on validation errors", :js => true do
249
- fill_in "product_price", :with => "19,99"
250
- click_button "Create"
251
- expect(find('input#product_price').value).to eq('19,99')
252
- end
253
- end
254
-
255
- # Regression test for #2097
256
- it "can set the count on hand to a null value" do
257
- fill_in "product_name", with: "Baseball Cap"
258
- fill_in "product_price", with: "100"
259
- select @shipping_category.name, from: "product_shipping_category_id"
260
- click_button "Create"
261
- expect(page).to have_content("successfully created!")
262
- click_button "Update"
263
- expect(page).to have_content("successfully updated!")
264
- end
265
- end
266
-
267
-
268
- context "cloning a product", js: true do
269
- it "should allow an admin to clone a product" do
270
- create(:product)
271
-
272
- visit spree.admin_products_path
273
- within_row(1) do
274
- click_icon :clone
275
- end
276
-
277
- expect(page).to have_content("Product has been cloned")
278
- end
279
-
280
- context "cloning a deleted product" do
281
- it "should allow an admin to clone a deleted product" do
282
- create(:product, name: "apache baseball cap")
283
-
284
- visit spree.admin_products_path
285
- click_on 'Filter'
286
- check "Show Deleted"
287
- click_on 'Search'
288
-
289
- expect(page).to have_content("apache baseball cap")
290
-
291
- within_row(1) do
292
- click_icon :clone
293
- end
294
-
295
- expect(page).to have_content("Product has been cloned")
296
- end
297
- end
298
- end
299
-
300
- context 'updating a product' do
301
- let(:product) { create(:product) }
302
-
303
- let(:prototype) do
304
- size = build_option_type_with_values("size", %w(Small Medium Large))
305
- FactoryGirl.create(:prototype, name: "Size", option_types: [ size ])
306
- end
307
-
308
- before(:each) do
309
- @option_type_prototype = prototype
310
- @property_prototype = create(:prototype, name: "Random")
311
- end
312
-
313
- it 'should parse correctly available_on' do
314
- visit spree.admin_product_path(product)
315
- fill_in "product_available_on", with: "2012/12/25"
316
- click_button "Update"
317
- expect(page).to have_content("successfully updated!")
318
- expect(Spree::Product.last.available_on.to_s).to eq("2012-12-25 00:00:00 UTC")
319
- end
320
-
321
- it 'should add option_types when selecting a prototype', js: true do
322
- visit spree.admin_product_path(product)
323
- within('#sidebar') do
324
- click_link 'Properties'
325
- end
326
- click_link "Select From Prototype"
327
-
328
- within("#prototypes tr#row_#{prototype.id}") do
329
- click_link 'Select'
330
- wait_for_ajax
331
- end
332
-
333
- within(:css, "tr.product_property:first-child") do
334
- expect(first('input[type=text]').value).to eq('baseball_cap_color')
335
- end
336
- end
337
-
338
- context "using a locale with a different decimal format" do
339
- before do
340
- # change English locale’s separator and delimiter to match 19,99 format
341
- I18n.backend.store_translations(
342
- :en,
343
- number: {
344
- currency: {
345
- format: {
346
- separator: ",",
347
- delimiter: "."
348
- }
349
- },
350
- format: {
351
- separator: ",",
352
- delimiter: "."
353
- }
354
- }
355
- )
356
- end
357
-
358
- after do
359
- # revert changes to English locale
360
- I18n.backend.store_translations(
361
- :en,
362
- number: {
363
- currency: {
364
- format: {
365
- separator: ".",
366
- delimiter: ","
367
- }
368
- },
369
- format: {
370
- separator: ".",
371
- delimiter: ","
372
- }
373
- }
374
- )
375
- end
376
-
377
- it 'should parse correctly decimal values like weight' do
378
- visit spree.admin_product_path(product)
379
- fill_in 'product_weight', with: '1'
380
- click_button 'Update'
381
- weight_prev = find('#product_weight').value
382
- click_button 'Update'
383
- expect(find('#product_weight').value).to eq(weight_prev)
384
- end
385
- end
386
- end
387
-
388
- context 'deleting a product', :js => true do
389
- let!(:product) { create(:product) }
390
-
391
- it "is still viewable" do
392
- visit spree.admin_products_path
393
- accept_alert do
394
- click_icon :delete
395
- wait_for_ajax
396
- end
397
- click_on 'Filter'
398
- # This will show our deleted product
399
- check "Show Deleted"
400
- click_on 'Search'
401
- click_link product.name
402
- expect(find("#product_price").value.to_f).to eq(product.price.to_f)
403
- end
404
- end
405
- end
406
-
407
- context 'with only product permissions' do
408
-
409
- before do
410
- allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
411
- end
412
-
413
- custom_authorization! do |user|
414
- can [:admin, :update, :index, :read], Spree::Product
415
- end
416
- let!(:product) { create(:product) }
417
-
418
- it "should only display accessible links on index" do
419
- visit spree.admin_products_path
420
-
421
- expect(page).to have_link('Products')
422
- expect(page).not_to have_link('Option Types')
423
- expect(page).not_to have_link('Properties')
424
- expect(page).not_to have_link('Prototypes')
425
- expect(page).not_to have_link('New Product')
426
- expect(page).not_to have_css('.icon-clone')
427
- expect(page).to have_css('.icon-edit')
428
- expect(page).not_to have_css('.delete-resource')
429
- end
430
-
431
- it "should only display accessible links on edit" do
432
- visit spree.admin_product_path(product)
433
-
434
- # product tabs should be hidden
435
- expect(page).to have_link('Details')
436
- expect(page).not_to have_link('Images')
437
- expect(page).not_to have_link('Variants')
438
- expect(page).not_to have_link('Properties')
439
- expect(page).not_to have_link('Stock Management')
440
-
441
- # no create permission
442
- expect(page).not_to have_link('New Product')
443
- end
444
- end
445
- end