workarea-core 3.4.34 → 3.4.39

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
  SHA256:
3
- metadata.gz: 314c6ea37c26a932c59db1704e58543674eaf44df1751825d2141a7466c9069a
4
- data.tar.gz: fc6e14cb1bb9c8cfc0d4d2c884847b30bba2c7a9bb62cbc15b722abbb71f90e8
3
+ metadata.gz: ae6526862e8c543160a1df0f1ee154cf6de027b87fa2222910e86f13b826e6a5
4
+ data.tar.gz: fe422c3b67acfc7befdccba7de26c314cd23e40e93e51f3968a2f1a59922e0f1
5
5
  SHA512:
6
- metadata.gz: 4970592a6e9a7bfee84f97b2bd5f9a3ad8d361f76af3c7ba537d870bb23f714e1aff417c6ed1e2694d65b0b0be993753fce7a34b9f18557900ece6dcfa90f9b6
7
- data.tar.gz: 05cf391954ee8613ff48071f7f66ea68178e78f07b41a91ab545de6ed22f53feb721d11f56014aa21dd3e0d365c5aafc1839b142cbeaaa4f4a65a4d787a5a025
6
+ metadata.gz: a1f096e09ee3909187463dec66d4b023afe2b2396ecfad07e005069b4fb1ae3ca43e2ab5b3b42bff01ee1f96cc794665ad359900d0cb82f0b1cac7df9ea7acf3
7
+ data.tar.gz: f04a5d34dcb94969890639267860780c5620ffc2190f0ec0427ae65115e20c675ead70895dd9961aa31f0ea99bc18a612e2aa7d16c18b40f9f75c3823a43264e
@@ -50,7 +50,8 @@ module Workarea
50
50
  end
51
51
 
52
52
  def current_impersonation
53
- @current_impersonation ||= User.find(cookies.signed[:user_id])
53
+ return @current_impersonation if defined?(@current_impersonation)
54
+ @current_impersonation = User.find(cookies.signed[:user_id]) rescue nil
54
55
  end
55
56
 
56
57
  def touch_impersonation
@@ -7,7 +7,10 @@ module Workarea
7
7
  default from: -> (*) { Workarea.config.email_from }
8
8
 
9
9
  def default_url_options(options = {})
10
- super.merge(host: Workarea.config.host)
10
+ # super isn't returning the configured options, so manually merge them in
11
+ super
12
+ .merge(Rails.application.config.action_mailer.default_url_options.to_h)
13
+ .merge(host: Workarea.config.host)
11
14
  end
12
15
  end
13
16
  end
@@ -158,10 +158,14 @@ module Workarea
158
158
  # Used in auto completing an order for a logged in user.
159
159
  #
160
160
  # @param [Hash] parameters for updating
161
- # @return [self]
161
+ # @return [Boolean] whether the update was successful.
162
162
  #
163
163
  def update(params = {})
164
- steps.each { |s| s.new(self).update(params) }
164
+ return true if params.blank?
165
+
166
+ steps.reduce(true) do |result, step|
167
+ result &= step.new(self).update(params)
168
+ end
165
169
  end
166
170
 
167
171
  # Whether this checkout needs any further information
@@ -15,7 +15,8 @@ module Workarea
15
15
  validate :subject_exists
16
16
 
17
17
  def full_subject
18
- Workarea.config.inquiry_subjects[subject]
18
+ I18n.t('workarea.inquiry.subjects')[subject.optionize.to_sym].presence ||
19
+ Workarea.config.inquiry_subjects[subject]
19
20
  end
20
21
 
21
22
  private
@@ -80,12 +80,7 @@ module Workarea
80
80
  build_credit_card unless credit_card
81
81
  credit_card.saved_card_id = nil
82
82
  credit_card.attributes = attrs.slice(
83
- :month,
84
- :year,
85
- :saved_card_id,
86
- :number,
87
- :cvv,
88
- :amount
83
+ *Workarea.config.credit_card_attributes
89
84
  )
90
85
  save
91
86
  end
@@ -11,6 +11,10 @@ module Workarea
11
11
  def self.available_sorts
12
12
  AdminSorting.available_sorts
13
13
  end
14
+
15
+ def default_admin_sort
16
+ [{ _score: :desc }, { updated_at: :desc }]
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -16,7 +16,7 @@ module Workarea
16
16
  end
17
17
 
18
18
  def default_admin_sort
19
- [{ _score: :desc }, { updated_at: :desc }]
19
+ [{ updated_at: :desc }, { _score: :desc }]
20
20
  end
21
21
 
22
22
  def user_selected_sort
@@ -97,6 +97,8 @@ en:
97
97
  under: 'Under %{price}'
98
98
  inventory_sku:
99
99
  name: "Inventory %{id}"
100
+ inquiry:
101
+ subjects: {}
100
102
  order:
101
103
  name: "Order %{id}"
