Commit f412d4fb authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'fix-tree-saver-and-tree-restorer-specs' into 'master'

Fix treeSaver and treeRestorer specs

Closes #214003

See merge request gitlab-org/gitlab!29275
parents ee9e3c9f c5b161d8
...@@ -70,8 +70,7 @@ module Gitlab ...@@ -70,8 +70,7 @@ module Gitlab
# Do not create relation if it is: # Do not create relation if it is:
# - An unknown service # - An unknown service
# - A legacy trigger # - A legacy trigger
unknown_service? || unknown_service? || legacy_trigger?
(!Feature.enabled?(:use_legacy_pipeline_triggers, @importable) && legacy_trigger?)
end end
def setup_models def setup_models
......
...@@ -25,7 +25,7 @@ describe Gitlab::ImportExport::Project::TreeRestorer, quarantine: { flaky: 'http ...@@ -25,7 +25,7 @@ describe Gitlab::ImportExport::Project::TreeRestorer, quarantine: { flaky: 'http
@project = create(:project, :builds_enabled, :issues_disabled, name: 'project', path: 'project') @project = create(:project, :builds_enabled, :issues_disabled, name: 'project', path: 'project')
@shared = @project.import_export_shared @shared = @project.import_export_shared
allow(Feature).to receive(:enabled?).and_call_original allow(Feature).to receive(:enabled?) { true }
stub_feature_flags(project_import_ndjson: ndjson_enabled) stub_feature_flags(project_import_ndjson: ndjson_enabled)
setup_import_export_config('complex') setup_import_export_config('complex')
...@@ -34,6 +34,7 @@ describe Gitlab::ImportExport::Project::TreeRestorer, quarantine: { flaky: 'http ...@@ -34,6 +34,7 @@ describe Gitlab::ImportExport::Project::TreeRestorer, quarantine: { flaky: 'http
allow_any_instance_of(Repository).to receive(:fetch_source_branch!).and_return(true) allow_any_instance_of(Repository).to receive(:fetch_source_branch!).and_return(true)
allow_any_instance_of(Gitlab::Git::Repository).to receive(:branch_exists?).and_return(false) allow_any_instance_of(Gitlab::Git::Repository).to receive(:branch_exists?).and_return(false)
expect(@shared).not_to receive(:error)
expect_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch).with('feature', 'DCBA') expect_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch).with('feature', 'DCBA')
allow_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch) allow_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch)
......
...@@ -29,12 +29,11 @@ describe Gitlab::ImportExport::Project::TreeSaver do ...@@ -29,12 +29,11 @@ describe Gitlab::ImportExport::Project::TreeSaver do
before_all do before_all do
RSpec::Mocks.with_temporary_scope do RSpec::Mocks.with_temporary_scope do
allow(Feature).to receive(:enabled?).and_call_original allow(Feature).to receive(:enabled?) { true }
stub_feature_flags(project_export_as_ndjson: ndjson_enabled) stub_feature_flags(project_export_as_ndjson: ndjson_enabled)
project.add_maintainer(user) 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 = described_class.new(project: project, current_user: user, shared: shared)
project_tree_saver.save project_tree_saver.save
......
...@@ -38,15 +38,12 @@ module ImportExport ...@@ -38,15 +38,12 @@ module ImportExport
end end
def setup_reader(reader) def setup_reader(reader)
case reader if reader == :ndjson_reader && Feature.enabled?(:project_import_ndjson)
when :legacy_reader
allow_any_instance_of(Gitlab::ImportExport::JSON::LegacyReader::File).to receive(:exist?).and_return(true)
allow_any_instance_of(Gitlab::ImportExport::JSON::NdjsonReader).to receive(:exist?).and_return(false)
when :ndjson_reader
allow_any_instance_of(Gitlab::ImportExport::JSON::LegacyReader::File).to receive(:exist?).and_return(false) allow_any_instance_of(Gitlab::ImportExport::JSON::LegacyReader::File).to receive(:exist?).and_return(false)
allow_any_instance_of(Gitlab::ImportExport::JSON::NdjsonReader).to receive(:exist?).and_return(true) allow_any_instance_of(Gitlab::ImportExport::JSON::NdjsonReader).to receive(:exist?).and_return(true)
else else
raise "invalid reader #{reader}. Supported readers: :legacy_reader, :ndjson_reader" allow_any_instance_of(Gitlab::ImportExport::JSON::LegacyReader::File).to receive(:exist?).and_return(true)
allow_any_instance_of(Gitlab::ImportExport::JSON::NdjsonReader).to receive(:exist?).and_return(false)
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