summaryrefslogtreecommitdiff
path: root/spec/support/helpers/stubbed_member.rb
blob: 27420c9b709486f9831fa6288ab6412211234ade (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

# Extend the ProjectMember & GroupMember class with the ability to
# to run project_authorizations refresh jobs inline.

# This is needed so that calls like `group.add_member(user, access_level)` or `create(:project_member)`
# in the specs can be run without including `:sidekiq_inline` trait.
module StubbedMember
  extend ActiveSupport::Concern

  module Member
    private

    def refresh_member_authorized_projects(blocking:)
      return super unless blocking

      AuthorizedProjectsWorker.new.perform(user_id)
    end
  end

  module ProjectMember
    private

    def blocking_project_authorizations_refresh
      AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker.new.perform(project.id, user.id)
    end
  end
end