conversations_controller_test.rb 634 B

12345678910111213141516171819202122
  1. require 'test_helper'
  2. class ConversationsControllerTest < ActionDispatch::IntegrationTest
  3. def setup
  4. @user = users(:daniel)
  5. @other_user = users(:ben)
  6. log_in_as @user
  7. end
  8. test "should redirect conversation which user is not participating in" do
  9. get conversation_path conversations(:two)
  10. assert_redirected_to root_path
  11. end
  12. test "last message should be shown in index" do
  13. message = @user.messages.build(content: "Hello, world!",
  14. conversation: conversations(:one))
  15. message.save
  16. get conversations_path
  17. assert_match message.content, response.body
  18. end
  19. end