spree_core 3.3.6 → 3.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/spree/base_helper.rb +17 -18
  3. data/app/helpers/spree/products_helper.rb +5 -5
  4. data/app/models/concerns/spree/calculated_adjustments.rb +4 -3
  5. data/app/models/concerns/spree/default_price.rb +4 -5
  6. data/app/models/concerns/spree/display_money.rb +1 -1
  7. data/app/models/concerns/spree/named_type.rb +1 -1
  8. data/app/models/concerns/spree/ransackable_attributes.rb +5 -6
  9. data/app/models/concerns/spree/user_address.rb +6 -6
  10. data/app/models/concerns/spree/user_methods.rb +3 -3
  11. data/app/models/concerns/spree/user_payment_source.rb +4 -2
  12. data/app/models/concerns/spree/user_reporting.rb +1 -1
  13. data/app/models/spree/ability.rb +3 -3
  14. data/app/models/spree/address.rb +13 -9
  15. data/app/models/spree/adjustable/adjuster/promotion.rb +1 -1
  16. data/app/models/spree/adjustable/adjustments_updater.rb +2 -2
  17. data/app/models/spree/adjustable/promotion_accumulator.rb +6 -4
  18. data/app/models/spree/adjustment.rb +2 -3
  19. data/app/models/spree/app_configuration.rb +5 -6
  20. data/app/models/spree/base.rb +1 -1
  21. data/app/models/spree/calculator/default_tax.rb +4 -5
  22. data/app/models/spree/calculator/flat_percent_item_total.rb +1 -1
  23. data/app/models/spree/calculator/flat_rate.rb +3 -3
  24. data/app/models/spree/calculator/flexi_rate.rb +5 -5
  25. data/app/models/spree/calculator/price_sack.rb +9 -9
  26. data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +1 -1
  27. data/app/models/spree/calculator/shipping/flat_rate.rb +3 -3
  28. data/app/models/spree/calculator/shipping/flexi_rate.rb +7 -7
  29. data/app/models/spree/calculator/shipping/per_item.rb +2 -2
  30. data/app/models/spree/calculator/shipping/price_sack.rb +4 -4
  31. data/app/models/spree/calculator/tiered_flat_rate.rb +3 -2
  32. data/app/models/spree/calculator/tiered_percent.rb +4 -3
  33. data/app/models/spree/calculator.rb +4 -4
  34. data/app/models/spree/classification.rb +2 -2
  35. data/app/models/spree/credit_card.rb +1 -1
  36. data/app/models/spree/exchange.rb +4 -5
  37. data/app/models/spree/gateway/bogus.rb +20 -20
  38. data/app/models/spree/gateway/bogus_simple.rb +2 -4
  39. data/app/models/spree/gateway.rb +4 -4
  40. data/app/models/spree/image.rb +3 -3
  41. data/app/models/spree/inventory_unit.rb +30 -30
  42. data/app/models/spree/line_item.rb +7 -9
  43. data/app/models/spree/option_type.rb +1 -1
  44. data/app/models/spree/order/checkout.rb +5 -5
  45. data/app/models/spree/order/currency_updater.rb +1 -4
  46. data/app/models/spree/order/payments.rb +4 -4
  47. data/app/models/spree/order/store_credit.rb +2 -2
  48. data/app/models/spree/order.rb +11 -29
  49. data/app/models/spree/order_contents.rb +6 -5
  50. data/app/models/spree/order_inventory.rb +3 -4
  51. data/app/models/spree/order_updater.rb +13 -14
  52. data/app/models/spree/payment/processing.rb +25 -26
  53. data/app/models/spree/payment.rb +72 -79
  54. data/app/models/spree/payment_capture_event.rb +1 -1
  55. data/app/models/spree/payment_method/check.rb +1 -1
  56. data/app/models/spree/payment_method/store_credit.rb +5 -5
  57. data/app/models/spree/payment_method.rb +7 -7
  58. data/app/models/spree/preferences/configuration.rb +6 -9
  59. data/app/models/spree/preferences/preferable.rb +11 -11
  60. data/app/models/spree/preferences/preferable_class_methods.rb +2 -3
  61. data/app/models/spree/preferences/scoped_store.rb +6 -5
  62. data/app/models/spree/preferences/store.rb +9 -14
  63. data/app/models/spree/price.rb +1 -1
  64. data/app/models/spree/product/scopes.rb +49 -49
  65. data/app/models/spree/product.rb +16 -16
  66. data/app/models/spree/promotion/actions/create_item_adjustments.rb +2 -1
  67. data/app/models/spree/promotion/actions/free_shipping.rb +1 -1
  68. data/app/models/spree/promotion/rules/first_order.rb +7 -6
  69. data/app/models/spree/promotion/rules/item_total.rb +3 -5
  70. data/app/models/spree/promotion/rules/one_use_per_user.rb +1 -2
  71. data/app/models/spree/promotion/rules/option_value.rb +14 -6
  72. data/app/models/spree/promotion/rules/product.rb +4 -4
  73. data/app/models/spree/promotion/rules/taxon.rb +6 -6
  74. data/app/models/spree/promotion/rules/user.rb +3 -3
  75. data/app/models/spree/promotion/rules/user_logged_in.rb +1 -1
  76. data/app/models/spree/promotion.rb +15 -16
  77. data/app/models/spree/promotion_action.rb +1 -1
  78. data/app/models/spree/promotion_handler/cart.rb +3 -2
  79. data/app/models/spree/promotion_handler/free_shipping.rb +1 -3
  80. data/app/models/spree/promotion_handler/page.rb +3 -3
  81. data/app/models/spree/promotion_rule.rb +5 -4
  82. data/app/models/spree/refund.rb +8 -8
  83. data/app/models/spree/reimbursement/credit.rb +1 -1
  84. data/app/models/spree/reimbursement/reimbursement_type_engine.rb +1 -3
  85. data/app/models/spree/reimbursement.rb +4 -8
  86. data/app/models/spree/reimbursement_performer.rb +0 -5
  87. data/app/models/spree/reimbursement_tax_calculator.rb +5 -12
  88. data/app/models/spree/reimbursement_type.rb +2 -2
  89. data/app/models/spree/return_authorization.rb +22 -26
  90. data/app/models/spree/return_item/eligibility_validator/default.rb +3 -3
  91. data/app/models/spree/return_item/eligibility_validator/inventory_shipped.rb +2 -2
  92. data/app/models/spree/return_item/eligibility_validator/no_reimbursements.rb +2 -2
  93. data/app/models/spree/return_item/eligibility_validator/order_completed.rb +2 -2
  94. data/app/models/spree/return_item/eligibility_validator/rma_required.rb +2 -3
  95. data/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb +2 -2
  96. data/app/models/spree/return_item.rb +15 -19
  97. data/app/models/spree/returns_calculator.rb +1 -2
  98. data/app/models/spree/shipment.rb +14 -35
  99. data/app/models/spree/shipment_handler.rb +10 -12
  100. data/app/models/spree/shipping_calculator.rb +5 -6
  101. data/app/models/spree/shipping_method.rb +3 -3
  102. data/app/models/spree/shipping_rate.rb +2 -2
  103. data/app/models/spree/state.rb +2 -2
  104. data/app/models/spree/stock/availability_validator.rb +1 -1
  105. data/app/models/spree/stock/content_item.rb +2 -3
  106. data/app/models/spree/stock/coordinator.rb +3 -2
  107. data/app/models/spree/stock/differentiator.rb +3 -2
  108. data/app/models/spree/stock/estimator.rb +7 -5
  109. data/app/models/spree/stock/package.rb +5 -5
  110. data/app/models/spree/stock/packer.rb +1 -1
  111. data/app/models/spree/stock/prioritizer.rb +5 -7
  112. data/app/models/spree/stock/quantifier.rb +0 -1
  113. data/app/models/spree/stock/splitter/backordered.rb +2 -4
  114. data/app/models/spree/stock/splitter/base.rb +3 -2
  115. data/app/models/spree/stock/splitter/shipping_category.rb +2 -1
  116. data/app/models/spree/stock_item.rb +1 -1
  117. data/app/models/spree/stock_location.rb +12 -11
  118. data/app/models/spree/stock_movement.rb +1 -3
  119. data/app/models/spree/stock_transfer.rb +1 -1
  120. data/app/models/spree/store.rb +4 -4
  121. data/app/models/spree/store_credit.rb +3 -3
  122. data/app/models/spree/tax_category.rb +1 -1
  123. data/app/models/spree/tax_rate.rb +10 -10
  124. data/app/models/spree/taxon.rb +13 -13
  125. data/app/models/spree/taxonomy.rb +9 -8
  126. data/app/models/spree/validations/db_maximum_length_validator.rb +2 -3
  127. data/app/models/spree/variant.rb +30 -41
  128. data/app/models/spree/zone.rb +10 -10
  129. data/app/validators/db_maximum_length_validator.rb +5 -5
  130. data/config/initializers/acts_as_taggable_on.rb +3 -3
  131. data/config/initializers/assets.rb +1 -1
  132. data/config/initializers/friendly_id.rb +1 -1
  133. data/config/initializers/premailer_assets.rb +1 -1
  134. data/config/locales/en.yml +8 -2
  135. data/db/default/spree/states.rb +1 -0
  136. data/lib/generators/spree/custom_user/custom_user_generator.rb +12 -15
  137. data/lib/generators/spree/install/install_generator.rb +45 -32
  138. data/lib/spree/core/components.rb +3 -3
  139. data/lib/spree/core/controller_helpers/auth.rb +5 -10
  140. data/lib/spree/core/controller_helpers/common.rb +2 -3
  141. data/lib/spree/core/controller_helpers/order.rb +3 -7
  142. data/lib/spree/core/controller_helpers/respond_with.rb +4 -4
  143. data/lib/spree/core/engine.rb +3 -3
  144. data/lib/spree/core/environment/calculators.rb +0 -1
  145. data/lib/spree/core/environment_extension.rb +8 -8
  146. data/lib/spree/core/importer/order.rb +64 -67
  147. data/lib/spree/core/importer/product.rb +10 -9
  148. data/lib/spree/core/product_filters.rb +17 -18
  149. data/lib/spree/core/routes.rb +2 -6
  150. data/lib/spree/core/search/base.rb +62 -59
  151. data/lib/spree/core/version.rb +1 -1
  152. data/lib/spree/core.rb +4 -6
  153. data/lib/spree/i18n.rb +3 -5
  154. data/lib/spree/localized_number.rb +0 -2
  155. data/lib/spree/migrations.rb +8 -7
  156. data/lib/spree/money.rb +3 -7
  157. data/lib/spree/permitted_attributes.rb +2 -2
  158. data/lib/spree/responder.rb +4 -5
  159. data/lib/spree/testing_support/authorization_helpers.rb +3 -3
  160. data/lib/spree/testing_support/caching.rb +5 -5
  161. data/lib/spree/testing_support/capybara_ext.rb +16 -18
  162. data/lib/spree/testing_support/common_rake.rb +8 -9
  163. data/lib/spree/testing_support/controller_requests.rb +6 -6
  164. data/lib/spree/testing_support/extension_rake.rb +2 -3
  165. data/lib/spree/testing_support/factories/address_factory.rb +1 -1
  166. data/lib/spree/testing_support/factories/adjustment_factory.rb +1 -1
  167. data/lib/spree/testing_support/factories/calculator_factory.rb +1 -1
  168. data/lib/spree/testing_support/factories/country_factory.rb +1 -1
  169. data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
  170. data/lib/spree/testing_support/factories/customer_return_factory.rb +1 -3
  171. data/lib/spree/testing_support/factories/image_factory.rb +2 -2
  172. data/lib/spree/testing_support/factories/inventory_unit_factory.rb +1 -1
  173. data/lib/spree/testing_support/factories/line_item_factory.rb +2 -2
  174. data/lib/spree/testing_support/factories/options_factory.rb +1 -1
  175. data/lib/spree/testing_support/factories/order_factory.rb +1 -1
  176. data/lib/spree/testing_support/factories/payment_factory.rb +1 -1
  177. data/lib/spree/testing_support/factories/payment_method_factory.rb +4 -4
  178. data/lib/spree/testing_support/factories/price_factory.rb +1 -1
  179. data/lib/spree/testing_support/factories/product_factory.rb +1 -1
  180. data/lib/spree/testing_support/factories/product_option_type_factory.rb +1 -1
  181. data/lib/spree/testing_support/factories/product_property_factory.rb +1 -1
  182. data/lib/spree/testing_support/factories/promotion_category_factory.rb +1 -2
  183. data/lib/spree/testing_support/factories/promotion_factory.rb +1 -2
  184. data/lib/spree/testing_support/factories/promotion_rule_factory.rb +1 -1
  185. data/lib/spree/testing_support/factories/property_factory.rb +1 -1
  186. data/lib/spree/testing_support/factories/prototype_factory.rb +1 -1
  187. data/lib/spree/testing_support/factories/refund_factory.rb +1 -1
  188. data/lib/spree/testing_support/factories/reimbursement_factory.rb +2 -2
  189. data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +1 -1
  190. data/lib/spree/testing_support/factories/return_authorization_factory.rb +1 -1
  191. data/lib/spree/testing_support/factories/return_item_factory.rb +1 -1
  192. data/lib/spree/testing_support/factories/role_factory.rb +1 -1
  193. data/lib/spree/testing_support/factories/shipment_factory.rb +2 -2
  194. data/lib/spree/testing_support/factories/shipping_category_factory.rb +1 -1
  195. data/lib/spree/testing_support/factories/shipping_method_factory.rb +3 -3
  196. data/lib/spree/testing_support/factories/state_factory.rb +1 -1
  197. data/lib/spree/testing_support/factories/stock_factory.rb +1 -1
  198. data/lib/spree/testing_support/factories/stock_item_factory.rb +1 -1
  199. data/lib/spree/testing_support/factories/stock_location_factory.rb +2 -2
  200. data/lib/spree/testing_support/factories/stock_movement_factory.rb +1 -1
  201. data/lib/spree/testing_support/factories/store_credit_category_factory.rb +2 -2
  202. data/lib/spree/testing_support/factories/store_credit_event_factory.rb +1 -1
  203. data/lib/spree/testing_support/factories/store_credit_factory.rb +1 -1
  204. data/lib/spree/testing_support/factories/store_credit_type_factory.rb +1 -1
  205. data/lib/spree/testing_support/factories/store_factory.rb +1 -1
  206. data/lib/spree/testing_support/factories/tag_factory.rb +1 -1
  207. data/lib/spree/testing_support/factories/tax_category_factory.rb +2 -2
  208. data/lib/spree/testing_support/factories/tax_rate_factory.rb +1 -1
  209. data/lib/spree/testing_support/factories/taxon_factory.rb +1 -1
  210. data/lib/spree/testing_support/factories/taxonomy_factory.rb +1 -1
  211. data/lib/spree/testing_support/factories/tracker_factory.rb +1 -1
  212. data/lib/spree/testing_support/factories/user_factory.rb +1 -1
  213. data/lib/spree/testing_support/factories/variant_factory.rb +1 -2
  214. data/lib/spree/testing_support/factories/zone_factory.rb +1 -1
  215. data/lib/spree/testing_support/factories/zone_member_factory.rb +1 -1
  216. data/lib/spree/testing_support/factories.rb +3 -3
  217. data/lib/spree/testing_support/flash.rb +1 -3
  218. data/lib/spree/testing_support/i18n.rb +5 -6
  219. data/lib/spree/testing_support/kernel.rb +1 -2
  220. data/lib/spree/testing_support/order_walkthrough.rb +12 -15
  221. data/lib/spree/testing_support/preferences.rb +0 -1
  222. data/lib/tasks/core.rake +47 -56
  223. data/lib/tasks/email.rake +2 -2
  224. data/lib/tasks/exchanges.rake +5 -5
  225. data/spree_core.gemspec +1 -1
  226. metadata +5 -9
  227. data/app/models/spree/calculator/percent_per_item.rb +0 -51
  228. data/config/initializers/premailer_rails.rb +0 -3
  229. data/lib/spree/core/delegate_belongs_to.rb +0 -99
  230. data/lib/spree/testing_support/microdata.rb +0 -192
