2016-03-01 05:42:08 +11:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe AccountsController, type: :controller do
|
2016-09-08 08:33:07 +10:00
|
|
|
render_views
|
|
|
|
|
2022-01-28 10:46:42 +11:00
|
|
|
let(:account) { Fabricate(:account) }
|
2016-03-01 05:42:08 +11:00
|
|
|
|
2022-03-07 08:51:40 +11:00
|
|
|
shared_examples 'cacheable response' do
|
2020-07-22 19:44:02 +10:00
|
|
|
it 'does not set cookies' do
|
|
|
|
expect(response.cookies).to be_empty
|
|
|
|
expect(response.headers['Set-Cookies']).to be nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not set sessions' do
|
|
|
|
expect(session).to be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns public Cache-Control header' do
|
|
|
|
expect(response.headers['Cache-Control']).to include 'public'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-01 05:42:08 +11:00
|
|
|
describe 'GET #show' do
|
2020-05-04 06:19:24 +10:00
|
|
|
let(:format) { 'html' }
|
|
|
|
|
|
|
|
let!(:status) { Fabricate(:status, account: account) }
|
|
|
|
let!(:status_reply) { Fabricate(:status, account: account, thread: Fabricate(:status)) }
|
|
|
|
let!(:status_self_reply) { Fabricate(:status, account: account, thread: status) }
|
|
|
|
let!(:status_media) { Fabricate(:status, account: account) }
|
|
|
|
let!(:status_pinned) { Fabricate(:status, account: account) }
|
|
|
|
let!(:status_private) { Fabricate(:status, account: account, visibility: :private) }
|
|
|
|
let!(:status_direct) { Fabricate(:status, account: account, visibility: :direct) }
|
|
|
|
let!(:status_reblog) { Fabricate(:status, account: account, reblog: Fabricate(:status)) }
|
2017-05-23 10:53:01 +10:00
|
|
|
|
2016-09-08 08:33:07 +10:00
|
|
|
before do
|
2020-05-04 06:19:24 +10:00
|
|
|
status_media.media_attachments << Fabricate(:media_attachment, account: account, type: :image)
|
|
|
|
account.pinned_statuses << status_pinned
|
2022-01-17 10:49:55 +11:00
|
|
|
account.pinned_statuses << status_private
|
2016-03-01 05:42:08 +11:00
|
|
|
end
|
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
shared_examples 'preliminary checks' do
|
|
|
|
context 'when account is not approved' do
|
|
|
|
before do
|
|
|
|
account.user.update(approved: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http not found' do
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
expect(response).to have_http_status(404)
|
|
|
|
end
|
|
|
|
end
|
2020-11-08 10:28:39 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'as HTML' do
|
|
|
|
let(:format) { 'html' }
|
2020-05-04 06:19:24 +10:00
|
|
|
|
2020-11-08 10:28:39 +11:00
|
|
|
it_behaves_like 'preliminary checks'
|
|
|
|
|
|
|
|
context 'when account is permanently suspended' do
|
2020-05-04 06:19:24 +10:00
|
|
|
before do
|
|
|
|
account.suspend!
|
2020-11-08 10:28:39 +11:00
|
|
|
account.deletion_request.destroy
|
2020-05-04 06:19:24 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http gone' do
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
expect(response).to have_http_status(410)
|
|
|
|
end
|
2017-05-23 10:53:01 +10:00
|
|
|
end
|
2020-05-04 06:19:24 +10:00
|
|
|
|
2020-11-08 10:28:39 +11:00
|
|
|
context 'when account is temporarily suspended' do
|
|
|
|
before do
|
|
|
|
account.suspend!
|
|
|
|
end
|
2020-05-04 06:19:24 +10:00
|
|
|
|
2020-11-08 10:28:39 +11:00
|
|
|
it 'returns http forbidden' do
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
2020-05-04 06:19:24 +10:00
|
|
|
|
|
|
|
shared_examples 'common response characteristics' do
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns Link header' do
|
|
|
|
expect(response.headers['Link'].to_s).to include ActivityPub::TagManager.instance.uri_for(account)
|
|
|
|
end
|
2017-05-23 10:53:01 +10:00
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
it 'renders show template' do
|
|
|
|
expect(response).to render_template(:show)
|
|
|
|
end
|
2017-05-23 10:53:01 +10:00
|
|
|
end
|
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
context do
|
|
|
|
before do
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'common response characteristics'
|
|
|
|
|
|
|
|
it 'renders public status' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders self-reply' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_self_reply))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders status with media' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_media))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders reblog' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_reblog.reblog))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders pinned status' do
|
|
|
|
expect(response.body).to include(I18n.t('stream_entries.pinned'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render private status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_private))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render direct status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_direct))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reply to someone else' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reply))
|
|
|
|
end
|
2016-09-08 08:33:07 +10:00
|
|
|
end
|
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
context 'when signed-in' do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user follows account' do
|
|
|
|
before do
|
|
|
|
user.account.follow!(account)
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render private status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_private))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user is blocked' do
|
|
|
|
before do
|
|
|
|
account.block!(user.account)
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders unavailable message' do
|
|
|
|
expect(response.body).to include(I18n.t('accounts.unavailable'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render public status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render self-reply' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_self_reply))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render status with media' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_media))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reblog' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reblog.reblog))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render pinned status' do
|
|
|
|
expect(response.body).to_not include(I18n.t('stream_entries.pinned'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render private status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_private))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render direct status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_direct))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reply to someone else' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reply))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with replies' do
|
|
|
|
before do
|
|
|
|
allow(controller).to receive(:replies_requested?).and_return(true)
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'common response characteristics'
|
|
|
|
|
|
|
|
it 'renders public status' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders self-reply' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_self_reply))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders status with media' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_media))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders reblog' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_reblog.reblog))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render pinned status' do
|
|
|
|
expect(response.body).to_not include(I18n.t('stream_entries.pinned'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render private status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_private))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render direct status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_direct))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders reply to someone else' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_reply))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with media' do
|
|
|
|
before do
|
|
|
|
allow(controller).to receive(:media_requested?).and_return(true)
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'common response characteristics'
|
|
|
|
|
|
|
|
it 'does not render public status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render self-reply' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_self_reply))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders status with media' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_media))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reblog' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reblog.reblog))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render pinned status' do
|
|
|
|
expect(response.body).to_not include(I18n.t('stream_entries.pinned'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render private status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_private))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render direct status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_direct))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reply to someone else' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reply))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with tag' do
|
|
|
|
let(:tag) { Fabricate(:tag) }
|
|
|
|
|
|
|
|
let!(:status_tag) { Fabricate(:status, account: account) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(controller).to receive(:tag_requested?).and_return(true)
|
|
|
|
status_tag.tags << tag
|
|
|
|
get :show, params: { username: account.username, format: format, tag: tag.to_param }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'common response characteristics'
|
|
|
|
|
|
|
|
it 'does not render public status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render self-reply' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_self_reply))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render status with media' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_media))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reblog' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reblog.reblog))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render pinned status' do
|
|
|
|
expect(response.body).to_not include(I18n.t('stream_entries.pinned'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render private status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_private))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render direct status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_direct))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reply to someone else' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reply))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders status with tag' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_tag))
|
|
|
|
end
|
2016-09-08 08:33:07 +10:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
context 'as JSON' do
|
|
|
|
let(:authorized_fetch_mode) { false }
|
2017-11-10 00:36:17 +11:00
|
|
|
let(:format) { 'json' }
|
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
before do
|
|
|
|
allow(controller).to receive(:authorized_fetch_mode?).and_return(authorized_fetch_mode)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'preliminary checks'
|
|
|
|
|
2020-11-08 10:28:39 +11:00
|
|
|
context 'when account is suspended permanently' do
|
|
|
|
before do
|
|
|
|
account.suspend!
|
|
|
|
account.deletion_request.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http gone' do
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
expect(response).to have_http_status(410)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when account is suspended temporarily' do
|
|
|
|
before do
|
|
|
|
account.suspend!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
context do
|
|
|
|
before do
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns application/activity+json' do
|
2021-03-17 20:09:55 +11:00
|
|
|
expect(response.media_type).to eq 'application/activity+json'
|
2020-05-04 06:19:24 +10:00
|
|
|
end
|
|
|
|
|
2022-03-07 08:51:40 +11:00
|
|
|
it_behaves_like 'cacheable response'
|
2020-05-04 06:19:24 +10:00
|
|
|
|
|
|
|
it 'renders account' do
|
|
|
|
json = body_as_json
|
|
|
|
expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'in authorized fetch mode' do
|
|
|
|
let(:authorized_fetch_mode) { true }
|
2017-09-04 20:53:18 +10:00
|
|
|
|
2020-09-14 21:04:29 +10:00
|
|
|
it 'returns http unauthorized' do
|
|
|
|
expect(response).to have_http_status(401)
|
2017-11-10 00:36:17 +11:00
|
|
|
end
|
|
|
|
end
|
2020-05-04 06:19:24 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when signed in' do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns application/activity+json' do
|
2021-03-17 20:09:55 +11:00
|
|
|
expect(response.media_type).to eq 'application/activity+json'
|
2020-05-04 06:19:24 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns public Cache-Control header' do
|
|
|
|
expect(response.headers['Cache-Control']).to include 'public'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders account' do
|
|
|
|
json = body_as_json
|
|
|
|
expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with signature' do
|
|
|
|
let(:remote_account) { Fabricate(:account, domain: 'example.com') }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(controller).to receive(:signed_request_account).and_return(remote_account)
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns application/activity+json' do
|
2021-03-17 20:09:55 +11:00
|
|
|
expect(response.media_type).to eq 'application/activity+json'
|
2020-05-04 06:19:24 +10:00
|
|
|
end
|
|
|
|
|
2022-03-07 08:51:40 +11:00
|
|
|
it_behaves_like 'cacheable response'
|
2020-05-04 06:19:24 +10:00
|
|
|
|
|
|
|
it 'renders account' do
|
|
|
|
json = body_as_json
|
|
|
|
expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'in authorized fetch mode' do
|
|
|
|
let(:authorized_fetch_mode) { true }
|
2017-05-23 10:53:01 +10:00
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns application/activity+json' do
|
2021-03-17 20:09:55 +11:00
|
|
|
expect(response.media_type).to eq 'application/activity+json'
|
2020-05-04 06:19:24 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns private Cache-Control header' do
|
|
|
|
expect(response.headers['Cache-Control']).to include 'private'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns Vary header with Signature' do
|
|
|
|
expect(response.headers['Vary']).to include 'Signature'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders account' do
|
|
|
|
json = body_as_json
|
|
|
|
expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
2017-11-10 00:36:17 +11:00
|
|
|
end
|
|
|
|
end
|
2016-09-08 08:33:07 +10:00
|
|
|
end
|
2020-05-04 06:19:24 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'as RSS' do
|
|
|
|
let(:format) { 'rss' }
|
2016-09-08 08:33:07 +10:00
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
it_behaves_like 'preliminary checks'
|
|
|
|
|
2020-11-08 10:28:39 +11:00
|
|
|
context 'when account is permanently suspended' do
|
|
|
|
before do
|
|
|
|
account.suspend!
|
|
|
|
account.deletion_request.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http gone' do
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
expect(response).to have_http_status(410)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when account is temporarily suspended' do
|
|
|
|
before do
|
|
|
|
account.suspend!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http forbidden' do
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
shared_examples 'common response characteristics' do
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
2017-11-10 00:36:17 +11:00
|
|
|
|
2022-03-07 08:51:40 +11:00
|
|
|
it_behaves_like 'cacheable response'
|
2020-05-04 06:19:24 +10:00
|
|
|
end
|
2017-11-10 00:36:17 +11:00
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
context do
|
|
|
|
before do
|
|
|
|
get :show, params: { username: account.username, format: format }
|
2017-11-10 00:36:17 +11:00
|
|
|
end
|
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
it_behaves_like 'common response characteristics'
|
|
|
|
|
|
|
|
it 'renders public status' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status))
|
|
|
|
end
|
2017-11-10 00:36:17 +11:00
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
it 'renders self-reply' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_self_reply))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders status with media' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_media))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reblog' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reblog.reblog))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render private status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_private))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render direct status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_direct))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reply to someone else' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reply))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with replies' do
|
|
|
|
before do
|
|
|
|
allow(controller).to receive(:replies_requested?).and_return(true)
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'common response characteristics'
|
|
|
|
|
|
|
|
it 'renders public status' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders self-reply' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_self_reply))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders status with media' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_media))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reblog' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reblog.reblog))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render private status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_private))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render direct status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_direct))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders reply to someone else' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_reply))
|
2017-11-10 00:36:17 +11:00
|
|
|
end
|
2017-08-26 02:50:52 +10:00
|
|
|
end
|
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
context 'with media' do
|
|
|
|
before do
|
|
|
|
allow(controller).to receive(:media_requested?).and_return(true)
|
|
|
|
get :show, params: { username: account.username, format: format }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'common response characteristics'
|
|
|
|
|
|
|
|
it 'does not render public status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status))
|
|
|
|
end
|
2017-11-10 00:36:17 +11:00
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
it 'does not render self-reply' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_self_reply))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders status with media' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_media))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reblog' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reblog.reblog))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render private status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_private))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render direct status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_direct))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reply to someone else' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reply))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with tag' do
|
|
|
|
let(:tag) { Fabricate(:tag) }
|
|
|
|
|
|
|
|
let!(:status_tag) { Fabricate(:status, account: account) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(controller).to receive(:tag_requested?).and_return(true)
|
|
|
|
status_tag.tags << tag
|
|
|
|
get :show, params: { username: account.username, format: format, tag: tag.to_param }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'common response characteristics'
|
|
|
|
|
|
|
|
it 'does not render public status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render self-reply' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_self_reply))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render status with media' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_media))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reblog' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reblog.reblog))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render private status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_private))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render direct status' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_direct))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render reply to someone else' do
|
|
|
|
expect(response.body).to_not include(ActivityPub::TagManager.instance.url_for(status_reply))
|
|
|
|
end
|
2017-11-10 00:36:17 +11:00
|
|
|
|
2020-05-04 06:19:24 +10:00
|
|
|
it 'renders status with tag' do
|
|
|
|
expect(response.body).to include(ActivityPub::TagManager.instance.url_for(status_tag))
|
2017-11-10 00:36:17 +11:00
|
|
|
end
|
2016-09-08 08:33:07 +10:00
|
|
|
end
|
2016-03-01 05:42:08 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|