Skip to content

A platform for community discussion. Free, open, simple.

DEV: Change cakeday and cakeday_birthday to off by default (#36274)

Jarek Radoszb10ea7929f59
diff --git a/plugins/discourse-cakeday/config/settings.yml b/plugins/discourse-cakeday/config/settings.yml
index 688cc0e5fa3..19e416dea55 100644
--- a/plugins/discourse-cakeday/config/settings.yml
+++ b/plugins/discourse-cakeday/config/settings.yml
@@ -1,12 +1,12 @@
plugins:
cakeday_enabled:
- default: true
+ default: false
client: true
cakeday_emoji:
default: 'cake'
client: true
cakeday_birthday_enabled:
- default: true
+ default: false
client: true
cakeday_birthday_emoji:
default: 'birthday'
diff --git a/plugins/discourse-cakeday/db/migrate/20251127125226_delete_old_default_values.rb b/plugins/discourse-cakeday/db/migrate/20251127125226_delete_old_default_values.rb
new file mode 100644
index 00000000000..a32601ba7c2
--- /dev/null
+++ b/plugins/discourse-cakeday/db/migrate/20251127125226_delete_old_default_values.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class DeleteOldDefaultValues < ActiveRecord::Migration[8.0]
+ def up
+ delete_setting("cakeday_enabled", migration_timestamp("20250717093505"))
+ delete_setting("cakeday_birthday_enabled", migration_timestamp("20250811132217"))
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+
+ private
+
+ def migration_timestamp(version)
+ DB.query_single(<<~SQL, version:).first
+ SELECT created_at
+ FROM schema_migration_details
+ WHERE version = :version
+ SQL
+ end
+
+ def delete_setting(name, time)
+ DB.exec(<<~SQL, name:, time:)
+ DELETE FROM site_settings
+ WHERE
+ name = :name AND
+ created_at >= timestamp :time - interval '10 seconds' AND
+ created_at <= timestamp :time + interval '10 seconds' AND
+ updated_at >= timestamp :time - interval '10 seconds' AND
+ updated_at <= timestamp :time + interval '10 seconds'
+ SQL
+ end
+end
diff --git a/plugins/discourse-cakeday/spec/serializers/post_serializer_spec.rb b/plugins/discourse-cakeday/spec/serializers/post_serializer_spec.rb
index 80ee11dae9e..0cb33f7a891 100644
--- a/plugins/discourse-cakeday/spec/serializers/post_serializer_spec.rb
+++ b/plugins/discourse-cakeday/spec/serializers/post_serializer_spec.rb
@@ -8,22 +8,30 @@ RSpec.describe PostSerializer do
let(:serializer) { described_class.new(post, scope: Guardian.new(user), root: false) }
it "includes both the user's birthdate and cakedate" do
+ SiteSetting.cakeday_enabled = true
+ SiteSetting.cakeday_birthday_enabled = true
expect(serializer.as_json[:user_birthdate]).to eq(user.date_of_birth)
expect(serializer.as_json[:user_cakedate]).to eq(user.created_at.strftime("%Y-%m-%d"))
end
it "does not include the user's cakedate when cakeday_enabled is false" do
SiteSetting.cakeday_enabled = false
+ SiteSetting.cakeday_birthday_enabled = true
expect(serializer.as_json.has_key?(:user_cakedate)).to eq(false)
end
it "does not include the user's birthdate when cakeday_birthday_enabled is false" do
+ SiteSetting.cakeday_enabled = true
SiteSetting.cakeday_birthday_enabled = false
expect(serializer.as_json.has_key?(:user_birthdate)).to eq(false)
end
context "when user has hidden their profile" do
- before { user.user_option.update!(hide_profile: true) }
+ before do
+ SiteSetting.cakeday_enabled = true
+ SiteSetting.cakeday_birthday_enabled = true
+ user.user_option.update!(hide_profile: true)
+ end
it "does not include the user's cakedate" do
expect(serializer.as_json.has_key?(:user_cakedate)).to eq(false)
@@ -36,6 +44,11 @@ RSpec.describe PostSerializer do
end
context "when user is not logged in" do
+ before do
+ SiteSetting.cakeday_enabled = true
+ SiteSetting.cakeday_birthday_enabled = true
+ end
+
let(:serializer) { described_class.new(post, scope: Guardian.new, root: false) }
it "does not include the user's birthdate nor the cakedate" do
diff --git a/plugins/discourse-cakeday/spec/serializers/user_serializer_spec.rb b/plugins/discourse-cakeday/spec/serializers/user_serializer_spec.rb
index e7be8e19fcc..616dd70d9ae 100644
--- a/plugins/discourse-cakeday/spec/serializers/user_serializer_spec.rb
+++ b/plugins/discourse-cakeday/spec/serializers/user_serializer_spec.rb
@@ -7,22 +7,30 @@ RSpec.describe UserSerializer do
let(:serializer) { described_class.new(user, scope: Guardian.new(user), root: false) }
it "includes both the user's birthdate and cakedate" do
+ SiteSetting.cakeday_enabled = true
+ SiteSetting.cakeday_birthday_enabled = true
expect(serializer.as_json[:birthdate]).to eq(user.date_of_birth)
expect(serializer.as_json[:cakedate]).to eq(user.created_at.strftime("%Y-%m-%d"))
end
it "does not include the user's cakedate when cakeday_enabled is false" do
SiteSetting.cakeday_enabled = false
+ SiteSetting.cakeday_birthday_enabled = true
expect(serializer.as_json.has_key?(:cakedate)).to eq(false)
end
it "does not include the user's birthdate when cakeday_birthday_enabled is false" do
+ SiteSetting.cakeday_enabled = true
SiteSetting.cakeday_birthday_enabled = false
expect(serializer.as_json.has_key?(:birthdate)).to eq(false)
end
context "when user has hidden their profile" do
- before { user.user_option.update!(hide_profile: true) }
+ before do
+ SiteSetting.cakeday_enabled = true
+ SiteSetting.cakeday_birthday_enabled = true
+ user.user_option.update!(hide_profile: true)
+ end
it "does not include the user's cakedate" do
expect(serializer.as_json.has_key?(:user_cakedate)).to eq(false)
@@ -35,6 +43,11 @@ RSpec.describe UserSerializer do
end
context "when user is not logged in" do
+ before do
+ SiteSetting.cakeday_enabled = true
+ SiteSetting.cakeday_birthday_enabled = true
+ end
+
let(:serializer) { described_class.new(user, scope: Guardian.new, root: false) }
it "does not include the user's birthdate nor the cakedate" do
diff --git a/plugins/discourse-cakeday/spec/system/cakeday_user_summary_spec.rb b/plugins/discourse-cakeday/spec/system/cakeday_user_summary_spec.rb
index 992882085e2..eadcf75fddc 100644
--- a/plugins/discourse-cakeday/spec/system/cakeday_user_summary_spec.rb
+++ b/plugins/discourse-cakeday/spec/system/cakeday_user_summary_spec.rb
@@ -7,7 +7,11 @@ RSpec.describe "Cakeday/Birthday emojis" do
let(:user_page) { PageObjects::Pages::User.new }
let(:user_menu) { PageObjects::Components::UserMenu.new }
- before { sign_in(current_user) }
+ before do
+ SiteSetting.cakeday_enabled = true
+ SiteSetting.cakeday_birthday_enabled = true
+ sign_in(current_user)
+ end
context "for users with `created_at` and `date_of_birth` dates" do
fab!(:user_with_cakeday) { Fabricate(:user, created_at: CONTROL_DATE.prev_year) }
diff --git a/plugins/discourse-cakeday/spec/system/core_features_spec.rb b/plugins/discourse-cakeday/spec/system/core_features_spec.rb
index ea0fa3f5e4d..5a50b7c7c29 100644
--- a/plugins/discourse-cakeday/spec/system/core_features_spec.rb
+++ b/plugins/discourse-cakeday/spec/system/core_features_spec.rb
@@ -1,7 +1,10 @@
# frozen_string_literal: true
RSpec.describe "Core features" do
- before { enable_current_plugin }
+ before do
+ SiteSetting.cakeday_enabled = true
+ SiteSetting.cakeday_birthday_enabled = true
+ end
it_behaves_like "having working core features"
end