Commit 7ab06d44 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Update specs to respect Project#namespace_id not null constraint

Signed-off-by: default avatarDmitriy Zaporozhets <>
parent f02adf74d437
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20170502101023_cleanup_namespaceless_pending_delete_projects.rb')
describe CleanupNamespacelessPendingDeleteProjects do
describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222043024 do
before do
# Stub after_save callbacks that will fail when Project has no namespace
allow_any_instance_of(Project).to receive(:ensure_storage_path_exists).and_return(nil)
......@@ -8,7 +8,7 @@
let(:users) { table(:users) }
before do
project = projects.create!(name: 'gitlab')
project = projects.create!(name: 'gitlab', namespace_id: 1)
user = users.create(email: '')
issues.create(title: 'Issue 1', author_id: nil, project_id:
issues.create(title: 'Issue 2', author_id:, project_id:
......@@ -2499,7 +2499,8 @@ def enable_lfs
it 'is a no-op when there is no namespace' do
project.update_column(:namespace_id, nil)
expect_any_instance_of(Projects::UpdatePagesConfigurationService).not_to receive(:execute)
expect_any_instance_of(Gitlab::PagesTransfer).not_to receive(:rename_project)
......@@ -2531,7 +2532,8 @@ def enable_lfs
it 'is a no-op on legacy projects when there is no namespace' do
export_path = legacy_project.export_path
legacy_project.update_column(:namespace_id, nil)
expect(FileUtils).not_to receive(:rm_rf).with(export_path)
......@@ -2543,7 +2545,8 @@ def enable_lfs
it 'runs on hashed storage projects when there is no namespace' do
export_path = project.export_path
project.update_column(:namespace_id, nil)
allow(FileUtils).to receive(:rm_rf).and_call_original
expect(FileUtils).to receive(:rm_rf).with(export_path).and_call_original
......@@ -22,7 +22,9 @@
context 'project has no namespace' do
# Only possible with schema 20180222043024 and lower.
# Project#namespace_id has not null constraint since then
context 'project has no namespace', :migration, schema: 20180222043024 do
let!(:project) do
project = build(:project, namespace_id: nil) false)
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