summaryrefslogtreecommitdiff
path: root/test/controllers/topics/sticks_controller_test.rb
blob: 675bed1ef69f41f397b6eda6e4de818a9fafebab (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
# frozen_string_literal: true

require 'test_helper'

class Topics::SticksControllerTest < ActionController::TestCase
  setup do
    @user = create(:moderator)
    @topic = create(:topic)
    @forum = @topic.forum
  end

  test 'can be stuck and unstuck' do
    sign_in create(:moderator)

    post :create, params: { topic_id: @topic, forum_id: @forum }

    @topic.reload
    assert_response :redirect
    assert_redirected_to forum_topic_path(@forum, @topic)
    assert @topic.sticky

    delete :destroy, params: { topic_id: @topic, forum_id: @forum }

    @topic.reload
    assert_response :redirect
    assert_redirected_to forum_topic_path(@forum, @topic)
    assert_not @topic.sticky
  end
end