spree_core 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -89,7 +89,7 @@ $(document).ready(function(){
89
89
  html = format_user_autocomplete(item);
90
90
  return $("<li></li>")
91
91
  .data("item.autocomplete", item)
92
- .append("<a class='ui-menu-item'>" + html + "</a>")
92
+ .append("<a>" + html + "</a>")
93
93
  .appendTo(ul);
94
94
  }
95
95
 
@@ -1,5 +1,5 @@
1
1
  $ ->
2
- ($ 'input[type=checkbox]:not(:checked)').attr 'disabled', true if ($ '.categories input:checked').length > 0
2
+ ($ 'fieldset.categories input[type=checkbox]:not(:checked)').attr 'disabled', true if ($ '.categories input:checked').length > 0
3
3
  categoryCheckboxes = '.categories input[type=checkbox]'
4
4
  $(categoryCheckboxes).change ->
5
5
  if ($ this).is(':checked')
@@ -108,7 +108,7 @@ module Spree
108
108
 
109
109
  tmp = super.where(["#{Variant.table_name}.sku #{LIKE} ?", "%#{params[:q]}%"])
110
110
  tmp = tmp.includes(:variants_including_master).limit(params[:limit] || 10)
111
- @collection.concat(tmp)
111
+ @collection.concat(tmp).uniq!
112
112
  end
113
113
  @collection
114
114
  end
@@ -4,8 +4,8 @@ module Spree
4
4
  if request.referer && request.referer.starts_with?('http://' + request.host)
5
5
  session['user_return_to'] = request.referer
6
6
  end
7
- if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
8
- session[:locale] = I18n.locale = params[:locale].to_sym
7
+ if params[:locale] && I18n.available_locales.map(&:to_s).include?(params[:locale])
8
+ session[:locale] = I18n.locale = params[:locale]
9
9
  flash.notice = t(:locale_changed)
10
10
  else
11
11
  flash[:error] = t(:locale_not_changed)
@@ -111,7 +111,7 @@ module Spree
111
111
  options = { :email => order.email,
112
112
  :customer => order.email,
113
113
  :ip => '192.168.1.100', # TODO: Use an actual IP
114
- :order_id => order.number }
114
+ :order_id => "#{order.number}-#{self.identifier}" }
115
115
 
