docbrown/app/decorators
Daniel Uber 9f9594ccdc
role deprecation cleanup (#15717)
* User decorator (and spec) should use `trusted?`

Fixes a few issues seen in an rspec run that show as:

    DEPRECATION WARNING: User#trusted is deprecated, favor
    User#trusted? (called from config_body_class at
    /opt/apps/forem/app/decorators/user_decorator.rb:58)

And here:

/opt/apps/forem/spec/decorators/user_decorator_spec.rb:112
/opt/apps/forem/spec/decorators/user_decorator_spec.rb:121
/opt/apps/forem/spec/decorators/user_decorator_spec.rb:130
/opt/apps/forem/spec/decorators/user_decorator_spec.rb:139

* prefer User trusted? to trusted

DEPRECATION WARNING: User#trusted is deprecated, favor
User#trusted? (called from permissions at
/opt/apps/forem/app/models/rating_vote.rb:25)

* Prefer trusted? to trusted in user spec

* Use warned? rather than warned in admin article partial

* use trusted? rather than trusted in moderator requests spec

* Prefer trusted? to trusted in moderations controller

* Prefer trusted? to trusted in moderations view

* User auditable? should call trusted? and not trusted

Deprecations go rolling right along.

* Invert guard clause logic to be positive

The original "return unless multiple negated conditions hold" guard
was cumbersome.

Invert to return if any of the exceptions apply, namely:

- this is a comment or readinglist rating (rather than explicit),
allowed for all
- this rating is from a moderator/trusted user (allowed)
- this rating is offered by the article's author (allowed)

I had intended to also remove the safe navigation operators (since it
wasn't clear why there would be a null user or null article, as
rating_vote joins users to articles with a score), but the builtin
validation tests (is expected to validate ...) build objects with
missing attributes, and raise errors when the spec is run.
2021-12-09 15:27:45 -06:00
..
application_decorator.rb Fix and clean up podcast pages (#15004) 2021-10-15 17:38:57 -04:00
article_decorator.rb ✂️✂️✂️ Remove boosted states from articles (legacy/dead code) (#14977) 2021-10-07 14:39:34 -04:00
campaign_decorator.rb Introduce domain model for campaigns (#9300) 2020-07-20 09:04:53 -04:00
comment_decorator.rb Update format specifiers in readable_publish_date (#13660) 2021-05-07 08:51:49 +02:00
listing_decorator.rb Move HexComparer to Hex::Comparer service (#12202) 2021-01-12 11:34:30 -05:00
mention_decorator.rb Expand @-mention functionality to posts (#13367) 2021-05-12 07:33:33 -07:00
notification_decorator.rb Switch decorators to Rails builtin decorations - take 2 (#6125) [deploy] 2020-02-19 15:30:53 -05:00
organization_decorator.rb Move HexComparer to Hex::Comparer service (#12202) 2021-01-12 11:34:30 -05:00
podcast_episode_decorator.rb Update format specifiers in readable_publish_date (#13660) 2021-05-07 08:51:49 +02:00
profile_decorator.rb Fix profile field production display area functionality and remove SiteConfig.dev_to? hacks for better generalization (#12015) 2021-02-11 10:05:06 -05:00
sponsorship_decorator.rb Switch decorators to Rails builtin decorations - take 2 (#6125) [deploy] 2020-02-19 15:30:53 -05:00
user_decorator.rb role deprecation cleanup (#15717) 2021-12-09 15:27:45 -06:00