102
104
  traffic_referrer:
@@ -63,6 +63,19 @@ module Workarea
63
63
  remove_file 'public/favicon.ico'
64
64
  end
65
65
 
66
+ def add_development_mailer_port
67
+ development_port = <<-CODE
68
+
69
+ config.action_mailer.default_url_options = { port: 3000 }
70
+ CODE
71
+
72
+ inject_into_file(
73
+ 'config/environments/development.rb',
74
+ development_port,
75
+ before: /^end/
76
+ )
77
+ end
78
+
66
79
  private
67
80
 
68
81
  def app_name
@@ -4,7 +4,7 @@ Workarea.configure do |config|
4
4
 
5
5
  config.host = {
6
6
  'test' => 'www.example.com',
7
- 'development' => 'localhost:3000',
7
+ 'development' => 'localhost',
8
8
  'production' => 'www.<%= app_name.dasherize %>.com' # TODO
9
9
  }[Rails.env]
10
10
 
@@ -1289,6 +1289,17 @@ module Workarea
1289
1289
 
1290
1290
  # The number of results that will show per-type in the admin jump to
1291
1291
  config.jump_to_results_per_type = 5
1292
+
1293
+ # Attributes that will be sliced out of params and persisted on
1294
+ # the credit card tender during checkout.
1295
+ config.credit_card_attributes = %i[
1296
+ month
1297
+ year
1298
+ saved_card_id
1299
+ number
1300
+ cvv
1301
+ amount
1302
+ ]
1292
1303
  end
1293
1304
  end
1294
1305
  end
@@ -139,6 +139,7 @@ require 'workarea/ext/mongoid/audit_log_entry.decorator'
139
139
  require 'workarea/ext/mongoid/find_ordered'
140
140
  require 'workarea/ext/sprockets/ruby_processor'
141
141
  require 'workarea/ext/jbuilder/jbuilder_append_partials'
142
+ require 'workarea/ext/jbuilder/jbuilder_cache'
142
143
 
143
144
  if Rails.env.development?
144
145
  require 'workarea/ext/freedom_patches/routes_reloader'
@@ -0,0 +1,29 @@
1
+ decorate JbuilderTemplate, with: :workarea do
2
+ def _cache_fragment_for(*)
3
+ return yield if workarea_admin?
4
+
5
+ super
6
+ end
7
+
8
+ def _cache_key(*)
9
+ super.tap do |result|
10
+ result << workarea_cache_varies if workarea_cache_varies.present?
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def workarea_admin?
17
+ @context&.controller&.current_user&.admin?
18
+ rescue ::RuntimeError
19
+ false
20
+ end
21
+
22
+ def workarea_cache_varies
23
+ workarea_request_env['workarea.cache_varies']
24
+ end
25
+
26
+ def workarea_request_env
27
+ @context.controller.request.env || {}
28
+ end
29
+ end
@@ -2,7 +2,7 @@ module Workarea
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 4
5
- PATCH = 34
5
+ PATCH = 39
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
@@ -88,5 +88,11 @@ module Workarea
88
88
  def test_favicon
89
89
  assert_no_file 'public/favicon.ico'
90
90
  end
91
+
92
+ def test_development_mailer_port
93
+ assert_file 'config/environments/development.rb' do |file|
94
+ assert_match(%(config.action_mailer.default_url_options = { port: 3000 }), file)
95
+ end
96
+ end
91
97
  end
92
98
  end
@@ -21,5 +21,15 @@ module Workarea
21
21
  assert_equal([changed_email], changed_mail.from)
22
22
  end
23
23
  end
24
+
25
+ def test_default_url_options
26
+ @current_options = Rails.application.config.action_mailer.default_url_options.deep_dup
27
+ Rails.application.config.action_mailer.default_url_options = { port: 12345 }
28
+
29
+ assert_equal(12345, ApplicationMailer.new.default_url_options[:port])
30
+
31
+ ensure
32
+ Rails.application.config.action_mailer.default_url_options = @current_options
33
+ end
24
34
  end
25
35
  end
@@ -51,6 +51,63 @@ module Workarea
51
51
  refute_equal(payment_id, checkout.payment.object_id)
52
52
  end
53
53
 