@@ -3,27 +3,26 @@ module Spree
3
3
  include Rails::Generators::ResourceHelpers
4
4
  include Rails::Generators::Migration
5
5
 
6
-
7
- desc "Set up a Spree installation with a custom User class"
6
+ desc 'Set up a Spree installation with a custom User class'
8
7
 
9
8
  def self.source_paths
10
- paths = self.superclass.source_paths
9
+ paths = superclass.source_paths
11
10
  paths << File.expand_path('../templates', __FILE__)
12
11
  paths.flatten
13
12
  end
14
13
 
15
14
  def check_for_constant
16
- begin
17
- klass
18
- rescue NameError
19
- @shell.say "Couldn't find #{class_name}. Are you sure that this class exists within your application and is loaded?", :red
20
- exit(1)
21
- end
15
+
16
+ klass
17
+ rescue NameError
18
+ @shell.say "Couldn't find #{class_name}. Are you sure that this class exists within your application and is loaded?", :red
19
+ exit(1)
20
+
22
21
  end
23
22
 
24
23
  def generate
25
- migration_template 'migration.rb.tt', "db/migrate/add_spree_fields_to_custom_user_table.rb"
26
- template 'authentication_helpers.rb.tt', "lib/spree/authentication_helpers.rb"
24
+ migration_template 'migration.rb.tt', 'db/migrate/add_spree_fields_to_custom_user_table.rb'
25
+ template 'authentication_helpers.rb.tt', 'lib/spree/authentication_helpers.rb'
27
26
 
