Commit Graph

8 Commits

Author SHA1 Message Date
Javi Martín
614b4fbe4c Add and apply FactoryBot/AssociationStyle rule
This rule was added in rubocop-factory_bot 2.23.0. We were following it
sometimes, and sometimes we were not.
2023-09-08 13:52:54 +02:00
Javi Martín
b88a01f641 Add and apply FactoryBot/RedundantFactoryOption rule
This rule was added in rubocop-factory_bot 2.23.0.
2023-09-08 13:39:26 +02:00
karim-semmoud
f4973498be Add budget image to Budget and image factories and model 2023-06-26 19:40:42 +02:00
Javi Martín
8eea6f585a Remove hack to allow IO files in Active Storage
We were using this hack in order to allow `File.new` attachments in
tests files. However, we can use the `fixture_file_upload` helper
instead.

Just like it happened with `file_fixture`, this helper method doesn't
work in fixtures, so in this case we're using `Rack::Test::UploadedFile`
instead.
2022-02-23 19:00:33 +01:00
Javi Martín
be9c272ce4 Remove default Active Storage direct upload action
We're already using a custom controller to handle direct uploads.

Besides, as mentioned by one of Active Storage co-authors [1], the
Active Storage DirectUploadsController doesn't provide any
authentication or validation at all, meaning anyone could create blobs
in our database by posting to `/rails/active_storage/direct_uploads`.
The response there could be then used to upload any file (again, without
validation) to `/rails/active_storage/disk/`.

For now, we're monkey-patching the controllers in order to send
unauthorized responses, since we aren't using these routes. If we ever
enable direct uploads with Active Storage, we'll have to add some sort
of authentication.

Similar upload solutions like CKEditor don't have this issue since their
controllers inherit from `ApplicationController` (which includes
authorization rules), while Active Storage controllers inherit from
`ActionController::Base`.

[1] https://discuss.rubyonrails.org/t/activestorage-direct-uploads-safe-by-default-how-to-make-it-safe/74863/2
2021-09-24 13:39:15 +02:00
Javi Martín
fc1a89e966 Use dynamic attributes in factories
Static attributes are deprecated since factory bot 4.11; we haven't
upgraded yet but now we're ready to do so:

https://thoughtbot.com/blog/deprecating-static-attributes-in-factory_bot-4-11
2019-08-07 19:43:57 +02:00
voodoorai2000
19b7526421 Add document upload from admin section 2019-04-30 11:59:08 +02:00
Pierre Mesure
cba6cc029e Split factories 2018-08-08 07:20:47 +02:00