DEV: Remove draft attributes from topic lists (#12525)

DEV: Remove draft attributes from topic lists (#12525)

diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index e607079..b632d6b 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -258,10 +258,6 @@ class CategoriesController < ApplicationController
       result.topic_list = TopicQuery.new(nil, topic_options).list_top_for(SiteSetting.top_page_default_timeframe.to_sym)
     end
 
-    result.topic_list.draft = result.category_list.draft
-    result.topic_list.draft_key = result.category_list.draft_key
-    result.topic_list.draft_sequence = result.category_list.draft_sequence
-
     render_serialized(result, CategoryAndTopicListsSerializer, root: false)
   end
 
diff --git a/app/models/category_list.rb b/app/models/category_list.rb
index 32efd7f..7488a76 100644
--- a/app/models/category_list.rb
+++ b/app/models/category_list.rb
@@ -1,6 +1,8 @@
 # frozen_string_literal: true
 
-class CategoryList < DraftableList
+class CategoryList
+  include ActiveModel::Serialization
+
   cattr_accessor :preloaded_topic_custom_fields
   self.preloaded_topic_custom_fields = Set.new
 
@@ -33,7 +35,6 @@ class CategoryList < DraftableList
       end
     end
 
-    super(@guardian.user)
   end
 
   def preload_key
diff --git a/app/models/draftable_list.rb b/app/models/draftable_list.rb
deleted file mode 100644
index 3a641a7..0000000
--- a/app/models/draftable_list.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-class DraftableList
-  include ActiveModel::Serialization
-
-  def initialize(user)
-    @current_user = user
-  end
-
-  def draft_key
-    @draft_key || Draft::NEW_TOPIC
-  end
-
-  def draft_sequence
-    @draft_sequence || DraftSequence.current(@current_user, draft_key)
-  end
-
-  def draft
-    @draft || Draft.get(@current_user, draft_key, draft_sequence) if @current_user
-  end
-
-  def draft_key=(key)
-    @draft_key = key
-  end
-
-  def draft_sequence=(sequence)
-    @draft_sequence = sequence
-  end
-
-  def draft=(draft)
-    @draft = draft
-  end
-end
diff --git a/app/models/topic_list.rb b/app/models/topic_list.rb
index 9a69fe1..4308d88 100644
--- a/app/models/topic_list.rb
+++ b/app/models/topic_list.rb
@@ -1,6 +1,8 @@
 # frozen_string_literal: true
 
-class TopicList < DraftableList
+class TopicList
+  include ActiveModel::Serialization
+
   cattr_accessor :preloaded_custom_fields
   self.preloaded_custom_fields = Set.new
 
@@ -52,8 +54,6 @@ class TopicList < DraftableList
     end
 
     @publish_read_state = !!@opts[:publish_read_state]
-
-    super(current_user)
   end
 
   def top_tags
diff --git a/app/serializers/category_list_serializer.rb b/app/serializers/category_list_serializer.rb
index 275108b..1fe73e2 100644
--- a/app/serializers/category_list_serializer.rb
+++ b/app/serializers/category_list_serializer.rb
@@ -3,10 +3,7 @@
 class CategoryListSerializer < ApplicationSerializer
 
   attributes :can_create_category,
-             :can_create_topic,
-             :draft,
-             :draft_key,
-             :draft_sequence
+             :can_create_topic
 
   has_many :categories, serializer: CategoryDetailedSerializer, embed: :objects
 
diff --git a/app/serializers/top_list_serializer.rb b/app/serializers/top_list_serializer.rb
index 195f922..291089d 100644
--- a/app/serializers/top_list_serializer.rb
+++ b/app/serializers/top_list_serializer.rb
@@ -2,10 +2,7 @@
 
 class TopListSerializer < ApplicationSerializer
 
-  attributes :can_create_topic,
-             :draft,
-             :draft_key,
-             :draft_sequence
+  attributes :can_create_topic
 
   def can_create_topic
     scope.can_create?(Topic)
diff --git a/app/serializers/topic_list_serializer.rb b/app/serializers/topic_list_serializer.rb
index 2766f9c..a3ece48 100644
--- a/app/serializers/topic_list_serializer.rb
+++ b/app/serializers/topic_list_serializer.rb
@@ -4,9 +4,6 @@ class TopicListSerializer < ApplicationSerializer
 
   attributes :can_create_topic,
              :more_topics_url,
-             :draft,
-             :draft_key,
-             :draft_sequence,
              :for_period,
              :per_page,
              :top_tags,
diff --git a/spec/requests/api/categories_spec.rb b/spec/requests/api/categories_spec.rb
index 938f110..e131112 100644
--- a/spec/requests/api/categories_spec.rb
+++ b/spec/requests/api/categories_spec.rb
@@ -33,7 +33,7 @@ describe 'categories' do
       end
     end
 
-    get 'Retreives a list of categories' do
+    get 'Retrieves a list of categories' do
       tags 'Categories'
       consumes 'application/json'
       expected_request_schema = nil
diff --git a/spec/requests/api/schemas/json/category_list_response.json b/spec/requests/api/schemas/json/category_list_response.json
index e4a7fa5..1aa3c8f 100644
--- a/spec/requests/api/schemas/json/category_list_response.json
+++ b/spec/requests/api/schemas/json/category_list_response.json
@@ -11,18 +11,6 @@
         "can_create_topic": {
           "type": "boolean"
         },
-        "draft": {
-          "type": [
-            "string",
-            "null"
-          ]
-        },
-        "draft_key": {
-          "type": "string"
-        },
-        "draft_sequence": {
-          "type": "integer"
-        },
         "categories": {
           "type": "array",
           "items": [
diff --git a/spec/requests/api/schemas/json/category_topics_response.json b/spec/requests/api/schemas/json/category_topics_response.json
index 772d42b..472616b 100644
--- a/spec/requests/api/schemas/json/category_topics_response.json
+++ b/spec/requests/api/schemas/json/category_topics_response.json
@@ -43,18 +43,6 @@
         "can_create_topic": {
           "type": "boolean"
         },
-        "draft": {
-          "type": [
-            "string",
-            "null"
-          ]
-        },
-        "draft_key": {
-          "type": "string"
-        },
-        "draft_sequence": {
-          "type": "integer"
-        },
         "per_page": {
           "type": "integer"
         },
@@ -238,9 +226,6 @@
       },
       "required": [
         "can_create_topic",
-        "draft",
-        "draft_key",
-        "draft_sequence",
         "per_page",
         "topics"
       ]
diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rb
index 6fce406..ddbc383 100644
--- a/spec/requests/categories_controller_spec.rb
+++ b/spec/requests/categories_controller_spec.rb
@@ -57,8 +57,6 @@ describe CategoriesController do
     it 'returns the right response for a normal user' do
       sign_in(user)
 
-      Draft.set(user, Draft::NEW_TOPIC, 0, 'hello')
-
       get "/categories.json"
 
       expect(response.status).to eq(200)
@@ -68,10 +66,6 @@ describe CategoriesController do
       expect(category_list["categories"].map { |c| c["id"] }).to contain_exactly(
         SiteSetting.get(:uncategorized_category_id), category.id
       )
-
-      expect(category_list["draft_sequence"]).to eq(0)
-      expect(category_list["draft_key"]).to eq(Draft::NEW_TOPIC)
-      expect(category_list["draft"]).to eq('hello')
     end
   end
 
@@ -511,14 +505,7 @@ describe CategoriesController do
       topic_list = json['topic_list']
 
       expect(category_list['categories'].size).to eq(2) # 'Uncategorized' and category
-      expect(category_list['draft_key']).to eq(Draft::NEW_TOPIC)
-      expect(category_list['draft_sequence']).to eq(nil)
-      expect(category_list['draft']).to eq(nil)
-
       expect(topic_list['topics'].size).to eq(5)
-      expect(topic_list['draft_key']).to eq(Draft::NEW_TOPIC)
-      expect(topic_list['draft_sequence']).to eq(nil)
-      expect(topic_list['draft']).to eq(nil)
 
       Fabricate(:category, parent_category: category)
 
diff --git a/spec/requests/tags_controller_spec.rb b/spec/requests/tags_controller_spec.rb
index cecb8a4..0232aa3 100644
--- a/spec/requests/tags_controller_spec.rb
+++ b/spec/requests/tags_controller_spec.rb

[... diff too long, it was truncated ...]

GitHub sha: 65ad8750

This commit appears in #12525 which was approved by eviltrout. It was merged by pmusaraj.