spree_core 2.2.5 → 2.2.6

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: 88ab16ad8f605d308074b823d9a7c70f6504bb08
4
- data.tar.gz: 6bcb7afca77e7006f6eb12e4ba1177b66bd3a585
3
+ metadata.gz: 04e5eefe3009befd78025ca57659db32bc2e50a3
4
+ data.tar.gz: f15a4fb3f353eb751af1989d90b3efead4115fbd
5
5
  SHA512:
6
- metadata.gz: 91fa2acf65367622c4d6d526beb7d696dad6b2a143ee03a376c4045741620840c60b01f749feb8e771ca9fd618695872b37498d08369c35052c6b1d10cc2c176
7
- data.tar.gz: 8e1596b38affe2af7d32a8dfefceea76e9626ad4b1540bf8ba3655d0d787fc6834544476ebfc0f7529413aac35ac132690574a6fbeb6afc83d333df7d7f253fa
6
+ metadata.gz: c5f0b142e192633ab15d86f362310bc9b6640b274f3da599e52ccf0440bf6434983c990adba8c2002d9b9b2415bcb01bb518c6da3bd267e800af093c16085eb4
7
+ data.tar.gz: e9fc9ce3dce676ea2c268012c0155fef5827ef8c17bcf868e3593ebb0f68b7c1a7959e97c625aff7cb041a83cbc1bbd3687dafd5d4c1bc42a6accc5846e587c8
@@ -20,8 +20,8 @@ module Spree
20
20
  end
21
21
 
22
22
  def self.default(user = nil, kind = "bill")
23
- if user
24
- user.send(:"#{kind}_address") || build_default
23
+ if user && user_address = user.send(:"#{kind}_address")
24
+ user_address.clone
25
25
  else
26
26
  build_default
27
27
  end
@@ -81,11 +81,17 @@ module Spree
81
81
  end
82
82
 
83
83
  def credit!(credit_amount=nil)
84
+ raise Core::GatewayError.new(Spree.t(:payment_processing_failed)) if processing?
85
+
86
+ # Calculate credit amount before marking as processing since it messes up the order totals not having payment in completed state.
87
+ credit_amount ||= credit_allowed >= order.outstanding_balance.abs ? order.outstanding_balance.abs : credit_allowed.abs
88
+ credit_amount = credit_amount.to_f
89
+
90
+ # Mark as processing to avoid race condition that could send multiple credits to the gateway.
91
+ started_processing!
84
92
  protect_from_connection_error do
85
93
  check_environment
86
94
 
87
- credit_amount ||= credit_allowed >= order.outstanding_balance.abs ? order.outstanding_balance.abs : credit_allowed.abs
88
- credit_amount = credit_amount.to_f
89
95
  credit_cents = Spree::Money.new(credit_amount, currency: currency).money.cents
90
96
 
91
97
  if payment_method.payment_profiles_supported?
@@ -95,6 +101,8 @@ module Spree
95
101
  end
96
102
 
97
103
  record_response(response)
104
+ # Always set back to 'completed' as initial payment record was successful.
105
+ self.update_column(:state, 'completed')
98
106
 
99
107
  if response.success?
