Commit efe01800309e3328a2837b61b87f82d2c7816235

Authored by Joenio Costa
1 parent 2a6128ac

removing trailing whitespaces

(ActionItem3118)
vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
@@ -26,8 +26,8 @@ module ActiveRecord @@ -26,8 +26,8 @@ module ActiveRecord
26 # Configuration options are: 26 # Configuration options are:
27 # 27 #
28 # * +column+ - specifies the column name to use for keeping the position integer (default: +position+) 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 # to give it an entire string that is interpolated if you need a tighter scope than just a foreign key. 31 # to give it an entire string that is interpolated if you need a tighter scope than just a foreign key.
32 # Example: <tt>acts_as_list :scope => 'todo_list_id = #{todo_list_id} AND completed = 0'</tt> 32 # Example: <tt>acts_as_list :scope => 'todo_list_id = #{todo_list_id} AND completed = 0'</tt>
33 def acts_as_list(options = {}) 33 def acts_as_list(options = {})
@@ -45,7 +45,7 @@ module ActiveRecord @@ -45,7 +45,7 @@ module ActiveRecord
45 elsif configuration[:scope].is_a?(Array) 45 elsif configuration[:scope].is_a?(Array)
46 scope_condition_method = %( 46 scope_condition_method = %(
47 def scope_condition 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 memo[column.intern] = send(column.intern); memo 49 memo[column.intern] = send(column.intern); memo
50 end 50 end
51 self.class.send(:sanitize_sql_hash_for_conditions, attrs) 51 self.class.send(:sanitize_sql_hash_for_conditions, attrs)
@@ -255,7 +255,7 @@ module ActiveRecord @@ -255,7 +255,7 @@ module ActiveRecord
255 increment_positions_on_lower_items(position) 255 increment_positions_on_lower_items(position)
256 self.update_attribute(position_column, position) 256 self.update_attribute(position_column, position)
257 end 257 end
258 - end 258 + end
259 end 259 end
260 end 260 end
261 end 261 end
vendor/plugins/acts_as_list/test/list_test.rb
@@ -14,7 +14,7 @@ def setup_db @@ -14,7 +14,7 @@ def setup_db
14 t.column :pos, :integer 14 t.column :pos, :integer
15 t.column :parent_id, :integer 15 t.column :parent_id, :integer
16 t.column :parent_type, :string 16 t.column :parent_type, :string
17 - t.column :created_at, :datetime 17 + t.column :created_at, :datetime
18 t.column :updated_at, :datetime 18 t.column :updated_at, :datetime
19 end 19 end
20 end 20 end
@@ -194,38 +194,38 @@ class ListTest &lt; Test::Unit::TestCase @@ -194,38 +194,38 @@ class ListTest &lt; Test::Unit::TestCase
194 assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos') 194 assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos')
195 end 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 assert_equal true, ListMixin.find(1).in_list? 198 assert_equal true, ListMixin.find(1).in_list?
199 ListMixin.find(1).remove_from_list 199 ListMixin.find(1).remove_from_list
200 assert_equal false, ListMixin.find(1).in_list? 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 assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) 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 assert_equal [2, 1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) 208 assert_equal [2, 1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
209 - 209 +
210 assert_equal 1, ListMixin.find(1).pos 210 assert_equal 1, ListMixin.find(1).pos
211 assert_equal nil, ListMixin.find(2).pos 211 assert_equal nil, ListMixin.find(2).pos
212 assert_equal 2, ListMixin.find(3).pos 212 assert_equal 2, ListMixin.find(3).pos
213 assert_equal 3, ListMixin.find(4).pos 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 assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) 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 assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) 222 assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
223 - 223 +
224 assert_equal 1, ListMixin.find(1).pos 224 assert_equal 1, ListMixin.find(1).pos
225 assert_equal 2, ListMixin.find(3).pos 225 assert_equal 2, ListMixin.find(3).pos
226 assert_equal 3, ListMixin.find(4).pos 226 assert_equal 3, ListMixin.find(4).pos
227 - end  
228 - 227 + end
  228 +
229 def test_before_destroy_callbacks_do_not_update_position_to_nil_before_deleting_the_record 229 def test_before_destroy_callbacks_do_not_update_position_to_nil_before_deleting_the_record
230 assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) 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 &lt; Test::Unit::TestCase @@ -484,38 +484,37 @@ class ArrayScopeListTest &lt; Test::Unit::TestCase
484 assert_equal 1, ArrayScopeListMixin.find(3).pos 484 assert_equal 1, ArrayScopeListMixin.find(3).pos
485 assert_equal 2, ArrayScopeListMixin.find(4).pos 485 assert_equal 2, ArrayScopeListMixin.find(4).pos
486 end 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 assert_equal true, ArrayScopeListMixin.find(1).in_list? 489 assert_equal true, ArrayScopeListMixin.find(1).in_list?
490 ArrayScopeListMixin.find(1).remove_from_list 490 ArrayScopeListMixin.find(1).remove_from_list
491 assert_equal false, ArrayScopeListMixin.find(1).in_list? 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 assert_equal [1, 2, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id) 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 assert_equal [2, 1, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id) 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 assert_equal 1, ArrayScopeListMixin.find(1).pos 501 assert_equal 1, ArrayScopeListMixin.find(1).pos
502 assert_equal nil, ArrayScopeListMixin.find(2).pos 502 assert_equal nil, ArrayScopeListMixin.find(2).pos
503 assert_equal 2, ArrayScopeListMixin.find(3).pos 503 assert_equal 2, ArrayScopeListMixin.find(3).pos
504 assert_equal 3, ArrayScopeListMixin.find(4).pos 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 assert_equal [1, 2, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id) 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 assert_equal [1, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id) 513 assert_equal [1, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id)
514 - 514 +
515 assert_equal 1, ArrayScopeListMixin.find(1).pos 515 assert_equal 1, ArrayScopeListMixin.find(1).pos
516 assert_equal 2, ArrayScopeListMixin.find(3).pos 516 assert_equal 2, ArrayScopeListMixin.find(3).pos
517 assert_equal 3, ArrayScopeListMixin.find(4).pos 517 assert_equal 3, ArrayScopeListMixin.find(4).pos
518 - end  
519 -  
520 -end 518 + end
521 519
  520 +end