Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
Close the activity search, the inbox name and four untested places
Guido Boykeb64fae99f270
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.ymlindex 43a07d2..c427b01 100644--- a/.github/workflows/guards.yml+++ b/.github/workflows/guards.yml@@ -199,6 +199,8 @@ jobs:spec/lib/tasks/chats_purge_legacy_threads_spec.rbspec/lib/tasks/chats_scope_project_cleanup_spec.rbspec/lib/tasks/data_backfills_spec.rb+ spec/lib/tasks/activities_drop_member_emails_spec.rb+ spec/presenters/inbox/activity_line_spec.rbspec/mailers/spec/middleware/active_storage_tenant_bypass_spec.rbspec/migrations/remove_ticket_id_from_chats_spec.rbdiff --git a/app/controllers/organisations/projects/activities_controller.rb b/app/controllers/organisations/projects/activities_controller.rbindex 3819524..6704182 100644--- a/app/controllers/organisations/projects/activities_controller.rb+++ b/app/controllers/organisations/projects/activities_controller.rb@@ -163,7 +163,7 @@ class Organisations::Projects::ActivitiesController < Organisations::BaseControl<<~SQL.squish,activities.action ILIKE :pattern ORactivities.key ILIKE :pattern OR- CAST(activities.parameters AS TEXT) ILIKE :pattern OR+ CAST(activities.parameters - 'user_email' AS TEXT) ILIKE :pattern OR(activities.trackable_type = 'Ticket' AND activities.trackable_id IN (:ticket_ids)) OR(activities.secondary_type = 'Ticket' AND activities.secondary_id IN (:ticket_ids))SQLdiff --git a/app/controllers/user_preferences_controller.rb b/app/controllers/user_preferences_controller.rbindex bd7b7de..bd094ef 100644--- a/app/controllers/user_preferences_controller.rb+++ b/app/controllers/user_preferences_controller.rb@@ -41,10 +41,10 @@ class UserPreferencesController < ApplicationController# change (user decision 04.09.2026). Applied BEFORE the JSONB prefs so one# submit can carry both; a failed picture keeps the section rendered with# the model's own error message.- return if section == 'display' && user_param_hash? && !apply_avatar_update- # Which email the others see (User::EmailDisplay): a column on users, saved- # here and not in the Devise profile for the same reason as the picture.- return if section == 'display' && user_param_hash? && !apply_email_visibility_update+ # The picture and which email the others see (User::EmailDisplay) are+ # columns and an attachment on users, saved here in ONE update, so a+ # refused part leaves nothing half saved.+ return if section == 'display' && user_param_hash? && !apply_display_update# Handle language preference separatelyif section == 'language' && user_param_hash? && params[:user].key?(:language_preference)@@ -90,35 +90,30 @@ class UserPreferencesController < ApplicationControllerparams.require(:user).permit(:language_preference, :session_timeout_minutes)end- # Attach/remove the profile picture from the display section. Returns true- # when the rest of the update may proceed; renders the section itself (422)- # on a validation failure. Mass assignment through current_user.update on- # purpose: only that staged path runs the acceptable_avatar validation -- # a direct avatar.attach on a persisted record would bypass it.- def apply_avatar_update+ # The display section's own columns: the profile picture and which email the+ # others see. Returns true when the rest of the update may proceed; renders+ # the section itself (422) on a validation failure. Mass assignment through+ # current_user.update on purpose: only that staged path runs the+ # acceptable_avatar validation - a direct avatar.attach on a persisted record+ # would bypass it. Login address and password stay behind the Devise+ # profile's current-password gate.+ def apply_display_update+ permitted = avatar_changes.merge(params.require(:user).permit(:email_visibility, :contact_email).to_h)+ return true if permitted.empty?+ return true if current_user.update(permitted)++ render_display_errors+ end++ def avatar_changespermitted = params.require(:user).permit(:avatar, :remove_avatar, :avatar_crop_x, :avatar_crop_y, :avatar_crop_size)crop = { x: permitted.delete(:avatar_crop_x), y: permitted.delete(:avatar_crop_y),size: permitted.delete(:avatar_crop_size) }# An untouched file field submits "", and the has_one_attached writer# treats an empty string as DELETE - blank means "no change".permitted.delete(:avatar) if permitted[:avatar].blank?- return true if permitted.empty?-permitted[:avatar] = UserAvatars::CropUpload.call(upload: permitted[:avatar], crop: crop) if permitted[:avatar].present?- return true if current_user.update(permitted)-- render_display_errors- end-- # Which email the others see (User::EmailDisplay). Only these two columns: the- # login address and the password stay behind the Devise profile's- # current-password gate. Returns true when the rest of the update may proceed.- def apply_email_visibility_update- permitted = params.require(:user).permit(:email_visibility, :contact_email)- return true if permitted.empty?- return true if current_user.update(permitted)-- render_display_errors+ permitted.to_hend# The display section again, with the model's own error messages (422).diff --git a/app/models/activity.rb b/app/models/activity.rbindex cacffeb..b29535b 100644--- a/app/models/activity.rb+++ b/app/models/activity.rb@@ -200,12 +200,6 @@ class Activity < ApplicationRecordsecondary&.full_name || I18n.t('activities.deleted_user')end- def assignee_email- return nil unless %w[assigned unassigned].include?(action)-- secondary&.email || nil- end-def subscriber_display_namereturn nil unless %w[subscriber_added subscriber_removed].include?(action)diff --git a/app/models/codebase_import_file.rb b/app/models/codebase_import_file.rbindex 2e55087..74b2622 100644--- a/app/models/codebase_import_file.rb+++ b/app/models/codebase_import_file.rb@@ -112,7 +112,7 @@ class CodebaseImportFile < ApplicationRecordenddef uploaded_by_name- user.full_name || user.email+ user.display_nameend# Progress tracking for import jobsdiff --git a/app/models/concerns/project_trackable.rb b/app/models/concerns/project_trackable.rbindex eef643d..ee0f58c 100644--- a/app/models/concerns/project_trackable.rb+++ b/app/models/concerns/project_trackable.rb@@ -18,8 +18,11 @@ module ProjectTrackableaction: 'member_added',secondary: user,parameters: {+ # No email: the row is shown and searched by everyone who reads the+ # project's activities, and a member chooses which email the others see+ # (User::EmailDisplay). Older rows may still carry `user_email`; the+ # activity search leaves that key out.user_name: user.full_name,- user_email: user.email,tickets_access: permission_details[:tickets_access],notes_access: permission_details[:notes_access],documents_access: permission_details[:documents_access],diff --git a/app/presenters/inbox/activity_line.rb b/app/presenters/inbox/activity_line.rbindex b961ec0..5fe087a 100644--- a/app/presenters/inbox/activity_line.rb+++ b/app/presenters/inbox/activity_line.rb@@ -28,10 +28,9 @@ module Inboxactor = @notification.actorreturn I18n.t('views.organisations.notifications.item.system_actor', default: 'System') unless actor- actor.try(:full_name).presence ||- [actor.try(:first_name), actor.try(:last_name)].compact.join(' ').presence ||- actor.try(:email) ||- 'Unbekannt'+ # The one name rule (User#display_name): a member without a name is named+ # by the email they show to others, never by a hidden login address.+ actor.display_nameenddef time_agodiff --git a/app/services/lalabase/tools/recent_activity.rb b/app/services/lalabase/tools/recent_activity.rbindex 5516a1f..2ee5ccf 100644--- a/app/services/lalabase/tools/recent_activity.rb+++ b/app/services/lalabase/tools/recent_activity.rb@@ -28,8 +28,9 @@ module Lalabase# * `post_excerpt` (ticket.post_added) is comment CONTENT, and a comment# carries its own privacy (visible_to_user_id) that the :tickets area# does not express -- exactly the gap issue #267 describes,- # * `user_email` (project.member_added) is personal data the answer does- # not need to be useful.+ # * `user_email` (project.member_added, only on rows written before+ # 2026-10-29) is a login address the member may hide from others+ # (User::EmailDisplay).# Everything else that is not listed here is simply left out.SUBJECT_FIELDS = %w[display_name note_title document_title meeting_title ticket_title user_name].freezediff --git a/lib/lalabase/data_backfills.rb b/lib/lalabase/data_backfills.rbindex e8f6739..ae69953 100644--- a/lib/lalabase/data_backfills.rb+++ b/lib/lalabase/data_backfills.rb@@ -39,7 +39,11 @@ module Lalabase# (ProjectDeletionJob until 2026-10-08) go: a row without a project passes# the inbox rule as a system message. A row with a mail log stays (bounces).# Idempotent, and it may stay: it only deletes rows whose subject is gone.- 'notifications:purge_project_leftovers'+ 'notifications:purge_project_leftovers',+ # member_added activities written before 2026-10-29 lose the login address+ # they stored (`user_email`); a member chooses which email the others see.+ # Idempotent, and it may go once no installation is older than that.+ 'activities:drop_member_emails'].freezeendenddiff --git a/lib/tasks/activities_drop_member_emails.rake b/lib/tasks/activities_drop_member_emails.rakenew file mode 100644index 0000000..0280118--- /dev/null+++ b/lib/tasks/activities_drop_member_emails.rake@@ -0,0 +1,19 @@+# frozen_string_literal: true++namespace :activities do+ # A data backfill (Lalabase::DataBackfills::TASKS). Until 2026-10-29+ # ProjectTrackable#track_member_added stored the member's login address in the+ # activity's parameters (`user_email`). Everyone who reads the project's+ # members area sees those rows, and the activity search read the whole JSON,+ # so it confirmed an address a member may now hide (User::EmailDisplay). This+ # removes the key from the old rows; other parameters stay. Idempotent: the+ # second run finds no row with the key.+ desc 'Remove the stored login address from old member_added activities (a data backfill)'+ task drop_member_emails: :environment do+ removed = ActsAsTenant.without_tenant do+ Activity.unscoped.where('parameters ? :key', key: 'user_email')+ .update_all(['parameters = parameters - :key', { key: 'user_email' }])+ end+ puts "activities:drop_member_emails: #{removed} activities cleaned."+ end+enddiff --git a/spec/architecture/shown_email_guard_spec.rb b/spec/architecture/shown_email_guard_spec.rbindex d829dd6..794972f 100644--- a/spec/architecture/shown_email_guard_spec.rb+++ b/spec/architecture/shown_email_guard_spec.rb@@ -11,16 +11,22 @@ require 'rails_helper'# picker, the activity page and the import preview. A choice that each of# those has to remember is not a choice, so the bare read is refused here.#-# A tripwire, not a proof: it reads `<receiver>.email` / `<receiver>&.email` in-# Ruby, ERB and JavaScript. It does not see an email reached through `send`,-# `[:email]`, `pluck(:email)`, `as_json` of a whole user, or a SQL fragment.+# A tripwire, not a proof: it reads `<receiver>.email`, `<receiver>&.email`,+# `try(:email)` and `send(:email)` in Ruby, ERB and JavaScript, and refuses an+# email key in the parameters an activity stores (activities are shown and+# searched by everyone who reads the project). It does not see `[:email]`,+# `pluck(:email)`, `as_json` of a whole user, or a SQL fragment.module ShownEmailGuard- ROOTS = %w[app/controllers app/services app/views app/helpers app/components app/javascript].freeze+ ROOTS = %w[app/controllers app/services app/views app/helpers app/components app/javascript+ app/presenters app/models app/jobs app/queries].freeze- # The account owner's own view, Lalabase's own mail, Devise and the instance- # admin area keep the login address on purpose (User::EmailDisplay header).- EXCLUDED = %r{\Aapp/(?:views|controllers|services)/admin/|\Aapp/views/devise/|\Aapp/controllers/users/|- mailers?/|_mailer|\Aapp/views/user_data_exports/|\Aapp/services/user_data_exports/}x+ # The account owner's own view, Lalabase's own mail, Devise, the data export+ # and the instance admin area keep the login address on purpose+ # (User::EmailDisplay header). Anchored, so a file elsewhere whose name only+ # contains one of these words is still read.+ EXCLUDED = %r{\Aapp/(?:views|controllers|services|models)/admin/|\Aapp/views/devise/|\Aapp/controllers/users/|+ \Aapp/mailers/|\Aapp/views/[a-z_]+_mailer/|\Aapp/views/layouts/[a-z_]*mailer|+ \Aapp/views/user_data_exports/|\Aapp/services/user_data_exports/}x# Receivers whose `.email` is not a member's login address shown to others.SAFE_RECEIVERS = {@@ -44,10 +50,31 @@ module ShownEmailGuard['app/services/notifications/score_calculator.rb', '@recipient'] =>"compares the recipient's own address with a rule value, nothing is shown",['app/javascript/controllers/subscriber_picker_controller.js', 'user'] =>- 'reads the JSON field `email`, which the server fills with User#shown_email'+ 'reads the JSON field `email`, which the server fills with User#shown_email',+ ['app/jobs/email_delivery_job.rb', 'recipient'] =>+ "Lalabase's own mail goes to the login address of its recipient",+ ['app/jobs/email_webhook_processor_job.rb', 'recipient'] =>+ 'a server log line about a bounced or complained mail, never rendered',+ ['app/models/email_log.rb', 'recipient'] =>+ "the address Lalabase's own mail was sent to",+ ['app/models/user/deletion_lifecycle.rb', 'self'] =>+ 'writes the tombstone address of an erased account',+ ['app/models/user/email_display.rb', 'users'] =>+ 'the owner itself: the SQL branch for members who show their login address',+ ['app/models/user_activity.rb', 'user'] =>+ 'a server security log line about the account itself, never rendered',+ ['app/models/user_deletion.rb', 'deleted_user'] =>+ 'the deletion audit record of the instance admin area'}.freeze- CALL = /(?<receiver>@?[A-Za-z_]\w*)(?:\.|&\.)email\b(?![\w?!=])/+ CALL = /(?<receiver>@?[A-Za-z_]\w*)(?:(?:\.|&\.)email\b(?![\w?!=])|(?:\.|&\.)(?:try|send|public_send)\(:email\))/++ # Where activities are written: an email key there is stored for every reader+ # of the project's history, and the activity search reads the whole JSON.+ # (UserTrackable writes the account's own security log, UserActivity, which is+ # not the project history; it is not listed here.)+ ACTIVITY_WRITERS = '{app/models/concerns/trackable.rb,app/models/concerns/{project,ticket,person}_trackable.rb}'+ EMAIL_KEY = /\b\w*email\w*:\s|['"]\w*email\w*['"]\s*=>/def self.filesROOTS.flat_map { |root| Dir[Rails.root.join(root, '**', '*.{rb,erb,js}')] }@@ -80,6 +107,19 @@ RSpec.describe ShownEmailGuard, :ci_guard do}end+ it 'stores no email in the parameters of an activity' do+ findings = Dir[Rails.root.join(described_class::ACTIVITY_WRITERS)].sort.flat_map do |path|+ File.readlines(path).each_with_index.filter_map do |line, index|+ next if line.match?(/\A\s*#/) || !line.match?(described_class::EMAIL_KEY)++ "#{Pathname(path).relative_path_from(Rails.root)}:#{index + 1}: #{line.strip}"+ end+ end++ expect(Dir[Rails.root.join(described_class::ACTIVITY_WRITERS)]).not_to be_empty+ expect(findings).to be_empty, "An activity is read by everyone in the project; store no email:\n#{findings.join("\n")}"+ end+it 'keeps no allow-list entry without a finding' dofound = described_class.findings.to_set { |file, receiver, *| [file, receiver] }stale = described_class::ALLOWED.keys.reject { |key| found.include?(key) }@@ -92,8 +132,9 @@ RSpec.describe ShownEmailGuard, :ci_guard doexpect(files).to include('app/views/organisations/memberships/_member.html.erb','app/services/people/directory.rb', 'app/services/people/lookup.rb',- 'app/javascript/controllers/subscriber_picker_controller.js')- expect(files).not_to include('app/views/devise/registrations/edit.html.erb')+ 'app/javascript/controllers/subscriber_picker_controller.js',+ 'app/presenters/inbox/activity_line.rb', 'app/models/activity.rb')+ expect(files).not_to include('app/views/devise/registrations/edit.html.erb', 'app/mailers/notification_mailer.rb')endit 'sees a bare read in Ruby, ERB and JavaScript, and lets the shown email pass' do@@ -105,5 +146,10 @@ RSpec.describe ShownEmailGuard, :ci_guard doexpect(probe.call('membership.user.shown_email')).to eq([])expect(probe.call('user.email_visibility')).to eq([])expect(probe.call('user.email?')).to eq([])+ expect(probe.call('actor.try(:email)')).to eq(['actor'])+ expect(probe.call('user.send(:email)')).to eq(['user'])+ expect('user_email: user.email,').to match(described_class::EMAIL_KEY)+ expect("'user_email' => x").to match(described_class::EMAIL_KEY)+ expect('user_name: user.full_name,').not_to match(described_class::EMAIL_KEY)endenddiff --git a/spec/components/neo_filter_bar_component_spec.rb b/spec/components/neo_filter_bar_component_spec.rbindex b3385a6..f7aa172 100644--- a/spec/components/neo_filter_bar_component_spec.rb+++ b/spec/components/neo_filter_bar_component_spec.rb@@ -637,6 +637,16 @@ RSpec.describe NeoFilterBarComponent, type: :component doexpect(labels[referenced_user.id]).to eq(referenced_user.display_name)end+ # A user without a name is labelled like everywhere else, never by a hidden+ # login address (User::EmailDisplay).+ it 'never labels a nameless user by a hidden login address' do+ referenced_user.update!(first_name: nil, last_name: nil, email: '[email protected]', email_visibility: 'none')++ labels = JSON.parse(build(ad_hoc_filters: { 'assignee' => [referenced_user.id] }).send(:value_labels_json))++ expect(labels[referenced_user.id]).to eq(I18n.t('users.unnamed'))+ end+it 'maps a creator user-id to the user display name' dolabels = JSON.parse(build(ad_hoc_filters: { 'creator' => [referenced_user.id] }).send(:value_labels_json))expect(labels[referenced_user.id]).to eq(referenced_user.display_name)diff --git a/spec/components/overview/activity_feed_component_spec.rb b/spec/components/overview/activity_feed_component_spec.rbindex 0d075fd..2e55ac8 100644--- a/spec/components/overview/activity_feed_component_spec.rb+++ b/spec/components/overview/activity_feed_component_spec.rb@@ -41,6 +41,23 @@ RSpec.describe Overview::ActivityFeedComponent, type: :component doexpect(page).to have_text(I18n.t('dashboard.briefing.sections.activity.title'))end+ # A nameless actor is named like everywhere else, never by the part before the+ # @ of a hidden login address (User::EmailDisplay).+ it 'never names a nameless actor by a hidden login address' do+ ghost = build(:user, first_name: nil, last_name: nil, email: '[email protected]', email_visibility: 'none')+ group = instance_double(Dashboard::BriefingActivityGroup,+ icon: 'pencil', css_class: 'text-cobalt-600', trackable: nil,+ trackable_display_name: 'Some note', headline_action: 'updated',+ secondary_count: 0, actor: ghost, latest_at: 1.hour.ago)+ allow(briefing).to receive(:recent_activities_others).and_return([group])++ render_inline(build_component)++ expect(page).to have_text('Some note')+ expect(page).to have_text(I18n.t('users.unnamed'))+ expect(page).to have_no_text('ghost-login')+ end+it 'passes an explicit whitelisted limit through to the briefing' doexpect(briefing).to receive(:recent_activities_others).with(limit: 10).and_return([])render_inline(build_component(limit: 10))diff --git a/spec/lib/tasks/activities_drop_member_emails_spec.rb b/spec/lib/tasks/activities_drop_member_emails_spec.rbnew file mode 100644index 0000000..20ea19f--- /dev/null+++ b/spec/lib/tasks/activities_drop_member_emails_spec.rb@@ -0,0 +1,51 @@+# frozen_string_literal: true++require 'rails_helper'+require 'rake'++# What: `rake activities:drop_member_emails`, a data backfill.+# Why: project.member_added stored the member's login address in its parameters+# until 2026-10-29. Every reader of the project's members area sees and+# searches those rows, and a member now chooses which email the others see+# (User::EmailDisplay). The task removes the key from the old rows.+RSpec.describe 'activities:drop_member_emails', :ci_guard do+ before(:all) do+ Rails.application.load_tasks unless Rake::Task.task_defined?('activities:drop_member_emails')+ end++ before { Rake::Task['activities:drop_member_emails'].reenable }++ let(:organisation) { create(:organisation) }+ let(:project) { create(:project, organisation: organisation) }+ let(:member) { create(:user, email: '[email protected]') }++ def activity_with(parameters)+ ActsAsTenant.with_tenant(organisation) do+ create(:activity, trackable: project, organisation: organisation, secondary: member,+ key: 'project.member_added', action: 'member_added', parameters: parameters)+ end+ end++ it 'removes the stored login address and keeps every other parameter' do+ old_row = activity_with('user_name' => 'Mia Mitglied', 'user_email' => '[email protected]', 'tickets_access' => 'read_only')++ expect { Rake::Task['activities:drop_member_emails'].invoke }.to output(/1 activities/).to_stdout++ expect(old_row.reload.parameters).to eq('user_name' => 'Mia Mitglied', 'tickets_access' => 'read_only')+ end++ it 'leaves rows without the key alone and touches nothing the second time' do+ new_row = activity_with('user_name' => 'Mia Mitglied')+ activity_with('user_email' => '[email protected]')++ expect { Rake::Task['activities:drop_member_emails'].invoke }.to output(/1 activities/).to_stdout+ Rake::Task['activities:drop_member_emails'].reenable+ expect { Rake::Task['activities:drop_member_emails'].invoke }.to output(/0 activities/).to_stdout++ expect(new_row.reload.parameters).to eq('user_name' => 'Mia Mitglied')+ end++ it 'runs on every deploy' do+ expect(Lalabase::DataBackfills::TASKS).to include('activities:drop_member_emails')+ end+enddiff --git a/spec/models/activity_spec.rb b/spec/models/activity_spec.rbindex 4395021..c2c2cd6 100644--- a/spec/models/activity_spec.rb+++ b/spec/models/activity_spec.rb@@ -568,23 +568,6 @@ RSpec.describe Activity, type: :model doendend- describe '#assignee_email' do- it 'returns email for assignment actions' do- activity = create_activity(action: 'assigned', key: 'ticket.assigned', secondary: assignee)- expect(activity.assignee_email).to eq(assignee.email)- end-- it 'returns nil for non-assignment actions' do- activity = create_activity(action: 'created')- expect(activity.assignee_email).to be_nil- end-- it 'returns nil when secondary is nil' do- activity = create_activity(action: 'assigned', key: 'ticket.assigned', secondary: nil)- expect(activity.assignee_email).to be_nil- end- end-describe '#subscriber_display_name' doit 'returns display_name for subscriber_added' doactivity = create_activity(action: 'subscriber_added', key: 'ticket.subscriber_added', secondary: assignee)diff --git a/spec/models/activity_user_data_spec.rb b/spec/models/activity_user_data_spec.rbindex f98d6cb..e95751f 100644--- a/spec/models/activity_user_data_spec.rb+++ b/spec/models/activity_user_data_spec.rb@@ -74,7 +74,9 @@ RSpec.describe 'Activity user data handling', type: :model do# Helper methods should retrieve data from associationexpect(activity.assignee_display_name).to eq(assignee.full_name)- expect(activity.assignee_email).to eq(assignee.email)+ # No email reader: an activity is shown to everyone who reads the+ # ticket, and a member chooses which email the others see.+ expect(activity).not_to respond_to(:assignee_email)endit 'handles deleted users gracefully' do@@ -87,7 +89,6 @@ RSpec.describe 'Activity user data handling', type: :model do# Should return fallback for deleted userexpect(activity.assignee_display_name).to eq(I18n.t('activities.deleted_user'))- expect(activity.assignee_email).to be_nilendenddiff --git a/spec/presenters/inbox/activity_line_spec.rb b/spec/presenters/inbox/activity_line_spec.rbnew file mode 100644index 0000000..cbbd65a--- /dev/null+++ b/spec/presenters/inbox/activity_line_spec.rb@@ -0,0 +1,29 @@+# frozen_string_literal: true++require 'rails_helper'++# The actor of an inbox line is named like everywhere else (User#display_name):+# a member without a name never appears with the login address they hide+# (User::EmailDisplay).+RSpec.describe Inbox::ActivityLine, :ci_guard do+ def line_for(actor)+ described_class.new(instance_double(Notification, actor: actor))+ end++ it 'names the actor by name' do+ expect(line_for(build(:user, first_name: 'Nina', last_name: 'Beispiel')).actor_name).to eq('Nina Beispiel')+ end++ it 'never names a nameless actor by a hidden login address' do+ ghost = build(:user, first_name: nil, last_name: nil, email: '[email protected]', email_visibility: 'none')++ expect(line_for(ghost).actor_name).to eq(I18n.t('users.unnamed'))+ end++ it 'names a nameless actor who shows a contact address by that address' do+ ghost = build(:user, first_name: nil, last_name: nil, email: '[email protected]',+ email_visibility: 'contact', contact_email: '[email protected]')++ expect(line_for(ghost).actor_name).to eq('ghost.team')+ end+enddiff --git a/spec/requests/organisations/shown_email_spec.rb b/spec/requests/organisations/shown_email_spec.rbindex 14bf9e2..334546d 100644--- a/spec/requests/organisations/shown_email_spec.rb+++ b/spec/requests/organisations/shown_email_spec.rb@@ -95,6 +95,19 @@ RSpec.describe 'The email a member shows to others', :ci_guard, type: :request dexpect_no_hidden_login_address(response.body)end+ # Ties in the name break on the SHOWN email: the order must not leak the+ # alphabetical position of a hidden login address.+ it 'sorts two members of the same name by the shown email, not the login address' do+ member('Max', '[email protected]', email_visibility: 'contact', contact_email: '[email protected]')+ member('Max', '[email protected]', email_visibility: 'contact', contact_email: '[email protected]')++ get organisation_memberships_path(organisation)++ expect(response).to have_http_status(:ok)+ expect(response.body.index('[email protected]')).to be < response.body.index('[email protected]')+ expect(response.body).not_to include('[email protected]', '[email protected]')+ end+it 'finds a member by the shown email, never by a hidden login address' doget organisation_memberships_path(organisation, q: 'lena.team')expect(response.body).to include('[email protected]')@@ -105,6 +118,76 @@ RSpec.describe 'The email a member shows to others', :ci_guard, type: :request dendend+ describe 'the person form of a member' do+ it 'shows the chosen email in the locked field, and nothing for one who shows none' do+ lena_row = create(:person, organisation: organisation, user: lena, name: 'Lena Beispiel')+ nina_row = create(:person, organisation: organisation, user: nina, name: 'Nina Beispiel')+ frame = { 'Turbo-Frame' => Organisations::PeopleController::DETAIL_FRAME_ID }++ get edit_organisation_person_path(organisation, lena_row), headers: frame+ expect(response).to have_http_status(:ok)+ expect(response.body).to include('value="[email protected]"')+ expect_no_hidden_login_address(response.body)++ get edit_organisation_person_path(organisation, nina_row), headers: frame+ expect(response).to have_http_status(:ok)+ expect(response.body).to include('person_email_locked')+ expect_no_hidden_login_address(response.body)+ end+ end++ describe 'the activity search of a project' do+ # project.member_added belongs to the members area (Activities::AreaRegistry).+ before { create(:project_permission, user: admin, project: project, tickets_access: 'read_write', members_access: 'read_only') }++ # Rows written before this change still carry the login address in their+ # parameters; the search must not read it there either.+ it 'never confirms a hidden login address, also from an older member_added row' do+ ActsAsTenant.with_tenant(organisation) do+ create(:activity, trackable: project, organisation: organisation, actor: admin, secondary: nina,+ key: 'project.member_added', action: 'member_added',+ parameters: { 'user_name' => 'Zugang Nordlicht', 'user_email' => '[email protected]' })+ end+ path = ->(q) { organisation_project_activities_path(organisation_id: organisation.id, project_id: project.id, q: q) }+ # The row reads "<event>: <member>"; the event label and the member name+ # also stand alone in the page's filters, the pair only in the row.+ row = 'Mitglied hinzugefügt: Nina Beispiel'++ get path.call('Zugang Nord')+ expect(response).to have_http_status(:ok)+ expect(response.body).to include(row)++ get path.call('[email protected]')+ expect(response).to have_http_status(:ok)+ expect(response.body).not_to include(row)+ end++ it 'stores no login address when a member joins a project' do+ activity = ActsAsTenant.with_tenant(organisation) do+ Current.set(user: admin) { project.track_member_added(nina) }+ Activity.where(trackable: project, action: 'member_added').order(:created_at).last+ end++ expect(activity.parameters).to include('user_name')+ expect(activity.parameters.to_json).not_to include('nina-login')+ end+ end++ describe 'the codebase import preview' do+ it 'names a same-domain member by name and shown email, never by a hidden login address' do+ organisation.update!(data_import_enabled: true)+ file = ActsAsTenant.with_tenant(organisation) do+ create(:codebase_import_file, :with_valid_users_xml, organisation: organisation, user: admin)+ end++ get preview_import_organisation_codebase_import_file_path(organisation, file)++ expect(response).to have_http_status(:ok)+ expect(response.body).to include('Lena Beispiel', '[email protected]')+ expect_no_hidden_login_address(response.body)+ end+ end+describe 'sharing a smart folder' dolet(:folder) doActsAsTenant.with_tenant(organisation) do@@ -137,6 +220,19 @@ RSpec.describe 'The email a member shows to others', :ci_guard, type: :request dexpect_no_hidden_login_address(response.body)end+ it 'names the owner of a shared folder in the list by name' do+ ActsAsTenant.with_tenant(organisation) do+ create(:smart_folder, user: nina, organisation: organisation, project: project, target_object_type: 'Ticket',+ name: 'Ninas Ordner').tap { |f| create(:smart_folder_share, smart_folder: f, user: admin) }+ end++ get organisation_smart_folders_path(organisation)++ expect(response).to have_http_status(:ok)+ expect(response.body).to include('Ninas Ordner', 'Nina Beispiel')+ expect_no_hidden_login_address(response.body)+ end+it 'names the owner of a shared folder without a hidden login address' doforeign = ActsAsTenant.with_tenant(organisation) docreate(:smart_folder, user: lena, organisation: organisation, project: project, target_object_type: 'Ticket').tap do |f|diff --git a/spec/requests/user_preferences_email_visibility_spec.rb b/spec/requests/user_preferences_email_visibility_spec.rbindex 7a49f0a..0673320 100644--- a/spec/requests/user_preferences_email_visibility_spec.rb+++ b/spec/requests/user_preferences_email_visibility_spec.rb@@ -76,6 +76,19 @@ RSpec.describe 'User preferences: the email the others see', :ci_guard, type: :rexpect(user.email_visibility).to eq('none')end+ # One save for the picture and the choice: a refused choice must not leave a+ # new picture behind under a 422 that says nothing was saved.+ it 'keeps the old picture when the email choice in the same submit is refused' do+ patch user_preferences_path, params: {+ current_section: 'display',+ user: { avatar: fixture_file_upload('test_avatar.png', 'image/png'), email_visibility: 'contact', contact_email: '' }+ }++ expect(response).to have_http_status(:unprocessable_content)+ expect(user.reload.avatar).not_to be_attached+ expect(user.email_visibility).to eq('login')+ end+it 'leaves the choice alone when the section is saved without it' douser.update!(email_visibility: 'none')