@@ -47,22 +47,6 module Redmine | |||
|
47 | 47 | base.extend ClassMethods |
|
48 | 48 | end |
|
49 | 49 | |
|
50 | # Move to the given position | |
|
51 | # For compatibility with the previous way of sorting items | |
|
52 | def move_to=(pos) | |
|
53 | case pos.to_s | |
|
54 | when 'highest' | |
|
55 | self.position = 1 | |
|
56 | when 'higher' | |
|
57 | self.position -= 1 if position > 1 | |
|
58 | when 'lower' | |
|
59 | self.position += 1 | |
|
60 | when 'lowest' | |
|
61 | self.position = nil | |
|
62 | set_default_position | |
|
63 | end | |
|
64 | end | |
|
65 | ||
|
66 | 50 | private |
|
67 | 51 | |
|
68 | 52 | def position_scope |
@@ -181,27 +181,27 class RolesControllerTest < ActionController::TestCase | |||
|
181 | 181 | end |
|
182 | 182 | |
|
183 | 183 | def test_move_highest |
|
184 |
put :update, :id => 3, :role => {: |
|
|
184 | put :update, :id => 3, :role => {:position => 1} | |
|
185 | 185 | assert_redirected_to '/roles' |
|
186 | 186 | assert_equal 1, Role.find(3).position |
|
187 | 187 | end |
|
188 | 188 | |
|
189 | 189 | def test_move_higher |
|
190 | 190 | position = Role.find(3).position |
|
191 |
put :update, :id => 3, :role => {: |
|
|
191 | put :update, :id => 3, :role => {:position => position - 1} | |
|
192 | 192 | assert_redirected_to '/roles' |
|
193 | 193 | assert_equal position - 1, Role.find(3).position |
|
194 | 194 | end |
|
195 | 195 | |
|
196 | 196 | def test_move_lower |
|
197 | 197 | position = Role.find(2).position |
|
198 |
put :update, :id => 2, :role => {: |
|
|
198 | put :update, :id => 2, :role => {:position => position + 1} | |
|
199 | 199 | assert_redirected_to '/roles' |
|
200 | 200 | assert_equal position + 1, Role.find(2).position |
|
201 | 201 | end |
|
202 | 202 | |
|
203 | 203 | def test_move_lowest |
|
204 |
put :update, :id => 2, :role => {: |
|
|
204 | put :update, :id => 2, :role => {:position => Role.givable.count} | |
|
205 | 205 | assert_redirected_to '/roles' |
|
206 | 206 | assert_equal Role.givable.count, Role.find(2).position |
|
207 | 207 | end |
@@ -154,7 +154,7 class EnumerationTest < ActiveSupport::TestCase | |||
|
154 | 154 | a = IssuePriority.create!(:name => 'A') |
|
155 | 155 | b = IssuePriority.create!(:name => 'B') |
|
156 | 156 | override = IssuePriority.create!(:name => 'BB', :parent_id => b.id) |
|
157 | b.move_to = 'higher' | |
|
157 | b.position -= 1 | |
|
158 | 158 | b.save! |
|
159 | 159 | |
|
160 | 160 | assert_equal [2, 1, 1], [a, b, override].map(&:reload).map(&:position) |
@@ -82,7 +82,7 class IssuePriorityTest < ActiveSupport::TestCase | |||
|
82 | 82 | |
|
83 | 83 | def test_moving_a_priority_should_update_position_names |
|
84 | 84 | prio = IssuePriority.first |
|
85 | prio.move_to = 'lowest' | |
|
85 | prio.position = IssuePriority.count | |
|
86 | 86 | prio.save! |
|
87 | 87 | prio.reload |
|
88 | 88 | assert_equal 'highest', prio.position_name |
General Comments 0
You need to be logged in to leave comments.
Login now