client_test.rb 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. require 'test_helper'
  2. class ClientTest < ActiveSupport::TestCase
  3. test "should not save client with missing room name" do
  4. client = Client.create CLIENT_PARAMS_MISSING_NAME
  5. assert_predicate client , :new_record?
  6. end
  7. test "should not save client with empty room name" do
  8. client = Client.create CLIENT_PARAMS_EMPTY_NAME
  9. assert_predicate client , :new_record?
  10. end
  11. test "should not save client with missing nicks list" do
  12. client = Client.create CLIENT_PARAMS_MISSING_NICKS
  13. assert_predicate client , :new_record?
  14. end
  15. test "should not save client with empty nicks list" do
  16. client = Client.create CLIENT_PARAMS_EMPTY_NICKS
  17. assert_predicate client , :new_record?
  18. end
  19. test "should not save client with missing client type" do
  20. client = Client.create CLIENT_PARAMS_MISSING_TYPE
  21. assert_predicate client , :new_record?
  22. end
  23. test "should not save client with empty client type" do
  24. client = Client.create CLIENT_PARAMS_EMPTY_TYPE
  25. assert_predicate client , :new_record?
  26. end
  27. test "should save client with valid params" do
  28. client = Client.create CLIENT_C_PARAMS_VALID
  29. assert_not_predicate client , :new_record?
  30. assert_not_nil client.room
  31. assert_kind_of Client , client
  32. end
  33. test "should not save client with duplicate channel name" do
  34. assert_raises ActiveRecord::RecordNotUnique do
  35. client = Client.create CLIENT_A_PARAMS_VALID
  36. end
  37. end
  38. # TODO: ensure Room is destroyed upon destruction of it's only associated Client
  39. # TODO: ensure messages are dependent-destroyed upon destruction of their Room
  40. end