conversation_test.rb 977 B

12345678910111213141516171819202122232425262728293031323334353637
  1. require 'test_helper'
  2. class PingConversationTest < Test::Unit::TestCase
  3. def test_create_conversation
  4. fake "api/ping-api/v1/conversations", :method => :post, :body => load_fixture('ping/conversation')
  5. conversation = ShopifyAPI::Ping::Conversation.new(
  6. topic: 'my topic',
  7. participants: [
  8. {
  9. name: 'foo',
  10. id: 'test',
  11. group: 'customer',
  12. }
  13. ]
  14. )
  15. conversation.save
  16. assert_equal "d315d4f7-53bd-49ec-8808-23f6db3c641a", conversation.id
  17. end
  18. def test_send_message
  19. fake "api/ping-api/v1/conversations/123/messages", :method => :post, :body => load_fixture('ping/message')
  20. conversation = ShopifyAPI::Ping::Conversation.new(id: '123')
  21. message = conversation.send_message(
  22. dedupe_key: SecureRandom.uuid,
  23. content: {
  24. text: "Hello from shopify_api",
  25. },
  26. sender_id: 'test',
  27. )
  28. assert_equal "d0c7a2e6-8084-4e79-8483-e4a1352b81f7", message.id
  29. end
  30. end