diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/models/snippet_spec.rb | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) | |
download | gitlab-ce-aee0a117a889461ce8ced6fcf73207fe017f1d99.tar.gz |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/models/snippet_spec.rb')
-rw-r--r-- | spec/models/snippet_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index e24dd910c39..5d4a78bb15f 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -403,6 +403,51 @@ RSpec.describe Snippet do end end + describe '.find_by_project_title_trunc_created_at' do + let_it_be(:snippet) { create(:snippet) } + let_it_be(:created_at_without_ms) { snippet.created_at.change(usec: 0) } + + it 'returns a record if arguments match' do + result = described_class.find_by_project_title_trunc_created_at( + snippet.project, + snippet.title, + created_at_without_ms + ) + + expect(result).to eq(snippet) + end + + it 'returns nil if project does not match' do + result = described_class.find_by_project_title_trunc_created_at( + 'unmatched project', + snippet.title, + created_at_without_ms # to_s truncates ms of the argument + ) + + expect(result).to be(nil) + end + + it 'returns nil if title does not match' do + result = described_class.find_by_project_title_trunc_created_at( + snippet.project, + 'unmatched title', + created_at_without_ms # to_s truncates ms of the argument + ) + + expect(result).to be(nil) + end + + it 'returns nil if created_at does not match' do + result = described_class.find_by_project_title_trunc_created_at( + snippet.project, + snippet.title, + snippet.created_at # fails match by milliseconds + ) + + expect(result).to be(nil) + end + end + describe '#participants' do let_it_be(:project) { create(:project, :public) } let_it_be(:snippet) { create(:snippet, content: 'foo', project: project) } |