spree_frontend 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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/products_controller.rb +1 -1
  3. data/app/views/spree/shared/_taxonomies.html.erb +4 -2
  4. data/spree_frontend.gemspec +1 -2
  5. metadata +8 -84
  6. data/spec/controllers/controller_extension_spec.rb +0 -126
  7. data/spec/controllers/controller_helpers_spec.rb +0 -122
  8. data/spec/controllers/spree/checkout_controller_spec.rb +0 -462
  9. data/spec/controllers/spree/checkout_controller_with_views_spec.rb +0 -36
  10. data/spec/controllers/spree/content_controller_spec.rb +0 -12
  11. data/spec/controllers/spree/current_order_tracking_spec.rb +0 -44
  12. data/spec/controllers/spree/home_controller_spec.rb +0 -47
  13. data/spec/controllers/spree/orders_controller_ability_spec.rb +0 -96
  14. data/spec/controllers/spree/orders_controller_spec.rb +0 -134
  15. data/spec/controllers/spree/orders_controller_transitions_spec.rb +0 -31
  16. data/spec/controllers/spree/products_controller_spec.rb +0 -87
  17. data/spec/controllers/spree/taxons_controller_spec.rb +0 -12
  18. data/spec/features/address_spec.rb +0 -93
  19. data/spec/features/automatic_promotion_adjustments_spec.rb +0 -47
  20. data/spec/features/caching/products_spec.rb +0 -59
  21. data/spec/features/caching/taxons_spec.rb +0 -22
  22. data/spec/features/cart_spec.rb +0 -90
  23. data/spec/features/checkout_spec.rb +0 -572
  24. data/spec/features/checkout_unshippable_spec.rb +0 -34
  25. data/spec/features/coupon_code_spec.rb +0 -88
  26. data/spec/features/currency_spec.rb +0 -18
  27. data/spec/features/free_shipping_promotions_spec.rb +0 -59
  28. data/spec/features/locale_spec.rb +0 -60
  29. data/spec/features/microdata_spec.rb +0 -0
  30. data/spec/features/order_spec.rb +0 -74
  31. data/spec/features/page_promotions_spec.rb +0 -36
  32. data/spec/features/products_spec.rb +0 -334
  33. data/spec/features/taxons_spec.rb +0 -147
  34. data/spec/features/template_rendering_spec.rb +0 -19
  35. data/spec/fixtures/thinking-cat.jpg +0 -0
  36. data/spec/helpers/frontend_helper_spec.rb +0 -57
  37. data/spec/helpers/order_helper_spec.rb +0 -12
  38. data/spec/helpers/taxons_helper_spec.rb +0 -17
  39. data/spec/spec_helper.rb +0 -126
  40. data/spec/support/shared_contexts/checkout_setup.rb +0 -10
  41. data/spec/support/shared_contexts/custom_products.rb +0 -25
  42. data/spec/support/shared_contexts/product_prototypes.rb +0 -30
  43. data/spec/views/spree/checkout/_summary_spec.rb +0 -11
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "checkout with unshippable items", type: :feature, inaccessible: true do
4
- let!(:stock_location) { create(:stock_location) }
5
- let(:order) { OrderWalkthrough.up_to(:delivery) }
6
-
7
- before do
8
- OrderWalkthrough.add_line_item!(order)
9
- line_item = order.line_items.last
10
- stock_item = stock_location.stock_item(line_item.variant)
11
- stock_item.adjust_count_on_hand -999
12
- stock_item.backorderable = false
13
- stock_item.save!
14
-
15
- user = create(:user)
16
- order.user = user
17
- order.update_with_updater!
18
-
19
- allow_any_instance_of(Spree::CheckoutController).to receive_messages(:current_order => order)
20
- allow_any_instance_of(Spree::CheckoutController).to receive_messages(:try_spree_current_user => user)
21
- allow_any_instance_of(Spree::CheckoutController).to receive_messages(:skip_state_validation? => true)
22
- allow_any_instance_of(Spree::CheckoutController).to receive_messages(:ensure_sufficient_stock_lines => true)
23
- end
24
-
25
- it 'displays and removes' do
26
- visit spree.checkout_state_path(:delivery)
27
- expect(page).to have_content('Unshippable Items')
28
-
29
- click_button "Save and Continue"
30
-
31
- order.reload
32
- expect(order.line_items.count).to eq 1
33
- end
34
- end
@@ -1,88 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Coupon code promotions", type: :feature, js: true do
4
- let!(:country) { create(:country, name: "United States of America", states_required: true) }
5
- let!(:state) { create(:state, name: "Alabama", country: country) }
6
- let!(:zone) { create(:zone) }
7
- let!(:shipping_method) { create(:shipping_method) }
8
- let!(:payment_method) { create(:check_payment_method) }
9
- let!(:product) { create(:product, name: "RoR Mug", price: 20) }
10
- let!(:store) { create(:store) }
11
-
12
- context "visitor makes checkout as guest without registration" do
13
- def create_basic_coupon_promotion(code)
14
- promotion = Spree::Promotion.create!(name: code.titleize,
15
- code: code,
16
- starts_at: 1.day.ago,
17
- expires_at: 1.day.from_now)
18
-
19
- calculator = Spree::Calculator::FlatRate.new
20
- calculator.preferred_amount = 10
21
-
22
- action = Spree::Promotion::Actions::CreateItemAdjustments.new
23
- action.calculator = calculator
24
- action.promotion = promotion
25
- action.save
26
-
27
- promotion.reload # so that promotion.actions is available
28
- end
29
-
30
- let!(:promotion) { create_basic_coupon_promotion("onetwo") }
31
-
32
- # OrdersController
33
- context "on the payment page" do
34
- before do
35
- visit spree.root_path
36
- click_link "RoR Mug"
37
- click_button "add-to-cart-button"
38
- click_button "Checkout"
39
- fill_in "order_email", with: "spree@example.com"
40
- fill_in "First Name", with: "John"
41
- fill_in "Last Name", with: "Smith"
42
- fill_in "Street Address", with: "1 John Street"
43
- fill_in "City", with: "City of John"
44
- fill_in "Zip", with: "01337"
45
- select country.name, from: "Country"
46
- select state.name, from: "order[bill_address_attributes][state_id]"
47
- fill_in "Phone", with: "555-555-5555"
48
-
49
- # To shipping method screen
50
- click_button "Save and Continue"
51
- # To payment screen
52
- click_button "Save and Continue"
53
- end
54
-
55
- it "informs about an invalid coupon code" do
56
- fill_in "order_coupon_code", with: "coupon_codes_rule_man"
57
- click_button "Save and Continue"
58
- expect(page).to have_content(Spree.t(:coupon_code_not_found))
59
- end
60
-
61
- it "informs the user about a coupon code which has exceeded its usage" do
62
- promotion.update_column(:usage_limit, 5)
63
- allow_any_instance_of(promotion.class).to receive_messages(credits_count: 10)
64
-
65
- fill_in "order_coupon_code", with: "onetwo"
66
- click_button "Save and Continue"
67
- expect(page).to have_content(Spree.t(:coupon_code_max_usage))
68
- end
69
-
70
- it "can enter an invalid coupon code, then a real one" do
71
- fill_in "order_coupon_code", with: "coupon_codes_rule_man"
72
- click_button "Save and Continue"
73
- expect(page).to have_content(Spree.t(:coupon_code_not_found))
74
- fill_in "order_coupon_code", with: "onetwo"
75
- click_button "Save and Continue"
76
- expect(page).to have_content("Promotion (Onetwo) -$10.00")
77
- end
78
-
79
- context "with a promotion" do
80
- it "applies a promotion to an order" do
81
- fill_in "order_coupon_code", with: "onetwo"
82
- click_button "Save and Continue"
83
- expect(page).to have_content("Promotion (Onetwo) -$10.00")
84
- end
85
- end
86
- end
87
- end
88
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Switching currencies in backend", :type => :feature do
4
- before do
5
- create(:base_product, :name => "RoR Mug")
6
- end
7
-
8
- # Regression test for #2340
9
- it "does not cause current_order to become nil", inaccessible: true do
10
- visit spree.root_path
11
- click_link "RoR Mug"
12
- click_button "Add To Cart"
13
- # Now that we have an order...
14
- Spree::Config[:currency] = "AUD"
15
- expect { visit spree.root_path }.not_to raise_error
16
- end
17
-
18
- end
@@ -1,59 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Free shipping promotions", :type => :feature, :js => true do
4
- let!(:country) { create(:country, :name => "United States of America", :states_required => true) }
5
- let!(:state) { create(:state, :name => "Alabama", :country => country) }
6
- let!(:zone) { create(:zone) }
7
- let!(:shipping_method) do
8
- sm = create(:shipping_method)
9
- sm.calculator.preferred_amount = 10
10
- sm.calculator.save
11
- sm
12
- end
13
-
14
- let!(:payment_method) { create(:check_payment_method) }
15
- let!(:product) { create(:product, :name => "RoR Mug", :price => 20) }
16
- let!(:promotion) do
17
- promotion = Spree::Promotion.create!(:name => "Free Shipping",
18
- :starts_at => 1.day.ago,
19
- :expires_at => 1.day.from_now)
20
-
21
- action = Spree::Promotion::Actions::FreeShipping.new
22
- action.promotion = promotion
23
- action.save
24
-
25
- promotion.reload # so that promotion.actions is available
26
- end
27
-
28
- context "free shipping promotion automatically applied" do
29
- before do
30
-
31
- visit spree.root_path
32
- click_link "RoR Mug"
33
- click_button "add-to-cart-button"
34
- click_button "Checkout"
35
- fill_in "order_email", :with => "spree@example.com"
36
- fill_in "First Name", :with => "John"
37
- fill_in "Last Name", :with => "Smith"
38
- fill_in "Street Address", :with => "1 John Street"
39
- fill_in "City", :with => "City of John"
40
- fill_in "Zip", :with => "01337"
41
- select country.name, :from => "Country"
42
- select state.name, :from => "order[bill_address_attributes][state_id]"
43
- fill_in "Phone", :with => "555-555-5555"
44
-
45
- # To shipping method screen
46
- click_button "Save and Continue"
47
- # To payment screen
48
- click_button "Save and Continue"
49
- end
50
-
51
- # Regression test for #4428
52
- it "applies the free shipping promotion" do
53
- within("#checkout-summary") do
54
- expect(page).to have_content("Shipping total: $10.00")
55
- expect(page).to have_content("Promotion (Free Shipping): -$10.00")
56
- end
57
- end
58
- end
59
- end
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'setting locale', type: :feature do
4
- def with_locale(locale)
5
- I18n.locale = locale
6
- Spree::Frontend::Config[:locale] = locale
7
- yield
8
- I18n.locale = 'en'
9
- Spree::Frontend::Config[:locale] = 'en'
10
- end
11
-
12
- context 'shopping cart link and page' do
13
- before do
14
- I18n.backend.store_translations(:fr,
15
- spree: {
16
- cart: 'Panier',
17
- shopping_cart: 'Panier'
18
- })
19
- end
20
-
21
- it 'should be in french' do
22
- with_locale('fr') do
23
- visit spree.root_path
24
- click_link 'Panier'
25
- expect(page).to have_content('Panier')
26
- end
27
- end
28
- end
29
-
30
- context 'checkout form validation messages' do
31
- include_context 'checkout setup'
32
-
33
- let(:error_messages) do
34
- {
35
- 'en' => 'This field is required.',
36
- 'fr' => 'Ce champ est obligatoire.',
37
- 'de' => 'Dieses Feld ist ein Pflichtfeld.',
38
- }
39
- end
40
-
41
- def check_error_text(text)
42
- %w(firstname lastname address1 city).each do |attr|
43
- expect(find("#b#{attr} label.error").text).to eq(text)
44
- end
45
- end
46
-
47
- it 'shows translated jquery.validate error messages', js: true do
48
- visit spree.root_path
49
- click_link mug.name
50
- click_button 'add-to-cart-button'
51
- error_messages.each do |locale, message|
52
- with_locale(locale) do
53
- visit '/checkout/address'
54
- find('.form-buttons input[type=submit]').click
55
- check_error_text message
56
- end
57
- end
58
- end
59
- end
60
- end
File without changes
@@ -1,74 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'orders', :type => :feature do
4
- let(:order) { OrderWalkthrough.up_to(:complete) }
5
- let(:user) { create(:user) }
6
-
7
- before do
8
- order.update_attribute(:user_id, user.id)
9
- order.shipments.destroy_all
10
- allow_any_instance_of(Spree::OrdersController).to receive_messages(:try_spree_current_user => user)
11
- end
12
-
13
- it "can visit an order" do
14
- # Regression test for current_user call on orders/show
15
- expect { visit spree.order_path(order) }.not_to raise_error
16
- end
17
-
18
- it "should display line item price" do
19
- # Regression test for #2772
20
- line_item = order.line_items.first
21
- line_item.target_shipment = create(:shipment)
22
- line_item.price = 19.00
23
- line_item.save!
24
-
25
- visit spree.order_path(order)
26
-
27
- # Tests view spree/shared/_order_details
28
- within 'td.price' do
29
- expect(page).to have_content "19.00"
30
- end
31
- end
32
-
33
- it "should have credit card info if paid with credit card" do
34
- create(:payment, :order => order)
35
- visit spree.order_path(order)
36
- within '.payment-info' do
37
- expect(page).to have_content "Ending in 1111"
38
- end
39
- end
40
-
41
- it "should have payment method name visible if not paid with credit card" do
42
- create(:check_payment, :order => order)
43
- visit spree.order_path(order)
44
- within '.payment-info' do
45
- expect(page).to have_content "Check"
46
- end
47
- end
48
-
49
- # Regression test for #2282
50
- context "can support a credit card with blank information" do
51
- before do
52
- credit_card = create(:credit_card)
53
- credit_card.update_column(:cc_type, '')
54
- payment = order.payments.first
55
- payment.source = credit_card
56
- payment.save!
57
- end
58
-
59
- specify do
60
- visit spree.order_path(order)
61
- within '.payment-info' do
62
- expect { find("img") }.to raise_error(Capybara::ElementNotFound)
63
- end
64
- end
65
- end
66
-
67
- it "should return the correct title when displaying a completed order" do
68
- visit spree.order_path(order)
69
-
70
- within '#order_summary' do
71
- expect(page).to have_content("#{Spree.t(:order)} #{order.number}")
72
- end
73
- end
74
- end
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'page promotions', :type => :feature do
4
- let!(:product) { create(:product, :name => "RoR Mug", :price => 20) }
5
- before do
6
- promotion = Spree::Promotion.create!(:name => "$10 off",
7
- :path => 'test',
8
- :starts_at => 1.day.ago,
9
- :expires_at => 1.day.from_now)
10
-
11
- calculator = Spree::Calculator::FlatRate.new
12
- calculator.preferred_amount = 10
13
-
14
- action = Spree::Promotion::Actions::CreateItemAdjustments.create(:calculator => calculator)
15
- promotion.actions << action
16
-
17
- visit spree.root_path
18
- click_link "RoR Mug"
19
- click_button "add-to-cart-button"
20
- end
21
-
22
- it "automatically applies a page promotion upon visiting" do
23
- expect(page).not_to have_content("Promotion ($10 off) -$10.00")
24
- visit '/content/test'
25
- visit '/cart'
26
- expect(page).to have_content("Promotion ($10 off) -$10.00")
27
- expect(page).to have_content("Subtotal (1 item) $20.00")
28
- end
29
-
30
- it "does not activate an adjustment for a path that doesn't have a promotion" do
31
- expect(page).not_to have_content("Promotion ($10 off) -$10.00")
32
- visit '/content/cvv'
33
- visit '/cart'
34
- expect(page).not_to have_content("Promotion ($10 off) -$10.00")
35
- end
36
- end
@@ -1,334 +0,0 @@
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(:products) { Spree::TestingSupport::Microdata::Document.new(page.body).extract_items }
25
- let(:ringer) { products.keep_if { |product| product.properties["name"].first.match("Ringer") }.first }
26
-
27
- it "correctly displays the product name via microdata" do
28
- expect(ringer.properties["name"]).to eq ["Ruby on Rails Ringer T-Shirt"]
29
- end
30
-
31
- it "correctly displays the product image via microdata" do
32
- expect(ringer.properties['image'].first).to include '/assets/noimage/small'
33
- end
34
-
35
- it "correctly displays the product url via microdata" do
36
- expect(ringer.properties["url"]).to eq ["/products/ruby-on-rails-ringer-t-shirt"]
37
- end
38
- end
39
-
40
- describe 'meta tags and title' do
41
- let(:jersey) { Spree::Product.find_by_name('Ruby on Rails Baseball Jersey') }
42
- 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' } }
43
-
44
- it 'should return the correct title when displaying a single product' do
45
- click_link jersey.name
46
- expect(page).to have_title('Ruby on Rails Baseball Jersey - ' + store_name)
47
- within('div#product-description') do
48
- within('h1.product-title') do
49
- expect(page).to have_content('Ruby on Rails Baseball Jersey')
50
- end
51
- end
52
- end
53
-
54
- it 'displays metas' do
55
- jersey.update_attributes metas
56
- click_link jersey.name
57
- expect(page).to have_meta(:description, 'Brand new Ruby on Rails Jersey')
58
- expect(page).to have_meta(:keywords, 'ror, jersey, ruby')
59
- end
60
-
61
- it 'displays title if set' do
62
- jersey.update_attributes metas
63
- click_link jersey.name
64
- expect(page).to have_title('Ruby on Rails Baseball Jersey Buy High Quality Geek Apparel')
65
- end
66
-
67
- it "doesn't use meta_title as heading on page" do
68
- jersey.update_attributes metas
69
- click_link jersey.name
70
- within("h1") do
71
- expect(page).to have_content(jersey.name)
72
- expect(page).not_to have_content(jersey.meta_title)
73
- end
74
- end
75
-
76
- it 'uses product name in title when meta_title set to empty string' do
77
- jersey.update_attributes meta_title: ''
78
- click_link jersey.name
79
- expect(page).to have_title('Ruby on Rails Baseball Jersey - ' + store_name)
80
- end
81
- end
82
-
83
- context "using Russian Rubles as a currency" do
84
- before do
85
- Spree::Config[:currency] = "RUB"
86
- end
87
-
88
- let!(:product) do
89
- product = Spree::Product.find_by_name("Ruby on Rails Ringer T-Shirt")
90
- product.price = 19.99
91
- product.tap(&:save)
92
- end
93
-
94
- # Regression tests for #2737
95
- context "uses руб as the currency symbol" do
96
- it "on products page" do
97
- visit spree.root_path
98
- within("#product_#{product.id}") do
99
- within(".price") do
100
- expect(page).to have_content("19.99 ₽")
101
- end
102
- end
103
- end
104
-
105
- it "on product page" do
106
- visit spree.product_path(product)
107
- within(".price") do
108
- expect(page).to have_content("19.99 ₽")
109
- end
110
- end
111
-
112
- it "when adding a product to the cart", js: true do
113
- visit spree.product_path(product)
114
- click_button "Add To Cart"
115
- click_link "Home"
116
- within(".cart-info") do
117
- expect(page).to have_content("19.99 ₽")
118
- end
119
- end
120
-
121
- it "when on the 'address' state of the cart", js: true do
122
- visit spree.product_path(product)
123
- click_button "Add To Cart"
124
- click_button "Checkout"
125
- fill_in "order_email", with: "test@example.com"
126
- click_button 'Continue'
127
- within("tr[data-hook=item_total]") do
128
- expect(page).to have_content("19.99 ₽")
129
- end
130
- end
131
- end
132
- end
133
-
134
- it "should be able to search for a product" do
135
- fill_in "keywords", with: "shirt"
136
- click_button "Search"
137
-
138
- expect(page.all('#products .product-list-item').size).to eq(1)
139
- end
140
-
141
- context "a product with variants" do
142
- let(:product) { Spree::Product.find_by_name("Ruby on Rails Baseball Jersey") }
143
- let(:option_value) { create(:option_value) }
144
- let!(:variant) { build(:variant, price: 5.59, product: product, option_values: []) }
145
-
146
- before do
147
- # Need to have two images to trigger the error
148
- image = File.open(File.expand_path('../../fixtures/thinking-cat.jpg', __FILE__))
149
- product.images.create!(:attachment => image)
150
- product.images.create!(:attachment => image)
151
-
152
- product.option_types << option_value.option_type
153
- variant.option_values << option_value
154
- variant.save!
155
- end
156
-
157
- it "should be displayed" do
158
- expect { click_link product.name }.to_not raise_error
159
- end
160
-
161
- it "displays price of first variant listed", js: true do
162
- click_link product.name
163
- within("#product-price") do
164
- expect(page).to have_content variant.price
165
- expect(page).not_to have_content Spree.t(:out_of_stock)
166
- end
167
- end
168
-
169
- it "doesn't display out of stock for master product" do
170
- product.master.stock_items.update_all count_on_hand: 0, backorderable: false
171
-
172
- click_link product.name
173
- within("#product-price") do
174
- expect(page).not_to have_content Spree.t(:out_of_stock)
175
- end
176
- end
177
-
178
- it "doesn't display cart form if all variants (including master) are out of stock" do
179
- product.variants_including_master.each { |v| v.stock_items.update_all count_on_hand: 0, backorderable: false }
180
-
181
- click_link product.name
182
- within("[data-hook=product_price]") do
183
- expect(page).not_to have_content Spree.t(:add_to_cart)
184
- end
185
- end
186
- end
187
-
188
- context "a product with variants, images only for the variants" do
189
- let(:product) { Spree::Product.find_by_name("Ruby on Rails Baseball Jersey") }
190
- let(:variant1) { create(:variant, product: product, price: 9.99) }
191
- let(:variant2) { create(:variant, product: product, price: 10.99) }
192
-
193
- before do
194
- image = File.open(File.expand_path('../../fixtures/thinking-cat.jpg', __FILE__))
195
- variant1.images.create!(attachment: image)
196
- variant2.images.create!(attachment: image)
197
- end
198
-
199
- it "should not display no image available" do
200
- visit spree.root_path
201
- expect(page).to have_xpath("//img[contains(@src,'thinking-cat')]")
202
- end
203
- end
204
-
205
- context "an out of stock product without variants" do
206
- let(:product) { Spree::Product.find_by_name("Ruby on Rails Tote") }
207
-
208
- before do
209
- product.master.stock_items.update_all count_on_hand: 0, backorderable: false
210
- end
211
-
212
- it "does display out of stock for master product" do
213
- click_link product.name
214
- within("#product-price") do
215
- expect(page).to have_content Spree.t(:out_of_stock)
216
- end
217
- end
218
-
219
- it "doesn't display cart form if master is out of stock" do
220
- click_link product.name
221
- within("[data-hook=product_price]") do
222
- expect(page).not_to have_content Spree.t(:add_to_cart)
223
- end
224
- end
225
- end
226
-
227
- context 'product with taxons' do
228
- let(:product) { Spree::Product.find_by_name("Ruby on Rails Tote") }
229
- let(:taxon) { product.taxons.first }
230
-
231
- it 'displays breadcrumbs for the default taxon when none selected' do
232
- click_link product.name
233
- within("#breadcrumbs") do
234
- expect(page).to have_content taxon.name
235
- end
236
- end
237
-
238
- it 'displays selected taxon in breadcrumbs' do
239
- taxon = Spree::Taxon.last
240
- product.taxons << taxon
241
- product.save!
242
- visit '/t/' + taxon.to_param
243
- click_link product.name
244
- within("#breadcrumbs") do
245
- expect(page).to have_content taxon.name
246
- end
247
- end
248
- end
249
-
250
- it "should be able to hide products without price" do
251
- expect(page.all('#products .product-list-item').size).to eq(9)
252
- Spree::Config.show_products_without_price = false
253
- Spree::Config.currency = "CAN"
254
- visit spree.root_path
255
- expect(page.all('#products .product-list-item').size).to eq(0)
256
- end
257
-
258
-
259
- it "should be able to display products priced under 10 dollars" do
260
- within(:css, '#taxonomies') { click_link "Ruby on Rails" }
261
- check "Price_Range_Under_$10.00"
262
- within(:css, '#sidebar_products_search') { click_button "Search" }
263
- expect(page).to have_content("No products found")
264
- end
265
-
266
- it "should be able to display products priced between 15 and 18 dollars" do
267
- within(:css, '#taxonomies') { click_link "Ruby on Rails" }
268
- check "Price_Range_$15.00_-_$18.00"
269
- within(:css, '#sidebar_products_search') { click_button "Search" }
270
-
271
- expect(page.all('#products .product-list-item').size).to eq(3)
272
- tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
273
- tmp.delete("")
274
- expect(tmp.sort!).to eq(["Ruby on Rails Mug", "Ruby on Rails Stein", "Ruby on Rails Tote"])
275
- end
276
-
277
- it "should be able to display products priced between 15 and 18 dollars across multiple pages" do
278
- Spree::Config.products_per_page = 2
279
- within(:css, '#taxonomies') { click_link "Ruby on Rails" }
280
- check "Price_Range_$15.00_-_$18.00"
281
- within(:css, '#sidebar_products_search') { click_button "Search" }
282
-
283
- expect(page.all('#products .product-list-item').size).to eq(2)
284
- products = page.all('#products .product-list-item span[itemprop=name]')
285
- expect(products.count).to eq(2)
286
-
287
- find('.pagination .next a').click
288
- products = page.all('#products .product-list-item span[itemprop=name]')
289
- expect(products.count).to eq(1)
290
- end
291
-
292
- it "should be able to display products priced 18 dollars and above" do
293
- within(:css, '#taxonomies') { click_link "Ruby on Rails" }
294
- check "Price_Range_$18.00_-_$20.00"
295
- check "Price_Range_$20.00_or_over"
296
- within(:css, '#sidebar_products_search') { click_button "Search" }
297
-
298
- expect(page.all('#products .product-list-item').size).to eq(4)
299
- tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
300
- tmp.delete("")
301
- expect(tmp.sort!).to eq(["Ruby on Rails Bag",
302
- "Ruby on Rails Baseball Jersey",
303
- "Ruby on Rails Jr. Spaghetti",
304
- "Ruby on Rails Ringer T-Shirt"])
305
- end
306
-
307
- it "should be able to put a product without a description in the cart" do
308
- product = FactoryGirl.create(:base_product, :description => nil, :name => 'Sample', :price => '19.99')
309
- visit spree.product_path(product)
310
- expect(page).to have_content "This product has no description"
311
- click_button 'add-to-cart-button'
312
- expect(page).to have_content "This product has no description"
313
- end
314
-
315
- it "shouldn't be able to put a product without a current price in the cart" do
316
- product = FactoryGirl.create(:base_product, :description => nil, :name => 'Sample', :price => '19.99')
317
- Spree::Config.currency = "CAN"
318
- Spree::Config.show_products_without_price = true
319
- visit spree.product_path(product)
320
- expect(page).to have_content "This product is not available in the selected currency."
321
- expect(page).not_to have_content "add-to-cart-button"
322
- end
323
-
324
- it "should return the correct title when displaying a single product" do
325
- product = Spree::Product.find_by_name("Ruby on Rails Baseball Jersey")
326
- click_link product.name
327
-
328
- within("div#product-description") do
329
- within("h1.product-title") do
330
- expect(page).to have_content("Ruby on Rails Baseball Jersey")
331
- end
332
- end
333
- end
334
- end