I made sure that my MessageBoards would acts_as_list for Forum: ----------------------------- class Forum < ActiveRecord::Base #This is a superset of message boards has_many :message_boards, :order => ''position'', :dependent => :destroy ... end ----------------------------- class MessageBoard < ActiveRecord::Base #This is a subset of forums belongs_to :forum #This causes MessageBoard to act as a list #it uses order as its index acts_as_list :scope => :forum_id ... end ----------------------------- But for some reason, the unit tests file indicates several failures: ----------------------------- #in forum_test.rb def test_board_up forum = Forum.new(:title => ''basic'') assert forum.valid?, "forum is invalid, expect more failures" assert_equal forum.title, ''basic'' board = [] board[0] = forum.message_boards.build(:title => ''#1'', :description => ''one''\ ) board[2] = forum.message_boards.build(:title => ''#3'', :description => ''thre\ e'') board[1] = forum.message_boards.build(:title => ''#2'', :description => ''two''\ ) forum.message_boards[2].move_lower forum.save board_temp = forum.message_boards board_temp.each{|b| puts b.title} for num in 0..2 assert_equal board_temp[num].title, board[num].title assert_equal board_temp[num].description, board[num].description end forum.destroy end def test_board_down forum = Forum.new(:title => ''basic'') assert forum.valid?, "forum is invalid, expect more failures" assert_equal forum.title, ''basic'' board = [] board[0] = forum.message_boards.build(:title => ''#1'', :description => ''one''\ ) board[2] = forum.message_boards.build(:title => ''#3'', :description => ''thre\ e'') board[1] = forum.message_boards.build(:title => ''#2'', :description => ''two''\ ) board[2].move_higher forum.save board_temp = forum.message_boards board_temp.each{|b| puts b.title} for num in 0..2 assert_equal board_temp[num].title, board[num].title assert_equal board_temp[num].description, board[num].description end forum.destroy end ----------------------------- Loaded suite forum_test Started .#1 #3 #2 F.#1 #3 #2 F...... Finished in 0.597854 seconds. 1) Failure: test_board_down(ForumTest) [forum_test.rb:133:in `test_board_down'' forum_test.rb:132:in `each'' forum_test.rb:132:in `test_board_down'']: <"#3"> expected but was <"#2">. 2) Failure: test_board_up(ForumTest) [forum_test.rb:114:in `test_board_up'' forum_test.rb:113:in `each'' forum_test.rb:113:in `test_board_up'']: <"#3"> expected but was <"#2">. 10 tests, 43 assertions, 2 failures, 0 errors ----------------------------- Why doesn''t move_higher and move_lower affect forum.message_boards in any way? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I attempted to save forum, move up/down the board, and save the forum again, but that doesn''t seem to work, either... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sorry, I''m really desperate on this. Can someone help me out? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Does move_higher save it when it does it? Perhaps try calling save after doing the move_higher. On Jan 9, 2008 7:57 AM, Taro <japtar10101-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Sorry, I''m really desperate on this. Can someone help me out? > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve heard move_higher and move_lower doesn''t save. Which isn''t exactly the problem with this test as I''ll explain later. I''ve noticed a slight flaw in my test, so revised it to get a similar results as before. As one might notice in the test code, forum.save doesn''t seem to have any effect on saving changes of move_higher/ move_lower (or, move_higher/lower does nothing...): ----------------------------------- def test_board_up forum = Forum.new(:title => ''basic'') assert forum.valid?, "forum is invalid, expect more failures" assert_equal forum.title, ''basic'' board = [] #initialize three boards in this order: #1, #3, #2 #board array holds = [#1, #2, #3] board[0] = forum.message_boards.build(:title => ''#1'', :description => ''one'') board[2] = forum.message_boards.build(:title => ''#3'', :description => ''three'') board[1] = forum.message_boards.build(:title => ''#2'', :description => ''two'') #save, just in case forum.save # move the index #2 lower (so that it''s less than #3) forum.message_boards[2].move_lower # and save. forum.save board_temp = forum.message_boards board_temp.each{|b| puts "\ntest_board_up order #{b.title}"} for num in 0..2 assert_equal board_temp[num].title, board[num].title assert_equal board_temp[num].description, board[num].description end forum.destroy end def test_board_down forum = Forum.new(:title => ''basic'') assert forum.valid?, "forum is invalid, expect more failures" assert_equal forum.title, ''basic'' board = [] #initialize three boards in this order: #1, #3, #2 #board array holds = [#1, #2, #3] board[0] = forum.message_boards.build(:title => ''#1'', :description => ''one'') board[2] = forum.message_boards.build(:title => ''#3'', :description => ''three'') board[1] = forum.message_boards.build(:title => ''#2'', :description => ''two'') #save, just in case forum.save # move the index #3 higher (so that it''s greater than #2) forum.message_boards[1].move_higher # and save. forum.save board_temp = forum.message_boards board_temp.each{|b| puts "\ntest_board_down order #{b.title}"} for num in 0..2 assert_equal board_temp[num].title, board[num].title assert_equal board_temp[num].description, board[num].description end forum.destroy end ----------------------------------- Loaded suite forum_test Started . test_board_down order #1 test_board_down order #3 test_board_down order #2 F. test_board_up order #1 test_board_up order #3 test_board_up order #2 F...... Finished in 0.615307 seconds. 1) Failure: test_board_down(ForumTest) [forum_test.rb:152:in `test_board_down'' forum_test.rb:151:in `each'' forum_test.rb:151:in `test_board_down'']: <"#3"> expected but was <"#2">. 2) Failure: test_board_up(ForumTest) [forum_test.rb:125:in `test_board_up'' forum_test.rb:124:in `each'' forum_test.rb:124:in `test_board_up'']: <"#3"> expected but was <"#2">. 10 tests, 43 assertions, 2 failures, 0 errors ----------------------------------- On Jan 8, 5:51 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Does move_higher save it when it does it? Perhaps try calling save after > doing the move_higher. > > On Jan 9, 2008 7:57 AM, Taro <japtar10...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Sorry, I''m really desperate on this. Can someone help me out? > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---