FEATURE: enable tagging by default (#13175)

FEATURE: enable tagging by default (#13175)

Over the years we have found that a few communities never discovered tags.

Instead of having them default off we now have them default on, ensuring that everyone finds out about them.

Co-authored-by: Dan Ungureanu dan@ungureanu.me

diff --git a/config/site_settings.yml b/config/site_settings.yml
index a944842..da7b823 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -2396,7 +2396,7 @@ user_api:
 tags:
   tagging_enabled:
     client: true
-    default: false
+    default: true
     refresh: true
   tag_style:
     client: true
diff --git a/db/migrate/20210527114834_set_tagging_enabled.rb b/db/migrate/20210527114834_set_tagging_enabled.rb
new file mode 100644
index 0000000..73e9fa7
--- /dev/null
+++ b/db/migrate/20210527114834_set_tagging_enabled.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class SetTaggingEnabled < ActiveRecord::Migration[6.1]
+  def up
+    result = execute <<~SQL
+      SELECT created_at
+      FROM schema_migration_details
+      ORDER BY created_at
+      LIMIT 1
+    SQL
+
+    # keep tagging disabled for existing sites
+    if result.first['created_at'].to_datetime < 1.hour.ago
+      execute <<~SQL
+        INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
+        VALUES('tagging_enabled', 5, 'f', NOW(), NOW())
+        ON CONFLICT (name) DO NOTHING
+      SQL
+    end
+  end
+
+  def down
+    raise ActiveRecord::IrreversibleMigration
+  end
+end
diff --git a/spec/lib/search_spec.rb b/spec/lib/search_spec.rb
index 5e5cec5..86e9992 100644
--- a/spec/lib/search_spec.rb
+++ b/spec/lib/search_spec.rb
@@ -106,6 +106,7 @@ describe Search do
 
     it "includes custom tables" do
       begin
+        SiteSetting.tagging_enabled = false
         expect(Search.execute("test").posts[0].topic.association(:category).loaded?).to be true
         expect(Search.execute("test").posts[0].topic.association(:tags).loaded?).to be false
 
diff --git a/spec/requests/api/schemas/json/group_response.json b/spec/requests/api/schemas/json/group_response.json
index 7ba3520..c4b3111 100644
--- a/spec/requests/api/schemas/json/group_response.json
+++ b/spec/requests/api/schemas/json/group_response.json
@@ -280,6 +280,36 @@
           "items": [
 
           ]
+        },
+        "watching_tags": {
+          "type": "array",
+          "items": [
+
+          ]
+        },
+        "watching_first_post_tags": {
+          "type": "array",
+          "items": [
+
+          ]
+        },
+        "tracking_tags": {
+          "type": "array",
+          "items": [
+
+          ]
+        },
+        "regular_tags": {
+          "type": "array",
+          "items": [
+
+          ]
+        },
+        "muted_tags": {
+          "type": "array",
+          "items": [
+
+          ]
         }
       },
       "required": [
diff --git a/spec/serializers/topic_view_serializer_spec.rb b/spec/serializers/topic_view_serializer_spec.rb
index c7515a8..ac256d2 100644
--- a/spec/serializers/topic_view_serializer_spec.rb
+++ b/spec/serializers/topic_view_serializer_spec.rb
@@ -196,8 +196,6 @@ describe TopicViewSerializer do
     fab!(:staff_tag_group) { Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [hidden_tag.name]) }
 
     before do
-      SiteSetting.tagging_enabled = true
-      hidden_tag.tag_groups << staff_tag_group
       topic.tags << hidden_tag
     end
 
@@ -218,7 +216,6 @@ describe TopicViewSerializer do
     fab!(:tag3) { Fabricate(:tag, name: 'atag', topic_count: 3) }
 
     before do
-      SiteSetting.tagging_enabled = true
       topic.tags << tag1
       topic.tags << tag2
       topic.tags << tag3

GitHub sha: 435c4817

This commit appears in #13175 which was approved by riking, eviltrout, and ZogStriP. It was merged by udan11.