From 7a3747cc1ddaf4d919cd950e5a201ed2c244be43 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Shibuya Date: Sun, 23 Jul 2023 19:03:32 +0900 Subject: [PATCH] Support setting #aws_acl to nil for bucket-level ACL compatibility Closes #175 --- lib/carrierwave-aws.rb | 2 ++ spec/carrierwave-aws_spec.rb | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/carrierwave-aws.rb b/lib/carrierwave-aws.rb index db93efc..0387347 100644 --- a/lib/carrierwave-aws.rb +++ b/lib/carrierwave-aws.rb @@ -40,6 +40,8 @@ def self.aws_acl=(acl) end def self.normalized_acl(acl) + return nil if acl.nil? + normalized = acl.to_s.downcase.sub('_', '-') unless ACCEPTED_ACL.include?(normalized) diff --git a/spec/carrierwave-aws_spec.rb b/spec/carrierwave-aws_spec.rb index 1f8bb49..2e12c4b 100644 --- a/spec/carrierwave-aws_spec.rb +++ b/spec/carrierwave-aws_spec.rb @@ -20,7 +20,7 @@ end describe '#aws_acl' do - it 'allows known acess control values' do + it 'allows known access control values' do expect do uploader.aws_acl = 'private' uploader.aws_acl = 'public-read' @@ -28,6 +28,13 @@ end.not_to raise_exception end + it 'allows nil' do + uploader.aws_acl = 'public-read' + expect do + uploader.aws_acl = nil + end.to change { uploader.aws_acl }.from('public-read').to(nil) + end + it 'does not allow unknown control values' do expect do uploader.aws_acl = 'everybody'