summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-12-04 11:29:25 +0100
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-12-12 16:05:38 +0100
commitdad4c0b645d499c93fba14ce1e691da151929071 (patch)
tree4c06fa010755af6a3cbaf0f795f9f1681665144b /spec/models
parent2a181d68c810e89ff5d2e49999775d8b58adb394 (diff)
downloadgitlab-ce-dad4c0b645d499c93fba14ce1e691da151929071.tar.gz
Move Repository#write_ref to Git::Repository#write_refrepo-write-ref-client-prep
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/project_spec.rb5
-rw-r--r--spec/models/repository_spec.rb17
2 files changed, 20 insertions, 2 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index f4699fd243d..dd9e8498519 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -1863,10 +1863,11 @@ describe Project do
project.change_head(project.default_branch)
end
- it 'creates the new reference with rugged' do
- expect(project.repository.rugged.references).to receive(:create).with('HEAD',
+ it 'creates the new reference' do
+ expect(project.repository.raw_repository).to receive(:write_ref).with('HEAD',
"refs/heads/#{project.default_branch}",
force: true)
+
project.change_head(project.default_branch)
end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 358bc3dfb94..129fce74f45 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1916,6 +1916,23 @@ describe Repository do
File.delete(path)
end
+
+ it "attempting to call keep_around when exists a lock does not fail" do
+ ref = repository.send(:keep_around_ref_name, sample_commit.id)
+ path = File.join(repository.path, ref)
+ lock_path = "#{path}.lock"
+
+ FileUtils.mkdir_p(File.dirname(path))
+ File.open(lock_path, 'w') { |f| f.write('') }
+
+ begin
+ expect { repository.keep_around(sample_commit.id) }.not_to raise_error(Gitlab::Git::Repository::GitError)
+
+ expect(File.exist?(lock_path)).to be_falsey
+ ensure
+ File.delete(path)
+ end
+ end
end
describe '#update_ref' do