effective_orders 1.2.12 → 1.2.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: 6171edb7decb2419e845db8af7b83851a284a8f8
4
- data.tar.gz: 2d4a15554d343111758486fc031159b8e2c83ff0
3
+ metadata.gz: 101d33deb56c39e2cb0805f69c46cdae7b11df2f
4
+ data.tar.gz: 164d3ac6fcef01e5c36fecafa3758df40791cf7b
5
5
  SHA512:
6
- metadata.gz: 877e43822891f56644670344377ed7fa76e45fcf3b9bccab2e4170bbf814b971929e30c3fba978cca691d77236530c388fd880220df520bbc4c075e4b4d0634c
7
- data.tar.gz: 306ce59d6f08dd5d8cd5faf3d765709c1ddd094d7b54d40965ea734da4561e509e1248d333e0e3f06074faa29655d57a32e1998ce6949d6c0219466e47498c69
6
+ metadata.gz: 8b53c1a55398129ef3d432b424735c368950f470984423cf1da2ff2201d2e64585c4d172105e726fc52fa10d65332a9604c0a82bd1d213b94b603e519baa25f0
7
+ data.tar.gz: 44699ee1eb34067dc7b3ace224c31ded9faa93351e1f96a19faf073af2c2eab36890d72c460861a3f57a4e8df382c5737eaf127ad3730454973da476b963aae6
@@ -6,7 +6,7 @@ module Effective
6
6
  acts_as_obfuscated :format => '###-####-###'
7
7
  end
8
8
 
9
- acts_as_addressable :billing => {:presence => EffectiveOrders.require_billing_address, :use_full_name => true}, :shipping => {:presence => EffectiveOrders.require_shipping_address, :use_full_name => true}
9
+ acts_as_addressable :billing => {:singular => true, :presence => EffectiveOrders.require_billing_address, :use_full_name => true}, :shipping => {:singular => true, :presence => EffectiveOrders.require_shipping_address, :use_full_name => true}
10
10
  attr_accessor :save_billing_address, :save_shipping_address, :shipping_address_same_as_billing # save these addresses to the user if selected
11
11
 
12
12
  belongs_to :user # This is the user who purchased the order
@@ -96,14 +96,31 @@ module Effective
96
96
  def user=(user)
97
97
  super
98
98
 
99
- if user.respond_to?(:billing_address) && (billing_address.blank? || billing_address.empty?)
99
+ # Copy user addresses into this order if they are present
100
+ if user.respond_to?(:billing_address) && !user.billing_address.nil?
100
101
  self.billing_address = user.billing_address
101
- self.billing_address.full_name = billing_name if billing_address.present? && billing_address.full_name.blank?
102
102
  end
103
103
 
104
- if user.respond_to?(:shipping_address) && (shipping_address.blank? || shipping_address.empty?)
104
+ if user.respond_to?(:shipping_address) && !user.shipping_address.nil?
105
105
  self.shipping_address = user.shipping_address
106
- self.shipping_address.full_name = billing_name if shipping_address.present? &&shipping_address.full_name.blank?
106
+ end
107
+
108
+ # If our addresses are required, make sure they exist
109
+ if EffectiveOrders.require_billing_address
110
+ self.billing_address ||= Effective::Address.new()
111
+ end
112
+
113
+ if EffectiveOrders.require_shipping_address
114
+ self.shipping_address ||= Effective::Address.new()
115
+ end
116
+
117
+ # Ensure the Full Name is assigned when an address exists
118
+ if billing_address.nil? == false && billing_address.full_name.blank?
119
+ self.billing_address.full_name = billing_name
120
+ end
121
+
122
+ if shipping_address.nil? == false && shipping_address.full_name.blank?
123
+ self.shipping_address.full_name = billing_name
107
124
  end
108
125
  end
109
126
 
@@ -165,17 +182,13 @@ module Effective
165
182
  end
166
183
 
167
184
  def billing_name
