spree_core 2.0.12 → 2.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f6fc34716045492c73cd83a2a7f9e446a0f5a6b
4
- data.tar.gz: 94a3ffee5660aa9d365687e48197c2caed09936e
3
+ metadata.gz: 6a7abff523eebb24d6e7573a1276b2c68eac15b2
4
+ data.tar.gz: 59dd2a80a97247e186725cb8f0be540bf816ddf7
5
5
  SHA512:
6
- metadata.gz: 73ce47ef477bde8e1f32f37556a55e610b290ab8e69f29518e7f2911401b7b281731383498276f0d0ccf34dd621838d5209b06642b7897526e8c763fd2e51b54
7
- data.tar.gz: 687cf5058572498f0ed8582a32766056fb1090e74cbf9c5fd7645ffa041b9d38ec82379010e55ec3e1b8ae2fc38afe91c1dd7bddd2edb1ee944a862a7e6198ef
6
+ metadata.gz: 45e619b3362386a0fa401f357190c61d60c740064e68dc5a46802b60ddd41a0fe459d156eb59148e821d7573184a269260a838c16f045df11c5ae85c7a18c11a
7
+ data.tar.gz: 21e099c966c74e43758a2e3ef8c0864eefd5543f79c586d0d6354bcf923e695c7250d31d03b6bed10042800340634c1a0de657ffc1d9959aa198bd8bfa070bfa
@@ -172,7 +172,7 @@ module Spree
172
172
 
173
173
  # Returns style of image or nil
174
174
  def image_style_from_method_name(method_name)
175
- if style = method_name.to_s.sub(/_image$/, '')
175
+ if method_name.to_s.match(/_image$/) && style = method_name.to_s.sub(/_image$/, '')
176
176
  possible_styles = Spree::Image.attachment_definitions[:attachment][:styles]
177
177
  style if style.in? possible_styles.with_indifferent_access
178
178
  end
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  class Country < ActiveRecord::Base
3
- has_many :states, order: 'name ASC'
3
+ has_many :states, order: "#{Spree::State.quoted_table_name}.name ASC"
4
4
 
5
5
  validates :name, :iso_name, presence: true
6
6
 
@@ -12,7 +12,7 @@ module Spree
12
12
  .where("spree_shipments.state != 'canceled'")
13
13
  .where(variant_id: stock_item.variant_id)
14
14
  .where('spree_orders.completed_at is not null')
15
- .backordered.order("spree_orders.completed_at ASC")
15
+ .backordered.order("#{Spree::Order.quoted_table_name}.completed_at ASC")
16
16
  end
17
17
 
18
18
  attr_accessible :shipment, :variant_id
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  class OptionType < ActiveRecord::Base
3
- has_many :option_values, order: :position, dependent: :destroy
3
+ has_many :option_values, order: "#{Spree::OptionValue.quoted_table_name}.position", dependent: :destroy
4
4
  has_many :product_option_types, dependent: :destroy
5
5
  has_many :products, through: :product_option_types
6
6
  has_and_belongs_to_many :prototypes, join_table: 'spree_option_types_prototypes'
@@ -8,7 +8,7 @@ module Spree
8
8
  attr_accessible :name, :presentation, :option_values_attributes
9
9
 
10
10
  validates :name, :presentation, presence: true
11
- default_scope order: "#{self.table_name}.position"
11
+ default_scope order: "#{quoted_table_name}.position"
12
12
 
13
13
  accepts_nested_attributes_for :option_values, reject_if: lambda { |ov| ov[:name].blank? || ov[:presentation].blank? }, allow_destroy: true
14
14
  end
@@ -47,9 +47,9 @@ module Spree
47
47
  belongs_to :ship_address, foreign_key: :ship_address_id, class_name: 'Spree::Address'
48
48
  alias_attribute :shipping_address, :ship_address
49
49
 
