spree_frontend 3.2.9 → 3.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/checkout_controller.rb +8 -2
- data/app/controllers/spree/orders_controller.rb +7 -3
- data/app/controllers/spree/products_controller.rb +3 -1
- data/app/helpers/spree/frontend_helper.rb +1 -1
- data/app/helpers/spree/taxons_helper.rb +2 -3
- data/app/views/spree/checkout/_confirm.html.erb +3 -0
- data/app/views/spree/checkout/_summary.html.erb +1 -1
- data/app/views/spree/checkout/payment/_storecredit.html.erb +1 -0
- data/app/views/spree/products/_cart_form.html.erb +3 -3
- data/app/views/spree/shared/_main_nav_bar.html.erb +1 -1
- data/app/views/spree/shared/_order_details.html.erb +0 -1
- data/app/views/spree/shared/_products.html.erb +4 -1
- data/spec/controllers/controller_extension_spec.rb +126 -0
- data/spec/controllers/controller_helpers_spec.rb +122 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +547 -0
- data/spec/controllers/spree/checkout_controller_with_views_spec.rb +36 -0
- data/spec/controllers/spree/content_controller_spec.rb +12 -0
- data/spec/controllers/spree/current_order_tracking_spec.rb +44 -0
- data/spec/controllers/spree/home_controller_spec.rb +47 -0
- data/spec/controllers/spree/orders_controller_ability_spec.rb +96 -0
- data/spec/controllers/spree/orders_controller_spec.rb +134 -0
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +31 -0
- data/spec/controllers/spree/products_controller_spec.rb +87 -0
- data/spec/controllers/spree/taxons_controller_spec.rb +12 -0
- data/spec/features/address_spec.rb +93 -0
- data/spec/features/automatic_promotion_adjustments_spec.rb +47 -0
- data/spec/features/caching/products_spec.rb +59 -0
- data/spec/features/caching/taxons_spec.rb +22 -0
- data/spec/features/cart_spec.rb +132 -0
- data/spec/features/checkout_spec.rb +723 -0
- data/spec/features/checkout_unshippable_spec.rb +34 -0
- data/spec/features/coupon_code_spec.rb +88 -0
- data/spec/features/currency_spec.rb +18 -0
- data/spec/features/delivery_spec.rb +64 -0
- data/spec/features/free_shipping_promotions_spec.rb +59 -0
- data/spec/features/locale_spec.rb +60 -0
- data/spec/features/microdata_spec.rb +0 -0
- data/spec/features/order_spec.rb +107 -0
- data/spec/features/page_promotions_spec.rb +36 -0
- data/spec/features/products_spec.rb +345 -0
- data/spec/features/taxons_spec.rb +147 -0
- data/spec/features/template_rendering_spec.rb +19 -0
- data/spec/helpers/frontend_helper_spec.rb +57 -0
- data/spec/helpers/taxons_helper_spec.rb +17 -0
- data/spec/spec_helper.rb +128 -0
- data/spec/support/shared_contexts/checkout_setup.rb +10 -0
- data/spec/support/shared_contexts/custom_products.rb +25 -0
- data/spec/support/shared_contexts/product_prototypes.rb +30 -0
- data/spec/views/spree/checkout/_summary_spec.rb +11 -0
- data/spree_frontend.gemspec +5 -4
- metadata +90 -15
@@ -0,0 +1,345 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "Visiting Products", type: :feature, inaccessible: true do
|
5
|
+
include_context "custom products"
|
6
|
+
|
7
|
+
let(:store_name) do
|
8
|
+
((first_store = Spree::Store.first) && first_store.name).to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
visit spree.root_path
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be able to show the shopping cart after adding a product to it" do
|
16
|
+
click_link "Ruby on Rails Ringer T-Shirt"
|
17
|
+
expect(page).to have_content("$19.99")
|
18
|
+
|
19
|
+
click_button 'add-to-cart-button'
|
20
|
+
expect(page).to have_content("Shopping Cart")
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "correct displaying of microdata" do
|
24
|
+
let(:product) { Spree::Product.find_by(name: 'Ruby on Rails Ringer T-Shirt') }
|
25
|
+
|
26
|
+
it "on products page" do
|
27
|
+
within("#product_#{product.id}") do
|
28
|
+
within('[itemprop=name]') do
|
29
|
+
expect(page).to have_content('Ruby on Rails Ringer T-Shirt')
|
30
|
+
end
|
31
|
+
expect(page).to have_css("[itemprop='price'][content='19.99']")
|
32
|
+
expect(page).to have_css("[itemprop='priceCurrency'][content='USD']")
|
33
|
+
expect(page).to have_css("[itemprop='url'][href='/products/ruby-on-rails-ringer-t-shirt']")
|
34
|
+
expect(page).to have_css("[itemprop='image'][src*='/assets/noimage/small']")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "on product page" do
|
39
|
+
click_link product.name
|
40
|
+
within('[data-hook=product_show]') do
|
41
|
+
within('[itemprop=name]') do
|
42
|
+
expect(page).to have_content('Ruby on Rails Ringer T-Shirt')
|
43
|
+
end
|
44
|
+
expect(page).to have_css("[itemprop='price'][content='19.99']")
|
45
|
+
expect(page).to have_css("[itemprop='priceCurrency'][content='USD']")
|
46
|
+
expect(page).to have_css("[itemprop='image'][src*='/assets/noimage/product']")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'meta tags and title' do
|
52
|
+
let(:jersey) { Spree::Product.find_by_name('Ruby on Rails Baseball Jersey') }
|
53
|
+
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' } }
|
54
|
+
|
55
|
+
it 'should return the correct title when displaying a single product' do
|
56
|
+
click_link jersey.name
|
57
|
+
expect(page).to have_title('Ruby on Rails Baseball Jersey - ' + store_name)
|
58
|
+
within('div#product-description') do
|
59
|
+
within('h1.product-title') do
|
60
|
+
expect(page).to have_content('Ruby on Rails Baseball Jersey')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'displays metas' do
|
66
|
+
jersey.update_attributes metas
|
67
|
+
click_link jersey.name
|
68
|
+
expect(page).to have_meta(:description, 'Brand new Ruby on Rails Jersey')
|
69
|
+
expect(page).to have_meta(:keywords, 'ror, jersey, ruby')
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'displays title if set' do
|
73
|
+
jersey.update_attributes metas
|
74
|
+
click_link jersey.name
|
75
|
+
expect(page).to have_title('Ruby on Rails Baseball Jersey Buy High Quality Geek Apparel')
|
76
|
+
end
|
77
|
+
|
78
|
+
it "doesn't use meta_title as heading on page" do
|
79
|
+
jersey.update_attributes metas
|
80
|
+
click_link jersey.name
|
81
|
+
within("h1") do
|
82
|
+
expect(page).to have_content(jersey.name)
|
83
|
+
expect(page).not_to have_content(jersey.meta_title)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'uses product name in title when meta_title set to empty string' do
|
88
|
+
jersey.update_attributes meta_title: ''
|
89
|
+
click_link jersey.name
|
90
|
+
expect(page).to have_title('Ruby on Rails Baseball Jersey - ' + store_name)
|
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 #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", js: true do
|
133
|
+
visit spree.product_path(product)
|
134
|
+
click_button "Add To Cart"
|
135
|
+
click_button "Checkout"
|
136
|
+
fill_in "order_email", with: "test@example.com"
|
137
|
+
click_button 'Continue'
|
138
|
+
within("tr[data-hook=item_total]") do
|
139
|
+
expect(page).to have_content("19.99 ₽")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should be able to search for a product" do
|
146
|
+
fill_in "keywords", with: "shirt"
|
147
|
+
click_button "Search"
|
148
|
+
|
149
|
+
expect(page.all('#products .product-list-item').size).to eq(1)
|
150
|
+
end
|
151
|
+
|
152
|
+
context "a product with variants" do
|
153
|
+
let(:product) { Spree::Product.find_by_name("Ruby on Rails Baseball Jersey") }
|
154
|
+
let(:option_value) { create(:option_value) }
|
155
|
+
let!(:variant) { build(:variant, price: 5.59, product: product, option_values: []) }
|
156
|
+
|
157
|
+
before do
|
158
|
+
# Need to have two images to trigger the error
|
159
|
+
image = File.open(File.expand_path('../../fixtures/thinking-cat.jpg', __FILE__))
|
160
|
+
product.images.create!(attachment: image)
|
161
|
+
product.images.create!(attachment: image)
|
162
|
+
|
163
|
+
product.option_types << option_value.option_type
|
164
|
+
variant.option_values << option_value
|
165
|
+
variant.save!
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should be displayed" do
|
169
|
+
expect { click_link product.name }.to_not raise_error
|
170
|
+
end
|
171
|
+
|
172
|
+
it "displays price of first variant listed", js: true do
|
173
|
+
click_link product.name
|
174
|
+
within("#product-price") do
|
175
|
+
expect(page).to have_content variant.price
|
176
|
+
expect(page).not_to have_content Spree.t(:out_of_stock)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
it "doesn't display out of stock for master product" do
|
181
|
+
product.master.stock_items.update_all count_on_hand: 0, backorderable: false
|
182
|
+
|
183
|
+
click_link product.name
|
184
|
+
within("#product-price") do
|
185
|
+
expect(page).not_to have_content Spree.t(:out_of_stock)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
it "doesn't display cart form if all variants (including master) are out of stock" do
|
190
|
+
product.variants_including_master.each { |v| v.stock_items.update_all count_on_hand: 0, backorderable: false }
|
191
|
+
|
192
|
+
click_link product.name
|
193
|
+
within("[data-hook=product_price]") do
|
194
|
+
expect(page).not_to have_content Spree.t(:add_to_cart)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
context "a product with variants, images only for the variants" do
|
200
|
+
let(:product) { Spree::Product.find_by_name("Ruby on Rails Baseball Jersey") }
|
201
|
+
let(:variant1) { create(:variant, product: product, price: 9.99) }
|
202
|
+
let(:variant2) { create(:variant, product: product, price: 10.99) }
|
203
|
+
|
204
|
+
before do
|
205
|
+
image = File.open(File.expand_path('../../fixtures/thinking-cat.jpg', __FILE__))
|
206
|
+
variant1.images.create!(attachment: image)
|
207
|
+
variant2.images.create!(attachment: image)
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should not display no image available" do
|
211
|
+
visit spree.root_path
|
212
|
+
expect(page).to have_xpath("//img[contains(@src,'thinking-cat')]")
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context "an out of stock product without variants" do
|
217
|
+
let(:product) { Spree::Product.find_by_name("Ruby on Rails Tote") }
|
218
|
+
|
219
|
+
before do
|
220
|
+
product.master.stock_items.update_all count_on_hand: 0, backorderable: false
|
221
|
+
end
|
222
|
+
|
223
|
+
it "does display out of stock for master product" do
|
224
|
+
click_link product.name
|
225
|
+
within("#product-price") do
|
226
|
+
expect(page).to have_content Spree.t(:out_of_stock)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
it "doesn't display cart form if master is out of stock" do
|
231
|
+
click_link product.name
|
232
|
+
within("[data-hook=product_price]") do
|
233
|
+
expect(page).not_to have_content Spree.t(:add_to_cart)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
context 'product with taxons' do
|
239
|
+
let(:product) { Spree::Product.find_by_name("Ruby on Rails Tote") }
|
240
|
+
let(:taxon) { product.taxons.first }
|
241
|
+
|
242
|
+
it 'displays breadcrumbs for the default taxon when none selected' do
|
243
|
+
click_link product.name
|
244
|
+
within("#breadcrumbs") do
|
245
|
+
expect(page).to have_content taxon.name
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'displays selected taxon in breadcrumbs' do
|
250
|
+
taxon = Spree::Taxon.last
|
251
|
+
product.taxons << taxon
|
252
|
+
product.save!
|
253
|
+
visit '/t/' + taxon.to_param
|
254
|
+
click_link product.name
|
255
|
+
within("#breadcrumbs") do
|
256
|
+
expect(page).to have_content taxon.name
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should be able to hide products without price" do
|
262
|
+
expect(page.all('#products .product-list-item').size).to eq(9)
|
263
|
+
Spree::Config.show_products_without_price = false
|
264
|
+
Spree::Config.currency = "CAN"
|
265
|
+
visit spree.root_path
|
266
|
+
expect(page.all('#products .product-list-item').size).to eq(0)
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
it "should be able to display products priced under 10 dollars" do
|
271
|
+
within(:css, '#taxonomies') { click_link "Ruby on Rails" }
|
272
|
+
check "Price_Range_Under_$10.00"
|
273
|
+
within(:css, '#sidebar_products_search') { click_button "Search" }
|
274
|
+
expect(page).to have_content("No products found")
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should be able to display products priced between 15 and 18 dollars" do
|
278
|
+
within(:css, '#taxonomies') { click_link "Ruby on Rails" }
|
279
|
+
check "Price_Range_$15.00_-_$18.00"
|
280
|
+
within(:css, '#sidebar_products_search') { click_button "Search" }
|
281
|
+
|
282
|
+
expect(page.all('#products .product-list-item').size).to eq(3)
|
283
|
+
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
|
284
|
+
tmp.delete("")
|
285
|
+
expect(tmp.sort!).to eq(["Ruby on Rails Mug", "Ruby on Rails Stein", "Ruby on Rails Tote"])
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should be able to display products priced between 15 and 18 dollars across multiple pages" do
|
289
|
+
Spree::Config.products_per_page = 2
|
290
|
+
within(:css, '#taxonomies') { click_link "Ruby on Rails" }
|
291
|
+
check "Price_Range_$15.00_-_$18.00"
|
292
|
+
within(:css, '#sidebar_products_search') { click_button "Search" }
|
293
|
+
|
294
|
+
expect(page.all('#products .product-list-item').size).to eq(2)
|
295
|
+
products = page.all('#products .product-list-item span[itemprop=name]')
|
296
|
+
expect(products.count).to eq(2)
|
297
|
+
|
298
|
+
find('.pagination .next a').click
|
299
|
+
products = page.all('#products .product-list-item span[itemprop=name]')
|
300
|
+
expect(products.count).to eq(1)
|
301
|
+
end
|
302
|
+
|
303
|
+
it "should be able to display products priced 18 dollars and above" do
|
304
|
+
within(:css, '#taxonomies') { click_link "Ruby on Rails" }
|
305
|
+
check "Price_Range_$18.00_-_$20.00"
|
306
|
+
check "Price_Range_$20.00_or_over"
|
307
|
+
within(:css, '#sidebar_products_search') { click_button "Search" }
|
308
|
+
|
309
|
+
expect(page.all('#products .product-list-item').size).to eq(4)
|
310
|
+
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
|
311
|
+
tmp.delete("")
|
312
|
+
expect(tmp.sort!).to eq(["Ruby on Rails Bag",
|
313
|
+
"Ruby on Rails Baseball Jersey",
|
314
|
+
"Ruby on Rails Jr. Spaghetti",
|
315
|
+
"Ruby on Rails Ringer T-Shirt"])
|
316
|
+
end
|
317
|
+
|
318
|
+
it "should be able to put a product without a description in the cart" do
|
319
|
+
product = FactoryGirl.create(:base_product, description: nil, name: 'Sample', price: '19.99')
|
320
|
+
visit spree.product_path(product)
|
321
|
+
expect(page).to have_content "This product has no description"
|
322
|
+
click_button 'add-to-cart-button'
|
323
|
+
expect(page).to have_content "This product has no description"
|
324
|
+
end
|
325
|
+
|
326
|
+
it "shouldn't be able to put a product without a current price in the cart" do
|
327
|
+
product = FactoryGirl.create(:base_product, description: nil, name: 'Sample', price: '19.99')
|
328
|
+
Spree::Config.currency = "CAN"
|
329
|
+
Spree::Config.show_products_without_price = true
|
330
|
+
visit spree.product_path(product)
|
331
|
+
expect(page).to have_content "This product is not available in the selected currency."
|
332
|
+
expect(page).not_to have_content "add-to-cart-button"
|
333
|
+
end
|
334
|
+
|
335
|
+
it "should return the correct title when displaying a single product" do
|
336
|
+
product = Spree::Product.find_by_name("Ruby on Rails Baseball Jersey")
|
337
|
+
click_link product.name
|
338
|
+
|
339
|
+
within("div#product-description") do
|
340
|
+
within("h1.product-title") do
|
341
|
+
expect(page).to have_content("Ruby on Rails Baseball Jersey")
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "viewing products", type: :feature, inaccessible: true do
|
4
|
+
let!(:taxonomy) { create(:taxonomy, name: "Category") }
|
5
|
+
let!(:super_clothing) { taxonomy.root.children.create(name: "Super Clothing") }
|
6
|
+
let!(:t_shirts) { super_clothing.children.create(name: "T-Shirts") }
|
7
|
+
let!(:xxl) { t_shirts.children.create(name: "XXL") }
|
8
|
+
let!(:product) do
|
9
|
+
product = create(:product, name: "Superman T-Shirt")
|
10
|
+
product.taxons << t_shirts
|
11
|
+
end
|
12
|
+
let(:metas) { { meta_description: 'Brand new Ruby on Rails TShirts', meta_title: "Ruby On Rails TShirt", meta_keywords: 'ror, tshirt, ruby' } }
|
13
|
+
let(:store_name) do
|
14
|
+
((first_store = Spree::Store.first) && first_store.name).to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
# Regression test for #1796
|
18
|
+
it "can see a taxon's products, even if that taxon has child taxons" do
|
19
|
+
visit '/t/category/super-clothing/t-shirts'
|
20
|
+
expect(page).to have_content("Superman T-Shirt")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "shouldn't show nested taxons with a search" do
|
24
|
+
visit '/t/category/super-clothing?keywords=shirt'
|
25
|
+
expect(page).to have_content("Superman T-Shirt")
|
26
|
+
expect(page).not_to have_selector("div[data-hook='taxon_children']")
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'breadcrumbs' do
|
30
|
+
before do
|
31
|
+
visit '/t/category/super-clothing/t-shirts'
|
32
|
+
end
|
33
|
+
it "should render breadcrumbs" do
|
34
|
+
expect(page.find("#breadcrumbs")).to have_link("T-Shirts")
|
35
|
+
end
|
36
|
+
it "should mark last breadcrumb as active" do
|
37
|
+
expect(page.find('#breadcrumbs .active')).to have_link("T-Shirts")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'meta tags and title' do
|
42
|
+
it 'displays metas' do
|
43
|
+
t_shirts.update_attributes metas
|
44
|
+
visit '/t/category/super-clothing/t-shirts'
|
45
|
+
expect(page).to have_meta(:description, 'Brand new Ruby on Rails TShirts')
|
46
|
+
expect(page).to have_meta(:keywords, 'ror, tshirt, ruby')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'display title if set' do
|
50
|
+
t_shirts.update_attributes metas
|
51
|
+
visit '/t/category/super-clothing/t-shirts'
|
52
|
+
expect(page).to have_title("Ruby On Rails TShirt")
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'displays title from taxon root and taxon name' do
|
56
|
+
visit '/t/category/super-clothing/t-shirts'
|
57
|
+
expect(page).to have_title('Category - T-Shirts - ' + store_name)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Regression test for #2814
|
61
|
+
it "doesn't use meta_title as heading on page" do
|
62
|
+
t_shirts.update_attributes metas
|
63
|
+
visit '/t/category/super-clothing/t-shirts'
|
64
|
+
within("h1.taxon-title") do
|
65
|
+
expect(page).to have_content(t_shirts.name)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'uses taxon name in title when meta_title set to empty string' do
|
70
|
+
t_shirts.update_attributes meta_title: ''
|
71
|
+
visit '/t/category/super-clothing/t-shirts'
|
72
|
+
expect(page).to have_title('Category - T-Shirts - ' + store_name)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "taxon pages" do
|
77
|
+
include_context "custom products"
|
78
|
+
before do
|
79
|
+
visit spree.root_path
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should be able to visit brand Ruby on Rails" do
|
83
|
+
within(:css, '#taxonomies') { click_link "Ruby on Rails" }
|
84
|
+
|
85
|
+
expect(page.all('#products .product-list-item').size).to eq(7)
|
86
|
+
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
|
87
|
+
tmp.delete("")
|
88
|
+
array = ["Ruby on Rails Bag",
|
89
|
+
"Ruby on Rails Baseball Jersey",
|
90
|
+
"Ruby on Rails Jr. Spaghetti",
|
91
|
+
"Ruby on Rails Mug",
|
92
|
+
"Ruby on Rails Ringer T-Shirt",
|
93
|
+
"Ruby on Rails Stein",
|
94
|
+
"Ruby on Rails Tote"]
|
95
|
+
expect(tmp.sort!).to eq(array)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should be able to visit brand Ruby" do
|
99
|
+
within(:css, '#taxonomies') { click_link "Ruby" }
|
100
|
+
|
101
|
+
expect(page.all('#products .product-list-item').size).to eq(1)
|
102
|
+
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
|
103
|
+
tmp.delete("")
|
104
|
+
expect(tmp.sort!).to eq(["Ruby Baseball Jersey"])
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should be able to visit brand Apache" do
|
108
|
+
within(:css, '#taxonomies') { click_link "Apache" }
|
109
|
+
|
110
|
+
expect(page.all('#products .product-list-item').size).to eq(1)
|
111
|
+
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
|
112
|
+
tmp.delete("")
|
113
|
+
expect(tmp.sort!).to eq(["Apache Baseball Jersey"])
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should be able to visit category Clothing" do
|
117
|
+
click_link "Clothing"
|
118
|
+
|
119
|
+
expect(page.all('#products .product-list-item').size).to eq(5)
|
120
|
+
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
|
121
|
+
tmp.delete("")
|
122
|
+
expect(tmp.sort!).to eq(["Apache Baseball Jersey",
|
123
|
+
"Ruby Baseball Jersey",
|
124
|
+
"Ruby on Rails Baseball Jersey",
|
125
|
+
"Ruby on Rails Jr. Spaghetti",
|
126
|
+
"Ruby on Rails Ringer T-Shirt"])
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should be able to visit category Mugs" do
|
130
|
+
click_link "Mugs"
|
131
|
+
|
132
|
+
expect(page.all('#products .product-list-item').size).to eq(2)
|
133
|
+
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
|
134
|
+
tmp.delete("")
|
135
|
+
expect(tmp.sort!).to eq(["Ruby on Rails Mug", "Ruby on Rails Stein"])
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should be able to visit category Bags" do
|
139
|
+
click_link "Bags"
|
140
|
+
|
141
|
+
expect(page.all('#products .product-list-item').size).to eq(2)
|
142
|
+
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
|
143
|
+
tmp.delete("")
|
144
|
+
expect(tmp.sort!).to eq(["Ruby on Rails Bag", "Ruby on Rails Tote"])
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Template rendering", type: :feature do
|
4
|
+
|
5
|
+
after do
|
6
|
+
Capybara.ignore_hidden_elements = true
|
7
|
+
end
|
8
|
+
|
9
|
+
before do
|
10
|
+
Capybara.ignore_hidden_elements = false
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'layout should have canonical tag referencing site url' do
|
14
|
+
Spree::Store.create!(code: 'spree', name: 'My Spree Store', url: 'spreestore.example.com', mail_from_address: 'test@example.com')
|
15
|
+
|
16
|
+
visit spree.root_path
|
17
|
+
expect(find('link[rel=canonical]')[:href]).to eql('http://spreestore.example.com/')
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
describe FrontendHelper, type: :helper do
|
5
|
+
# Regression test for #2034
|
6
|
+
context "flash_message" do
|
7
|
+
let(:flash) { { "notice" => "ok", "foo" => "foo", "bar" => "bar" } }
|
8
|
+
|
9
|
+
it "should output all flash content" do
|
10
|
+
flash_messages
|
11
|
+
html = Nokogiri::HTML(helper.output_buffer)
|
12
|
+
expect(html.css(".alert-notice").text).to eq("ok")
|
13
|
+
expect(html.css(".alert-foo").text).to eq("foo")
|
14
|
+
expect(html.css(".alert-bar").text).to eq("bar")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should output flash content except one key" do
|
18
|
+
flash_messages(ignore_types: :bar)
|
19
|
+
html = Nokogiri::HTML(helper.output_buffer)
|
20
|
+
expect(html.css(".alert-notice").text).to eq("ok")
|
21
|
+
expect(html.css(".alert-foo").text).to eq("foo")
|
22
|
+
expect(html.css(".alert-bar").text).to be_empty
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should output flash content except some keys" do
|
26
|
+
flash_messages(ignore_types: [:foo, :bar])
|
27
|
+
html = Nokogiri::HTML(helper.output_buffer)
|
28
|
+
expect(html.css(".alert-notice").text).to eq("ok")
|
29
|
+
expect(html.css(".alert-foo").text).to be_empty
|
30
|
+
expect(html.css(".alert-bar").text).to be_empty
|
31
|
+
expect(helper.output_buffer).to eq("<div class=\"alert alert-notice\">ok</div>")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Regression test for #2759
|
36
|
+
it "nested_taxons_path works with a Taxon object" do
|
37
|
+
taxon = create(:taxon, name: "iphone")
|
38
|
+
expect(spree.nested_taxons_path(taxon)).to eq("/t/iphone")
|
39
|
+
end
|
40
|
+
|
41
|
+
context '#checkout_progress' do
|
42
|
+
before do
|
43
|
+
@order = create(:order, state: 'address')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'does not include numbers by default' do
|
47
|
+
output = checkout_progress
|
48
|
+
expect(output).to_not include('1.')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'has option to include numbers' do
|
52
|
+
output = checkout_progress(numbers: true)
|
53
|
+
expect(output).to include('1.')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::TaxonsHelper, type: :helper do
|
4
|
+
# Regression test for #4382
|
5
|
+
it "#taxon_preview" do
|
6
|
+
taxon = create(:taxon)
|
7
|
+
child_taxon = create(:taxon, parent: taxon)
|
8
|
+
product_1 = create(:product)
|
9
|
+
product_2 = create(:product)
|
10
|
+
product_3 = create(:product)
|
11
|
+
taxon.products << product_1
|
12
|
+
taxon.products << product_2
|
13
|
+
child_taxon.products << product_3
|
14
|
+
|
15
|
+
expect(taxon_preview(taxon.reload)).to eql([product_1, product_2, product_3])
|
16
|
+
end
|
17
|
+
end
|