Skip to content

Commit

Permalink
Fix column value populated without a file when using filename override
Browse files Browse the repository at this point in the history
Fixes #2284
  • Loading branch information
mshibuya committed Jan 1, 2023
1 parent eca7b98 commit f1eff6e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/carrierwave/uploader/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def current_path
# [String] uniquely identifies a file
#
def identifier
@identifier || storage.try(:identifier)
@identifier || (file && storage.try(:identifier))
end

##
Expand Down
26 changes: 26 additions & 0 deletions spec/uploader/proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,32 @@
end
end

describe '#identifier' do
subject { uploader.identifier }

context "when nothing has been done" do
it { is_expected.to be_nil }
end

context "when a file is stored" do
before { uploader.store!(test_file) }

it { is_expected.to eq 'test.jpg' }
end

context "when #filename is set to always return a value" do
before do
uploader.class_eval do
def filename
'dummy'
end
end
end

it { is_expected.to be_nil }
end
end

describe '#read' do
subject { uploader.read }

Expand Down

0 comments on commit f1eff6e

Please sign in to comment.