diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-07-27 20:02:54 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-07-30 17:01:55 +0300 |
commit | 16c8a030fc339b4d86e5e46b0d9c6394ff978d83 (patch) | |
tree | 3b5074f167f1570ec49cfb8b83592051b07cf8cf /spec/models/milestone_spec.rb | |
parent | 3d2dad449da2915b2c431bf32548e03b08fcbe40 (diff) |
Fix ordering by name on milestones page
We should sort by title because name is only an alias for
the title attribute on the milestone model.
Diffstat (limited to 'spec/models/milestone_spec.rb')
-rw-r--r-- | spec/models/milestone_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 204d6b47832..55b984faecf 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -310,4 +310,24 @@ describe Milestone do expect(milestone.participants).to eq [user] end end + + describe '.sort_by_attribute' do + set(:milestone_1) { create(:milestone, title: 'Foo') } + set(:milestone_2) { create(:milestone, title: 'Bar') } + set(:milestone_3) { create(:milestone, title: 'Zoo') } + + context 'ordering by name ascending' do + it 'sorts by title ascending' do + expect(described_class.sort_by_attribute('name_asc')) + .to eq([milestone_2, milestone_1, milestone_3]) + end + end + + context 'ordering by name descending' do + it 'sorts by title descending' do + expect(described_class.sort_by_attribute('name_desc')) + .to eq([milestone_3, milestone_1, milestone_2]) + end + end + end end |