28
27
  file_action = File.exist?('config/initializers/spree.rb') ? :append_file : :create_file
29
28
  send(file_action, 'config/initializers/spree.rb') do
@@ -37,9 +36,9 @@ module Spree
37
36
  def self.next_migration_number(dirname)
38
37
  if ApplicationRecord.timestamped_migrations
39
38
  sleep 1 # make sure to get a different migration every time
40
- Time.new.utc.strftime("%Y%m%d%H%M%S")
39
+ Time.new.utc.strftime('%Y%m%d%H%M%S')
41
40
  else
42
- "%.3d" % (current_migration_number(dirname) + 1)
41
+ format('%.3d', (current_migration_number(dirname) + 1))
43
42
  end
44
43
  end
45
44
 
@@ -50,7 +49,5 @@ module Spree
50
49
  def table_name
51
50
  klass.table_name
52
51
  end
53
-
54
52
  end
55
53
  end
56
-
@@ -3,12 +3,14 @@ require 'highline/import'
3
3
  require 'bundler'
4
4
  require 'bundler/cli'
5
5
  require 'active_support/core_ext/string/indent'
6
+ require 'spree/core'
6
7
 
7
8
  module Spree
8
9
  class InstallGenerator < Rails::Generators::Base
9
10
  class_option :migrate, type: :boolean, default: true, banner: 'Run Spree migrations'
