diff options
author | Alejandro RodrÃguez <alejorro70@gmail.com> | 2016-06-16 13:33:29 -0400 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2016-06-16 13:33:29 -0400 |
commit | 7022357c8cd7888e04252b8964882d0e081032df (patch) | |
tree | eccbd555c8494f733c598d18be93d046f84af975 /spec/models | |
parent | d9812bae49db3b3af7afe702d7b60d75f05d0fad (diff) | |
download | gitlab-ce-7022357c8cd7888e04252b8964882d0e081032df.tar.gz |
Add sorting dropdown to tag page14918-add-filter-dropdown-to-tag-page
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/repository_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 8c2347992f1..d8350000bf6 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -31,6 +31,47 @@ describe Repository, models: true do it { is_expected.not_to include('v1.0.0') } end + describe 'tags_sorted_by' do + context 'name' do + subject { repository.tags_sorted_by('name').map(&:name) } + + it { is_expected.to eq(['v1.1.0', 'v1.0.0']) } + end + + context 'updated' do + let(:tag_a) { repository.find_tag('v1.0.0') } + let(:tag_b) { repository.find_tag('v1.1.0') } + + context 'desc' do + subject { repository.tags_sorted_by('updated_desc').map(&:name) } + + before do + double_first = double(committed_date: Time.now) + double_last = double(committed_date: Time.now - 1.second) + + allow(repository).to receive(:commit).with(tag_a.target).and_return(double_first) + allow(repository).to receive(:commit).with(tag_b.target).and_return(double_last) + end + + it { is_expected.to eq(['v1.0.0', 'v1.1.0']) } + end + + context 'asc' do + subject { repository.tags_sorted_by('updated_asc').map(&:name) } + + before do + double_first = double(committed_date: Time.now - 1.second) + double_last = double(committed_date: Time.now) + + allow(repository).to receive(:commit).with(tag_a.target).and_return(double_last) + allow(repository).to receive(:commit).with(tag_b.target).and_return(double_first) + end + + it { is_expected.to eq(['v1.1.0', 'v1.0.0']) } + end + end + end + describe :last_commit_for_path do subject { repository.last_commit_for_path(sample_commit.id, '.gitignore').id } |