workarea-core 3.5.18 → 3.5.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/workarea/current_tracking.rb +4 -2
- data/app/controllers/workarea/impersonation.rb +2 -1
- data/app/models/workarea/order/item.rb +4 -4
- data/app/models/workarea/search/admin/inventory_sku.rb +5 -1
- data/app/models/workarea/shipping/service.rb +12 -5
- data/config/initializers/00_configuration.rb +11 -0
- data/config/locales/en.yml +1 -0
- data/lib/workarea/version.rb +1 -1
- data/lib/workarea/visit.rb +8 -1
- data/test/integration/workarea/authentication_test.rb +2 -1
- data/test/models/workarea/order/item_test.rb +9 -0
- data/test/models/workarea/shipping/service_test.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a59bf88202898e6d59be0edbdb90c7000fe606fa3ab522aee27079288708e262
|
4
|
+
data.tar.gz: 76cb3fbfaf8847f50b296cb1790bc6997f9b79f304af9131854442ba779c465d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88354b9cb2e04bca758bfa1f1d089a979684a1e18bdb37c54d523ed622e47c7131f2cf4c41d4baa71d1bb712a888c7fb6b40d1c34cc6b972d4dde8c5c8fbe892
|
7
|
+
data.tar.gz: d6008ffbfc3f803061e92a43d1b598b3179c51ed2205175b63213fe66525a25c71ee2d53e5b87761d0c70f703c325654dc58499a5e8aa3a07100642388039f02
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Workarea
|
2
2
|
module CurrentTracking
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
include HttpCaching
|
5
4
|
|
6
5
|
included do
|
7
6
|
before_action :ensure_current_metrics
|
@@ -27,7 +26,10 @@ module Workarea
|
|
27
26
|
if email.blank?
|
28
27
|
cookies.delete(:email)
|
29
28
|
elsif email != cookies.signed[:email]
|
30
|
-
|
29
|
+
unless impersonating?
|
30
|
+
Metrics::User.find_or_initialize_by(id: email).merge!(current_visit&.metrics)
|
31
|
+
end
|
32
|
+
|
31
33
|
cookies.permanent.signed[:email] = email
|
32
34
|
end
|
33
35
|
|
@@ -15,10 +15,11 @@ module Workarea
|
|
15
15
|
session[:user_id] = user.id.to_s
|
16
16
|
|
17
17
|
user.mark_impersonated_by!(current_user)
|
18
|
-
|
18
|
+
update_tracking!(email: user.email)
|
19
19
|
end
|
20
20
|
|
21
21
|
def stop_impersonation
|
22
|
+
update_tracking!(email: current_admin.email)
|
22
23
|
session[:user_id] = current_admin.id.to_s
|
23
24
|
session.delete(:admin_id)
|
24
25
|
end
|
@@ -33,17 +33,17 @@ module Workarea
|
|
33
33
|
# To allow for custom policies defining their own methods here
|
34
34
|
Workarea.config.fulfillment_policies.each do |class_name|
|
35
35
|
define_method "#{class_name.demodulize.underscore}?" do
|
36
|
-
|
36
|
+
fulfilled_by?(class_name.demodulize.underscore)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
# These methods exist for findability
|
41
41
|
def shipping?
|
42
|
-
|
42
|
+
fulfilled_by?('shipping')
|
43
43
|
end
|
44
44
|
|
45
45
|
def download?
|
46
|
-
|
46
|
+
fulfilled_by?('download')
|
47
47
|
end
|
48
48
|
|
49
49
|
# Whether this order has any items that need to be fulfilled by a particular
|
@@ -53,7 +53,7 @@ module Workarea
|
|
53
53
|
# @return [Boolean]
|
54
54
|
#
|
55
55
|
def fulfilled_by?(*types)
|
56
|
-
types.
|
56
|
+
types.map(&:to_s).include?(fulfillment)
|
57
57
|
end
|
58
58
|
|
59
59
|
# Whether this item is a digital (not-shipped) type of item.
|
@@ -37,15 +37,22 @@ module Workarea
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.by_price(price)
|
40
|
-
cache.select do |
|
41
|
-
(
|
42
|
-
(
|
40
|
+
cache.select do |service|
|
41
|
+
(service.subtotal_min.nil? || service.subtotal_min <= price) &&
|
42
|
+
(service.subtotal_max.nil? || service.subtotal_max >= price)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
def self.find_tax_code(carrier, name)
|
47
|
-
|
48
|
-
|
47
|
+
service = find_by(carrier: carrier, name: name) rescue nil
|
48
|
+
service.present? ? service.tax_code : default_tax_code(carrier, name)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.default_tax_code(carrier, name)
|
52
|
+
default = Workarea.config.default_shipping_service_tax_code
|
53
|
+
return default unless default.respond_to?(:call)
|
54
|
+
|
55
|
+
default.call(carrier, name)
|
49
56
|
end
|
50
57
|
|
51
58
|
def find_rate(price = 0.to_m)
|
@@ -76,6 +76,17 @@ Workarea::Configuration.define_fields do
|
|
76
76
|
zip: '19106'
|
77
77
|
},
|
78
78
|
description: 'Origin location for calculating shipping costs'
|
79
|
+
|
80
|
+
# This can be overwritten within the app to use a proc for more complex
|
81
|
+
# scenarios.
|
82
|
+
field 'Default Shipping Service Tax Code',
|
83
|
+
type: String,
|
84
|
+
allow_blank: true,
|
85
|
+
description: %(
|
86
|
+
Tax code assigned to shipping options when an existing service does
|
87
|
+
not exist. This is useful for third-party gateways to assign tax codes
|
88
|
+
to dynamically generated options.
|
89
|
+
).squish
|
79
90
|
end
|
80
91
|
|
81
92
|
fieldset 'Payment', namespaced: false do
|
data/config/locales/en.yml
CHANGED
data/lib/workarea/version.rb
CHANGED
data/lib/workarea/visit.rb
CHANGED
@@ -6,7 +6,6 @@ module Workarea
|
|
6
6
|
attr_writer :override_segments
|
7
7
|
|
8
8
|
delegate :postal_code, :city, :subdivision, :region, :country, to: :geolocation
|
9
|
-
delegate :admin?, to: :metrics
|
10
9
|
|
11
10
|
def initialize(env)
|
12
11
|
@env = env
|
@@ -25,6 +24,14 @@ module Workarea
|
|
25
24
|
session[:user_id].present?
|
26
25
|
end
|
27
26
|
|
27
|
+
def impersonating?
|
28
|
+
session[:admin_id].present?
|
29
|
+
end
|
30
|
+
|
31
|
+
def admin?
|
32
|
+
(logged_in? && impersonating?) || metrics.admin?
|
33
|
+
end
|
34
|
+
|
28
35
|
def request
|
29
36
|
@request ||= ActionDispatch::Request.new(env)
|
30
37
|
end
|
@@ -3,8 +3,9 @@ require 'test_helper'
|
|
3
3
|
module Workarea
|
4
4
|
class AuthenticationTest < IntegrationTest
|
5
5
|
class AuthenticationController < Workarea::ApplicationController
|
6
|
-
include Authentication
|
7
6
|
include HttpCaching
|
7
|
+
include Authentication
|
8
|
+
include Impersonation
|
8
9
|
include Storefront::CurrentCheckout
|
9
10
|
|
10
11
|
before_action :cache_page, only: :cached
|
@@ -55,6 +55,15 @@ module Workarea
|
|
55
55
|
)
|
56
56
|
assert(item.on_sale?)
|
57
57
|
end
|
58
|
+
|
59
|
+
def test_fulfilled_by?
|
60
|
+
item.fulfillment = 'shipping'
|
61
|
+
assert(item.fulfilled_by?(:shipping))
|
62
|
+
assert(item.fulfilled_by?(:shipping, :download))
|
63
|
+
refute(item.fulfilled_by?(:download))
|
64
|
+
assert(item.shipping?)
|
65
|
+
refute(item.download?)
|
66
|
+
end
|
58
67
|
end
|
59
68
|
end
|
60
69
|
end
|
@@ -35,6 +35,32 @@ module Workarea
|
|
35
35
|
assert_equal(3.to_m, shipping_service.find_rate(7.to_m).price)
|
36
36
|
assert_equal(2.to_m, shipping_service.find_rate(10.to_m).price)
|
37
37
|
end
|
38
|
+
|
39
|
+
def test_find_tax_code
|
40
|
+
create_shipping_service(name: 'Ground', carrier: 'UPS', tax_code: '001')
|
41
|
+
create_shipping_service(name: 'Express', carrier: 'UPS', tax_code: nil)
|
42
|
+
Workarea.config.default_shipping_service_tax_code = nil
|
43
|
+
|
44
|
+
assert_equal('001', Service.find_tax_code('UPS', 'Ground'))
|
45
|
+
assert_nil(Service.find_tax_code('UPS', 'Express'))
|
46
|
+
assert_nil(Service.find_tax_code('FedEx', 'Express'))
|
47
|
+
|
48
|
+
Workarea.config.default_shipping_service_tax_code = '101'
|
49
|
+
|
50
|
+
assert_equal('001', Service.find_tax_code('UPS', 'Ground'))
|
51
|
+
assert_nil(Service.find_tax_code('UPS', 'Express'))
|
52
|
+
assert_equal('101', Service.find_tax_code('FedEx', 'Express'))
|
53
|
+
assert_equal('101', Service.find_tax_code('FedEx', 'Express'))
|
54
|
+
|
55
|
+
Workarea.config.default_shipping_service_tax_code = -> (carrier, name) do
|
56
|
+
carrier == 'FedEx' ? '101' : '001'
|
57
|
+
end
|
58
|
+
|
59
|
+
assert_equal('001', Service.find_tax_code('UPS', 'Ground'))
|
60
|
+
assert_nil(Service.find_tax_code('UPS', 'Express'))
|
61
|
+
assert_equal('101', Service.find_tax_code('FedEx', 'Express'))
|
62
|
+
assert_equal('001', Service.find_tax_code('DHL', 'Overnight'))
|
63
|
+
end
|
38
64
|
end
|
39
65
|
end
|
40
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workarea-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Crouse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|