conversation_participations_controller_test.rb 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. require 'test_helper'
  2. class ConversationParticipationsControllerTest < ActionDispatch::IntegrationTest
  3. def setup
  4. @user = users(:daniel)
  5. @other_user = users(:jane)
  6. @conversation = conversations(:one)
  7. @unallowed_conversation = conversations(:two)
  8. log_in_as @user
  9. end
  10. test "should create valid conversation participation" do
  11. get conversation_path @conversation
  12. assert_difference 'ConversationParticipation.all.count', 1 do
  13. post conversation_participations_path,
  14. params: { conversation_participation: {
  15. conversation_id: @conversation.id, user_id: @other_user.id
  16. } }
  17. end
  18. assert_redirected_to conversation_path @conversation
  19. end
  20. test "should not create invalid conversation participation" do
  21. assert_no_difference 'ConversationParticipation.all.count' do
  22. post conversation_participations_path,
  23. params: { conversation_participation: {
  24. conversation_id: @unallowed_conversation.id, user_id: @other_user.id
  25. } }
  26. end
  27. end
  28. end