summaryrefslogtreecommitdiff
path: root/spec/models/concerns
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2017-03-09 16:51:20 +0200
committerValery Sizov <valery@gitlab.com>2017-03-14 14:11:18 +0200
commit96fe1856da46517b028fe0ddac89f314f25c8855 (patch)
tree6e4a7ebf58e706a5e3957090638f6cfa5bb9c56b /spec/models/concerns
parentb3eda944454cb180cdefb8ddff35fdeb729e3ed5 (diff)
downloadgitlab-ce-96fe1856da46517b028fe0ddac89f314f25c8855.tar.gz
Fix relative position calculation
Diffstat (limited to 'spec/models/concerns')
-rw-r--r--spec/models/concerns/relative_positioning_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/models/concerns/relative_positioning_spec.rb b/spec/models/concerns/relative_positioning_spec.rb
index 69906382545..12f44bfe0a5 100644
--- a/spec/models/concerns/relative_positioning_spec.rb
+++ b/spec/models/concerns/relative_positioning_spec.rb
@@ -100,5 +100,32 @@ describe Issue, 'RelativePositioning' do
expect(new_issue.relative_position).to be > issue.relative_position
expect(issue.relative_position).to be < issue1.relative_position
end
+
+ it 'positions issues between other two if distance is 1' do
+ issue1.update relative_position: issue.relative_position + 1
+
+ new_issue.move_between(issue, issue1)
+
+ expect(new_issue.relative_position).to be > issue.relative_position
+ 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
+
+ new_issue.move_between(issue, issue1)
+
+ expect(new_issue.relative_position).to eq(100 + 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
+
+ new_issue.move_between(issue, issue1)
+
+ expect(new_issue.relative_position).to eq(250)
+ end
end
end