Move attachable methods from helpers to models

We were using helper methods inside the model; we might as well include
them in the model and use them from anywhere else.

Note we're using a different logic for images and documents methods.
That's because for images the logic was defined in the helper methods,
but for documents the logic is defined in the Documentable concern. In
the past, different documentable classes allowed different content
types, while imageable classes have always allowed the same content
types.

I'm not sure which method is better; for now, I'm leaving it the way it
was (except for the fact that we're removing the helper methods).
This commit is contained in:
Javi Martín
2021-07-24 02:20:59 +02:00
parent 4d8842c0d4
commit b52ceb2c78
8 changed files with 46 additions and 47 deletions

View File

@@ -1,9 +1,7 @@
shared_examples "document validations" do |documentable_factory|
include DocumentablesHelper
let!(:document) { build(:document, documentable_factory.to_sym) }
let!(:maxfilesize) { document.documentable.class.max_file_size }
let!(:acceptedcontenttypes) { accepted_content_types(document.documentable.class) }
let!(:maxfilesize) { document.max_file_size }
let!(:acceptedcontenttypes) { document.accepted_content_types }
it "is valid" do
expect(document).to be_valid