10
11
  class_option :seed, type: :boolean, default: true, banner: 'load seed data (migrations must be run)'
11
12
  class_option :sample, type: :boolean, default: true, banner: 'load sample data (migrations must be run)'
13
+ class_option :copy_views, type: :boolean, default: true, banner: 'copy frontend views from spree to your application for easy customization'
12
14
  class_option :auto_accept, type: :boolean
13
15
  class_option :user_class, type: :string
14
16
  class_option :admin_email, type: :string
@@ -17,7 +19,7 @@ module Spree
17
19
  class_option :enforce_available_locales, type: :boolean, default: nil
18
20
 
19
21
  def self.source_paths
20
- paths = self.superclass.source_paths
22
+ paths = superclass.source_paths
21
23
  paths << File.expand_path('../templates', "../../#{__FILE__}")
22
24
  paths << File.expand_path('../templates', "../#{__FILE__}")
23
25
  paths << File.expand_path('../templates', __FILE__)
@@ -28,10 +30,11 @@ module Spree
28
30
  @run_migrations = options[:migrate]
29
31
  @load_seed_data = options[:seed]
30
32
  @load_sample_data = options[:sample]
33
+ @copy_views = options[:copy_views]
31
34
 
32
35
  unless @run_migrations
33
- @load_seed_data = false
34
- @load_sample_data = false
36
+ @load_seed_data = false
37
+ @load_sample_data = false
35
38
  end
