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 +4 -4
- data/app/models/effective/order.rb +29 -16
- data/lib/effective_orders/version.rb +1 -1
- data/spec/dummy/config/environments/production.rb +0 -3
- data/spec/dummy/config/environments/test.rb +0 -4
- data/spec/dummy/log/test.log +48 -0
- data/spec/models/factories_spec.rb +16 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 101d33deb56c39e2cb0805f69c46cdae7b11df2f
|
4
|
+
data.tar.gz: 164d3ac6fcef01e5c36fecafa3758df40791cf7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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) &&
|
104
|
+
if user.respond_to?(:shipping_address) && !user.shipping_address.nil?
|
105
105
|
self.shipping_address = user.shipping_address
|
106
|
-
|
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
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
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
|
@@ -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
|
data/spec/dummy/log/test.log
CHANGED
@@ -122,3 +122,51 @@
|
|
122
122
|
[1m[36m (0.1ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
123
123
|
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
124
124
|
[1m[36m (0.1ms)[0m [1mSELECT MAX("orders"."id") AS max_id FROM "orders"[0m
|
125
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
126
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
127
|
+
[1m[36m (0.5ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
128
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
129
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
130
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
131
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
132
|
+
[1m[36m (0.5ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
133
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
134
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
135
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
136
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
137
|
+
[1m[36m (0.4ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
138
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
139
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
140
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
141
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
142
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
143
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
144
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
145
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
146
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
147
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
148
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
149
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
150
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
151
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
152
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
153
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
154
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
155
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
156
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
157
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
158
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
159
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
160
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
161
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
162
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
163
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
164
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
165
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
166
|
+
[1m[36m (0.3ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
167
|
+
[1m[36m (0.4ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
168
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
169
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
170
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
171
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
172
|
+
[1m[36m (0.2ms)[0m [1mSELECT MAX("orders"."id") FROM "orders"[0m
|
@@ -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.
|
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-
|
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
|
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
|
124
|
+
version: 1.1.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: effective_obfuscation
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|