solidus_core 2.7.4 → 2.8.0

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 (136) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -17
  3. data/app/assets/images/logo/solidus.svg +18 -0
  4. data/app/assets/javascripts/spree.js.erb +2 -2
  5. data/app/helpers/spree/base_helper.rb +1 -7
  6. data/app/helpers/spree/taxons_helper.rb +2 -2
  7. data/app/mailers/spree/carton_mailer.rb +4 -4
  8. data/app/models/spree/calculator/flat_percent_item_total.rb +4 -1
  9. data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +5 -3
  10. data/app/models/spree/calculator/tiered_percent.rb +2 -1
  11. data/app/models/spree/country.rb +8 -0
  12. data/app/models/spree/fulfilment_changer.rb +9 -1
  13. data/app/models/spree/gallery/product_gallery.rb +18 -0
  14. data/app/models/spree/gallery/variant_gallery.rb +21 -0
  15. data/app/models/spree/image.rb +11 -1
  16. data/app/models/spree/inventory_unit.rb +8 -0
  17. data/app/models/spree/line_item.rb +1 -1
  18. data/app/models/spree/order.rb +0 -4
  19. data/app/models/spree/order_cancellations.rb +31 -10
  20. data/app/models/spree/order_contents.rb +1 -5
  21. data/app/models/spree/order_inventory.rb +5 -4
  22. data/app/models/spree/product.rb +9 -0
  23. data/app/models/spree/product/scopes.rb +3 -4
  24. data/app/models/spree/promotion.rb +1 -6
  25. data/app/models/spree/promotion_handler/coupon.rb +15 -0
  26. data/app/models/spree/reimbursement.rb +21 -6
  27. data/app/models/spree/reimbursement_performer.rb +12 -6
  28. data/app/models/spree/reimbursement_type.rb +1 -1
  29. data/app/models/spree/reimbursement_type/credit.rb +5 -2
  30. data/app/models/spree/reimbursement_type/exchange.rb +1 -1
  31. data/app/models/spree/reimbursement_type/original_payment.rb +1 -1
  32. data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +6 -6
  33. data/app/models/spree/reimbursement_type/store_credit.rb +18 -3
  34. data/app/models/spree/shipment.rb +11 -11
  35. data/app/models/spree/stock/allocator/base.rb +19 -0
  36. data/app/models/spree/stock/allocator/on_hand_first.rb +42 -0
  37. data/app/models/spree/stock/content_item.rb +1 -1
  38. data/app/models/spree/stock/inventory_units_finalizer.rb +47 -0
  39. data/app/models/spree/stock/location_sorter/base.rb +38 -0
  40. data/app/models/spree/stock/location_sorter/default_first.rb +15 -0
  41. data/app/models/spree/stock/location_sorter/unsorted.rb +14 -0
  42. data/app/models/spree/stock/simple_coordinator.rb +24 -10
  43. data/app/models/spree/stock_location.rb +2 -0
  44. data/app/models/spree/store_credit.rb +4 -12
  45. data/app/models/spree/store_credit_event.rb +2 -2
  46. data/app/models/spree/store_credit_reason.rb +11 -0
  47. data/app/models/spree/taxon.rb +8 -3
  48. data/app/models/spree/unit_cancel.rb +3 -0
  49. data/app/models/spree/variant.rb +18 -7
  50. data/config/initializers/money.rb +5 -0
  51. data/config/locales/en.yml +661 -527
  52. data/db/default/spree/store_credit.rb +1 -1
  53. data/db/default/spree/zones.rb +2 -2
  54. data/db/migrate/20180710170104_create_spree_store_credit_reasons_table.rb +42 -0
  55. data/db/migrate/20190106184413_remove_code_from_spree_promotions.rb +41 -0
  56. data/lib/generators/spree/dummy/templates/rails/test.rb +0 -3
  57. data/lib/generators/spree/install/install_generator.rb +2 -2
  58. data/lib/generators/spree/install/templates/config/initializers/spree.rb.tt +2 -2
  59. data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/backend/all.js +1 -1
  60. data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/frontend/all.js +1 -1
  61. data/lib/solidus/migrations/promotions_with_code_handlers.rb +66 -0
  62. data/lib/spree/app_configuration.rb +20 -4
  63. data/lib/spree/core/controller_helpers/common.rb +1 -1
  64. data/lib/spree/core/stock_configuration.rb +12 -0
  65. data/lib/spree/core/version.rb +1 -1
  66. data/lib/spree/i18n.rb +4 -0
  67. data/lib/spree/money.rb +13 -11
  68. data/lib/spree/permission_sets.rb +0 -1
  69. data/lib/spree/permission_sets/promotion_management.rb +1 -0
  70. data/lib/spree/testing_support/dummy_app.rb +13 -2
  71. data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/backend/all.js +1 -1
  72. data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/frontend/all.js +1 -1
  73. data/lib/spree/testing_support/factories/store_credit_event_factory.rb +5 -5
  74. data/lib/spree/testing_support/factories/{store_credit_update_reason_factory.rb → store_credit_reason_factory.rb} +1 -1
  75. data/lib/spree/testing_support/partial_double_verification.rb +13 -0
  76. data/lib/spree/testing_support/shared_examples/gallery.rb +18 -0
  77. data/spec/helpers/products_helper_spec.rb +10 -8
  78. data/spec/helpers/taxons_helper_spec.rb +3 -1
  79. data/spec/lib/i18n_spec.rb +5 -0
  80. data/spec/lib/spree/core/controller_helpers/auth_spec.rb +6 -2
  81. data/spec/lib/spree/core/stock_configuration_spec.rb +19 -0
  82. data/spec/lib/spree/core/testing_support/factories/store_credit_reason_factory_spec.rb +14 -0
  83. data/spec/lib/spree/money_spec.rb +12 -13
  84. data/spec/migrate/20190106184413_remove_code_from_spree_promotions_spec.rb +136 -0
  85. data/spec/models/spree/calculator/flat_percent_item_total_spec.rb +10 -1
  86. data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +18 -6
  87. data/spec/models/spree/calculator/tiered_percent_spec.rb +7 -1
  88. data/spec/models/spree/country_spec.rb +76 -0
  89. data/spec/models/spree/customer_return_spec.rb +2 -1
  90. data/spec/models/spree/fulfilment_changer_spec.rb +33 -0
  91. data/spec/models/spree/gallery/product_gallery_spec.rb +21 -0
  92. data/spec/models/spree/gallery/variant_gallery_spec.rb +21 -0
  93. data/spec/models/spree/inventory_unit_spec.rb +1 -4
  94. data/spec/models/spree/order/checkout_spec.rb +6 -6
  95. data/spec/models/spree/order/finalizing_spec.rb +1 -20
  96. data/spec/models/spree/order/outstanding_balance_integration_spec.rb +2 -1
  97. data/spec/models/spree/order/updating_spec.rb +1 -1
  98. data/spec/models/spree/order_cancellations_spec.rb +55 -14
  99. data/spec/models/spree/order_inventory_spec.rb +12 -5
  100. data/spec/models/spree/order_merger_spec.rb +6 -3
  101. data/spec/models/spree/order_spec.rb +3 -7
  102. data/spec/models/spree/order_updater_spec.rb +3 -8
  103. data/spec/models/spree/payment/cancellation_spec.rb +4 -3
  104. data/spec/models/spree/payment_spec.rb +1 -17
  105. data/spec/models/spree/permission_sets/promotion_management_spec.rb +2 -0
  106. data/spec/models/spree/product_spec.rb +10 -1
  107. data/spec/models/spree/promotion_handler/coupon_spec.rb +62 -8
  108. data/spec/models/spree/promotion_spec.rb +24 -10
  109. data/spec/models/spree/refund_spec.rb +2 -1
  110. data/spec/models/spree/reimbursement_performer_spec.rb +5 -4
  111. data/spec/models/spree/reimbursement_spec.rb +26 -2
  112. data/spec/models/spree/reimbursement_type/credit_spec.rb +2 -1
  113. data/spec/models/spree/reimbursement_type/exchange_spec.rb +2 -1
  114. data/spec/models/spree/reimbursement_type/original_payment_spec.rb +2 -1
  115. data/spec/models/spree/reimbursement_type/store_credit_spec.rb +14 -2
  116. data/spec/models/spree/return_item_spec.rb +1 -1
  117. data/spec/models/spree/shipment_spec.rb +20 -13
  118. data/spec/models/spree/shipping_calculator_spec.rb +13 -3
  119. data/spec/models/spree/stock/allocator/on_hand_first_spec.rb +146 -0
  120. data/spec/models/spree/stock/content_item_spec.rb +70 -0
  121. data/spec/models/spree/stock/estimator_spec.rb +5 -2
  122. data/spec/models/spree/stock/inventory_units_finalizer_spec.rb +34 -0
  123. data/spec/models/spree/stock/location_sorter/default_first_spec.rb +20 -0
  124. data/spec/models/spree/stock/location_sorter/unsorted_spec.rb +19 -0
  125. data/spec/models/spree/stock/simple_coordinator_spec.rb +17 -0
  126. data/spec/models/spree/store_credit_event_spec.rb +12 -12
  127. data/spec/models/spree/store_credit_spec.rb +2 -2
  128. data/spec/models/spree/unit_cancel_spec.rb +20 -1
  129. data/spec/models/spree/variant_spec.rb +46 -24
  130. data/spec/spec_helper.rb +1 -0
  131. metadata +30 -9
  132. data/.yardopts +0 -1
  133. data/app/models/spree/store_credit_update_reason.rb +0 -4
  134. data/lib/spree/permission_sets/report_display.rb +0 -11
  135. data/spec/lib/spree/core/testing_support/factories/store_credit_update_reason_factory_spec.rb +0 -14
  136. data/spec/models/spree/permission_sets/report_display_spec.rb +0 -25
