diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2017-10-05 15:01:26 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2017-10-05 15:01:26 +0200 |
commit | f879c58706305600fc894e9e2ce8b972c0da1d87 (patch) | |
tree | 6fd2f5754563700bee72a4bea85a024b39dda92a /spec/models | |
parent | 4656283c5cd10116d79812db24c37ff79b0e0273 (diff) | |
download | gitlab-ce-f879c58706305600fc894e9e2ce8b972c0da1d87.tar.gz |
Fix namespace deletion tests
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/namespace_spec.rb | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 81d5ab7a6d3..3ea614776ca 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -152,22 +152,24 @@ describe Namespace do end describe '#move_dir' do + let(:namespace) { create(:namespace) } + let!(:project) { create(:project_empty_repo, namespace: namespace) } + before do - @namespace = create :namespace - @project = create(:project_empty_repo, namespace: @namespace) - allow(@namespace).to receive(:path_changed?).and_return(true) + allow(namespace).to receive(:path_changed?).and_return(true) end 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 it "moves dir if path changed" do - 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) - expect(@namespace).to receive(:remove_exports!) - expect(@namespace.move_dir).to be_truthy + 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) + expect(namespace).to receive(:remove_exports!) + expect(namespace.move_dir).to be_truthy end context "when any project has container images" do @@ -177,14 +179,14 @@ describe Namespace do stub_container_registry_config(enabled: true) 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).and_return('new_path') + allow(namespace).to receive(:path_was).and_return(namespace.path) + allow(namespace).to receive(:path).and_return('new_path') end 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 |