diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/custom_emoji_spec.rb | 25 | ||||
-rw-r--r-- | spec/models/site_upload_spec.rb | 5 | ||||
-rw-r--r-- | spec/models/status_spec.rb | 29 |
3 files changed, 50 insertions, 9 deletions
diff --git a/spec/models/custom_emoji_spec.rb b/spec/models/custom_emoji_spec.rb new file mode 100644 index 000000000..cb51e9519 --- /dev/null +++ b/spec/models/custom_emoji_spec.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +RSpec.describe CustomEmoji, type: :model do + describe '.from_text' do + let!(:emojo) { Fabricate(:custom_emoji) } + + subject { described_class.from_text(text, nil) } + + context 'with plain text' do + let(:text) { 'Hello :coolcat:' } + + it 'returns records used via shortcodes in text' do + is_expected.to include(emojo) + end + end + + context 'with html' do + let(:text) { '<p>Hello :coolcat:</p>' } + + it 'returns records used via shortcodes in text' do + is_expected.to include(emojo) + end + end + end +end diff --git a/spec/models/site_upload_spec.rb b/spec/models/site_upload_spec.rb new file mode 100644 index 000000000..8745d54b8 --- /dev/null +++ b/spec/models/site_upload_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SiteUpload, type: :model do + +end diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index 484effd5e..9cb71d715 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -173,16 +173,19 @@ RSpec.describe Status, type: :model do end end - describe '.local_only' do - it 'returns only statuses from local accounts' do - local_account = Fabricate(:account, domain: nil) - remote_account = Fabricate(:account, domain: 'test.com') - local_status = Fabricate(:status, account: local_account) - remote_status = Fabricate(:status, account: remote_account) + describe '.not_in_filtered_languages' do + context 'for accounts with language filters' do + let(:user) { Fabricate(:user, filtered_languages: ['en']) } - results = described_class.local_only - expect(results).to include(local_status) - expect(results).not_to include(remote_status) + it 'does not include statuses in filtered languages' do + status = Fabricate(:status, language: 'en') + expect(Status.not_in_filtered_languages(user.account)).not_to include status + end + + it 'includes status with unknown language' do + status = Fabricate(:status, language: nil) + expect(Status.not_in_filtered_languages(user.account)).to include status + end end end @@ -529,6 +532,14 @@ RSpec.describe Status, type: :model do end end + describe 'validation' do + it 'disallow empty uri for remote status' do + alice.update(domain: 'example.com') + status = Fabricate.build(:status, uri: '', account: alice) + expect(status).to model_have_error_on_field(:uri) + end + end + describe 'after_create' do it 'saves ActivityPub uri as uri for local status' do status = Status.create(account: alice, text: 'foo') |