summaryrefslogtreecommitdiff
path: root/spec/models/concerns
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2017-03-07 19:57:24 +0200
committerValery Sizov <valery@gitlab.com>2017-03-07 21:02:08 +0200
commit9895d6707d51140b3cc75e925cfd775c6bd93f83 (patch)
tree9b9903dd2e1130128f2708a32dc25f6828a71b37 /spec/models/concerns
parent1497db75f5f4850f51082de326fa0b4d8574bf3b (diff)
downloadgitlab-ce-9895d6707d51140b3cc75e925cfd775c6bd93f83.tar.gz
[Issue Board Sorting] More accurate move through the listorderable-issues
Diffstat (limited to 'spec/models/concerns')
-rw-r--r--spec/models/concerns/relative_positioning_spec.rb41
1 files changed, 36 insertions, 5 deletions
diff --git a/spec/models/concerns/relative_positioning_spec.rb b/spec/models/concerns/relative_positioning_spec.rb
index 0c777c04669..901bde8e8dd 100644
--- a/spec/models/concerns/relative_positioning_spec.rb
+++ b/spec/models/concerns/relative_positioning_spec.rb
@@ -24,13 +24,44 @@ describe Issue, 'RelativePositioning' do
end
end
- describe '#move_to_top' do
- it 'moves issue to the end' do
- new_issue = create :issue, project: project
+ describe '#prev_relative_position' do
+ it 'returns previous position if there is an issue above' do
+ expect(issue1.prev_relative_position).to eq issue.relative_position
+ end
- new_issue.move_to_top
+ it 'returns minimum position if there is no issue above' do
+ expect(issue.prev_relative_position).to eq RelativePositioning::MIN_POSITION
+ end
+ end
- expect(new_issue.relative_position).to be < issue.relative_position
+ describe '#next_relative_position' do
+ it 'returns next position if there is an issue below' 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
+ end
+ end
+
+
+ describe '#move_before' do
+ it 'moves issue before' do
+ [issue1, issue].each(&:move_to_end)
+
+ issue.move_before(issue1)
+
+ expect(issue.relative_position).to be < issue1.relative_position
+ end
+ end
+
+ describe '#move_after' do
+ it 'moves issue after' do
+ [issue, issue1].each(&:move_to_end)
+
+ issue.move_after(issue1)
+
+ expect(issue.relative_position).to be > issue1.relative_position
end
end