diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 6b29ee5bac65ba4916411140d2d11c9ee5f87e37..7651c99d8b408f7ecd095a8d182efc495133bbaf 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -19,6 +19,7 @@ class Namespace < ApplicationRecord include Referable include CrossDatabaseIgnoredTables include UseSqlFunctionForPrimaryKeyLookups + include SafelyChangeColumnDefault include Todoable ignore_column :unlock_membership_to_ldap, remove_with: '16.7', remove_after: '2023-11-16' @@ -27,6 +28,8 @@ class Namespace < ApplicationRecord ignore_column :emails_disabled, remove_with: '17.0', remove_after: '2024-04-24' + columns_changing_default :organization_id + # Tells ActiveRecord not to store the full class name, in order to save some space # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69794 self.store_full_sti_class = false @@ -161,9 +164,9 @@ class Namespace < ApplicationRecord validate :parent_organization_match, if: :require_organization? attribute :organization_id, :integer, default: -> do - return 1 if Feature.enabled?(:namespace_model_default_org, Feature.current_request) + return if Feature.enabled?(:require_organization, Feature.current_request) - columns_hash['organization_id'].default + Organizations::Organization::DEFAULT_ORGANIZATION_ID end delegate :name, to: :owner, allow_nil: true, prefix: true diff --git a/config/feature_flags/gitlab_com_derisk/namespace_model_default_org.yml b/config/feature_flags/gitlab_com_derisk/namespace_model_default_org.yml deleted file mode 100644 index 676b9ed125ef3d3ed59541abe12ba6df1d1c8bcf..0000000000000000000000000000000000000000 --- a/config/feature_flags/gitlab_com_derisk/namespace_model_default_org.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -name: namespace_model_default_org -feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/466141 -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/168228 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/492445 -milestone: '17.6' -group: group::tenant scale -type: gitlab_com_derisk -default_enabled: false diff --git a/db/fixtures/development/02_users.rb b/db/fixtures/development/02_users.rb index 0d53624fd6c3c59bc3fee903a9663c37dd97fdf8..e175ab93740e03ab039ed55ad191d68206ae9820 100644 --- a/db/fixtures/development/02_users.rb +++ b/db/fixtures/development/02_users.rb @@ -9,10 +9,10 @@ class Gitlab::Seeder::Users RANDOM_USERS_COUNT = 20 MASS_NAMESPACES_COUNT = ENV['CI'] ? 1 : 100 MASS_USERS_COUNT = ENV['CI'] ? 10 : 1_000_000 - attr_reader :opts + attr_reader :organization - def initialize(opts = {}) - @opts = opts + def initialize(organization: ) + @organization = organization end def seed! @@ -47,12 +47,13 @@ def create_mass_users! relation = User.where(admin: false) Gitlab::Seeder.with_mass_insert(relation.count, 'user namespaces') do ActiveRecord::Base.connection.execute <<~SQL - INSERT INTO namespaces (name, path, owner_id, type) + INSERT INTO namespaces (name, path, owner_id, type, organization_id) SELECT username, username, id, - 'User' + 'User', + #{organization.id} FROM users WHERE NOT admin ON CONFLICT DO NOTHING; SQL @@ -82,7 +83,7 @@ def create_random_users! confirmed_at: DateTime.now, password: random_password ) do |user| - user.assign_personal_namespace(Organizations::Organization.default_organization) + user.assign_personal_namespace(organization) end print '.' @@ -95,11 +96,12 @@ def create_random_users! def create_mass_namespaces! Gitlab::Seeder.with_mass_insert(MASS_NAMESPACES_COUNT, "root namespaces and subgroups 9 levels deep") do ActiveRecord::Base.connection.execute <<~SQL - INSERT INTO namespaces (name, path, type) + INSERT INTO namespaces (name, path, type, organization_id) SELECT 'mass insert group level 0 - ' || seq, '#{Gitlab::Seeder::MASS_INSERT_GROUP_START}_0_' || seq, - 'Group' + 'Group', + #{organization.id} FROM generate_series(1, #{MASS_NAMESPACES_COUNT}) AS seq ON CONFLICT DO NOTHING; SQL @@ -108,12 +110,13 @@ def create_mass_namespaces! count = Namespace.where("path LIKE '#{Gitlab::Seeder::MASS_INSERT_PREFIX}%'").where(type: 'Group').count * 2 Gitlab::Seeder.log_message("Creating subgroups at level #{idx}: #{count}") ActiveRecord::Base.connection.execute <<~SQL - INSERT INTO namespaces (name, path, type, parent_id) + INSERT INTO namespaces (name, path, type, parent_id, organization_id) SELECT 'mass insert group level #{idx} - ' || seq, '#{Gitlab::Seeder::MASS_INSERT_GROUP_START}_#{idx}_' || seq, 'Group', - namespaces.id + namespaces.id, + namespaces.organization_id FROM namespaces CROSS JOIN generate_series(1, 2) AS seq WHERE namespaces.type='Group' AND namespaces.path like '#{Gitlab::Seeder::MASS_INSERT_GROUP_START}_#{idx-1}_%' @@ -189,6 +192,6 @@ def random_password end Gitlab::Seeder.quiet do - users = Gitlab::Seeder::Users.new + users = Gitlab::Seeder::Users.new(organization: Organizations::Organization.default_organization) users.seed! end diff --git a/db/fixtures/development/03_project.rb b/db/fixtures/development/03_project.rb index 16141dd534aaf9b570d8bc7a281a1e303b7b1249..639c2a69a3a7793d1d287f97b1d79b35ad1114fe 100644 --- a/db/fixtures/development/03_project.rb +++ b/db/fixtures/development/03_project.rb @@ -56,6 +56,12 @@ class Gitlab::Seeder::Projects BATCH_SIZE = 100_000 + attr_reader :organization + + def initialize(organization:) + @organization = organization + end + def seed! Sidekiq::Testing.inline! do create_real_projects! @@ -106,7 +112,7 @@ def self.insert_projects_sql(type:, range:) SQL end - def self.create_real_project!(url: nil, force_latest_storage: false, project_path: nil, group_path: nil) + def self.create_real_project!(organization:, url: nil, force_latest_storage: false, project_path: nil, group_path: nil) if url group_path, project_path = url.split('/')[-2..-1] end @@ -116,7 +122,8 @@ def self.create_real_project!(url: nil, force_latest_storage: false, project_pat unless group group = Group.new( name: group_path.titleize, - path: group_path + path: group_path, + organization: organization ) group.description = FFaker::Lorem.sentence group.save! @@ -135,7 +142,7 @@ def self.create_real_project!(url: nil, force_latest_storage: false, project_pat params = { import_url: url, - organization_id: Organizations::Organization.default_organization.id, + organization_id: organization.id, namespace_id: group.id, name: project_path.titleize, description: FFaker::Lorem.sentence, @@ -179,7 +186,7 @@ def create_real_projects! size = ENV['SIZE'].present? ? ENV['SIZE'].to_i : 8 PROJECT_URLS.first(size).each_with_index do |url, i| - self.class.create_real_project!(url: url, force_latest_storage: i.even?) + self.class.create_real_project!(url: url, force_latest_storage: i.even?, organization: organization) end end @@ -187,7 +194,7 @@ def create_large_projects! return unless ENV['LARGE_PROJECTS'].present? LARGE_PROJECT_URLS.each do |url| - self.class.create_real_project!(url: url) + self.class.create_real_project!(url: url, organization: organization) end if ENV['FORK'].present? @@ -244,6 +251,6 @@ def self.visibility_level_per_user end Gitlab::Seeder.quiet do - projects = Gitlab::Seeder::Projects.new + projects = Gitlab::Seeder::Projects.new(organization: Organizations::Organization.default_organization) projects.seed! end diff --git a/db/fixtures/development/20_nested_groups.rb b/db/fixtures/development/20_nested_groups.rb index d9aea17aa16cbb302306f691181a643054e5ac43..f542553f0a5e22caccebe177da4f71d246bbdd83 100644 --- a/db/fixtures/development/20_nested_groups.rb +++ b/db/fixtures/development/20_nested_groups.rb @@ -24,7 +24,9 @@ full_path = full_path.sub(/\.git\z/, '') full_path, _, project_path = full_path.rpartition('/') group = Sidekiq::Worker.skipping_transaction_check do - Group.find_by_full_path(full_path) || Groups::NestedCreateService.new(user, group_path: full_path).execute + Group.find_by_full_path(full_path) || Groups::NestedCreateService.new( + user, group_path: full_path, organization_id: Organizations::Organization.default_organization.id + ).execute end params = { diff --git a/db/fixtures/development/30_composer_packages.rb b/db/fixtures/development/30_composer_packages.rb index a30d838ad8c5d6fd0b9cba4dc27478b3cd111599..0f32bdd461dcf6259e1bcaec15cfe3a3b132cbd2 100644 --- a/db/fixtures/development/30_composer_packages.rb +++ b/db/fixtures/development/30_composer_packages.rb @@ -3,6 +3,12 @@ require './spec/support/sidekiq_middleware' class Gitlab::Seeder::ComposerPackages + attr_reader :organization + + def initialize(organization:) + @organization = organization + end + def group @group ||= Group.find_by(path: 'composer') @@ -10,7 +16,8 @@ def group @group = Group.create!( name: 'Composer', path: 'composer', - description: FFaker::Lorem.sentence + description: FFaker::Lorem.sentence, + organization: organization ) @group.add_owner(user) @@ -94,7 +101,8 @@ def create_real_project!(url) Sidekiq::Testing.inline! do COMPOSER_PACKAGES.each do |path, versions| - project = Gitlab::Seeder::ComposerPackages.new.create_real_project!(path) + project = Gitlab::Seeder::ComposerPackages.new(organization: Organizations::Organization.default_organization) + project.create_real_project!(path) versions.each do |version| params = {} diff --git a/db/fixtures/development/33_triage_ops.rb b/db/fixtures/development/33_triage_ops.rb index 173b9a73d5b3842c3a7d7649753834f9db4cbc7f..1580be3aeb629e9ba0d05b60bfd28f85a8c2b1df 100644 --- a/db/fixtures/development/33_triage_ops.rb +++ b/db/fixtures/development/33_triage_ops.rb @@ -92,6 +92,12 @@ class Gitlab::Seeder::TriageOps pipeline:update-cache LABELS + attr_reader :organization + + def initialize(organization:) + @organization = organization + end + def seed! puts "Updating settings to allow web hooks to localhost" ApplicationSetting.current_without_cache.update!(allow_local_requests_from_web_hooks_and_services: true) @@ -213,7 +219,8 @@ def ensure_group(full_path) group = Group.new( name: group_path.titleize, path: group_path, - parent: parent + parent: parent, + organization_id: organization.id ) group.description = FFaker::Lorem.sentence group.save! @@ -253,7 +260,8 @@ def ensure_project(project_fullpath) if ENV['SEED_TRIAGE_OPS'] Gitlab::Seeder.quiet do - Gitlab::Seeder::TriageOps.new.seed! + seeder = Gitlab::Seeder::TriageOps.new(organization: Organizations::Organization.default_organization) + seeder.seed! end else puts "Skipped. Use the `SEED_TRIAGE_OPS` environment variable to enable seeding data for triage ops project." diff --git a/db/post_migrate/20241203144100_drop_namespaces_organization_id_default.rb b/db/post_migrate/20241203144100_drop_namespaces_organization_id_default.rb new file mode 100644 index 0000000000000000000000000000000000000000..3cc2188f494c822a7a9122d630912c38891621a7 --- /dev/null +++ b/db/post_migrate/20241203144100_drop_namespaces_organization_id_default.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class DropNamespacesOrganizationIdDefault < Gitlab::Database::Migration[2.2] + milestone '17.7' + + def change + change_column_default(:namespaces, :organization_id, from: 1, to: nil) + end +end diff --git a/db/schema_migrations/20241203144100 b/db/schema_migrations/20241203144100 new file mode 100644 index 0000000000000000000000000000000000000000..87c8f9b407fc0d38a41859f8842e77ba779af71b --- /dev/null +++ b/db/schema_migrations/20241203144100 @@ -0,0 +1 @@ +24e4c35ec89a72b08ebae320d85cfeed56163379b3acdf9cd83facd5ee448bdb \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index c88d4cf98eb080a79e0064f32a1235e30e11b227..033d26a6465cf728b5d355bacd679dedbf3fda22 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -201,7 +201,7 @@ CREATE TABLE namespaces ( shared_runners_enabled boolean DEFAULT true NOT NULL, allow_descendants_override_disabled_shared_runners boolean DEFAULT false NOT NULL, traversal_ids bigint[] DEFAULT '{}'::bigint[] NOT NULL, - organization_id bigint DEFAULT 1, + organization_id bigint, CONSTRAINT check_2eae3bdf93 CHECK ((organization_id IS NOT NULL)) ); diff --git a/ee/db/fixtures/development/30_customizable_cycle_analytics.rb b/ee/db/fixtures/development/30_customizable_cycle_analytics.rb index 227b338b986a1efe803764734873007742e42b2e..663f87988ae3fad5a00d8ca2976635f702b7f42f 100644 --- a/ee/db/fixtures/development/30_customizable_cycle_analytics.rb +++ b/ee/db/fixtures/development/30_customizable_cycle_analytics.rb @@ -20,15 +20,16 @@ class Gitlab::Seeder::CustomizableCycleAnalytics include ActiveSupport::Testing::TimeHelpers include CycleAnalyticsHelpers - attr_reader :project, :group, :user + attr_reader :project, :group, :user, :organization DAYS_BACK = 20 ISSUE_COUNT = 25 MERGE_REQUEST_COUNT = 10 GROUP_LABEL_COUNT = 10 - def initialize(project) + def initialize(organization:, project: nil) @user = User.admins.first + @organization = organization @project = project || create_vsm_project! @group = @project.group.root_ancestor end @@ -226,7 +227,8 @@ def merge_requests def create_vsm_project! group = Group.new( name: "Value Stream Management Group #{suffix}", - path: "vsmg-#{suffix}" + path: "vsmg-#{suffix}", + organization: organization ) group.description = FFaker::Lorem.sentence group.save! @@ -237,7 +239,7 @@ def create_vsm_project! # before transaction is commited. group.update!(traversal_ids: [group.id]) - Gitlab::Seeder::Projects.create_real_project!(project_path: "vsmp-#{suffix}", group_path: group.path) + Gitlab::Seeder::Projects.create_real_project!(project_path: "vsmp-#{suffix}", group_path: group.path, organization: organization) group.projects.last end @@ -290,7 +292,10 @@ def get_date_after(created_at) project = Project.find(project_id) if project_id if ENV[flag] - seeder = Gitlab::Seeder::CustomizableCycleAnalytics.new(project) + seeder = Gitlab::Seeder::CustomizableCycleAnalytics.new( + project: project, + organization: Organizations::Organization.default_organization + ) seeder.seed! else puts "Skipped. Use the `#{flag}` environment variable to enable." diff --git a/ee/spec/lib/ee/gitlab/background_migration/backfill_free_shared_runners_minutes_limit_spec.rb b/ee/spec/lib/ee/gitlab/background_migration/backfill_free_shared_runners_minutes_limit_spec.rb index e3c0eddb5dd3e4bc506adbc34ece743bf30dd259..59c0e2ff4dc8ddedc99cbb61abc9b2c9f0af6ced 100644 --- a/ee/spec/lib/ee/gitlab/background_migration/backfill_free_shared_runners_minutes_limit_spec.rb +++ b/ee/spec/lib/ee/gitlab/background_migration/backfill_free_shared_runners_minutes_limit_spec.rb @@ -6,10 +6,9 @@ let!(:namespaces) { table(:namespaces) } let(:organizations) { table(:organizations) } - let(:organization) { organizations.create!(name: 'Foobar', path: 'path1') } - let(:start_id) { namespaces.minimum(:id) } let(:end_id) { namespaces.maximum(:id) } + let(:organization) { table(:organizations).create!(name: 'organization', path: 'organization') } let!(:namespace_free_without_limit) do namespaces.create!( name: 'free_namespace_no_limit', diff --git a/ee/spec/services/sbom/ingestion/tasks/ingest_component_versions_spec.rb b/ee/spec/services/sbom/ingestion/tasks/ingest_component_versions_spec.rb index b3ccf8a30df2bb17c625ad00c30b068f92b07419..092c1e83398dbb95b3591fad78811e755c06f665 100644 --- a/ee/spec/services/sbom/ingestion/tasks/ingest_component_versions_spec.rb +++ b/ee/spec/services/sbom/ingestion/tasks/ingest_component_versions_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Sbom::Ingestion::Tasks::IngestComponentVersions, feature_category: :dependency_management do describe '#execute' do - let_it_be(:pipeline) { build_stubbed(:ci_pipeline) } + let_it_be(:pipeline) { create(:ci_pipeline) } let(:occurrence_maps) { create_list(:sbom_occurrence_map, 4, :with_component) } diff --git a/ee/spec/services/sbom/ingestion/tasks/ingest_components_spec.rb b/ee/spec/services/sbom/ingestion/tasks/ingest_components_spec.rb index 931e9fdc39138a3bd1046c89be30b04484e63a88..61d3b7736e78ea2f20e465b5224dd242b86db9d2 100644 --- a/ee/spec/services/sbom/ingestion/tasks/ingest_components_spec.rb +++ b/ee/spec/services/sbom/ingestion/tasks/ingest_components_spec.rb @@ -6,7 +6,7 @@ describe '#execute' do let!(:organization) { create(:organization, :default) } - let_it_be(:pipeline) { build_stubbed(:ci_pipeline) } + let_it_be(:pipeline) { create(:ci_pipeline) } let(:occurrence_maps) { create_list(:sbom_occurrence_map, 4) } let(:occurrence_map) { create(:sbom_occurrence_map) } diff --git a/ee/spec/services/sbom/ingestion/tasks/ingest_source_packages_spec.rb b/ee/spec/services/sbom/ingestion/tasks/ingest_source_packages_spec.rb index 6ccebfd76dab59bf0703d693680c0bad17a799db..32c1a0f88bbae7bd363f3f7e1095a0d8079af0e8 100644 --- a/ee/spec/services/sbom/ingestion/tasks/ingest_source_packages_spec.rb +++ b/ee/spec/services/sbom/ingestion/tasks/ingest_source_packages_spec.rb @@ -4,9 +4,7 @@ RSpec.describe Sbom::Ingestion::Tasks::IngestSourcePackages, feature_category: :dependency_management do describe '#execute' do - let!(:organization) { create(:organization, :default) } - - let_it_be(:pipeline) { build_stubbed(:ci_pipeline) } + let_it_be(:pipeline) { create(:ci_pipeline) } let_it_be(:occurrence_maps) { build_list(:sbom_occurrence_map, 2, :with_source_package) } subject(:ingest_source_package) { described_class.new(pipeline, occurrence_maps) } diff --git a/spec/finders/organizations/groups_finder_spec.rb b/spec/finders/organizations/groups_finder_spec.rb index 1a15bc8acdf673572478652d235396e8ccc56eda..94faa6f99b2b3a787d944473247aeda25daea9b5 100644 --- a/spec/finders/organizations/groups_finder_spec.rb +++ b/spec/finders/organizations/groups_finder_spec.rb @@ -8,8 +8,12 @@ let_it_be(:organization) { organization_user.organization } let_it_be(:user) { organization_user.user } let_it_be(:default_organization) { create(:organization, :default) } + let_it_be(:other_organization) { create(:organization) } let_it_be_with_reload(:public_group) { create(:group, name: 'public-group', organization: organization) } - let_it_be_with_reload(:outside_organization_group) { create(:group) } + let_it_be_with_reload(:outside_organization_group) do + create(:group, name: 'outside-organization', organization: other_organization) + end + let_it_be_with_reload(:private_group) do create(:group, :private, name: 'private-group', organization: organization) end diff --git a/spec/models/concerns/case_sensitivity_spec.rb b/spec/models/concerns/case_sensitivity_spec.rb index 63ca1403fab0cfe85cd196b7ae67b30cd0f7dad3..49248af7e46e2d7d13886674930d01c7ced8027d 100644 --- a/spec/models/concerns/case_sensitivity_spec.rb +++ b/spec/models/concerns/case_sensitivity_spec.rb @@ -5,6 +5,7 @@ RSpec.describe CaseSensitivity do describe '.iwhere' do let_it_be(:connection) { Namespace.connection } + let_it_be(:organization) { create(:organization) } let_it_be(:model) do Class.new(ActiveRecord::Base) do include CaseSensitivity @@ -13,11 +14,9 @@ end end - let_it_be(:organization) { Organizations::Organization.create!(name: 'organization', path: 'organization') } let_it_be(:model_1) do - model.create!( - path: 'mOdEl-1', name: 'mOdEl 1', type: Namespaces::UserNamespace.sti_name, organization_id: organization.id - ) + model.create!(path: 'mOdEl-1', name: 'mOdEl 1', type: Namespaces::UserNamespace.sti_name, + organization_id: organization.id) end let_it_be(:model_2) do diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 3e0095f3cb5a8fbc309e5d4b8727a904ad9b4dcd..793457dfb07438433658017d0e1ee8755907020b 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -286,43 +286,31 @@ describe 'default values' do context 'organzation_id' do - context 'when feature flag namespace_model_default_org is enabled' do - context 'and database has a default value' do - before do - described_class.connection.execute("ALTER TABLE namespaces ALTER COLUMN organization_id SET DEFAULT 100") - described_class.reset_column_information - end - - after do - described_class.connection.execute("ALTER TABLE namespaces ALTER COLUMN organization_id SET DEFAULT 1") - described_class.reset_column_information - end + context 'when FF require_organization is enabled' do + context 'and organization is set' do + let(:created_namespace) { build(:group) } - it 'uses value from model' do - expect(described_class.new.organization_id).to eq(1) + it 'is valid' do + expect(created_namespace).to be_valid end end - context 'and database has no default value' do - before do - described_class.connection.execute("ALTER TABLE namespaces ALTER COLUMN organization_id DROP DEFAULT") - described_class.reset_column_information - end + context 'and organization is not set' do + let(:created_namespace) { build(:group) } - after do - described_class.connection.execute("ALTER TABLE namespaces ALTER COLUMN organization_id SET DEFAULT 1") - described_class.reset_column_information + before do + created_namespace.organization_id = nil end - it 'uses value from model' do - expect(described_class.new.organization_id).to eq(1) + it 'is invalid' do + expect(created_namespace).to be_invalid end end end - context 'when feature flag namespace_model_default_org is disabled' do + context 'when FF require_organization is disabled' do before do - stub_feature_flags(namespace_model_default_org: false) + stub_feature_flags(require_organization: false) end context 'and database has a default value' do @@ -331,19 +319,13 @@ described_class.reset_column_information end - it 'uses database value' do - expect(described_class.new.organization_id).to eq(100) - end - end - - context 'and database has no default value' do - before do - described_class.connection.execute("ALTER TABLE namespaces ALTER COLUMN organization_id DROP DEFAULT") + after do + described_class.connection.execute("ALTER TABLE namespaces ALTER COLUMN organization_id SET DEFAULT 1") described_class.reset_column_information end - it 'is nil' do - expect(described_class.new.organization_id).to be_nil + it 'uses value from model' do + expect(described_class.new.organization_id).to eq(Organizations::Organization::DEFAULT_ORGANIZATION_ID) end end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c175954f13e6d0766df52fcda02b34ebf2cbaa8e..2ea45caa503e708ecddd55b131d366c69ab851af 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -6559,14 +6559,6 @@ def add_user(access) it 'returns the personal namespace' do expect(personal_namespace).to eq(user.namespace) end - - context 'when organization is nil' do - it 'builds a new namespace using default organization' do - user.assign_personal_namespace(nil) - - expect(user.namespace.organization).to eq(Organizations::Organization.default_organization) - end - end end end diff --git a/spec/requests/api/graphql/organizations/organization_query_spec.rb b/spec/requests/api/graphql/organizations/organization_query_spec.rb index ce2ee4abced7be0052ca3911e6c20c4c720e5d86..0616c285eaf1943b8a511780ed5e662fa2b5aa2c 100644 --- a/spec/requests/api/graphql/organizations/organization_query_spec.rb +++ b/spec/requests/api/graphql/organizations/organization_query_spec.rb @@ -133,7 +133,7 @@ def run_query create(:group, :private, name: 'no-access', organization: organization) private_group.add_developer(user) public_group.add_developer(user) - create(:group) { |g| g.add_developer(user) } # outside organization + create(:group, organization: create(:organization)) { |g| g.add_developer(user) } # outside organization end it 'returns ancestors of authorized groups' do @@ -215,7 +215,8 @@ def pagination_query(params) end before_all do - create(:project) { |p| p.add_developer(user) } # some other project that shouldn't show up in our results + # some other project that shouldn't show up in our results + create(:project, organization: create(:organization)) { |p| p.add_developer(user) } end before do diff --git a/spec/services/groups/create_service_spec.rb b/spec/services/groups/create_service_spec.rb index 2702f475422d89f7f294b13c4868720763c08bdb..d33aece18537401c3a4685df94c0e93100d6780a 100644 --- a/spec/services/groups/create_service_spec.rb +++ b/spec/services/groups/create_service_spec.rb @@ -238,12 +238,9 @@ end context 'when organization_id is not specified' do - let_it_be(:default_organization) { create(:organization, :default) } let(:group_params) { { path: 'group_path' } } - it 'creates group in default organization' do - expect(created_group.organization).to eq(default_organization) - end + it_behaves_like 'does not create a group' end end