Merge commit '3178acc5cb8415a72b646dbe77be05255d3966f3' into glitch-soc/merge-upstream

This commit is contained in:
Claire committed 2025-01-23 13:38:23 +01:00
commit 19fa4cfcf2
143 files changed
+741 -1289

No files matched your search

+38
View File
@@ -249,6 +249,44 @@ RSpec.describe LinkDetailsExtractor do
expect(subject.author_name).to eq 'Author 1, Author 2'
end
end
context 'with embedded arrays' do
let(:ld_json) do
{
'@context' => 'https://schema.org',
'@type' => 'NewsArticle',
'headline' => 'A lot of authors',
'description' => 'But we decided to cram them into one',
'author' => [[{
'@type' => 'Person',
'name' => ['Author 1'],
}]],
'publisher' => [[{
'@type' => 'NewsMediaOrganization',
'name' => 'Pet News',
'url' => 'https://example.com',
}]],
}.to_json
end
let(:html) { <<~HTML }
<!doctype html>
<html>
<body>
<script type="application/ld+json">
#{ld_json}
</script>
</body>
</html>
HTML
it 'gives correct author_name' do
expect(subject.author_name).to eq 'Author 1'
end
it 'gives provider_name' do
expect(subject.provider_name).to eq 'Pet News'
end
end
end
context 'when Open Graph protocol data is present' do
@@ -107,6 +107,13 @@ RSpec.describe 'API V1 Push Subscriptions' do
it_behaves_like 'validation error'
end
it 'gracefully handles invalid nested params' do
post api_v1_push_subscription_path, params: { subscription: 'invalid' }, headers: headers
expect(response)
.to have_http_status(400)
end
end
describe 'PUT /api/v1/push/subscription' do
@@ -133,6 +140,13 @@ RSpec.describe 'API V1 Push Subscriptions' do
policy: alerts_payload[:data][:policy]
)
end
it 'gracefully handles invalid nested params' do
put api_v1_push_subscription_path(endpoint_push_subscription), params: { data: 'invalid' }, headers: headers
expect(response)
.to have_http_status(400)
end
end
describe 'GET /api/v1/push/subscription' do
@@ -52,4 +52,28 @@ RSpec.describe 'API Web Push Subscriptions' do
end
end
end
describe 'POST /api/web/push_subscriptions' do
before { sign_in Fabricate :user }
it 'gracefully handles invalid nested params' do
post api_web_push_subscriptions_path, params: { subscription: 'invalid' }
expect(response)
.to have_http_status(400)
end
end
describe 'PUT /api/web/push_subscriptions' do
before { sign_in Fabricate :user }
let(:subscription) { Fabricate :web_push_subscription }
it 'gracefully handles invalid nested params' do
put api_web_push_subscription_path(subscription), params: { data: 'invalid' }
expect(response)
.to have_http_status(400)
end
end
end
+18
View File
@@ -0,0 +1,18 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Disputes Appeals' do
describe 'POST /disputes/appeals' do
before { sign_in strike.target_account.user }
let(:strike) { Fabricate :account_warning }
it 'gracefully handles invalid nested params' do
post disputes_strike_appeal_path(strike, appeal: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
+24
View File
@@ -13,4 +13,28 @@ RSpec.describe 'Filters' do
end
end
end
describe 'POST /filters' do
before { sign_in Fabricate :user }
it 'gracefully handles invalid nested params' do
post filters_path(custom_filter: 'invalid')
expect(response)
.to have_http_status(400)
end
end
describe 'PUT /filters/:id' do
before { sign_in(filter.account.user) }
let(:filter) { Fabricate :custom_filter }
it 'gracefully handles invalid nested params' do
put filter_path(filter, custom_filter: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
+9
View File
@@ -28,4 +28,13 @@ RSpec.describe 'Invites' do
end
end
end
describe 'POST /invites' do
it 'gracefully handles invalid nested params' do
post invites_path(invite: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Aliases' do
describe 'POST /settings/aliases' do
before { sign_in Fabricate(:user) }
it 'gracefully handles invalid nested params' do
post settings_aliases_path(account_alias: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Deletes' do
describe 'DELETE /settings/delete' do
before { sign_in Fabricate(:user) }
it 'gracefully handles invalid nested params' do
delete settings_delete_path(form_delete_confirmation: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
@@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Aliases' do
describe 'POST /settings/featured_tags' do
before { sign_in Fabricate(:user) }
it 'gracefully handles invalid nested params' do
post settings_featured_tags_path(featured_tag: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Imports' do
describe 'POST /settings/imports' do
before { sign_in Fabricate(:user) }
it 'gracefully handles invalid nested params' do
post settings_imports_path(form_import: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
@@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Migration Redirects' do
describe 'POST /settings/migration/redirect' do
before { sign_in Fabricate(:user) }
it 'gracefully handles invalid nested params' do
post settings_migration_redirect_path(form_redirect: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
+11
View File
@@ -18,4 +18,15 @@ RSpec.describe 'Settings Migrations' do
it { is_expected.to redirect_to new_user_session_path }
end
end
context 'when user is signed in' do
before { sign_in Fabricate(:user) }
it 'gracefully handles invalid nested params' do
post settings_migration_path(account_migration: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Privacy' do
describe 'PUT /settings/privacy' do
before { sign_in Fabricate(:user) }
it 'gracefully handles invalid nested params' do
put settings_privacy_path(account: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Profiles' do
describe 'PUT /settings/profile' do
before { sign_in Fabricate(:user) }
it 'gracefully handles invalid nested params' do
put settings_profile_path(account: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Statuses Cleanup' do
describe 'PUT /statuses_cleanup' do
before { sign_in Fabricate(:user) }
it 'gracefully handles invalid nested params' do
put statuses_cleanup_path(account_statuses_cleanup_policy: 'invalid')
expect(response)
.to have_http_status(400)
end
end
end
+8 -1
View File
@@ -44,6 +44,8 @@ RSpec.describe 'Filters' do
let(:new_title) { 'Change title value' }
let!(:custom_filter) { Fabricate :custom_filter, account: user.account, title: filter_title }
let!(:keyword_one) { Fabricate :custom_filter_keyword, custom_filter: custom_filter }
let!(:keyword_two) { Fabricate :custom_filter_keyword, custom_filter: custom_filter }
it 'Updates the saved filter' do
navigate_to_filters
@@ -51,7 +53,12 @@ RSpec.describe 'Filters' do
click_on filter_title
fill_in filter_title_field, with: new_title
click_on submit_button
fill_in 'custom_filter_keywords_attributes_0_keyword', with: 'New value'
fill_in 'custom_filter_keywords_attributes_1_keyword', with: 'Wilderness'
expect { click_on submit_button }
.to change { keyword_one.reload.keyword }.to(/New value/)
.and(change { keyword_two.reload.keyword }.to(/Wilderness/))
expect(page).to have_content(new_title)
end
+27 -5
View File
@@ -5,8 +5,6 @@ require 'rails_helper'
RSpec.describe 'Profile' do
include ProfileStories
subject { page }
let(:local_domain) { Rails.configuration.x.local_domain }
before do
@@ -17,7 +15,8 @@ RSpec.describe 'Profile' do
it 'I can view public account page for Alice' do
visit account_path('alice')
expect(subject).to have_title("alice (@alice@#{local_domain})")
expect(page)
.to have_title("alice (@alice@#{local_domain})")
end
it 'I can change my account' do
@@ -26,8 +25,31 @@ RSpec.describe 'Profile' do
fill_in 'Display name', with: 'Bob'
fill_in 'Bio', with: 'Bob is silent'
first('button[type=submit]').click
fill_in 'account_fields_attributes_0_name', with: 'Personal Website'
fill_in 'account_fields_attributes_0_value', with: 'https://host.example/personal'
expect(subject).to have_content 'Changes successfully saved!'
fill_in 'account_fields_attributes_1_name', with: 'Professional Biography'
fill_in 'account_fields_attributes_1_value', with: 'https://host.example/pro'
expect { submit_form }
.to change { bob.account.reload.display_name }.to('Bob')
.and(change_account_fields)
expect(page)
.to have_content 'Changes successfully saved!'
end
def submit_form
first('button[type=submit]').click
end
def change_account_fields
change { bob.account.reload.fields }
.from([])
.to(
contain_exactly(
be_a(Account::Field),
be_a(Account::Field)
)
)
end
end