Commit f879c587 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Fix namespace deletion tests

parent 4656283c
...@@ -271,6 +271,8 @@ module Gitlab ...@@ -271,6 +271,8 @@ module Gitlab
FileUtils.mv(full_path(storage, old_name), full_path(storage, new_name)) FileUtils.mv(full_path(storage, old_name), full_path(storage, new_name))
end end
end end
rescue GRPC::InvalidArgument
false
end end
def url_to_repo(path) def url_to_repo(path)
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Admin::UsersController do describe Admin::UsersController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:admin) { create(:admin) } set(:admin) { create(:admin) }
before do before do
sign_in(admin) sign_in(admin)
......
...@@ -152,22 +152,24 @@ describe Namespace do ...@@ -152,22 +152,24 @@ describe Namespace do
end end
describe '#move_dir' do describe '#move_dir' do
let(:namespace) { create(:namespace) }
let!(:project) { create(:project_empty_repo, namespace: namespace) }
before do before do
@namespace = create :namespace allow(namespace).to receive(:path_changed?).and_return(true)
@project = create(:project_empty_repo, namespace: @namespace)
allow(@namespace).to receive(:path_changed?).and_return(true)
end end
it "raises error when directory exists" do it "raises error when directory exists" do
expect { @namespace.move_dir }.to raise_error("namespace directory cannot be moved") expect { namespace.move_dir }.to raise_error("namespace directory cannot be moved")
end end
it "moves dir if path changed" do it "moves dir if path changed" do
new_path = @namespace.full_path + "_new" new_path = namespace.full_path + "_new"
allow(@namespace).to receive(:full_path_was).and_return(@namespace.full_path)
allow(@namespace).to receive(:full_path).and_return(new_path) allow(namespace).to receive(:full_path_was).and_return(namespace.full_path)
expect(@namespace).to receive(:remove_exports!) allow(namespace).to receive(:full_path).and_return(new_path)
expect(@namespace.move_dir).to be_truthy expect(namespace).to receive(:remove_exports!)
expect(namespace.move_dir).to be_truthy
end end
context "when any project has container images" do context "when any project has container images" do
...@@ -177,14 +179,14 @@ describe Namespace do ...@@ -177,14 +179,14 @@ describe Namespace do
stub_container_registry_config(enabled: true) stub_container_registry_config(enabled: true)
stub_container_registry_tags(repository: :any, tags: ['tag']) stub_container_registry_tags(repository: :any, tags: ['tag'])
create(:project, namespace: @namespace, container_repositories: [container_repository]) create(:project, namespace: namespace, container_repositories: [container_repository])
allow(@namespace).to receive(:path_was).and_return(@namespace.path) allow(namespace).to receive(:path_was).and_return(namespace.path)
allow(@namespace).to receive(:path).and_return('new_path') allow(namespace).to receive(:path).and_return('new_path')
end end
it 'raises an error about not movable project' do it 'raises an error about not movable project' do
expect { @namespace.move_dir }.to raise_error(/Namespace cannot be moved/) expect { namespace.move_dir }.to raise_error(/Namespace cannot be moved/)
end end
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