@@ -19,4 +19,4 @@ Spree::ReimbursementType.create_with(name: "Store Credit").find_or_create_by!(ty
19
19
 
20
20
  Spree::StoreCreditCategory.find_or_create_by!(name: 'Gift Card')
21
21
 
22
- Spree::StoreCreditUpdateReason.find_or_create_by!(name: 'Credit Given In Error')
22
+ Spree::StoreCreditReason.find_or_create_by!(name: 'Credit Given In Error')
@@ -5,9 +5,9 @@ north_america = Spree::Zone.find_or_create_by!(name: "North America", descriptio
5
5
 
6
6
  %w(PL FI PT RO DE FR SK HU SI IE AT ES IT BE SE LV BG GB LT CY LU MT DK NL EE HR CZ GR).
7
7
  each do |symbol|
8
- eu_vat.zone_members.create!(zoneable: Spree::Country.find_by!(iso: symbol))
8
+ eu_vat.zone_members.find_or_create_by!(zoneable: Spree::Country.find_by!(iso: symbol))
9
9
  end
10
10
 
11
11
  %w(US CA).each do |symbol|
12
- north_america.zone_members.create!(zoneable: Spree::Country.find_by!(iso: symbol))
12
+ north_america.zone_members.find_or_create_by!(zoneable: Spree::Country.find_by!(iso: symbol))
13
13
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpreeStoreCreditReasonsTable < ActiveRecord::Migration[5.1]
4
+ class StoreCreditUpdateReason < ActiveRecord::Base
5
+ self.table_name = "spree_store_credit_update_reasons"
6
+ end
7
+
8
+ class StoreCreditReason < ActiveRecord::Base
9
+ self.table_name = "spree_store_credit_reasons"
10
+ end
11
+
12
+ def up
13
+ create_table :spree_store_credit_reasons do |t|
14
+ t.string :name
15
+ t.boolean :active, default: true
16
+
17
+ t.timestamps
18
+ end
19
+
20
+ StoreCreditUpdateReason.all.each do |update_reason|
21
+ StoreCreditReason.create!(name: update_reason.name)
22
+ end
23
+
24
+ drop_table :spree_store_credit_update_reasons
25
+ rename_column :spree_store_credit_events, :update_reason_id, :store_credit_reason_id
26
+ end
27
+
28
+ def down
29
+ create_table :spree_store_credit_update_reasons do |t|
30
+ t.string :name
31
+
32
+ t.timestamps
33
+ end
34
+
35
+ StoreCreditReason.all.each do |store_credit_reason|
36
+ StoreCreditUpdateReason.create!(name: store_credit_reason.name)
37
+ end
38
+
39
+ drop_table :spree_store_credit_reasons
40
+ rename_column :spree_store_credit_events, :store_credit_reason_id, :update_reason_id
41
+ end
42
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'solidus/migrations/promotions_with_code_handlers'
4
+
5
+ class RemoveCodeFromSpreePromotions < ActiveRecord::Migration[5.1]
6
+ class Promotion < ActiveRecord::Base
7
+ self.table_name = "spree_promotions"
8
+ end
9
+
10
+ def up
11
+ promotions_with_code = Promotion.where.not(code: nil)
12
+
13
+ if promotions_with_code.any?
14
+ # You have some promotions with "code" field present! This is not good
15
+ # since we are going to remove that column.
16
+ #
17
+ self.class.promotions_with_code_handler.new(self, promotions_with_code).call
18
+ end
19
+
20
+ remove_index :spree_promotions, name: :index_spree_promotions_on_code
21
+ remove_column :spree_promotions, :code
22
+ end
23
+
24
+ def down
25
+ add_column :spree_promotions, :code, :string
26
+ add_index :spree_promotions, :code, name: :index_spree_promotions_on_code
27
+ end
28
+
29
+ def self.promotions_with_code_handler
30
+ # We propose different approaches, just pick the one that you prefer or
31
+ # write your custom one.
32
+ #
33
+ # The fist one (raising an exception) is the default but you can
34
+ # comment/uncomment the one then better fits you needs or use a
35
+ # custom class or callable object.
36
+ #
37
+ Solidus::Migrations::PromotionWithCodeHandlers::RaiseException
38
+ # Solidus::Migrations::PromotionWithCodeHandlers::MoveToSpreePromotionCode
39
+ # Solidus::Migrations::PromotionWithCodeHandlers::DoNothing
40
+ end
41
+ end
@@ -20,9 +20,6 @@ Dummy::Application.configure do
20
20
  # Raise exceptions instead of rendering exception templates
21
21
  config.action_dispatch.show_exceptions = false
22
22
 
23
- # Disable request forgery protection in test environment
24
- config.action_controller.allow_forgery_protection = false
25
-
26
23
  # Tell Action Mailer not to deliver emails to the real world.
27
24
  # The :test delivery method accumulates sent emails in the
28
25
  # ActionMailer::Base.deliveries array.
@@ -84,12 +84,12 @@ module Spree
84
84
  config.to_prepare do
85
85
  # Load application's model / class decorators
86
86
  Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
87
- Rails.configuration.cache_classes ? require(c) : load(c)
87
+ require_dependency(c)
88
88
  end
89
89
 
90
90
  # Load application's view overrides
91
91
  Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/*.rb")) do |c|
92
- Rails.configuration.cache_classes ? require(c) : load(c)
92
+ require_dependency(c)
93
93
  end
94
94
  end
95
95
  APP
@@ -22,7 +22,7 @@ Spree.config do |config|
22
22
  # Frontend:
23
23
 
24
24
  # Custom logo for the frontend
25
- # config.logo = "logo/solidus_logo.png"
25
+ # config.logo = "logo/solidus.svg"
26
26
 
27
27
  # Template to use when rendering layout
28
28
  # config.layout = "spree/layouts/spree_application"
@@ -31,7 +31,7 @@ Spree.config do |config|
31
31
  # Admin:
32
32
 
33
33
  # Custom logo for the admin
34
- # config.admin_interface_logo = "logo/solidus_logo.png"
34
+ # config.admin_interface_logo = "logo/solidus.svg"
35
35
 
36
36
  # Gateway credentials can be configured statically here and referenced from
37
37
  # the admin. They can also be fully configured from the admin.
@@ -5,6 +5,6 @@
5
5
  // the compiled file.
6
6
  //
7
7
  //= require jquery
8
- //= require jquery_ujs
8
+ //= require rails-ujs
9
9
  //= require spree/backend
10
10
  //= require_tree .
@@ -5,6 +5,6 @@
5
5
  // the compiled file.
6
6
  //
7
7
  //= require jquery
8
- //= require jquery_ujs
8
+ //= require rails-ujs
9
9
  //= require spree/frontend
10
10
  //= require_tree .
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solidus
4
+ module Migrations
5
+ module PromotionWithCodeHandlers
6
+ class PromotionCode < ActiveRecord::Base
7
+ self.table_name = "spree_promotion_codes"
8
+ end
9
+
10
+ class Base
11
+ attr_reader :migration_context, :promotions
12
+
13
+ def initialize(migration_context, promotions)
14
+ @migration_context = migration_context
15
+ @promotions = promotions
16
+ end
17
+ end
18
+
19
+ class RaiseException < Base
20
+ def call
21
+ # Please note that this will block the current migration and rollback all
22
+ # the previous ones run with the same "rails db:migrate" command.
23
+ #
24
+ raise StandardError, "You are trying to drop 'code' column from "\
25
+ "spree_promotions table but you have at least one record with that "\
26
+ "column filled. Please take care of that or you could lose data. See:" \
27
+ "\n" \
28
+ "https://github.com/solidusio/solidus/pull/3028"\
29
+ "\n"
30
+ end
31
+ end
32
+
33
+ class MoveToSpreePromotionCode < Base
34
+ def call
35
+ # This is another possible approach, it will convert Spree::Promotion#code
36
+ # to a Spree::PromotionCode before removing the `code` field.
37
+ #
38
+ # NOTE: promotion codes will be downcased and stripped
39
+ promotions.find_each do |promotion|
40
+ normalized_code = promotion.code.downcase.strip
41
+
42
+ PromotionCode.find_or_create_by!(
43
+ value: normalized_code,
44
+ promotion_id: promotion.id
45
+ ) do
46
+ migration_context.say "Creating Spree::PromotionCode with value "\
47
+ "'#{normalized_code}' for Spree::Promotion with id '#{promotion.id}'"
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ class DoNothing < Base
54
+ def call
55
+ # This approach will delete all codes without taking any action. At
56
+ # least we could print a message to track what we are deleting.
57
+ #
58
+ promotions.find_each do |promotion|
59
+ migration_context.say "Code '#{promotion.code}' is going to be removed "\
60
+ "from Spree::Promotion with id '#{promotion.id}'"
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -31,8 +31,8 @@ module Spree
31
31
  preference :address_requires_state, :boolean, default: true
32
32
 
33
33
  # @!attribute [rw] admin_interface_logo
34
- # @return [String] URL of logo used in admin (default: +'logo/solidus_logo.png'+)
35
- preference :admin_interface_logo, :string, default: 'logo/solidus_logo.png'
34
+ # @return [String] URL of logo used in admin (default: +'logo/solidus.svg'+)
35
+ preference :admin_interface_logo, :string, default: 'logo/solidus.svg'
36
36
 
37
37
  # @!attribute [rw] admin_products_per_page
38
38
  # @return [Integer] Number of products to display in admin (default: +10+)
@@ -142,8 +142,8 @@ module Spree
142
142
  preference :layout, :string, default: 'spree/layouts/spree_application'
143
143
 
144
144
  # @!attribute [rw] logo
145
- # @return [String] URL of logo used on frontend (default: +'logo/solidus_logo.png'+)
146
- preference :logo, :string, default: 'logo/solidus_logo.png'
145
+ # @return [String] URL of logo used on frontend (default: +'logo/solidus.svg'+)
146
+ preference :logo, :string, default: 'logo/solidus.svg'
147
147
 
148
148
  # @!attribute [rw] order_bill_address_used
149
149
  # @return [Boolean] Use the order's bill address, as opposed to storing
@@ -295,6 +295,8 @@ module Spree
295
295
  # promotion_chooser_class allows extensions to provide their own PromotionChooser
296
296
  class_name_attribute :promotion_chooser_class, default: 'Spree::PromotionChooser'
297
297
 
298
+ class_name_attribute :allocator_class, default: 'Spree::Stock::Allocator::OnHandFirst'
299
+
298
300
  class_name_attribute :shipping_rate_sorter_class, default: 'Spree::Stock::ShippingRateSorter'
299
301
 
300
302
  class_name_attribute :shipping_rate_selector_class, default: 'Spree::Stock::ShippingRateSelector'
@@ -407,6 +409,20 @@ module Spree
407
409
  # returns a String
408
410
  class_name_attribute :taxon_url_parametizer_class, default: 'ActiveSupport::Inflector'
409
411
 
412
+ # Allows providing your own class for image galleries on Variants
413
+ #
414
+ # @!attribute [rw] variant_gallery_class
415
+ # @return [Class] a class that implements an `images` method and returns an
416
+ # Enumerable of images adhering to the present_image_class interface
417
+ class_name_attribute :variant_gallery_class, default: 'Spree::Gallery::VariantGallery'
418
+
419
+ # Allows providing your own class for image galleries on Products
420
+ #
421
+ # @!attribute [rw] product_gallery_class
422
+ # @return [Class] a class that implements an `images` method and returns an
423
+ # Enumerable of images adhering to the present_image_class interface
424
+ class_name_attribute :product_gallery_class, default: 'Spree::Gallery::ProductGallery'
425
+
410
426
  # Allows providing your own class instance for generating order numbers.
411
427
  #
412
428
  # @!attribute [rw] order_number_generator
@@ -62,7 +62,7 @@ module Spree
62
62
  candidate &&
63
63
  available_locales.include?(candidate.to_sym)
64
64
  end
65
- session[:locale] = locale
65
+ session[set_user_language_locale_key] = locale
66
66
  I18n.locale = locale
67
67
  Carmen.i18n_backend.locale = locale
68
68
  end
@@ -5,6 +5,8 @@ module Spree
5
5
  class StockConfiguration
6
6
  attr_writer :coordinator_class
7
7
  attr_writer :estimator_class
8
+ attr_writer :location_sorter_class
9
+ attr_writer :allocator_class
8
10
 
9
11
  def coordinator_class
10
12
  @coordinator_class ||= '::Spree::Stock::SimpleCoordinator'
@@ -15,6 +17,16 @@ module Spree
15
17
  @estimator_class ||= '::Spree::Stock::Estimator'
16
18
  @estimator_class.constantize
17
19
  end
20
+
21
+ def location_sorter_class
22
+ @location_sorter_class ||= '::Spree::Stock::LocationSorter::Unsorted'
23
+ @location_sorter_class.constantize
24
+ end
25
+
26
+ def allocator_class
27
+ @allocator_class ||= '::Spree::Stock::Allocator::OnHandFirst'
28
+ @allocator_class.constantize
29
+ end
18
30
  end
19
31
  end
20
32
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Spree
4
4
  def self.solidus_version
5
- "2.7.4"
5
+ "2.8.0"
6
6
  end
7
7
 
8
8
  def self.solidus_gem_version
data/lib/spree/i18n.rb CHANGED
@@ -26,6 +26,10 @@ module Spree
26
26
  # extra functionality. e.g return reasonable strings for missing translations
27
27
 
28
28
  def translate(key, options = {})
29
+ Spree::Deprecation.warn <<-WARN.squish
30
+ Spree.t & Spree.translate have been deprecated.
31
+ Instead use I18n.t('spree.your_translation_key')
32
+ WARN
29
33
  options[:scope] = [:spree, *options[:scope]]
30
34
  TranslationHelperWrapper.new.translate(key, options)
31
35
  end
data/lib/spree/money.rb CHANGED
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'money'
4
- require 'monetize'
5
- require 'active_support/core_ext/string/output_safety'
6
-
7
3
  module Spree
8
4
  # Spree::Money is a relatively thin wrapper around Monetize which handles
9
5
  # formatting via Spree::Config.
@@ -77,16 +73,22 @@ module Spree
77
73
  @money.format(@options.merge(options))
78
74
  end
79
75
 
80
- # @note If you pass in options, ensure you pass in the html: true as well.
76
+ # @note If you pass in options, ensure you pass in the { html_wrap: true } as well.
81
77
  # @param options [Hash] additional formatting options
82
78
  # @return [String] the value of this money object formatted according to
83
- # its options and any additional options, by default as html.
84
- def to_html(options = { html: true })
79
+ # its options and any additional options, by default with html_wrap.
80
+ def to_html(options = { html_wrap: true })
85
81
  output = format(options)
86
- if options[:html]
87
- # 1) prevent blank, breaking spaces
88
- # 2) prevent escaping of HTML character entities
89
- output = output.sub(" ", "&nbsp;").html_safe
82
+ # Maintain compatibility by checking html option renamed to html_wrap.
83
+ if options[:html] || options[:html] == false
84
+ Spree::Deprecation.warn <<-WARN.squish, caller
85
+ Spree::Money#to_html called with Spree::Money#to_html(html: #{options[:html]}),
86
+ which will not be supported in the future.
87
+ Instead use :html_wrap e.g. Spree::Money#to_html(html_wrap: #{options[:html]})
88
+ WARN
89
+ end
90
+ if options[:html_wrap] || options[:html]
91
+ output = output.html_safe
90
92
  end
91
93
  output
92
94
  end
@@ -11,7 +11,6 @@ require 'spree/permission_sets/product_display'
11
11
  require 'spree/permission_sets/product_management'
12
12
  require 'spree/permission_sets/promotion_display'
13
13
  require 'spree/permission_sets/promotion_management'
14
- require 'spree/permission_sets/report_display'
15
14
  require 'spree/permission_sets/restricted_stock_display'
16
15
  require 'spree/permission_sets/restricted_stock_management'
17
16
  require 'spree/permission_sets/stock_display'
@@ -8,6 +8,7 @@ module Spree
8
8
  can :manage, Spree::PromotionRule
9
9
  can :manage, Spree::PromotionAction
10
10
  can :manage, Spree::PromotionCategory
11
+ can :manage, Spree::PromotionCode
11
12
  end
12
13
  end
13
14
  end
@@ -12,9 +12,16 @@ Rails.env = 'test'
12
12
 
13
13
  require 'solidus_core'
14
14
 
15
+ # @private
16
+ def forgery_protected_by_default?
17
+ Gem::Version.new(Rails.version) >= Gem::Version.new('5.2')
18
+ end
19
+
15
20
  # @private
16
21
  class ApplicationController < ActionController::Base
17
- protect_from_forgery with: :exception
22
+ if !forgery_protected_by_default?
23
+ protect_from_forgery with: :exception
24
+ end
18
25
  end
19
26
 
20
27
  # @private
@@ -50,14 +57,18 @@ module DummyApp
50
57
  config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
51
58
  config.whiny_nils = true
52
59
  config.consider_all_requests_local = true
60
+ config.action_controller.allow_forgery_protection = true
53
61
  config.action_controller.perform_caching = false
54
62
  config.action_dispatch.show_exceptions = false
55
63
  config.active_support.deprecation = :stderr
56
64
  config.action_mailer.delivery_method = :test
57
- config.action_controller.allow_forgery_protection = false
58
65
  config.active_support.deprecation = :stderr
59
66
  config.secret_key_base = 'SECRET_TOKEN'
60
67
 
68
+ if forgery_protected_by_default?
69
+ config.action_controller.default_protect_from_forgery = true
70
+ end
71
+
61
72
  if config.active_record.sqlite3
62
73
  # Rails >= 5.2
63
74
  config.active_record.sqlite3.represent_boolean_as_integer = true
@@ -5,6 +5,6 @@
5
5
  // the compiled file.
6
6
  //
7
7
  //= require jquery
8
- //= require jquery_ujs
8
+ //= require rails-ujs
9
9
  //= require spree/backend
10
10
  //= require_tree .