Commit 9ddf459f authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'zeitwerk-fixes' into 'master'

Various fixes when loading classes

See merge request gitlab-org/gitlab!63818
parents 13246d81 5b1aa9f4
...@@ -1588,6 +1588,7 @@ Gitlab/NamespacedClass: ...@@ -1588,6 +1588,7 @@ Gitlab/NamespacedClass:
- 'app/models/list_user_preference.rb' - 'app/models/list_user_preference.rb'
- 'app/models/member.rb' - 'app/models/member.rb'
- 'app/models/members/group_member.rb' - 'app/models/members/group_member.rb'
- 'app/models/members/last_group_owner_assigner.rb'
- 'app/models/members/project_member.rb' - 'app/models/members/project_member.rb'
- 'app/models/members_preloader.rb' - 'app/models/members_preloader.rb'
- 'app/models/merge_request.rb' - 'app/models/merge_request.rb'
......
# frozen_string_literal: true # frozen_string_literal: true
module Members class LastGroupOwnerAssigner
class LastGroupOwnerAssigner def initialize(group, members)
def initialize(group, members) @group = group
@group = group @members = members
@members = members end
end
def execute def execute
@last_blocked_owner = no_owners_in_heirarchy? && group.single_blocked_owner? @last_blocked_owner = no_owners_in_heirarchy? && group.single_blocked_owner?
@group_single_owner = owners.size == 1 @group_single_owner = owners.size == 1
members.each { |member| set_last_owner(member) } members.each { |member| set_last_owner(member) }
end end
private private
attr_reader :group, :members, :last_blocked_owner, :group_single_owner attr_reader :group, :members, :last_blocked_owner, :group_single_owner
def no_owners_in_heirarchy? def no_owners_in_heirarchy?
owners.empty? owners.empty?
end end
def set_last_owner(member) def set_last_owner(member)
member.last_owner = member.id.in?(owner_ids) && group_single_owner member.last_owner = member.id.in?(owner_ids) && group_single_owner
member.last_blocked_owner = member.id.in?(blocked_owner_ids) && last_blocked_owner member.last_blocked_owner = member.id.in?(blocked_owner_ids) && last_blocked_owner
end end
def owner_ids def owner_ids
@owner_ids ||= owners.where(id: member_ids).ids @owner_ids ||= owners.where(id: member_ids).ids
end end
def blocked_owner_ids def blocked_owner_ids
@blocked_owner_ids ||= group.blocked_owners.where(id: member_ids).ids @blocked_owner_ids ||= group.blocked_owners.where(id: member_ids).ids
end end
def member_ids def member_ids
@members_ids ||= members.pluck(:id) @members_ids ||= members.pluck(:id)
end end
def owners def owners
@owners ||= group.members_with_parents.owners.load @owners ||= group.members_with_parents.owners.load
end
end end
end end
...@@ -4,7 +4,7 @@ class MemberSerializer < BaseSerializer ...@@ -4,7 +4,7 @@ class MemberSerializer < BaseSerializer
entity MemberEntity entity MemberEntity
def represent(members, opts = {}) def represent(members, opts = {})
Members::LastGroupOwnerAssigner.new(opts[:group], members).execute unless opts[:source].is_a?(Project) LastGroupOwnerAssigner.new(opts[:group], members).execute unless opts[:source].is_a?(Project)
super(members, opts) super(members, opts)
end end
......
...@@ -28,7 +28,7 @@ module API ...@@ -28,7 +28,7 @@ module API
desc 'Update existing merge request approval setting' do desc 'Update existing merge request approval setting' do
detail 'This feature is gated by the :group_merge_request_approval_settings_feature_flag' detail 'This feature is gated by the :group_merge_request_approval_settings_feature_flag'
success EE::API::Entities::GroupMergeRequestApprovalSetting success ::API::Entities::GroupMergeRequestApprovalSetting
end end
params do params do
optional :allow_author_approval, type: Boolean, desc: 'Allow authors to self-approve merge requests' optional :allow_author_approval, type: Boolean, desc: 'Allow authors to self-approve merge requests'
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Gitlab module Gitlab
module SubscriptionPortal module SubscriptionPortal
class Client class Client
include SubscriptionPortal::Clients::REST include SubscriptionPortal::Clients::Rest
include SubscriptionPortal::Clients::Graphql include SubscriptionPortal::Clients::Graphql
ResponseError = Class.new(StandardError) ResponseError = Class.new(StandardError)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Gitlab module Gitlab
module SubscriptionPortal module SubscriptionPortal
module Clients module Clients
module REST module Rest
extend ActiveSupport::Concern extend ActiveSupport::Concern
class_methods do class_methods do
......
...@@ -6,5 +6,5 @@ RSpec.describe Gitlab::SubscriptionPortal::Client do ...@@ -6,5 +6,5 @@ RSpec.describe Gitlab::SubscriptionPortal::Client do
subject { described_class } subject { described_class }
it { is_expected.to include_module Gitlab::SubscriptionPortal::Clients::Graphql } it { is_expected.to include_module Gitlab::SubscriptionPortal::Clients::Graphql }
it { is_expected.to include_module Gitlab::SubscriptionPortal::Clients::REST } it { is_expected.to include_module Gitlab::SubscriptionPortal::Clients::Rest }
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Gitlab::SubscriptionPortal::Clients::REST do RSpec.describe Gitlab::SubscriptionPortal::Clients::Rest do
let(:client) { Gitlab::SubscriptionPortal::Client } let(:client) { Gitlab::SubscriptionPortal::Client }
let(:http_response) { nil } let(:http_response) { nil }
let(:http_method) { :post } let(:http_method) { :post }
......
...@@ -23,7 +23,7 @@ module API ...@@ -23,7 +23,7 @@ module API
expose :issue_type, expose :issue_type,
as: :type, as: :type,
format_with: :upcase, format_with: :upcase,
documentation: { type: "String", desc: "One of #{Issue.issue_types.keys.map(&:upcase)}" } documentation: { type: "String", desc: "One of #{::Issue.issue_types.keys.map(&:upcase)}" }
expose :assignee, using: ::API::Entities::UserBasic do |issue| expose :assignee, using: ::API::Entities::UserBasic do |issue|
issue.assignees.first issue.assignees.first
......
...@@ -5,7 +5,7 @@ module Gitlab ...@@ -5,7 +5,7 @@ module Gitlab
module MigrationHelpers module MigrationHelpers
include Migrations::BackgroundMigrationHelpers include Migrations::BackgroundMigrationHelpers
include DynamicModelHelpers include DynamicModelHelpers
include Migrations::RenameTableHelpers include RenameTableHelpers
# https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS # https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
MAX_IDENTIFIER_NAME_LENGTH = 63 MAX_IDENTIFIER_NAME_LENGTH = 63
......
# frozen_string_literal: true # frozen_string_literal: true
# rubocop:disable Cop/CustomErrorClass
module Gitlab module Gitlab
module Graphql module Graphql
StandardGraphqlError = Class.new(StandardError) class StandardGraphqlError < StandardError
end
end end
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Members::LastGroupOwnerAssigner do RSpec.describe LastGroupOwnerAssigner do
describe "#execute" do describe "#execute" do
let_it_be(:user, reload: true) { create(:user) } let_it_be(:user, reload: true) { create(:user) }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
......
...@@ -42,7 +42,7 @@ RSpec.describe MemberSerializer do ...@@ -42,7 +42,7 @@ RSpec.describe MemberSerializer do
it_behaves_like 'members.json' it_behaves_like 'members.json'
it 'does not invoke group owner assignment' do it 'does not invoke group owner assignment' do
expect(Members::LastGroupOwnerAssigner).not_to receive(:new) expect(LastGroupOwnerAssigner).not_to receive(:new)
representation representation
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment