mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 00:38:27 +00:00
Merge commit 'b43eaa4517107326c7e73b949cec759f841b4a30' into glitch-soc/merge-upstream
Conflicts: - `spec/controllers/api/v1/accounts/credentials_controller_spec.rb` Conflict due to glitch-soc's different note length handling. Ported the changes in `spec/requests/api/v1/accounts/credentials_spec.rb` instead.
This commit is contained in:
@@ -15,15 +15,11 @@ RSpec.describe 'credentials API' do
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write write:accounts'
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns the expected content' do
|
||||
it 'returns http success with expected content' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(body_as_json).to include({
|
||||
source: hash_including({
|
||||
discoverable: false,
|
||||
@@ -34,24 +30,55 @@ RSpec.describe 'credentials API' do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /api/v1/accounts/update_credentials' do
|
||||
describe 'PATCH /api/v1/accounts/update_credentials' do
|
||||
subject do
|
||||
patch '/api/v1/accounts/update_credentials', headers: headers, params: params
|
||||
end
|
||||
|
||||
let(:params) { { discoverable: true, locked: false, indexable: true } }
|
||||
before { allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_async) }
|
||||
|
||||
let(:params) do
|
||||
{
|
||||
avatar: fixture_file_upload('avatar.gif', 'image/gif'),
|
||||
discoverable: true,
|
||||
display_name: "Alice Isn't Dead",
|
||||
header: fixture_file_upload('attachment.jpg', 'image/jpeg'),
|
||||
indexable: true,
|
||||
locked: false,
|
||||
note: 'Hello!',
|
||||
source: {
|
||||
privacy: 'unlisted',
|
||||
sensitive: true,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'read read:accounts'
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
describe 'with empty source list' do
|
||||
let(:params) { { display_name: "I'm a cat", source: {} } }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
it 'returns http success' do
|
||||
subject
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns JSON with updated attributes' do
|
||||
describe 'with invalid data' do
|
||||
let(:params) { { note: "This is too long. #{'a' * Account::MAX_NOTE_LENGTH}" } }
|
||||
|
||||
it 'returns http unprocessable entity' do
|
||||
subject
|
||||
expect(response).to have_http_status(422)
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns http success with updated JSON attributes' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
||||
expect(body_as_json).to include({
|
||||
source: hash_including({
|
||||
discoverable: true,
|
||||
@@ -59,6 +86,27 @@ RSpec.describe 'credentials API' do
|
||||
}),
|
||||
locked: false,
|
||||
})
|
||||
|
||||
expect(ActivityPub::UpdateDistributionWorker)
|
||||
.to have_received(:perform_async).with(user.account_id)
|
||||
end
|
||||
|
||||
def expect_account_updates
|
||||
expect(user.account.reload)
|
||||
.to have_attributes(
|
||||
display_name: eq("Alice Isn't Dead"),
|
||||
note: 'Hello!',
|
||||
avatar: exist,
|
||||
header: exist
|
||||
)
|
||||
end
|
||||
|
||||
def expect_user_updates
|
||||
expect(user.reload)
|
||||
.to have_attributes(
|
||||
setting_default_privacy: eq('unlisted'),
|
||||
setting_default_sensitive: be(true)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user