* 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.
47 lines
2.1 KiB
Text
47 lines
2.1 KiB
Text
<% title t("views.moderations.heading") %>
|
|
|
|
<%= javascript_packs_with_chunks_tag "modCenter", defer: true %>
|
|
|
|
<div id="moderation-page" aria-hidden="true"></div>
|
|
|
|
<% if current_user&.trusted? %>
|
|
<div class="crayons-layout crayons-layout--2-cols" id="mod-center">
|
|
<%= render "moderations/mod_sidebar_left" %>
|
|
<main class="mod-index-container articles-list crayons-layout__content">
|
|
|
|
<header class="mod-index-header hidden m:block">
|
|
<h2 class="crayons-subtitle-1">
|
|
<%= @tag ? "##{@tag.name}" : t("views.moderations.all") %>
|
|
</h2>
|
|
</header>
|
|
|
|
<section class="mod-index-body">
|
|
<div class="mod-index-list-header lh-tight hidden m:grid">
|
|
<h2 class="mod-index-list-header__label"><%= t("views.moderations.post") %></h2>
|
|
<h2 class="mod-index-list-header__label"><%= t("views.moderations.author") %></h2>
|
|
<h2 class="mod-index-list-header__label align-center"><%= t("views.moderations.date") %></h2>
|
|
</div>
|
|
|
|
<div class="mod-index-list" id="mod-index-list" data-articles="<%= @articles %>">
|
|
</div>
|
|
</section>
|
|
</div>
|
|
<div data-testid="flag-user-modal-container" class="flag-user-modal-container hidden">
|
|
</div>
|
|
</main>
|
|
<% else %>
|
|
<div class="container" style="margin-top: 90px;">
|
|
<h1 class="pt-5" style="text-align: center"><%= t("views.moderations.notice.subtitle", community: community_name) %></h1>
|
|
<div class="body">
|
|
<p><%= t("views.moderations.notice.desc1_html", community: community_name) %></p>
|
|
<p>
|
|
<%= t("views.moderations.notice.desc2_html", code: link_to(t("views.moderations.notice.code_of_conduct"), code_of_conduct_path), trusted: link_to(t("views.moderations.notice.trusted"), community_moderation_path),
|
|
tag: link_to(t("views.moderations.notice.tag"), tag_moderation_path)) %>
|
|
</p>
|
|
<p><%= t("views.moderations.notice.desc3_html", email: mail_to(email_link, email_link)) %></p>
|
|
<% unless user_signed_in? %>
|
|
<p><em><%= t("views.moderations.notice.desc4") %></em></p>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|