solidus_frontend_devise_token_auth 2.8.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +26 -0
  3. data/README.md +42 -0
  4. data/Rakefile +17 -0
  5. data/app/assets/config/solidus_frontend_manifest.js +4 -0
  6. data/app/assets/images/credit_cards/amex_cid.gif +0 -0
  7. data/app/assets/images/credit_cards/credit_card.gif +0 -0
  8. data/app/assets/images/credit_cards/discover_cid.gif +0 -0
  9. data/app/assets/images/credit_cards/icons/american_express.png +0 -0
  10. data/app/assets/images/credit_cards/icons/cirrus.png +0 -0
  11. data/app/assets/images/credit_cards/icons/delta.png +0 -0
  12. data/app/assets/images/credit_cards/icons/diners_club.png +0 -0
  13. data/app/assets/images/credit_cards/icons/directdebit.png +0 -0
  14. data/app/assets/images/credit_cards/icons/discover.png +0 -0
  15. data/app/assets/images/credit_cards/icons/egold.png +0 -0
  16. data/app/assets/images/credit_cards/icons/maestro.png +0 -0
  17. data/app/assets/images/credit_cards/icons/master.png +0 -0
  18. data/app/assets/images/credit_cards/icons/paypal.png +0 -0
  19. data/app/assets/images/credit_cards/icons/solo.png +0 -0
  20. data/app/assets/images/credit_cards/icons/switch.png +0 -0
  21. data/app/assets/images/credit_cards/icons/visa.png +0 -0
  22. data/app/assets/images/credit_cards/icons/visaelectron.png +0 -0
  23. data/app/assets/images/credit_cards/icons/westernunion.png +0 -0
  24. data/app/assets/images/credit_cards/icons/wirecard.png +0 -0
  25. data/app/assets/images/credit_cards/icons/worldpay.png +0 -0
  26. data/app/assets/images/credit_cards/master_cid.jpg +0 -0
  27. data/app/assets/images/credit_cards/visa_cid.gif +0 -0
  28. data/app/assets/images/favicon.ico +0 -0
  29. data/app/assets/images/icons/add-to-cart.png +0 -0
  30. data/app/assets/images/icons/checkout.png +0 -0
  31. data/app/assets/images/icons/delete.png +0 -0
  32. data/app/assets/images/icons/update.png +0 -0
  33. data/app/assets/images/spinner.gif +0 -0
  34. data/app/assets/images/spree/frontend/cart.png +0 -0
  35. data/app/assets/javascripts/spree/frontend/cart.js +30 -0
  36. data/app/assets/javascripts/spree/frontend/checkout/address.js +127 -0
  37. data/app/assets/javascripts/spree/frontend/checkout/coupon-code.js +41 -0
  38. data/app/assets/javascripts/spree/frontend/checkout/payment.js +55 -0
  39. data/app/assets/javascripts/spree/frontend/checkout.js +24 -0
  40. data/app/assets/javascripts/spree/frontend/locale_selector.js +5 -0
  41. data/app/assets/javascripts/spree/frontend/product.js +81 -0
  42. data/app/assets/javascripts/spree/frontend.js +5 -0
  43. data/app/assets/stylesheets/spree/frontend/_skeleton.scss +242 -0
  44. data/app/assets/stylesheets/spree/frontend/_variables.scss +65 -0
  45. data/app/assets/stylesheets/spree/frontend/screen.css.scss +1387 -0
  46. data/app/assets/stylesheets/spree/frontend.css +5 -0
  47. data/app/controllers/spree/checkout_controller.rb +236 -0
  48. data/app/controllers/spree/content_controller.rb +11 -0
  49. data/app/controllers/spree/home_controller.rb +14 -0
  50. data/app/controllers/spree/locale_controller.rb +20 -0
  51. data/app/controllers/spree/orders_controller.rb +138 -0
  52. data/app/controllers/spree/products_controller.rb +52 -0
  53. data/app/controllers/spree/store_controller.rb +30 -0
  54. data/app/controllers/spree/taxons_controller.rb +31 -0
  55. data/app/helpers/spree/orders_helper.rb +18 -0
  56. data/app/helpers/spree/taxon_filters_helper.rb +13 -0
  57. data/app/models/spree/frontend_configuration.rb +10 -0
  58. data/app/views/spree/address/_form.html.erb +96 -0
  59. data/app/views/spree/address/_form_hidden.html.erb +12 -0
  60. data/app/views/spree/checkout/_address.html.erb +33 -0
  61. data/app/views/spree/checkout/_confirm.html.erb +25 -0
  62. data/app/views/spree/checkout/_coupon_code.html.erb +12 -0
  63. data/app/views/spree/checkout/_delivery.html.erb +108 -0
  64. data/app/views/spree/checkout/_payment.html.erb +67 -0
  65. data/app/views/spree/checkout/_summary.html.erb +76 -0
  66. data/app/views/spree/checkout/_terms_and_conditions.en.html.erb +1 -0
  67. data/app/views/spree/checkout/edit.html.erb +32 -0
  68. data/app/views/spree/checkout/existing_payment/_gateway.html.erb +9 -0
  69. data/app/views/spree/checkout/payment/_check.html.erb +0 -0
  70. data/app/views/spree/checkout/payment/_gateway.html.erb +36 -0
  71. data/app/views/spree/content/cvv.html.erb +13 -0
  72. data/app/views/spree/home/index.html.erb +12 -0
  73. data/app/views/spree/layouts/spree_application.html.erb +36 -0
  74. data/app/views/spree/orders/_adjustment_row.html.erb +8 -0
  75. data/app/views/spree/orders/_adjustments.html.erb +24 -0
  76. data/app/views/spree/orders/_form.html.erb +29 -0
  77. data/app/views/spree/orders/_line_item.html.erb +34 -0
  78. data/app/views/spree/orders/edit.html.erb +47 -0
  79. data/app/views/spree/orders/show.html.erb +22 -0
  80. data/app/views/spree/payments/_payment.html.erb +18 -0
  81. data/app/views/spree/products/_cart_form.html.erb +65 -0
  82. data/app/views/spree/products/_image.html.erb +8 -0
  83. data/app/views/spree/products/_promotions.html.erb +19 -0
  84. data/app/views/spree/products/_properties.html.erb +15 -0
  85. data/app/views/spree/products/_taxons.html.erb +14 -0
  86. data/app/views/spree/products/_thumbnails.html.erb +21 -0
  87. data/app/views/spree/products/index.html.erb +27 -0
  88. data/app/views/spree/products/show.html.erb +51 -0
  89. data/app/views/spree/shared/_address.html.erb +38 -0
  90. data/app/views/spree/shared/_filters.html.erb +27 -0
  91. data/app/views/spree/shared/_footer.html.erb +6 -0
  92. data/app/views/spree/shared/_head.html.erb +14 -0
  93. data/app/views/spree/shared/_header.html.erb +5 -0
  94. data/app/views/spree/shared/_image.html.erb +12 -0
  95. data/app/views/spree/shared/_link_to_cart.html.erb +1 -0
  96. data/app/views/spree/shared/_locale_selector.html.erb +25 -0
  97. data/app/views/spree/shared/_login_bar_items.html.erb +1 -0
  98. data/app/views/spree/shared/_main_nav_bar.html.erb +12 -0
  99. data/app/views/spree/shared/_nav_bar.html.erb +9 -0
  100. data/app/views/spree/shared/_order_details.html.erb +146 -0
  101. data/app/views/spree/shared/_products.html.erb +51 -0
  102. data/app/views/spree/shared/_search.html.erb +11 -0
  103. data/app/views/spree/shared/_shipment_tracking.html.erb +9 -0
  104. data/app/views/spree/shared/_sidebar.html.erb +3 -0
  105. data/app/views/spree/shared/_taxonomies.html.erb +9 -0
  106. data/app/views/spree/shared/unauthorized.html.erb +0 -0
  107. data/app/views/spree/store/cart_link.html.erb +1 -0
  108. data/app/views/spree/taxons/_taxon.html.erb +4 -0
  109. data/app/views/spree/taxons/show.html.erb +20 -0
  110. data/config/initializers/assets.rb +3 -0
  111. data/config/initializers/canonical_rails.rb +16 -0
  112. data/config/routes.rb +33 -0
  113. data/lib/generators/solidus/views/override_generator.rb +49 -0
  114. data/lib/solidus_frontend.rb +3 -0
  115. data/lib/spree/frontend/engine.rb +13 -0
  116. data/lib/spree/frontend/middleware/seo_assist.rb +52 -0
  117. data/lib/spree/frontend.rb +15 -0
  118. data/lib/spree_frontend.rb +3 -0
  119. data/lib/tasks/rake_util.rb +18 -0
  120. data/lib/tasks/taxon.rake +16 -0
  121. data/script/rails +10 -0
  122. data/solidus_frontend.gemspec +35 -0
  123. data/spec/controllers/controller_helpers_spec.rb +30 -0
  124. data/spec/controllers/locale_controller_spec.rb +57 -0
  125. data/spec/controllers/spree/checkout_controller_spec.rb +539 -0
  126. data/spec/controllers/spree/checkout_controller_with_views_spec.rb +37 -0
  127. data/spec/controllers/spree/content_controller_spec.rb +9 -0
  128. data/spec/controllers/spree/current_order_tracking_spec.rb +47 -0
  129. data/spec/controllers/spree/home_controller_spec.rb +29 -0
  130. data/spec/controllers/spree/orders_controller_ability_spec.rb +93 -0
  131. data/spec/controllers/spree/orders_controller_spec.rb +225 -0
  132. data/spec/controllers/spree/orders_controller_transitions_spec.rb +33 -0
  133. data/spec/controllers/spree/products_controller_spec.rb +38 -0
  134. data/spec/controllers/spree/taxons_controller_spec.rb +14 -0
  135. data/spec/features/address_spec.rb +78 -0
  136. data/spec/features/automatic_promotion_adjustments_spec.rb +49 -0
  137. data/spec/features/caching/products_spec.rb +48 -0
  138. data/spec/features/caching/taxons_spec.rb +21 -0
  139. data/spec/features/cart_spec.rb +85 -0
  140. data/spec/features/checkout_spec.rb +690 -0
  141. data/spec/features/checkout_unshippable_spec.rb +37 -0
  142. data/spec/features/coupon_code_spec.rb +266 -0
  143. data/spec/features/currency_spec.rb +20 -0
  144. data/spec/features/free_shipping_promotions_spec.rb +60 -0
  145. data/spec/features/locale_spec.rb +27 -0
  146. data/spec/features/order_spec.rb +73 -0
  147. data/spec/features/products_spec.rb +291 -0
  148. data/spec/features/promotion_code_invalidation_spec.rb +54 -0
  149. data/spec/features/quantity_promotions_spec.rb +130 -0
  150. data/spec/features/taxons_spec.rb +158 -0
  151. data/spec/features/template_rendering_spec.rb +20 -0
  152. data/spec/fixtures/thinking-cat.jpg +0 -0
  153. data/spec/generators/solidus/views/override_generator_spec.rb +50 -0
  154. data/spec/helpers/base_helper_spec.rb +13 -0
  155. data/spec/helpers/order_helper_spec.rb +14 -0
  156. data/spec/helpers/taxon_filters_helper_spec.rb +12 -0
  157. data/spec/spec_helper.rb +106 -0
  158. data/spec/support/features/fill_in_with_force.rb +12 -0
  159. data/spec/support/shared_contexts/checkout_setup.rb +12 -0
  160. data/spec/support/shared_contexts/custom_products.rb +28 -0
  161. data/spec/support/shared_contexts/locales.rb +16 -0
  162. data/spec/views/spree/checkout/_summary_spec.rb +11 -0
  163. metadata +337 -0
