Merge commit '4fc8c6912979e8fd7882fb360b77e677ffd68565' into glitch-soc/merge-upstream

This commit is contained in:
Claire committed 2025-02-12 18:40:21 +01:00
commit 28d85ede4c
61 files changed
+1158 -896

No files matched your search

@@ -5,6 +5,7 @@ require 'rails_helper'
RSpec.describe 'finding software updates through the admin interface' do
before do
Fabricate(:software_update, version: '99.99.99', type: 'major', urgent: true, release_notes: 'https://github.com/mastodon/mastodon/releases/v99')
Fabricate(:software_update, version: '3.5.0', type: 'major', urgent: true, release_notes: 'https://github.com/mastodon/mastodon/releases/v3.5.0')
sign_in Fabricate(:owner_user), scope: :user
end
@@ -16,6 +17,7 @@ RSpec.describe 'finding software updates through the admin interface' do
expect(page).to have_title(I18n.t('admin.software_updates.title'))
expect(page).to have_content('99.99.99')
.and have_no_content('3.5.0')
click_on I18n.t('admin.software_updates.release_notes')
expect(page).to have_current_path('https://github.com/mastodon/mastodon/releases/v99', url: true)
@@ -0,0 +1,42 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Featured Tags' do
let(:user) { Fabricate(:user) }
before { sign_in(user) }
describe 'Managing tags' do
let(:tag) { Fabricate(:tag) }
let(:status) { Fabricate :status, account: user.account }
before { status.tags << tag }
it 'Views, adds, and removes featured tags' do
visit settings_featured_tags_path
# Link to existing tag used on a status
expect(page.body)
.to include(
settings_featured_tags_path(featured_tag: { name: tag.name })
)
# Invalid entry
fill_in 'featured_tag_name', with: 'test, #foo !bleh'
expect { click_on I18n.t('featured_tags.add_new') }
.to_not change(user.account.featured_tags, :count)
# Valid entry
fill_in 'featured_tag_name', with: '#friends'
expect { click_on I18n.t('featured_tags.add_new') }
.to change(user.account.featured_tags, :count).by(1)
# Delete the created entry
expect { click_on I18n.t('filters.index.delete') }
.to change(user.account.featured_tags, :count).by(-1)
expect(page)
.to have_title(I18n.t('settings.featured_tags'))
end
end
end
@@ -0,0 +1,42 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Migration Redirects' do
let!(:user) { Fabricate(:user, password: 'testtest') }
before { sign_in(user) }
describe 'Managing redirects' do
before { stub_resolver }
it 'creates and destroys redirects' do
visit new_settings_migration_redirect_path
expect(page)
.to have_title(I18n.t('settings.migrate'))
# Empty form invalid submission
expect { click_on I18n.t('migrations.set_redirect') }
.to_not(change { user.account.moved_to_account_id }.from(nil))
# Valid form submission
fill_in 'form_redirect_acct', with: 'new@example.host'
fill_in 'form_redirect_current_password', with: 'testtest'
expect { click_on I18n.t('migrations.set_redirect') }
.to(change { user.reload.account.moved_to_account_id }.from(nil))
# Delete the account move
expect { click_on I18n.t('migrations.cancel') }
.to(change { user.reload.account.moved_to_account_id }.to(nil))
expect(page)
.to have_content(I18n.t('migrations.cancelled_msg'))
end
private
def stub_resolver
resolver = instance_double(ResolveAccountService, call: Fabricate(:account))
allow(ResolveAccountService).to receive(:new).and_return(resolver)
end
end
end
+67
View File
@@ -0,0 +1,67 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Privacy' do
let!(:user) { Fabricate(:user) }
before { sign_in(user) }
describe 'Managing privacy settings' do
before { user.account.update(discoverable: false) }
context 'with a successful update' do
before { allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_async) }
it 'updates user profile information' do
# View settings page
visit settings_privacy_path
expect(page)
.to have_content(I18n.t('privacy.title'))
.and have_private_cache_control
# Fill out form and submit
check 'account_discoverable'
check 'account_indexable'
expect { click_on submit_button }
.to change { user.account.reload.discoverable }.to(true)
expect(page)
.to have_content(I18n.t('privacy.title'))
.and have_content(I18n.t('generic.changes_saved_msg'))
expect(ActivityPub::UpdateDistributionWorker)
.to have_received(:perform_async).with(user.account.id)
end
end
context 'with a failed update' do
before do
allow(UpdateAccountService).to receive(:new).and_return(failing_update_service)
allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_async)
end
it 'updates user profile information' do
# View settings page
visit settings_privacy_path
expect(page)
.to have_content(I18n.t('privacy.title'))
.and have_private_cache_control
# Fill out form and submit
check 'account_discoverable'
check 'account_indexable'
expect { click_on submit_button }
.to_not(change { user.account.reload.discoverable })
expect(page)
.to have_content(I18n.t('privacy.title'))
expect(ActivityPub::UpdateDistributionWorker)
.to_not have_received(:perform_async)
end
private
def failing_update_service
instance_double(UpdateAccountService, call: false)
end
end
end
end