Commit Graph

215 Commits

Author SHA1 Message Date
Albert Yi
0f2e6a9a1b fix tests 2018-05-09 12:45:37 -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
8fd9d374ca Fix #3583: Copying notes should copy tags to destination. 2018-03-31 12:58:56 -05:00
evazion
be0c2cfcfa posts: fix incorrect large_file_url for animated_gifs.
For animated_gif posts, large_file_url was returning
"/data/sample-$md5.jpg" instead of "/data/$md5.gif".
2018-03-28 19:17:15 -05:00
evazion
d089be9f8a tests: fix upload tests. 2018-03-20 19:49:58 -05:00
evazion
e596a7fd0f tests: fix <char>_(cosplay) alias test. 2018-01-20 14:26:16 -06:00
evazion
83ab90d495 tests: fix tag removal warning tests. 2018-01-20 13:59:21 -06:00
evazion
3d09ce5e55 tests: fix status:active test for #3472. 2018-01-20 12:50:30 -06:00
Albert Yi
dfd343f70e Merge pull request #3496 from BrokenEagle/feat-mod-action-event-ids
Add categories to mod actions
2018-01-15 11:09:38 -08:00
evazion
4f543671a2 tests: move test/helpers to test/test_helpers.
The Rails convention is for test/helpers to be used for testing the view
helpers in app/helpers. We were using it to store certain utility
methods instead. Move these to test/test_helpers so that test/helpers
can be used for its intended purpose.
2018-01-14 16:11:15 -06:00
BrokenEagle
dd8d80eaf7 Updated tests for mod actions 2018-01-14 00:07:20 -08:00
r888888888
604e9e9866 fix some unit tests 2018-01-02 15:12:48 -08:00
r888888888
4a80d6c337 refactor User#validate_sock_puppet to disable for tests 2018-01-02 14:32:38 -08:00
evazion
d8eef6ef2b Fix #1563: Warn users attempting to upload with very few tags. 2017-12-27 15:04:00 -06:00
evazion
8c44789fbc Fix #3440: Implications aren't applied to automatic tags.
Apply implications after adding automatic tags.
2017-12-19 14:37:12 -06:00
Albert Yi
8d5f1bccaf Merge pull request #3403 from evazion/fix-favgroup-race
Fix race condition when adding posts to favgroups
2017-12-13 14:28:38 -08:00
Albert Yi
1d901e9307 Merge pull request #3357 from evazion/feat-soft-post-validations
Post editing: add warning when creating new tags (#3352)
2017-12-13 14:24:51 -08:00
evazion
d6d73404a9 Apply aliases to characters in <character>_(cosplay) tags (#3409). 2017-12-06 12:47:27 -06:00
evazion
acd49be4cc Fix #3419: Deleting a post doesn't clear parent's "parent" status.
Bug: when deleting a child post and the "Move favorites to parent?" option is
set, the parent's has_active_children flag is not cleared.

`give_favorites_to_parent` moves the votes, and moving the votes has the
side effect of reloading the post (to get the new score). But reloading
the post wipes out the is_deleted_changed? flag, which is used by `update_parent_on_save`.

Fix: update the `is_deleted` flag *before* moving favorites, so that the
`update_parent_on_save` callback runs before `give_favorite_to_parent` runs.
2017-12-05 19:35:15 -06:00
evazion
3c6a613964 Fix #3410: Unable to create a new wiki page.
Fix `Post.fast_count(nil)` failing when the user had the "safe mode" or
"deleted post filter" options turned on.
2017-11-29 12:34:07 -06:00
evazion
4939c0345a Fix test failures when removing posts from deleted pools.
These tests failed because removing posts from deleted pools is now
Builder-only.
2017-11-26 18:10:08 -06:00
evazion
80e115b600 favgroups: fix race condition when adding posts to favgroups.
Adding or removing a post id to a favgroup's post_ids string is
non-atomic. Lock it to prevent simultaneous updates to the same favgroup
from clobbering each other.

Same bug as #3091.
2017-11-26 11:02:39 -06:00
evazion
bc3e2438d9 posts: add tests for warning validations. 2017-11-25 17:03:33 -06:00
evazion
a14c492020 Fix #3396: Pixiv novel cover IDs are parsed incorrectly. 2017-11-21 13:03:03 -06:00
evazion
b3a9cd6c06 Fix Post.fast_count("pool:1537") == 0 (fixup 134958d1).
Fixup for a bug in 134958d1. `Post.fast_count("pool:1537")` still
returned zero because `Tag.is_simple_tag?` incorrectly parsed
"pool:1537" as a simple tag, so Post.fast_count still looked for it in
the tags table and found the empty "pool:1537" tag.
2017-11-20 21:21:36 -06:00
r888888888
502f1298a9 fix unit tests 2017-11-20 16:30:07 -08:00
Albert Yi
f11992bd91 Merge pull request #3391 from evazion/fix-3390
Fix #3390: Searching certain metatags results in an empty paginator
2017-11-20 14:23:27 -08:00
evazion
134958d137 Fix #3390: Searching certain metatags results in an empty paginator
Fixes Post#get_count_from_cache to only lookup the count in the tags
table when the search is for a single "simple" tag.

Check memcache when the search is not a simple tag:

* multi-tag searches (touhou rating:s)
* single metatag searches (rating:s, source:"foo bar")
* negated tags (-touhou)
* wildcard tags (*touhou*)
* or searches (~touhou)
2017-11-20 14:41:02 -06:00
evazion
9b887c3c3a Fix #3387: Safebooru: Two tag searches fail for members.
Makes the `rating:s` and `-status:deleted` tags not count against the
tag limit.
2017-11-19 20:58:22 -06:00
r888888888
3ad332ad3d fix post test 2017-11-16 14:20:32 -08:00
r888888888
73f257ec63 disable manual post count expiration, rely solely on timed expiries (fixes #3376) 2017-11-16 13:43:38 -08:00
r888888888
2c56a19dec rework how category metatags work #3307 2017-10-09 16:08:14 -07:00
r888888888
b66773086c add failing test #3307 2017-10-09 15:03:53 -07:00
r888888888
28c3f8321a add failing test for #3307 2017-10-09 13:23:45 -07:00
r888888888
1f3bafc061 delegate removal from favorites and updating of user fav counts to delayed job 2017-09-13 14:19:54 -07:00
evazion
af42740ca9 expunge: decrement user favorite counts. 2017-09-13 13:29:35 -07:00
evazion
fd9dc6f647 expunge: decrement upload and note/post update counts (fix #2062). 2017-09-13 13:29:35 -07:00
Albert Yi
e4bc01533b Merge pull request #3245 from evazion/fix-2344
Fix #2344: Negating status metatag breaks deleted post filter.
2017-07-31 12:50:21 -07:00
Albert Yi
fe6ae4b3d1 Merge pull request #3233 from evazion/feat-order-metatags
Add order:{tagcount,gentags,arttags,chartags,copytags} metatags.
2017-07-31 11:56:06 -07:00
evazion
1c38fbbf64 Fix #2344: Negating status metatag breaks deleted post filter. 2017-07-28 19:52:35 -05:00
evazion
fffc107d4f Add order:{tagcount,gentags,arttags,chartags,copytags} metatags. 2017-07-21 23:11:02 -05:00
evazion
44f6673d94 Post#expunge!: run callbacks when reparenting children.
* Set parent IDs with `update` instead of `update_column` /
  `update_all` when reparenting children. This fixes it so that new post
  versions are saved and the has_children flag is set on the new parent.

* Slightly simplify logic of update_children_on_destroy: the single
  child case is subsumed by the multi-child case.
2017-07-21 00:13:20 -05:00
evazion
fbee7f6912 Post#expunge!: fix remove_pool! to remove posts from deleted pools.
Don't silently ignore attempts to remove posts from deleted pools.
Remove the restriction on removing posts from deleted pools instead (ref: #1109).

Fixes failure to remove posts from deleted pools during expungement.
2017-07-21 00:13:20 -05:00
r888888888
d48ed95191 favoritescontroller#destroy should work even if the post doesn't exist, remove from favorites on expunge (fixes #3222) 2017-07-19 13:39:24 -07:00
evazion
3e3844a796 Remove unused tag subscription code (#2956, #3206). 2017-07-13 13:44:26 -05:00
evazion
d84feaa4bb posts: fix expunging posts not removing image from iqdb.
`File.exists?(preview_file_path)` is always false because the file has
already been deleted by this point. Remove the check entirely.
2017-06-14 21:31:30 -05:00
evazion
a844a1daf4 posts: fix expunging posts not deleting files.
Fix expungement to ignore the "file still in use" check.
2017-06-14 21:31:24 -05:00
r888888888
bffa1f3dc3 fix unit tests 2017-05-30 17:37:42 -07:00
evazion
a401b1f570 posts: fix nil source tests; fix source:none metatag. 2017-05-26 15:12:39 -05:00
evazion
2259506bc2 flags: disallow flagging pending posts. 2017-05-19 14:37:38 -05:00