116
116
  options.merge!({ :shipping => order.ship_total * 100,
117
117
  :tax => order.tax_total * 100,
@@ -8,6 +8,8 @@ module Spree
8
8
  has_many :offsets, :class_name => "Spree::Payment", :foreign_key => :source_id, :conditions => "source_type = 'Spree::Payment' AND amount < 0 AND state = 'completed'"
9
9
  has_many :log_entries, :as => :source
10
10
 
11
+ before_save :set_unique_identifier
12
+
11
13
  after_save :create_payment_profile, :if => :profiles_supported?
12
14
 
13
15
  # update the order totals, etc.
@@ -100,5 +102,22 @@ module Spree
100
102
  order.payments.reload
101
103
  order.update!
102
104
  end
105
+
106
+ # Necessary because some payment gateways will refuse payments with
107
+ # duplicate IDs. We *were* using the Order number, but that's set once and
108
+ # is unchanging. What we need is a unique identifier on a per-payment basis,
109
+ # and this is it. Related to #1998.
110
+ # See https://github.com/spree/spree/issues/1998#issuecomment-12869105
111
+ def set_unique_identifier
112
+ chars = [('A'..'Z').to_a, ('0'..'9').to_a].flatten - %w(0 1 I O)
113
+ identifier = ''
114
+ 8.times { identifier << chars[rand(chars.length)] }
115
+ if Spree::Payment.exists?(:identifier => identifier)
116
+ # Call it again, we've got a duplicate ID.
117
+ set_unique_identifier
118
+ else
119
+ self.identifier = identifier
120
+ end
121
+ end
103
122
  end
104
123
  end
@@ -67,7 +67,7 @@ module Spree
67
67
  end
68
68
 
69
69
  def options_text
70
- values = self.option_values.sort_by(&:position)
70
+ values = self.option_values.joins(:option_type).order("#{Spree::OptionType.table_name}.position asc")
71
71
 
72
72
  values.map! do |ov|
73
73
  "#{ov.option_type.presentation}: #{ov.presentation}"
@@ -4,7 +4,7 @@
4
4
  :scope => 'spree.date_picker',
5
5
  :default => 'yy/mm/dd'),
6
6
  :abbr_day_names => I18n.t(:abbr_day_names, :scope => :date),
7
- :month_names => I18n.t(:month_names, :scope => :date).delete_if(&:blank?),
7
+ :month_names => I18n.t(:month_names, :scope => :date).reject(&:blank?),
8
8
  :previous => I18n.t(:previous),
9
9
  :next => I18n.t(:next),
10
10
  :no_results => I18n.t(:no_results),
@@ -1,7 +1,7 @@
1
1
  [<% @taxons.each_with_index do |t,i| %>
2
2
  { "attr" :
3
3
  { "id" : "<%= t.id %>" },
4
- "data" : "<%= escape_javascript(raw(t.name)) %>"
4
+ "data" : "<%= raw(t.name.gsub('"','\"')) %>"
5
5
  <% unless t.children.empty? %>
6
6
  ,"state" : "closed"
7
7
  <% end %>
@@ -76,7 +76,7 @@
76
76
  </td>
77
77
  <td data-hook="order_item_description">
78
78
  <h4><%= item.variant.product.name %></h4>
79
- <%= truncate(item.variant.product.description, :length => 100, :omission => "...") %>
79
+ <%= truncate(raw(item.variant.product.description), :length => 100, :omission => "...") %>
80
80
  <%= "(" + item.variant.options_text + ")" unless item.variant.option_values.empty? %>
81
81
  </td>
82
82
  <td data-hook="order_item_price" class="price"><span><%= money item.price %></span></td>
@@ -0,0 +1,5 @@
1
+ class AddIdentifierToSpreePayments < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_payments, :identifier, :string
4
+ end
5
+ end
@@ -164,8 +164,8 @@ module Spree
164
164
  locale = session[:locale]
165
165
  locale ||= Spree::Config[:default_locale] unless Spree::Config[:default_locale].blank?
166
166
  locale ||= Rails.application.config.i18n.default_locale
167
- locale ||= I18n.default_locale unless I18n.available_locales.include?(locale.to_sym)
168
- I18n.locale = locale.to_sym
167
+ locale ||= I18n.default_locale unless I18n.available_locales.map(&:to_s).include?(locale)
168
+ I18n.locale = locale
169
169
  end
170
170
 
171
171
  # Returns which layout to render.
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "1.2.3"
3
+ "1.2.4"
4
4
  end
5
5
  end
data/lib/tasks/core.rake CHANGED
@@ -3,13 +3,13 @@ require 'spree/core/custom_fixtures'
3
3
 
4
4
  namespace :db do
5
5
  desc %q{Loads a specified fixture file:
6
- For .yml/.csv use rake db:load_file[spree/filename.yml,/absolute/path/to/parent/]
6
+ For .yml use rake db:load_file[spree/filename.yml,/absolute/path/to/parent/]
7
7
  For .rb use rake db:load_file[/absolute/path/to/sample/filename.rb]}
8
8
 
9
9
  task :load_file , [:file, :dir] => :environment do |t, args|
10
10
  file = Pathname.new(args.file)
11
11
 
12
- if %w{.csv .yml}.include? file.extname
12
+ if %w{.yml}.include? file.extname
13
13
  puts "loading fixture #{Pathname.new(args.dir).join(file)}"
14
14
  Spree::Core::Fixtures.create_fixtures(args.dir, file.to_s.sub(file.extname, ""))
15
15
  elsif file.exist?
@@ -25,7 +25,7 @@ For .rb use rake db:load_file[/absolute/path/to/sample/filename.rb]}
25
25
 
26
26
  fixtures = ActiveSupport::OrderedHash.new
27
27
  ruby_files = ActiveSupport::OrderedHash.new
28
- Dir.glob(File.join(dir , '**/*.{yml,csv,rb}')).each do |fixture_file|
28
+ Dir.glob(File.join(dir , '**/*.{yml,rb}')).each do |fixture_file|
29
29
  ext = File.extname fixture_file
30
30
  if ext == ".rb"
31
31
  ruby_files[File.basename(fixture_file, '.*')] = fixture_file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-06 00:00:00.000000000 Z
12
+ date: 2013-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: acts_as_list
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: '2.0'
53
+ version: 2.1.4
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
61
+ version: 2.1.4
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: select2-rails
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: '3.0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: select2-rails
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '3.2'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '3.2'
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: highline
80
96
  requirement: !ruby/object:Gem::Requirement
@@ -194,7 +210,7 @@ dependencies:
194
210
  requirements:
195
211
  - - ~>
196
212
  - !ruby/object:Gem::Version
197
- version: 3.2.10
213
+ version: 3.2.11
198
214
  type: :runtime
199
215
  prerelease: false
200
216
  version_requirements: !ruby/object:Gem::Requirement
@@ -202,7 +218,7 @@ dependencies:
202
218
  requirements:
203
219
  - - ~>
204
220
  - !ruby/object:Gem::Version
205
- version: 3.2.10
221
+ version: 3.2.11
206
222
  - !ruby/object:Gem::Dependency
207
223
  name: kaminari
208
224
  requirement: !ruby/object:Gem::Requirement
@@ -1018,6 +1034,7 @@ files:
1018
1034
  - db/migrate/20121009142519_add_lock_version_to_variant.rb
1019
1035
  - db/migrate/20121017010007_remove_not_null_constraint_from_products_on_hand.rb
1020
1036
  - db/migrate/20121124203911_add_position_to_taxonomies.rb
1037
+ - db/migrate/20130203232234_add_identifier_to_spree_payments.rb
1021
1038
  - db/seeds.rb
1022
1039
  - vendor/assets/images/datepicker/cal.gif
1023
1040
  - vendor/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png
@@ -1118,7 +1135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1118
1135
  version: '0'
1119
1136
  segments:
1120
1137
  - 0
1121
- hash: 3458993315221565622
1138
+ hash: -97604365585348825
1122
1139
  requirements:
1123
1140
  - none
1124
1141
  rubyforge_project: spree_core