Merge commit '877090518682b6c77ba9bdfa0231afd56daec44d' into glitch-soc/merge-upstream

Conflicts:
- `app/models/concerns/user/has_settings.rb`:
  Not a real conflict, upstream added a setting textually close to a glitch-soc one.
  Added upstream's new setting.
- `app/views/settings/preferences/appearance/show.html.haml`:
  Not a real conflict, upstream added a setting textually close to a glitch-soc one.
  Added upstream's new setting.
- `config/routes.rb`:
  Upstream moved web app routes to `config/routes/web_app.rb`, while glitch-soc had
  an extra route.
  Moved the extra route to `config/routes/web_app.rb`.
- `spec/controllers/settings/preferences/appearance_controller_spec.rb`:
  This spec got converted to a system spec upstream.
  However, the theme setting works differently in glitch-soc, so the spec had been
  changed.
  Changed the corresponding system spec as well.
This commit is contained in:
Claire committed 2024-12-25 18:01:37 +01:00
commit 0aa69487a2
759 files changed
+13447 -7221

No files matched your search

@@ -0,0 +1,34 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Login activities page' do
let!(:user) { Fabricate :user }
let!(:login_activity) { Fabricate :login_activity, user: user }
context 'when signed in' do
before { sign_in user }
describe 'Viewing the login activities page' do
it 'shows the login activity history' do
visit edit_user_registration_path
click_on I18n.t('sessions.view_authentication_history')
expect(page)
.to have_content(browser_description)
.and have_content(login_activity.authentication_method)
.and have_content(login_activity.ip)
.and have_private_cache_control
end
def browser_description
I18n.t(
'sessions.description',
browser: I18n.t("sessions.browsers.#{login_activity.browser}", default: login_activity.browser),
platform: I18n.t("sessions.platforms.#{login_activity.platform}", default: login_activity.platform)
)
end
end
end
end
@@ -0,0 +1,43 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings preferences appearance page' do
let(:user) { Fabricate :user }
before { sign_in user }
it 'Views and updates user prefs' do
visit settings_preferences_appearance_path
expect(page)
.to have_private_cache_control
# TODO: glitch-soc's option is elsewhere
# select 'contrast', from: theme_selection_field
check confirm_reblog_field
uncheck confirm_delete_field
expect { save_changes }
.to change { user.reload.settings['web.reblog_modal'] }.to(true)
.and(change { user.reload.settings['web.delete_modal'] }.to(false))
expect(page)
.to have_title(I18n.t('settings.appearance'))
end
def save_changes
within('form') { click_on submit_button }
end
def confirm_delete_field
I18n.t('simple_form.labels.defaults.setting_delete_modal')
end
def confirm_reblog_field
I18n.t('simple_form.labels.defaults.setting_boost_modal')
end
def theme_selection_field
I18n.t('simple_form.labels.defaults.setting_theme')
end
end
@@ -0,0 +1,27 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings preferences notifications page' do
let(:user) { Fabricate :user }
before { sign_in user }
it 'Views and updates user prefs' do
visit settings_preferences_notifications_path
expect(page)
.to have_private_cache_control
uncheck notifications_follow_field
expect { click_on submit_button }
.to change { user.reload.settings['notification_emails.follow'] }.to(false)
expect(page)
.to have_title(I18n.t('settings.notifications'))
end
def notifications_follow_field
I18n.t('simple_form.labels.notification_emails.follow')
end
end
@@ -0,0 +1,38 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings preferences other page' do
let(:user) { Fabricate :user }
before { sign_in user }
it 'Views and updates user prefs' do
visit settings_preferences_other_path
expect(page)
.to have_private_cache_control
check language_field(:es)
check language_field(:fr)
check mark_sensitive_field
expect { save_changes }
.to change { user.reload.chosen_languages }.to(%w(es fr))
.and(change { user.reload.settings.default_sensitive }.to(true))
expect(page)
.to have_title(I18n.t('settings.preferences'))
end
def save_changes
within('form') { click_on submit_button }
end
def mark_sensitive_field
I18n.t('simple_form.labels.defaults.setting_default_sensitive')
end
def language_field(key)
LanguagesHelper::SUPPORTED_LOCALES[key].last
end
end
+37
View File
@@ -0,0 +1,37 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings profile page' do
let(:user) { Fabricate :user }
let(:account) { user.account }
before do
allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_async)
sign_in user
end
it 'Views and updates profile information' do
visit settings_profile_path
expect(page)
.to have_private_cache_control
fill_in display_name_field, with: 'New name'
attach_file avatar_field, Rails.root.join('spec', 'fixtures', 'files', 'avatar.gif')
expect { click_on submit_button }
.to change { account.reload.display_name }.to('New name')
.and(change { account.reload.avatar.instance.avatar_file_name }.from(nil).to(be_present))
expect(ActivityPub::UpdateDistributionWorker)
.to have_received(:perform_async).with(account.id)
end
def display_name_field
I18n.t('simple_form.labels.defaults.display_name')
end
def avatar_field
I18n.t('simple_form.labels.defaults.avatar')
end
end
@@ -0,0 +1,34 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings verification page' do
let(:user) { Fabricate :user }
before { sign_in user }
describe 'Viewing the verification page' do
it 'shows the page and updates attribution' do
visit settings_verification_path
expect(page)
.to have_content(verification_summary)
.and have_private_cache_control
fill_in attribution_field, with: 'host.example'
expect { click_on submit_button }
.to(change { user.account.reload.attribution_domains_as_text })
expect(page)
.to have_content(success_message)
end
end
def verification_summary
I18n.t('verification.website_verification')
end
def attribution_field
I18n.t('simple_form.labels.account.attribution_domains_as_text')
end
end