diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/concerns/relative_positioning_spec.rb | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/spec/models/concerns/relative_positioning_spec.rb b/spec/models/concerns/relative_positioning_spec.rb index 729056b6abc..66c1f47d12b 100644 --- a/spec/models/concerns/relative_positioning_spec.rb +++ b/spec/models/concerns/relative_positioning_spec.rb @@ -6,9 +6,13 @@ describe RelativePositioning do let(:issue1) { create(:issue, project: project) } let(:new_issue) { create(:issue, project: project) } - before do - [issue, issue1].each do |issue| - issue.move_to_end && issue.save + describe '.move_to_end' do + it 'moves the object to the end' do + Issue.move_to_end([issue, issue1]) + + expect(issue1.prev_relative_position).to eq issue.relative_position + expect(issue.prev_relative_position).to eq nil + expect(issue1.next_relative_position).to eq nil end end @@ -59,6 +63,12 @@ describe RelativePositioning do end describe '#move_to_end' do + before do + [issue, issue1].each do |issue| + issue.move_to_end && issue.save + end + end + it 'moves issue to the end' do new_issue.move_to_end @@ -67,6 +77,12 @@ describe RelativePositioning do end describe '#shift_after?' do + before do + [issue, issue1].each do |issue| + issue.move_to_end && issue.save + end + end + it 'returns true' do issue.update(relative_position: issue1.relative_position - 1) @@ -81,6 +97,12 @@ describe RelativePositioning do end describe '#shift_before?' do + before do + [issue, issue1].each do |issue| + issue.move_to_end && issue.save + end + end + it 'returns true' do issue.update(relative_position: issue1.relative_position + 1) @@ -95,6 +117,12 @@ describe RelativePositioning do end describe '#move_between' do + before do + [issue, issue1].each do |issue| + issue.move_to_end && issue.save + end + end + it 'positions issue between two other' do new_issue.move_between(issue, issue1) |