summaryrefslogtreecommitdiff
path: root/test/controllers/conversations/messages_controller_test.rb
blob: 79ba8b7b905ff304e4f022c69849e3f27850fb25 (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
# frozen_string_literal: true

require 'test_helper'

class Conversations::MessagesControllerTest < ActionController::TestCase
  setup do
    @request.cookies['_ses'] = 'c1836832948'
    @conversation = create(:conversation_with_messages)
    @from = @conversation.from
    sign_in @from
  end

  test 'should get new' do
    get :new, params: { conversation_id: @conversation.slug }
    assert_response :success
  end

  test 'can post a reply to an existing conversation' do
    assert_difference('Message.count') do
      post :create, params: { conversation_id: @conversation.slug, message: { body: 'How are you?' } }
      assert_response :redirect
    end
  end
end