This way we don't have to write `"spec/fixtures/files"` every time. Note this method isn't included in factories. We could include it like so: ``` FactoryBot::SyntaxRunner.class_eval do include ActiveSupport::Testing::FileFixtures self.file_fixture_path = RSpec.configuration.file_fixture_path end ``` However, I'm not sure about the possible side effects, and since we only use attachments in a few factories, there isn't much gain in applying the monkey-patch.
14 lines
402 B
Ruby
14 lines
402 B
Ruby
require "rails_helper"
|
|
|
|
describe Image do
|
|
it_behaves_like "image validations", "budget_investment_image"
|
|
it_behaves_like "image validations", "proposal_image"
|
|
|
|
it "stores attachments with Active Storage" do
|
|
image = create(:image, attachment: File.new(file_fixture("clippy.jpg")))
|
|
|
|
expect(image.attachment).to be_attached
|
|
expect(image.attachment.filename).to eq "clippy.jpg"
|
|
end
|
|
end
|