Skip to content

Commit

Permalink
Support setting #aws_acl to nil for bucket-level ACL compatibility
Browse files Browse the repository at this point in the history
Closes #175
  • Loading branch information
mshibuya committed Jul 23, 2023
1 parent 226b420 commit 7a3747c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/carrierwave-aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion spec/carrierwave-aws_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@
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'
uploader.aws_acl = 'authenticated-read'
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'
Expand Down

0 comments on commit 7a3747c

Please sign in to comment.