54
+ def test_update
55
+ create_shipping_service
56
+ checkout = Checkout.new(@order)
57
+
58
+ checkout.start_as(:guest)
59
+
60
+ refute(
61
+ checkout.update(
62
+ email: 'test@workarea.com',
63
+ shipping_address: {
64
+ last_name: 'Crouse',
65
+ street: '22 S. 3rd St.',
66
+ street_2: 'Second Floor',
67
+ city: 'Philadelphia',
68
+ region: 'PA',
69
+ postal_code: '19106',
70
+ country: 'US'
71
+ },
72
+ billing_address: {
73
+ first_name: 'Ben',
74
+ street: '22 S. 3rd St.',
75
+ street_2: 'Second Floor',
76
+ city: 'Philadelphia',
77
+ region: 'PA',
78
+ postal_code: '19106',
79
+ country: 'US'
80
+ }
81
+ )
82
+ )
83
+
84
+ assert(
85
+ checkout.update(
86
+ email: 'test@workarea.com',
87
+ shipping_address: {
88
+ first_name: 'Ben',
89
+ last_name: 'Crouse',
90
+ street: '22 S. 3rd St.',
91
+ street_2: 'Second Floor',
92
+ city: 'Philadelphia',
93
+ region: 'PA',
94
+ postal_code: '19106',
95
+ country: 'US'
96
+ },
97
+ billing_address: {
98
+ first_name: 'Ben',
99
+ last_name: 'Crouse',
100
+ street: '22 S. 3rd St.',
101
+ street_2: 'Second Floor',
102
+ city: 'Philadelphia',
103
+ region: 'PA',
104
+ postal_code: '19106',
105
+ country: 'US'
106
+ }
107
+ )
108
+ )
109
+ end
110
+
54
111
  def test_continue_as
55
112
  checkout = Checkout.new(@order)
56
113
  checkout.continue_as(@user)
@@ -81,6 +81,16 @@ module Workarea
81
81
  assert_equal(results.reverse, search.results)
82
82
  end
83
83
 
84
+ def test_default_sort_by_score
85
+ # Unlike other admin searches (primarily indexes), we want searching to
86
+ # default sort by score. Testing scores directly is unreliable so just
87
+ # do a simple check here.
88
+ assert_equal(
89
+ [{ _score: :desc }, { updated_at: :desc }],
90
+ AdminSearch.new.default_admin_sort
91
+ )
92
+ end
93
+
84
94
  def test_selected_sorting
85
95
  results = [
86
96
  create_product(name: 'A', variants: []),
@@ -90,9 +90,9 @@ Gem::Specification.new do |s|
90
90
  s.add_dependency 'referer-parser', '~> 0.3.0'
91
91
  s.add_dependency 'serviceworker-rails', '~> 0.5.5'
92
92
  s.add_dependency 'logstasher', '~> 1.2.2'
93
- s.add_dependency 'chartkick', '~> 3.3.0'
93
+ s.add_dependency 'chartkick', '~> 3.4.0'
94
94
  s.add_dependency 'puma', '>= 4.3.1'
95
- s.add_dependency 'rack' , '>= 2.0.8'
95
+ s.add_dependency 'rack' , '>= 2.1.4'
96
96
 
97
97
  # HACK for vendoring active_shipping
98
98
  s.add_dependency 'active_utils', '~> 3.3.1'
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.4.34
4
+ version: 3.4.39
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-06-11 00:00:00.000000000 Z
11
+ date: 2020-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -1086,14 +1086,14 @@ dependencies:
1086
1086
  requirements:
1087
1087
  - - "~>"
1088
1088
  - !ruby/object:Gem::Version
1089
- version: 3.3.0
1089
+ version: 3.4.0
1090
1090
  type: :runtime
1091
1091
  prerelease: false
1092
1092
  version_requirements: !ruby/object:Gem::Requirement
1093
1093
  requirements:
1094
1094
  - - "~>"
1095
1095
  - !ruby/object:Gem::Version
1096
- version: 3.3.0
1096
+ version: 3.4.0
1097
1097
  - !ruby/object:Gem::Dependency
1098
1098
  name: puma
1099
1099
  requirement: !ruby/object:Gem::Requirement
@@ -1114,14 +1114,14 @@ dependencies:
1114
1114
  requirements:
1115
1115
  - - ">="
1116
1116
  - !ruby/object:Gem::Version
1117
- version: 2.0.8
1117
+ version: 2.1.4
1118
1118
  type: :runtime
1119
1119
  prerelease: false
1120
1120
  version_requirements: !ruby/object:Gem::Requirement
1121
1121
  requirements:
1122
1122
  - - ">="
1123
1123
  - !ruby/object:Gem::Version
1124
- version: 2.0.8
1124
+ version: 2.1.4
1125
1125
  - !ruby/object:Gem::Dependency
1126
1126
  name: active_utils
1127
1127
  requirement: !ruby/object:Gem::Requirement
@@ -1864,6 +1864,7 @@ files:
1864
1864
  - lib/workarea/ext/freedom_patches/string.rb
1865
1865
  - lib/workarea/ext/freedom_patches/uri.rb
1866
1866
  - lib/workarea/ext/jbuilder/jbuilder_append_partials.rb
1867
+ - lib/workarea/ext/jbuilder/jbuilder_cache.rb
1867
1868
  - lib/workarea/ext/mongoid/audit_log_entry.decorator
1868
1869
  - lib/workarea/ext/mongoid/each_by.rb
1869
1870
  - lib/workarea/ext/mongoid/error.rb