diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/models/merge_request_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r-- | spec/models/merge_request_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index edd543854cb..4a8a2909891 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -80,6 +80,24 @@ RSpec.describe MergeRequest, factory_default: :keep do end end + describe '.order_closed_at_asc' do + let_it_be(:older_mr) { create(:merge_request, :closed_last_month) } + let_it_be(:newer_mr) { create(:merge_request, :closed_last_month) } + + it 'returns MRs ordered by closed_at ascending' do + expect(described_class.order_closed_at_asc).to eq([older_mr, newer_mr]) + end + end + + describe '.order_closed_at_desc' do + let_it_be(:older_mr) { create(:merge_request, :closed_last_month) } + let_it_be(:newer_mr) { create(:merge_request, :closed_last_month) } + + it 'returns MRs ordered by closed_at descending' do + expect(described_class.order_closed_at_desc).to eq([newer_mr, older_mr]) + end + end + describe '.with_jira_issue_keys' do let_it_be(:mr_with_jira_title) { create(:merge_request, :unique_branches, title: 'Fix TEST-123') } let_it_be(:mr_with_jira_description) { create(:merge_request, :unique_branches, description: 'this closes TEST-321') } @@ -577,6 +595,26 @@ RSpec.describe MergeRequest, factory_default: :keep do expect(merge_requests).to eq([newer_mr, older_mr]) end end + + context 'closed_at' do + let_it_be(:older_mr) { create(:merge_request, :closed_last_month) } + let_it_be(:newer_mr) { create(:merge_request, :closed_last_month) } + + it 'sorts asc' do + merge_requests = described_class.sort_by_attribute(:closed_at_asc) + expect(merge_requests).to eq([older_mr, newer_mr]) + end + + it 'sorts desc' do + merge_requests = described_class.sort_by_attribute(:closed_at_desc) + expect(merge_requests).to eq([newer_mr, older_mr]) + end + + it 'sorts asc when its closed_at' do + merge_requests = described_class.sort_by_attribute(:closed_at) + expect(merge_requests).to eq([older_mr, newer_mr]) + end + end end describe 'time to merge calculations' do |