about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/fabricators/media_attachment_fabricator.rb2
-rw-r--r--spec/services/post_status_service_spec.rb41
2 files changed, 42 insertions, 1 deletions
diff --git a/spec/fabricators/media_attachment_fabricator.rb b/spec/fabricators/media_attachment_fabricator.rb
index 59db2440d..dc91d708f 100644
--- a/spec/fabricators/media_attachment_fabricator.rb
+++ b/spec/fabricators/media_attachment_fabricator.rb
@@ -1,3 +1,3 @@
 Fabricator(:media_attachment) do
-
+  account
 end
diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb
index 9ee4daf6f..acb922d64 100644
--- a/spec/services/post_status_service_spec.rb
+++ b/spec/services/post_status_service_spec.rb
@@ -7,4 +7,45 @@ RSpec.describe PostStatusService do
   it 'creates a new response status'
   it 'processes mentions'
   it 'pings PuSH hubs'
+
+  it 'does not allow attaching more than 4 files' do
+    account = Fabricate(:account)
+
+    expect do
+      PostStatusService.new.call(
+      account,
+      "test status update",
+      nil,
+      media_ids: [
+        Fabricate(:media_attachment, account: account),
+        Fabricate(:media_attachment, account: account),
+        Fabricate(:media_attachment, account: account),
+        Fabricate(:media_attachment, account: account),
+        Fabricate(:media_attachment, account: account),
+      ].map(&:id),
+    )
+    end.to raise_error(
+      Mastodon::ValidationError,
+      'Cannot attach more than 4 files',
+    )
+  end
+
+  it 'does not allow attaching both videos and images' do
+    account = Fabricate(:account)
+
+    expect do
+      PostStatusService.new.call(
+      account,
+      "test status update",
+      nil,
+      media_ids: [
+        Fabricate(:media_attachment, type: :video, account: account),
+        Fabricate(:media_attachment, type: :image, account: account),
+      ].map(&:id),
+    )
+    end.to raise_error(
+      Mastodon::ValidationError,
+      'Cannot attach a video to a toot that already contains images',
+    )
+  end
 end