custom_emoji_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. require 'rails_helper'
  2. RSpec.describe CustomEmoji, type: :model do
  3. describe '#local?' do
  4. let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) }
  5. subject { custom_emoji.local? }
  6. context 'domain is nil' do
  7. let(:domain) { nil }
  8. it 'returns true' do
  9. is_expected.to be true
  10. end
  11. end
  12. context 'domain is present' do
  13. let(:domain) { 'example.com' }
  14. it 'returns false' do
  15. is_expected.to be false
  16. end
  17. end
  18. end
  19. describe '#object_type' do
  20. it 'returns :emoji' do
  21. custom_emoji = Fabricate(:custom_emoji)
  22. expect(custom_emoji.object_type).to be :emoji
  23. end
  24. end
  25. describe '.from_text' do
  26. let!(:emojo) { Fabricate(:custom_emoji) }
  27. subject { described_class.from_text(text, nil) }
  28. context 'with plain text' do
  29. let(:text) { 'Hello :coolcat:' }
  30. it 'returns records used via shortcodes in text' do
  31. is_expected.to include(emojo)
  32. end
  33. end
  34. context 'with html' do
  35. let(:text) { '<p>Hello :coolcat:</p>' }
  36. it 'returns records used via shortcodes in text' do
  37. is_expected.to include(emojo)
  38. end
  39. end
  40. end
  41. end