diff options
author | Valery Sizov <valery@gitlab.com> | 2017-03-10 17:12:31 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2017-03-14 14:11:59 +0200 |
commit | 5670777735a615b511c3282e8fc79b67c74669bc (patch) | |
tree | 0659efe220286457fb00eaf0eba2c808f9cd3f8a /spec | |
parent | 67686e38fdb1d9c427a39ff1862af691ccd4e598 (diff) | |
download | gitlab-ce-5670777735a615b511c3282e8fc79b67c74669bc.tar.gz |
[Issue sorting] Filling positions preferable in the middle
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/concerns/relative_positioning_spec.rb | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/spec/models/concerns/relative_positioning_spec.rb b/spec/models/concerns/relative_positioning_spec.rb index 12f44bfe0a5..fbae9efcd98 100644 --- a/spec/models/concerns/relative_positioning_spec.rb +++ b/spec/models/concerns/relative_positioning_spec.rb @@ -12,12 +12,6 @@ describe Issue, 'RelativePositioning' do end end - describe '#min_relative_position' do - it 'returns maximum position' do - expect(issue.min_relative_position).to eq issue.relative_position - end - end - describe '#max_relative_position' do it 'returns maximum position' do expect(issue.max_relative_position).to eq issue1.relative_position @@ -29,8 +23,8 @@ describe Issue, 'RelativePositioning' do expect(issue1.prev_relative_position).to eq issue.relative_position end - it 'returns minimum position if there is no issue above' do - expect(issue.prev_relative_position).to eq RelativePositioning::MIN_POSITION + it 'returns nil if there is no issue above' do + expect(issue.prev_relative_position).to eq nil end end @@ -39,8 +33,8 @@ describe Issue, 'RelativePositioning' do expect(issue.next_relative_position).to eq issue1.relative_position end - it 'returns next position if there is no issue below' do - expect(issue1.next_relative_position).to eq RelativePositioning::MAX_POSITION + it 'returns nil if there is no issue below' do + expect(issue1.next_relative_position).to eq nil end end @@ -110,15 +104,33 @@ describe Issue, 'RelativePositioning' do expect(issue.relative_position).to be < issue1.relative_position end - it 'positions issue closer to before-issue if distance is big enough' do - issue.update relative_position: 100 - issue1.update relative_position: 6000 + it 'positions issue in the middle of other two if distance is big enough' do + issue.update relative_position: 6000 + issue1.update relative_position: 10000 new_issue.move_between(issue, issue1) - expect(new_issue.relative_position).to eq(100 + RelativePositioning::DISTANCE) + expect(new_issue.relative_position).to eq(8000) + end + + it 'positions issue closer to the middle if we are at the very top' do + issue1.update relative_position: 6000 + + new_issue.move_between(nil, issue1) + + expect(new_issue.relative_position).to eq(6000 - RelativePositioning::DISTANCE) + end + + it 'positions issue closer to the middle if we are at the very bottom' do + issue.update relative_position: 6000 + issue1.update relative_position: nil + + new_issue.move_between(issue, nil) + + expect(new_issue.relative_position).to eq(6000 + RelativePositioning::DISTANCE) end + it 'positions issue in the middle of other two if distance is not big enough' do issue.update relative_position: 100 issue1.update relative_position: 400 |