workarea-core 3.5.11 → 3.5.12

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: 72fffa19332c0b8652c70135ef370a1704350ea0037845df1615c958bd9a8bc8
4
- data.tar.gz: 717aaef848a0ad75774fc0ed23b41c80362b8657c021d06630296dbdbe3e4dea
3
+ metadata.gz: 07f92725a7deefad82f4df41734ec888981896e7ed23948b809da43495f3234c
4
+ data.tar.gz: be8b5ee9228c3c3c073f2e0456d2dcb60abb77bae48f904f75b608b6e5ce3fb3
5
5
  SHA512:
6
- metadata.gz: da8b605d36c1b60257fb73d8e65a3bee6e5b99f03d991861b4eef5ab9338fd00e8787eb1e32d6e1df3905bdc95ec349d3ab022a6b0a7e648e0006eb6341f444e
7
- data.tar.gz: '09fbd0f844ae5ff48b37f160981b9173982114a0f5584e6846a565be9459697812265e9c4224f82efabfe12265537b3e6bfb0f1c501ad0521bc632d9ca13f82e'
6
+ metadata.gz: 252398a30da73f5e643367f8c63628a7cbbd739d5ec7bf945ffa71d59065b7b7b60b22cf2a9867f96a0e7047136a4b7ff3bddb7e0943fd8c388c88458645d82b
7
+ data.tar.gz: 29fbc57881073fabc8294289477c1ff548f640c10dba07aa8c1409dd2757ff9b78c3ed34236efc22ee99c8c2c9e06006363eb2bb8ca7ba43fd422418e163084f
@@ -6,22 +6,21 @@ module Workarea
6
6
  uri = URI.parse(request_url)
7
7
  url = "#{uri.scheme}://#{uri.host}"
8
8
  url += ":#{uri.port}" unless uri.port.in? [80, 443]
9
-
10
- redis_key = "cors_#{url.optionize}"
11
- return if Workarea.redis.get(redis_key) == 'true'
9
+ id = "direct_upload_#{url}"
12
10
 
13
11
  response = Workarea.s3.get_bucket_cors(Configuration::S3.bucket)
14
12
  cors = response.data[:body]
15
- cors['CORSConfiguration'] << {
16
- 'ID' => "direct_upload_#{url}",
17
- 'AllowedMethod' => 'PUT',
18
- 'AllowedOrigin' => url,
19
- 'AllowedHeader' => '*'
20
- }
21
- cors['CORSConfiguration'].uniq!
22
-
23
- Workarea.s3.put_bucket_cors(Configuration::S3.bucket, cors)
24
- Workarea.redis.set(redis_key, 'true')
13
+
14
+ unless cors['CORSConfiguration'].pluck('ID').include?(id)
15
+ cors['CORSConfiguration'] << {
16
+ 'ID' => id,
17
+ 'AllowedMethod' => 'PUT',
18
+ 'AllowedOrigin' => url,
19
+ 'AllowedHeader' => '*'
20
+ }
21
+
22
+ Workarea.s3.put_bucket_cors(Configuration::S3.bucket, cors)
23
+ end
25
24
  end
26
25
 
27
26
  attr_reader :type, :filename
@@ -17,11 +17,11 @@ module Workarea
17
17
  import.process!
18
18
 
19
19
  ensure
20
- if import.error?
20
+ if import&.error?
21
21
  Admin::DataFileMailer.import_error(id).deliver_now
22
- elsif import.failure?
22
+ elsif import&.failure?
23
23
  Admin::DataFileMailer.import_failure(id).deliver_now
24
- else
24
+ elsif import.present?
25
25
  Admin::DataFileMailer.import(id).deliver_now
26
26
  end
27
27
  end
@@ -2,7 +2,7 @@ module Workarea
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 5
5
- PATCH = 11
5
+ PATCH = 12
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
8
8
 
@@ -38,7 +38,10 @@ module Workarea
38
38
  end
39
39
 
40
40
  def current_email
41
- cookies.signed[:email]
41
+ # For performance, prefer to use the cookie. The fallback to looking it up
42
+ # by user is a failsafe against a blank email cookie (e.g. from a raised
43
+ # error or poor application coding).
44
+ cookies.signed[:email].presence || (email_from_user_id if logged_in?)
42
45
  end
43
46
 
44
47
  def metrics
@@ -91,5 +94,9 @@ module Workarea
91
94
  def blank_metrics
92
95
  @blank_metrics ||= Metrics::User.new
93
96
  end
97
+
98
+ def email_from_user_id
99
+ User.find(session[:user_id]).email rescue nil
100
+ end
94
101
  end
95
102
  end
@@ -108,11 +108,8 @@ module Workarea
108
108
  ).returns(true)
109
109
 
110
110
  assert(DirectUpload.ensure_cors!('http://test.host/admin/content_assets'))
111
- assert_equal('true', Workarea.redis.get('cors_http_test_host'))
112
111
  assert(DirectUpload.ensure_cors!('http://localhost:3000/admin/content_assets'))
113
- assert_equal('true', Workarea.redis.get('cors_http_localhost_3000'))
114
112
  assert(DirectUpload.ensure_cors!('https://example.com/admin/direct_uploads'))
115
- assert_equal('true', Workarea.redis.get('cors_https_example_com'))
116
113
  end
117
114
 
118
115
  private
@@ -53,5 +53,11 @@ module Workarea
53
53
  t('workarea.admin.data_file_mailer.import_failure.errors')
54
54
  )
55
55
  end
56
+
57
+ def test_perform_with_missing_import
58
+ assert_raises Mongoid::Errors::DocumentNotFound do
59
+ ProcessImport.new.perform('foo')
60
+ end
61
+ end
56
62
  end
57
63
  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.11
4
+ version: 3.5.12
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-05-13 00:00:00.000000000 Z
11
+ date: 2020-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler