Commit Graph

54 Commits

Author SHA1 Message Date
Donovan Daniels
6f296e8e01
[Posts] Add back comment disabling (#749) 2024-10-28 13:56:22 -07:00
Earlopain
fc7d84affd
[RuboCop] Enable Style/FrozenStringLiteralComment
This reduces allocations on the posts page by about 5%, from basic testing
2024-02-25 18:15:55 +01:00
Donovan Daniels
6eaf435002
Bring ForumPost ModAction trigger in line with Comments (#542)
* [Tests] Add hide & delete modaction tests to comments and forum posts

* [ForumPosts] Remove user id check on destroy

* [ForumPosts] Don't create edit modaction on hide

* Assert correct amount of ModActions is created

Especially important when it previously created 2 instead of 1 for hiding

---------

Co-authored-by: Earlopain <14981592+Earlopain@users.noreply.github.com>
2023-12-04 19:41:29 +01:00
Donovan Daniels
115c140cc2
[Posts] Make comment_disabled not hide comments (#546)
* [Posts] Make comment_disabled not hide comments

* [VoteManager] Disallow voting on locked/disabled comments

* [Comments] Disable editing/hiding disabled & locked comments

* Tweaking

* Allow hiding when comments locked
* Don't allow mods to vote when comments locked
* Change wording from disabled to locked everywhere

---------

Co-authored-by: Earlopain <14981592+Earlopain@users.noreply.github.com>
2023-09-05 17:27:05 +02:00
Earlopain
580776ca81
[Comments] Remove quoted response 2023-04-03 00:10:28 +02:00
Earlopain
7a028cf003
[Tests] Set CurrentUser.ip_addr in base setup 2022-11-26 16:20:16 +01:00
Earlopain
c68fdfce2b
[Tests] Always use CurrentUser as helper 2022-11-26 15:20:15 +01:00
Earlopain
98e55562eb
[Tests] Clean up teardowns 2022-11-26 14:02:06 +01:00
Earlopain
87313c437c [Tests] Include FactoryBot::Syntax::Methods
The newly included create method behaves exacly like the self-written one,
with the added benefit of it not appearing in backtraces.
2022-11-25 21:06:54 +01:00
Earlopain
c9f65608de
[Tests] Replace timecop with native Rails method
Also removes it at a bunch of places where it's not needed
2022-11-25 14:32:56 +01:00
Earlopain
0cd5391d3c
[Users] Fix double dot in account to new message 2022-09-11 18:54:43 +02:00
Earlopain
93cd28c0e1
[Posts] Change comment locked to disabled
Instead of just preventing new comments hide everything completly.
2022-05-16 15:53:39 +02:00
Earlopain
2f5b55a0bc
[Comments] Hide a few buttons on sticky 2022-05-16 14:42:44 +02:00
Earlopain
6d3f272e90
[Posts] Allow locking comment sections 2022-05-16 14:20:11 +02:00
Jason Gronn
23253d6766
[Comments] Disable downvoting own comment (#397)
* Disable downvoting own comment; hide vote buttons for own comment

* Revert hiding buttons; merge upvote/downvote paths; fix tests that relied on previous behaviour

* Undo some changes I did not mean to make

* Fix a mistake I made

* Fix some other unit tests
2022-04-30 12:48:53 +02:00
Earlopain
ec559f1a34
[Tests] Fix some comment tests 2022-03-28 21:17:34 +02:00
Earlopain
e7b03a84e9
[Config] remove dead keys 2021-04-03 20:14:15 +02:00
Kira
55cb64acf7 Fix deprecated use of update_attributes 2019-09-09 12:58:18 -07:00
evazion
03abbd0683 Fix #2894: Use [[:space:]] instead of \s in regexes. 2018-09-20 19:24:38 -05:00
evazion
0eff095a3e Refactor searching text attributes.
* Allow using ApplicationRecord#attribute_matches to search text attributes,
and standardize models on using this instead of duplicating code.

* Remove restrictions that limited wildcard searches to Builders only in various places.
2018-08-31 19:50:46 -05: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
feb3ec0750 Fix #3417: Deleting a user's comment credits the change to them. 2017-12-02 19:41:37 -06:00
evazion
69d4712708 mentions: process mentions added in an edit (fix #2736) 2017-08-04 23:48:53 -05:00
evazion
a3a9a78015 /comments.json: default to id_desc order instead undefined order. 2017-05-09 18:12:37 -05:00
evazion
54db229094 comment_test.rb: add quote-stripping test. 2017-04-24 21:15:47 -05:00
evazion
c0e5c400a7 tests: fix tests for Rails.cache. 2017-04-16 16:48:36 -05:00
r888888888
0b8d4105aa fix tests 2017-04-04 12:39:17 -07:00
evazion
46280f2227 mentions: include mentioner in subject line.
The template looks like this:

Subject:

    #{creator_name} mentioned you in a comment on post ##{post_id}

Body:

    @#{creator_name} mentioned you in a \"comment\":/posts/#{post_id}#comment-#{id} on post ##{post_id}:

    [quote]
    #{DText.excerpt(body, "@"+user_name)}
    [/quote]
2017-02-25 23:05:44 -06:00
evazion
72502dbe2f Fix comment voting tests.
2) Error:
CommentTest#test_: A comment created by an unlimited user should not allow duplicate votes. :
ActiveRecord::RecordInvalid: Validation failed: You have already voted for this comment
    app/models/comment.rb:142:in `vote!'
    test/unit/comment_test.rb:164:in `block (3 levels) in <class:CommentTest>'

  3) Error:
CommentTest#test_: A comment created by an unlimited user should not allow upvotes by the creator. :
ActiveRecord::RecordInvalid: Validation failed: You cannot upvote your own comments
    app/models/comment.rb:142:in `vote!'
    test/unit/comment_test.rb:179:in `block (3 levels) in <class:CommentTest>'
2017-02-03 04:03:44 -06:00
Albert Yi
b9a1e115fb add additional mod actions 2017-01-03 16:02:36 -08:00
evazion
0e73f3c8a9 Add tests for stickying comments. 2016-12-26 23:52:46 -06:00
evazion
01afc46f74 Fix failures in commenting tests.
Restricting users from upvoting their own comments broke some tests.
Switch these tests to downvoting instead.
2016-12-03 20:06:50 -06:00
evazion
1047d7c96b Prevent users from upvoting their own comments. 2016-11-06 01:32:54 -06:00
evazion
cb1e1d3a94 Prevent commenting on nonexistent posts (#2704). 2016-10-06 09:39:57 +00:00
r888888888
8a63fb0f7c enable mention for comments #2466 2015-11-30 16:51:07 -08:00
Toks
8055a7c64b Fix order:comm and comment deletion for unbumped comments
fixes #1351, fixes #1352
2013-12-24 20:59:19 -05:00
Toks
8c7fa25a5d add tests for #1263 2013-06-29 15:10:09 -04:00
r888888888
4dff618863 Use webmock instead of fakeweb for VCR; Fix tests; Use Timecop to speed up tests previously using sleep; Move artist rename into seperate operation 2013-05-24 12:59:13 -07:00
albert
b19994396d fix tests, fixes #1173 2013-04-03 17:23:25 -04:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
922ccabe1d fix comment votes affecting comment updater_id 2013-03-18 16:03:29 -07:00
albert
1da9e24bd0 fixes #804 2013-03-09 01:56:59 -05:00
albert
4cbef26c05 fix comment bumping 2013-02-24 17:54:42 -05:00
albert
17881068e1 * Removed Pixa/Tinami sources
* Upgraded to Rails 3.2.3
* Fixed tests
2012-06-01 19:22:58 -04:00
albert
4d4ae4b443 tests 2012-05-11 18:26:14 -04:00
albert
91ef2a6df2 improved test 2012-05-11 18:04:50 -04:00
albert
8fffa9747f fix attr_accessible 2011-12-14 11:19:58 -05:00
albert
f587724476 fixes #101: comment limitations 2011-10-03 18:54:01 -04:00
albert
22074eed1f fixes #69: Comment voting non functional 2011-09-14 17:46:42 -04:00
Dean Matzkov
5efb6a5b92 Fix unit tests for ruby-1.8 compatibility 2011-09-08 21:00:29 -06:00