diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
commit | 9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch) | |
tree | 865198c01d1824a9b098127baa3ab980c9cd2c06 /spec/routing/uploads_routing_spec.rb | |
parent | 6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff) |
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'spec/routing/uploads_routing_spec.rb')
-rw-r--r-- | spec/routing/uploads_routing_spec.rb | 95 |
1 files changed, 71 insertions, 24 deletions
diff --git a/spec/routing/uploads_routing_spec.rb b/spec/routing/uploads_routing_spec.rb index 198cda59357..63840b4c30b 100644 --- a/spec/routing/uploads_routing_spec.rb +++ b/spec/routing/uploads_routing_spec.rb @@ -3,37 +3,84 @@ require 'spec_helper' RSpec.describe 'Uploads', 'routing' do - it 'allows creating uploads for personal snippets' do - expect(post('/uploads/personal_snippet?id=1')).to route_to( - controller: 'uploads', - action: 'create', - model: 'personal_snippet', - id: '1' - ) + context 'for personal snippets' do + it 'allows creating uploads for personal snippets' do + expect(post('/uploads/personal_snippet?id=1')).to route_to( + controller: 'uploads', + action: 'create', + model: 'personal_snippet', + id: '1' + ) + end + end + + context 'for users' do + it 'allows creating uploads for users' do + expect(post('/uploads/user?id=1')).to route_to( + controller: 'uploads', + action: 'create', + model: 'user', + id: '1' + ) + end end - it 'allows creating uploads for users' do - expect(post('/uploads/user?id=1')).to route_to( - controller: 'uploads', - action: 'create', - model: 'user', - id: '1' - ) + context 'for abuse reports' do + it 'allows fetching uploaded files for abuse reports' do + expect(get('/uploads/-/system/abuse_report/1/secret/test.png')).to route_to( + controller: 'uploads', + action: 'show', + model: 'abuse_report', + id: '1', + secret: 'secret', + filename: 'test.png' + ) + end + + it 'allows creating uploads for abuse reports' do + expect(post('/uploads/abuse_report?id=1')).to route_to( + controller: 'uploads', + action: 'create', + model: 'abuse_report', + id: '1' + ) + end + + it 'allows authorizing uploads for abuse reports' do + expect(post('/uploads/abuse_report/authorize')).to route_to( + controller: 'uploads', + action: 'authorize', + model: 'abuse_report' + ) + end + + it 'allows fetching abuse report screenshots' do + expect(get('/uploads/-/system/abuse_report/screenshot/1/test.jpg')).to route_to( + controller: 'uploads', + action: 'show', + model: 'abuse_report', + id: '1', + filename: 'test.jpg', + mounted_as: 'screenshot' + ) + end end - it 'allows fetching alert metric metric images' do - expect(get('/uploads/-/system/alert_management_metric_image/file/1/test.jpg')).to route_to( - controller: 'uploads', - action: 'show', - model: 'alert_management_metric_image', - id: '1', - filename: 'test.jpg', - mounted_as: 'file' - ) + context 'for alert management' do + it 'allows fetching alert metric metric images' do + expect(get('/uploads/-/system/alert_management_metric_image/file/1/test.jpg')).to route_to( + controller: 'uploads', + action: 'show', + model: 'alert_management_metric_image', + id: '1', + filename: 'test.jpg', + mounted_as: 'file' + ) + end end it 'does not allow creating uploads for other models' do - unroutable_models = UploadsController::MODEL_CLASSES.keys.compact - %w[personal_snippet user] + unroutable_models = UploadsController::MODEL_CLASSES.keys.compact - %w[personal_snippet user abuse_report] unroutable_models.each do |model| expect(post("/uploads/#{model}?id=1")).not_to be_routable |