36
39
  end
37
40
 
@@ -40,8 +43,8 @@ module Spree
40
43
  end
41
44
 
42
45
  def additional_tweaks
43
- return unless File.exists? 'public/robots.txt'
44
- append_file "public/robots.txt", <<-ROBOTS.strip_heredoc
46
+ return unless File.exist? 'public/robots.txt'
47
+ append_file 'public/robots.txt', <<-ROBOTS.strip_heredoc
45
48
  User-agent: *
46
49
  Disallow: /checkout
47
50
  Disallow: /cart
@@ -56,23 +59,33 @@ module Spree
56
59
  def setup_assets
57
60
  @lib_name = 'spree'
58
61
  %w{javascripts stylesheets images}.each do |path|
59
- empty_directory "vendor/assets/#{path}/spree/frontend" if defined? Spree::Frontend || Rails.env.test?
60
- empty_directory "vendor/assets/#{path}/spree/backend" if defined? Spree::Backend || Rails.env.test?
62
+ if Spree::Core::Engine.frontend_available? || Rails.env.test?
63
+ empty_directory "vendor/assets/#{path}/spree/frontend"
64
+ end
65
+ if Spree::Core::Engine.backend_available? || Rails.env.test?
66
+ empty_directory "vendor/assets/#{path}/spree/backend"
67
+ end
61
68
  end
62
69
 
63
- if defined? Spree::Frontend || Rails.env.test?
64
- template "vendor/assets/javascripts/spree/frontend/all.js"
65
- template "vendor/assets/stylesheets/spree/frontend/all.css"
70
+ if Spree::Core::Engine.frontend_available? || Rails.env.test?
71
+ template 'vendor/assets/javascripts/spree/frontend/all.js'
72
+ template 'vendor/assets/stylesheets/spree/frontend/all.css'
66
73
  end
67
74
 
