Commit 095e2843 authored by Francisco Javier López's avatar Francisco Javier López

Merge branch '331906_fix_tests_for_snippets' into 'master'

Update tests for snippets to support default branch

See merge request gitlab-org/gitlab!65552
parents 031711dc 51da7c74
...@@ -29,7 +29,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoRestorer do ...@@ -29,7 +29,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoRestorer do
expect(restorer.restore).to be_truthy expect(restorer.restore).to be_truthy
end.to change { SnippetRepository.count }.by(1) end.to change { SnippetRepository.count }.by(1)
blob = snippet.repository.blob_at('HEAD', snippet.file_name) blob = snippet.repository.blob_at(snippet.default_branch, snippet.file_name)
expect(blob).not_to be_nil expect(blob).not_to be_nil
expect(blob.data).to eq(snippet.content) expect(blob.data).to eq(snippet.content)
end end
......
...@@ -828,14 +828,10 @@ RSpec.describe Snippet do ...@@ -828,14 +828,10 @@ RSpec.describe Snippet do
end end
context 'when default branch in settings is different from "master"' do context 'when default branch in settings is different from "master"' do
let(:default_branch) { 'main' } let(:default_branch) { 'custom-branch' }
it 'changes the HEAD reference to the default branch' do it 'changes the HEAD reference to the default branch' do
expect(File.read(head_path).squish).to eq 'ref: refs/heads/master' expect { subject }.to change { File.read(head_path).squish }.to("ref: refs/heads/#{default_branch}")
subject
expect(File.read(head_path).squish).to eq "ref: refs/heads/#{default_branch}"
end end
end end
end end
......
...@@ -85,8 +85,8 @@ RSpec.describe 'Creating a Snippet' do ...@@ -85,8 +85,8 @@ RSpec.describe 'Creating a Snippet' do
end.to change { Snippet.count }.by(1) end.to change { Snippet.count }.by(1)
snippet = Snippet.last snippet = Snippet.last
created_file_1 = snippet.repository.blob_at('HEAD', file_1[:filePath]) created_file_1 = snippet.repository.blob_at(snippet.default_branch, file_1[:filePath])
created_file_2 = snippet.repository.blob_at('HEAD', file_2[:filePath]) created_file_2 = snippet.repository.blob_at(snippet.default_branch, file_2[:filePath])
expect(created_file_1.data).to match(file_1[:content]) expect(created_file_1.data).to match(file_1[:content])
expect(created_file_2.data).to match(file_2[:content]) expect(created_file_2.data).to match(file_2[:content])
......
...@@ -138,7 +138,7 @@ RSpec.describe API::ProjectSnippets do ...@@ -138,7 +138,7 @@ RSpec.describe API::ProjectSnippets do
aggregate_failures do aggregate_failures do
expect(snippet.repository.exists?).to be_truthy expect(snippet.repository.exists?).to be_truthy
blob = snippet.repository.blob_at('master', file_path) blob = snippet.repository.blob_at(snippet.default_branch, file_path)
expect(blob.data).to eq file_content expect(blob.data).to eq file_content
end end
......
...@@ -223,7 +223,7 @@ RSpec.describe API::Snippets, factory_default: :keep do ...@@ -223,7 +223,7 @@ RSpec.describe API::Snippets, factory_default: :keep do
it 'commit the files to the repository' do it 'commit the files to the repository' do
subject subject
blob = snippet.repository.blob_at('master', file_path) blob = snippet.repository.blob_at(snippet.default_branch, file_path)
expect(blob.data).to eq file_content expect(blob.data).to eq file_content
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