Revert "FEATURE: do not automatically approve first post (#33)" (#35)

Revert “FEATURE: do not automatically approve first post (#33)” (#35)

This reverts commit 083ca4f41b8b8db43ad467a35a5e8cb2f8113903.

diff --git a/lib/category_experts/post_handler.rb b/lib/category_experts/post_handler.rb
index 5ff46b5..30b2834 100644
--- a/lib/category_experts/post_handler.rb
+++ b/lib/category_experts/post_handler.rb
@@ -50,7 +50,6 @@ module CategoryExperts
 
     def mark_post_as_approved
       raise Discourse::InvalidParameters unless ensure_poster_is_category_expert
-      return if post.is_first_post?
 
       post.custom_fields[CategoryExperts::POST_APPROVED_GROUP_NAME] = users_expert_group.name
       post.custom_fields[CategoryExperts::POST_PENDING_EXPERT_APPROVAL] = false
diff --git a/spec/lib/post_handler_spec.rb b/spec/lib/post_handler_spec.rb
index 18ac22c..2f847e0 100644
--- a/spec/lib/post_handler_spec.rb
+++ b/spec/lib/post_handler_spec.rb
@@ -10,7 +10,6 @@ describe CategoryExperts::PostHandler do
   fab!(:group) { Fabricate(:group, users: [expert]) }
   fab!(:second_group) { Fabricate(:group, users: [second_expert]) }
   fab!(:topic) { Fabricate(:topic, category: category) }
-  fab!(:first_post) { Fabricate(:post, topic: topic) }
 
   before do
     SiteSetting.enable_category_experts
@@ -51,10 +50,7 @@ describe CategoryExperts::PostHandler do
       SiteSetting.category_experts_posts_require_approval = false
     end
 
-    it "marks posts as approved automatically but not the first post" do
-      expect(first_post.custom_fields[CategoryExperts::POST_APPROVED_GROUP_NAME]).to eq(nil)
-      expect(topic.custom_fields[CategoryExperts::TOPIC_EXPERT_POST_GROUP_NAMES]).to eq(nil)
-
+    it "marks posts as approved automatically" do
       result = NewPostManager.new(expert, raw: 'this is a new post', topic_id: topic.id).perform
 
       expect(result.post.custom_fields[CategoryExperts::POST_APPROVED_GROUP_NAME]).to eq(group.name)
diff --git a/spec/requests/category_experts_controller_spec.rb b/spec/requests/category_experts_controller_spec.rb
index 9da1621..0fc0468 100644
--- a/spec/requests/category_experts_controller_spec.rb
+++ b/spec/requests/category_experts_controller_spec.rb
@@ -114,7 +114,6 @@ describe CategoryExpertsController do
 
   describe "#approve_post" do
     fab!(:topic) { Fabricate(:topic, category: category1) }
-    fab!(:first_post) { Fabricate(:post, topic: topic) }
 
     before do
       create_post(topic_id: topic.id, user: user)
@@ -157,7 +156,7 @@ describe CategoryExpertsController do
       end
 
       it "adds the group names to the topic custom field when an approved post already exists" do
-        CategoryExperts::PostHandler.new(post: topic.posts.last).mark_post_as_approved
+        CategoryExperts::PostHandler.new(post: topic.first_post).mark_post_as_approved
 
         post = create_post(topic_id: topic.id, user: other_user)
         CategoryExperts::PostHandler.new(post: post).mark_post_for_approval
@@ -215,12 +214,12 @@ describe CategoryExpertsController do
       end
 
       it "doesn't remove the group name from the topic custom field if another approved post exists" do
+        CategoryExperts::PostHandler.new(post: topic.first_post).mark_post_as_approved
+
         post = create_post(topic_id: topic.id, user: user)
         CategoryExperts::PostHandler.new(post: post).mark_post_as_approved
 
-        post2 = create_post(topic_id: topic.id, user: user)
-        CategoryExperts::PostHandler.new(post: post2).mark_post_as_approved
-        post("/category-experts/unapprove.json", params: { post_id: post2.id })
+        post("/category-experts/unapprove.json", params: { post_id: post.id })
 
         expect(response.status).to eq(200)
 

GitHub sha: 272eec04

This commit appears in #35 which was merged by lis2.