summaryrefslogtreecommitdiff
path: root/test/controllers/lists_controller_test.rb
blob: d1fc582a56fc08a8f272f0e600fcb66daf575ae3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

require 'test_helper'

class ListsControllerTest < ActionController::TestCase
  test 'should get index' do
    get :index
    assert_response :success
    assert_not_nil assigns(:top_scoring_images)
    assert_not_nil assigns(:all_time_top_scoring_images)
    assert_not_nil assigns(:top_commented_images)
  end

  test 'should get recent comments' do
    get :recent_comments
    assert_response :success
    assert_not_nil assigns(:recent_comments)
  end

  test 'should list user comments' do
    @comment = create(:comment_as_user)
    @user = @comment.user

    get :my_comments, params: { user_id: @user.id }
    assert_response :success
    assert_not_nil assigns(:my_comments)
  end

  test 'should list my comments' do
    @comment = create(:comment_as_user)
    sign_in @comment.user

    get :my_comments
    assert_response :success
    assert_not_nil assigns(:my_comments)
  end
end