From 6daa69327b32a46cc36a03b18dede42154ca6ffa Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 11 Jan 2024 04:32:32 -0500 Subject: [PATCH 01/10] Fix `LineLength` haml-lint in `t` usage (#28686) --- .../admin/account_warnings/_account_warning.html.haml | 5 ++++- app/views/admin/action_logs/_action_log.html.haml | 4 +++- app/views/mail_subscriptions/show.html.haml | 6 +++++- app/views/user_mailer/appeal_approved.html.haml | 4 +++- app/views/user_mailer/appeal_rejected.html.haml | 4 +++- app/views/user_mailer/suspicious_sign_in.html.haml | 8 ++++++-- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/views/admin/account_warnings/_account_warning.html.haml b/app/views/admin/account_warnings/_account_warning.html.haml index 85bac789f7..5702e4f6d2 100644 --- a/app/views/admin/account_warnings/_account_warning.html.haml +++ b/app/views/admin/account_warnings/_account_warning.html.haml @@ -5,7 +5,10 @@ = fa_icon 'warning' .log-entry__content .log-entry__title - = t(account_warning.action, scope: 'admin.strikes.actions', name: content_tag(:span, account_warning.account ? account_warning.account.username : I18n.t('admin.action_logs.deleted_account'), class: 'username'), target: content_tag(:span, account_warning.target_account.pretty_acct, class: 'target')).html_safe + = t(account_warning.action, + scope: 'admin.strikes.actions', + name: content_tag(:span, account_warning.account ? account_warning.account.username : I18n.t('admin.action_logs.deleted_account'), class: 'username'), + target: content_tag(:span, account_warning.target_account.pretty_acct, class: 'target')).html_safe .log-entry__timestamp %time.formatted{ datetime: account_warning.created_at.iso8601 } = l(account_warning.created_at) diff --git a/app/views/admin/action_logs/_action_log.html.haml b/app/views/admin/action_logs/_action_log.html.haml index a2fce2d114..dcc3331809 100644 --- a/app/views/admin/action_logs/_action_log.html.haml +++ b/app/views/admin/action_logs/_action_log.html.haml @@ -4,6 +4,8 @@ = image_tag action_log.account.avatar.url(:original), alt: '', width: 40, height: 40, class: 'avatar' .log-entry__content .log-entry__title - = t("admin.action_logs.actions.#{action_log.action}_#{action_log.target_type.underscore}_html", name: content_tag(:span, action_log.account.username, class: 'username'), target: content_tag(:span, log_target(action_log), class: 'target')) + = t "admin.action_logs.actions.#{action_log.action}_#{action_log.target_type.underscore}_html", + name: content_tag(:span, action_log.account.username, class: 'username'), + target: content_tag(:span, log_target(action_log), class: 'target') .log-entry__timestamp %time.formatted{ datetime: action_log.created_at.iso8601 } diff --git a/app/views/mail_subscriptions/show.html.haml b/app/views/mail_subscriptions/show.html.haml index afa2ab6ed7..776d561d70 100644 --- a/app/views/mail_subscriptions/show.html.haml +++ b/app/views/mail_subscriptions/show.html.haml @@ -4,7 +4,11 @@ .simple_form %h1.title= t('mail_subscriptions.unsubscribe.title') %p.lead - = t('mail_subscriptions.unsubscribe.confirmation_html', domain: content_tag(:strong, site_hostname), type: content_tag(:strong, I18n.t(@type, scope: 'mail_subscriptions.unsubscribe.emails')), email: content_tag(:strong, @user.email), settings_path: settings_preferences_notifications_path) + = t 'mail_subscriptions.unsubscribe.confirmation_html', + domain: content_tag(:strong, site_hostname), + type: content_tag(:strong, I18n.t(@type, scope: 'mail_subscriptions.unsubscribe.emails')), + email: content_tag(:strong, @user.email), + settings_path: settings_preferences_notifications_path = form_tag unsubscribe_path, method: :post do = hidden_field_tag :token, params[:token] diff --git a/app/views/user_mailer/appeal_approved.html.haml b/app/views/user_mailer/appeal_approved.html.haml index 3a2de822f4..223ba7f0b8 100644 --- a/app/views/user_mailer/appeal_approved.html.haml +++ b/app/views/user_mailer/appeal_approved.html.haml @@ -36,7 +36,9 @@ %tbody %tr %td.column-cell.text-center - %p= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone.presence), format: :with_time_zone), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone.presence), format: :with_time_zone) + %p= t 'user_mailer.appeal_approved.explanation', + appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone.presence), format: :with_time_zone), + strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone.presence), format: :with_time_zone) %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/user_mailer/appeal_rejected.html.haml b/app/views/user_mailer/appeal_rejected.html.haml index ccbd1c4bad..59354f1d40 100644 --- a/app/views/user_mailer/appeal_rejected.html.haml +++ b/app/views/user_mailer/appeal_rejected.html.haml @@ -36,7 +36,9 @@ %tbody %tr %td.column-cell.text-center - %p= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone.presence), format: :with_time_zone), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone.presence), format: :with_time_zone) + %p= t 'user_mailer.appeal_rejected.explanation', + appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone.presence), format: :with_time_zone), + strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone.presence), format: :with_time_zone) %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/user_mailer/suspicious_sign_in.html.haml b/app/views/user_mailer/suspicious_sign_in.html.haml index 5bafe9d1b2..0cd21b4e60 100644 --- a/app/views/user_mailer/suspicious_sign_in.html.haml +++ b/app/views/user_mailer/suspicious_sign_in.html.haml @@ -45,7 +45,10 @@ = @remote_ip %br/ %strong #{t('sessions.browser')}: - %span{ title: @user_agent }= t 'sessions.description', browser: t("sessions.browsers.#{@detection.id}", default: @detection.id.to_s), platform: t("sessions.platforms.#{@detection.platform.id}", default: @detection.platform.id.to_s) + %span{ title: @user_agent } + = t 'sessions.description', + browser: t("sessions.browsers.#{@detection.id}", default: @detection.id.to_s), + platform: t("sessions.platforms.#{@detection.platform.id}", default: @detection.platform.id.to_s) %br/ = l(@timestamp.in_time_zone(@resource.time_zone.presence), format: :with_time_zone) @@ -64,4 +67,5 @@ %tbody %tr %td.column-cell.text-center - %p= t 'user_mailer.suspicious_sign_in.further_actions_html', action: link_to(t('user_mailer.suspicious_sign_in.change_password'), edit_user_registration_url) + %p= t 'user_mailer.suspicious_sign_in.further_actions_html', + action: link_to(t('user_mailer.suspicious_sign_in.change_password'), edit_user_registration_url) From 204bbf49d20ff34ad6559aa0166db68340b72d29 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 11:08:49 +0100 Subject: [PATCH 02/10] New Crowdin Translations (automated) (#28692) Co-authored-by: GitHub Actions --- app/javascript/mastodon/locales/br.json | 22 +++++++++++++++++++--- app/javascript/mastodon/locales/pl.json | 4 ++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/javascript/mastodon/locales/br.json b/app/javascript/mastodon/locales/br.json index 462a5b3393..ad6e55c5e1 100644 --- a/app/javascript/mastodon/locales/br.json +++ b/app/javascript/mastodon/locales/br.json @@ -1,5 +1,5 @@ { - "about.blocks": "Servijerioù habaskaet", + "about.blocks": "Servijerioù evezhiet", "about.contact": "Darempred :", "about.disclaimer": "Mastodon zo ur meziant frank, open-source hag ur merk marilhet eus Mastodon gGmbH.", "about.domain_blocks.no_reason_available": "Abeg dihegerz", @@ -22,6 +22,7 @@ "account.browse_more_on_origin_server": "Furchal pelloc'h war ar profil orin", "account.cancel_follow_request": "Nullañ ar reked heuliañ", "account.copy": "Eilañ al liamm war-zu ho profil", + "account.direct": "Menegiñ @{name} ent-prevez", "account.disable_notifications": "Paouez d'am c'hemenn pa vez embannet traoù gant @{name}", "account.domain_blocked": "Domani stanket", "account.edit_profile": "Kemmañ ar profil", @@ -68,6 +69,7 @@ "account.unendorse": "Paouez da lakaat war-wel war ar profil", "account.unfollow": "Diheuliañ", "account.unmute": "Diguzhat @{name}", + "account.unmute_notifications_short": "Diguzhat ar c'hemennoù", "account.unmute_short": "Diguzhat", "account_note.placeholder": "Klikit evit ouzhpennañ un notenn", "admin.dashboard.daily_retention": "Feur azdalc'h an implijerien·ezed dre zeiz goude bezañ lakaet o anv", @@ -75,6 +77,9 @@ "admin.dashboard.retention.average": "Keidenn", "admin.dashboard.retention.cohort": "Miz an enrolladur", "admin.dashboard.retention.cohort_size": "Implijerien.erezed nevez", + "admin.impact_report.instance_accounts": "Profiloù kontoù a vefe dilamet", + "admin.impact_report.instance_followers": "Heulierien a gollfe hon implijerien", + "admin.impact_report.instance_follows": "Heulierien a gollfe o implijerien", "alert.rate_limited.message": "Klaskit en-dro a-benn {retry_time, time, medium}.", "alert.rate_limited.title": "Feur bevennet", "alert.unexpected.message": "Ur fazi dic'hortozet zo degouezhet.", @@ -105,6 +110,7 @@ "column.blocks": "Implijer·ezed·ien berzet", "column.bookmarks": "Sinedoù", "column.community": "Red-amzer lec'hel", + "column.direct": "Menegoù prevez", "column.directory": "Mont a-dreuz ar profiloù", "column.domain_blocks": "Domani berzet", "column.favourites": "Muiañ-karet", @@ -348,6 +354,7 @@ "lightbox.next": "Da-heul", "lightbox.previous": "A-raok", "limited_account_hint.action": "Diskouez an aelad memes tra", + "limited_account_hint.title": "Kuzhet eo bet ar profil-mañ gant an evezhierien eus {domain}.", "link_preview.author": "Gant {name}", "lists.account.add": "Ouzhpennañ d'al listenn", "lists.account.remove": "Lemel kuit eus al listenn", @@ -373,6 +380,7 @@ "navigation_bar.bookmarks": "Sinedoù", "navigation_bar.community_timeline": "Red-amzer lec'hel", "navigation_bar.compose": "Skrivañ un toud nevez", + "navigation_bar.direct": "Menegoù prevez", "navigation_bar.discover": "Dizoleiñ", "navigation_bar.domain_blocks": "Domanioù kuzhet", "navigation_bar.edit_profile": "Kemmañ ar profil", @@ -452,6 +460,7 @@ "onboarding.profile.note_hint": "Gallout a rit @menegiñ tud all pe #hashtagoù…", "onboarding.profile.save_and_continue": "Enrollañ ha kenderc'hel", "onboarding.profile.upload_avatar": "Enporzhiañ ur skeudenn profil", + "onboarding.share.lead": "Roit da c'houzout d'an dud e c'hallont ho kavout war vMastondon!", "onboarding.share.message": "Me a zo {username} war #Mastodon! Heuilhit ac'hanon war {url}", "onboarding.share.title": "Skignañ ho profil", "onboarding.start.lead": "Your new Mastodon account is ready to go. Here's how you can make the most of it:", @@ -465,6 +474,7 @@ "onboarding.steps.setup_profile.title": "Customize your profile", "onboarding.steps.share_profile.body": "Let your friends know how to find you on Mastodon!", "onboarding.steps.share_profile.title": "Share your profile", + "password_confirmation.mismatching": "Disheñvel eo an daou c'her-termen-se", "picture_in_picture.restore": "Adlakaat", "poll.closed": "Serret", "poll.refresh": "Azbevaat", @@ -545,6 +555,7 @@ "report_notification.categories.spam": "Spam", "report_notification.categories.violation": "Torradur da reolennoù ar servijer", "report_notification.open": "Digeriñ an disklêriadur", + "search.no_recent_searches": "Klask nevez ebet", "search.placeholder": "Klask", "search.quick_action.account_search": "Profiloù a glot gant {x}", "search.quick_action.go_to_account": "Mont d'ar profil {x}", @@ -572,8 +583,10 @@ "server_banner.server_stats": "Stadegoù ar servijer :", "sign_in_banner.create_account": "Krouiñ ur gont", "sign_in_banner.sign_in": "Kevreañ", - "status.admin_account": "Digeriñ etrefas evezherezh evit @{name}", - "status.admin_status": "Digeriñ an toud e-barzh an etrefas evezherezh", + "sign_in_banner.sso_redirect": "Kennaskañ pe lakaat hoc'h anv", + "status.admin_account": "Digeriñ etrefas evezhiañ evit @{name}", + "status.admin_domain": "Digeriñ an etrefas evezhiañ evit {domain}", + "status.admin_status": "Digeriñ an embannadenn e-barzh an etrefas evezhiañ", "status.block": "Berzañ @{name}", "status.bookmark": "Ouzhpennañ d'ar sinedoù", "status.cancel_reblog_private": "Nac'hañ ar skignadenn", @@ -581,6 +594,8 @@ "status.copy": "Eilañ liamm ar c'hannad", "status.delete": "Dilemel", "status.detailed_status": "Gwel kaozeadenn munudek", + "status.direct": "Menegiñ @{name} ent-prevez", + "status.direct_indicator": "Meneg prevez", "status.edit": "Kemmañ", "status.edited": "Aozet {date}", "status.edited_x_times": "Edited {count, plural, one {# time} other {# times}}", @@ -624,6 +639,7 @@ "status.title.with_attachments": "{user} posted {attachmentCount, plural, one {an attachment} other {# attachments}}", "status.translate": "Treiñ", "status.translated_from_with": "Troet diwar {lang} gant {provider}", + "status.uncached_media_warning": "Rakwel n'eo ket da gaout", "status.unmute_conversation": "Diguzhat ar gaozeadenn", "status.unpin": "Dispilhennañ eus ar profil", "subscribed_languages.save": "Enrollañ ar cheñchamantoù", diff --git a/app/javascript/mastodon/locales/pl.json b/app/javascript/mastodon/locales/pl.json index 9a3710da71..35dbc6661d 100644 --- a/app/javascript/mastodon/locales/pl.json +++ b/app/javascript/mastodon/locales/pl.json @@ -42,7 +42,7 @@ "account.go_to_profile": "Przejdź do profilu", "account.hide_reblogs": "Ukryj podbicia od @{name}", "account.in_memoriam": "Ku pamięci.", - "account.joined_short": "Dołączony", + "account.joined_short": "Dołączył(a)", "account.languages": "Zmień subskrybowane języki", "account.link_verified_on": "Własność tego odnośnika została potwierdzona {date}", "account.locked_info": "To konto jest prywatne. Właściciel ręcznie wybiera kto może go obserwować.", @@ -492,7 +492,7 @@ "onboarding.profile.save_and_continue": "Zapisz i kontynuuj", "onboarding.profile.title": "Ustawienia profilu", "onboarding.profile.upload_avatar": "Dodaj zdjęcie profilowe", - "onboarding.profile.upload_header": "Dodaj zdjęcie nagłówkowe", + "onboarding.profile.upload_header": "Dodaj banner profilu", "onboarding.share.lead": "Daj znać ludziom, jak mogą cię znaleźć na Mastodonie!", "onboarding.share.message": "Jestem {username} na #Mastodon! Śledź mnie tutaj {url}", "onboarding.share.next_steps": "Możliwe dalsze kroki:", From 55802242ce65dcea36b74fffcb3474e8254192f7 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 11 Jan 2024 05:36:27 -0500 Subject: [PATCH 03/10] Refactor login activity partial (remove inline ruby) (#28687) --- app/helpers/admin/settings_helper.rb | 56 +++++++++++++++++++ .../_login_activity.html.haml | 10 +--- .../login_activities_controller_spec.rb | 5 ++ 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/app/helpers/admin/settings_helper.rb b/app/helpers/admin/settings_helper.rb index 552a3ee5a8..6937331e1a 100644 --- a/app/helpers/admin/settings_helper.rb +++ b/app/helpers/admin/settings_helper.rb @@ -4,4 +4,60 @@ module Admin::SettingsHelper def captcha_available? ENV['HCAPTCHA_SECRET_KEY'].present? && ENV['HCAPTCHA_SITE_KEY'].present? end + + def login_activity_title(activity) + t( + "login_activities.#{login_activity_key(activity)}", + method: login_activity_method(activity), + ip: login_activity_ip(activity), + browser: login_activity_browser(activity) + ) + end + + private + + def login_activity_key(activity) + activity.success? ? 'successful_sign_in_html' : 'failed_sign_in_html' + end + + def login_activity_method(activity) + content_tag( + :span, + login_activity_method_string(activity), + class: 'target' + ) + end + + def login_activity_ip(activity) + content_tag( + :span, + activity.ip, + class: 'target' + ) + end + + def login_activity_browser(activity) + content_tag( + :span, + login_activity_browser_description(activity), + class: 'target', + title: activity.user_agent + ) + end + + def login_activity_method_string(activity) + if activity.omniauth? + t("auth.providers.#{activity.provider}") + else + t("login_activities.authentication_methods.#{activity.authentication_method}") + end + end + + def login_activity_browser_description(activity) + t( + 'sessions.description', + browser: t(activity.browser, scope: 'sessions.browsers', default: activity.browser.to_s), + platform: t(activity.platform, scope: 'sessions.platforms', default: activity.platform.to_s) + ) + end end diff --git a/app/views/settings/login_activities/_login_activity.html.haml b/app/views/settings/login_activities/_login_activity.html.haml index 2e001cdcef..36314926a3 100644 --- a/app/views/settings/login_activities/_login_activity.html.haml +++ b/app/views/settings/login_activities/_login_activity.html.haml @@ -1,8 +1,3 @@ -:ruby - method_str = content_tag(:span, login_activity.omniauth? ? t(login_activity.provider, scope: 'auth.providers') : t(login_activity.authentication_method, scope: 'login_activities.authentication_methods'), class: 'target') - ip_str = content_tag(:span, login_activity.ip, class: 'target') - browser_str = content_tag(:span, t('sessions.description', browser: t("sessions.browsers.#{login_activity.browser}", default: login_activity.browser.to_s), platform: t("sessions.platforms.#{login_activity.platform}", default: login_activity.platform.to_s)), class: 'target', title: login_activity.user_agent) - .log-entry .log-entry__header .log-entry__avatar @@ -10,9 +5,6 @@ = fa_icon login_activity.success? ? 'check' : 'times' .log-entry__content .log-entry__title - - if login_activity.success? - = t('login_activities.successful_sign_in_html', method: method_str, ip: ip_str, browser: browser_str) - - else - = t('login_activities.failed_sign_in_html', method: method_str, ip: ip_str, browser: browser_str) + = login_activity_title(login_activity) .log-entry__timestamp %time.formatted{ datetime: login_activity.created_at.iso8601 }= l(login_activity.created_at) diff --git a/spec/controllers/settings/login_activities_controller_spec.rb b/spec/controllers/settings/login_activities_controller_spec.rb index 4f266e03dd..294bf85c97 100644 --- a/spec/controllers/settings/login_activities_controller_spec.rb +++ b/spec/controllers/settings/login_activities_controller_spec.rb @@ -6,6 +6,7 @@ describe Settings::LoginActivitiesController do render_views let!(:user) { Fabricate(:user) } + let!(:login_activity) { Fabricate :login_activity, user: user } before do sign_in user, scope: :user @@ -19,6 +20,10 @@ describe Settings::LoginActivitiesController do it 'returns http success with private cache control headers', :aggregate_failures do expect(response).to have_http_status(200) expect(response.headers['Cache-Control']).to include('private, no-store') + expect(response.body) + .to include(login_activity.user_agent) + .and include(login_activity.authentication_method) + .and include(login_activity.ip.to_s) end end end From 87097a227c2ab24f27b0d87ec6808c07cb13d93a Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 11 Jan 2024 05:45:26 -0500 Subject: [PATCH 04/10] Clean up `settings/featured_tags/index` view (#28688) --- app/helpers/settings_helper.rb | 27 +++++++++++++++++++ .../settings/featured_tags/index.html.haml | 2 +- .../settings/featured_tags_controller_spec.rb | 10 +++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index 3c72b22c66..10863a316c 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -9,6 +9,19 @@ module SettingsHelper LanguagesHelper.sorted_locale_keys(I18n.available_locales) end + def featured_tags_hint(recently_used_tags) + safe_join( + [ + t('simple_form.hints.featured_tag.name'), + safe_join( + links_for_featured_tags(recently_used_tags), + ', ' + ), + ], + ' ' + ) + end + def session_device_icon(session) device = session.detection.device @@ -28,4 +41,18 @@ module SettingsHelper safe_join([image_tag(account.avatar.url, width: 15, height: 15, alt: '', class: 'avatar'), content_tag(:span, account.acct, class: 'username')], ' ') end end + + private + + def links_for_featured_tags(tags) + tags.map { |tag| post_link_to_featured_tag(tag) } + end + + def post_link_to_featured_tag(tag) + link_to( + "##{tag.display_name}", + settings_featured_tags_path(featured_tag: { name: tag.name }), + method: :post + ) + end end diff --git a/app/views/settings/featured_tags/index.html.haml b/app/views/settings/featured_tags/index.html.haml index 22f9180129..c8c9ec4069 100644 --- a/app/views/settings/featured_tags/index.html.haml +++ b/app/views/settings/featured_tags/index.html.haml @@ -12,7 +12,7 @@ .fields-group = f.input :name, - hint: safe_join([t('simple_form.hints.featured_tag.name'), safe_join(@recently_used_tags.map { |tag| link_to("##{tag.display_name}", settings_featured_tags_path(featured_tag: { name: tag.name }), method: :post) }, ', ')], ' '), + hint: featured_tags_hint(@recently_used_tags), wrapper: :with_block_label .actions diff --git a/spec/controllers/settings/featured_tags_controller_spec.rb b/spec/controllers/settings/featured_tags_controller_spec.rb index fc25e7aa88..4e1dd52945 100644 --- a/spec/controllers/settings/featured_tags_controller_spec.rb +++ b/spec/controllers/settings/featured_tags_controller_spec.rb @@ -43,10 +43,20 @@ describe Settings::FeaturedTagsController do end describe 'GET to #index' do + let(:tag) { Fabricate(:tag) } + + before do + status = Fabricate :status, account: user.account + status.tags << tag + end + it 'responds with success' do get :index expect(response).to have_http_status(200) + expect(response.body).to include( + settings_featured_tags_path(featured_tag: { name: tag.name }) + ) end end From 4e08a4892f01188255e803b87f641ef019bdb883 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 11 Jan 2024 05:54:42 -0500 Subject: [PATCH 05/10] Move streaming `around` config into manager class (#28684) --- spec/rails_helper.rb | 15 --------------- spec/support/streaming_server_manager.rb | 13 +++++++++++++ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index aabb121fc3..aaf587f49b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -107,21 +107,6 @@ RSpec.configure do |config| Capybara.current_driver = :rack_test end - config.around :each, type: :system do |example| - # The streaming server needs access to the database - # but with use_transactional_tests every transaction - # is rolled-back, so the streaming server never sees the data - # So we disable this feature for system tests, and use DatabaseCleaner to clean - # the database tables between each test - self.use_transactional_tests = false - - DatabaseCleaner.cleaning do - example.run - end - - self.use_transactional_tests = true - end - config.before do |example| allow(Resolv::DNS).to receive(:open).and_raise('Real DNS queries are disabled, stub Resolv::DNS as needed') unless example.metadata[:type] == :system end diff --git a/spec/support/streaming_server_manager.rb b/spec/support/streaming_server_manager.rb index 2c535767e2..39657586f2 100644 --- a/spec/support/streaming_server_manager.rb +++ b/spec/support/streaming_server_manager.rb @@ -95,6 +95,19 @@ RSpec.configure do |config| end end + config.around :each, type: :system do |example| + # Streaming server needs DB access but `use_transactional_tests` rolls back + # every transaction. Disable this feature for streaming tests, and use + # DatabaseCleaner to clean the database tables between each test. + self.use_transactional_tests = false + + DatabaseCleaner.cleaning do + example.run + end + + self.use_transactional_tests = true + end + private def streaming_server_manager From 3f3df9ab201c588a9a849a78f5cdccb9f16b5fac Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 11 Jan 2024 05:57:52 -0500 Subject: [PATCH 06/10] Update omniauth-cas to version 3.0.0 (#28683) --- Gemfile | 5 ++--- Gemfile.lock | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index e096a5d685..a393b14471 100644 --- a/Gemfile +++ b/Gemfile @@ -39,9 +39,8 @@ end gem 'net-ldap', '~> 0.18' -# TODO: Point back at released omniauth-cas gem when PR merged -# https://github.com/dlindahl/omniauth-cas/pull/68 -gem 'omniauth-cas', github: 'stanhu/omniauth-cas', ref: '4211e6d05941b4a981f9a36b49ec166cecd0e271' +# TODO: Point back at released omniauth-cas gem when new version is released +gem 'omniauth-cas', github: 'dlindahl/omniauth-cas', ref: '9d9d3a91b316c55d49ab6e621977f2067010c5bf' gem 'omniauth-saml', '~> 2.0' gem 'omniauth_openid_connect', '~> 0.6.1' gem 'omniauth', '~> 2.0' diff --git a/Gemfile.lock b/Gemfile.lock index 595c9fd279..ccb9f4b115 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,6 +7,16 @@ GIT hkdf (~> 0.2) jwt (~> 2.0) +GIT + remote: https://github.com/dlindahl/omniauth-cas.git + revision: 9d9d3a91b316c55d49ab6e621977f2067010c5bf + ref: 9d9d3a91b316c55d49ab6e621977f2067010c5bf + specs: + omniauth-cas (3.0.0) + addressable (~> 2.8) + nokogiri (~> 1.12) + omniauth (~> 2.1) + GIT remote: https://github.com/jhawthorn/nsa.git revision: e020fcc3a54d993ab45b7194d89ab720296c111b @@ -18,16 +28,6 @@ GIT sidekiq (>= 3.5) statsd-ruby (~> 1.4, >= 1.4.0) -GIT - remote: https://github.com/stanhu/omniauth-cas.git - revision: 4211e6d05941b4a981f9a36b49ec166cecd0e271 - ref: 4211e6d05941b4a981f9a36b49ec166cecd0e271 - specs: - omniauth-cas (2.0.0) - addressable (~> 2.3) - nokogiri (~> 1.5) - omniauth (>= 1.2, < 3) - GEM remote: https://rubygems.org/ specs: From 782a0165c700933840ba2297f8b67147979b8631 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 13:48:01 +0100 Subject: [PATCH 07/10] Update dependency node to 20.11 (#28670) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nvmrc b/.nvmrc index d4c3d320cc..a3597ecbd1 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20.10 +20.11 From b68f185573158dedabe4b78bdf86a0cfaa5abb96 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 11 Jan 2024 08:14:24 -0500 Subject: [PATCH 08/10] Reduce `LineLength` for `react_component` helper in views/admin (#28694) --- .../admin/reports/_media_attachments.html.haml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/views/admin/reports/_media_attachments.html.haml b/app/views/admin/reports/_media_attachments.html.haml index 8ecd7444d2..3c52d69178 100644 --- a/app/views/admin/reports/_media_attachments.html.haml +++ b/app/views/admin/reports/_media_attachments.html.haml @@ -2,6 +2,16 @@ = render_video_component(status, visible: false) - elsif status.ordered_media_attachments.first.audio? - audio = status.ordered_media_attachments.first - = react_component :audio, src: audio.file.url(:original), height: 110, alt: audio.description, lang: status.language, duration: audio.file.meta.dig(:original, :duration) + = react_component :audio, + alt: audio.description, + duration: audio.file.meta.dig(:original, :duration), + height: 110, + lang: status.language, + src: audio.file.url(:original) - else - = react_component :media_gallery, height: 343, sensitive: status.sensitive?, visible: false, lang: status.language, media: status.ordered_media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json } + = react_component :media_gallery, + height: 343, + lang: status.language, + media: status.ordered_media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json }, + sensitive: status.sensitive?, + visible: false From 95bd46d32afaaccc78762f7fc9c6428c4880cbc0 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 11 Jan 2024 10:11:57 -0500 Subject: [PATCH 09/10] Remove double subject call in `api/v1/admin/ip_blocks` spec (#28696) --- spec/requests/api/v1/admin/ip_blocks_spec.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/requests/api/v1/admin/ip_blocks_spec.rb b/spec/requests/api/v1/admin/ip_blocks_spec.rb index fbcb39e3be..98b954dd49 100644 --- a/spec/requests/api/v1/admin/ip_blocks_spec.rb +++ b/spec/requests/api/v1/admin/ip_blocks_spec.rb @@ -177,7 +177,9 @@ RSpec.describe 'IP Blocks' do let(:params) { { severity: 'sign_up_requires_approval', comment: 'Decreasing severity' } } it 'returns the correct ip block', :aggregate_failures do - subject + expect { subject } + .to change_severity_level + .and change_comment_value expect(response).to have_http_status(200) expect(body_as_json).to match(hash_including({ @@ -187,12 +189,12 @@ RSpec.describe 'IP Blocks' do })) end - it 'updates the severity correctly' do - expect { subject }.to change { ip_block.reload.severity }.from('no_access').to('sign_up_requires_approval') + def change_severity_level + change { ip_block.reload.severity }.from('no_access').to('sign_up_requires_approval') end - it 'updates the comment correctly' do - expect { subject }.to change { ip_block.reload.comment }.from('Spam').to('Decreasing severity') + def change_comment_value + change { ip_block.reload.comment }.from('Spam').to('Decreasing severity') end context 'when ip block does not exist' do From 2954279e9c630a9d146575bf600978dc6c5279bd Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 11 Jan 2024 10:13:11 -0500 Subject: [PATCH 10/10] Remove double subject call in `api/v1/admin/trends/links/links` spec (#28695) --- .../api/v1/admin/trends/links/links_spec.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/spec/requests/api/v1/admin/trends/links/links_spec.rb b/spec/requests/api/v1/admin/trends/links/links_spec.rb index 05020b0fd0..48842828b3 100644 --- a/spec/requests/api/v1/admin/trends/links/links_spec.rb +++ b/spec/requests/api/v1/admin/trends/links/links_spec.rb @@ -32,18 +32,18 @@ describe 'Links' do it_behaves_like 'forbidden for wrong role', '' it 'returns http success' do - subject + expect { subject } + .to change_link_trendable_to_true expect(response).to have_http_status(200) + expects_correct_link_data end - it 'sets the link as trendable' do - expect { subject }.to change { preview_card.reload.trendable }.from(false).to(true) + def change_link_trendable_to_true + change { preview_card.reload.trendable }.from(false).to(true) end - it 'returns the link data' do - subject - + def expects_correct_link_data expect(body_as_json).to match( a_hash_including( url: preview_card.url, @@ -85,13 +85,14 @@ describe 'Links' do it_behaves_like 'forbidden for wrong role', '' it 'returns http success' do - subject + expect { subject } + .to_not change_link_trendable expect(response).to have_http_status(200) end - it 'does not set the link as trendable' do - expect { subject }.to_not(change { preview_card.reload.trendable }) + def change_link_trendable + change { preview_card.reload.trendable } end it 'returns the link data' do