From 1a2365857842474ca2ead49ee393d525d4ae213c Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Wed, 9 May 2018 17:05:29 -0400 Subject: [PATCH 1/2] Update FAQ with info about comment threads (#298) * Update FAQ with info about comment threads Also removed scholarship info, seems less relevant these days. * Fix grammar --- app/views/pages/faq.html.erb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/pages/faq.html.erb b/app/views/pages/faq.html.erb index 07215a798..52fbffcf6 100644 --- a/app/views/pages/faq.html.erb +++ b/app/views/pages/faq.html.erb @@ -107,6 +107,11 @@
Include `cover_image: [url]` in the front matter of your post. For more information on our editor, check out our editor guide.

+

+ How does comment threading work? +
+ Comments are threaded with a maximum depth, and then they become flat. You can respond to flattened-out threads by replying to the last comment in the overall thread. +

I heard you were planning on open sourcing the code. Is that ever going to happen?
@@ -126,7 +131,7 @@
We mail out the sticker packs separately from the shirts. Please be patient! If you don't recieve the stickers within three weeks (domestic) or six weeks (international), e-mail members@dev.to for help.

- How do I cancel my membership? + How do I cancel my sustaining membership?
Go to your settings page and click 'cancel membership'.

@@ -135,11 +140,6 @@
Please e-mail members@dev.to immediately.

-

- How do scholarships work? -
- Scholarship recipients receive a yearly 'workshop pass' that provides full access to dev.to workshops and webinars. -

How are scholarships provided?
From 6cff2e68d5f6f4311dc4eabee7874e49c312e28c Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Wed, 9 May 2018 18:26:36 -0400 Subject: [PATCH 2/2] Add /mod views (#299) * Fix boosted issue * Add /mod views * Fix format issue * Remove unnecessary articles controller code --- app/controllers/moderations_controller.rb | 20 ++++++ app/helpers/application_helper.rb | 1 + app/views/moderations/mod.html.erb | 74 +++++++++++++++++++++++ config/routes.rb | 5 ++ spec/requests/moderations_spec.rb | 42 +++++++++++++ 5 files changed, 142 insertions(+) create mode 100644 app/controllers/moderations_controller.rb create mode 100644 app/views/moderations/mod.html.erb create mode 100644 spec/requests/moderations_spec.rb diff --git a/app/controllers/moderations_controller.rb b/app/controllers/moderations_controller.rb new file mode 100644 index 000000000..79001d591 --- /dev/null +++ b/app/controllers/moderations_controller.rb @@ -0,0 +1,20 @@ +class ModerationsController < ApplicationController + + before_action :check_trusted + + def article + @moderatable = Article.find_by_slug(params[:slug]) + render template: "moderations/mod" + end + + def comment + @moderatable = Comment.find(params[:id_code].to_i(26)) + render template: "moderations/mod" + end + + private + + def check_trusted + not_found unless current_user&.has_role?(:trusted) + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b43533091..e6672f9b8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -21,6 +21,7 @@ module ApplicationHelper controller_name == "users" || controller_name == "pages" || controller_name == "dashboards"|| + controller_name == "moderations"|| controller_name == "stories" || controller_name == "comments" || controller_name == "notifications" || diff --git a/app/views/moderations/mod.html.erb b/app/views/moderations/mod.html.erb new file mode 100644 index 000000000..08cc407d8 --- /dev/null +++ b/app/views/moderations/mod.html.erb @@ -0,0 +1,74 @@ + + +

+

MODERATE: <%= @moderatable.title %>

+ + + +

+ Negative reactions are private. Use the :thumbsdown: to move something "down" for any reason. The :vomit: is for clear code of conduct violations. +

+
+ + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2562a0c8d..70bd64247 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -220,6 +220,7 @@ Rails.application.routes.draw do get "/:timeframe" => "stories#index", constraints: { timeframe: /latest/} + #Lagacy comment format (might still be floating around app, and external links) get "/:username/:slug/comments/new/:parent_id_code" => "comments#new" get "/:username/:slug/comments/new" => "comments#new" get "/:username/:slug/comments" => "comments#index" @@ -227,11 +228,15 @@ Rails.application.routes.draw do get "/:username/:slug/comments/:id_code/edit" => "comments#edit" get "/:username/:slug/comments/:id_code/delete_confirm" => "comments#delete_confirm" + #Proper link format get "/:username/comment/:id_code" => "comments#index" get "/:username/comment/:id_code/edit" => "comments#edit" get "/:username/comment/:id_code/delete_confirm" => "comments#delete_confirm" + get "/:username/comment/:id_code/mod" => "moderations#comment" + get "/:username/:slug/:view" => "stories#show", constraints: { view: /moderate/} + get "/:username/:slug/mod" => "moderations#article" get "/:username/:slug/edit" => "articles#edit" get "/:username/:slug/delete_confirm" => "articles#delete_confirm" get "/:username/:view" => "stories#index", constraints: { view: /comments|moderate|admin/} diff --git a/spec/requests/moderations_spec.rb b/spec/requests/moderations_spec.rb new file mode 100644 index 000000000..f1bb5d406 --- /dev/null +++ b/spec/requests/moderations_spec.rb @@ -0,0 +1,42 @@ +require "rails_helper" + +RSpec.describe "Moderations", type: :request do + let(:user) { create(:user) } + let(:article) { create(:article, user_id: user.id) } + let(:comment) do + create(:comment, + commentable_id: article.id, + commentable_type: "Article", + user_id: user.id) + end + + before do + sign_in user + end + + describe "GET moderations article" do + it "returns 200 if user trusted" do + user.add_role :trusted + get article.path + "/mod" + expect(response).to have_http_status(200) + end + it "returns 404 if user trusted not trusted" do + expect do + get article.path + "/mod" + end.to raise_error(ActionController::RoutingError) + end + end + + describe "GET moderations comment" do + it "returns 200 if user trusted" do + user.add_role :trusted + get comment.path + "/mod" + expect(response).to have_http_status(200) + end + it "returns 404 if user trusted not trusted" do + expect do + get comment.path + "/mod" + end.to raise_error(ActionController::RoutingError) + end + end +end \ No newline at end of file