Commit Graph

19 Commits

Author SHA1 Message Date
evazion
d4da8499ce models: stop saving IP addresses in version tables.
Mark various `creator_ip_addr` and `updater_ip_addr` columns as ignored
and stop updating them in preparation for dropping them.
2022-09-18 03:49:17 -05:00
evazion
afe5095ee6 posts: mark media asset as expunged when post is expunged.
Fix it so that when a post is expunged, the media asset is also marked
as expunged. This way the files will be deleted, but the media asset
will still remain as a record of what was expunged. The media asset will
have the md5, width, height, file ext, and file size of the deleted file.
2021-10-26 02:53:32 -05:00
evazion
5c7a0f225c media assets: prevent duplicate media assets.
Add a md5 uniqueness constraint on media assets to prevent duplicate
assets from being created. This way we can guarantee that there is one
active media asset per uploaded file.

Also make it so that if two people are uploading the same file at the
same time, the file is processed only once.
2021-10-24 04:35:06 -05:00
evazion
d5981754c4 posts: automatically tag animated_gif & animated_png on tag edit.
Automatically tag animated_gif and animated_png when a post is edited.
Add them back if the user tries to remove them from an animated post,
or remove them if the user tries to add them to a non-animated post.

Before we added these tags at upload time, but it was possible for users
to remove them after upload, or to incorrectly add them to non-animated
posts. They were added at upload time because we couldn't afford to open
the file and parse the metadata on every tag edit. Now that we save the
metadata in the database, we can do this.

This also makes it so you can't tag ugoira on non-ugoira files.

Known bug: it's possible to have an animated GIF where every frame is
identical. Post #3770975 is an example. This will be detected as an
animated GIF even though visually it doesn't appear to be animated.

Fixes #4041: Animated_gif tag not added to preprocessed uploads
2021-09-21 08:26:02 -05:00
evazion
be4646aa6f tests: fix username conflicts in parallel tests.
Parallel tests sometimes failed because the username generator sometimes
generated duplicate usernames.
2020-06-11 02:43:19 -05:00
evazion
3656063a6b tests: fix unit tests.
* Move old post archive tests to post version tests.

* Fix pool tests that assumed that multiple edits by the same user
  weren't merged.

* Fix references to `is_active` and `notes` on artist model.
2020-03-21 21:07:35 -05:00
evazion
3c2a379d6f uploads: replace old upload limits with new upload limits. 2020-02-03 22:05:58 -06:00
evazion
7c8c4e9f82 tests: fix null uploader_ip_addr exceptions in create(:post).
Caused by a change in FactoryBot 5. Associations in factories are now
constructed using the same strategy as the base object, meaning that
using `build` to construct an object will also construct the
associations using `build`. This meant that overriding `create` to do
`build` + `save` broke the way that associations were constructed.

https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations
2019-08-04 12:43:12 -05:00
Albert Yi
04edc3f533 update factories + tests 2019-05-10 17:31:07 -07:00
r888888888
abce4d2551 Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently
ignoring it.

misc models: convert to strong params.

artist commentaries: convert to strong params.

* Disallow changing or setting post_id to a nonexistent post.

artists: convert to strong params.

* Disallow setting `is_banned` in create/update actions. Changing it
  this way instead of with the ban/unban actions would leave the artist in
  a partially banned state.

bans: convert to strong params.

* Disallow changing the user_id after the ban has been created.

comments: convert to strong params.

favorite groups: convert to strong params.

news updates: convert to strong params.

post appeals: convert to strong params.

post flags: convert to strong params.

* Disallow users from setting the `is_deleted` / `is_resolved` flags.

ip bans: convert to strong params.

user feedbacks: convert to strong params.

* Disallow users from setting `disable_dmail_notification` when creating feedbacks.
* Disallow changing the user_id after the feedback has been created.

notes: convert to strong params.

wiki pages: convert to strong params.

* Also fix non-Builders being able to delete wiki pages.

saved searches: convert to strong params.

pools: convert to strong params.

* Disallow setting `post_count` or `is_deleted` in create/update actions.

janitor trials: convert to strong params.

post disapprovals: convert to strong params.

* Factor out quick-mod bar to shared partial.
* Fix quick-mod bar to use `Post#is_approvable?` to determine visibility
  of Approve button.

dmail filters: convert to strong params.

password resets: convert to strong params.

user name change requests: convert to strong params.

posts: convert to strong params.

users: convert to strong params.

* Disallow setting password_hash, last_logged_in_at, last_forum_read_at,
  has_mail, and dmail_filter_attributes[user_id].

* Remove initialize_default_image_size (dead code).

uploads: convert to strong params.

* Remove `initialize_status` because status already defaults to pending
  in the database.

tag aliases/implications: convert to strong params.

tags: convert to strong params.

forum posts: convert to strong params.

* Disallow changing the topic_id after creating the post.
* Disallow setting is_deleted (destroy/undelete actions should be used instead).
* Remove is_sticky / is_locked (nonexistent attributes).

forum topics: convert to strong params.

* merges https://github.com/evazion/danbooru/tree/wip-rails-5.1
* lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4)
* switch to factorybot and change all references

Co-authored-by: r888888888 <r888888888@gmail.com>
Co-authored-by: evazion <noizave@gmail.com>

add diffs
2018-04-06 18:09:57 -07:00
evazion
3edd814be5 tests: add iqdb queries controller tests. 2017-02-06 18:48:37 -06:00
r888888888
341b29ce41 fix tests 2015-08-18 17:40:53 -07:00
Toks
afa4e83d9b Auto-add automatic tags whenever post is updated
Instead of being limited to when it's first uploaded.
2013-12-15 19:39:10 -05:00
r888888888
d5f575159f rename references of privileged to gold 2013-04-28 00:04:52 -07:00
albert
17881068e1 * Removed Pixa/Tinami sources
* Upgraded to Rails 3.2.3
* Fixed tests
2012-06-01 19:22:58 -04:00
albert
5610731b35 sync 2010-08-18 18:42:33 -04:00
albert
3d9d6e229a added pool unit test 2010-02-13 05:11:27 -05:00
albert
2f3a6e4a8b added moderation tests for post test 2010-02-10 16:33:00 -05:00
albert
e6888ea1dd fixed tag and pending post tests, added category multiget helper to tag, post/unapproval/post version in progress still 2010-02-10 16:12:30 -05:00