From 771fa5b782c32f5f41ffd722092159a841d470f6 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Mon, 23 Dec 2019 20:12:14 -0500 Subject: [PATCH] Final fixes to /mod (#5234) [deploy] --- app/views/moderations/index.html.erb | 9 +++++---- spec/requests/moderations_spec.rb | 10 ++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/views/moderations/index.html.erb b/app/views/moderations/index.html.erb index cf781e507..c1c09cb94 100644 --- a/app/views/moderations/index.html.erb +++ b/app/views/moderations/index.html.erb @@ -21,15 +21,16 @@ Posts This Week + <% plucked_article_ids = Article.cached_tagged_with(@tag).pluck(:id) if @tag %>
- <%= number_with_delimiter(@tag ? Comment.where(commentable_id: Article.cached_tagged_with(@tag).pluck(:id) ).where("created_at > ?", 7.days.ago).size : Comment.where("created_at > ?", 7.days.ago).size) %> + <%= number_with_delimiter(@tag ? Comment.where(commentable_id: plucked_article_ids ).where("created_at > ?", 7.days.ago).size : Comment.where("created_at > ?", 7.days.ago).size) %>
Comments This Week
- <%= number_with_delimiter(@tag ? Reaction.where(reactable_id: Article.cached_tagged_with(@tag).pluck(:id) ).where("created_at > ?", 7.days.ago).size : Reaction.where("created_at > ?", 7.days.ago).size) %> + <%= number_with_delimiter(@tag ? Reaction.where(reactable_id: plucked_article_ids ).where("created_at > ?", 7.days.ago).size : Reaction.where("created_at > ?", 7.days.ago).size) %>
Reactions This Week
@@ -58,9 +59,9 @@
- <%= article.cached_user.name %> + <%= article.cached_user.name %> ・ <%= article.readable_publish_date %> - <% if article.nth_published_by_author < 4 %> + <% if article.nth_published_by_author > 0 && article.nth_published_by_author < 4 %> ・ 👋 <%= article.nth_published_by_author.ordinalize %> post by this user <% end %>
diff --git a/spec/requests/moderations_spec.rb b/spec/requests/moderations_spec.rb index 5b358eefd..a64852591 100644 --- a/spec/requests/moderations_spec.rb +++ b/spec/requests/moderations_spec.rb @@ -63,16 +63,10 @@ RSpec.describe "Moderations", type: :request do expect(response.body).to include("We build the") end - it "grants access to /mod index with articles" do - create(:article, published: true) - get "/mod" - expect(response.body).to include("We build the") - end - - it "grants access to /mod index with articles" do + it "grants access to /mod/:tag index with articles" do create(:article, published: true) get "/mod/#{article.tags.first}" - expect(response.body).to include("#"+article.tags.first.name.titleize) + expect(response.body).to include("#" + article.tags.first.name.titleize) end end end