diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-07-04 02:58:58 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-07-04 07:11:33 +0300 |
commit | 3286dd7a1db69460573a5fd2c9e997039b1f406b (patch) | |
tree | fba63dd375acb038a1e27f03eb9ba7530578cefd /spec/models | |
parent | 0ccdc631e6f45c0fd327631decb47f80d781302e (diff) |
Don't garbage collect commits that have related DB records like comments
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/merge_request_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/note_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 8 |
3 files changed, 14 insertions, 2 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 3b199f4d98d..ceb4d64698f 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -464,7 +464,7 @@ describe MergeRequest, models: true do context 'when it is not broken and has no conflicts' do it 'is marked as mergeable' do allow(subject).to receive(:broken?) { false } - allow(project).to receive_message_chain(:repository, :can_be_merged?) { true } + allow(project.repository).to receive(:can_be_merged?) { true } expect { subject.check_if_can_be_merged }.to change { subject.merge_status }.to('can_be_merged') end @@ -481,7 +481,7 @@ describe MergeRequest, models: true do context 'when it has conflicts' do before do allow(subject).to receive(:broken?) { false } - allow(project).to receive_message_chain(:repository, :can_be_merged?) { false } + allow(project.repository).to receive(:can_be_merged?) { false } end it 'becomes unmergeable' do diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 285ab19cfaf..6549791f675 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -70,6 +70,10 @@ describe Note, models: true do it "should be recognized by #for_commit?" do expect(note).to be_for_commit end + + it "keeps the commit around" do + expect(note.project.repository.kept_around?(commit.id)).to be_truthy + end end describe 'authorization' do diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 851b8b241d7..e753306a31f 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1117,6 +1117,14 @@ describe Repository, models: true do end end + describe "#keep_around" do + it "stores a reference to the specified commit sha so it isn't garbage collected" do + repository.keep_around(sample_commit.id) + + expect(repository.kept_around?(sample_commit.id)).to be_truthy + end + end + def create_remote_branch(remote_name, branch_name, target) rugged = repository.rugged rugged.references.create("refs/remotes/#{remote_name}/#{branch_name}", target) |