From 62400272bf1ef6fca275aaea8cd4dec339f616f2 Mon Sep 17 00:00:00 2001 From: Tim Diggins Date: Thu, 28 May 2020 16:00:22 +0100 Subject: [PATCH 1/2] add in a couple of smoke tests of moderation controller. I noticed that there are no specs of moderation controller at all To increase confidence a bit, it might be helfpul to have these very basic smoke tests. --- .../controllers/thredded/moderation_controller_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/controllers/thredded/moderation_controller_spec.rb b/spec/controllers/thredded/moderation_controller_spec.rb index ffcebde98..61ed1fadc 100644 --- a/spec/controllers/thredded/moderation_controller_spec.rb +++ b/spec/controllers/thredded/moderation_controller_spec.rb @@ -15,4 +15,14 @@ expect(response).to be_successful expect(assigns(:posts).to_a.length).to eq(1) end + + it 'GET #history' do + create(:topic, with_posts: 1) + get :history + end + + it 'GET #activity' do + create(:topic, with_posts: 1) + get :activity + end end From f239146771e4bc4c0f36766fb3a0d33178ad6472 Mon Sep 17 00:00:00 2001 From: Tim Diggins Date: Thu, 28 May 2020 16:19:50 +0100 Subject: [PATCH 2/2] add working (though no-op) PostModerationRecordPolicy --- app/controllers/thredded/moderation_controller.rb | 1 + .../thredded/post_moderation_record_policy.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 app/policies/thredded/post_moderation_record_policy.rb diff --git a/app/controllers/thredded/moderation_controller.rb b/app/controllers/thredded/moderation_controller.rb index 43a8f4277..50c39f2bc 100644 --- a/app/controllers/thredded/moderation_controller.rb +++ b/app/controllers/thredded/moderation_controller.rb @@ -21,6 +21,7 @@ def history .send(Kaminari.config.page_method_name, current_page) .preload(:messageboard, :post_user, :moderator, post: :postable) .preload_first_topic_post + authorize @post_moderation_records end def activity diff --git a/app/policies/thredded/post_moderation_record_policy.rb b/app/policies/thredded/post_moderation_record_policy.rb new file mode 100644 index 000000000..12e996ab8 --- /dev/null +++ b/app/policies/thredded/post_moderation_record_policy.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Thredded + class PostModerationRecordPolicy + def initialize(user, scope) + @user = user + @scope = scope + end + + def history? + true + end + end +end