about summary refs log tree commit diff
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/account_moderation_note_spec.rb5
-rw-r--r--spec/models/email_domain_block_spec.rb21
-rw-r--r--spec/models/feed_spec.rb2
-rw-r--r--spec/models/media_attachment_spec.rb9
4 files changed, 35 insertions, 2 deletions
diff --git a/spec/models/account_moderation_note_spec.rb b/spec/models/account_moderation_note_spec.rb
new file mode 100644
index 000000000..c4be8c4af
--- /dev/null
+++ b/spec/models/account_moderation_note_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe AccountModerationNote, type: :model do
+  pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/email_domain_block_spec.rb b/spec/models/email_domain_block_spec.rb
new file mode 100644
index 000000000..5f5d189d9
--- /dev/null
+++ b/spec/models/email_domain_block_spec.rb
@@ -0,0 +1,21 @@
+require 'rails_helper'
+
+RSpec.describe EmailDomainBlock, type: :model do
+  describe 'validations' do
+    it 'has a valid fabricator' do
+      email_domain_block = Fabricate.build(:email_domain_block)
+      expect(email_domain_block).to be_valid
+    end
+  end
+
+  describe 'block?' do
+    it 'returns true if the domain is registed' do
+      Fabricate(:email_domain_block, domain: 'example.com')
+      expect(EmailDomainBlock.block?('nyarn@example.com')).to eq true
+    end
+    it 'returns true if the domain is not registed' do
+      Fabricate(:email_domain_block, domain: 'domain')
+      expect(EmailDomainBlock.block?('example')).to eq false
+    end
+  end
+end
diff --git a/spec/models/feed_spec.rb b/spec/models/feed_spec.rb
index 1c377c17f..5433f44bd 100644
--- a/spec/models/feed_spec.rb
+++ b/spec/models/feed_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Feed, type: :model do
       Fabricate(:status, account: account, id: 3)
       Fabricate(:status, account: account, id: 10)
       Redis.current.zadd(FeedManager.instance.key(:home, account.id),
-                        [[4, 'deleted'], [3, 'val3'], [2, 'val2'], [1, 'val1']])
+                        [[4, 4], [3, 3], [2, 2], [1, 1]])
 
       feed = Feed.new(:home, account)
       results = feed.get(3)
diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb
index f6717b7d5..9fce5bc4f 100644
--- a/spec/models/media_attachment_spec.rb
+++ b/spec/models/media_attachment_spec.rb
@@ -17,7 +17,6 @@ RSpec.describe MediaAttachment, type: :model do
       expect(media.file.meta["original"]["height"]).to eq 128
       expect(media.file.meta["original"]["aspect"]).to eq 1.0
     end
-
   end
 
   describe 'non-animated gif non-conversion' do
@@ -50,4 +49,12 @@ RSpec.describe MediaAttachment, type: :model do
       expect(media.file.meta["small"]["aspect"]).to eq 400.0/267
     end
   end
+
+  describe 'descriptions for remote attachments' do
+    it 'are cut off at 140 characters' do
+      media = Fabricate(:media_attachment, description: 'foo' * 1000, remote_url: 'http://example.com/blah.jpg')
+
+      expect(media.description.size).to be <= 420
+    end
+  end
 end