mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-26 15:46:47 +09:00
Hello world
First open source release of Campfire 🎉
This commit is contained in:
commit
df76a227dc
664 files changed
+36235
No files matched your search
@@ -0,0 +1,34 @@
|
||||
require "test_helper"
|
||||
|
||||
class MessageTest < ActiveSupport::TestCase
|
||||
include ActionCable::TestHelper, ActiveJob::TestHelper
|
||||
|
||||
test "creating a message enqueues to push later" do
|
||||
assert_enqueued_jobs 1, only: [ Room::PushMessageJob ] do
|
||||
create_new_message_in rooms(:designers)
|
||||
end
|
||||
end
|
||||
|
||||
test "all emoji" do
|
||||
assert Message.new(body: "😄🤘").plain_text_body.all_emoji?
|
||||
assert_not Message.new(body: "Haha! 😄🤘").plain_text_body.all_emoji?
|
||||
assert_not Message.new(body: "🔥\nmultiple lines\n💯").plain_text_body.all_emoji?
|
||||
assert_not Message.new(body: "🔥 💯").plain_text_body.all_emoji?
|
||||
end
|
||||
|
||||
test "mentionees" do
|
||||
message = Message.new room: rooms(:pets), body: "<div>Hey #{mention_attachment_for(:david)}</div>", creator: users(:jason), client_message_id: "earth"
|
||||
assert_equal [ users(:david) ], message.mentionees
|
||||
|
||||
message_with_duplicate_mentions = Message.new room: rooms(:pets), body: "<div>Hey #{mention_attachment_for(:david)} #{mention_attachment_for(:david)}</div>", creator: users(:jason), client_message_id: "earth"
|
||||
assert_equal [ users(:david) ], message.mentionees
|
||||
|
||||
message_mentioning_a_non_member = Message.new room: rooms(:pets), body: "<div>Hey #{mention_attachment_for(:kevin)}</div>", creator: users(:jason), client_message_id: "earth"
|
||||
assert_equal [], message_mentioning_a_non_member.mentionees
|
||||
end
|
||||
|
||||
private
|
||||
def create_new_message_in(room)
|
||||
room.messages.create!(creator: users(:jason), body: "Hello", client_message_id: "123")
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user