50
- has_many :adjustments, as: :adjustable, dependent: :destroy, order: 'created_at ASC'
50
+ has_many :adjustments, as: :adjustable, dependent: :destroy, order: "#{::Spree::Adjustment.quoted_table_name}.created_at ASC"
51
51
  has_many :line_item_adjustments, through: :line_items, source: :adjustments
52
- has_many :line_items, dependent: :destroy, order: 'created_at ASC'
52
+ has_many :line_items, dependent: :destroy, order: "#{::Spree::LineItem.quoted_table_name}.created_at ASC"
53
53
  has_many :payments, dependent: :destroy
54
54
  has_many :return_authorizations, dependent: :destroy
55
55
  has_many :state_changes, as: :stateful
@@ -100,7 +100,7 @@ module Spree
100
100
  end
101
101
 
102
102
  def self.by_customer(customer)
103
- joins(:user).where("#{Spree.user_class.table_name}.email" => customer)
103
+ joins(:user).where("#{Spree.user_class.quoted_table_name}.email" => customer)
104
104
  end
105
105
 
106
106
  def self.by_state(state)
@@ -48,7 +48,7 @@ module Spree
48
48
  dependent: :destroy,
49
49
  order: "#{::Spree::Variant.quoted_table_name}.position ASC"
50
50
 
51
- has_many :prices, through: :variants, order: 'spree_variants.position, spree_variants.id, currency'
51
+ has_many :prices, through: :variants, order: "#{::Spree::Variant.quoted_table_name}.position, #{::Spree::Variant.quoted_table_name}.id, #{::Spree::Price.quoted_table_name}.currency"
52
52
  has_many :stock_items, through: :variants_including_master
53
53
 
54
54
  delegate_belongs_to :master, :sku, :price, :currency, :display_amount, :display_price, :weight, :height, :width, :depth, :is_master, :has_default_price?, :cost_currency, :price_in, :amount_in
@@ -8,7 +8,7 @@ module Spree
8
8
 
9
9
  attr_accessible :property_name, :value, :position
10
10
 
11
- default_scope order: "#{self.table_name}.position"
11
+ default_scope order: "#{quoted_table_name}.position"
12
12
 
13
13
  # virtual attributes for use with AJAX completion stuff
14
14
  def property_name
@@ -9,12 +9,12 @@ module Spree
9
9
 
10
10
  validates :name, :presentation, presence: true
11
11
 
12
- scope :sorted, -> { order(:name) }
12
+ scope :sorted, -> { order("#{quoted_table_name}.name") }
13
13
 
14
14
  def self.find_all_by_prototype(prototype)
15
15
  id = prototype
16
16
  id = prototype.id if prototype.class == Prototype
17
- joins("LEFT JOIN properties_prototypes ON property_id = #{self.table_name}.id").
17
+ joins("LEFT JOIN properties_prototypes ON property_id = #{quoted_table_name}.id").
18
18
  where(prototype_id: id)
19
19
  end
20
20
  end
@@ -64,11 +64,11 @@ module Spree
64
64
  end
65
65
 
66
66
  def self.on_backend_query
67
- "#{table_name}.display_on != 'front_end' OR #{table_name}.display_on IS NULL"
67
+ "#{quoted_table_name}.display_on != 'front_end' OR #{quoted_table_name}.display_on IS NULL"
68
68
  end
69
69
 
70
70
  def self.on_frontend_query
71
- "#{table_name}.display_on != 'back_end' OR #{table_name}.display_on IS NULL"
71
+ "#{quoted_table_name}.display_on != 'back_end' OR #{quoted_table_name}.display_on IS NULL"
72
72
  end
73
73
  end
74
74
  end
@@ -7,14 +7,14 @@ module Spree
7
7
  attr_accessible :name, :abbr
8
8
 
9
9
  def self.find_all_by_name_or_abbr(name_or_abbr)
10
- where('name = ? OR abbr = ?', name_or_abbr, name_or_abbr)
10
+ where("#{quoted_table_name}.name = ? OR #{quoted_table_name}.abbr = ?", name_or_abbr, name_or_abbr)
11
11
  end
12
12
 
