Update dev.to/mods for non-logged in users (#12301)

* complete implementation

* check if forem is DEV properly

* Add tests

* improve tests

* improve tests again

* REALLY improve tests (sheesh!)

* Address code review comments

* small changes

* modify specs
This commit is contained in:
Arit Amana 2021-01-20 13:53:50 -05:00 committed by GitHub
parent 0f15b8dbd3
commit 94236d7ee6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 17 deletions

View file

@ -31,12 +31,13 @@
</main>
<% else %>
<div class="container" style="margin-top: 90px;">
<h1 style="text-align: center"><%= community_name %> Mods</h1>
<h1 class="pt-5" style="text-align: center"><%= community_name %> Mods</h1>
<div class="body">
<p>We periodically award some <%= community_name %> members with heightened privileges to help moderate the community.</p>
<p>Email <%= email_link %> if you'd like to be considered right away.</p>
<p>Check out our <%= link_to "Code of Conduct", code_of_conduct_path %> and read through our <%= link_to "Trusted User Guide", community_moderation_path %> and <%= link_to "Tag Moderation Guide", tag_moderation_path %>.</p>
<p>If you'd like to assist us as a trusted user or tag mod, please email us at <%= mail_to email_link, email_link %> and let us know which role you're interested in and why. If it's tag moderation, please tell us what tags you'd like to moderate for.</p>
<% unless user_signed_in? %>
<p><em>P.S. You are not currently signed in.</em></p>
<p><em>P.S. You are not currently signed in.</em></p>
<% end %>
</div>
</div>

View file

@ -84,26 +84,26 @@ RSpec.describe "Moderations", type: :request do
describe "actions_panel" do
context "when the user is a tag moderator" do
let(:tag_mod) { create(:user, :tag_moderator) }
let(:tag) { tag_mod.roles.find_by(name: "tag_moderator").resource }
let(:article1) { create(:article, tags: tag) }
let(:article2) { create(:article, tags: "javascript, cool, beans") }
it "shows the option to remove the tag when the article has the tag" do
tag_mod = create(:user, :tag_moderator)
tag_mod.add_role :trusted
tag = tag_mod.roles.find_by(name: "tag_moderator").resource
article = create(:article, tags: tag)
sign_in tag_mod
get "#{article.path}/actions_panel"
get "#{article1.path}/actions_panel"
expect(response.body).to include "circle centered-icon adjustment-icon subtract"
end
end
it "shows the option to add the tag when the article has the tag" do
tag_mod = create(:user, :tag_moderator)
tag_mod.add_role :trusted
article = create(:article, tags: "javascript, cool, beans")
sign_in tag_mod
it "shows the option to add the tag when the article has the tag" do
tag_mod.add_role :trusted
sign_in tag_mod
get "#{article.path}/actions_panel"
expect(response.body).to include "circle centered-icon adjustment-icon plus"
get "#{article2.path}/actions_panel"
expect(response.body).to include "circle centered-icon adjustment-icon plus"
end
end
end
@ -123,10 +123,11 @@ RSpec.describe "Moderations", type: :request do
end
context "when the user is an admin" do
let(:admin) { create(:user, :admin) }
let(:article) { create(:article, tags: "javascript, cool, beans") }
before do
admin = create(:user, :admin)
sign_in admin
article = create(:article, tags: "javascript, cool, beans")
get "#{article.path}/actions_panel"
end
@ -135,4 +136,40 @@ RSpec.describe "Moderations", type: :request do
expect(response.body).to include "circle centered-icon adjustment-icon subtract"
end
end
describe "/mod" do
let(:dev_name_copy) { "We periodically award some DEV members with heightened privileges" }
# rubocop:disable Layout/LineLength
let(:coc_guides_copy) do
'Check out our <a href="/code-of-conduct">Code of Conduct</a> and read through our <a href="/community-moderation">Trusted User Guide</a> and <a href="/tag-moderation">Tag Moderation Guide</a>.'
end
# rubocop:enable Layout/LineLength
let(:become_mod_copy) { "If you'd like to assist us as a trusted user or tag mod" }
let(:logged_out_copy) { "P.S. You are not currently signed in." }
let(:user) { create(:user) }
before do
allow(SiteConfig).to receive(:community_name).and_return("DEV")
end
context "when user logged in" do
it "indicates community name, codes of conduct/guides, and describes how to become a mod" do
sign_in user
get "/mod"
expect(response.body).to include dev_name_copy
expect(response.body).to include coc_guides_copy
expect(response.body).to include become_mod_copy
expect(response.body).not_to include logged_out_copy
end
end
context "when user logged out" do
it "warns that user is not signed in" do
get "/mod"
expect(response.body).to include logged_out_copy
end
end
end
end