workarea-core 3.4.37 → 3.4.42

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: b92c8bfc7ed302168dc43867258156fc8022d861c8888d267509f06397be80a5
4
- data.tar.gz: 48aaafb4e4ce343b8c5f86014531a86392d29a13042f8daf291d7be116fe27f1
3
+ metadata.gz: fb1a7c0e5cf9108b58d636eca7349f0ec61c1c24b91e3356d6978a70048fb745
4
+ data.tar.gz: 46609e92ace1945db58648ce33306fb2000532d9b1867bbf1a8530484e2a2ba0
5
5
  SHA512:
6
- metadata.gz: 359c095f749b941148ef804d7534010a1e2b489e9dd3a6aef49c5ecffb59ac6a9c5cc9afa212b076bd21a40c64ff614414e812f9a432d9d0f6306fbd060b19a2
7
- data.tar.gz: 1b8ac9254951ed01039219df5548b13655441785f99a3e119625b9964e5eeb6a5fde8772dd45d206a29f0b605416f78d6dbcbd745356327276086619701ce0fa
6
+ metadata.gz: 4320bf6ca0537e6aa5e5ca6c3c5afd68cd269579fc38f8acff6d669064c8d8aaf37b2afadc160edf8c55fb4857834cb9d9a38a1a6e9fdb9e2f36bae62781d286
7
+ data.tar.gz: 353ee66c41b45fe5695a19c444fb8f21e4c35140cdfa804f03b8da50bb6cd2e6e70d05e1ee06b61cc4577c666d68dca09f4e58915a04b1974f7b916eacc531b0
@@ -9,6 +9,7 @@ module Workarea
9
9
  @current_referrer ||= TrafficReferrer.new(
10
10
  RefererParser::Parser.new.parse(referrer).slice(:source, :medium, :uri)
11
11
  )
12
+ rescue RefererParser::InvalidUriError
12
13
  end
13
14
  end
14
15
  end
@@ -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
@@ -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
 
@@ -140,6 +140,7 @@ require 'workarea/ext/mongoid/find_ordered'
140
140
  require 'workarea/ext/sprockets/ruby_processor'
141
141
  require 'workarea/ext/jbuilder/jbuilder_append_partials'
142
142
  require 'workarea/ext/jbuilder/jbuilder_cache'
143
+ require 'workarea/ext/referer_parser/parser.decorator'
143
144
 
144
145
  if Rails.env.development?
145
146
  require 'workarea/ext/freedom_patches/routes_reloader'
@@ -0,0 +1,43 @@
1
+ module RefererParser
2
+ # This code is actually in `master` branch of
3
+ # https://github.com/snowplow-referer-parser/ruby-referer-parser but
4
+ # has not yet been released. It's used to allow through android-app://
5
+ # URLs.
6
+ decorate Parser do
7
+ # Given a string or URI, return a hash of data
8
+ def parse(obj)
9
+ url = obj.is_a?(URI) ? obj : URI.parse(obj.to_s)
10
+
11
+ unless ['android-app', 'http', 'https'].include?(url.scheme)
12
+ raise InvalidUriError, "Only Android-App, HTTP, and HTTPS schemes are supported -- #{url.scheme}"
13
+ end
14
+
15
+ data = { known: false, uri: url.to_s }
16
+
17
+ domain, name_key = domain_and_name_key_for(url)
18
+ if domain && name_key
19
+ referer_data = @name_hash[name_key]
20
+ data[:known] = true
21
+ data[:source] = referer_data[:source]
22
+ data[:medium] = referer_data[:medium]
23
+ data[:domain] = domain
24
+
25
+ # Parse parameters if the referer uses them
26
+ if url.query && referer_data[:parameters]
27
+ query_params = CGI.parse(url.query)
28
+ referer_data[:parameters].each do |param|
29
+ # If there is a matching parameter, get the first non-blank value
30
+ unless (values = query_params[param]).empty?
31
+ data[:term] = values.reject { |v| v.strip == '' }.first
32
+ break if data[:term]
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ data
39
+ rescue URI::InvalidURIError
40
+ raise InvalidUriError.new("Unable to parse URI, not a URI? -- #{obj.inspect}", $ERROR_INFO)
41
+ end
42
+ end
43
+ end
@@ -2,7 +2,7 @@ module Workarea
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 4
5
- PATCH = 37
5
+ PATCH = 42
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
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ module RefererParser
4
+ class ParserTest < Workarea::TestCase
5
+ def test_parse_android_app_referrers
6
+ referrers = [
7
+ 'android-app://com.linkedin.android',
8
+ 'android-app://org.telegram.plus',
9
+ 'android-app://com.twitter.android'
10
+ ]
11
+
12
+ referrers.each do |uri|
13
+ referrer = Parser.new.parse(uri)
14
+
15
+ refute(referrer[:known])
16
+ assert_equal(uri, referrer[:uri])
17
+ end
18
+ end
19
+ end
20
+ 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,7 +90,7 @@ 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
95
  s.add_dependency 'rack' , '>= 2.1.4'
96
96
 
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.37
4
+ version: 3.4.42
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-07-22 00:00:00.000000000 Z
11
+ date: 2020-10-14 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
@@ -1873,6 +1873,7 @@ files:
1873
1873
  - lib/workarea/ext/mongoid/list_field.rb
1874
1874
  - lib/workarea/ext/mongoid/moped_bson.rb
1875
1875
  - lib/workarea/ext/mongoid/timestamps_timeless.rb
1876
+ - lib/workarea/ext/referer_parser/parser.decorator
1876
1877
  - lib/workarea/ext/sprockets/ruby_processor.rb
1877
1878
  - lib/workarea/ext/sprockets/task.rb
1878
1879
  - lib/workarea/geolocation.rb
@@ -2017,6 +2018,7 @@ files:
2017
2018
  - test/lib/workarea/ext/mongoid/except_test.rb
2018
2019
  - test/lib/workarea/ext/mongoid/find_ordered_test.rb
2019
2020
  - test/lib/workarea/ext/mongoid/list_field_test.rb
2021
+ - test/lib/workarea/ext/referer_parser/parser_test.rb
2020
2022
  - test/lib/workarea/geolocation_test.rb
2021
2023
  - test/lib/workarea/lint/inconsistent_details_test.rb
2022
2024
  - test/lib/workarea/lint/products_missing_images_test.rb