Skip to content

Commit

Permalink
add failing test cases for carrierwaveuploader#2702
Browse files Browse the repository at this point in the history
  • Loading branch information
rajyan committed Sep 13, 2023
1 parent 8815592 commit f4e58cb
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions spec/orm/activerecord_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -635,18 +635,17 @@ def filename
end
end

describe 'with overriddent filename' do

describe '#save' do

before do
@uploader.class_eval do
def filename
model.name + File.extname(super)
end
describe 'with overridden filename' do
before do
@uploader.class_eval do
def filename
model.name + File.extname(super)
end
allow(@event).to receive(:name).and_return('jonas')
end
allow(@event).to receive(:name).and_return('jonas')
end

describe '#save' do

it "should copy the file to the upload directory when a file has been assigned" do
@event.image = stub_file('test.jpeg')
Expand All @@ -664,6 +663,33 @@ def filename

end

describe '#changes' do
it "should be generated" do
@event.image = stub_file('test.jpeg')
expect(@event.changes).to eq({'image' => [nil, 'test.jpeg']})
end

it "shouldn't be generated when the attribute value is unchanged" do
@event.image = stub_file('test.jpeg')
@event.save!
@event.image = @event[:image]

expect(@event.changes).to be_blank
expect(@event).not_to be_changed
@event.remote_image_url = ""
expect(@event).not_to be_changed
end

it "shouldn't be generated after second save" do
@event.image = stub_file('old.jpeg')
@event.save!
@event.image = stub_file('new.jpeg')
@event.save!

expect(@event.changes).to be_blank
expect(@event).not_to be_changed
end
end
end

describe 'with validates_presence_of' do
Expand Down Expand Up @@ -1552,7 +1578,7 @@ def filename
end
end

describe 'with overriddent filename' do
describe 'with overridden filename' do

describe '#save' do

Expand Down

0 comments on commit f4e58cb

Please sign in to comment.