mirror of
https://github.com/mastodon/mastodon.git
synced 2025-02-06 15:05:07 +00:00
Migrate visibility interaction checks on statuses to request spec (#33622)
This commit is contained in:
parent
1c23ebd62f
commit
5be938e661
|
@ -9,45 +9,6 @@ RSpec.describe StatusesController do
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
let(:status) { Fabricate(:status, account: account) }
|
let(:status) { Fabricate(:status, account: account) }
|
||||||
|
|
||||||
context 'when account is permanently suspended' do
|
|
||||||
before do
|
|
||||||
account.suspend!
|
|
||||||
account.deletion_request.destroy
|
|
||||||
|
|
||||||
get :show, params: { account_username: account.username, id: status.id }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http gone' do
|
|
||||||
expect(response).to have_http_status(410)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when account is temporarily suspended' do
|
|
||||||
before do
|
|
||||||
account.suspend!
|
|
||||||
|
|
||||||
get :show, params: { account_username: account.username, id: status.id }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http forbidden' do
|
|
||||||
expect(response).to have_http_status(403)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when status is a reblog' do
|
|
||||||
let(:original_account) { Fabricate(:account, domain: 'example.com') }
|
|
||||||
let(:original_status) { Fabricate(:status, account: original_account, url: 'https://example.com/123') }
|
|
||||||
let(:status) { Fabricate(:status, account: account, reblog: original_status) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
get :show, params: { account_username: status.account.username, id: status.id }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to the original status' do
|
|
||||||
expect(response).to redirect_to(original_status.url)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when status is public' do
|
context 'when status is public' do
|
||||||
before do
|
before do
|
||||||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||||
|
@ -142,17 +103,6 @@ RSpec.describe StatusesController do
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when account blocks user' do
|
|
||||||
before do
|
|
||||||
account.block!(user.account)
|
|
||||||
get :show, params: { account_username: status.account.username, id: status.id }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http not found' do
|
|
||||||
expect(response).to have_http_status(404)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when status is public' do
|
context 'when status is public' do
|
||||||
before do
|
before do
|
||||||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||||
|
|
67
spec/requests/statuses_spec.rb
Normal file
67
spec/requests/statuses_spec.rb
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Statuses' do
|
||||||
|
describe 'GET /@:account_username/:id' do
|
||||||
|
let(:account) { Fabricate(:account) }
|
||||||
|
let(:status) { Fabricate(:status, account: account) }
|
||||||
|
|
||||||
|
context 'when signed out' do
|
||||||
|
context 'when account is permanently suspended' do
|
||||||
|
before do
|
||||||
|
account.suspend!
|
||||||
|
account.deletion_request.destroy
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http gone' do
|
||||||
|
get "/@#{account.username}/#{status.id}"
|
||||||
|
|
||||||
|
expect(response)
|
||||||
|
.to have_http_status(410)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when account is temporarily suspended' do
|
||||||
|
before { account.suspend! }
|
||||||
|
|
||||||
|
it 'returns http forbidden' do
|
||||||
|
get "/@#{account.username}/#{status.id}"
|
||||||
|
|
||||||
|
expect(response)
|
||||||
|
.to have_http_status(403)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when status is a reblog' do
|
||||||
|
let(:original_account) { Fabricate(:account, domain: 'example.com') }
|
||||||
|
let(:original_status) { Fabricate(:status, account: original_account, url: 'https://example.com/123') }
|
||||||
|
let(:status) { Fabricate(:status, account: account, reblog: original_status) }
|
||||||
|
|
||||||
|
it 'redirects to the original status' do
|
||||||
|
get "/@#{status.account.username}/#{status.id}"
|
||||||
|
|
||||||
|
expect(response)
|
||||||
|
.to redirect_to(original_status.url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when signed in' do
|
||||||
|
let(:user) { Fabricate(:user) }
|
||||||
|
|
||||||
|
before { sign_in(user) }
|
||||||
|
|
||||||
|
context 'when account blocks user' do
|
||||||
|
before { account.block!(user.account) }
|
||||||
|
|
||||||
|
it 'returns http not found' do
|
||||||
|
get "/@#{status.account.username}/#{status.id}"
|
||||||
|
|
||||||
|
expect(response)
|
||||||
|
.to have_http_status(404)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user