100
108
  self.class.create!(
@@ -121,7 +129,6 @@ module Spree
121
129
 
122
130
  def partial_credit(amount)
123
131
  return if amount > credit_allowed
124
- started_processing!
125
132
  credit!(amount)
126
133
  end
127
134
 
@@ -0,0 +1,8 @@
1
+ class ChangeSpreePriceAmountPrecision < ActiveRecord::Migration
2
+ def change
3
+ change_column :spree_prices, :amount, :decimal, :precision => 10, :scale => 2
4
+ change_column :spree_line_items, :price, :decimal, :precision => 10, :scale => 2, :null => false
5
+ change_column :spree_line_items, :cost_price, :decimal, :precision => 10, :scale => 2
6
+ change_column :spree_variants, :cost_price, :decimal, :precision => 10, :scale => 2
7
+ end
8
+ end
@@ -1,29 +1,7 @@
1
- # Borrowed from http://my.rails-royce.org/2010/07/21/email-validation-in-ruby-on-rails-without-regexp/
2
- # Mentioned in tweet here: https://twitter.com/_sohara/status/177120126083141633
3
- require 'mail'
4
1
  class EmailValidator < ActiveModel::EachValidator
5
2
  def validate_each(record,attribute,value)
6
- unless valid?(value)
3
+ unless value =~ /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
7
4
  record.errors.add(attribute, :invalid, {:value => value}.merge!(options))
8
5
  end
9
6
  end
10
-
11
- def valid?(email)
12
- begin
13
- m = Mail::Address.new(email)
14
- # We must check that value contains a domain and that value is an email address
15
- r = m.domain && m.address == email
16
- t = m.__send__(:tree)
17
- # We need to dig into treetop
18
- # A valid domain must have dot_atom_text elements size > 1
19
- # user@localhost is excluded
20
- # treetop must respond to domain
21
- # We exclude valid email values like <user@localhost.com>
22
- # Hence we use m.__send__(tree).domain
23
- r &&= (t.domain.dot_atom_text.elements.size > 1)
24
- rescue Exception => e
25
- r = false
26
- end
27
- r
28
- end
29
7
  end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "2.2.5"
3
+ "2.2.6"
4
4
  end
5
5
  end
@@ -27,7 +27,7 @@ module Spree
27
27
  mattr_reader *ATTRIBUTES
28
28
 
29
29
  @@address_attributes = [
30
- :firstname, :lastname, :address1, :address2,
30
+ :id, :firstname, :lastname, :address1, :address2,
31
31
  :city, :country_id, :state_id, :zipcode, :phone,
32
32
  :state_name, :alternative_phone, :company,
33
33
  :country => [:iso, :name, :iso3, :iso_name],
@@ -13,7 +13,7 @@ module CapybaraExt
13
13
  end
14
14
 
15
15
  def within_row(num, &block)
16
- if example.metadata[:js]
16
+ if RSpec.current_example.metadata[:js]
17
17
  within("table.index tbody tr:nth-child(#{num})", &block)
18
18
  else
19
19
  within(:xpath, all("table.index tbody tr")[num-1].path, &block)
@@ -21,7 +21,7 @@ module CapybaraExt
21
21
  end
22
22
 
23
23
  def column_text(num)
24
- if example.metadata[:js]
24
+ if RSpec.current_example.metadata[:js]
25
25
  find("td:nth-child(#{num})").text
26
26
  else
27
27
  all("td")[num-1].text
@@ -143,7 +143,7 @@ RSpec::Matchers.define :have_meta do |name, expected|
143
143
  has_css?("meta[name='#{name}'][content='#{expected}']", visible: false)
144
144
  end
145
145
 
146
- failure_message_for_should do |actual|
146
+ failure_message do |actual|
147
147
  actual = first("meta[name='#{name}']")
148
148
  if actual
149
149
  "expected that meta #{name} would have content='#{expected}' but was '#{actual[:content]}'"
@@ -158,7 +158,7 @@ RSpec::Matchers.define :have_title do |expected|
158
158
  has_css?("title", :text => expected, visible: false)
159
159
  end
160
160
 
161
- failure_message_for_should do |actual|
161
+ failure_message do |actual|
162
162
  actual = first("title")
163
163
  if actual
164
164
  "expected that title would have been '#{expected}' but was '#{actual.text}'"
@@ -22,8 +22,8 @@ module Spree
22
22
  end
23
23
 
24
24
  def assert_preference_unset(preference)
25
- find("#preferences_#{preference}")['checked'].should be_false
26
- Spree::Config[preference].should be_false
25
+ find("#preferences_#{preference}")['checked'].should be false
26
+ Spree::Config[preference].should be false
27
27
  end
28
28
  end
29
29
  end
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.2.5
4
+ version: 2.2.6
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-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -604,6 +604,7 @@ files:
604
604
  - db/migrate/20140219060952_add_considered_risky_to_orders.rb
605
605
  - db/migrate/20140307235515_add_user_id_to_spree_credit_cards.rb
606
606
  - db/migrate/20140415041315_add_user_id_created_by_id_index_to_order.rb
607
+ - db/migrate/20140508151342_change_spree_price_amount_precision.rb
607
608
  - db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
608
609
  - db/migrate/20140609201656_add_deleted_at_to_spree_promotion_actions.rb
609
610
  - db/migrate/20140616202624_remove_uncaptured_amount_from_spree_payments.rb