Commit 65427442 authored by James Lopez's avatar James Lopez

refactored a couple of things

parent cec1e3eb
...@@ -4,18 +4,19 @@ include ImportExport::CommonUtil ...@@ -4,18 +4,19 @@ include ImportExport::CommonUtil
describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
describe 'restore project tree' do describe 'restore project tree' do
before(:all) do before(:all) do
user = create(:user) @user = create(:user)
RSpec::Mocks.with_temporary_scope do RSpec::Mocks.with_temporary_scope do
@shared = Gitlab::ImportExport::Shared.new(relative_path: "", project_path: 'path') @shared = Gitlab::ImportExport::Shared.new(relative_path: "", project_path: 'path')
allow(@shared).to receive(:export_path).and_return('spec/lib/gitlab/import_export/') allow(@shared).to receive(:export_path).and_return('spec/lib/gitlab/import_export/')
project = create(:empty_project, :builds_disabled, :issues_disabled, name: 'project', path: 'project') @project = create(:empty_project, :builds_disabled, :issues_disabled, name: 'project', path: 'project')
project_tree_restorer = described_class.new(user: user, shared: @shared, project: project) project_tree_restorer = described_class.new(user: @user, shared: @shared, project: @project)
@restored_project_json = project_tree_restorer.restore @restored_project_json = project_tree_restorer.restore
end end
end end
before do after(:all) do
@user.destroy!
end end
context 'JSON' do context 'JSON' do
...@@ -98,7 +99,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do ...@@ -98,7 +99,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
end end
it 'has a project feature' do it 'has a project feature' do
expect(Project.first.project_feature).not_to be_nil expect(@project.project_feature).not_to be_nil
end end
it 'restores the correct service' do it 'restores the correct service' do
...@@ -106,20 +107,16 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do ...@@ -106,20 +107,16 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
end end
context 'Merge requests' do context 'Merge requests' do
before do
@restored_project_json
end
it 'always has the new project as a target' do it 'always has the new project as a target' do
expect(MergeRequest.find_by_title('MR1').target_project).to eq(Project.first) expect(MergeRequest.find_by_title('MR1').target_project).to eq(@project)
end end
it 'has the same source project as originally if source/target are the same' do it 'has the same source project as originally if source/target are the same' do
expect(MergeRequest.find_by_title('MR1').source_project).to eq(Project.first) expect(MergeRequest.find_by_title('MR1').source_project).to eq(@project)
end end
it 'has the new project as target if source/target differ' do it 'has the new project as target if source/target differ' do
expect(MergeRequest.find_by_title('MR2').target_project).to eq(Project.first) expect(MergeRequest.find_by_title('MR2').target_project).to eq(@project)
end end
it 'has no source if source/target differ' do it 'has no source if source/target differ' do
......
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