13
13
  # table of { country.id => [ state.id , state.name ] }, arrays sorted by name
14
14
  # blank is added elsewhere, if needed
15
15
  def self.states_group_by_country_id
16
16
  state_info = Hash.new { |h, k| h[k] = [] }
17
- self.order('name ASC').each { |state|
17
+ self.order("#{quoted_table_name}.name ASC").each { |state|
18
18
  state_info[state.country_id.to_s].push [state.id, state.name]
19
19
  }
20
20
  state_info
@@ -10,7 +10,7 @@ module Spree
10
10
  validates :stock_item, presence: true
11
11
  validates :quantity, presence: true
12
12
 
13
- scope :recent, order('created_at DESC')
13
+ scope :recent, order("#{quoted_table_name}.created_at DESC")
14
14
 
15
15
  def readonly?
16
16
  !new_record?
@@ -10,7 +10,7 @@ module Spree
10
10
 
11
11
  after_save :set_name
12
12
 
13
- default_scope order: "#{self.table_name}.position"
13
+ default_scope order: "#{quoted_table_name}.position"
14
14
 
15
15
  private
16
16
  def set_name
@@ -61,7 +61,7 @@ module Spree
61
61
  end
62
62
 
63
63
  def options_text
64
- values = self.option_values.joins(:option_type).order("#{Spree::OptionType.table_name}.position asc")
64
+ values = self.option_values.joins(:option_type).order("#{Spree::OptionType.quoted_table_name}.position asc")
65
65
 
66
66
  values.map! do |ov|
67
67
  "#{ov.option_type.presentation}: #{ov.presentation}"
@@ -1,5 +1,10 @@
1
1
  class RenameShippingMethodsZonesToSpreeShippingMethodsZones < ActiveRecord::Migration
2
2
  def change
3
3
  rename_table :shipping_methods_zones, :spree_shipping_methods_zones
4
+ # If Spree::ShippingMethod zones association was patched in
5
+ # CreateShippingMethodZone migrations, it needs to be patched back
6
+ Spree::ShippingMethod.has_and_belongs_to_many :zones, :join_table => 'spree_shipping_methods_zones',
7
+ :class_name => 'Spree::Zone',
8
+ :foreign_key => 'shipping_method_id'
4
9
  end
5
10
  end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- '2.0.12'
3
+ '2.0.13'
4
4
  end
5
5
  end
@@ -34,7 +34,12 @@ module Spree
34
34
  event_name = "spree.checkout.coupon_code_added"
35
35
  if promotion.activate(:coupon_code => @order.coupon_code, :order => @order)
36
36
  promo = @order.adjustments.includes(:originator).promotion.detect { |p| p.originator.promotion.code == @order.coupon_code }
37
- determine_promotion_application_result(promo)
37
+ if promo.present?
38
+ determine_promotion_application_result(promo)
39
+ else
40
+ # if action is create line items
41
+ return { :coupon_applied? => true, :success => Spree.t(:coupon_code_applied) }
42
+ end
38
43
  else
39
44
  return { :coupon_applied? => false, :error => Spree.t(:coupon_code_not_eligible) }
40
45
  end
data/lib/tasks/core.rake CHANGED
@@ -86,8 +86,8 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
86
86
  end
87
87
 
88
88
  if load_sample
89
- #prevent errors for missing attributes (since rails 3.1 upgrade)
90
-
89
+ # Reload models' attributes in case they were loaded in old migrations with wrong attributes
90
+ ActiveRecord::Base.descendants.each(&:reset_column_information)
91
91
  Rake::Task["spree_sample:load"].invoke
92
92
  end
93
93
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.12
4
+ version: 2.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-29 00:00:00.000000000 Z
11
+ date: 2014-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -212,14 +212,14 @@ dependencies:
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: 3.2.18
215
+ version: 3.2.21
216
216
  type: :runtime
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: 3.2.18
222
+ version: 3.2.21
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: ransack
225
225
  requirement: !ruby/object:Gem::Requirement