solidus_frontend_devise_token_auth 2.8.0.alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "checkout with unshippable items", type: :feature, inaccessible: true do
6
+ let!(:stock_location) { create(:stock_location) }
7
+ let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:address) }
8
+
9
+ before do
10
+ create(:line_item, order: order)
11
+ order.reload
12
+ line_item = order.line_items.last
13
+ stock_item = stock_location.stock_item(line_item.variant)
14
+ stock_item.adjust_count_on_hand(0)
15
+ stock_item.backorderable = false
16
+ stock_item.save!
17
+
18
+ user = create(:user)
19
+ order.user = user
20
+ order.recalculate
21
+
22
+ allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
23
+ allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
24
+ allow_any_instance_of(Spree::CheckoutController).to receive_messages(skip_state_validation?: true)
25
+ allow_any_instance_of(Spree::CheckoutController).to receive_messages(ensure_sufficient_stock_lines: true)
26
+ end
27
+
28
+ it 'displays and removes' do
29
+ visit spree.checkout_state_path(:delivery)
30
+ expect(page).to have_content('Unshippable Items')
31
+
32
+ click_button "Save and Continue"
33
+
34
+ order.reload
35
+ expect(order.line_items.count).to eq 1
36
+ end
37
+ end
@@ -0,0 +1,266 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "Coupon code promotions", type: :feature, js: true do
6
+ let!(:store) { create(:store) }
7
+ let!(:country) { create(:country, name: "United States of America", states_required: true) }
8
+ let!(:state) { create(:state, name: "Alabama", country: country) }
9
+ let!(:zone) { create(:zone) }
10
+ let!(:shipping_method) { create(:shipping_method) }
11
+ let!(:payment_method) { create(:check_payment_method) }
12
+ let!(:product) { create(:product, name: "RoR Mug", price: 20) }
13
+
14
+ context "visitor makes checkout" do
15
+ def create_basic_coupon_promotion(code)
16
+ promotion = create(
17
+ :promotion,
18
+ name: code.titleize,
19
+ code: code,
20
+ starts_at: 1.day.ago,
21
+ expires_at: 1.day.from_now
22
+ )
23
+
24
+ calculator = Spree::Calculator::FlatRate.new
25
+ calculator.preferred_amount = 10
26
+
27
+ action = Spree::Promotion::Actions::CreateItemAdjustments.new
28
+ action.calculator = calculator
29
+ action.promotion = promotion
30
+ action.save
31
+
32
+ promotion.reload # so that promotion.actions is available
33
+ end
34
+
35
+ let!(:promotion) { create_basic_coupon_promotion("onetwo") }
36
+
37
+ context "on the payment page" do
38
+ context "as guest without registration" do
39
+ before do
40
+ visit spree.root_path
41
+ click_link "RoR Mug"
42
+ click_button "add-to-cart-button"
43
+ click_button "Checkout"
44
+ fill_in "order_email", with: "spree@example.com"
45
+ fill_in "First Name", with: "John"
46
+ fill_in "Last Name", with: "Smith"
47
+ fill_in "Street Address", with: "1 John Street"
48
+ fill_in "City", with: "City of John"
49
+ fill_in "Zip", with: "01337"
50
+ select country.name, from: "Country"
51
+ select state.name, from: "order[bill_address_attributes][state_id]"
52
+ fill_in "Phone", with: "555-555-5555"
53
+
54
+ # To shipping method screen
55
+ click_button "Save and Continue"
56
+ # To payment screen
57
+ click_button "Save and Continue"
58
+ end
59
+
60
+ it "informs about an invalid coupon code" do
61
+ fill_in "order_coupon_code", with: "coupon_codes_rule_man"
62
+ click_button "Apply Code"
63
+ expect(page).to have_content(I18n.t('spree.coupon_code_not_found'))
64
+ end
65
+
66
+ it "can enter an invalid coupon code, then a real one" do
67
+ fill_in "order_coupon_code", with: "coupon_codes_rule_man"
68
+ click_button "Apply Code"
69
+ expect(page).to have_content(I18n.t('spree.coupon_code_not_found'))
70
+ fill_in "order_coupon_code", with: "onetwo"
71
+ click_button "Apply Code"
72
+ expect(page).to have_content("Promotion (Onetwo) -$10.00")
73
+ end
74
+
75
+ context "with a promotion" do
76
+ it "applies a promotion to an order" do
77
+ fill_in "order_coupon_code", with: "onetwo"
78
+ click_button "Apply Code"
79
+ expect(page).to have_content("Promotion (Onetwo) -$10.00")
80
+ end
81
+ end
82
+ end
83
+
84
+ context 'as logged user' do
85
+ let!(:user) { create(:user, bill_address: create(:address), ship_address: create(:address)) }
86
+
87
+ before do
88
+ allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
89
+ allow_any_instance_of(Spree::OrdersController).to receive_messages(try_spree_current_user: user)
90
+ end
91
+
92
+ context 'with saved credit card' do
93
+ let(:bogus) { create(:credit_card_payment_method) }
94
+ let!(:credit_card) do
95
+ create(:credit_card, user_id: user.id, payment_method: bogus, gateway_customer_profile_id: "BGS-WEFWF")
96
+ end
97
+
98
+ before do
99
+ user.wallet.add(credit_card)
100
+
101
+ visit spree.root_path
102
+ click_link "RoR Mug"
103
+ click_button "add-to-cart-button"
104
+ # To Cart
105
+ click_button "Checkout"
106
+ # To shipping method screen, address is auto-populated
107
+ # with user's saved addresses
108
+ click_button "Save and Continue"
109
+ # To payment screen
110
+ click_button "Save and Continue"
111
+ end
112
+
113
+ it "shows wallet payments on coupon code errors" do
114
+ fill_in "order_coupon_code", with: "coupon_codes_rule_man"
115
+ click_button "Apply Code"
116
+
117
+ expect(page).to have_content("The coupon code you entered doesn't exist. Please try again.")
118
+ expect(page).to have_content("Use an existing card")
119
+ end
120
+ end
121
+ end
122
+ end
123
+
124
+ # CheckoutController
125
+ context "on the cart page" do
126
+ before do
127
+ visit spree.root_path
128
+ click_link "RoR Mug"
129
+ click_button "add-to-cart-button"
130
+ end
131
+
132
+ it "can enter a coupon code and receives success notification" do
133
+ fill_in "order_coupon_code", with: "onetwo"
134
+ click_button "Update"
135
+ expect(page).to have_content(I18n.t('spree.coupon_code_applied'))
136
+ end
137
+
138
+ it "can enter a promotion code with both upper and lower case letters" do
139
+ fill_in "order_coupon_code", with: "ONETwO"
140
+ click_button "Update"
141
+ expect(page).to have_content(I18n.t('spree.coupon_code_applied'))
142
+ end
143
+
144
+ it "informs the user about a coupon code which has exceeded its usage" do
145
+ expect_any_instance_of(Spree::Promotion).to receive(:usage_limit_exceeded?).and_return(true)
146
+
147
+ fill_in "order_coupon_code", with: "onetwo"
148
+ click_button "Update"
149
+ expect(page).to have_content(I18n.t('spree.coupon_code_max_usage'))
150
+ end
151
+
152
+ context "informs the user if the coupon code is not eligible" do
153
+ before do
154
+ rule = Spree::Promotion::Rules::ItemTotal.new
155
+ rule.promotion = promotion
156
+ rule.preferred_amount = 100
157
+ rule.save
158
+ end
159
+
160
+ specify do
161
+ visit spree.cart_path
162
+
163
+ fill_in "order_coupon_code", with: "onetwo"
164
+ click_button "Update"
165
+ expect(page).to have_content(I18n.t(:item_total_less_than_or_equal, scope: [:spree, :eligibility_errors, :messages], amount: "$100.00"))
166
+ end
167
+ end
168
+
169
+ it "informs the user if the coupon is expired" do
170
+ promotion.expires_at = Date.today.beginning_of_week
171
+ promotion.starts_at = Date.today.beginning_of_week.advance(day: 3)
172
+ promotion.save!
173
+ fill_in "order_coupon_code", with: "onetwo"
174
+ click_button "Update"
175
+ expect(page).to have_content(I18n.t('spree.coupon_code_expired'))
176
+ end
177
+
178
+ context "calculates the correct amount of money saved with flat percent promotions" do
179
+ before do
180
+ calculator = Spree::Calculator::FlatPercentItemTotal.new
181
+ calculator.preferred_flat_percent = 20
182
+ promotion.actions.first.calculator = calculator
183
+ promotion.save
184
+
185
+ create(:product, name: "Spree Mug", price: 10)
186
+ end
187
+
188
+ specify do
189
+ visit spree.root_path
190
+ click_link "Spree Mug"
191
+ click_button "add-to-cart-button"
192
+
193
+ visit spree.cart_path
194
+ fill_in "order_coupon_code", with: "onetwo"
195
+ click_button "Update"
196
+
197
+ fill_in "order_line_items_attributes_0_quantity", with: 2
198
+ fill_in "order_line_items_attributes_1_quantity", with: 2
199
+ click_button "Update"
200
+
201
+ within '#cart_adjustments' do
202
+ # 20% of $40 = 8
203
+ # 20% of $20 = 4
204
+ # Therefore: promotion discount amount is $12.
205
+ expect(page).to have_content("Promotion (Onetwo) -$12.00")
206
+ end
207
+
208
+ within '.cart-total' do
209
+ expect(page).to have_content("$48.00")
210
+ end
211
+ end
212
+ end
213
+
214
+ context "calculates the correct amount of money saved with flat 100% promotions on the whole order" do
215
+ before do
216
+ calculator = Spree::Calculator::FlatPercentItemTotal.new
217
+ calculator.preferred_flat_percent = 100
218
+
219
+ promotion.promotion_actions.first.discard
220
+
221
+ Spree::Promotion::Actions::CreateAdjustment.create!(
222
+ calculator: calculator,
223
+ promotion: promotion
224
+ )
225
+
226
+ create(:product, name: "Spree Mug", price: 10)
227
+ end
228
+
229
+ specify do
230
+ visit spree.root_path
231
+ click_link "Spree Mug"
232
+ click_button "add-to-cart-button"
233
+
234
+ visit spree.cart_path
235
+
236
+ within '.cart-total' do
237
+ expect(page).to have_content("$30.00")
238
+ end
239
+
240
+ fill_in "order_coupon_code", with: "onetwo"
241
+ click_button "Update"
242
+
243
+ within '#cart_adjustments' do
244
+ expect(page).to have_content("Promotion (Onetwo) -$30.00")
245
+ end
246
+
247
+ within '.cart-total' do
248
+ expect(page).to have_content("$0.00")
249
+ end
250
+
251
+ fill_in "order_line_items_attributes_0_quantity", with: 2
252
+ fill_in "order_line_items_attributes_1_quantity", with: 2
253
+ click_button "Update"
254
+
255
+ within '#cart_adjustments' do
256
+ expect(page).to have_content("Promotion (Onetwo) -$60.00")
257
+ end
258
+
259
+ within '.cart-total' do
260
+ expect(page).to have_content("$0.00")
261
+ end
262
+ end
263
+ end
264
+ end
265
+ end
266
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "Switching currencies in backend", type: :feature do
6
+ before do
7
+ create(:store)
8
+ create(:base_product, name: "RoR Mug")
9
+ end
10
+
11
+ # Regression test for https://github.com/spree/spree/issues/2340
12
+ it "does not cause current_order to become nil", inaccessible: true do
13
+ visit spree.root_path
14
+ click_link "RoR Mug"
15
+ click_button "Add To Cart"
16
+ # Now that we have an order...
17
+ Spree::Config[:currency] = "AUD"
18
+ visit spree.root_path
19
+ end
20
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "Free shipping promotions", type: :feature, js: true do
6
+ let!(:store) { create(:store) }
7
+ let!(:country) { create(:country, name: "United States of America", states_required: true) }
8
+ let!(:state) { create(:state, name: "Alabama", country: country) }
9
+ let!(:zone) { create(:zone) }
10
+ let!(:shipping_method) do
11
+ sm = create(:shipping_method)
12
+ sm.calculator.preferred_amount = 10
13
+ sm.calculator.save
14
+ sm
15
+ end
16
+
17
+ let!(:payment_method) { create(:check_payment_method) }
18
+ let!(:product) { create(:product, name: "RoR Mug", price: 20) }
19
+ let!(:promotion) do
20
+ create(
21
+ :promotion,
22
+ apply_automatically: true,
23
+ promotion_actions: [Spree::Promotion::Actions::FreeShipping.new],
24
+ name: "Free Shipping",
25
+ starts_at: 1.day.ago,
26
+ expires_at: 1.day.from_now,
27
+ )
28
+ end
29
+
30
+ context "free shipping promotion automatically applied" do
31
+ before do
32
+ visit spree.root_path
33
+ click_link "RoR Mug"
34
+ click_button "add-to-cart-button"
35
+ click_button "Checkout"
36
+ fill_in "order_email", with: "spree@example.com"
37
+ fill_in "First Name", with: "John"
38
+ fill_in "Last Name", with: "Smith"
39
+ fill_in "Street Address", with: "1 John Street"
40
+ fill_in "City", with: "City of John"
41
+ fill_in "Zip", with: "01337"
42
+ select country.name, from: "Country"
43
+ select state.name, from: "order[bill_address_attributes][state_id]"
44
+ fill_in "Phone", with: "555-555-5555"
45
+
46
+ # To shipping method screen
47
+ click_button "Save and Continue"
48
+ # To payment screen
49
+ click_button "Save and Continue"
50
+ end
51
+
52
+ # Regression test for https://github.com/spree/spree/issues/4428
53
+ it "applies the free shipping promotion" do
54
+ within("#checkout-summary") do
55
+ expect(page).to have_content("Shipping total: $10.00")
56
+ expect(page).to have_content("Promotion (Free Shipping): -$10.00")
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'setting locale', type: :feature do
6
+ let!(:store) { create(:store) }
7
+ def with_locale(locale)
8
+ I18n.locale = locale
9
+ Spree::Frontend::Config[:locale] = locale
10
+ yield
11
+ ensure
12
+ I18n.locale = I18n.default_locale
13
+ Spree::Frontend::Config[:locale] = 'en'
14
+ end
15
+
16
+ context 'shopping cart link and page' do
17
+ include_context "fr locale"
18
+
19
+ it 'should be in french' do
20
+ with_locale('fr') do
21
+ visit spree.root_path
22
+ click_link 'Panier'
23
+ expect(page).to have_content('Panier')
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'orders', type: :feature do
6
+ let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:complete) }
7
+ let(:user) { create(:user) }
8
+
9
+ before do
10
+ order.update_attribute(:user_id, user.id)
11
+ allow_any_instance_of(Spree::OrdersController).to receive_messages(try_spree_current_user: user)
12
+ end
13
+
14
+ it "can visit an order" do
15
+ # Regression test for current_user call on orders/show
16
+ visit spree.order_path(order)
17
+ end
18
+
19
+ it "should display line item price" do
20
+ # Regression test for https://github.com/spree/spree/issues/2772
21
+ line_item = order.line_items.first
22
+ line_item.target_shipment = create(:shipment)
23
+ line_item.price = 19.00
24
+ line_item.save!
25
+
26
+ visit spree.order_path(order)
27
+
28
+ # Tests view spree/shared/_order_details
29
+ within 'td.price' do
30
+ expect(page).to have_content "19.00"
31
+ end
32
+ end
33
+
34
+ it "should have credit card info if paid with credit card" do
35
+ create(:payment, order: order)
36
+ visit spree.order_path(order)
37
+ within '.payment-info' do
38
+ expect(page).to have_content "Ending in 1111"
39
+ end
40
+ end
41
+
42
+ it "should have payment method name visible if not paid with credit card" do
43
+ create(:check_payment, order: order)
44
+ visit spree.order_path(order)
45
+ within '.payment-info' do
46
+ expect(page).to have_content "Check"
47
+ end
48
+ end
49
+
50
+ # Regression test for https://github.com/spree/spree/issues/2282
51
+ context "can support a credit card with blank information" do
52
+ before do
53
+ credit_card = create(:credit_card)
54
+ credit_card.update_column(:cc_type, '')
55
+ payment = order.payments.first
56
+ payment.source = credit_card
57
+ payment.save!
58
+ end
59
+
60
+ specify do
61
+ visit spree.order_path(order)
62
+ expect(find('.payment-info')).to have_no_css('img')
63
+ end
64
+ end
65
+
66
+ it "should return the correct title when displaying a completed order" do
67
+ visit spree.order_path(order)
68
+
69
+ within '#order_summary' do
70
+ expect(page).to have_content("#{I18n.t('spree.order')} #{order.number}")
71
+ end
72
+ end
73
+ end