Commit 93ff65e1 authored by charlie ablett's avatar charlie ablett

Test project namespace is destroyed with project_namespace.rb

Changelog: added
parent eb506c84
......@@ -57,7 +57,7 @@ class Namespace < ApplicationRecord
has_one :admin_note, inverse_of: :namespace
accepts_nested_attributes_for :admin_note, update_only: true
validates :owner, presence: true, unless: ->(n) { n.type == "Group" }
validates :owner, presence: true, unless: ->(n) { n.type == "Group" || n.type == 'Namespaces::ProjectNamespace' }
validates :name,
presence: true,
length: { maximum: 255 }
......
# frozen_string_literal: true
FactoryBot.define do
factory :project_namespace, class: 'Namespaces::ProjectNamespace' do
project
sequence(:name) { |n| "project_namespace#{n}" }
path { name.downcase.gsub(/\s/, '_') }
type { 'Namespaces::ProjectNamespace' }
owner { nil }
project_creation_level { ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS }
end
end
......@@ -185,6 +185,17 @@ RSpec.describe Project, factory_default: :keep do
end
end
context 'when destroying project' do
let_it_be(:project) { create(:project) }
let_it_be(:project_namespace) { create(:project_namespace, project: project) }
it 'also destroys the associated ProjectNamespace' do
project.destroy!
expect { project_namespace.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
end
context 'when creating a new project' do
let_it_be(:project) { create(:project) }
......
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