68
- if defined? Spree::Backend || Rails.env.test?
69
- template "vendor/assets/javascripts/spree/backend/all.js"
70
- template "vendor/assets/stylesheets/spree/backend/all.css"
75
+ if Spree::Core::Engine.backend_available? || Rails.env.test?
76
+ template 'vendor/assets/javascripts/spree/backend/all.js'
77
+ template 'vendor/assets/stylesheets/spree/backend/all.css'
71
78
  end
72
79
  end
73
80
 
74
81
  def create_overrides_directory
75
- empty_directory "app/overrides"
82
+ empty_directory 'app/overrides'
83
+ end
84
+
85
+ def copy_views
86
+ if @copy_views && Spree::Core::Engine.frontend_available?
87
+ generate 'spree:frontend:copy_views'
88
+ end
76
89
  end
77
90
 
78
91
  def configure_application
@@ -91,7 +104,7 @@ module Spree
91
104
  end
92
105
  APP
93
106
 
94
- if !options[:enforce_available_locales].nil?
107
+ unless options[:enforce_available_locales].nil?
95
108
  application <<-APP.strip_heredoc.indent!(4)
96
109
  # Prevent this deprecation message: https://github.com/svenfuchs/i18n/commit/3b6e56e
97
110
  I18n.enforce_available_locales = #{options[:enforce_available_locales]}
@@ -100,7 +113,7 @@ module Spree
100
113
  end
101
114
 
102
115
  def include_seed_data
103
- append_file "db/seeds.rb", <<-SEEDS.strip_heredoc
116
+ append_file 'db/seeds.rb', <<-SEEDS.strip_heredoc
104
117
 
105
118
  Spree::Core::Engine.load_seed if defined?(Spree::Core)
106
119
  Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
@@ -108,14 +121,14 @@ module Spree
108
121
  end
109
122
 
110
123
  def install_migrations
111
- say_status :copying, "migrations"
124
+ say_status :copying, 'migrations'
112
125
  silence_stream(STDOUT) do
113
126
  silence_warnings { rake 'railties:install:migrations' }
114
127
  end
115
128
  end
116
129
 
117
130
  def create_database
118
- say_status :creating, "database"
131
+ say_status :creating, 'database'
119
132
  silence_stream(STDOUT) do
120
133
  silence_stream(STDERR) do
121
134
  silence_warnings { rake 'db:create' }
@@ -125,7 +138,7 @@ module Spree
125
138
 
126
139
  def run_migrations
127
140
  if @run_migrations
128
- say_status :running, "migrations"
141
+ say_status :running, 'migrations'
129
142
  silence_stream(STDOUT) do
130
143
  silence_stream(STDERR) do
131
144
  silence_warnings { rake 'db:migrate' }
@@ -138,13 +151,13 @@ module Spree
138
151
 
139
152
  def populate_seed_data
140
153
  if @load_seed_data
141
- say_status :loading, "seed data"
142
- rake_options=[]
143
- rake_options << "AUTO_ACCEPT=1" if options[:auto_accept]
154
+ say_status :loading, 'seed data'
155
+ rake_options = []
156
+ rake_options << 'AUTO_ACCEPT=1' if options[:auto_accept]
144
157
  rake_options << "ADMIN_EMAIL=#{options[:admin_email]}" if options[:admin_email]
145
158
  rake_options << "ADMIN_PASSWORD=#{options[:admin_password]}" if options[:admin_password]
146
159
 
147
- cmd = lambda { rake("db:seed #{rake_options.join(' ')}") }
160
+ cmd = -> { rake("db:seed #{rake_options.join(' ')}") }
148
161
  if options[:auto_accept] || (options[:admin_email] && options[:admin_password])
149
162
  silence_stream(STDOUT) do
150
163
  silence_stream(STDERR) do
@@ -155,20 +168,20 @@ module Spree
155
168
  cmd.call
156
169
  end
157
170
  else
158
- say_status :skipping, "seed data (you can always run rake db:seed)"
171
+ say_status :skipping, 'seed data (you can always run rake db:seed)'
159
172
  end
160
173
  end
161
174
 
162
175
  def load_sample_data
163
176
  if @load_sample_data
164
- say_status :loading, "sample data"
177
+ say_status :loading, 'sample data'
165
178
  silence_stream(STDOUT) do
166
179
  silence_stream(STDERR) do
167
180
  silence_warnings { rake 'spree_sample:load' }
168
181
  end
169
182
  end
170
183
  else
171
- say_status :skipping, "sample data (you can always run rake spree_sample:load)"
184
+ say_status :skipping, 'sample data (you can always run rake spree_sample:load)'
172
185
  end
173
186
  end
174
187
 
@@ -189,19 +202,19 @@ module Spree
189
202
  end
190
203
 
