From db9792894d77dd947d690d0fb6ac7f30ebb8d73d Mon Sep 17 00:00:00 2001 From: Pablo Brasero Date: Tue, 9 Dec 2025 12:59:57 +0000 Subject: [PATCH] Add user setting to show/hide their heatmap --- app/models/user.rb | 1 + .../20251218105716_add_public_heatmap_to_users.rb | 7 +++++++ db/structure.sql | 4 +++- test/models/user_test.rb | 11 +++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20251218105716_add_public_heatmap_to_users.rb diff --git a/app/models/user.rb b/app/models/user.rb index 53d70464c..127d62774 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -37,6 +37,7 @@ # note_comments_count :integer default(0) # creation_address :inet # company :string +# public_heatmap :boolean default(TRUE), not null # # Indexes # diff --git a/db/migrate/20251218105716_add_public_heatmap_to_users.rb b/db/migrate/20251218105716_add_public_heatmap_to_users.rb new file mode 100644 index 000000000..e810e4b12 --- /dev/null +++ b/db/migrate/20251218105716_add_public_heatmap_to_users.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddPublicHeatmapToUsers < ActiveRecord::Migration[8.1] + def change + add_column :users, :public_heatmap, :boolean, :default => true, :null => false + end +end diff --git a/db/structure.sql b/db/structure.sql index 519dc858c..6b13ee431 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1593,7 +1593,8 @@ CREATE TABLE public.users ( note_comments_count integer DEFAULT 0, creation_address inet, home_location_name character varying, - company character varying + company character varying, + public_heatmap boolean DEFAULT true NOT NULL ); @@ -3569,6 +3570,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('23'), ('22'), ('21'), +('20251218105716'), ('20251121134648'), ('20250704143751'), ('20250506052030'), diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 1b4b4d548..db52692ec 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -227,6 +227,17 @@ class UserTest < ActiveSupport::TestCase assert_raise(ActiveRecord::RecordInvalid) { user.save! } end + def test_heatmap_public_by_default + # A bit roundabout, but want to make sure that + # the factory doesn't betray us here by setting + # a default value. + attrs = attributes_for(:user) + attrs.delete(:public_heatmap) + user = User.new(attrs) + user.save! + assert_predicate user, :public_heatmap? + end + def test_visible pending = create(:user, :pending) active = create(:user, :active) -- 2.39.5