168
- if billing_address.try(:full_name).present?
169
- billing_address.full_name
170
- elsif user.respond_to?(:full_name)
171
- user.full_name.to_s
172
- elsif user.respond_to?(:first_name) && user.respond_to?(:last_name)
173
- user.first_name.to_s + ' ' + user.last_name.to_s
174
- elsif user.to_s.start_with?('#<User:') == false
175
- user.to_s
176
- else
177
- ''
178
- end
185
+ name ||= billing_address.try(:full_name).presence
186
+ name ||= user.try(:full_name).presence
187
+ name ||= (user.try(:first_name).to_s + ' ' + user.try(:last_name).to_s).presence
188
+ name ||= user.try(:email).presence
189
+ name ||= user.to_s
190
+ name ||= "User #{user.try(:id)}"
191
+ name
179
192
  end
180
193
 
181
194
  # :validate => false, :email => false
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '1.2.12'.freeze
2
+ VERSION = '1.2.13'.freeze
3
3
  end
@@ -19,9 +19,6 @@ Rails.application.configure do
19
19
  # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
20
  # config.action_dispatch.rack_cache = true
21
21
 
22
- # Disable Rails's static asset server (Apache or nginx will already do this).
23
- config.serve_static_assets = false
24
-
25
22
  # Compress JavaScripts and CSS.
26
23
  config.assets.js_compressor = :uglifier
27
24
  # config.assets.css_compressor = :sass
@@ -12,10 +12,6 @@ Rails.application.configure do
12
12
  # preloads Rails for running tests, you may have to set it to true.
13
13
  config.eager_load = false
14
14
 
15
- # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
17
- config.static_cache_control = 'public, max-age=3600'
18
-
19
15
  # Show full error reports and disable caching.
20
16
  config.consider_all_requests_local = true
21
17
  config.action_controller.perform_caching = false
@@ -122,3 +122,51 @@
122
122
   (0.1ms) SELECT MAX("orders"."id") AS max_id FROM "orders"
123
123
   (0.3ms) SELECT MAX("orders"."id") AS max_id FROM "orders"
124
124
   (0.1ms) SELECT MAX("orders"."id") AS max_id FROM "orders"
125
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
126
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
127
+  (0.5ms) SELECT MAX("orders"."id") FROM "orders"
128
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
129
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
130
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
131
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
132
+  (0.5ms) SELECT MAX("orders"."id") FROM "orders"
133
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
134
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
135
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
136
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
137
+  (0.4ms) SELECT MAX("orders"."id") FROM "orders"
138
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
139
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
140
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
141
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
142
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
143
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
144
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
145
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
146
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
147
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
148
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
149
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
150
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
151
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
152
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
153
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
154
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
155
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
156
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
157
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
158
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
159
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
160
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
161
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
162
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
163
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
164
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
165
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
166
+  (0.3ms) SELECT MAX("orders"."id") FROM "orders"
167
+  (0.4ms) SELECT MAX("orders"."id") FROM "orders"
168
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
169
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
170
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
171
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
172
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
@@ -10,4 +10,20 @@ describe 'Factories' do
10
10
  it 'should have all valid factories' do
11
11
  factories.each { |factory| FactoryGirl.create(factory).valid?.should eq true }
12
12
  end
13
+
14
+ it 'should have created an Order with a billing_address and shipping_address' do
15
+ order = FactoryGirl.create(:order)
16
+
17
+ order.billing_address.present?.should eq true
18
+ order.shipping_address.present?.should eq true
19
+
20
+ order.billing_address.valid?.should eq true
21
+ order.shipping_address.valid?.should eq true
22
+
23
+ order.billing_address.full_name.present?.should eq true
24
+ order.shipping_address.full_name.present?.should eq true
25
+
26
+ order.save.should eq true
27
+ end
28
+
13
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.12
4
+ version: 1.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-19 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 1.0.3
117
+ version: 1.1.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 1.0.3
124
+ version: 1.1.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: effective_obfuscation
127
127
  requirement: !ruby/object:Gem::Requirement