Commit c1e39421 authored by James Edwards-Jones's avatar James Edwards-Jones

Extract constant for LfsPointerFile::VERSION_LINE

parent 9d32fccf
module Gitlab module Gitlab
module Git module Git
class LfsPointerFile class LfsPointerFile
VERSION = "https://git-lfs.github.com/spec/v1".freeze
VERSION_LINE = "version #{VERSION}".freeze
def initialize(data) def initialize(data)
@data = data @data = data
end end
def pointer def pointer
@pointer ||= <<~FILE @pointer ||= <<~FILE
version https://git-lfs.github.com/spec/v1 #{VERSION_LINE}
oid sha256:#{sha256} oid sha256:#{sha256}
size #{size} size #{size}
FILE FILE
......
...@@ -43,7 +43,7 @@ describe Files::CreateService do ...@@ -43,7 +43,7 @@ describe Files::CreateService do
blob = repository.blob_at('lfs', file_path) blob = repository.blob_at('lfs', file_path)
expect(blob.data).not_to start_with('version https://git-lfs.github.com/spec/v1') expect(blob.data).not_to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
expect(blob.data).to eq(file_content) expect(blob.data).to eq(file_content)
end end
end end
...@@ -58,7 +58,7 @@ describe Files::CreateService do ...@@ -58,7 +58,7 @@ describe Files::CreateService do
blob = repository.blob_at('lfs', file_path) blob = repository.blob_at('lfs', file_path)
expect(blob.data).to start_with('version https://git-lfs.github.com/spec/v1') expect(blob.data).to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
end end
it "creates an LfsObject with the file's content" do it "creates an LfsObject with the file's content" do
......
...@@ -126,7 +126,7 @@ describe Files::MultiService do ...@@ -126,7 +126,7 @@ describe Files::MultiService do
blob = repository.blob_at('lfs', new_file_path) blob = repository.blob_at('lfs', new_file_path)
expect(blob.data).to start_with('version https://git-lfs.github.com/spec/v1') expect(blob.data).to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
end end
it "creates an LfsObject with the file's content" do it "creates an LfsObject with the file's content" do
...@@ -145,7 +145,7 @@ describe Files::MultiService do ...@@ -145,7 +145,7 @@ describe Files::MultiService do
blob = repository.blob_at('lfs', new_file_path) blob = repository.blob_at('lfs', new_file_path)
expect(blob.data).to start_with('version https://git-lfs.github.com/spec/v1') expect(blob.data).to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
end end
it "creates an LfsObject with the file's content" do it "creates an LfsObject with the file's content" do
......
...@@ -53,7 +53,7 @@ describe Lfs::FileTransformer do ...@@ -53,7 +53,7 @@ describe Lfs::FileTransformer do
it 'returns an LFS pointer' do it 'returns an LFS pointer' do
result = subject.new_file(file_path, file_content) result = subject.new_file(file_path, file_content)
expect(result.content).to start_with('version https://git-lfs.github.com/spec/v1') expect(result.content).to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
end end
it 'returns LFS pointer encoding as text' do it 'returns LFS pointer encoding as text' do
...@@ -68,7 +68,7 @@ describe Lfs::FileTransformer do ...@@ -68,7 +68,7 @@ describe Lfs::FileTransformer do
it "doesn't create LFS pointers" do it "doesn't create LFS pointers" do
new_content = subject.new_file(file_path, file_content).content new_content = subject.new_file(file_path, file_content).content
expect(new_content).not_to start_with('version https://git-lfs.github.com/spec/v1') expect(new_content).not_to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
expect(new_content).to eq(file_content) expect(new_content).to eq(file_content)
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