@@ -0,0 +1,291 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "Visiting Products", type: :feature, inaccessible: true do
6
+ include_context "custom products"
7
+
8
+ let(:store_name) do
9
+ ((first_store = Spree::Store.first) && first_store.name).to_s
10
+ end
11
+
12
+ before(:each) do
13
+ visit spree.root_path
14
+ end
15
+
16
+ it "should be able to show the shopping cart after adding a product to it" do
17
+ click_link "Ruby on Rails Ringer T-Shirt"
18
+ expect(page).to have_content("$19.99")
19
+
20
+ click_button 'add-to-cart-button'
21
+ expect(page).to have_content("Shopping Cart")
22
+ end
23
+
24
+ # Regression spec for Spree [PR#7442](https://github.com/spree/spree/pull/7442)
25
+ context "when generating product links" do
26
+ let(:product) { Spree::Product.available.first }
27
+
28
+ it "should not use the *_url helper to generate the product links" do
29
+ visit spree.root_path
30
+ expect(page).not_to have_xpath(".//a[@href='#{spree.product_url(product, host: current_host)}']")
31
+ end
32
+
33
+ it "should use *_path helper to generate the product links" do
34
+ visit spree.root_path
35
+ expect(page).to have_xpath(".//a[@href='#{spree.product_path(product)}']")
36
+ end
37
+ end
38
+
39
+ describe 'meta tags and title' do
40
+ let(:jersey) { Spree::Product.find_by(name: 'Ruby on Rails Baseball Jersey') }
41
+ let(:metas) { { meta_description: 'Brand new Ruby on Rails Jersey', meta_title: 'Ruby on Rails Baseball Jersey Buy High Quality Geek Apparel', meta_keywords: 'ror, jersey, ruby' } }
42
+
43
+ it 'should return the correct title when displaying a single product' do
44
+ click_link jersey.name
45
+ expect(page).to have_title('Ruby on Rails Baseball Jersey - ' + store_name)
46
+ within('div#product-description') do
47
+ within('h1.product-title') do
48
+ expect(page).to have_content('Ruby on Rails Baseball Jersey')
49
+ end
50
+ end
51
+ end
52
+
53
+ it 'displays metas' do
54
+ jersey.update_attributes metas
55
+ click_link jersey.name
56
+ expect(page).to have_meta(:description, 'Brand new Ruby on Rails Jersey')
57
+ expect(page).to have_meta(:keywords, 'ror, jersey, ruby')
58
+ end
59
+
60
+ it 'displays title if set' do
61
+ jersey.update_attributes metas
62
+ click_link jersey.name
63
+ expect(page).to have_title('Ruby on Rails Baseball Jersey Buy High Quality Geek Apparel')
64
+ end
65
+
66
+ it "doesn't use meta_title as heading on page" do
67
+ jersey.update_attributes metas
68
+ click_link jersey.name
69
+ within("h1") do
70
+ expect(page).to have_content(jersey.name)
71
+ expect(page).not_to have_content(jersey.meta_title)
72
+ end
73
+ end
74
+
75
+ it 'uses product name in title when meta_title set to empty string' do
76
+ jersey.update_attributes meta_title: ''
77
+ click_link jersey.name
78
+ expect(page).to have_title('Ruby on Rails Baseball Jersey - ' + store_name)
79
+ end
80
+ end
81
+
82
+ describe 'schema.org markup' do
83
+ let(:product) { Spree::Product.available.first }
84
+
85
+ it 'has correct schema.org/Offer attributes' do
86
+ expect(page).to have_css("#product_#{product.id} [itemprop='price'][content='19.99']")
87
+ expect(page).to have_css("#product_#{product.id} [itemprop='priceCurrency'][content='USD']")
88
+ click_link product.name
89
+ expect(page).to have_css("[itemprop='price'][content='19.99']")
90
+ expect(page).to have_css("[itemprop='priceCurrency'][content='USD']")
91
+ end
92
+ end
93
+
94
+ context "using Russian Rubles as a currency" do
95
+ before do
96
+ Spree::Config[:currency] = "RUB"
97
+ end
98
+
99
+ let!(:product) do
100
+ product = Spree::Product.find_by(name: "Ruby on Rails Ringer T-Shirt")
101
+ product.price = 19.99
102
+ product.tap(&:save)
103
+ end
104
+
105
+ # Regression tests for https://github.com/spree/spree/issues/2737
106
+ context "uses руб as the currency symbol" do
107
+ it "on products page" do
108
+ visit spree.root_path
109
+ within("#product_#{product.id}") do
110
+ within(".price") do
111
+ expect(page).to have_content("19.99 ₽")
112
+ end
113
+ end
114
+ end
115
+
116
+ it "on product page" do
117
+ visit spree.product_path(product)
118
+ within(".price") do
119
+ expect(page).to have_content("19.99 ₽")
120
+ end
121
+ end
122
+
123
+ it "when adding a product to the cart", js: true do
124
+ visit spree.product_path(product)
125
+ click_button "Add To Cart"
126
+ click_link "Home"
127
+ within(".cart-info") do
128
+ expect(page).to have_content("19.99 ₽")
129
+ end
130
+ end
131
+
132
+ it "when on the 'address' state of the cart" do
133
+ visit spree.product_path(product)
134
+ click_button "Add To Cart"
135
+ click_button "Checkout"
136
+ within("tr[data-hook=item_total]") do
137
+ expect(page).to have_content("19.99 ₽")
138
+ end
139
+ end
140
+ end
141
+ end
142
+
143
+ it "should be able to search for a product" do
144
+ fill_in "keywords", with: "shirt"
145
+ click_button "Search"
146
+
147
+ expect(page.all('ul.product-listing li').size).to eq(1)
148
+ end
149
+
150
+ context "a product with variants" do
151
+ let(:product) { Spree::Product.find_by(name: "Ruby on Rails Baseball Jersey") }
152
+ let(:option_value) { create(:option_value) }
153
+ let!(:variant) { product.variants.create!(price: 5.59) }
154
+
155
+ before do
156
+ # Need to have two images to trigger the error
157
+ image = File.open(File.expand_path('../fixtures/thinking-cat.jpg', __dir__))
158
+ product.images.create!(attachment: image)
159
+ product.images.create!(attachment: image)
160
+
161
+ product.option_types << option_value.option_type
162
+ variant.option_values << option_value
163
+ end
164
+
165
+ it "displays price of first variant listed", js: true do
166
+ click_link product.name
167
+ within("#product-price") do
168
+ expect(page).to have_content variant.price
169
+ expect(page).not_to have_content I18n.t('spree.out_of_stock')
170
+ end
171
+ end
172
+
173
+ it "doesn't display out of stock for master product" do
174
+ product.master.stock_items.update_all count_on_hand: 0, backorderable: false
175
+
176
+ click_link product.name
177
+ within("#product-price") do
178
+ expect(page).not_to have_content I18n.t('spree.out_of_stock')
179
+ end
180
+ end
181
+ end
182
+
183
+ context "a product with variants, images only for the variants" do
184
+ let(:product) { Spree::Product.find_by(name: "Ruby on Rails Baseball Jersey") }
185
+
186
+ before do
187
+ image = File.open(File.expand_path('../fixtures/thinking-cat.jpg', __dir__))
188
+ v1 = product.variants.create!(price: 9.99)
189
+ v2 = product.variants.create!(price: 10.99)
190
+ v1.images.create!(attachment: image)
191
+ v2.images.create!(attachment: image)
192
+ end
193
+
194
+ it "should not display no image available" do
195
+ visit spree.root_path
196
+ expect(page).to have_xpath("//img[contains(@src,'thinking-cat')]")
197
+ end
198
+ end
199
+
200
+ it "should be able to hide products without price" do
201
+ expect(page.all('ul.product-listing li').size).to eq(9)
202
+ Spree::Config.show_products_without_price = false
203
+ Spree::Config.currency = "CAN"
204
+ visit spree.root_path
205
+ expect(page.all('ul.product-listing li').size).to eq(0)
206
+ end
207
+
208
+ it "should be able to display products priced under 10 dollars" do
209
+ within(:css, '#taxonomies') { click_link "Ruby on Rails" }
210
+ check "Price_Range_Under_$10.00"
211
+ within(:css, '#sidebar_products_search') { click_button "Search" }
212
+ expect(page).to have_content("No products found")
213
+ end
214
+
215
+ it "should be able to display products priced between 15 and 18 dollars" do
216
+ within(:css, '#taxonomies') { click_link "Ruby on Rails" }
217
+ check "Price_Range_$15.00_-_$18.00"
218
+ within(:css, '#sidebar_products_search') { click_button "Search" }
219
+
220
+ expect(page.all('ul.product-listing li').size).to eq(3)
221
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
222
+ tmp.delete("")
223
+ expect(tmp.sort!).to eq(["Ruby on Rails Mug", "Ruby on Rails Stein", "Ruby on Rails Tote"])
224
+ end
225
+
226
+ it "should be able to display products priced between 15 and 18 dollars across multiple pages" do
227
+ Spree::Config.products_per_page = 2
228
+ within(:css, '#taxonomies') { click_link "Ruby on Rails" }
229
+ check "Price_Range_$15.00_-_$18.00"
230
+ within(:css, '#sidebar_products_search') { click_button "Search" }
231
+
232
+ expect(page.all('ul.product-listing li').size).to eq(2)
233
+ products = page.all('ul.product-listing li a[itemprop=name]')
234
+ expect(products.count).to eq(2)
235
+
236
+ find('nav.pagination .next a').click
237
+ products = page.all('ul.product-listing li a[itemprop=name]')
238
+ expect(products.count).to eq(1)
239
+ end
240
+
241
+ it "should be able to display products priced 18 dollars and above" do
242
+ within(:css, '#taxonomies') { click_link "Ruby on Rails" }
243
+ check "Price_Range_$18.00_-_$20.00"
244
+ check "Price_Range_$20.00_or_over"
245
+ within(:css, '#sidebar_products_search') { click_button "Search" }
246
+
247
+ expect(page.all('ul.product-listing li').size).to eq(4)
248
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
249
+ tmp.delete("")
250
+ expect(tmp.sort!).to eq(["Ruby on Rails Bag",
251
+ "Ruby on Rails Baseball Jersey",
252
+ "Ruby on Rails Jr. Spaghetti",
253
+ "Ruby on Rails Ringer T-Shirt"])
254
+ end
255
+
256
+ it "should be able to put a product without a description in the cart" do
257
+ product = FactoryBot.create(:base_product, description: nil, name: 'Sample', price: '19.99')
258
+ visit spree.product_path(product)
259
+ expect(page).to have_content "This product has no description"
260
+ click_button 'add-to-cart-button'
261
+ expect(page).to have_content "This product has no description"
262
+ end
263
+
264
+ it "shouldn't be able to put a product without a current price in the cart" do
265
+ product = FactoryBot.create(:base_product, description: nil, name: 'Sample', price: '19.99')
266
+ Spree::Config.currency = "CAN"
267
+ Spree::Config.show_products_without_price = true
268
+ visit spree.product_path(product)
269
+ expect(page).to have_content "This product is not available in the selected currency."
270
+ expect(page).not_to have_content "add-to-cart-button"
271
+ end
272
+
273
+ it "should be able to list products without a price" do
274
+ product = FactoryBot.create(:base_product, description: nil, name: 'Sample', price: '19.99')
275
+ Spree::Config.currency = "CAN"
276
+ Spree::Config.show_products_without_price = true
277
+ visit spree.products_path
278
+ expect(page).to have_content(product.name)
279
+ end
280
+
281
+ it "should return the correct title when displaying a single product" do
282
+ product = Spree::Product.find_by(name: "Ruby on Rails Baseball Jersey")
283
+ click_link product.name
284
+
285
+ within("div#product-description") do
286
+ within("h1.product-title") do
287
+ expect(page).to have_content("Ruby on Rails Baseball Jersey")
288
+ end
289
+ end
290
+ end
291
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.feature "Promotion Code Invalidation" do
6
+ given!(:promotion) do
7
+ FactoryBot.create(
8
+ :promotion_with_item_adjustment,
9
+ code: "PROMO",
10
+ per_code_usage_limit: 1,
11
+ adjustment_rate: 5
12
+ )
13
+ end
14
+
15
+ background do
16
+ create(:store)
17
+ FactoryBot.create(:product, name: "DL-44")
18
+ FactoryBot.create(:product, name: "E-11")
19
+
20
+ visit spree.root_path
21
+ click_link "DL-44"
22
+ click_button "Add To Cart"
23
+
24
+ visit spree.root_path
25
+ click_link "E-11"
26
+ click_button "Add To Cart"
27
+ end
28
+
29
+ scenario "adding the promotion to a cart with two applicable items" do
30
+ fill_in "Coupon code", with: "PROMO"
31
+ click_button "Update"
32
+
33
+ expect(page).to have_content("The coupon code was successfully applied to your order")
34
+
35
+ within("#cart_adjustments") do
36
+ expect(page).to have_content("-$10.00")
37
+ end
38
+
39
+ # Remove an item
40
+ fill_in "order_line_items_attributes_0_quantity", with: 0
41
+ click_button "Update"
42
+ within("#cart_adjustments") do
43
+ expect(page).to have_content("-$5.00")
44
+ end
45
+
46
+ # Add it back
47
+ visit spree.root_path
48
+ click_link "DL-44"
49
+ click_button "Add To Cart"
50
+ within("#cart_adjustments") do
51
+ expect(page).to have_content("-$10.00")
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.feature "Quantity Promotions" do
6
+ given(:action) do
7
+ Spree::Promotion::Actions::CreateQuantityAdjustments.create(
8
+ calculator: calculator,
9
+ preferred_group_size: 2
10
+ )
11
+ end
12
+
13
+ given(:promotion) { FactoryBot.create(:promotion, code: "PROMO") }
14
+ given(:calculator) { FactoryBot.create(:calculator, preferred_amount: 5) }
15
+
16
+ background do
17
+ create(:store)
18
+ FactoryBot.create(:product, name: "DL-44")
19
+ FactoryBot.create(:product, name: "E-11")
20
+ promotion.actions << action
21
+
22
+ visit spree.root_path
23
+ click_link "DL-44"
24
+ click_button "Add To Cart"
25
+ end
26
+
27
+ scenario "adding and removing items from the cart" do
28
+ # Attempt to use the code with too few items.
29
+ fill_in "Coupon code", with: "PROMO"
30
+ click_button "Update"
31
+ expect(page).to have_content("This coupon code could not be applied to the cart at this time")
32
+
33
+ # Add another item to our cart.
34
+ visit spree.root_path
35
+ click_link "DL-44"
36
+ click_button "Add To Cart"
37
+
38
+ # Using the code should now succeed.
39
+ fill_in "Coupon code", with: "PROMO"
40
+ click_button "Update"
41
+ expect(page).to have_content("The coupon code was successfully applied to your order")
42
+ within("#cart_adjustments") do
43
+ expect(page).to have_content("-$10.00")
44
+ end
45
+
46
+ # Reduce quantity by 1, making promotion not apply.
47
+ fill_in "order_line_items_attributes_0_quantity", with: 1
48
+ click_button "Update"
49
+ expect(page).to_not have_content("#cart_adjustments")
50
+
51
+ # Bump quantity to 3, making promotion apply "once."
52
+ fill_in "order_line_items_attributes_0_quantity", with: 3
53
+ click_button "Update"
54
+ within("#cart_adjustments") do
55
+ expect(page).to have_content("-$10.00")
56
+ end
57
+
58
+ # Bump quantity to 4, making promotion apply "twice."
59
+ fill_in "order_line_items_attributes_0_quantity", with: 4
60
+ click_button "Update"
61
+ within("#cart_adjustments") do
62
+ expect(page).to have_content("-$20.00")
63
+ end
64
+ end
65
+
66
+ # Catches an earlier issue with quantity calculation.
67
+ scenario "adding odd numbers of items to the cart" do
68
+ # Bump quantity to 3
69
+ fill_in "order_line_items_attributes_0_quantity", with: 3
70
+ click_button "Update"
71
+
72
+ # Apply the promo code and see a $10 discount (for 2 of the 3 items)
73
+ fill_in "Coupon code", with: "PROMO"
74
+ click_button "Update"
75
+ expect(page).to have_content("The coupon code was successfully applied to your order")
76
+ within("#cart_adjustments") do
77
+ expect(page).to have_content("-$10.00")
78
+ end
79
+
80
+ # Add a different product to our cart with quantity of 2.
81
+ visit spree.root_path
82
+ click_link "E-11"
83
+ fill_in "quantity", with: "2"
84
+ click_button "Add To Cart"
85
+
86
+ # We now have 5 items total, so discount should increase.
87
+ within("#cart_adjustments") do
88
+ expect(page).to have_content("-$20.00")
89
+ end
90
+ end
91
+
92
+ context "with a group size of 3" do
93
+ given(:action) do
94
+ Spree::Promotion::Actions::CreateQuantityAdjustments.create(
95
+ calculator: calculator,
96
+ preferred_group_size: 3
97
+ )
98
+ end
99
+
100
+ background { FactoryBot.create(:product, name: "DC-15A") }
101
+
102
+ scenario "odd number of changes to quantities" do
103
+ fill_in "order_line_items_attributes_0_quantity", with: 3
104
+ click_button "Update"
105
+
106
+ # Apply the promo code and see a $15 discount
107
+ fill_in "Coupon code", with: "PROMO"
108
+ click_button "Update"
109
+ expect(page).to have_content("The coupon code was successfully applied to your order")
110
+ within("#cart_adjustments") do
111
+ expect(page).to have_content("-$15.00")
112
+ end
113
+
114
+ # Add two different products to our cart
115
+ visit spree.root_path
116
+ click_link "E-11"
117
+ click_button "Add To Cart"
118
+ within("#cart_adjustments") do
119
+ expect(page).to have_content("-$15.00")
120
+ end
121
+
122
+ # Reduce quantity of first item to 2
123
+ fill_in "order_line_items_attributes_0_quantity", with: 2
124
+ click_button "Update"
125
+ within("#cart_adjustments") do
126
+ expect(page).to have_content("-$15.00")
127
+ end
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,158 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "viewing products", type: :feature, inaccessible: true do
6
+ let!(:taxonomy) { create(:taxonomy, name: "Category") }
7
+ let!(:super_clothing) { taxonomy.root.children.create(name: "Super Clothing") }
8
+ let!(:t_shirts) { super_clothing.children.create(name: "T-Shirts") }
9
+ let!(:xxl) { t_shirts.children.create(name: "XXL") }
10
+ let!(:product) do
11
+ product = create(:product, name: "Superman T-Shirt")
12
+ product.taxons << t_shirts
13
+ end
14
+ let(:metas) { { meta_description: 'Brand new Ruby on Rails TShirts', meta_title: "Ruby On Rails TShirt", meta_keywords: 'ror, tshirt, ruby' } }
15
+ let(:store_name) do
16
+ ((first_store = Spree::Store.first) && first_store.name).to_s
17
+ end
18
+
19
+ # Regression test for https://github.com/spree/spree/issues/1796
20
+ it "can see a taxon's products, even if that taxon has child taxons" do
21
+ visit '/t/category/super-clothing/t-shirts'
22
+ expect(page).to have_content("Superman T-Shirt")
23
+ end
24
+
25
+ it "shouldn't show nested taxons with a search" do
26
+ visit '/t/category/super-clothing?keywords=shirt'
27
+ expect(page).to have_content("Superman T-Shirt")
28
+ expect(page).not_to have_selector("div[data-hook='taxon_children']")
29
+ end
30
+
31
+ describe 'meta tags and title' do
32
+ it 'displays metas' do
33
+ t_shirts.update_attributes metas
34
+ visit '/t/category/super-clothing/t-shirts'
35
+ expect(page).to have_meta(:description, 'Brand new Ruby on Rails TShirts')
36
+ expect(page).to have_meta(:keywords, 'ror, tshirt, ruby')
37
+ end
38
+
39
+ it 'display title if set' do
40
+ t_shirts.update_attributes metas
41
+ visit '/t/category/super-clothing/t-shirts'
42
+ expect(page).to have_title("Ruby On Rails TShirt")
43
+ end
44
+
45
+ it 'displays title from taxon root and taxon name' do
46
+ visit '/t/category/super-clothing/t-shirts'
47
+ expect(page).to have_title('Category - T-Shirts - ' + store_name)
48
+ end
49
+
50
+ # Regression test for https://github.com/spree/spree/issues/2814
51
+ it "doesn't use meta_title as heading on page" do
52
+ t_shirts.update_attributes metas
53
+ visit '/t/category/super-clothing/t-shirts'
54
+ within("h1.taxon-title") do
55
+ expect(page).to have_content(t_shirts.name)
56
+ end
57
+ end
58
+
59
+ it 'uses taxon name in title when meta_title set to empty string' do
60
+ t_shirts.update_attributes meta_title: ''
61
+ visit '/t/category/super-clothing/t-shirts'
62
+ expect(page).to have_title('Category - T-Shirts - ' + store_name)
63
+ end
64
+ end
65
+
66
+ context "taxon pages" do
67
+ include_context "custom products"
68
+ before do
69
+ visit spree.root_path
70
+ end
71
+
72
+ it "should be able to visit brand Ruby on Rails" do
73
+ within(:css, '#taxonomies') { click_link "Ruby on Rails" }
74
+
75
+ expect(page.all('ul.product-listing li').size).to eq(7)
76
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
77
+ tmp.delete("")
78
+ array = ["Ruby on Rails Bag",
79
+ "Ruby on Rails Baseball Jersey",
80
+ "Ruby on Rails Jr. Spaghetti",
81
+ "Ruby on Rails Mug",
82
+ "Ruby on Rails Ringer T-Shirt",
83
+ "Ruby on Rails Stein",
84
+ "Ruby on Rails Tote"]
85
+ expect(tmp.sort!).to eq(array)
86
+ end
87
+
88
+ it "should be able to visit brand Ruby" do
89
+ within(:css, '#taxonomies') { click_link "Ruby" }
90
+
91
+ expect(page.all('ul.product-listing li').size).to eq(1)
92
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
93
+ tmp.delete("")
94
+ expect(tmp.sort!).to eq(["Ruby Baseball Jersey"])
95
+ end
96
+
97
+ it "should be able to visit brand Apache" do
98
+ within(:css, '#taxonomies') { click_link "Apache" }
99
+
100
+ expect(page.all('ul.product-listing li').size).to eq(1)
101
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
102
+ tmp.delete("")
103
+ expect(tmp.sort!).to eq(["Apache Baseball Jersey"])
104
+ end
105
+
106
+ it "should be able to visit category Clothing" do
107
+ click_link "Clothing"
108
+
109
+ expect(page.all('ul.product-listing li').size).to eq(5)
110
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
111
+ tmp.delete("")
112
+ expect(tmp.sort!).to eq(["Apache Baseball Jersey",
113
+ "Ruby Baseball Jersey",
114
+ "Ruby on Rails Baseball Jersey",
115
+ "Ruby on Rails Jr. Spaghetti",
116
+ "Ruby on Rails Ringer T-Shirt"])
117
+ end
118
+
119
+ it "should be able to visit category Mugs" do
120
+ click_link "Mugs"
121
+
122
+ expect(page.all('ul.product-listing li').size).to eq(2)
123
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
124
+ tmp.delete("")
125
+ expect(tmp.sort!).to eq(["Ruby on Rails Mug", "Ruby on Rails Stein"])
126
+ end
127
+
128
+ it "should be able to visit category Bags" do
129
+ click_link "Bags"
130
+
131
+ expect(page.all('ul.product-listing li').size).to eq(2)
132
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
133
+ tmp.delete("")
134
+ expect(tmp.sort!).to eq(["Ruby on Rails Bag", "Ruby on Rails Tote"])
135
+ end
136
+ end
137
+
138
+ # Regression test for https://github.com/solidusio/solidus/issues/2602
139
+ context "root taxon page" do
140
+ it "shows taxon previews" do
141
+ visit spree.nested_taxons_path(taxonomy.root)
142
+
143
+ expect(page).to have_css('ul.product-listing li', count: 2)
144
+ expect(page).to have_content("Superman T-Shirt", count: 2)
145
+ end
146
+
147
+ context "with prices in other currency" do
148
+ before { Spree::Price.update_all(currency: "CAD") }
149
+
150
+ it "shows no products" do
151
+ visit spree.nested_taxons_path(taxonomy.root)
152
+
153
+ expect(page).to have_css('ul.product-listing li', count: 0)
154
+ expect(page).to have_no_content("Superman T-Shirt")
155
+ end
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "Template rendering", type: :feature do
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
+ it 'layout should have canonical tag referencing site url' do
15
+ Spree::Store.create!(code: 'spree', name: 'My Spree Store', url: 'spreestore.example.com', mail_from_address: 'test@example.com')
16
+
17
+ visit spree.root_path
18
+ expect(find('link[rel=canonical]')[:href]).to eql('http://spreestore.example.com/')
19
+ end
20
+ end
Binary file