summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatt Jankowski <matt@jankowski.online>2024-05-27 05:49:44 -0400
committerGitHub <noreply@github.com>2024-05-27 09:49:44 +0000
commitc61e356475cf5df85f067a951abf404b93795f19 (patch)
tree583461343261045498b8443dc29439b5f47f8a86 /spec
parent87156f57b5b7b71be8a40e9cc568a87583b55144 (diff)
Add `Status::MEDIA_ATTACHMENTS_LIMIT` configuration constant (#30433)
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/v2/instance_spec.rb2
-rw-r--r--spec/services/post_status_service_spec.rb5
2 files changed, 4 insertions, 3 deletions
diff --git a/spec/requests/api/v2/instance_spec.rb b/spec/requests/api/v2/instance_spec.rb
index c5c6a26f49e..5c464f09a7d 100644
--- a/spec/requests/api/v2/instance_spec.rb
+++ b/spec/requests/api/v2/instance_spec.rb
@@ -45,7 +45,7 @@ describe 'Instances' do
),
statuses: include(
max_characters: StatusLengthValidator::MAX_CHARS,
- max_media_attachments: 4 # TODO, move to constant somewhere
+ max_media_attachments: Status::MEDIA_ATTACHMENTS_LIMIT
),
polls: include(
max_options: PollValidator::MAX_OPTIONS
diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb
index 18891bf1186..11bf4c30ea3 100644
--- a/spec/services/post_status_service_spec.rb
+++ b/spec/services/post_status_service_spec.rb
@@ -228,14 +228,15 @@ RSpec.describe PostStatusService do
expect(media.reload.status).to be_nil
end
- it 'does not allow attaching more than 4 files' do
+ it 'does not allow attaching more files than configured limit' do
+ stub_const('Status::MEDIA_ATTACHMENTS_LIMIT', 1)
account = Fabricate(:account)
expect do
subject.call(
account,
text: 'test status update',
- media_ids: Array.new(5) { Fabricate(:media_attachment, account: account) }.map(&:id)
+ media_ids: Array.new(2) { Fabricate(:media_attachment, account: account) }.map(&:id)
)
end.to raise_error(
Mastodon::ValidationError,