Commit 49d35e1f authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '331906_fix_tests_for_design' into 'master'

Update tests for design to support default branch

See merge request gitlab-org/gitlab!65271
parents de54ed9a d69cea62
......@@ -119,7 +119,7 @@ module DesignManagement
# Returns the latest blobs for the designs as a Hash of `{ Design => Blob }`
def existing_blobs
@existing_blobs ||= begin
items = designs.map { |d| ['HEAD', d.full_path] }
items = designs.map { |d| [target_branch, d.full_path] }
repository.blobs_at(items).each_with_object({}) do |blob, h|
design = designs.find { |d| d.full_path == blob.path }
......
......@@ -109,7 +109,7 @@ RSpec.describe Projects::DesignManagement::Designs::RawImagesController do
context 'when sha is nil' do
let(:sha) { nil }
let(:expected_ref) { 'master' }
let(:expected_ref) { project.design_repository.root_ref }
it_behaves_like 'a successful request for sha'
end
......
......@@ -191,8 +191,8 @@ RSpec.describe DesignManagement::CopyDesignCollection::CopyService, :clean_gitla
expect(commits_on_master(limit: 99)).to include(*target_issue.design_versions.ordered.pluck(:sha))
end
it 'creates a master branch if none previously existed' do
expect { subject }.to change { target_repository.branch_names }.from([]).to(['master'])
it 'creates a default branch if none previously existed' do
expect { subject }.to change { target_repository.branch_names }.from([]).to([project.design_repository.root_ref])
end
it 'does not create default branch when one exists' do
......@@ -255,7 +255,7 @@ RSpec.describe DesignManagement::CopyDesignCollection::CopyService, :clean_gitla
end
def commits_on_master(limit: 10)
target_repository.commits('master', limit: limit).map(&:id)
target_repository.commits(target_repository.root_ref, limit: limit).map(&:id)
end
end
end
......
......@@ -177,6 +177,18 @@ RSpec.describe DesignManagement::SaveDesignsService do
end
end
context 'when HEAD branch is different from master' do
before do
stub_feature_flags(main_branch_over_master: true)
end
it 'does not raise an exception during update' do
run_service
expect { run_service }.not_to raise_error
end
end
context 'when a design is being updated' do
before do
run_service
......@@ -343,7 +355,7 @@ RSpec.describe DesignManagement::SaveDesignsService do
path = File.join(build(:design, issue: issue, filename: filename).full_path)
design_repository.create_if_not_exists
design_repository.create_file(user, path, 'something fake',
branch_name: 'master',
branch_name: project.default_branch_or_main,
message: 'Somehow created without being tracked in db')
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