Commit efe01800309e3328a2837b61b87f82d2c7816235
1 parent
2a6128ac
Exists in
master
and in
29 other branches
removing trailing whitespaces
(ActionItem3118)
Showing
2 changed files
with
42 additions
and
43 deletions
Show diff stats
vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
| ... | ... | @@ -26,8 +26,8 @@ module ActiveRecord |
| 26 | 26 | # Configuration options are: |
| 27 | 27 | # |
| 28 | 28 | # * +column+ - specifies the column name to use for keeping the position integer (default: +position+) |
| 29 | - # * +scope+ - restricts what is to be considered a list. Given a symbol, it'll attach <tt>_id</tt> | |
| 30 | - # (if it hasn't already been added) and use that as the foreign key restriction. It's also possible | |
| 29 | + # * +scope+ - restricts what is to be considered a list. Given a symbol, it'll attach <tt>_id</tt> | |
| 30 | + # (if it hasn't already been added) and use that as the foreign key restriction. It's also possible | |
| 31 | 31 | # to give it an entire string that is interpolated if you need a tighter scope than just a foreign key. |
| 32 | 32 | # Example: <tt>acts_as_list :scope => 'todo_list_id = #{todo_list_id} AND completed = 0'</tt> |
| 33 | 33 | def acts_as_list(options = {}) |
| ... | ... | @@ -45,7 +45,7 @@ module ActiveRecord |
| 45 | 45 | elsif configuration[:scope].is_a?(Array) |
| 46 | 46 | scope_condition_method = %( |
| 47 | 47 | def scope_condition |
| 48 | - attrs = %w(#{configuration[:scope].join(" ")}).inject({}) do |memo,column| | |
| 48 | + attrs = %w(#{configuration[:scope].join(" ")}).inject({}) do |memo,column| | |
| 49 | 49 | memo[column.intern] = send(column.intern); memo |
| 50 | 50 | end |
| 51 | 51 | self.class.send(:sanitize_sql_hash_for_conditions, attrs) |
| ... | ... | @@ -255,7 +255,7 @@ module ActiveRecord |
| 255 | 255 | increment_positions_on_lower_items(position) |
| 256 | 256 | self.update_attribute(position_column, position) |
| 257 | 257 | end |
| 258 | - end | |
| 258 | + end | |
| 259 | 259 | end |
| 260 | 260 | end |
| 261 | 261 | end | ... | ... |
vendor/plugins/acts_as_list/test/list_test.rb
| ... | ... | @@ -14,7 +14,7 @@ def setup_db |
| 14 | 14 | t.column :pos, :integer |
| 15 | 15 | t.column :parent_id, :integer |
| 16 | 16 | t.column :parent_type, :string |
| 17 | - t.column :created_at, :datetime | |
| 17 | + t.column :created_at, :datetime | |
| 18 | 18 | t.column :updated_at, :datetime |
| 19 | 19 | end |
| 20 | 20 | end |
| ... | ... | @@ -194,38 +194,38 @@ class ListTest < Test::Unit::TestCase |
| 194 | 194 | assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos') |
| 195 | 195 | end |
| 196 | 196 | |
| 197 | - def test_remove_from_list_should_then_fail_in_list? | |
| 197 | + def test_remove_from_list_should_then_fail_in_list? | |
| 198 | 198 | assert_equal true, ListMixin.find(1).in_list? |
| 199 | 199 | ListMixin.find(1).remove_from_list |
| 200 | 200 | assert_equal false, ListMixin.find(1).in_list? |
| 201 | - end | |
| 202 | - | |
| 203 | - def test_remove_from_list_should_set_position_to_nil | |
| 201 | + end | |
| 202 | + | |
| 203 | + def test_remove_from_list_should_set_position_to_nil | |
| 204 | 204 | assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) |
| 205 | - | |
| 206 | - ListMixin.find(2).remove_from_list | |
| 207 | - | |
| 205 | + | |
| 206 | + ListMixin.find(2).remove_from_list | |
| 207 | + | |
| 208 | 208 | assert_equal [2, 1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) |
| 209 | - | |
| 209 | + | |
| 210 | 210 | assert_equal 1, ListMixin.find(1).pos |
| 211 | 211 | assert_equal nil, ListMixin.find(2).pos |
| 212 | 212 | assert_equal 2, ListMixin.find(3).pos |
| 213 | 213 | assert_equal 3, ListMixin.find(4).pos |
| 214 | - end | |
| 215 | - | |
| 216 | - def test_remove_before_destroy_does_not_shift_lower_items_twice | |
| 214 | + end | |
| 215 | + | |
| 216 | + def test_remove_before_destroy_does_not_shift_lower_items_twice | |
| 217 | 217 | assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) |
| 218 | - | |
| 219 | - ListMixin.find(2).remove_from_list | |
| 220 | - ListMixin.find(2).destroy | |
| 221 | - | |
| 218 | + | |
| 219 | + ListMixin.find(2).remove_from_list | |
| 220 | + ListMixin.find(2).destroy | |
| 221 | + | |
| 222 | 222 | assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) |
| 223 | - | |
| 223 | + | |
| 224 | 224 | assert_equal 1, ListMixin.find(1).pos |
| 225 | 225 | assert_equal 2, ListMixin.find(3).pos |
| 226 | 226 | assert_equal 3, ListMixin.find(4).pos |
| 227 | - end | |
| 228 | - | |
| 227 | + end | |
| 228 | + | |
| 229 | 229 | def test_before_destroy_callbacks_do_not_update_position_to_nil_before_deleting_the_record |
| 230 | 230 | assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) |
| 231 | 231 | |
| ... | ... | @@ -484,38 +484,37 @@ class ArrayScopeListTest < Test::Unit::TestCase |
| 484 | 484 | assert_equal 1, ArrayScopeListMixin.find(3).pos |
| 485 | 485 | assert_equal 2, ArrayScopeListMixin.find(4).pos |
| 486 | 486 | end |
| 487 | - | |
| 488 | - def test_remove_from_list_should_then_fail_in_list? | |
| 487 | + | |
| 488 | + def test_remove_from_list_should_then_fail_in_list? | |
| 489 | 489 | assert_equal true, ArrayScopeListMixin.find(1).in_list? |
| 490 | 490 | ArrayScopeListMixin.find(1).remove_from_list |
| 491 | 491 | assert_equal false, ArrayScopeListMixin.find(1).in_list? |
| 492 | - end | |
| 493 | - | |
| 494 | - def test_remove_from_list_should_set_position_to_nil | |
| 492 | + end | |
| 493 | + | |
| 494 | + def test_remove_from_list_should_set_position_to_nil | |
| 495 | 495 | assert_equal [1, 2, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id) |
| 496 | - | |
| 497 | - ArrayScopeListMixin.find(2).remove_from_list | |
| 498 | - | |
| 496 | + | |
| 497 | + ArrayScopeListMixin.find(2).remove_from_list | |
| 498 | + | |
| 499 | 499 | assert_equal [2, 1, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id) |
| 500 | - | |
| 500 | + | |
| 501 | 501 | assert_equal 1, ArrayScopeListMixin.find(1).pos |
| 502 | 502 | assert_equal nil, ArrayScopeListMixin.find(2).pos |
| 503 | 503 | assert_equal 2, ArrayScopeListMixin.find(3).pos |
| 504 | 504 | assert_equal 3, ArrayScopeListMixin.find(4).pos |
| 505 | - end | |
| 506 | - | |
| 507 | - def test_remove_before_destroy_does_not_shift_lower_items_twice | |
| 505 | + end | |
| 506 | + | |
| 507 | + def test_remove_before_destroy_does_not_shift_lower_items_twice | |
| 508 | 508 | assert_equal [1, 2, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id) |
| 509 | - | |
| 510 | - ArrayScopeListMixin.find(2).remove_from_list | |
| 511 | - ArrayScopeListMixin.find(2).destroy | |
| 512 | - | |
| 509 | + | |
| 510 | + ArrayScopeListMixin.find(2).remove_from_list | |
| 511 | + ArrayScopeListMixin.find(2).destroy | |
| 512 | + | |
| 513 | 513 | assert_equal [1, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id) |
| 514 | - | |
| 514 | + | |
| 515 | 515 | assert_equal 1, ArrayScopeListMixin.find(1).pos |
| 516 | 516 | assert_equal 2, ArrayScopeListMixin.find(3).pos |
| 517 | 517 | assert_equal 3, ArrayScopeListMixin.find(4).pos |
| 518 | - end | |
| 519 | - | |
| 520 | -end | |
| 518 | + end | |
| 521 | 519 | |
| 520 | +end | ... | ... |