.circleci
.github
app
bin
config
db
docs
lib
log
nanobox
public
spec
controllers
activitypub
admin
api
auth
concerns
oauth
settings
well_known
about_controller_spec.rb
account_follow_controller_spec.rb
account_unfollow_controller_spec.rb
accounts_controller_spec.rb
application_controller_spec.rb
authorize_follows_controller_spec.rb
follower_accounts_controller_spec.rb
following_accounts_controller_spec.rb
home_controller_spec.rb
invites_controller_spec.rb
manifests_controller_spec.rb
media_controller_spec.rb
remote_follow_controller_spec.rb
statuses_controller_spec.rb
stream_entries_controller_spec.rb
tags_controller_spec.rb
fabricators
features
fixtures
helpers
lib
mailers
models
policies
presenters
requests
routing
services
support
validators
views
workers
rails_helper.rb
spec_helper.rb
streaming
vendor
.babelrc
.buildpacks
.codeclimate.yml
.dockerignore
.editorconfig
.env.nanobox
.env.production.sample
.env.test
.env.vagrant
.eslintignore
.eslintrc.yml
.foreman
.gitattributes
.gitignore
.haml-lint.yml
.nanoignore
.nvmrc
.postcssrc.yml
.profile
.rspec
.rubocop.yml
.ruby-version
.scss-lint.yml
.slugignore
.yarnclean
AUTHORS.md
Aptfile
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Capfile
Dockerfile
Gemfile
Gemfile.lock
LICENSE
Procfile
Procfile.dev
README.md
Rakefile
Vagrantfile
app.json
boxfile.yml
config.ru
docker-compose.yml
jest.config.js
package.json
scalingo.json
yarn.lock
40 lines
1.2 KiB
Ruby
40 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe MediaController do
|
|
render_views
|
|
|
|
describe '#show' do
|
|
it 'redirects to the file url when attached to a status' do
|
|
status = Fabricate(:status)
|
|
media_attachment = Fabricate(:media_attachment, status: status)
|
|
get :show, params: { id: media_attachment.to_param }
|
|
|
|
expect(response).to redirect_to(media_attachment.file.url(:original))
|
|
end
|
|
|
|
it 'responds with missing when there is not an attached status' do
|
|
media_attachment = Fabricate(:media_attachment, status: nil)
|
|
get :show, params: { id: media_attachment.to_param }
|
|
|
|
expect(response).to have_http_status(404)
|
|
end
|
|
|
|
it 'raises when shortcode cant be found' do
|
|
get :show, params: { id: 'missing' }
|
|
|
|
expect(response).to have_http_status(404)
|
|
end
|
|
|
|
it 'raises when not permitted to view' do
|
|
status = Fabricate(:status)
|
|
media_attachment = Fabricate(:media_attachment, status: status)
|
|
allow_any_instance_of(MediaController).to receive(:authorize).and_raise(ActiveRecord::RecordNotFound)
|
|
get :show, params: { id: media_attachment.to_param }
|
|
|
|
expect(response).to have_http_status(404)
|
|
end
|
|
end
|
|
end
|