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
@@ -21,14 +21,14 @@ module Spree
21
21
 
22
22
  # Wrapper for creating a new stock item respecting the backorderable config
23
23
  def propagate_variant(variant)
24
- self.stock_items.create!(variant: variant, backorderable: self.backorderable_default)
24
+ stock_items.create!(variant: variant, backorderable: backorderable_default)
25
25
  end
26
26
 
27
27
  # Return either an existing stock item or create a new one. Useful in
28
28
  # scenarios where the user might not know whether there is already a stock
29
29
  # item for a given variant
30
30
  def set_up_stock_item(variant)
31
- self.stock_item(variant) || propagate_variant(variant)
31
+ stock_item(variant) || propagate_variant(variant)
32
32
  end
33
33
 
34
34
  # Returns an instance of StockItem for the variant id.
@@ -68,7 +68,7 @@ module Spree
68
68
  move(variant, quantity, originator)
69
69
  end
70
70
 
71
- def restock_backordered(variant, quantity, originator = nil)
71
+ def restock_backordered(variant, quantity, _originator = nil)
72
72
  item = stock_item_or_create(variant)
73
73
  item.update_columns(
74
74
  count_on_hand: item.count_on_hand + quantity,
@@ -104,16 +104,17 @@ module Spree
104
104
  end
105
105
 
106
106
  private
107
- def create_stock_items
108
- Variant.includes(:product).find_each do |variant|
109
- propagate_variant(variant)
110
- end
107
+
108
+ def create_stock_items
109
+ Variant.includes(:product).find_each do |variant|
110
+ propagate_variant(variant)
111
111
  end
112
+ end
112
113
 
113
- def ensure_one_default
114
- if self.default
115
- StockLocation.where(default: true).where.not(id: self.id).update_all(default: false)
116
- end
114
+ def ensure_one_default
115
+ if default
116
+ StockLocation.where(default: true).where.not(id: id).update_all(default: false)
117
117
  end
118
+ end
118
119
  end
119
120
  end
@@ -30,10 +30,8 @@ module Spree
30
30
  private
31
31
 
32
32
  def update_stock_item_quantity
33
- return unless self.stock_item.should_track_inventory?
33
+ return unless stock_item.should_track_inventory?
34
34
  stock_item.adjust_count_on_hand quantity
35
35
  end
36
-
37
36
  end
38
37
  end
39
-
@@ -31,7 +31,7 @@ module Spree
31
31
 
32
32
  self.source_location = source_location
33
33
  self.destination_location = destination_location
34
- self.save!
34
+ save!
35
35
  end
36
36
  end
37
37
  end
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  class Store < Spree::Base
3
- has_many :orders, class_name: "Spree::Order"
3
+ has_many :orders, class_name: 'Spree::Order'
4
4
 
5
5
  with_options presence: true do
6
6
  validates :code, uniqueness: { case_sensitive: false, allow_blank: true }
@@ -10,7 +10,7 @@ module Spree
10
10
  before_save :ensure_default_exists_and_is_unique
11
11
  before_destroy :validate_not_default
12
12
 
13
- scope :by_url, lambda { |url| where("url like ?", "%#{url}%") }
13
+ scope :by_url, ->(url) { where('url like ?', "%#{url}%") }
14
14
 
15
15
  after_commit :clear_cache
16
16
 
@@ -20,7 +20,7 @@ module Spree
20
20
  end
21
21
 
22
22
  def self.default
23
- Rails.cache.fetch("default_store") do
23
+ Rails.cache.fetch('default_store') do
24
24
  where(default: true).first_or_initialize
25
25
  end
26
26
  end
@@ -43,7 +43,7 @@ module Spree
43
43
  end
44
44
 
45
45
  def clear_cache
46
- Rails.cache.delete("default_store")
46
+ Rails.cache.delete('default_store')
47
47
  end
48
48
  end
49
49
  end
@@ -204,9 +204,9 @@ module Spree
204
204
 
205
205
  def store_event
206
206
  return unless saved_change_to_amount? ||
207
- saved_change_to_amount_used? ||
208
- saved_change_to_amount_authorized? ||
209
- action == ELIGIBLE_ACTION
207
+ saved_change_to_amount_used? ||
208
+ saved_change_to_amount_authorized? ||
209
+ action == ELIGIBLE_ACTION
210
210
 
211
211
  event = if action
212
212
  store_credit_events.build(action: action)
@@ -8,7 +8,7 @@ module Spree
8
8
  before_save :set_default_category
9
9
 
10
10
  def set_default_category
11
- #set existing default tax category to false if this one has been marked as default
11
+ # set existing default tax category to false if this one has been marked as default
12
12
 
13
13
  if is_default && tax_category = self.class.where(is_default: true).where.not(id: id).first
14
14
  tax_category.update_columns(is_default: false, updated_at: Time.current)
@@ -6,9 +6,9 @@ module Spree
6
6
  include Spree::AdjustmentSource
7
7
 
8
8
  with_options inverse_of: :tax_rates do
9
- belongs_to :zone, class_name: "Spree::Zone", optional: true
9
+ belongs_to :zone, class_name: 'Spree::Zone', optional: true
10
10
  belongs_to :tax_category,
11
- class_name: "Spree::TaxCategory"
11
+ class_name: 'Spree::TaxCategory'
12
12
  end
13
13
 
14
14
  with_options presence: true do
@@ -16,15 +16,15 @@ module Spree
16
16
  validates :tax_category
17
17
  end
18
18
 
19
- scope :by_zone, -> (zone) { where(zone_id: zone.id) }
19
+ scope :by_zone, ->(zone) { where(zone_id: zone.id) }
20
20
  scope :potential_rates_for_zone,
21
- -> (zone) do
21
+ ->(zone) do
22
22
  where(zone_id: Spree::Zone.potential_matching_zones(zone).pluck(:id))
23
23
  end
24
24
  scope :for_default_zone,
25
25
  -> { potential_rates_for_zone(Spree::Zone.default_tax) }
26
26
  scope :for_tax_category,
27
- -> (category) { where(tax_category_id: category.try(:id)) }
27
+ ->(category) { where(tax_category_id: category.try(:id)) }
28
28
  scope :included_in_price, -> { where(included_in_price: true) }
29
29
 
30
30
  # Gets the array of TaxRates appropriate for the specified tax zone
@@ -44,7 +44,7 @@ module Spree
44
44
 
45
45
  included_rates = rates.select(&:included_in_price)
46
46
  if included_rates.any?
47
- pre_tax_amount /= (1 + included_rates.map(&:amount).sum)
47
+ pre_tax_amount /= (1 + included_rates.sum(&:amount))
48
48
  end
49
49
 
50
50
  item.update_column(:pre_tax_amount, pre_tax_amount)
@@ -85,7 +85,7 @@ module Spree
85
85
  potential_rates_for_zone(options[:tax_zone]).
86
86
  included_in_price.
87
87
  for_tax_category(options[:tax_category]).
88
- pluck(:amount).sum
88
+ sum(:amount)
89
89
  end
90
90
 
91
91
  def adjust(order, item)
@@ -100,14 +100,14 @@ module Spree
100
100
 
101
101
  def label
102
102
  Spree.t included_in_price? ? :including_tax : :excluding_tax,
103
- scope: "adjustment_labels.tax_rates",
103
+ scope: 'adjustment_labels.tax_rates',
104
104
  name: name.presence || tax_category.name,
105
105
  amount: amount_for_label
106
106
  end
107
107
 
108
108
  def amount_for_label
109
- return "" unless show_rate_in_label?
110
- " " + ActiveSupport::NumberHelper::NumberToPercentageConverter.convert(
109
+ return '' unless show_rate_in_label?
110
+ ' ' + ActiveSupport::NumberHelper::NumberToPercentageConverter.convert(
111
111
  amount * 100,
112
112
  locale: I18n.locale
113
113
  )
@@ -1,4 +1,4 @@
1
- # TODO let friendly id take care of sanitizing the url
1
+ # TODO: let friendly id take care of sanitizing the url
2
2
  require 'stringex'
3
3
 
4
4
  module Spree
@@ -31,14 +31,14 @@ module Spree
31
31
  after_touch :touch_ancestors_and_taxonomy
32
32
 
33
33
  has_attached_file :icon,
34
- styles: { mini: '32x32>', normal: '128x128>' },
35
- default_style: :mini,
36
- url: '/spree/taxons/:id/:style/:basename.:extension',
37
- path: ':rails_root/public/spree/taxons/:id/:style/:basename.:extension',
38
- default_url: '/assets/default_taxon.png'
34
+ styles: { mini: '32x32>', normal: '128x128>' },
35
+ default_style: :mini,
36
+ url: '/spree/taxons/:id/:style/:basename.:extension',
37
+ path: ':rails_root/public/spree/taxons/:id/:style/:basename.:extension',
38
+ default_url: '/assets/default_taxon.png'
39
39
 
40
40
  validates_attachment :icon,
41
- content_type: { content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"] }
41
+ content_type: { content_type: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'] }
42
42
 
43
43
  self.whitelisted_ransackable_associations = %w[taxonomy]
44
44
 
@@ -56,10 +56,10 @@ module Spree
56
56
 
57
57
  # Return meta_title if set otherwise generates from root name and/or taxon name
58
58
  def seo_title
59
- unless meta_title.blank?
60
- meta_title
61
- else
59
+ if meta_title.blank?
62
60
  root? ? name : "#{root.name} - #{name}"
61
+ else
62
+ meta_title
63
63
  end
64
64
  end
65
65
 
@@ -77,10 +77,10 @@ module Spree
77
77
  end
78
78
 
79
79
  def pretty_name
80
- ancestor_chain = self.ancestors.inject("") do |name, ancestor|
80
+ ancestor_chain = ancestors.inject('') do |name, ancestor|
81
81
  name += "#{ancestor.name} -> "
82
82
  end
83
- ancestor_chain + "#{name}"
83
+ ancestor_chain + name.to_s
84
84
  end
85
85
 
86
86
  # awesome_nested_set sorts by :lft and :rgt. This call re-inserts the child
@@ -90,7 +90,7 @@ module Spree
90
90
  #
91
91
  # See #3390 for background.
92
92
  def child_index=(idx)
93
- move_to_child_with_index(parent, idx.to_i) unless self.new_record?
93
+ move_to_child_with_index(parent, idx.to_i) unless new_record?
94
94
  end
95
95
 
96
96
  private
@@ -5,20 +5,21 @@ module Spree
5
5
  validates :name, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }
6
6
 
7
7
  has_many :taxons, inverse_of: :taxonomy
8
- has_one :root, -> { where parent_id: nil }, class_name: "Spree::Taxon", dependent: :destroy
8
+ has_one :root, -> { where parent_id: nil }, class_name: 'Spree::Taxon', dependent: :destroy
9
9
 
10
10
  after_create :set_root
11
11
  after_save :set_root_taxon_name
12
12
 
13
- default_scope { order("#{self.table_name}.position, #{self.table_name}.created_at") }
13
+ default_scope { order("#{table_name}.position, #{table_name}.created_at") }
14
14
 
15
15
  private
16
- def set_root
17
- self.root ||= Taxon.create!(taxonomy_id: id, name: name)
18
- end
19
16
 
20
- def set_root_taxon_name
21
- root.update_attributes(name: name)
22
- end
17
+ def set_root
18
+ self.root ||= Taxon.create!(taxonomy_id: id, name: name)
19
+ end
20
+
21
+ def set_root_taxon_name
22
+ root.update_attributes(name: name)
23
+ end
23
24
  end
24
25
  end
@@ -3,15 +3,14 @@ module Spree
3
3
  ##
4
4
  # Validates a field based on the maximum length of the underlying DB field, if there is one.
5
5
  class DbMaximumLengthValidator < ActiveModel::Validator
6
-
7
6
  def initialize(options)
8
7
  super
9
8
  @field = options[:field].to_s
10
- raise ArgumentError.new("a field must be specified to the validator") if @field.blank?
9
+ raise ArgumentError, 'a field must be specified to the validator' if @field.blank?
11
10
  end
12
11
 
13
12
  def validate(record)
14
- warn "`Spree::Validations::DbMaximumLengthValidator` is deprecated. Use `DbMaximumLengthValidator` instead."
13
+ warn '`Spree::Validations::DbMaximumLengthValidator` is deprecated. Use `DbMaximumLengthValidator` instead.'
15
14
  limit = record.class.columns_hash[@field].limit
16
15
  value = record[@field.to_sym]
17
16
  if value && limit && value.to_s.length > limit
@@ -31,12 +31,12 @@ module Spree
31
31
  has_many :option_value_variants, class_name: 'Spree::OptionValueVariant'
32
32
  has_many :option_values, through: :option_value_variants, class_name: 'Spree::OptionValue'
33
33
 
34
- has_many :images, -> { order(:position) }, as: :viewable, dependent: :destroy, class_name: "Spree::Image"
34
+ has_many :images, -> { order(:position) }, as: :viewable, dependent: :destroy, class_name: 'Spree::Image'
35
35
 
36
36
  has_many :prices,
37
- class_name: 'Spree::Price',
38
- dependent: :destroy,
39
- inverse_of: :variant
37
+ class_name: 'Spree::Price',
38
+ dependent: :destroy,
39
+ inverse_of: :variant
40
40
 
41
41
  before_validation :set_cost_currency
42
42
 
@@ -67,12 +67,12 @@ module Spree
67
67
 
68
68
  scope :not_deleted, -> { where("#{Variant.quoted_table_name}.deleted_at IS NULL") }
69
69
 
70
- scope :for_currency_and_available_price_amount, -> (currency) do
70
+ scope :for_currency_and_available_price_amount, ->(currency) do
71
71
  currency ||= Spree::Config[:currency]
72
- joins(:prices).where("spree_prices.currency = ?", currency).where("spree_prices.amount IS NOT NULL").distinct
72
+ joins(:prices).where('spree_prices.currency = ?', currency).where('spree_prices.amount IS NOT NULL').distinct
73
73
  end
74
74
 
75
- scope :active, -> (currency = nil) do
75
+ scope :active, ->(currency = nil) do
76
76
  not_discontinued.not_deleted.
77
77
  for_currency_and_available_price_amount(currency)
78
78
  end
@@ -92,11 +92,6 @@ module Spree
92
92
  !discontinued? && product.available?
93
93
  end
94
94
 
95
- def self.having_orders
96
- warn "`Spree::Variant#having_orders` is deprecated and will be removed in Spree 3.4"
97
- joins(:line_items).distinct
98
- end
99
-
100
95
  def tax_category
101
96
  if self[:tax_category_id].nil?
102
97
  product.tax_category
@@ -105,14 +100,8 @@ module Spree
105
100
  end
106
101
  end
107
102
 
108
- # returns number of units currently on backorder for this variant.
109
- def on_backorder
110
- warn "`Spree::Variant#on_backorder` is deprecated and will be removed in Spree 3.4"
111
- inventory_units.with_state('backordered').size
112
- end
113
-
114
103
  def options_text
115
- values = self.option_values.sort do |a, b|
104
+ values = option_values.sort do |a, b|
116
105
  a.option_type.position <=> b.option_type.position
117
106
  end
118
107
 
@@ -120,7 +109,7 @@ module Spree
120
109
  "#{ov.option_type.presentation}: #{ov.presentation}"
121
110
  end
122
111
 
123
- values.to_sentence({ words_connector: ", ", two_words_connector: ", " })
112
+ values.to_sentence(words_connector: ', ', two_words_connector: ', ')
124
113
  end
125
114
 
126
115
  # Default to master name
@@ -154,23 +143,23 @@ module Spree
154
143
 
155
144
  def set_option_value(opt_name, opt_value)
156
145
  # no option values on master
157
- return if self.is_master
146
+ return if is_master
158
147
 
159
148
  option_type = Spree::OptionType.where(name: opt_name).first_or_initialize do |o|
160
149
  o.presentation = opt_name
161
150
  o.save!
162
151
  end
163
152
 
164
- current_value = self.option_values.detect { |o| o.option_type.name == opt_name }
153
+ current_value = option_values.detect { |o| o.option_type.name == opt_name }
165
154
 
166
- unless current_value.nil?
167
- return if current_value.name == opt_value
168
- self.option_values.delete(current_value)
169
- else
155
+ if current_value.nil?
170
156
  # then we have to check to make sure that the product has the option type
171
- unless self.product.option_types.include? option_type
172
- self.product.option_types << option_type
157
+ unless product.option_types.include? option_type
158
+ product.option_types << option_type
173
159
  end
160
+ else
161
+ return if current_value.name == opt_value
162
+ option_values.delete(current_value)
174
163
  end
175
164
 
176
165
  option_value = Spree::OptionValue.where(option_type_id: option_type.id, name: opt_value).first_or_initialize do |o|
@@ -178,12 +167,12 @@ module Spree
178
167
  o.save!
179
168
  end
180
169
 
181
- self.option_values << option_value
182
- self.save
170
+ option_values << option_value
171
+ save
183
172
  end
184
173
 
185
174
  def option_value(opt_name)
186
- self.option_values.detect { |o| o.option_type.name == opt_name }.try(:presentation)
175
+ option_values.detect { |o| o.option_type.name == opt_name }.try(:presentation)
187
176
  end
188
177
 
189
178
  def price_in(currency)
@@ -197,27 +186,27 @@ module Spree
197
186
  def price_modifier_amount_in(currency, options = {})
198
187
  return 0 unless options.present?
199
188
 
200
- options.keys.map { |key|
189
+ options.keys.map do |key|
201
190
  m = "#{key}_price_modifier_amount_in".to_sym
202
- if self.respond_to? m
203
- self.send(m, currency, options[key])
191
+ if respond_to? m
192
+ send(m, currency, options[key])
204
193
  else
205
194
  0
206
195
  end
207
- }.sum
196
+ end.sum
208
197
  end
209
198
 
210
199
  def price_modifier_amount(options = {})
211
200
  return 0 unless options.present?
212
201
 
213
- options.keys.map { |key|
202
+ options.keys.map do |key|
214
203
  m = "#{key}_price_modifier_amount".to_sym
215
- if self.respond_to? m
216
- self.send(m, options[key])
204
+ if respond_to? m
205
+ send(m, options[key])
217
206
  else
218
207
  0
219
208
  end
220
- }.sum
209
+ end.sum
221
210
  end
222
211
 
223
212
  def name_and_sku
@@ -241,11 +230,11 @@ module Spree
241
230
  # Shortcut method to determine if inventory tracking is enabled for this variant
242
231
  # This considers both variant tracking flag and site-wide inventory tracking settings
243
232
  def should_track_inventory?
244
- self.track_inventory? && Spree::Config.track_inventory_levels
233
+ track_inventory? && Spree::Config.track_inventory_levels
245
234
  end
246
235
 
247
236
  def track_inventory
248
- self.should_track_inventory?
237
+ should_track_inventory?
249
238
  end
250
239
 
251
240
  def volume
@@ -31,9 +31,9 @@ module Spree
31
31
  def self.potential_matching_zones(zone)
32
32
  if zone.country?
33
33
  # Match zones of the same kind with similar countries
34
- joins(countries: :zones)
35
- .where('zone_members_spree_countries_join.zone_id = ?', zone.id)
36
- .distinct
34
+ joins(countries: :zones).
35
+ where('zone_members_spree_countries_join.zone_id = ?', zone.id).
36
+ distinct
37
37
  else
38
38
  # Match zones of the same kind with similar states in AND match zones
39
39
  # that have the states countries in
@@ -52,13 +52,13 @@ module Spree
52
52
  # Returns nil in the case of no matches.
53
53
  def self.match(address)
54
54
  return unless address &&
55
- matches = includes(:zone_members)
56
- .order('spree_zones.zone_members_count', 'spree_zones.created_at')
57
- .where("(spree_zone_members.zoneable_type = 'Spree::Country' AND " \
58
- 'spree_zone_members.zoneable_id = ?) OR ' \
59
- "(spree_zone_members.zoneable_type = 'Spree::State' AND " \
60
- 'spree_zone_members.zoneable_id = ?)', address.country_id, address.state_id)
61
- .references(:zones)
55
+ matches = includes(:zone_members).
56
+ order('spree_zones.zone_members_count', 'spree_zones.created_at').
57
+ where("(spree_zone_members.zoneable_type = 'Spree::Country' AND " \
58
+ 'spree_zone_members.zoneable_id = ?) OR ' \
59
+ "(spree_zone_members.zoneable_type = 'Spree::State' AND " \
60
+ 'spree_zone_members.zoneable_id = ?)', address.country_id, address.state_id).
61
+ references(:zones)
62
62
 
63
63
  %w[state country].each do |zone_kind|
64
64
  if match = matches.detect { |zone| zone_kind == zone.kind }
@@ -2,11 +2,11 @@
2
2
  # Validates a field based on the maximum length of the underlying DB field, if there is one.
3
3
  class DbMaximumLengthValidator < ActiveModel::EachValidator
4
4
  def validate_each(record, attribute, value)
5
- if defined?(Globalize)
6
- limit = record.class.translation_class.columns_hash[attribute.to_s].limit
7
- else
8
- limit = record.class.columns_hash[attribute.to_s].limit
9
- end
5
+ limit = if defined?(Globalize)
6
+ record.class.translation_class.columns_hash[attribute.to_s].limit
7
+ else
8
+ record.class.columns_hash[attribute.to_s].limit
9
+ end
10
10
  value = record[attribute.to_sym]
11
11
  if value && limit && value.to_s.length > limit
12
12
  record.errors.add(attribute.to_sym, :too_long, count: limit)
@@ -1,9 +1,9 @@
1
- require "acts-as-taggable-on"
1
+ require 'acts-as-taggable-on'
2
2
 
3
3
  ActsAsTaggableOn::Tag.class_eval do
4
- self.table_name_prefix = "spree_"
4
+ self.table_name_prefix = 'spree_'
5
5
  end
6
6
 
7
7
  ActsAsTaggableOn::Tagging.class_eval do
8
- self.table_name_prefix = "spree_"
8
+ self.table_name_prefix = 'spree_'
9
9
  end
@@ -1 +1 @@
1
- Rails.application.config.assets.precompile += %w( logo/spree_50.png noimage/*.png )
1
+ Rails.application.config.assets.precompile += %w(logo/spree_50.png noimage/*.png)
@@ -3,5 +3,5 @@
3
3
  FriendlyId.defaults do |config|
4
4
  config.use :reserved
5
5
  config.reserved_words = %w(new edit index session login logout users admin
6
- stylesheets assets javascripts images)
6
+ stylesheets assets javascripts images)
7
7
  end
@@ -1 +1 @@
1
- Rails.application.config.assets.precompile += %w( ink.css )
1
+ Rails.application.config.assets.precompile += %w(ink.css)
@@ -540,7 +540,7 @@ en:
540
540
  back_to_resource_list: 'Back To %{resource} List'
541
541
  back_to_payment: Back To Payment
542
542
  back_to_rma_reason_list: Back To RMA Reason List
543
- back_to_store: Go Back To Store
543
+ back_to_store: Back to Store
544
544
  back_to_users_list: Back To Users List
545
545
  backorderable: Backorderable
546
546
  backorderable_default: Backorderable default
@@ -749,6 +749,7 @@ en:
749
749
  excl: excl.
750
750
  expiration: Expiration
751
751
  extension: Extension
752
+ extensions_directory: Extensions Directory
752
753
  existing_shipments: Existing shipments
753
754
  failed_payment_attempts: Failed Payment Attempts
754
755
  filename: Filename
@@ -779,6 +780,7 @@ en:
779
780
  has_no_shipped_units: has no shipped units
780
781
  height: Height
781
782
  home: Home
783
+ help_center: Help Center
782
784
  i18n:
783
785
  available_locales: Available Locales
784
786
  fields: Fields
@@ -837,6 +839,7 @@ en:
837
839
  items_to_be_reimbursed: Items to be reimbursed
838
840
  items_reimbursed: Items reimbursed
839
841
  jirafe: Jirafe
842
+ join_slack: Join Slack
840
843
  last_name: Last Name
841
844
  last_name_begins_with: Last Name Begins With
842
845
  learn_more: Learn More
@@ -1364,7 +1367,10 @@ en:
1364
1367
  stock_movements: Stock Movements
1365
1368
  stock_movements_for_stock_location: Stock Movements for %{stock_location_name}
1366
1369
  stock_successfully_transferred: Stock was successfully transferred between locations.
1367
- stock_transfer: Stock Transfer
1370
+ stock_transfer_name: Stock Transfer
1371
+ stock_transfer:
1372
+ errors:
1373
+ must_have_variant: You must add atleast one variant.
1368
1374
  stock_transfers: Stock Transfers
1369
1375
  stop: Stop
1370
1376
  store: Store
@@ -4,6 +4,7 @@ state_inserts = []
4
4
  state_values = -> do
5
5
  Spree::Country.where(states_required: true).each do |country|
6
6
  carmen_country = Carmen::Country.named(country.name)
7
+ next if !carmen_country
7
8
  carmen_country.subregions.each do |subregion|
8
9
  name = connection.quote subregion.name
9
10
  abbr = connection.quote subregion.code