191
204
  unless options[:quiet]
192
- puts "*" * 50
205
+ puts '*' * 50
193
206
  puts "We added the following line to your application's config/routes.rb file:"
194
- puts " "
207
+ puts ' '
195
208
  puts " mount Spree::Core::Engine, at: '/'"
196
209
  end
197
210
  end
198
211
 
199
212
  def complete
200
213
  unless options[:quiet]
201
- puts "*" * 50
214
+ puts '*' * 50
202
215
  puts "Spree has been installed successfully. You're all ready to go!"
203
- puts " "
204
- puts "Enjoy!"
216
+ puts ' '
217
+ puts 'Enjoy!'
205
218
  end
206
219
  end
207
220
 
@@ -219,7 +232,7 @@ module Spree
219
232
 
220
233
  def file_exists?(extensions, filename)
221
234
  extensions.detect do |extension|
222
- File.exists?("#{filename}#{extension}")
235
+ File.exist?("#{filename}#{extension}")
223
236
  end
224
237
  end
225
238
 
@@ -2,15 +2,15 @@ module Spree
2
2
  module Core
3
3
  class Engine < ::Rails::Engine
4
4
  def self.api_available?
5
- @@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine')
5
+ @@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map { |e| e.class.to_s }.include?('Spree::Api::Engine')
6
6
  end
7
7
 
8
8
  def self.backend_available?
9
- @@backend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Backend::Engine')
9
+ @@backend_available ||= ::Rails::Engine.subclasses.map(&:instance).map { |e| e.class.to_s }.include?('Spree::Backend::Engine')
10
10
  end
11
11
 
12
12
  def self.frontend_available?
13
- @@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Frontend::Engine')
13
+ @@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map { |e| e.class.to_s }.include?('Spree::Frontend::Engine')
14
14
  end
15
15
  end
16
16
  end
@@ -9,7 +9,7 @@ module Spree
9
9
  before_action :set_guest_token
10
10
  helper_method :try_spree_current_user
11
11
 
12
- rescue_from CanCan::AccessDenied do |exception|
12
+ rescue_from CanCan::AccessDenied do |_exception|
13
13
  redirect_unauthorized_access
14
14
  end
15
15
  end
@@ -20,8 +20,8 @@ module Spree
20
20
  end
21
21
 
22
22
  def redirect_back_or_default(default)
23
- redirect_to(session["spree_user_return_to"] || request.env["HTTP_REFERER"] || default)
24
- session["spree_user_return_to"] = nil
23
+ redirect_to(session['spree_user_return_to'] || request.env['HTTP_REFERER'] || default)
24
+ session['spree_user_return_to'] = nil
25
25
  end
26
26
 
27
27
  def set_guest_token
@@ -35,12 +35,10 @@ module Spree
35
35
  authentication_routes = [:spree_signup_path, :spree_login_path, :spree_logout_path]
36
36
  disallowed_urls = []
37
37
  authentication_routes.each do |route|
38
- if respond_to?(route)
39
- disallowed_urls << send(route)
40
- end
38
+ disallowed_urls << send(route) if respond_to?(route)
41
39
  end
42
40
 
43
- disallowed_urls.map!{ |url| url[/\/\w+$/] }
41
+ disallowed_urls.map! { |url| url[/\/\w+$/] }
44
42
  unless disallowed_urls.include?(request.fullpath)
45
43
  session['spree_user_return_to'] = request.fullpath.gsub('//', '/')
46
44
  end
@@ -56,8 +54,6 @@ module Spree
56
54
  # This one will be defined by Devise
57
55
  elsif respond_to?(:current_spree_user)
58
56
  current_spree_user
59
- else
60
- nil
61
57
  end
62
58
  end
63
59
 
@@ -79,7 +75,6 @@ module Spree
79
75
  end
80
76
  end
81
77
  end
82
-
83
78
  end
84
79
  end
85
80
  end
@@ -40,9 +40,9 @@ module Spree
40
40
  current_store.seo_title
41
41
  end
42
42
 
43
- def render_404(exception = nil)
43
+ def render_404(_exception = nil)
44
44
  respond_to do |type|
45
- type.html { render status: :not_found, file: "#{::Rails.root}/public/404", formats: [:html], layout: nil}
45
+ type.html { render status: :not_found, file: "#{::Rails.root}/public/404", formats: [:html], layout: nil }
46
46
  type.all { head :not_found }
47
47
  end
48
48
  end
@@ -66,7 +66,6 @@ module Spree
66
66
  def get_layout
67
67
  layout ||= Spree::Config[:layout]
68
68
  end
