Merge commit '04492e7f934d07f8e89fa9c3d4fe3381f251e8a2' into glitch-soc/merge-upstream
This commit is contained in:
commit
4bea9a0a66
83 files changed
+1520
-846
No files matched your search
@@ -1,33 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Settings::SessionsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:session_activation) { Fabricate(:session_activation, user: user) }
|
||||
|
||||
before { sign_in user, scope: :user }
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
subject { delete :destroy, params: { id: id } }
|
||||
|
||||
context 'when session activation exists' do
|
||||
let(:id) { session_activation.id }
|
||||
|
||||
it 'destroys session activation' do
|
||||
expect(subject).to redirect_to edit_user_registration_path
|
||||
expect(SessionActivation.find_by(id: id)).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when session activation does not exist' do
|
||||
let(:id) { session_activation.id + 1000 }
|
||||
|
||||
it 'destroys session activation' do
|
||||
expect(subject).to have_http_status 404
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -317,4 +317,16 @@ RSpec.describe UserMailer do
|
||||
.and(have_body_text(I18n.t('user_mailer.terms_of_service_changed.changelog')))
|
||||
end
|
||||
end
|
||||
|
||||
describe '#announcement_published' do
|
||||
let(:announcement) { Fabricate :announcement }
|
||||
let(:mail) { described_class.announcement_published(receiver, announcement) }
|
||||
|
||||
it 'renders announcement_published mail' do
|
||||
expect(mail)
|
||||
.to be_present
|
||||
.and(have_subject(I18n.t('user_mailer.announcement_published.subject')))
|
||||
.and(have_body_text(I18n.t('user_mailer.announcement_published.description', domain: Rails.configuration.x.local_domain)))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Settings Sessions' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'DELETE /settings/sessions/:id' do
|
||||
context 'when session activation does not exist' do
|
||||
it 'returns not found' do
|
||||
delete settings_session_path(123_456_789)
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,10 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SystemHelpers
|
||||
def admin_user
|
||||
Fabricate(:admin_user)
|
||||
end
|
||||
|
||||
def submit_button
|
||||
I18n.t('generic.save_changes')
|
||||
end
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Announcement Mail Distributions' do
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
let(:announcement) { Fabricate(:announcement, notification_sent_at: nil) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'Sending an announcement notification', :inline_jobs do
|
||||
it 'marks the announcement as notified and sends the email' do
|
||||
visit admin_announcement_preview_path(announcement)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.announcements.preview.title'))
|
||||
|
||||
emails = capture_emails do
|
||||
expect { click_on I18n.t('admin.terms_of_service.preview.send_to_all', count: 1, display_count: 1) }
|
||||
.to(change { announcement.reload.notification_sent_at })
|
||||
end
|
||||
expect(emails.first)
|
||||
.to be_present
|
||||
.and(deliver_to(user.email))
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.announcements.title'))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Announcements Mail Previews' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
let(:announcement) { Fabricate(:announcement, notification_sent_at: nil) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
describe 'Viewing Announcements Mail previews' do
|
||||
it 'shows the Announcement Mail preview page' do
|
||||
visit admin_announcement_preview_path(announcement)
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.announcements.preview.title'))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin TermsOfService Tests' do
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
let(:announcement) { Fabricate(:announcement, notification_sent_at: nil) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'Sending test Announcement email', :inline_jobs do
|
||||
it 'generates the test email' do
|
||||
visit admin_announcement_preview_path(announcement)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.announcements.preview.title'))
|
||||
|
||||
emails = capture_emails { click_on I18n.t('admin.terms_of_service.preview.send_preview', email: user.email) }
|
||||
expect(emails.first)
|
||||
.to be_present
|
||||
.and(deliver_to(user.email))
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.announcements.title'))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -117,7 +117,7 @@ RSpec.describe 'Admin::Announcements' do
|
||||
end
|
||||
|
||||
def text_label
|
||||
I18n.t('simple_form.labels.announcement.text')
|
||||
form_label('announcement.text')
|
||||
end
|
||||
|
||||
def admin_user
|
||||
|
||||
@@ -57,7 +57,7 @@ RSpec.describe 'Admin Invites' do
|
||||
end
|
||||
|
||||
def max_use_field
|
||||
I18n.t('simple_form.labels.defaults.max_uses')
|
||||
form_label('defaults.max_uses')
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3,6 +3,8 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Relationships' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
describe 'Viewing account relationships page' do
|
||||
|
||||
@@ -65,7 +65,7 @@ RSpec.describe 'Admin Rules' do
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('generic.save_changes')
|
||||
click_on(submit_button)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::About' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to about settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_about_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.about.title'))
|
||||
|
||||
fill_in extended_description_field,
|
||||
with: 'new site description'
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::Appearance' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to appearance settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_appearance_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.appearance.title'))
|
||||
|
||||
fill_in custom_css_field,
|
||||
with: 'html { display: inline; }'
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::Branding' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to branding settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_branding_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.branding.title'))
|
||||
|
||||
fill_in short_description_field,
|
||||
with: 'new key value'
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::ContentRetention' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to content retention settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_content_retention_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.content_retention.title'))
|
||||
|
||||
fill_in media_cache_retention_period_field,
|
||||
with: '2'
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::Discovery' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to discovery settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_discovery_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.discovery.title'))
|
||||
|
||||
check trends_box
|
||||
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::Registrations' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to registrations settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_registrations_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.registrations.title'))
|
||||
|
||||
select open_mode_option,
|
||||
from: registrations_mode_field
|
||||
|
||||
@@ -28,7 +28,7 @@ RSpec.describe 'Admin Tags' do
|
||||
end
|
||||
|
||||
def display_name_field
|
||||
I18n.t('simple_form.labels.defaults.display_name')
|
||||
form_label('defaults.display_name')
|
||||
end
|
||||
|
||||
def match_error_text
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin TermsOfService Drafts' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
describe 'Managing TOS drafts' do
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin TermsOfService Generates' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
describe 'Generating a TOS policy' do
|
||||
@@ -27,6 +29,8 @@ RSpec.describe 'Admin TermsOfService Generates' do
|
||||
fill_in 'terms_of_service_generator_domain', with: 'host.example'
|
||||
fill_in 'terms_of_service_generator_jurisdiction', with: 'Europe'
|
||||
fill_in 'terms_of_service_generator_choice_of_law', with: 'New York'
|
||||
fill_in 'terms_of_service_generator_min_age', with: '16'
|
||||
|
||||
expect { submit_form }
|
||||
.to change(TermsOfService, :count).by(1)
|
||||
expect(page)
|
||||
|
||||
@@ -4,6 +4,7 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin TermsOfService Previews' do
|
||||
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ RSpec.describe 'Admin Warning Presets' do
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('generic.save_changes')
|
||||
click_on(submit_button)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ RSpec.describe 'Admin Webhooks' do
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('generic.save_changes')
|
||||
click_on(submit_button)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -108,6 +108,6 @@ RSpec.describe 'Filters' do
|
||||
end
|
||||
|
||||
def filter_title_field
|
||||
I18n.t('simple_form.labels.defaults.title')
|
||||
form_label('defaults.title')
|
||||
end
|
||||
end
|
||||
@@ -71,9 +71,9 @@ RSpec.describe 'Invites' do
|
||||
|
||||
def fill_invite_form
|
||||
select I18n.t('invites.max_uses', count: 100),
|
||||
from: I18n.t('simple_form.labels.defaults.max_uses')
|
||||
from: form_label('defaults.max_uses')
|
||||
select I18n.t("invites.expires_in.#{30.minutes.to_i}"),
|
||||
from: I18n.t('simple_form.labels.defaults.expires_in')
|
||||
check I18n.t('simple_form.labels.defaults.autofollow')
|
||||
from: form_label('defaults.expires_in')
|
||||
check form_label('defaults.autofollow')
|
||||
end
|
||||
end
|
||||
@@ -96,7 +96,7 @@ RSpec.describe 'Settings applications page' do
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('generic.save_changes')
|
||||
click_on(submit_button)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -33,18 +33,18 @@ RSpec.describe 'Settings preferences appearance page' do
|
||||
end
|
||||
|
||||
def confirm_delete_field
|
||||
I18n.t('simple_form.labels.defaults.setting_delete_modal')
|
||||
form_label('defaults.setting_delete_modal')
|
||||
end
|
||||
|
||||
def confirm_reblog_field
|
||||
I18n.t('simple_form.labels.defaults.setting_boost_modal')
|
||||
form_label('defaults.setting_boost_modal')
|
||||
end
|
||||
|
||||
def theme_selection_field
|
||||
I18n.t('simple_form.labels.defaults.setting_theme')
|
||||
form_label('defaults.setting_theme')
|
||||
end
|
||||
|
||||
def advanced_layout_field
|
||||
I18n.t('simple_form.labels.defaults.setting_advanced_layout')
|
||||
form_label('defaults.setting_advanced_layout')
|
||||
end
|
||||
end
|
||||
@@ -22,6 +22,6 @@ RSpec.describe 'Settings preferences notifications page' do
|
||||
end
|
||||
|
||||
def notifications_follow_field
|
||||
I18n.t('simple_form.labels.notification_emails.follow')
|
||||
form_label('notification_emails.follow')
|
||||
end
|
||||
end
|
||||
@@ -29,7 +29,7 @@ RSpec.describe 'Settings preferences other page' do
|
||||
end
|
||||
|
||||
def mark_sensitive_field
|
||||
I18n.t('simple_form.labels.defaults.setting_default_sensitive')
|
||||
form_label('defaults.setting_default_sensitive')
|
||||
end
|
||||
|
||||
def language_field(key)
|
||||
|
||||
@@ -27,7 +27,7 @@ RSpec.describe 'Settings Privacy' do
|
||||
.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'))
|
||||
.and have_content(success_message)
|
||||
expect(ActivityPub::UpdateDistributionWorker)
|
||||
.to have_received(:perform_async).with(user.account.id)
|
||||
end
|
||||
|
||||
@@ -28,10 +28,10 @@ RSpec.describe 'Settings profile page' do
|
||||
end
|
||||
|
||||
def display_name_field
|
||||
I18n.t('simple_form.labels.defaults.display_name')
|
||||
form_label('defaults.display_name')
|
||||
end
|
||||
|
||||
def avatar_field
|
||||
I18n.t('simple_form.labels.defaults.avatar')
|
||||
form_label('defaults.avatar')
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Settings Sessions' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let!(:session_activation) { Fabricate(:session_activation, user: user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'deleting a session' do
|
||||
it 'deletes listed session activation from the auth page' do
|
||||
visit edit_user_registration_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('settings.account_settings'))
|
||||
|
||||
expect { click_on(I18n.t('sessions.revoke')) }
|
||||
.to change(SessionActivation, :count).by(-1)
|
||||
expect { session_activation.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('sessions.revoke_success'))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -44,6 +44,6 @@ RSpec.describe 'Settings verification page' do
|
||||
end
|
||||
|
||||
def attribution_field
|
||||
I18n.t('simple_form.labels.account.attribution_domains')
|
||||
form_label('account.attribution_domains')
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::DistributeAnnouncementNotificationWorker do
|
||||
let(:worker) { described_class.new }
|
||||
|
||||
describe '#perform' do
|
||||
context 'with missing record' do
|
||||
it 'runs without error' do
|
||||
expect { worker.perform(nil) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context 'with valid announcement' do
|
||||
let(:announcement) { Fabricate(:announcement) }
|
||||
let!(:user) { Fabricate :user, confirmed_at: 3.days.ago }
|
||||
|
||||
it 'sends the announcement via email', :inline_jobs do
|
||||
emails = capture_emails { worker.perform(announcement.id) }
|
||||
|
||||
expect(emails.size)
|
||||
.to eq(1)
|
||||
expect(emails.first)
|
||||
.to have_attributes(
|
||||
to: [user.email],
|
||||
subject: I18n.t('user_mailer.announcement_published.subject')
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user