Skip to content

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.

Bind ids from requests to the organisation where nothing else did

Guido Boykeeb7a48ab5111
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.yml
index 9830cdf..a21f22b 100644
--- a/.github/workflows/guards.yml
+++ b/.github/workflows/guards.yml
@@ -179,6 +179,7 @@ jobs:
spec/jobs/meetings/ticket_suggestion_job_spec.rb
spec/jobs/email_delivery_job_access_gate_spec.rb
spec/jobs/tenant_propagation_spec.rb
+ spec/jobs/import_users_from_codebase_job_spec.rb
spec/jobs/embedding_processing_job_spec.rb
spec/locales/
spec/lib/lalabase/admin_extensions_spec.rb
@@ -225,6 +226,7 @@ jobs:
spec/models/ticket_spec.rb
spec/models/ticket_relation_tenant_boundary_spec.rb
spec/models/view_configuration_pinned_columns_spec.rb
+ spec/models/view_configuration_kanban_spec.rb
spec/models/time_session_spec.rb
spec/models/time_sessions/list_period_spec.rb
spec/models/time_sessions/list_filters_spec.rb
diff --git a/app/jobs/import_users_from_codebase_job.rb b/app/jobs/import_users_from_codebase_job.rb
index 6a034a8..7300ee8 100644
--- a/app/jobs/import_users_from_codebase_job.rb
+++ b/app/jobs/import_users_from_codebase_job.rb
@@ -32,7 +32,7 @@ class ImportUsersFromCodebaseJob < ApplicationJob
when /\Amap:(.+)\z/
existing_user_id = Regexp.last_match(1)
- result = map_to_existing_user(user_data, existing_user_id)
+ result = map_to_existing_user(user_data, existing_user_id, organisation)
results[result[:status]] += 1
when 'skip'
@@ -109,8 +109,11 @@ class ImportUsersFromCodebaseJob < ApplicationJob
{ status: :failed, error: e.message }
end
- def map_to_existing_user(user_data, existing_user_id)
- existing_user = User.find(existing_user_id)
+ # The id comes from the request; the preview only offers members. User carries no
+ # tenant, so without the organisation here any account of the instance could become
+ # the author of imported tickets, posts and time entries.
+ def map_to_existing_user(user_data, existing_user_id, organisation)
+ existing_user = organisation.users.find(existing_user_id)
CodebaseImportMapping.create!(
codebase_id: user_data[:id],
diff --git a/app/models/post.rb b/app/models/post.rb
index 812d981..716fb5c 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -79,6 +79,7 @@ class Post < ApplicationRecord
# Callbacks - set visible_to_user before validation
before_validation :set_visible_to_user_on_private
validate :private_post_visibility_consistency
+ validate :addressee_in_organisation
before_save :extract_plain_text_content
after_create_commit :auto_subscribe_author
@@ -123,7 +124,9 @@ class Post < ApplicationRecord
end
def set_visible_to_user_on_private
- if is_private? && visible_to_user.nil?
+ # The id, not the association: an id that resolves to nobody stays and fails the
+ # check below, instead of quietly becoming the author.
+ if is_private? && visible_to_user_id.nil?
self.visible_to_user = user
elsif !is_private?
self.visible_to_user = nil
@@ -138,6 +141,18 @@ class Post < ApplicationRecord
errors.add(:visible_to_user, :not_for_public)
end
+ # The addressee can come from the request (API). User carries no tenant, so without
+ # this any account of the instance was taken, and the answer told an existing id from
+ # a missing one. The author is always allowed: a note to oneself is the form's default.
+ def addressee_in_organisation
+ return unless is_private? && visible_to_user_id.present?
+ return unless will_save_change_to_visible_to_user_id?
+ return if visible_to_user_id == user_id
+ return if organisation&.memberships&.exists?(user_id: visible_to_user_id)
+
+ errors.add(:visible_to_user, :not_a_member)
+ end
+
def auto_subscribe_author
return unless user && ticket
diff --git a/app/models/smart_folders/validators/value_validator.rb b/app/models/smart_folders/validators/value_validator.rb
index 68a3ed9..9df6426 100644
--- a/app/models/smart_folders/validators/value_validator.rb
+++ b/app/models/smart_folders/validators/value_validator.rb
@@ -301,7 +301,7 @@ module SmartFolders
record = (rule.preloaded_references.dig(model_class.name, value_str) if rule.respond_to?(:preloaded_references) && rule.preloaded_references)
- record ||= model_class.find_by(id: value_str)
+ record ||= reference_scope(rule, model_class).find_by(id: value_str)
unless record
rule.errors.add(:value, :reference_not_found, id: value_str, model: model_class.model_name.human)
@@ -332,9 +332,10 @@ module SmartFolders
return false unless all_formats_valid
# SLOW operation: check the existence of all IDs.
- found_count = model_class.where(id: ids).count
+ scope = reference_scope(rule, model_class)
+ found_count = scope.where(id: ids).count
if found_count != ids.length
- missing_ids = ids - model_class.where(id: ids).pluck(:id).map(&:to_s)
+ missing_ids = ids - scope.where(id: ids).pluck(:id).map(&:to_s)
rule.errors.add(:value, :references_not_found, ids: missing_ids.join(', '), model: model_class.model_name.human)
return false
end
@@ -342,6 +343,21 @@ module SmartFolders
true
end
+ # User carries no tenant: any account of the instance passed as creator or assignee,
+ # and the rule stored that person's name. Tenant-scoped models are bound by their
+ # default scope already. Preloaded records come bound from their only source,
+ # AdHocToSmartFolderService#preload_references.
+ def reference_scope(rule, model_class)
+ return model_class unless tenantless?(model_class)
+
+ organisation = rule.try(:smart_folder_rule_group)&.smart_folder&.organisation || ActsAsTenant.current_tenant
+ organisation ? organisation.users : model_class.none
+ end
+
+ def tenantless?(model_class)
+ model_class <= User
+ end
+
# Checks the format of an ID (UUID or Integer)
def valid_id_format?(id_string, model_class, rule)
id_type = model_class.columns_hash['id']&.type
diff --git a/app/models/time_session.rb b/app/models/time_session.rb
index b97f998..dda3165 100644
--- a/app/models/time_session.rb
+++ b/app/models/time_session.rb
@@ -49,6 +49,15 @@
# fk_rails_... (time_session_group_id => time_session_groups.id)
#
class TimeSession < ApplicationRecord
+ # A session's subject is a Ticket OR a Meeting (Gespräche Slice 2), never both —
+ # the XOR is enforced by the DB check constraint time_sessions_single_subject and
+ # the #at_most_one_subject validation below. touch: keeps the subject's updated_at
+ # fresh when its booked time changes (same contract as :ticket).
+ # Declared BEFORE acts_as_tenant: the gem checks a foreign id only for associations
+ # it already knows, so declared after it, a ticket of another organisation passed.
+ belongs_to :ticket, optional: true, touch: true
+ belongs_to :meeting, optional: true, touch: true
+
acts_as_tenant(:organisation)
# The three mutually exclusive billing buckets: not in any billing group, in a
@@ -149,12 +158,6 @@ class TimeSession < ApplicationRecord
# Relationships
belongs_to :project
- # A session's subject is a Ticket OR a Meeting (Gespräche Slice 2), never both —
- # the XOR is enforced by the DB check constraint time_sessions_single_subject and
- # the #at_most_one_subject validation below. touch: keeps the subject's updated_at
- # fresh when its booked time changes (same contract as :ticket).
- belongs_to :ticket, optional: true, touch: true
- belongs_to :meeting, optional: true, touch: true
belongs_to :creator, class_name: 'User'
belongs_to :organisation
belongs_to :time_session_group, optional: true
diff --git a/app/models/view_configuration.rb b/app/models/view_configuration.rb
index ce9d57d..4a1ac32 100644
--- a/app/models/view_configuration.rb
+++ b/app/models/view_configuration.rb
@@ -134,6 +134,7 @@ class ViewConfiguration < ApplicationRecord
validates :view_type, presence: true, inclusion: { in: %w[tickets notes documents meetings] }
validates :user_id, uniqueness: { scope: %i[project_id view_type] }
validates :view_mode, inclusion: { in: VIEW_MODES }, allow_nil: true
+ validate :kanban_attribute_definition_of_own_project
# Ensure required columns are always included
before_save :ensure_required_columns
@@ -355,6 +356,17 @@ class ViewConfiguration < ApplicationRecord
self.class.status_attribute_for(project) || kanban_eligible_attributes.first
end
+ # TicketAttributeDefinition carries no tenant (it is scoped through its project), so
+ # nothing else checks the id from the request: a foreign one put the values and
+ # labels of another project's field on this board.
+ def kanban_attribute_definition_of_own_project
+ return if kanban_attribute_definition_id.blank?
+ return unless will_save_change_to_kanban_attribute_definition_id?
+ return if project&.ticket_attribute_definitions&.exists?(kanban_attribute_definition_id)
+
+ errors.add(:kanban_attribute_definition, :invalid)
+ end
+
# Appends custom attribute columns to base when view_type == 'tickets'
def self.append_custom_columns(base, project, view_type)
if view_type == 'tickets' && project.ticket_attribute_definitions.any?
diff --git a/app/services/ad_hoc_to_smart_folder_service.rb b/app/services/ad_hoc_to_smart_folder_service.rb
index 2f8923b..727bbf4 100644
--- a/app/services/ad_hoc_to_smart_folder_service.rb
+++ b/app/services/ad_hoc_to_smart_folder_service.rb
@@ -278,7 +278,7 @@ class AdHocToSmartFolderService
.map { |r| r[:value] }.compact.uniq
return nil if user_ids.empty?
- users_by_id = User.where(id: user_ids).index_by { |u| u.id.to_s }
+ users_by_id = project.organisation.users.where(id: user_ids).index_by { |u| u.id.to_s }
{ 'User' => users_by_id }
end
diff --git a/config/locales/models.de.yml b/config/locales/models.de.yml
index 342b33e..e8c7dab 100644
--- a/config/locales/models.de.yml
+++ b/config/locales/models.de.yml
@@ -330,6 +330,7 @@ de:
visible_to_user:
required_for_private: "muss für private Beiträge gesetzt sein"
not_for_public: "darf für öffentliche Beiträge nicht gesetzt sein"
+ not_a_member: "muss Mitglied der Organisation sein"
ticket_attribute_definition:
invalid_date: "ist kein gültiges Datum (Format JJJJ-MM-TT)"
attributes:
diff --git a/config/locales/models.en.yml b/config/locales/models.en.yml
index 22a2348..329309c 100644
--- a/config/locales/models.en.yml
+++ b/config/locales/models.en.yml
@@ -322,6 +322,7 @@ en:
visible_to_user:
required_for_private: "must be set for private posts"
not_for_public: "should not be set for public posts"
+ not_a_member: "must be a member of the organisation"
ticket_attribute_definition:
invalid_date: "is not a valid date (format YYYY-MM-DD)"
attributes:
diff --git a/spec/jobs/import_users_from_codebase_job_spec.rb b/spec/jobs/import_users_from_codebase_job_spec.rb
index c174440..fde4a15 100644
--- a/spec/jobs/import_users_from_codebase_job_spec.rb
+++ b/spec/jobs/import_users_from_codebase_job_spec.rb
@@ -2,7 +2,7 @@
require 'rails_helper'
-RSpec.describe ImportUsersFromCodebaseJob, type: :job do
+RSpec.describe ImportUsersFromCodebaseJob, :ci_guard, type: :job do
let(:organisation) { create(:organisation) }
let(:importing_user) { create(:user, organisation: organisation) }
let(:default_role) { create(:role, organisation: organisation, is_default: true) }
@@ -166,7 +166,7 @@ RSpec.describe ImportUsersFromCodebaseJob, type: :job do
end
context 'with map action' do
- let(:existing_user) { create(:user) }
+ let(:existing_user) { create(:user, organisation: organisation) }
it 'creates a mapping to the existing user' do
file_id = import_file.id
@@ -197,6 +197,21 @@ RSpec.describe ImportUsersFromCodebaseJob, type: :job do
expect(results['failed']).to eq(1)
expect(results['mapped']).to eq(0)
end
+
+ # The select only offers members, but the id comes from the request. Mapping onto
+ # an account of another organisation put that person's name and avatar on imported
+ # tickets, posts and time entries here.
+ it 'refuses a target user who is not a member of the organisation' do
+ foreign_user = create(:user, organisation: create(:organisation))
+
+ expect do
+ perform_job(import_file.id, { '101' => "map:#{foreign_user.id}" }, {}, importing_user.id)
+ end.not_to change(CodebaseImportMapping, :count)
+
+ results = import_file.reload.metadata['import_results']
+ expect(results['failed']).to eq(1)
+ expect(results['mapped']).to eq(0)
+ end
end
context 'with skip action' do
@@ -240,7 +255,7 @@ RSpec.describe ImportUsersFromCodebaseJob, type: :job do
end
context 'with mixed actions' do
- let(:existing_user) { create(:user) }
+ let(:existing_user) { create(:user, organisation: organisation) }
let(:multi_users_xml) do
build_users_xml([
diff --git a/spec/models/smart_folder_rule_spec.rb b/spec/models/smart_folder_rule_spec.rb
index e70c9e4..a04a0fc 100644
--- a/spec/models/smart_folder_rule_spec.rb
+++ b/spec/models/smart_folder_rule_spec.rb
@@ -28,7 +28,7 @@
#
require 'rails_helper'
-RSpec.describe SmartFolderRule, type: :model do
+RSpec.describe SmartFolderRule, :ci_guard, type: :model do
let(:organisation) { create(:organisation) }
let(:user) { create(:user) }
let(:project) { create(:project, organisation: organisation) }
@@ -44,6 +44,30 @@ RSpec.describe SmartFolderRule, type: :model do
ActsAsTenant.current_tenant = nil
end
+ # User carries no tenant. Before, any account of the instance passed as creator or
+ # assignee, the rule stored that person's name, and the error told an existing id from
+ # a missing one.
+ describe 'user reference of another organisation' do
+ def rule_for(field, value, operator: 'equals')
+ build(:smart_folder_rule, smart_folder_rule_group: smart_folder_rule_group,
+ field: field, operator: operator, value: value)
+ end
+
+ it 'accepts a member of the organisation' do
+ expect(rule_for('assignee', user.id)).to be_valid
+ end
+
+ %w[assignee creator].each do |field|
+ it "rejects an account of another organisation as #{field}, like an id that does not exist" do
+ foreign_user = create(:user, organisation: create(:organisation))
+
+ rule = rule_for(field, foreign_user.id)
+ expect(rule).not_to be_valid
+ expect(rule.errors.details[:value]).to include(a_hash_including(error: :reference_not_found))
+ end
+ end
+ end
+
describe 'field_config' do
it 'uses ActionTextFilter for content field' do
config = SmartFolderRule.field_config['content']
diff --git a/spec/models/time_session_spec.rb b/spec/models/time_session_spec.rb
index 7a84286..7707dac 100644
--- a/spec/models/time_session_spec.rb
+++ b/spec/models/time_session_spec.rb
@@ -54,7 +54,7 @@ require 'rails_helper'
# Covers the decision points: required fields + DB NOT NULL, numericality > 0
# (boundary 0!), billed default, soft-delete default_scope, duration_string parsing
# (all branches), billed edit guard, formatting helpers, scopes, tenant isolation.
-RSpec.describe TimeSession, type: :model do
+RSpec.describe TimeSession, :ci_guard, type: :model do
let(:organisation) { create(:organisation) }
let(:project) { create(:project, organisation: organisation) }
let(:creator) { create(:user, organisation: organisation) }
@@ -75,6 +75,38 @@ RSpec.describe TimeSession, type: :model do
it { is_expected.to belong_to(:ticket).optional }
it { is_expected.to belong_to(:meeting).optional }
it { is_expected.to belong_to(:time_session_group).optional }
+
+ # acts_as_tenant checks foreign ids only for associations declared before its call.
+ # Every write path resolves the subject itself today; this keeps the model from
+ # taking one of another organisation when a new path forgets to.
+ describe 'subject of another organisation' do
+ let(:other_organisation) { create(:organisation) }
+ let(:other_project) do
+ ActsAsTenant.with_tenant(other_organisation) { create(:project, organisation: other_organisation) }
+ end
+
+ it 'rejects a ticket of another organisation' do
+ foreign_ticket = ActsAsTenant.with_tenant(other_organisation) do
+ create(:ticket, project: other_project, organisation: other_organisation,
+ creator: create(:user, organisation: other_organisation))
+ end
+
+ session = build_session(ticket_id: foreign_ticket.id)
+ expect(session).not_to be_valid
+ expect(session.errors[:ticket_id]).to be_present
+ end
+
+ it 'rejects a meeting of another organisation' do
+ foreign_meeting = ActsAsTenant.with_tenant(other_organisation) do
+ create(:meeting, project: other_project, organisation: other_organisation,
+ creator: create(:user, organisation: other_organisation))
+ end
+
+ session = build_session(meeting_id: foreign_meeting.id)
+ expect(session).not_to be_valid
+ expect(session.errors[:meeting_id]).to be_present
+ end
+ end
end
# Gespräche Slice 2: a session's subject is a Ticket OR a Meeting, never both.
diff --git a/spec/models/view_configuration_kanban_spec.rb b/spec/models/view_configuration_kanban_spec.rb
index e7ff1dd..9ce362b 100644
--- a/spec/models/view_configuration_kanban_spec.rb
+++ b/spec/models/view_configuration_kanban_spec.rb
@@ -2,7 +2,7 @@
require 'rails_helper'
-RSpec.describe ViewConfiguration, 'kanban support' do
+RSpec.describe ViewConfiguration, 'kanban support', :ci_guard do
let(:organisation) { create(:organisation) }
let(:user) { create(:user) }
let(:project) { create(:project, organisation: organisation) }
@@ -105,5 +105,35 @@ RSpec.describe ViewConfiguration, 'kanban support' do
view_config.view_mode = nil
expect(view_config).to be_valid
end
+
+ # TicketAttributeDefinition carries no tenant, so nothing else stops an id from the
+ # request: the board then showed the values and labels of a foreign project's field.
+ describe 'kanban_attribute_definition' do
+ it "accepts a definition of the view's own project" do
+ own = create(:ticket_attribute_definition, :select, project: project, name: 'category')
+ view_config.kanban_attribute_definition_id = own.id
+ expect(view_config).to be_valid
+ end
+
+ it 'rejects a definition of another organisation' do
+ other_organisation = create(:organisation)
+ foreign = ActsAsTenant.with_tenant(other_organisation) do
+ create(:ticket_attribute_definition, :select,
+ project: create(:project, organisation: other_organisation), name: 'status')
+ end
+
+ view_config.kanban_attribute_definition_id = foreign.id
+ expect(view_config).not_to be_valid
+ expect(view_config.errors.details[:kanban_attribute_definition]).to include(error: :invalid)
+ end
+
+ it 'rejects a definition of another project in the same organisation' do
+ other_project = create(:project, organisation: organisation)
+ sibling = create(:ticket_attribute_definition, :select, project: other_project, name: 'status')
+
+ view_config.kanban_attribute_definition_id = sibling.id
+ expect(view_config).not_to be_valid
+ end
+ end
end
end
diff --git a/spec/requests/api/v1/write_endpoints_spec.rb b/spec/requests/api/v1/write_endpoints_spec.rb
index 0d271e1..60816d1 100644
--- a/spec/requests/api/v1/write_endpoints_spec.rb
+++ b/spec/requests/api/v1/write_endpoints_spec.rb
@@ -88,6 +88,24 @@ RSpec.describe 'API V1 Write Endpoints', :ci_guard, type: :request do
expect(body.dig('data', 'visible_to_user_id')).to eq(other_user.id)
end
+ # The addressee comes from the request. Without a rule it took any account of the
+ # instance, and the answer told an existing id (201) from a missing one (422).
+ { 'from another organisation' => -> { create(:user, organisation: create(:organisation)).id },
+ 'that does not exist' => -> { SecureRandom.uuid } }.each do |label, addressee|
+ it "refuses an addressee #{label}, with the same answer" do
+ addressee_id = instance_exec(&addressee)
+
+ expect do
+ post "/api/v1/tickets/#{ticket.id}/posts",
+ params: { post: { body: 'Geheim', is_private: true, visible_to_user_id: addressee_id } },
+ headers: auth_headers
+ end.not_to(change { ActsAsTenant.with_tenant(organisation) { Post.count } })
+
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(JSON.parse(response.body)['error']).to eq('validation_failed')
+ end
+ end
+
it 'returns 422 when body is missing' do
post "/api/v1/tickets/#{ticket.id}/posts",
params: { post: { body: '' } },
diff --git a/spec/requests/organisations/ticket_lookups_spec.rb b/spec/requests/organisations/ticket_lookups_spec.rb
index e4d8a67..c3226c7 100644
--- a/spec/requests/organisations/ticket_lookups_spec.rb
+++ b/spec/requests/organisations/ticket_lookups_spec.rb
@@ -98,7 +98,7 @@ RSpec.describe 'Organisations::TicketLookups', :ci_guard, type: :request do
it 'searches the title only, not the text of comments' do
ActsAsTenant.with_tenant(organisation) do
create(:post, ticket: readable_match, user: user, organisation: organisation,
- content: 'Kuendigungsfrist', is_private: true, visible_to_user_id: create(:user).id)
+ content: 'Kuendigungsfrist', is_private: true, visible_to_user_id: create(:user, organisation: organisation).id)
end
expect(lookup(q: 'Kuendigungsfrist')).to be_empty
diff --git a/spec/services/actors/save_smart_folder_from_filters_spec.rb b/spec/services/actors/save_smart_folder_from_filters_spec.rb
index 2bbe385..2f21ebb 100644
--- a/spec/services/actors/save_smart_folder_from_filters_spec.rb
+++ b/spec/services/actors/save_smart_folder_from_filters_spec.rb
@@ -58,7 +58,7 @@ RSpec.describe Actors::SaveSmartFolderFromFilters do
end
it 'persists one group per assignee for a multi-OR assignee filter' do
- other = create(:user)
+ other = create(:user, organisation: organisation)
folder = create_from(filter_params: { 'assignee' => [user.id.to_s, other.id.to_s] }).resource
expect(folder.smart_folder_rule_groups.count).to eq(2)
end
diff --git a/spec/services/ad_hoc_to_smart_folder_service_spec.rb b/spec/services/ad_hoc_to_smart_folder_service_spec.rb
index 2b4f887..a3895bc 100644
--- a/spec/services/ad_hoc_to_smart_folder_service_spec.rb
+++ b/spec/services/ad_hoc_to_smart_folder_service_spec.rb
@@ -67,6 +67,15 @@ RSpec.describe AdHocToSmartFolderService do
expect(conversion.preloaded_references['User']).to have_key(user.id.to_s)
end
+ # The validator trusts this preload, so it holds members of the organisation only;
+ # an account of another one is then looked up again and refused.
+ it 'preloads no account of another organisation' do
+ foreign_user = create(:user, organisation: create(:organisation))
+ conversion = convert(filter_params: { 'creator' => [user.id.to_s, foreign_user.id.to_s] })
+
+ expect(conversion.preloaded_references['User'].keys).to contain_exactly(user.id.to_s)
+ end
+
it 'leaves preloaded_references nil when there are no reference rules' do
expect(convert(filter_params: { 'tag' => ['bug'] }).preloaded_references).to be_nil
end
diff --git a/spec/services/meetings/list_query_spec.rb b/spec/services/meetings/list_query_spec.rb
index 868c424..a32b94b 100644
--- a/spec/services/meetings/list_query_spec.rb
+++ b/spec/services/meetings/list_query_spec.rb
@@ -137,7 +137,7 @@ RSpec.describe Meetings::ListQuery do
it 'does not dissolve a creator equality combined with an exclusion into a different condition' do
record = meeting('Mine')
folder = save_view('creator' => [user.id])
- folder.smart_folder_rule_groups.first.smart_folder_rules.create!(field: 'creator', operator: 'not_equals', value: create(:user).id, position: 2)
+ folder.smart_folder_rule_groups.first.smart_folder_rules.create!(field: 'creator', operator: 'not_equals', value: create(:user, organisation: organisation).id, position: 2)
expect(SmartFolderDissolver.new(folder).call).not_to be_dissolvable
expect(query(smart_folder: folder).pluck(:id)).to eq([record.id])
end
diff --git a/spec/services/projects/default_smart_folder_service_spec.rb b/spec/services/projects/default_smart_folder_service_spec.rb
index 2489bb4..f7f2801 100644
--- a/spec/services/projects/default_smart_folder_service_spec.rb
+++ b/spec/services/projects/default_smart_folder_service_spec.rb
@@ -246,6 +246,9 @@ RSpec.describe Projects::DefaultSmartFolderService do
before do
project.project_permissions.destroy_all
organisation.users.destroy_all
+ # "Meine Aufgaben" belongs to the calling member, and with no members left a
+ # rule for that user is refused before the public folders ask for one.
+ allow(service).to receive(:create_my_tasks)
end
it 'raises NoSystemUserError with a descriptive message' do
diff --git a/spec/services/smart_folder_round_trip_spec.rb b/spec/services/smart_folder_round_trip_spec.rb
index 9400dd9..62e1306 100644
--- a/spec/services/smart_folder_round_trip_spec.rb
+++ b/spec/services/smart_folder_round_trip_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe 'Smart folder round trip: saved from the bar, read back into the
let(:organisation) { create(:organisation) }
let(:admin_role) { create(:admin_role, organisation: organisation) }
let(:user) { create(:user) }
- let(:other) { create(:user) }
+ let(:other) { create(:user, organisation: organisation) }
let(:project) { create(:project, organisation: organisation) }
before do