Commit 58f24bc1 authored by nmilojevic1's avatar nmilojevic1

Fix TreeRestorer and TreeSaver specs

- Remove Feature.enable
- Use stub_feature_flag instead
parent a7053fc2
......@@ -11,7 +11,7 @@ describe Gitlab::ImportExport::Project::TreeRestorer do
let(:shared) { project.import_export_shared }
RSpec.shared_examples 'project tree restorer work properly' do |reader|
RSpec.shared_examples 'project tree restorer work properly' do |reader, ndjson_enabled|
describe 'restore project tree' do
before_all do
# Using an admin for import, so we can check assignment of existing members
......@@ -25,6 +25,9 @@ describe Gitlab::ImportExport::Project::TreeRestorer do
@project = create(:project, :builds_enabled, :issues_disabled, name: 'project', path: 'project')
@shared = @project.import_export_shared
allow(Feature).to receive(:enabled?).and_call_original
stub_feature_flags(project_import_ndjson: ndjson_enabled)
setup_import_export_config('complex')
setup_reader(reader)
......@@ -999,23 +1002,12 @@ describe Gitlab::ImportExport::Project::TreeRestorer do
end
context 'enable ndjson import' do
before_all do
# Test suite `restore project tree` run `project_tree_restorer.restore` in `before_all`.
# `Enable all features by default for testing` happens in `before(:each)`
# So it requires manually enable feature flag to allow ndjson_reader
Feature.enable(:project_import_ndjson)
end
it_behaves_like 'project tree restorer work properly', :legacy_reader
it_behaves_like 'project tree restorer work properly', :legacy_reader, true
it_behaves_like 'project tree restorer work properly', :ndjson_reader
it_behaves_like 'project tree restorer work properly', :ndjson_reader, true
end
context 'disable ndjson import' do
before do
stub_feature_flags(project_import_ndjson: false)
end
it_behaves_like 'project tree restorer work properly', :legacy_reader
it_behaves_like 'project tree restorer work properly', :legacy_reader, false
end
end
......@@ -16,7 +16,6 @@ describe Gitlab::ImportExport::Project::TreeSaver do
let_it_be(:group) { create(:group) }
let_it_be(:project) { setup_project }
let_it_be(:shared) { project.import_export_shared }
let_it_be(:project_tree_saver ) { described_class.new(project: project, current_user: user, shared: shared) }
let(:relation_name) { :projects }
......@@ -29,9 +28,17 @@ describe Gitlab::ImportExport::Project::TreeSaver do
end
before_all do
Feature.enable(:project_export_as_ndjson) if ndjson_enabled
project.add_maintainer(user)
project_tree_saver.save
RSpec::Mocks.with_temporary_scope do
allow(Feature).to receive(:enabled?).and_call_original
stub_feature_flags(project_export_as_ndjson: ndjson_enabled)
project.add_maintainer(user)
stub_feature_flags(project_export_as_ndjson: ndjson_enabled)
project_tree_saver = described_class.new(project: project, current_user: user, shared: shared)
project_tree_saver.save
end
end
after :all 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