change_replies_order_with_test.diff

Go MAEDA, 2016-05-08 16:09

Download (1.29 KB)

View differences:

app/controllers/messages_controller.rb (working copy)
47 47
      limit(@reply_pages.per_page).
48 48
      offset(@reply_pages.offset).
49 49
      to_a
50
    @replies.reverse! if User.current.wants_comments_in_reverse_order?
50 51

  
51 52
    @reply = Message.new(:subject => "RE: #{@message.subject}")
52 53
    render :action => "show", :layout => false if request.xhr?
test/functional/messages_controller_test.rb (working copy)
71 71
    assert_select 'div#reply textarea#message_content'
72 72
  end
73 73

  
74
  def test_show_comments_sorting_desc
75
    user = User.find(2)
76
    user.pref.comments_sorting = 'desc'
77
    user.pref.save!
78
    @request.session[:user_id] = user.id
79
    get :show, :board_id => 1, :id => 1
80
    assert_response :success
81
    replies = assigns(:replies)
82
    assert replies.first.created_on > replies.last.created_on
83
  end
84

  
74 85
  def test_show_message_not_found
75 86
    get :show, :board_id => 1, :id => 99999
76 87
    assert_response 404