Use the file_fixture helper in tests

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.
This commit is contained in:
Javi Martín
2021-09-18 17:20:52 +02:00
parent 5ff66f96cd
commit 4f232c3a25
22 changed files with 73 additions and 80 deletions

View File

@@ -10,10 +10,10 @@ describe DirectUpload do
end
it "is not valid for different kind of combinations with invalid atttachment content types" do
expect(build(:direct_upload, :proposal, :documents, attachment: File.new("spec/fixtures/files/clippy.png"))).not_to be_valid
expect(build(:direct_upload, :proposal, :image, attachment: File.new("spec/fixtures/files/empty.pdf"))).not_to be_valid
expect(build(:direct_upload, :budget_investment, :documents, attachment: File.new("spec/fixtures/files/clippy.png"))).not_to be_valid
expect(build(:direct_upload, :budget_investment, :image, attachment: File.new("spec/fixtures/files/empty.pdf"))).not_to be_valid
expect(build(:direct_upload, :proposal, :documents, attachment: File.new(file_fixture("clippy.png")))).not_to be_valid
expect(build(:direct_upload, :proposal, :image, attachment: File.new(file_fixture("empty.pdf")))).not_to be_valid
expect(build(:direct_upload, :budget_investment, :documents, attachment: File.new(file_fixture("clippy.png")))).not_to be_valid
expect(build(:direct_upload, :budget_investment, :image, attachment: File.new(file_fixture("empty.pdf")))).not_to be_valid
end
it "is not valid without resource_type" do