Merge commit '5dfdec645313e556413147597138a8008bc35996' into glitch-soc/merge-upstream

This commit is contained in:
Claire committed 2024-09-23 20:24:18 +02:00
commit c2c3a66478
124 files changed
+902 -699

No files matched your search

+15 -15
View File
@@ -46,21 +46,6 @@ RSpec.describe 'Accounts show response' do
describe 'GET to short username paths' do
context 'with existing statuses' do
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)) }
before do
status_media.media_attachments << Fabricate(:media_attachment, account: account, type: :image)
account.pinned_statuses << status_pinned
account.pinned_statuses << status_private
end
context 'with HTML' do
let(:format) { 'html' }
@@ -207,6 +192,21 @@ RSpec.describe 'Accounts show response' do
context 'with RSS' do
let(:format) { 'rss' }
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)) }
before do
status_media.media_attachments << Fabricate(:media_attachment, account: account, type: :image)
account.pinned_statuses << status_pinned
account.pinned_statuses << status_private
end
context 'with a normal account in an RSS request' do
before do
get short_account_path(username: account.username, format: format)
@@ -20,19 +20,16 @@ RSpec.describe 'Canonical Email Blocks' do
it_behaves_like 'forbidden for wrong role', ''
it_behaves_like 'forbidden for wrong role', 'Moderator'
it 'returns http success' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
context 'when there is no canonical email block' do
it 'returns an empty list' do
subject
expect(response.parsed_body).to be_empty
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to be_empty
end
end
@@ -43,7 +40,12 @@ RSpec.describe 'Canonical Email Blocks' do
it 'returns the correct canonical email hashes' do
subject
expect(response.parsed_body.pluck(:canonical_email_hash)).to match_array(expected_email_hashes)
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.pluck(:canonical_email_hash))
.to match_array(expected_email_hashes)
end
context 'with limit param' do
@@ -20,18 +20,14 @@ RSpec.describe 'Domain Allows' do
it_behaves_like 'forbidden for wrong role', ''
it_behaves_like 'forbidden for wrong role', 'Moderator'
it 'returns http success' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
context 'when there is no allowed domains' do
it 'returns an empty body' do
subject
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body).to be_empty
end
end
@@ -51,7 +47,12 @@ RSpec.describe 'Domain Allows' do
it 'returns the correct allowed domains' do
subject
expect(response.parsed_body).to match_array(expected_response)
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to match_array(expected_response)
end
context 'with limit param' do
@@ -20,19 +20,16 @@ RSpec.describe 'Domain Blocks' do
it_behaves_like 'forbidden for wrong role', ''
it_behaves_like 'forbidden for wrong role', 'Moderator'
it 'returns http success' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
context 'when there are no domain blocks' do
it 'returns an empty list' do
subject
expect(response.parsed_body).to be_empty
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to be_empty
end
end
@@ -66,7 +63,12 @@ RSpec.describe 'Domain Blocks' do
it 'returns the expected domain blocks' do
subject
expect(response.parsed_body).to match_array(expected_responde)
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to match_array(expected_responde)
end
context 'with limit param' do
@@ -21,19 +21,16 @@ RSpec.describe 'Email Domain Blocks' do
it_behaves_like 'forbidden for wrong role', ''
it_behaves_like 'forbidden for wrong role', 'Moderator'
it 'returns http success' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
context 'when there is no email domain block' do
it 'returns an empty list' do
subject
expect(response.parsed_body).to be_empty
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to be_empty
end
end
@@ -44,7 +41,12 @@ RSpec.describe 'Email Domain Blocks' do
it 'return the correct blocked email domains' do
subject
expect(response.parsed_body.pluck(:domain)).to match_array(blocked_email_domains)
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.pluck(:domain))
.to match_array(blocked_email_domains)
end
context 'with limit param' do
+12 -10
View File
@@ -20,19 +20,16 @@ RSpec.describe 'IP Blocks' do
it_behaves_like 'forbidden for wrong role', ''
it_behaves_like 'forbidden for wrong role', 'Moderator'
it 'returns http success' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
context 'when there is no ip block' do
it 'returns an empty body' do
subject
expect(response.parsed_body).to be_empty
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to be_empty
end
end
@@ -60,7 +57,12 @@ RSpec.describe 'IP Blocks' do
it 'returns the correct blocked ips' do
subject
expect(response.parsed_body).to match_array(expected_response)
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to match_array(expected_response)
end
context 'with limit param' do
+12 -10
View File
@@ -19,19 +19,16 @@ RSpec.describe 'Reports' do
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
it_behaves_like 'forbidden for wrong role', ''
it 'returns http success' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
context 'when there are no reports' do
it 'returns an empty list' do
subject
expect(response.parsed_body).to be_empty
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to be_empty
end
end
@@ -66,7 +63,12 @@ RSpec.describe 'Reports' do
it 'returns all unresolved reports' do
subject
expect(response.parsed_body).to match_array(expected_response)
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to match_array(expected_response)
end
context 'with resolved param' do
+21 -13
View File
@@ -20,19 +20,16 @@ RSpec.describe 'Tags' do
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
it_behaves_like 'forbidden for wrong role', ''
it 'returns http success' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
context 'when there are no tags' do
it 'returns an empty list' do
subject
expect(response.parsed_body).to be_empty
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to be_empty
end
end
@@ -48,6 +45,11 @@ RSpec.describe 'Tags' do
it 'returns the expected tags' do
subject
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
tags.each do |tag|
expect(response.parsed_body.find { |item| item[:id] == tag.id.to_s && item[:name] == tag.name }).to_not be_nil
end
@@ -82,8 +84,11 @@ RSpec.describe 'Tags' do
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:id].to_i).to eq(tag.id)
expect(response.parsed_body[:name]).to eq(tag.name)
expect(response.parsed_body)
.to include(
id: tag.id.to_s,
name: tag.name
)
end
context 'when the requested tag does not exist' do
@@ -116,8 +121,11 @@ RSpec.describe 'Tags' do
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:id].to_i).to eq(tag.id)
expect(response.parsed_body[:name]).to eq(tag.name.upcase)
expect(response.parsed_body)
.to include(
id: tag.id.to_s,
name: tag.name.upcase
)
end
context 'when the updated display name is invalid' do
@@ -41,8 +41,9 @@ RSpec.describe 'Credentials' do
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:client_id]).to_not be_present
expect(response.parsed_body[:client_secret]).to_not be_present
expect(response.parsed_body)
.to not_include(client_id: be_present)
.and not_include(client_secret: be_present)
end
end
+22 -10
View File
@@ -36,7 +36,10 @@ RSpec.describe 'API V2 Admin Accounts' do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(body_json_ids).to eq([admin_account.id])
expect(response.parsed_body)
.to contain_exactly(
hash_including(id: admin_account.id.to_s)
)
end
end
@@ -47,8 +50,11 @@ RSpec.describe 'API V2 Admin Accounts' do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(body_json_ids).to include(remote_account.id)
expect(body_json_ids).to_not include(other_remote_account.id)
expect(response.parsed_body)
.to contain_exactly(
hash_including(id: remote_account.id.to_s)
)
.and not_include(hash_including(id: other_remote_account.id.to_s))
end
end
@@ -59,7 +65,11 @@ RSpec.describe 'API V2 Admin Accounts' do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(body_json_ids).to include(suspended_remote.id, suspended_account.id)
expect(response.parsed_body)
.to contain_exactly(
hash_including(id: suspended_remote.id.to_s),
hash_including(id: suspended_account.id.to_s)
)
end
end
@@ -70,7 +80,10 @@ RSpec.describe 'API V2 Admin Accounts' do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(body_json_ids).to include(disabled_account.id)
expect(response.parsed_body)
.to contain_exactly(
hash_including(id: disabled_account.id.to_s)
)
end
end
@@ -81,14 +94,13 @@ RSpec.describe 'API V2 Admin Accounts' do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(body_json_ids).to include(pending_account.id)
expect(response.parsed_body)
.to contain_exactly(
hash_including(id: pending_account.id.to_s)
)
end
end
def body_json_ids
response.parsed_body.map { |a| a[:id].to_i }
end
context 'with limit param' do
let(:params) { { limit: 1 } }
@@ -0,0 +1,44 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings / Exports' do
let(:user) { Fabricate :user }
before { sign_in user }
describe 'GET /settings/application/:id' do
context 'when user does not own application' do
let(:application) { Fabricate :application }
it 'returns http missing' do
get settings_application_path(application)
expect(response)
.to have_http_status(404)
end
end
end
describe 'POST /settings/applications' do
subject { post '/settings/applications', params: params }
let(:params) do
{
doorkeeper_application: {
name: 'My New App',
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
website: 'http://google.com',
scopes: 'read write follow',
},
}
end
it 'supports passing scope values as string' do
expect { subject }
.to change(Doorkeeper::Application, :count).by(1)
expect(response)
.to redirect_to(settings_applications_path)
end
end
end
+16 -12
View File
@@ -168,10 +168,12 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
it 'returns avatar in response' do
perform_request!
avatar_link = get_avatar_link(response.parsed_body)
expect(avatar_link).to_not be_nil
expect(avatar_link[:type]).to eq alice.avatar.content_type
expect(avatar_link[:href]).to eq Addressable::URI.new(host: Rails.configuration.x.local_domain, path: alice.avatar.to_s, scheme: 'https').to_s
expect(response_avatar_link)
.to be_present
.and include(
type: eq(alice.avatar.content_type),
href: eq(Addressable::URI.new(host: Rails.configuration.x.local_domain, path: alice.avatar.to_s, scheme: 'https').to_s)
)
end
context 'with limited federation mode' do
@@ -182,8 +184,8 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
it 'does not return avatar in response' do
perform_request!
avatar_link = get_avatar_link(response.parsed_body)
expect(avatar_link).to be_nil
expect(response_avatar_link)
.to be_nil
end
end
@@ -197,8 +199,8 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
it 'does not return avatar in response' do
perform_request!
avatar_link = get_avatar_link(response.parsed_body)
expect(avatar_link).to be_nil
expect(response_avatar_link)
.to be_nil
end
end
end
@@ -212,8 +214,8 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
end
it 'does not return avatar in response' do
avatar_link = get_avatar_link(response.parsed_body)
expect(avatar_link).to be_nil
expect(response_avatar_link)
.to be_nil
end
end
@@ -247,7 +249,9 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
private
def get_avatar_link(json)
json[:links].find { |link| link[:rel] == 'http://webfinger.net/rel/avatar' }
def response_avatar_link
response
.parsed_body[:links]
.find { |link| link[:rel] == 'http://webfinger.net/rel/avatar' }
end
end