69
-
70
69
  end
71
70
  end
72
71
  end
@@ -13,7 +13,6 @@ module Spree
13
13
 
14
14
  # Used in the link_to_cart helper.
15
15
  def simple_current_order
16
-
17
16
  return @simple_current_order if @simple_current_order
18
17
 
19
18
  @simple_current_order = find_order_by_token_or_user
@@ -67,14 +66,14 @@ module Spree
67
66
  private
68
67
 
69
68
  def last_incomplete_order
70
- @last_incomplete_order ||= try_spree_current_user.last_incomplete_spree_order
69
+ @last_incomplete_order ||= try_spree_current_user.last_incomplete_spree_order(current_store)
71
70
  end
72
71
 
73
72
  def current_order_params
74
73
  { currency: current_currency, guest_token: cookies.signed[:guest_token], store_id: current_store.id, user_id: try_spree_current_user.try(:id) }
75
74
  end
76
75
 
77
- def find_order_by_token_or_user(options={}, with_adjustments = false)
76
+ def find_order_by_token_or_user(options = {}, with_adjustments = false)
78
77
  options[:lock] ||= false
79
78
 
80
79
  # Find any incomplete orders for the guest_token
@@ -87,13 +86,10 @@ module Spree
87
86
  end
88
87
 
89
88
  # Find any incomplete orders for the current user
90
- if order.nil? && try_spree_current_user
91
- order = last_incomplete_order
92
- end
89
+ order = last_incomplete_order if order.nil? && try_spree_current_user
93
90
 
94
91
  order
95
92
  end
96
-
97
93
  end
98
94
  end
99
95
  end
@@ -7,7 +7,7 @@ module ActionController
7
7
  # Checkout AS Array#extract_options! and original respond_with
8
8
  # implementation for a better picture of this hack
9
9
  if resources.last.is_a? Hash
10
- resources.last.merge! action_name: action_name.to_sym
10
+ resources.last[:action_name] = action_name.to_sym
11
11
  else
12
12
  resources.push action_name: action_name.to_sym
13
13
  end
@@ -35,7 +35,7 @@ module Spree
35
35
  self.spree_responders = {}
36
36
  end
37
37
 
38
- def respond_override(options={})
38
+ def respond_override(options = {})
39
39
  unless options.blank?
40
40
  action_name = options.keys.first
41
41
  action_value = options.values.first
@@ -52,10 +52,10 @@ module Spree
52
52
  end
53
53
 
54
54
  if format_value.is_a?(Proc)
55
- options = {action_name.to_sym => {format_name.to_sym => {success: format_value}}}
55
+ options = { action_name.to_sym => { format_name.to_sym => { success: format_value } } }
56
56
  end
57
57
 
58
- self.spree_responders.deep_merge!(self.name.to_sym => options)
58
+ spree_responders.deep_merge!(name.to_sym => options)
59
59
  end
60
60
  end
61
61
  end
@@ -116,12 +116,12 @@ module Spree
116
116
  end
117
117
 
118
118
  config.to_prepare do
119
- # Ensure spree locale paths are present before decorators
120
- I18n.load_path.unshift(*(Dir.glob(
119
+ # Load spree locales before decorators
120
+ I18n.load_path += Dir.glob(
121
121
  File.join(
122
122
  File.dirname(__FILE__), '../../../config/locales', '*.{rb,yml}'
123
123
  )
124
- ) - I18n.load_path))
124
+ )
125
125
 
126
126
  # Load application's model / class decorators
127
127
  Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')) do |c|
@@ -9,4 +9,3 @@ module Spree
9
9
  end
10
10
  end
11
11
  end
12
-
@@ -4,22 +4,22 @@ module Spree
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  def add_class(name)
7
- self.instance_variable_set "@#{name}", Set.new
7
+ instance_variable_set "@#{name}", Set.new
8
8
 
9
- create_method( "#{name}=".to_sym ) { |val|
10
- instance_variable_set( "@" + name, val)
11
- }
9
+ create_method("#{name}=".to_sym) do |val|
10
+ instance_variable_set('@' + name, val)
11
+ end
12
12
 
13
13
  create_method(name.to_sym) do
14
- instance_variable_get( "@" + name )
14
+ instance_variable_get('@' + name)
15
15
  end
16
16
  end
17
17
 
18
18
  private
19
19
 
20
- def create_method(name, &block)
21
- self.class.send(:define_method, name, &block)
22
- end
20
+ def create_method(name, &block)
21
+ self.class.send(:define_method, name, &block)
22
+ end
23
23
  end
24
24
  end
25
25
  end