diff --git a/.browserslistrc b/.browserslistrc index 0376af4bcc..6367e4d358 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1,6 +1,7 @@ [production] defaults > 0.2% +firefox >= 78 ios >= 15.6 not dead not OperaMini all diff --git a/.github/codecov.yml b/.github/codecov.yml index 701ba3af8f..d9b43b2594 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -1,3 +1,4 @@ +annotations: false comment: false # Do not leave PR comments coverage: status: diff --git a/Gemfile.lock b/Gemfile.lock index c70823d051..a988ad3f21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,35 +10,35 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) + actioncable (7.1.4) + actionpack (= 7.1.4) + activesupport (= 7.1.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + actionmailbox (7.1.4) + actionpack (= 7.1.4) + activejob (= 7.1.4) + activerecord (= 7.1.4) + activestorage (= 7.1.4) + activesupport (= 7.1.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.3.4) - actionpack (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activesupport (= 7.1.3.4) + actionmailer (7.1.4) + actionpack (= 7.1.4) + actionview (= 7.1.4) + activejob (= 7.1.4) + activesupport (= 7.1.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.3.4) - actionview (= 7.1.3.4) - activesupport (= 7.1.3.4) + actionpack (7.1.4) + actionview (= 7.1.4) + activesupport (= 7.1.4) nokogiri (>= 1.8.5) racc rack (>= 2.2.4) @@ -46,15 +46,15 @@ GEM rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.4) - actionpack (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + actiontext (7.1.4) + actionpack (= 7.1.4) + activerecord (= 7.1.4) + activestorage (= 7.1.4) + activesupport (= 7.1.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3.4) - activesupport (= 7.1.3.4) + actionview (7.1.4) + activesupport (= 7.1.4) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) @@ -64,22 +64,22 @@ GEM activemodel (>= 4.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (7.1.3.4) - activesupport (= 7.1.3.4) + activejob (7.1.4) + activesupport (= 7.1.4) globalid (>= 0.3.6) - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activerecord (7.1.3.4) - activemodel (= 7.1.3.4) - activesupport (= 7.1.3.4) + activemodel (7.1.4) + activesupport (= 7.1.4) + activerecord (7.1.4) + activemodel (= 7.1.4) + activesupport (= 7.1.4) timeout (>= 0.4.0) - activestorage (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activesupport (= 7.1.3.4) + activestorage (7.1.4) + actionpack (= 7.1.4) + activejob (= 7.1.4) + activerecord (= 7.1.4) + activesupport (= 7.1.4) marcel (~> 1.0) - activesupport (7.1.3.4) + activesupport (7.1.4) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -638,20 +638,20 @@ GEM rackup (1.0.0) rack (< 3) webrick - rails (7.1.3.4) - actioncable (= 7.1.3.4) - actionmailbox (= 7.1.3.4) - actionmailer (= 7.1.3.4) - actionpack (= 7.1.3.4) - actiontext (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activemodel (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + rails (7.1.4) + actioncable (= 7.1.4) + actionmailbox (= 7.1.4) + actionmailer (= 7.1.4) + actionpack (= 7.1.4) + actiontext (= 7.1.4) + actionview (= 7.1.4) + activejob (= 7.1.4) + activemodel (= 7.1.4) + activerecord (= 7.1.4) + activestorage (= 7.1.4) + activesupport (= 7.1.4) bundler (>= 1.15.0) - railties (= 7.1.3.4) + railties (= 7.1.4) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -666,9 +666,9 @@ GEM rails-i18n (7.0.9) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) + railties (7.1.4) + actionpack (= 7.1.4) + activesupport (= 7.1.4) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -857,7 +857,7 @@ GEM unf (~> 0.1.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - tzinfo-data (1.2024.1) + tzinfo-data (1.2024.2) tzinfo (>= 1.0.0) unf (0.1.4) unf_ext diff --git a/app/controllers/admin/account_moderation_notes_controller.rb b/app/controllers/admin/account_moderation_notes_controller.rb index 8b6c1a4454..a3c4adf59a 100644 --- a/app/controllers/admin/account_moderation_notes_controller.rb +++ b/app/controllers/admin/account_moderation_notes_controller.rb @@ -13,7 +13,7 @@ module Admin redirect_to admin_account_path(@account_moderation_note.target_account_id), notice: I18n.t('admin.account_moderation_notes.created_msg') else @account = @account_moderation_note.target_account - @moderation_notes = @account.targeted_moderation_notes.latest + @moderation_notes = @account.targeted_moderation_notes.chronological.includes(:account) @warnings = @account.strikes.custom.latest render 'admin/accounts/show' diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb index 9beb8fde6b..7b169ba26a 100644 --- a/app/controllers/admin/accounts_controller.rb +++ b/app/controllers/admin/accounts_controller.rb @@ -33,7 +33,7 @@ module Admin @deletion_request = @account.deletion_request @account_moderation_note = current_account.account_moderation_notes.new(target_account: @account) - @moderation_notes = @account.targeted_moderation_notes.latest + @moderation_notes = @account.targeted_moderation_notes.chronological.includes(:account) @warnings = @account.strikes.includes(:target_account, :account, :appeal).latest @domain_block = DomainBlock.rule_for(@account.domain) end diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 4b5afbe157..48685db17a 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -7,17 +7,12 @@ module Admin layout 'admin' - before_action :set_body_classes before_action :set_cache_headers after_action :verify_authorized private - def set_body_classes - @body_classes = 'admin' - end - def set_cache_headers response.cache_control.replace(private: true, no_store: true) end diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 3a6df662ea..5b0867dcfb 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -7,12 +7,12 @@ module Admin def index authorize :dashboard, :index? + @pending_appeals_count = Appeal.pending.async_count + @pending_reports_count = Report.unresolved.async_count + @pending_tags_count = Tag.pending_review.async_count + @pending_users_count = User.pending.async_count @system_checks = Admin::SystemCheck.perform(current_user) @time_period = (29.days.ago.to_date...Time.now.utc.to_date) - @pending_users_count = User.pending.count - @pending_reports_count = Report.unresolved.count - @pending_tags_count = Tag.pending_review.count - @pending_appeals_count = Appeal.pending.count end end end diff --git a/app/controllers/admin/report_notes_controller.rb b/app/controllers/admin/report_notes_controller.rb index b5f04a1caa..6b16c29fc7 100644 --- a/app/controllers/admin/report_notes_controller.rb +++ b/app/controllers/admin/report_notes_controller.rb @@ -21,7 +21,7 @@ module Admin redirect_to after_create_redirect_path, notice: I18n.t('admin.report_notes.created_msg') else - @report_notes = @report.notes.includes(:account).order(id: :desc) + @report_notes = @report.notes.chronological.includes(:account) @action_logs = @report.history.includes(:target) @form = Admin::StatusBatchAction.new @statuses = @report.statuses.with_includes diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb index 00d200d7c8..aa877f1448 100644 --- a/app/controllers/admin/reports_controller.rb +++ b/app/controllers/admin/reports_controller.rb @@ -13,7 +13,7 @@ module Admin authorize @report, :show? @report_note = @report.notes.new - @report_notes = @report.notes.includes(:account).order(id: :desc) + @report_notes = @report.notes.chronological.includes(:account) @action_logs = @report.history.includes(:target) @form = Admin::StatusBatchAction.new @statuses = @report.statuses.with_includes diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index c12960934e..4d94c80158 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -11,7 +11,6 @@ class Auth::RegistrationsController < Devise::RegistrationsController before_action :configure_sign_up_params, only: [:create] before_action :set_sessions, only: [:edit, :update] before_action :set_strikes, only: [:edit, :update] - before_action :set_body_classes, only: [:new, :create, :edit, :update] before_action :require_not_suspended!, only: [:update] before_action :set_cache_headers, only: [:edit, :update] before_action :set_rules, only: :new @@ -104,10 +103,6 @@ class Auth::RegistrationsController < Devise::RegistrationsController private - def set_body_classes - @body_classes = 'admin' if %w(edit update).include?(action_name) - end - def set_invite @invite = begin invite = Invite.find_by(code: invite_code) if invite_code.present? diff --git a/app/controllers/concerns/account_controller_concern.rb b/app/controllers/concerns/account_controller_concern.rb index d63bcc85c9..b75f3e3581 100644 --- a/app/controllers/concerns/account_controller_concern.rb +++ b/app/controllers/concerns/account_controller_concern.rb @@ -20,7 +20,7 @@ module AccountControllerConcern webfinger_account_link, actor_url_link, ] - ) + ).to_s end def webfinger_account_link diff --git a/app/controllers/concerns/api/pagination.rb b/app/controllers/concerns/api/pagination.rb index 7f06dc0202..b0b4ae4603 100644 --- a/app/controllers/concerns/api/pagination.rb +++ b/app/controllers/concerns/api/pagination.rb @@ -19,7 +19,7 @@ module Api::Pagination links = [] links << [next_path, [%w(rel next)]] if next_path links << [prev_path, [%w(rel prev)]] if prev_path - response.headers['Link'] = LinkHeader.new(links) unless links.empty? + response.headers['Link'] = LinkHeader.new(links).to_s unless links.empty? end def require_valid_pagination_options! diff --git a/app/controllers/disputes/base_controller.rb b/app/controllers/disputes/base_controller.rb index 1054f3db80..dd24a1b740 100644 --- a/app/controllers/disputes/base_controller.rb +++ b/app/controllers/disputes/base_controller.rb @@ -7,16 +7,11 @@ class Disputes::BaseController < ApplicationController skip_before_action :require_functional! - before_action :set_body_classes before_action :authenticate_user! before_action :set_cache_headers private - def set_body_classes - @body_classes = 'admin' - end - def set_cache_headers response.cache_control.replace(private: true, no_store: true) end diff --git a/app/controllers/filters/statuses_controller.rb b/app/controllers/filters/statuses_controller.rb index 94993f938b..7ada13f680 100644 --- a/app/controllers/filters/statuses_controller.rb +++ b/app/controllers/filters/statuses_controller.rb @@ -6,7 +6,6 @@ class Filters::StatusesController < ApplicationController before_action :authenticate_user! before_action :set_filter before_action :set_status_filters - before_action :set_body_classes before_action :set_cache_headers PER_PAGE = 20 @@ -42,10 +41,6 @@ class Filters::StatusesController < ApplicationController 'remove' if params[:remove] end - def set_body_classes - @body_classes = 'admin' - end - def set_cache_headers response.cache_control.replace(private: true, no_store: true) end diff --git a/app/controllers/filters_controller.rb b/app/controllers/filters_controller.rb index bd9964426b..8c4e867e93 100644 --- a/app/controllers/filters_controller.rb +++ b/app/controllers/filters_controller.rb @@ -5,7 +5,6 @@ class FiltersController < ApplicationController before_action :authenticate_user! before_action :set_filter, only: [:edit, :update, :destroy] - before_action :set_body_classes before_action :set_cache_headers def index @@ -52,10 +51,6 @@ class FiltersController < ApplicationController params.require(:custom_filter).permit(:title, :expires_in, :filter_action, context: [], keywords_attributes: [:id, :keyword, :whole_word, :_destroy]) end - def set_body_classes - @body_classes = 'admin' - end - def set_cache_headers response.cache_control.replace(private: true, no_store: true) end diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 9bc5164d59..070852695e 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -6,7 +6,6 @@ class InvitesController < ApplicationController layout 'admin' before_action :authenticate_user! - before_action :set_body_classes before_action :set_cache_headers def index @@ -47,10 +46,6 @@ class InvitesController < ApplicationController params.require(:invite).permit(:max_uses, :expires_in, :autofollow, :comment) end - def set_body_classes - @body_classes = 'admin' - end - def set_cache_headers response.cache_control.replace(private: true, no_store: true) end diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb index 53eee40012..9d10468e69 100644 --- a/app/controllers/media_controller.rb +++ b/app/controllers/media_controller.rb @@ -19,9 +19,7 @@ class MediaController < ApplicationController redirect_to @media_attachment.file.url(:original) end - def player - @body_classes = 'player' - end + def player; end private diff --git a/app/controllers/oauth/authorized_applications_controller.rb b/app/controllers/oauth/authorized_applications_controller.rb index 7bb22453ca..267409a9ce 100644 --- a/app/controllers/oauth/authorized_applications_controller.rb +++ b/app/controllers/oauth/authorized_applications_controller.rb @@ -6,7 +6,6 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio before_action :store_current_location before_action :authenticate_resource_owner! before_action :require_not_suspended!, only: :destroy - before_action :set_body_classes before_action :set_cache_headers before_action :set_last_used_at_by_app, only: :index, unless: -> { request.format == :json } @@ -23,10 +22,6 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio private - def set_body_classes - @body_classes = 'admin' - end - def store_current_location store_location_for(:user, request.url) end diff --git a/app/controllers/relationships_controller.rb b/app/controllers/relationships_controller.rb index dd794f3199..d351afcfb7 100644 --- a/app/controllers/relationships_controller.rb +++ b/app/controllers/relationships_controller.rb @@ -6,7 +6,6 @@ class RelationshipsController < ApplicationController before_action :authenticate_user! before_action :set_accounts, only: :show before_action :set_relationships, only: :show - before_action :set_body_classes before_action :set_cache_headers helper_method :following_relationship?, :followed_by_relationship?, :mutual_relationship? @@ -68,10 +67,6 @@ class RelationshipsController < ApplicationController end end - def set_body_classes - @body_classes = 'admin' - end - def set_cache_headers response.cache_control.replace(private: true, no_store: true) end diff --git a/app/controllers/settings/base_controller.rb b/app/controllers/settings/base_controller.rb index f15140aa2b..188334ac23 100644 --- a/app/controllers/settings/base_controller.rb +++ b/app/controllers/settings/base_controller.rb @@ -4,15 +4,10 @@ class Settings::BaseController < ApplicationController layout 'admin' before_action :authenticate_user! - before_action :set_body_classes before_action :set_cache_headers private - def set_body_classes - @body_classes = 'admin' - end - def set_cache_headers response.cache_control.replace(private: true, no_store: true) end diff --git a/app/controllers/severed_relationships_controller.rb b/app/controllers/severed_relationships_controller.rb index 168e85e3fe..965753a26f 100644 --- a/app/controllers/severed_relationships_controller.rb +++ b/app/controllers/severed_relationships_controller.rb @@ -4,7 +4,6 @@ class SeveredRelationshipsController < ApplicationController layout 'admin' before_action :authenticate_user! - before_action :set_body_classes before_action :set_cache_headers before_action :set_event, only: [:following, :followers] @@ -51,10 +50,6 @@ class SeveredRelationshipsController < ApplicationController account.local? ? account.local_username_and_domain : account.acct end - def set_body_classes - @body_classes = 'admin' - end - def set_cache_headers response.cache_control.replace(private: true, no_store: true) end diff --git a/app/controllers/shares_controller.rb b/app/controllers/shares_controller.rb index 6546b84978..1aa0ce5a0d 100644 --- a/app/controllers/shares_controller.rb +++ b/app/controllers/shares_controller.rb @@ -4,13 +4,6 @@ class SharesController < ApplicationController layout 'modal' before_action :authenticate_user! - before_action :set_body_classes def show; end - - private - - def set_body_classes - @body_classes = 'modal-layout compose-standalone' - end end diff --git a/app/controllers/statuses_cleanup_controller.rb b/app/controllers/statuses_cleanup_controller.rb index 4a3fc10ca4..e517bf3ae8 100644 --- a/app/controllers/statuses_cleanup_controller.rb +++ b/app/controllers/statuses_cleanup_controller.rb @@ -5,7 +5,6 @@ class StatusesCleanupController < ApplicationController before_action :authenticate_user! before_action :set_policy - before_action :set_body_classes before_action :set_cache_headers def show; end @@ -34,10 +33,6 @@ class StatusesCleanupController < ApplicationController params.require(:account_statuses_cleanup_policy).permit(:enabled, :min_status_age, :keep_direct, :keep_pinned, :keep_polls, :keep_media, :keep_self_fav, :keep_self_bookmark, :min_favs, :min_reblogs) end - def set_body_classes - @body_classes = 'admin' - end - def set_cache_headers response.cache_control.replace(private: true, no_store: true) end diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb index db7eddd78b..a0885b469b 100644 --- a/app/controllers/statuses_controller.rb +++ b/app/controllers/statuses_controller.rb @@ -56,7 +56,9 @@ class StatusesController < ApplicationController end def set_link_headers - response.headers['Link'] = LinkHeader.new([[ActivityPub::TagManager.instance.uri_for(@status), [%w(rel alternate), %w(type application/activity+json)]]]) + response.headers['Link'] = LinkHeader.new( + [[ActivityPub::TagManager.instance.uri_for(@status), [%w(rel alternate), %w(type application/activity+json)]]] + ).to_s end def set_status diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 26f69b9d12..a7ae4d6a04 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -159,6 +159,7 @@ module ApplicationHelper def body_classes output = body_class_string.split + output << content_for(:body_classes) output << "flavour-#{current_flavour.parameterize}" output << "skin-#{current_skin.parameterize}" output << 'system-font' if current_account&.user&.setting_system_font_ui diff --git a/app/javascript/mastodon/locales/fi.json b/app/javascript/mastodon/locales/fi.json index 39df3e010f..79ca95a58c 100644 --- a/app/javascript/mastodon/locales/fi.json +++ b/app/javascript/mastodon/locales/fi.json @@ -1,6 +1,6 @@ { "about.blocks": "Moderoidut palvelimet", - "about.contact": "Yhteydenotto:", + "about.contact": "Yhteystiedot:", "about.disclaimer": "Mastodon on vapaa avoimen lähdekoodin ohjelmisto ja Mastodon gGmbH:n tavaramerkki.", "about.domain_blocks.no_reason_available": "Syy ei ole tiedossa", "about.domain_blocks.preamble": "Mastodonin avulla voi yleensä tarkastella minkä tahansa fediversumiin kuuluvan palvelimen sisältöä ja olla yhteyksissä eri palvelinten käyttäjien kanssa. Nämä poikkeukset koskevat yksin tätä palvelinta.", @@ -304,7 +304,7 @@ "filter_modal.select_filter.title": "Suodata tämä julkaisu", "filter_modal.title.status": "Suodata julkaisu", "filter_warning.matches_filter": "Vastaa suodatinta ”{title}”", - "filtered_notifications_banner.pending_requests": "{count, plural, =0 {Ei keneltäkään, jonka} one {1 käyttäjältä, jonka} other {# käyttäjältä, jotka}} saatat tuntea", + "filtered_notifications_banner.pending_requests": "{count, plural, =0 {Ei keneltäkään, jonka} one {Yhdeltä käyttäjältä, jonka} other {# käyttäjältä, jotka}} saatat tuntea", "filtered_notifications_banner.title": "Suodatetut ilmoitukset", "firehose.all": "Kaikki", "firehose.local": "Tämä palvelin", @@ -370,7 +370,7 @@ "home.show_announcements": "Näytä tiedotteet", "ignore_notifications_modal.disclaimer": "Mastodon ei voi ilmoittaa käyttäjille, että olet sivuuttanut heidän ilmoituksensa. Ilmoitusten sivuuttaminen ei lopeta itse viestien lähetystä.", "ignore_notifications_modal.filter_instead": "Suodata sen sijaan", - "ignore_notifications_modal.filter_to_act_users": "Voit silti hyväksyä, hylätä tai raportoida käyttäjiä", + "ignore_notifications_modal.filter_to_act_users": "Voit kuitenkin yhä hyväksyä, hylätä tai raportoida käyttäjiä", "ignore_notifications_modal.filter_to_avoid_confusion": "Suodatus auttaa välttämään mahdollisia sekaannuksia", "ignore_notifications_modal.filter_to_review_separately": "Voit käydä suodatettuja ilmoituksia läpi erikseen", "ignore_notifications_modal.ignore": "Sivuuta ilmoitukset", diff --git a/app/javascript/mastodon/locales/ga.json b/app/javascript/mastodon/locales/ga.json index 71577be955..b51d4adf68 100644 --- a/app/javascript/mastodon/locales/ga.json +++ b/app/javascript/mastodon/locales/ga.json @@ -97,6 +97,8 @@ "block_modal.title": "An bhfuil fonn ort an t-úsáideoir a bhlocáil?", "block_modal.you_wont_see_mentions": "Ní fheicfidh tú postálacha a luann iad.", "boost_modal.combo": "Is féidir leat {combo} a bhrú chun é seo a scipeáil an chéad uair eile", + "boost_modal.reblog": "An post a threisiú?", + "boost_modal.undo_reblog": "An deireadh a chur le postáil?", "bundle_column_error.copy_stacktrace": "Cóipeáil tuairisc earráide", "bundle_column_error.error.body": "Ní féidir an leathanach a iarradh a sholáthar. Seans gurb amhlaidh mar gheall ar fhabht sa chód, nó mar gheall ar mhíréireacht leis an mbrabhsálaí.", "bundle_column_error.error.title": "Ó, níl sé sin go maith!", @@ -467,6 +469,7 @@ "mute_modal.you_wont_see_mentions": "Ní fheicfidh tú postálacha a luann iad.", "mute_modal.you_wont_see_posts": "Is féidir leo do phoist a fheiceáil go fóill, ach ní fheicfidh tú a gcuid postanna.", "navigation_bar.about": "Maidir le", + "navigation_bar.administration": "Riarachán", "navigation_bar.advanced_interface": "Oscail i gcomhéadan gréasáin chun cinn", "navigation_bar.blocks": "Cuntais bhactha", "navigation_bar.bookmarks": "Leabharmharcanna", @@ -483,6 +486,7 @@ "navigation_bar.follows_and_followers": "Ag leanúint agus do do leanúint", "navigation_bar.lists": "Liostaí", "navigation_bar.logout": "Logáil Amach", + "navigation_bar.moderation": "Measarthacht", "navigation_bar.mutes": "Úsáideoirí balbhaithe", "navigation_bar.opened_in_classic_interface": "Osclaítear poist, cuntais agus leathanaigh shonracha eile de réir réamhshocraithe sa chomhéadan gréasáin clasaiceach.", "navigation_bar.personal": "Pearsanta", diff --git a/app/javascript/mastodon/locales/ru.json b/app/javascript/mastodon/locales/ru.json index cd64e8b8e5..4439b8dc0a 100644 --- a/app/javascript/mastodon/locales/ru.json +++ b/app/javascript/mastodon/locales/ru.json @@ -48,7 +48,7 @@ "account.moved_to": "У {name} теперь новый аккаунт:", "account.mute": "Игнорировать @{name}", "account.mute_notifications_short": "Отключить уведомления", - "account.mute_short": "Немой", + "account.mute_short": "Глохни!", "account.muted": "Игнорируется", "account.mutual": "Взаимно", "account.no_bio": "Описание не предоставлено.", diff --git a/app/models/account.rb b/app/models/account.rb index 33c16d773f..e7a4ef937e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -75,6 +75,8 @@ class Account < ApplicationRecord DISPLAY_NAME_LENGTH_LIMIT = (ENV['MAX_DISPLAY_NAME_CHARS'] || 30).to_i NOTE_LENGTH_LIMIT = (ENV['MAX_BIO_CHARS'] || 500).to_i + AUTOMATED_ACTOR_TYPES = %w(Application Service).freeze + include Attachmentable # Load prior to Avatar & Header concerns include Account::Associations @@ -127,7 +129,8 @@ class Account < ApplicationRecord scope :without_silenced, -> { where(silenced_at: nil) } scope :without_instance_actor, -> { where.not(id: INSTANCE_ACTOR_ID) } scope :recent, -> { reorder(id: :desc) } - scope :bots, -> { where(actor_type: %w(Application Service)) } + scope :bots, -> { where(actor_type: AUTOMATED_ACTOR_TYPES) } + scope :non_automated, -> { where.not(actor_type: AUTOMATED_ACTOR_TYPES) } scope :groups, -> { where(actor_type: 'Group') } scope :alphabetic, -> { order(domain: :asc, username: :asc) } scope :matches_uri_prefix, ->(value) { where(arel_table[:uri].matches("#{sanitize_sql_like(value)}/%", false, true)).or(where(uri: value)) } @@ -183,7 +186,7 @@ class Account < ApplicationRecord end def bot? - %w(Application Service).include? actor_type + AUTOMATED_ACTOR_TYPES.include?(actor_type) end def instance_actor? diff --git a/app/models/account_moderation_note.rb b/app/models/account_moderation_note.rb index 79b8b4d25e..ca7f8e3d5f 100644 --- a/app/models/account_moderation_note.rb +++ b/app/models/account_moderation_note.rb @@ -18,7 +18,7 @@ class AccountModerationNote < ApplicationRecord belongs_to :account belongs_to :target_account, class_name: 'Account' - scope :latest, -> { reorder('created_at DESC') } + scope :chronological, -> { reorder(id: :asc) } validates :content, presence: true, length: { maximum: CONTENT_SIZE_LIMIT } end diff --git a/app/models/admin/account_action.rb b/app/models/admin/account_action.rb index 3700ce4cd6..4be58ba853 100644 --- a/app/models/admin/account_action.rb +++ b/app/models/admin/account_action.rb @@ -73,6 +73,14 @@ class Admin::AccountAction end end + def disabled_types_for_account(account) + if account.suspended? + %w(silence suspend) + elsif account.silenced? + %w(silence) + end + end + def i18n_scope :activerecord end diff --git a/app/models/report_note.rb b/app/models/report_note.rb index 7361c97e67..9d3be52594 100644 --- a/app/models/report_note.rb +++ b/app/models/report_note.rb @@ -18,7 +18,7 @@ class ReportNote < ApplicationRecord belongs_to :account belongs_to :report, inverse_of: :notes, touch: true - scope :latest, -> { reorder(created_at: :desc) } + scope :chronological, -> { reorder(id: :asc) } validates :content, presence: true, length: { maximum: CONTENT_SIZE_LIMIT } end diff --git a/app/views/admin/account_actions/new.html.haml b/app/views/admin/account_actions/new.html.haml index bce1c31760..5b98582d8c 100644 --- a/app/views/admin/account_actions/new.html.haml +++ b/app/views/admin/account_actions/new.html.haml @@ -1,6 +1,13 @@ - content_for :page_title do = t('admin.account_actions.title', acct: @account.pretty_acct) +- if @account.suspended? + .flash-message.alert + = t('admin.account_actions.already_suspended') +- elsif @account.silenced? + .flash-message.warn + = t('admin.account_actions.already_silenced') + = simple_form_for @account_action, url: admin_account_action_path(@account.id) do |f| = f.input :report_id, as: :hidden @@ -9,6 +16,7 @@ = f.input :type, as: :radio_buttons, collection: Admin::AccountAction.types_for_account(@account), + disabled: Admin::AccountAction.disabled_types_for_account(@account), hint: t('simple_form.hints.admin_account_action.type_html', acct: @account.pretty_acct), include_blank: false, label_method: ->(type) { account_action_type_label(type) }, diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 8430dd3c4f..27d8f4790b 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -56,19 +56,19 @@ .dashboard__item = link_to admin_reports_path, class: 'dashboard__quick-access' do - %span= t('admin.dashboard.pending_reports_html', count: @pending_reports_count) + %span= t('admin.dashboard.pending_reports_html', count: @pending_reports_count.value) = material_symbol 'chevron_right' = link_to admin_accounts_path(status: 'pending'), class: 'dashboard__quick-access' do - %span= t('admin.dashboard.pending_users_html', count: @pending_users_count) + %span= t('admin.dashboard.pending_users_html', count: @pending_users_count.value) = material_symbol 'chevron_right' = link_to admin_trends_tags_path(status: 'pending_review'), class: 'dashboard__quick-access' do - %span= t('admin.dashboard.pending_tags_html', count: @pending_tags_count) + %span= t('admin.dashboard.pending_tags_html', count: @pending_tags_count.value) = material_symbol 'chevron_right' = link_to admin_disputes_appeals_path(status: 'pending'), class: 'dashboard__quick-access' do - %span= t('admin.dashboard.pending_appeals_html', count: @pending_appeals_count) + %span= t('admin.dashboard.pending_appeals_html', count: @pending_appeals_count.value) = material_symbol 'chevron_right' .dashboard__item = react_admin_component :dimension, diff --git a/app/views/admin/reports/_actions.html.haml b/app/views/admin/reports/_actions.html.haml index 5fb540931b..7317d401e7 100644 --- a/app/views/admin/reports/_actions.html.haml +++ b/app/views/admin/reports/_actions.html.haml @@ -17,21 +17,27 @@ .report-actions__item__button = form.button t('admin.reports.delete_and_resolve'), name: :delete, - class: 'button button--destructive' + class: 'button button--destructive', + disabled: statuses.empty?, + title: statuses.empty? ? t('admin.reports.actions_no_posts') : '' .report-actions__item__description = t('admin.reports.actions.delete_description_html') .report-actions__item .report-actions__item__button = form.button t('admin.accounts.silence'), name: :silence, - class: 'button button--destructive' + class: 'button button--destructive', + disabled: report.target_account.silenced? || report.target_account.suspended?, + title: report.target_account.silenced? ? t('admin.account_actions.already_silenced') : '' .report-actions__item__description = t('admin.reports.actions.silence_description_html') .report-actions__item .report-actions__item__button = form.button t('admin.accounts.suspend'), name: :suspend, - class: 'button button--destructive' + class: 'button button--destructive', + disabled: report.target_account.suspended?, + title: report.target_account.suspended? ? t('admin.account_actions.already_suspended') : '' .report-actions__item__description = t('admin.reports.actions.suspend_description_html') .report-actions__item diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index d17ef79459..1b2b23caa7 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -3,6 +3,8 @@ = flavoured_javascript_pack_tag 'public', crossorigin: 'anonymous' = flavoured_javascript_pack_tag 'admin', async: true, crossorigin: 'anonymous' +- content_for :body_classes, 'admin' + - content_for :content do .admin-wrapper .sidebar-wrapper diff --git a/app/views/layouts/modal.html.haml b/app/views/layouts/modal.html.haml index 088ba82c1e..9c5975efc9 100644 --- a/app/views/layouts/modal.html.haml +++ b/app/views/layouts/modal.html.haml @@ -1,6 +1,8 @@ - content_for :header_tags do = flavoured_javascript_pack_tag 'public', crossorigin: 'anonymous' +- content_for :body_classes, 'modal-layout compose-standalone' + - content_for :content do - if user_signed_in? && !@hide_header .account-header diff --git a/app/views/media/player.html.haml b/app/views/media/player.html.haml index c5ba8680a0..e48982a323 100644 --- a/app/views/media/player.html.haml +++ b/app/views/media/player.html.haml @@ -2,6 +2,8 @@ = render_initial_state = flavoured_javascript_pack_tag 'public', crossorigin: 'anonymous' +- content_for :body_classes, 'player' + :ruby meta = @media_attachment.file.meta || {} diff --git a/config/initializers/active_record_encryption.rb b/config/initializers/active_record_encryption.rb index a83ca80765..b7a874e404 100644 --- a/config/initializers/active_record_encryption.rb +++ b/config/initializers/active_record_encryption.rb @@ -38,8 +38,4 @@ Rails.application.configure do config.active_record.encryption.key_derivation_salt = ENV.fetch('ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT') config.active_record.encryption.primary_key = ENV.fetch('ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY') config.active_record.encryption.support_sha1_for_non_deterministic_encryption = true - - # TODO: https://github.com/rails/rails/issues/50604#issuecomment-1880990392 - # Remove after updating to Rails 7.1.4 - ActiveRecord::Encryption.configure(**config.active_record.encryption) end diff --git a/config/locales/en.yml b/config/locales/en.yml index 267e04618b..217b1537f4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -25,6 +25,8 @@ en: admin: account_actions: action: Perform action + already_silenced: This account has already been silenced. + already_suspended: This account has already been suspended. title: Perform moderation action on %{acct} account_moderation_notes: create: Leave note @@ -602,6 +604,7 @@ en: suspend_description_html: The account and all its contents will be inaccessible and eventually deleted, and interacting with it will be impossible. Reversible within 30 days. Closes all reports against this account. actions_description_html: Decide which action to take to resolve this report. If you take a punitive action against the reported account, an email notification will be sent to them, except when the Spam category is selected. actions_description_remote_html: Decide which action to take to resolve this report. This will only affect how your server communicates with this remote account and handle its content. + actions_no_posts: This report doesn't have any associated posts to delete add_to_report: Add more to report already_suspended_badges: local: Already suspended on this server diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 42d1977662..8f0c80f1df 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -442,9 +442,9 @@ fi: create: Lisää verkkotunnus resolve: Selvitä verkkotunnus title: Estä uusi sähköpostiverkkotunnus - no_email_domain_block_selected: Sähköpostin verkkotunnuksia ei muutettu, koska yhtään ei ollut valittuna + no_email_domain_block_selected: Sähköpostiverkkotunnusten estoja ei muutettu; yhtäkään ei ollut valittu not_permitted: Ei sallittu - resolved_dns_records_hint_html: Verkkotunnuksen nimi määräytyy seuraaviin MX-verkkotunnuksiin, jotka ovat viime kädessä vastuussa sähköpostin vastaanottamisesta. MX-verkkotunnuksen estäminen estää rekisteröitymisen mistä tahansa sähköpostiosoitteesta, joka käyttää samaa MX-verkkotunnusta, vaikka näkyvä verkkotunnuksen nimi olisikin erilainen. Varo estämästä suuria sähköpostin palveluntarjoajia. + resolved_dns_records_hint_html: Verkkotunnusnimi kytkeytyy seuraaviin MX-verkkotunnuksiin, jotka ovat viime kädessä vastuussa sähköpostin vastaanottamisesta. MX-verkkotunnuksen estäminen estää rekisteröitymisen mistä tahansa sähköpostiosoitteesta, joka käyttää samaa MX-verkkotunnusta, vaikka näkyvä verkkotunnuksen nimi olisikin erilainen. Varo estämästä suuria sähköpostipalvelujen tarjoajia. resolved_through_html: Ratkaistu verkkotunnuksen %{domain} kautta title: Estetyt sähköpostiverkkotunnukset export_domain_allows: @@ -600,7 +600,7 @@ fi: resolve_description_html: Ilmoitettua tiliä kohtaan ei ryhdytä toimiin, varoitusta ei kirjata ja raportti suljetaan. silence_description_html: Tili näkyy vain niille, jotka jo seuraavat sitä tai etsivät sen manuaalisesti, mikä rajoittaa merkittävästi sen tavoitettavuutta. Voidaan perua milloin vain. Sulkee kaikki tiliin kohdistuvat raportit. suspend_description_html: Tili ja mikään sen sisältö eivät ole käytettävissä, ja lopulta ne poistetaan ja vuorovaikutus tilin kanssa on mahdotonta. Peruttavissa 30 päivän ajan. Sulkee kaikki tiliin kohdistuvat raportit. - actions_description_html: Päätä, mihin toimiin ryhdyt tämän raportin ratkaisemiseksi. Jos ryhdyt rangaistustoimeen ilmoitettua tiliä kohtaan, hänelle lähetetään sähköposti-ilmoitus, paitsi jos Roskaposti-luokka on valittuna. + actions_description_html: Päätä, mihin toimiin ryhdyt tämän raportin ratkaisemiseksi. Jos ryhdyt rangaistustoimeen ilmoitettua tiliä kohtaan, hänelle lähetetään sähköpostitse ilmoitus asiasta, paitsi jos valittuna on Roskaposti-luokka. actions_description_remote_html: Päätä, mihin toimiin ryhdyt tämän raportin ratkaisemiseksi. Tämä vaikuttaa vain siihen, miten sinun palvelimesi viestii tämän etätilin kanssa ja käsittelee sen sisältöä. add_to_report: Lisää raporttiin already_suspended_badges: @@ -977,7 +977,7 @@ fi: used_by_over_week: one: Käyttänyt yksi käyttäjä viimeisen viikon aikana other: Käyttänyt %{count} käyttäjää viimeisen viikon aikana - title: Suositukset ja trendit + title: Suositukset ja suuntaukset trending: Trendaus warning_presets: add_new: Lisää uusi @@ -1135,7 +1135,7 @@ fi: security: Turvallisuus set_new_password: Aseta uusi salasana setup: - email_below_hint_html: Tarkista roskapostikansiosi tai pyydä uusi viesti. Voit korjata sähköpostiosoitteesi, jos se oli väärin. + email_below_hint_html: Tarkista roskapostikansiosi tai pyydä uusi viesti. Voit myös korjata sähköpostiosoitteesi tarvittaessa. email_settings_hint_html: Napsauta lähettämäämme linkkiä vahvistaaksesi osoitteen %{email}. Odotamme täällä. link_not_received: Etkö saanut linkkiä? new_confirmation_instructions_sent: Saat pian uuden vahvistuslinkin sisältävän sähköpostiviestin! @@ -1195,8 +1195,8 @@ fi: caches: Muiden palvelinten välimuistiinsa tallentamaa sisältöä voi säilyä data_removal: Julkaisusi ja muut tietosi poistetaan pysyvästi email_change_html: Voit muuttaa sähköpostiosoitettasi poistamatta tiliäsi - email_contact_html: Jos ei saavu perille, voit pyytää apua sähköpostilla %{email} - email_reconfirmation_html: Jos et saa vahvistuksen sähköpostia, niin voit pyytää sitä uudelleen + email_contact_html: Mikäli viesti ei vieläkään saavu perille, voit pyytää apua sähköpostitse osoitteella %{email} + email_reconfirmation_html: Jos et saa vahvistussähköpostiviestiä, voit pyytää sitä uudelleen irreversible: Et voi palauttaa tiliäsi etkä aktivoida sitä uudelleen more_details_html: Tarkempia tietoja saat tietosuojakäytännöstämme. username_available: Käyttäjänimesi tulee saataville uudelleen diff --git a/config/locales/fr-CA.yml b/config/locales/fr-CA.yml index 45c6baece9..140bc94344 100644 --- a/config/locales/fr-CA.yml +++ b/config/locales/fr-CA.yml @@ -132,6 +132,7 @@ fr-CA: resubscribe: Se réabonner role: Rôle search: Rechercher + search_same_email_domain: Autres utilisateurs avec le même domaine de courriel search_same_ip: Autres utilisateur·rice·s avec la même IP security: Sécurité security_measures: @@ -1428,6 +1429,7 @@ fr-CA: media_attachments: validations: images_and_video: Impossible de joindre une vidéo à un message contenant déjà des images + not_found: Média %{ids} introuvable ou déjà attaché à un autre message not_ready: Impossible de joindre les fichiers en cours de traitement. Réessayez dans un instant ! too_many: Impossible de joindre plus de 4 fichiers migrations: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 4434a16531..5646877d23 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -132,6 +132,7 @@ fr: resubscribe: Se réabonner role: Rôle search: Rechercher + search_same_email_domain: Autres utilisateurs avec le même domaine de courriel search_same_ip: Autres utilisateur·rice·s avec la même IP security: Sécurité security_measures: @@ -1428,6 +1429,7 @@ fr: media_attachments: validations: images_and_video: Impossible de joindre une vidéo à un message contenant déjà des images + not_found: Média %{ids} introuvable ou déjà attaché à un autre message not_ready: Impossible de joindre les fichiers en cours de traitement. Réessayez dans un instant ! too_many: Impossible de joindre plus de 4 fichiers migrations: diff --git a/config/locales/fy.yml b/config/locales/fy.yml index d0127f77b1..de7495dd55 100644 --- a/config/locales/fy.yml +++ b/config/locales/fy.yml @@ -1454,6 +1454,7 @@ fy: media_attachments: validations: images_and_video: In fideo kin net oan in berjocht mei ôfbyldingen keppele wurde + not_found: Media %{ids} net fûn of al tafoege oan in oar berjocht not_ready: Kin gjin bestannen tafoegje dy’t noch net ferwurke binne. Probearje it letter opnij! too_many: Der kinne net mear as 4 ôfbyldingen tafoege wurde migrations: diff --git a/config/locales/ga.yml b/config/locales/ga.yml index 27237bf3a4..ad9ee21d3e 100644 --- a/config/locales/ga.yml +++ b/config/locales/ga.yml @@ -1532,6 +1532,7 @@ ga: media_attachments: validations: images_and_video: Ní féidir físeán a cheangal le postáil a bhfuil íomhánna ann cheana féin + not_found: Meán %{ids} gan aimsiú nó ceangailte le postáil eile cheana not_ready: Ní féidir comhaid nach bhfuil próiseáil críochnaithe acu a cheangal. Bain triail eile as i gceann nóiméad! too_many: Ní féidir níos mó ná 4 chomhad a cheangal migrations: diff --git a/config/locales/gd.yml b/config/locales/gd.yml index ef4add838e..2af647ab9c 100644 --- a/config/locales/gd.yml +++ b/config/locales/gd.yml @@ -1506,6 +1506,7 @@ gd: media_attachments: validations: images_and_video: Chan urrainn dhut video a cheangal ri post sa bheil dealbh mu thràth + not_found: Cha deach na meadhanan %{ids} a lorg no chaidh an ceangal ri post eile mu thràth not_ready: Chan urrainn dhuinn faidhlichean a cheangal ris nach eil air am pròiseasadh fhathast. Feuch ris a-rithist an ceann greis! too_many: Chan urrainn dhut barrachd air 4 faidhlichean a ceangal ris migrations: diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 579dbd967f..18496b9e1d 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -203,7 +203,7 @@ pt-BR: disable_sign_in_token_auth_user: Desativar autenticação via Token de Email para Usuário disable_user: Desativar usuário enable_custom_emoji: Ativar emoji personalizado - enable_sign_in_token_auth_user: Desativar autenticação via token por e-mail para o usuário + enable_sign_in_token_auth_user: Ativar autenticação via Token de Email para Usuário enable_user: Ativar usuário memorialize_account: Converter conta em memorial promote_user: Promover usuário @@ -442,6 +442,7 @@ pt-BR: create: Adicionar domínio resolve: Resolver domínio title: Bloquear novo domínio de e-mail + no_email_domain_block_selected: Nenhum bloco de domínio de email foi alterado, pois, nenhum foi selecionado not_permitted: Não permitido resolved_dns_records_hint_html: O nome de domínio é associado aos seguintes domínios MX, que são responsáveis por aceitar e-mails. Ao bloquear um domínio MX, você bloqueará as inscrições de qualquer endereço de e-mail que use o mesmo domínio MX, mesmo que o nome de domínio visível seja diferente. Tenha cuidado para não bloquear os principais provedores de e-mail. resolved_through_html: Resolvido através de %{domain} @@ -1440,6 +1441,13 @@ pt-BR: action: Sim, cancelar subscrição complete: Desinscrito confirmation_html: Tem certeza que deseja cancelar a assinatura de %{type} para Mastodon no %{domain} para o seu endereço de e-mail %{email}? Você sempre pode se inscrever novamente nas configurações de notificação de email. + emails: + notification_emails: + favourite: emails de notificação favoritos + follow: seguir emails de notificação + follow_request: emails de seguidores pendentes + mention: emails de notificação de menções + reblog: emails de notificação de boosts resubscribe_html: Se você cancelou sua inscrição por engano, você pode se inscrever novamente em suas configurações de notificações por e-mail. success_html: Você não mais receberá %{type} no Mastodon em %{domain} ao seu endereço de e-mail %{email}. title: Cancelar inscrição diff --git a/config/locales/simple_form.fr-CA.yml b/config/locales/simple_form.fr-CA.yml index e8aafa4b1c..640d7e344a 100644 --- a/config/locales/simple_form.fr-CA.yml +++ b/config/locales/simple_form.fr-CA.yml @@ -81,6 +81,7 @@ fr-CA: bootstrap_timeline_accounts: Ces comptes seront épinglés en tête de liste des recommandations pour les nouveaux utilisateurs. closed_registrations_message: Affiché lorsque les inscriptions sont fermées custom_css: Vous pouvez appliquer des styles personnalisés sur la version Web de Mastodon. + favicon: WEBP, PNG, GIF ou JPG. Remplace la favicon Mastodon par défaut avec une icône personnalisée. mascot: Remplace l'illustration dans l'interface Web avancée. media_cache_retention_period: Les fichiers médias des messages publiés par des utilisateurs distants sont mis en cache sur votre serveur. Lorsque cette valeur est positive, les médias sont supprimés au terme du nombre de jours spécifié. Si les données des médias sont demandées après leur suppression, elles seront téléchargées à nouveau, dans la mesure où le contenu source est toujours disponible. En raison des restrictions concernant la fréquence à laquelle les cartes de prévisualisation des liens interrogent des sites tiers, il est recommandé de fixer cette valeur à au moins 14 jours, faute de quoi les cartes de prévisualisation des liens ne seront pas mises à jour à la demande avant cette échéance. peers_api_enabled: Une liste de noms de domaine que ce serveur a rencontrés dans le fédiverse. Aucune donnée indiquant si vous vous fédérez ou non avec un serveur particulier n'est incluse ici, seulement l'information que votre serveur connaît un autre serveur. Cette option est utilisée par les services qui collectent des statistiques sur la fédération en général. diff --git a/config/locales/simple_form.fr.yml b/config/locales/simple_form.fr.yml index 315e22c5fb..04d48573a3 100644 --- a/config/locales/simple_form.fr.yml +++ b/config/locales/simple_form.fr.yml @@ -81,6 +81,7 @@ fr: bootstrap_timeline_accounts: Ces comptes seront épinglés en tête de liste des recommandations pour les nouveaux utilisateurs. closed_registrations_message: Affiché lorsque les inscriptions sont fermées custom_css: Vous pouvez appliquer des styles personnalisés sur la version Web de Mastodon. + favicon: WEBP, PNG, GIF ou JPG. Remplace la favicon Mastodon par défaut avec une icône personnalisée. mascot: Remplace l'illustration dans l'interface Web avancée. media_cache_retention_period: Les fichiers médias des messages publiés par des utilisateurs distants sont mis en cache sur votre serveur. Lorsque cette valeur est positive, les médias sont supprimés au terme du nombre de jours spécifié. Si les données des médias sont demandées après leur suppression, elles seront téléchargées à nouveau, dans la mesure où le contenu source est toujours disponible. En raison des restrictions concernant la fréquence à laquelle les cartes de prévisualisation des liens interrogent des sites tiers, il est recommandé de fixer cette valeur à au moins 14 jours, faute de quoi les cartes de prévisualisation des liens ne seront pas mises à jour à la demande avant cette échéance. peers_api_enabled: Une liste de noms de domaine que ce serveur a rencontrés dans le fédiverse. Aucune donnée indiquant si vous vous fédérez ou non avec un serveur particulier n'est incluse ici, seulement l'information que votre serveur connaît un autre serveur. Cette option est utilisée par les services qui collectent des statistiques sur la fédération en général. diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index c31a68926e..a8d401c7bb 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -1428,6 +1428,7 @@ zh-CN: media_attachments: validations: images_and_video: 无法在嘟文中同时插入视频和图片 + not_found: 未发现媒体%{ids} 或已附在另一条嘟文中 not_ready: 不能附加还在处理中的文件。请稍后再试! too_many: 最多只能添加 4 张图片 migrations: diff --git a/lib/mastodon/cli/accounts.rb b/lib/mastodon/cli/accounts.rb index 0cdf68158f..8a138323d4 100644 --- a/lib/mastodon/cli/accounts.rb +++ b/lib/mastodon/cli/accounts.rb @@ -502,7 +502,7 @@ module Mastodon::CLI - not muted/blocked by us LONG_DESC def prune - query = Account.remote.where.not(actor_type: %i(Application Service)) + query = Account.remote.non_automated query = query.where('NOT EXISTS (SELECT 1 FROM mentions WHERE account_id = accounts.id)') query = query.where('NOT EXISTS (SELECT 1 FROM favourites WHERE account_id = accounts.id)') query = query.where('NOT EXISTS (SELECT 1 FROM statuses WHERE account_id = accounts.id)') diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb index 0880273853..408e0dd2f6 100644 --- a/spec/controllers/activitypub/collections_controller_spec.rb +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -31,7 +31,7 @@ RSpec.describe ActivityPub::CollectionsController do .and have_cacheable_headers expect(response.media_type).to eq 'application/activity+json' - expect(body_as_json[:orderedItems]) + expect(response.parsed_body[:orderedItems]) .to be_an(Array) .and have_attributes(size: 3) .and include(ActivityPub::TagManager.instance.uri_for(private_pinned)) @@ -71,7 +71,7 @@ RSpec.describe ActivityPub::CollectionsController do expect(response.media_type).to eq 'application/activity+json' - expect(body_as_json[:orderedItems]) + expect(response.parsed_body[:orderedItems]) .to be_an(Array) .and have_attributes(size: 3) .and include(ActivityPub::TagManager.instance.uri_for(private_pinned)) @@ -94,7 +94,7 @@ RSpec.describe ActivityPub::CollectionsController do expect(response.media_type).to eq 'application/activity+json' expect(response.headers['Cache-Control']).to include 'private' - expect(body_as_json[:orderedItems]) + expect(response.parsed_body[:orderedItems]) .to be_an(Array) .and be_empty end @@ -110,7 +110,7 @@ RSpec.describe ActivityPub::CollectionsController do expect(response.media_type).to eq 'application/activity+json' expect(response.headers['Cache-Control']).to include 'private' - expect(body_as_json[:orderedItems]) + expect(response.parsed_body[:orderedItems]) .to be_an(Array) .and be_empty end diff --git a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb index c030078d43..cbd982f18f 100644 --- a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb +++ b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb @@ -34,7 +34,6 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController do context 'with signature from example.com' do subject(:response) { get :show, params: { account_username: account.username } } - let(:body) { body_as_json } let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') } it 'returns http success and cache control and activity json types and correct items' do @@ -42,7 +41,7 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController do expect(response.headers['Cache-Control']).to eq 'max-age=0, private' expect(response.media_type).to eq 'application/activity+json' - expect(body[:orderedItems]) + expect(response.parsed_body[:orderedItems]) .to be_an(Array) .and contain_exactly( follower_example_com_instance_actor.uri, diff --git a/spec/controllers/activitypub/outboxes_controller_spec.rb b/spec/controllers/activitypub/outboxes_controller_spec.rb index 26a52bad93..7ae28e8e09 100644 --- a/spec/controllers/activitypub/outboxes_controller_spec.rb +++ b/spec/controllers/activitypub/outboxes_controller_spec.rb @@ -19,7 +19,6 @@ RSpec.describe ActivityPub::OutboxesController do context 'without signature' do subject(:response) { get :show, params: { account_username: account.username, page: page } } - let(:body) { body_as_json } let(:remote_account) { nil } context 'with page not requested' do @@ -32,7 +31,7 @@ RSpec.describe ActivityPub::OutboxesController do expect(response.media_type).to eq 'application/activity+json' expect(response.headers['Vary']).to be_nil - expect(body[:totalItems]).to eq 4 + expect(response.parsed_body[:totalItems]).to eq 4 end context 'when account is permanently suspended' do @@ -68,9 +67,11 @@ RSpec.describe ActivityPub::OutboxesController do expect(response.media_type).to eq 'application/activity+json' expect(response.headers['Vary']).to include 'Signature' - expect(body[:orderedItems]).to be_an Array - expect(body[:orderedItems].size).to eq 2 - expect(body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true + expect(response.parsed_body) + .to include( + orderedItems: be_an(Array).and(have_attributes(size: 2)) + ) + expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true end context 'when account is permanently suspended' do @@ -110,9 +111,11 @@ RSpec.describe ActivityPub::OutboxesController do expect(response.media_type).to eq 'application/activity+json' expect(response.headers['Cache-Control']).to eq 'max-age=60, private' - expect(body_as_json[:orderedItems]).to be_an Array - expect(body_as_json[:orderedItems].size).to eq 2 - expect(body_as_json[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true + expect(response.parsed_body) + .to include( + orderedItems: be_an(Array).and(have_attributes(size: 2)) + ) + expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true end end @@ -127,9 +130,11 @@ RSpec.describe ActivityPub::OutboxesController do expect(response.media_type).to eq 'application/activity+json' expect(response.headers['Cache-Control']).to eq 'max-age=60, private' - expect(body_as_json[:orderedItems]).to be_an Array - expect(body_as_json[:orderedItems].size).to eq 3 - expect(body_as_json[:orderedItems].all? { |item| targets_public_collection?(item) || targets_followers_collection?(item, account) }).to be true + expect(response.parsed_body) + .to include( + orderedItems: be_an(Array).and(have_attributes(size: 3)) + ) + expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) || targets_followers_collection?(item, account) }).to be true end end @@ -144,9 +149,10 @@ RSpec.describe ActivityPub::OutboxesController do expect(response.media_type).to eq 'application/activity+json' expect(response.headers['Cache-Control']).to eq 'max-age=60, private' - expect(body_as_json[:orderedItems]) - .to be_an(Array) - .and be_empty + expect(response.parsed_body) + .to include( + orderedItems: be_an(Array).and(be_empty) + ) end end @@ -161,9 +167,10 @@ RSpec.describe ActivityPub::OutboxesController do expect(response.media_type).to eq 'application/activity+json' expect(response.headers['Cache-Control']).to eq 'max-age=60, private' - expect(body_as_json[:orderedItems]) - .to be_an(Array) - .and be_empty + expect(response.parsed_body) + .to include( + orderedItems: be_an(Array).and(be_empty) + ) end end end diff --git a/spec/controllers/activitypub/replies_controller_spec.rb b/spec/controllers/activitypub/replies_controller_spec.rb index c10c782c9a..27821b0d4e 100644 --- a/spec/controllers/activitypub/replies_controller_spec.rb +++ b/spec/controllers/activitypub/replies_controller_spec.rb @@ -66,7 +66,7 @@ RSpec.describe ActivityPub::RepliesController do context 'when status is public' do let(:parent_visibility) { :public } - let(:page_json) { body_as_json[:first] } + let(:page_json) { response.parsed_body[:first] } it 'returns http success and correct media type' do expect(response) diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index ca399fbd9b..a182300106 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -55,6 +55,23 @@ RSpec.describe Admin::AccountsController do describe 'GET #show' do let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } + describe 'account moderation notes' do + let(:account) { Fabricate(:account) } + + it 'includes moderation notes' do + note1 = Fabricate(:account_moderation_note, target_account: account) + note2 = Fabricate(:account_moderation_note, target_account: account) + + get :show, params: { id: account.id } + expect(response).to have_http_status(200) + + moderation_notes = assigns(:moderation_notes).to_a + + expect(moderation_notes.size).to be 2 + expect(moderation_notes).to eq [note1, note2] + end + end + context 'with a remote account' do let(:account) { Fabricate(:account, domain: 'example.com') } diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb index d07468a37b..1252ceb1f4 100644 --- a/spec/controllers/admin/reports_controller_spec.rb +++ b/spec/controllers/admin/reports_controller_spec.rb @@ -47,6 +47,24 @@ RSpec.describe Admin::ReportsController do expect(response.body) .to include(report.comment) end + + describe 'account moderation notes' do + let(:report) { Fabricate(:report) } + + it 'includes moderation notes' do + note1 = Fabricate(:report_note, report: report) + note2 = Fabricate(:report_note, report: report) + + get :show, params: { id: report } + + expect(response).to have_http_status(200) + + report_notes = assigns(:report_notes).to_a + + expect(report_notes.size).to be 2 + expect(report_notes).to eq [note1, note2] + end + end end describe 'POST #resolve' do diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb index 9a94e5e1a1..3cc3460718 100644 --- a/spec/controllers/auth/sessions_controller_spec.rb +++ b/spec/controllers/auth/sessions_controller_spec.rb @@ -402,7 +402,7 @@ RSpec.describe Auth::SessionsController do end it 'instructs the browser to redirect to home, logs the user in, and updates the sign count' do - expect(body_as_json[:redirect_path]).to eq(root_path) + expect(response.parsed_body[:redirect_path]).to eq(root_path) expect(controller.current_user).to eq user diff --git a/spec/controllers/concerns/account_controller_concern_spec.rb b/spec/controllers/concerns/account_controller_concern_spec.rb index 3eee46d7b9..384406a0ea 100644 --- a/spec/controllers/concerns/account_controller_concern_spec.rb +++ b/spec/controllers/concerns/account_controller_concern_spec.rb @@ -54,17 +54,12 @@ RSpec.describe AccountControllerConcern do it 'Prepares the account, returns success, and sets link headers' do get 'success', params: { account_username: account.username } - expect(response).to have_http_status(200) - expect(response.headers['Link'].to_s).to eq(expected_link_headers) + expect(response) + .to have_http_status(200) + .and have_http_link_header('http://test.host/.well-known/webfinger?resource=acct%3Ausername%40cb6e6126.ngrok.io').for(rel: 'lrdd', type: 'application/jrd+json') + .and have_http_link_header('https://cb6e6126.ngrok.io/users/username').for(rel: 'alternate', type: 'application/activity+json') expect(response.body) .to include(account.username) end - - def expected_link_headers - [ - '; rel="lrdd"; type="application/jrd+json"', - '; rel="alternate"; type="application/activity+json"', - ].join(', ') - end end end diff --git a/spec/controllers/follower_accounts_controller_spec.rb b/spec/controllers/follower_accounts_controller_spec.rb index e84528d13e..e14ed00e60 100644 --- a/spec/controllers/follower_accounts_controller_spec.rb +++ b/spec/controllers/follower_accounts_controller_spec.rb @@ -39,8 +39,6 @@ RSpec.describe FollowerAccountsController do end context 'when format is json' do - subject(:body) { response.parsed_body } - let(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } } context 'with page' do @@ -48,15 +46,15 @@ RSpec.describe FollowerAccountsController do it 'returns followers' do expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( orderedItems: contain_exactly( include(follow_from_bob.account.username), include(follow_from_chris.account.username) - ) + ), + totalItems: eq(2), + partOf: be_present ) - expect(body['totalItems']).to eq 2 - expect(body['partOf']).to be_present end context 'when account is permanently suspended' do @@ -86,8 +84,11 @@ RSpec.describe FollowerAccountsController do it 'returns followers' do expect(response).to have_http_status(200) - expect(body['totalItems']).to eq 2 - expect(body['partOf']).to be_blank + expect(response.parsed_body) + .to include( + totalItems: eq(2) + ) + .and not_include(:partOf) end context 'when account hides their network' do @@ -95,15 +96,17 @@ RSpec.describe FollowerAccountsController do alice.update(hide_collections: true) end - it 'returns followers count' do - expect(body['totalItems']).to eq 2 - end - - it 'does not return items' do - expect(body['items']).to be_blank - expect(body['orderedItems']).to be_blank - expect(body['first']).to be_blank - expect(body['last']).to be_blank + it 'returns followers count but not any items' do + expect(response.parsed_body) + .to include( + totalItems: eq(2) + ) + .and not_include( + :items, + :orderedItems, + :first, + :last + ) end end diff --git a/spec/controllers/following_accounts_controller_spec.rb b/spec/controllers/following_accounts_controller_spec.rb index 1e01b9f494..fea4d4845c 100644 --- a/spec/controllers/following_accounts_controller_spec.rb +++ b/spec/controllers/following_accounts_controller_spec.rb @@ -39,8 +39,6 @@ RSpec.describe FollowingAccountsController do end context 'when format is json' do - subject(:body) { response.parsed_body } - let(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } } context 'with page' do @@ -48,15 +46,15 @@ RSpec.describe FollowingAccountsController do it 'returns followers' do expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( orderedItems: contain_exactly( include(follow_of_bob.target_account.username), include(follow_of_chris.target_account.username) - ) + ), + totalItems: eq(2), + partOf: be_present ) - expect(body['totalItems']).to eq 2 - expect(body['partOf']).to be_present end context 'when account is permanently suspended' do @@ -86,8 +84,11 @@ RSpec.describe FollowingAccountsController do it 'returns followers' do expect(response).to have_http_status(200) - expect(body['totalItems']).to eq 2 - expect(body['partOf']).to be_blank + expect(response.parsed_body) + .to include( + totalItems: eq(2) + ) + .and not_include(:partOf) end context 'when account hides their network' do @@ -95,15 +96,17 @@ RSpec.describe FollowingAccountsController do alice.update(hide_collections: true) end - it 'returns followers count' do - expect(body['totalItems']).to eq 2 - end - - it 'does not return items' do - expect(body['items']).to be_blank - expect(body['orderedItems']).to be_blank - expect(body['first']).to be_blank - expect(body['last']).to be_blank + it 'returns followers count but not any items' do + expect(response.parsed_body) + .to include( + totalItems: eq(2) + ) + .and not_include( + :items, + :orderedItems, + :first, + :last + ) end end diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rb index 289109a1fa..2d5ff0135b 100644 --- a/spec/controllers/statuses_controller_spec.rb +++ b/spec/controllers/statuses_controller_spec.rb @@ -81,7 +81,7 @@ RSpec.describe StatusesController do 'Content-Type' => include('application/activity+json'), 'Link' => satisfy { |header| header.to_s.include?('activity+json') } ) - expect(body_as_json) + expect(response.parsed_body) .to include(content: include(status.text)) end end @@ -186,7 +186,7 @@ RSpec.describe StatusesController do 'Content-Type' => include('application/activity+json'), 'Link' => satisfy { |header| header.to_s.include?('activity+json') } ) - expect(body_as_json) + expect(response.parsed_body) .to include(content: include(status.text)) end end @@ -230,7 +230,7 @@ RSpec.describe StatusesController do 'Content-Type' => include('application/activity+json'), 'Link' => satisfy { |header| header.to_s.include?('activity+json') } ) - expect(body_as_json) + expect(response.parsed_body) .to include(content: include(status.text)) end end @@ -296,7 +296,7 @@ RSpec.describe StatusesController do 'Content-Type' => include('application/activity+json'), 'Link' => satisfy { |header| header.to_s.include?('activity+json') } ) - expect(body_as_json) + expect(response.parsed_body) .to include(content: include(status.text)) end end @@ -387,7 +387,7 @@ RSpec.describe StatusesController do 'Content-Type' => include('application/activity+json'), 'Link' => satisfy { |header| header.to_s.include?('activity+json') } ) - expect(body_as_json) + expect(response.parsed_body) .to include(content: include(status.text)) end end @@ -431,7 +431,7 @@ RSpec.describe StatusesController do 'Link' => satisfy { |header| header.to_s.include?('activity+json') } ) - expect(body_as_json) + expect(response.parsed_body) .to include(content: include(status.text)) end end @@ -497,7 +497,7 @@ RSpec.describe StatusesController do 'Content-Type' => include('application/activity+json'), 'Link' => satisfy { |header| header.to_s.include?('activity+json') } ) - expect(body_as_json) + expect(response.parsed_body) .to include(content: include(status.text)) end end diff --git a/spec/fabricators/account_moderation_note_fabricator.rb b/spec/fabricators/account_moderation_note_fabricator.rb index 05a687bf4e..1ded862638 100644 --- a/spec/fabricators/account_moderation_note_fabricator.rb +++ b/spec/fabricators/account_moderation_note_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:account_moderation_note) do - content 'MyText' + content { Faker::Lorem.sentences } account { Fabricate.build(:account) } target_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/report_note_fabricator.rb b/spec/fabricators/report_note_fabricator.rb index 080fad51ac..a5e9cc9009 100644 --- a/spec/fabricators/report_note_fabricator.rb +++ b/spec/fabricators/report_note_fabricator.rb @@ -3,5 +3,5 @@ Fabricator(:report_note) do report { Fabricate.build(:report) } account { Fabricate.build(:account) } - content 'Test Content' + content { Faker::Lorem.sentences } end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 1ea5b573c9..50181fdb91 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -8,7 +8,16 @@ RSpec.describe ApplicationHelper do before { helper.extend controller_helpers } it 'uses the controller body classes in the result' do - expect(helper.body_classes).to match(/modal-layout compose-standalone/) + expect(helper.body_classes) + .to match(/modal-layout compose-standalone/) + .and match(/theme-default/) + end + + it 'includes values set via content_for' do + helper.content_for(:body_classes) { 'admin' } + + expect(helper.body_classes) + .to match(/admin/) end private diff --git a/spec/models/account_moderation_note_spec.rb b/spec/models/account_moderation_note_spec.rb new file mode 100644 index 0000000000..079774c492 --- /dev/null +++ b/spec/models/account_moderation_note_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe AccountModerationNote do + describe 'chronological scope' do + it 'returns account moderation notes oldest to newest' do + account = Fabricate(:account) + note1 = Fabricate(:account_moderation_note, target_account: account) + note2 = Fabricate(:account_moderation_note, target_account: account) + + expect(account.targeted_moderation_notes.chronological).to eq [note1, note2] + end + end + + describe 'validations' do + it 'is invalid if the content is empty' do + report = Fabricate.build(:account_moderation_note, content: '') + expect(report.valid?).to be false + end + + it 'is invalid if content is longer than character limit' do + report = Fabricate.build(:account_moderation_note, content: comment_over_limit) + expect(report.valid?).to be false + end + + def comment_over_limit + Faker::Lorem.paragraph_by_chars(number: described_class::CONTENT_SIZE_LIMIT * 2) + end + end +end diff --git a/spec/models/report_note_spec.rb b/spec/models/report_note_spec.rb new file mode 100644 index 0000000000..417971c9a1 --- /dev/null +++ b/spec/models/report_note_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe ReportNote do + describe 'chronological scope' do + it 'returns report notes oldest to newest' do + report = Fabricate(:report) + note1 = Fabricate(:report_note, report: report) + note2 = Fabricate(:report_note, report: report) + + expect(report.notes.chronological).to eq [note1, note2] + end + end + + describe 'validations' do + it 'is invalid if the content is empty' do + report = Fabricate.build(:report_note, content: '') + expect(report.valid?).to be false + end + + it 'is invalid if content is longer than character limit' do + report = Fabricate.build(:report_note, content: comment_over_limit) + expect(report.valid?).to be false + end + + def comment_over_limit + Faker::Lorem.paragraph_by_chars(number: described_class::CONTENT_SIZE_LIMIT * 2) + end + end +end diff --git a/spec/requests/accounts_spec.rb b/spec/requests/accounts_spec.rb index d53816eff0..e657ae6060 100644 --- a/spec/requests/accounts_spec.rb +++ b/spec/requests/accounts_spec.rb @@ -69,8 +69,7 @@ RSpec.describe 'Accounts show response' do expect(response) .to have_http_status(200) .and render_template(:show) - - expect(response.headers['Link'].to_s).to include ActivityPub::TagManager.instance.uri_for(account) + .and have_http_link_header(ActivityPub::TagManager.instance.uri_for(account)).for(rel: 'alternate') end end @@ -135,7 +134,7 @@ RSpec.describe 'Accounts show response' do media_type: eq('application/activity+json') ) - expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) + expect(response.parsed_body).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) end context 'with authorized fetch mode' do @@ -164,7 +163,7 @@ RSpec.describe 'Accounts show response' do expect(response.headers['Cache-Control']).to include 'private' - expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) + expect(response.parsed_body).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) end end @@ -183,7 +182,7 @@ RSpec.describe 'Accounts show response' do media_type: eq('application/activity+json') ) - expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) + expect(response.parsed_body).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) end context 'with authorized fetch mode' do @@ -199,7 +198,7 @@ RSpec.describe 'Accounts show response' do expect(response.headers['Cache-Control']).to include 'private' expect(response.headers['Vary']).to include 'Signature' - expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) + expect(response.parsed_body).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) end end end diff --git a/spec/requests/api/v1/accounts/credentials_spec.rb b/spec/requests/api/v1/accounts/credentials_spec.rb index ce5940d468..77b815945e 100644 --- a/spec/requests/api/v1/accounts/credentials_spec.rb +++ b/spec/requests/api/v1/accounts/credentials_spec.rb @@ -20,7 +20,7 @@ RSpec.describe 'credentials API' do expect(response) .to have_http_status(200) - expect(body_as_json).to include({ + expect(response.parsed_body).to include({ source: hash_including({ discoverable: false, indexable: false, @@ -37,7 +37,7 @@ RSpec.describe 'credentials API' do expect(response).to have_http_status(200) - expect(body_as_json).to include({ + expect(response.parsed_body).to include({ locked: true, }) end @@ -93,7 +93,7 @@ RSpec.describe 'credentials API' do expect(response) .to have_http_status(200) - expect(body_as_json).to include({ + expect(response.parsed_body).to include({ source: hash_including({ discoverable: true, indexable: true, diff --git a/spec/requests/api/v1/accounts/familiar_followers_spec.rb b/spec/requests/api/v1/accounts/familiar_followers_spec.rb index 475f1b17e4..8edfa4c883 100644 --- a/spec/requests/api/v1/accounts/familiar_followers_spec.rb +++ b/spec/requests/api/v1/accounts/familiar_followers_spec.rb @@ -24,7 +24,7 @@ RSpec.describe 'Accounts Familiar Followers API' do account_ids = [account_a, account_b, account_b, account_a, account_a].map { |a| a.id.to_s } get '/api/v1/accounts/familiar_followers', params: { id: account_ids }, headers: headers - expect(body_as_json.pluck(:id)).to contain_exactly(account_a.id.to_s, account_b.id.to_s) + expect(response.parsed_body.pluck(:id)).to contain_exactly(account_a.id.to_s, account_b.id.to_s) end end end diff --git a/spec/requests/api/v1/accounts/featured_tags_spec.rb b/spec/requests/api/v1/accounts/featured_tags_spec.rb index bae7d448b6..f48ed01def 100644 --- a/spec/requests/api/v1/accounts/featured_tags_spec.rb +++ b/spec/requests/api/v1/accounts/featured_tags_spec.rb @@ -23,7 +23,7 @@ RSpec.describe 'account featured tags API' do subject expect(response).to have_http_status(200) - expect(body_as_json).to contain_exactly(a_hash_including({ + expect(response.parsed_body).to contain_exactly(a_hash_including({ name: 'bar', url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/bar", }), a_hash_including({ @@ -37,7 +37,7 @@ RSpec.describe 'account featured tags API' do subject expect(response).to have_http_status(200) - expect(body_as_json).to contain_exactly(a_hash_including({ + expect(response.parsed_body).to contain_exactly(a_hash_including({ name: 'bar', url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/bar", }), a_hash_including({ diff --git a/spec/requests/api/v1/accounts/follower_accounts_spec.rb b/spec/requests/api/v1/accounts/follower_accounts_spec.rb index 400b1c7aff..2672615390 100644 --- a/spec/requests/api/v1/accounts/follower_accounts_spec.rb +++ b/spec/requests/api/v1/accounts/follower_accounts_spec.rb @@ -21,8 +21,8 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers expect(response).to have_http_status(200) - expect(body_as_json.size).to eq 2 - expect([body_as_json[0][:id], body_as_json[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s) + expect(response.parsed_body.size).to eq 2 + expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s) end it 'does not return blocked users', :aggregate_failures do @@ -30,8 +30,8 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers expect(response).to have_http_status(200) - expect(body_as_json.size).to eq 1 - expect(body_as_json[0][:id]).to eq alice.id.to_s + expect(response.parsed_body.size).to eq 1 + expect(response.parsed_body[0][:id]).to eq alice.id.to_s end context 'when requesting user is blocked' do @@ -41,7 +41,7 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do it 'hides results' do get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers - expect(body_as_json.size).to eq 0 + expect(response.parsed_body.size).to eq 0 end end @@ -52,8 +52,8 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do account.mute!(bob) get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers - expect(body_as_json.size).to eq 2 - expect([body_as_json[0][:id], body_as_json[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s) + expect(response.parsed_body.size).to eq 2 + expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s) end end end diff --git a/spec/requests/api/v1/accounts/following_accounts_spec.rb b/spec/requests/api/v1/accounts/following_accounts_spec.rb index b0bb5141ca..19105ebf2f 100644 --- a/spec/requests/api/v1/accounts/following_accounts_spec.rb +++ b/spec/requests/api/v1/accounts/following_accounts_spec.rb @@ -21,8 +21,8 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers expect(response).to have_http_status(200) - expect(body_as_json.size).to eq 2 - expect([body_as_json[0][:id], body_as_json[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s) + expect(response.parsed_body.size).to eq 2 + expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s) end it 'does not return blocked users', :aggregate_failures do @@ -30,8 +30,8 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers expect(response).to have_http_status(200) - expect(body_as_json.size).to eq 1 - expect(body_as_json[0][:id]).to eq alice.id.to_s + expect(response.parsed_body.size).to eq 1 + expect(response.parsed_body[0][:id]).to eq alice.id.to_s end context 'when requesting user is blocked' do @@ -41,7 +41,7 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do it 'hides results' do get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers - expect(body_as_json.size).to eq 0 + expect(response.parsed_body.size).to eq 0 end end @@ -52,8 +52,8 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do account.mute!(bob) get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers - expect(body_as_json.size).to eq 2 - expect([body_as_json[0][:id], body_as_json[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s) + expect(response.parsed_body.size).to eq 2 + expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s) end end end diff --git a/spec/requests/api/v1/accounts/relationships_spec.rb b/spec/requests/api/v1/accounts/relationships_spec.rb index 76b1830bbe..9570d1214c 100644 --- a/spec/requests/api/v1/accounts/relationships_spec.rb +++ b/spec/requests/api/v1/accounts/relationships_spec.rb @@ -29,7 +29,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_an(Enumerable) .and contain_exactly( include( @@ -50,7 +50,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_an(Enumerable) .and have_attributes( size: 2 @@ -70,7 +70,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_an(Enumerable) .and have_attributes( size: 3 @@ -89,7 +89,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do it 'removes duplicate account IDs from params' do subject - expect(body_as_json) + expect(response.parsed_body) .to be_an(Enumerable) .and have_attributes( size: 2 @@ -141,7 +141,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do it 'returns JSON with correct data on previously cached requests' do # Initial request including multiple accounts in params get '/api/v1/accounts/relationships', headers: headers, params: { id: [simon.id, lewis.id] } - expect(body_as_json) + expect(response.parsed_body) .to have_attributes(size: 2) # Subsequent request with different id, should override cache from first request @@ -150,7 +150,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_an(Enumerable) .and have_attributes( size: 1 @@ -172,7 +172,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_an(Enumerable) .and contain_exactly( include( diff --git a/spec/requests/api/v1/accounts/statuses_spec.rb b/spec/requests/api/v1/accounts/statuses_spec.rb index 4a4d9383db..e056a78901 100644 --- a/spec/requests/api/v1/accounts/statuses_spec.rb +++ b/spec/requests/api/v1/accounts/statuses_spec.rb @@ -41,7 +41,7 @@ RSpec.describe 'API V1 Accounts Statuses' do it 'returns posts along with self replies', :aggregate_failures do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to have_attributes(size: 2) .and contain_exactly( include(id: status.id.to_s), @@ -102,7 +102,7 @@ RSpec.describe 'API V1 Accounts Statuses' do it 'lists the public status only' do get "/api/v1/accounts/#{account.id}/statuses", params: { pinned: true }, headers: headers - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly( a_hash_including(id: status.id.to_s) ) @@ -117,7 +117,7 @@ RSpec.describe 'API V1 Accounts Statuses' do it 'lists both the public and the private statuses' do get "/api/v1/accounts/#{account.id}/statuses", params: { pinned: true }, headers: headers - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly( a_hash_including(id: status.id.to_s), a_hash_including(id: private_status.id.to_s) diff --git a/spec/requests/api/v1/accounts_spec.rb b/spec/requests/api/v1/accounts_spec.rb index e31644352b..2ebe56fa7d 100644 --- a/spec/requests/api/v1/accounts_spec.rb +++ b/spec/requests/api/v1/accounts_spec.rb @@ -17,7 +17,7 @@ RSpec.describe '/api/v1/accounts' do get '/api/v1/accounts', headers: headers, params: { id: [account.id, other_account.id, 123_123] } expect(response).to have_http_status(200) - expect(body_as_json).to contain_exactly( + expect(response.parsed_body).to contain_exactly( hash_including(id: account.id.to_s), hash_including(id: other_account.id.to_s) ) @@ -32,7 +32,7 @@ RSpec.describe '/api/v1/accounts' do get "/api/v1/accounts/#{account.id}" expect(response).to have_http_status(200) - expect(body_as_json[:id]).to eq(account.id.to_s) + expect(response.parsed_body[:id]).to eq(account.id.to_s) end end @@ -41,7 +41,7 @@ RSpec.describe '/api/v1/accounts' do get '/api/v1/accounts/1' expect(response).to have_http_status(404) - expect(body_as_json[:error]).to eq('Record not found') + expect(response.parsed_body[:error]).to eq('Record not found') end end @@ -57,7 +57,7 @@ RSpec.describe '/api/v1/accounts' do subject expect(response).to have_http_status(200) - expect(body_as_json[:id]).to eq(account.id.to_s) + expect(response.parsed_body[:id]).to eq(account.id.to_s) end it_behaves_like 'forbidden for wrong scope', 'write:statuses' @@ -80,7 +80,7 @@ RSpec.describe '/api/v1/accounts' do subject expect(response).to have_http_status(200) - expect(body_as_json[:access_token]).to_not be_blank + expect(response.parsed_body[:access_token]).to_not be_blank user = User.find_by(email: 'hello@world.tld') expect(user).to_not be_nil @@ -114,7 +114,7 @@ RSpec.describe '/api/v1/accounts' do expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( following: true, requested: false @@ -134,7 +134,7 @@ RSpec.describe '/api/v1/accounts' do expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( following: false, requested: true @@ -157,7 +157,7 @@ RSpec.describe '/api/v1/accounts' do it 'changes reblogs option' do post "/api/v1/accounts/#{other_account.id}/follow", headers: headers, params: { reblogs: true } - expect(body_as_json).to include({ + expect(response.parsed_body).to include({ following: true, showing_reblogs: true, notifying: false, @@ -167,7 +167,7 @@ RSpec.describe '/api/v1/accounts' do it 'changes notify option' do post "/api/v1/accounts/#{other_account.id}/follow", headers: headers, params: { notify: true } - expect(body_as_json).to include({ + expect(response.parsed_body).to include({ following: true, showing_reblogs: false, notifying: true, @@ -177,7 +177,7 @@ RSpec.describe '/api/v1/accounts' do it 'changes languages option' do post "/api/v1/accounts/#{other_account.id}/follow", headers: headers, params: { languages: %w(en es) } - expect(body_as_json).to include({ + expect(response.parsed_body).to include({ following: true, showing_reblogs: false, notifying: false, diff --git a/spec/requests/api/v1/admin/accounts_spec.rb b/spec/requests/api/v1/admin/accounts_spec.rb index 1615581f0e..2dc45d5eb2 100644 --- a/spec/requests/api/v1/admin/accounts_spec.rb +++ b/spec/requests/api/v1/admin/accounts_spec.rb @@ -19,7 +19,7 @@ RSpec.describe 'Accounts' do subject expect(response).to have_http_status(200) - expect(body_as_json.pluck(:id)).to match_array(expected_results.map { |a| a.id.to_s }) + expect(response.parsed_body.pluck(:id)).to match_array(expected_results.map { |a| a.id.to_s }) end end @@ -93,7 +93,7 @@ RSpec.describe 'Accounts' do subject expect(response).to have_http_status(200) - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end end @@ -112,7 +112,7 @@ RSpec.describe 'Accounts' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: account.id.to_s, username: account.username, email: account.user.email) ) end diff --git a/spec/requests/api/v1/admin/canonical_email_blocks_spec.rb b/spec/requests/api/v1/admin/canonical_email_blocks_spec.rb index 0cddf2c69e..dd7e119911 100644 --- a/spec/requests/api/v1/admin/canonical_email_blocks_spec.rb +++ b/spec/requests/api/v1/admin/canonical_email_blocks_spec.rb @@ -30,7 +30,7 @@ RSpec.describe 'Canonical Email Blocks' do it 'returns an empty list' do subject - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty end end @@ -41,7 +41,7 @@ RSpec.describe 'Canonical Email Blocks' do it 'returns the correct canonical email hashes' do subject - expect(body_as_json.pluck(:canonical_email_hash)).to match_array(expected_email_hashes) + expect(response.parsed_body.pluck(:canonical_email_hash)).to match_array(expected_email_hashes) end context 'with limit param' do @@ -50,7 +50,7 @@ RSpec.describe 'Canonical Email Blocks' do it 'returns only the requested number of canonical email blocks' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end @@ -62,7 +62,7 @@ RSpec.describe 'Canonical Email Blocks' do canonical_email_blocks_ids = canonical_email_blocks.pluck(:id).map(&:to_s) - expect(body_as_json.pluck(:id)).to match_array(canonical_email_blocks_ids[2..]) + expect(response.parsed_body.pluck(:id)).to match_array(canonical_email_blocks_ids[2..]) end end @@ -74,7 +74,7 @@ RSpec.describe 'Canonical Email Blocks' do canonical_email_blocks_ids = canonical_email_blocks.pluck(:id).map(&:to_s) - expect(body_as_json.pluck(:id)).to match_array(canonical_email_blocks_ids[..2]) + expect(response.parsed_body.pluck(:id)).to match_array(canonical_email_blocks_ids[..2]) end end end @@ -96,7 +96,7 @@ RSpec.describe 'Canonical Email Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( id: eq(canonical_email_block.id.to_s), canonical_email_hash: eq(canonical_email_block.canonical_email_hash) @@ -142,7 +142,7 @@ RSpec.describe 'Canonical Email Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json[0][:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash) + expect(response.parsed_body.first[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash) end end @@ -151,7 +151,7 @@ RSpec.describe 'Canonical Email Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty end end end @@ -173,7 +173,7 @@ RSpec.describe 'Canonical Email Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash) + expect(response.parsed_body[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash) end context 'when the required email param is not provided' do @@ -193,7 +193,7 @@ RSpec.describe 'Canonical Email Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json[:canonical_email_hash]).to eq(params[:canonical_email_hash]) + expect(response.parsed_body[:canonical_email_hash]).to eq(params[:canonical_email_hash]) end end @@ -204,7 +204,7 @@ RSpec.describe 'Canonical Email Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash) + expect(response.parsed_body[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash) end end diff --git a/spec/requests/api/v1/admin/dimensions_spec.rb b/spec/requests/api/v1/admin/dimensions_spec.rb index 43e2db00c5..a28c2a9e3e 100644 --- a/spec/requests/api/v1/admin/dimensions_spec.rb +++ b/spec/requests/api/v1/admin/dimensions_spec.rb @@ -27,7 +27,7 @@ RSpec.describe 'Admin Dimensions' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_an(Array) end end diff --git a/spec/requests/api/v1/admin/domain_allows_spec.rb b/spec/requests/api/v1/admin/domain_allows_spec.rb index b8f0b0055c..26c962b347 100644 --- a/spec/requests/api/v1/admin/domain_allows_spec.rb +++ b/spec/requests/api/v1/admin/domain_allows_spec.rb @@ -30,7 +30,7 @@ RSpec.describe 'Domain Allows' do it 'returns an empty body' do subject - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty end end @@ -49,7 +49,7 @@ RSpec.describe 'Domain Allows' do it 'returns the correct allowed domains' do subject - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end context 'with limit param' do @@ -58,7 +58,7 @@ RSpec.describe 'Domain Allows' do it 'returns only the requested number of allowed domains' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end end @@ -79,7 +79,7 @@ RSpec.describe 'Domain Allows' do subject expect(response).to have_http_status(200) - expect(body_as_json[:domain]).to eq domain_allow.domain + expect(response.parsed_body[:domain]).to eq domain_allow.domain end context 'when the requested allowed domain does not exist' do @@ -107,7 +107,7 @@ RSpec.describe 'Domain Allows' do subject expect(response).to have_http_status(200) - expect(body_as_json[:domain]).to eq 'foo.bar.com' + expect(response.parsed_body[:domain]).to eq 'foo.bar.com' expect(DomainAllow.find_by(domain: 'foo.bar.com')).to be_present end end @@ -140,7 +140,7 @@ RSpec.describe 'Domain Allows' do it 'returns the existing allowed domain name' do subject - expect(body_as_json[:domain]).to eq(params[:domain]) + expect(response.parsed_body[:domain]).to eq(params[:domain]) end end end diff --git a/spec/requests/api/v1/admin/domain_blocks_spec.rb b/spec/requests/api/v1/admin/domain_blocks_spec.rb index 7f7b9aa48a..3f2cbbf113 100644 --- a/spec/requests/api/v1/admin/domain_blocks_spec.rb +++ b/spec/requests/api/v1/admin/domain_blocks_spec.rb @@ -30,7 +30,7 @@ RSpec.describe 'Domain Blocks' do it 'returns an empty list' do subject - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty end end @@ -64,7 +64,7 @@ RSpec.describe 'Domain Blocks' do it 'returns the expected domain blocks' do subject - expect(body_as_json).to match_array(expected_responde) + expect(response.parsed_body).to match_array(expected_responde) end context 'with limit param' do @@ -73,7 +73,7 @@ RSpec.describe 'Domain Blocks' do it 'returns only the requested number of domain blocks' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end end @@ -94,19 +94,17 @@ RSpec.describe 'Domain Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match( - { - id: domain_block.id.to_s, - domain: domain_block.domain, - digest: domain_block.domain_digest, - created_at: domain_block.created_at.strftime('%Y-%m-%dT%H:%M:%S.%LZ'), - severity: domain_block.severity.to_s, - reject_media: domain_block.reject_media, - reject_reports: domain_block.reject_reports, - private_comment: domain_block.private_comment, - public_comment: domain_block.public_comment, - obfuscate: domain_block.obfuscate, - } + expect(response.parsed_body).to match( + id: domain_block.id.to_s, + domain: domain_block.domain, + digest: domain_block.domain_digest, + created_at: domain_block.created_at.strftime('%Y-%m-%dT%H:%M:%S.%LZ'), + severity: domain_block.severity.to_s, + reject_media: domain_block.reject_media, + reject_reports: domain_block.reject_reports, + private_comment: domain_block.private_comment, + public_comment: domain_block.public_comment, + obfuscate: domain_block.obfuscate ) end @@ -134,7 +132,7 @@ RSpec.describe 'Domain Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match a_hash_including( + expect(response.parsed_body).to match a_hash_including( { domain: 'foo.bar.com', severity: 'silence', @@ -155,7 +153,7 @@ RSpec.describe 'Domain Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match a_hash_including( + expect(response.parsed_body).to match a_hash_including( { domain: 'foo.bar.com', severity: 'suspend', @@ -175,7 +173,7 @@ RSpec.describe 'Domain Blocks' do subject expect(response).to have_http_status(422) - expect(body_as_json[:existing_domain_block][:domain]).to eq('foo.bar.com') + expect(response.parsed_body[:existing_domain_block][:domain]).to eq('foo.bar.com') end end @@ -188,7 +186,7 @@ RSpec.describe 'Domain Blocks' do subject expect(response).to have_http_status(422) - expect(body_as_json[:existing_domain_block][:domain]).to eq('bar.com') + expect(response.parsed_body[:existing_domain_block][:domain]).to eq('bar.com') end end @@ -219,7 +217,7 @@ RSpec.describe 'Domain Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match a_hash_including( + expect(response.parsed_body).to match a_hash_including( { id: domain_block.id.to_s, domain: domain_block.domain, diff --git a/spec/requests/api/v1/admin/email_domain_blocks_spec.rb b/spec/requests/api/v1/admin/email_domain_blocks_spec.rb index 16656e0202..aa3073341a 100644 --- a/spec/requests/api/v1/admin/email_domain_blocks_spec.rb +++ b/spec/requests/api/v1/admin/email_domain_blocks_spec.rb @@ -31,7 +31,7 @@ RSpec.describe 'Email Domain Blocks' do it 'returns an empty list' do subject - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty end end @@ -42,7 +42,7 @@ RSpec.describe 'Email Domain Blocks' do it 'return the correct blocked email domains' do subject - expect(body_as_json.pluck(:domain)).to match_array(blocked_email_domains) + expect(response.parsed_body.pluck(:domain)).to match_array(blocked_email_domains) end context 'with limit param' do @@ -51,7 +51,7 @@ RSpec.describe 'Email Domain Blocks' do it 'returns only the requested number of email domain blocks' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end @@ -63,7 +63,7 @@ RSpec.describe 'Email Domain Blocks' do email_domain_blocks_ids = email_domain_blocks.pluck(:id).map(&:to_s) - expect(body_as_json.pluck(:id)).to match_array(email_domain_blocks_ids[2..]) + expect(response.parsed_body.pluck(:id)).to match_array(email_domain_blocks_ids[2..]) end end @@ -75,7 +75,7 @@ RSpec.describe 'Email Domain Blocks' do email_domain_blocks_ids = email_domain_blocks.pluck(:id).map(&:to_s) - expect(body_as_json.pluck(:id)).to match_array(email_domain_blocks_ids[..2]) + expect(response.parsed_body.pluck(:id)).to match_array(email_domain_blocks_ids[..2]) end end end @@ -97,7 +97,7 @@ RSpec.describe 'Email Domain Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json[:domain]).to eq(email_domain_block.domain) + expect(response.parsed_body[:domain]).to eq(email_domain_block.domain) end end @@ -125,7 +125,7 @@ RSpec.describe 'Email Domain Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json[:domain]).to eq(params[:domain]) + expect(response.parsed_body[:domain]).to eq(params[:domain]) end context 'when domain param is not provided' do @@ -176,7 +176,7 @@ RSpec.describe 'Email Domain Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty expect(EmailDomainBlock.find_by(id: email_domain_block.id)).to be_nil end diff --git a/spec/requests/api/v1/admin/ip_blocks_spec.rb b/spec/requests/api/v1/admin/ip_blocks_spec.rb index bd4015b2d9..b18f8f885c 100644 --- a/spec/requests/api/v1/admin/ip_blocks_spec.rb +++ b/spec/requests/api/v1/admin/ip_blocks_spec.rb @@ -30,7 +30,7 @@ RSpec.describe 'IP Blocks' do it 'returns an empty body' do subject - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty end end @@ -58,7 +58,7 @@ RSpec.describe 'IP Blocks' do it 'returns the correct blocked ips' do subject - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end context 'with limit param' do @@ -67,7 +67,7 @@ RSpec.describe 'IP Blocks' do it 'returns only the requested number of ip blocks' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end end @@ -89,7 +89,7 @@ RSpec.describe 'IP Blocks' do expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( ip: eq("#{ip_block.ip}/#{ip_block.ip.prefix}"), severity: eq(ip_block.severity.to_s) @@ -120,7 +120,7 @@ RSpec.describe 'IP Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( ip: eq("#{params[:ip]}/32"), severity: eq(params[:severity]), @@ -185,7 +185,7 @@ RSpec.describe 'IP Blocks' do .and change_comment_value expect(response).to have_http_status(200) - expect(body_as_json).to match(hash_including({ + expect(response.parsed_body).to match(hash_including({ ip: "#{ip_block.ip}/#{ip_block.ip.prefix}", severity: 'sign_up_requires_approval', comment: 'Decreasing severity', @@ -220,7 +220,7 @@ RSpec.describe 'IP Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty expect(IpBlock.find_by(id: ip_block.id)).to be_nil end diff --git a/spec/requests/api/v1/admin/measures_spec.rb b/spec/requests/api/v1/admin/measures_spec.rb index 56a2c1eaee..de359a5ccd 100644 --- a/spec/requests/api/v1/admin/measures_spec.rb +++ b/spec/requests/api/v1/admin/measures_spec.rb @@ -44,7 +44,7 @@ RSpec.describe 'Admin Measures' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_an(Array) end end diff --git a/spec/requests/api/v1/admin/reports_spec.rb b/spec/requests/api/v1/admin/reports_spec.rb index 4b0b7e1713..2c40f56dc8 100644 --- a/spec/requests/api/v1/admin/reports_spec.rb +++ b/spec/requests/api/v1/admin/reports_spec.rb @@ -29,7 +29,7 @@ RSpec.describe 'Reports' do it 'returns an empty list' do subject - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty end end @@ -64,7 +64,7 @@ RSpec.describe 'Reports' do it 'returns all unresolved reports' do subject - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end context 'with resolved param' do @@ -74,7 +74,7 @@ RSpec.describe 'Reports' do it 'returns only the resolved reports' do subject - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end end @@ -85,7 +85,7 @@ RSpec.describe 'Reports' do it 'returns all unresolved reports filed by the specified account' do subject - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end end @@ -96,7 +96,7 @@ RSpec.describe 'Reports' do it 'returns all unresolved reports targeting the specified account' do subject - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end end @@ -106,7 +106,7 @@ RSpec.describe 'Reports' do it 'returns only the requested number of reports' do subject - expect(body_as_json.size).to eq(1) + expect(response.parsed_body.size).to eq(1) end end end @@ -126,7 +126,7 @@ RSpec.describe 'Reports' do subject expect(response).to have_http_status(200) - expect(body_as_json).to include( + expect(response.parsed_body).to include( { id: report.id.to_s, action_taken: report.action_taken?, @@ -159,7 +159,7 @@ RSpec.describe 'Reports' do report.reload - expect(body_as_json).to include( + expect(response.parsed_body).to include( { id: report.id.to_s, action_taken: report.action_taken?, diff --git a/spec/requests/api/v1/admin/retention_spec.rb b/spec/requests/api/v1/admin/retention_spec.rb index 138959a0ab..c28fa6de81 100644 --- a/spec/requests/api/v1/admin/retention_spec.rb +++ b/spec/requests/api/v1/admin/retention_spec.rb @@ -27,7 +27,7 @@ RSpec.describe 'Admin Retention' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_an(Array) end end diff --git a/spec/requests/api/v1/admin/tags_spec.rb b/spec/requests/api/v1/admin/tags_spec.rb index 031be17f52..2f730cdeb8 100644 --- a/spec/requests/api/v1/admin/tags_spec.rb +++ b/spec/requests/api/v1/admin/tags_spec.rb @@ -30,7 +30,7 @@ RSpec.describe 'Tags' do it 'returns an empty list' do subject - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty end end @@ -47,7 +47,7 @@ RSpec.describe 'Tags' do it 'returns the expected tags' do subject tags.each do |tag| - expect(body_as_json.find { |item| item[:id] == tag.id.to_s && item[:name] == tag.name }).to_not be_nil + expect(response.parsed_body.find { |item| item[:id] == tag.id.to_s && item[:name] == tag.name }).to_not be_nil end end @@ -57,7 +57,7 @@ RSpec.describe 'Tags' do it 'returns only the requested number of tags' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end end @@ -82,8 +82,8 @@ RSpec.describe 'Tags' do it 'returns expected tag content' do subject - expect(body_as_json[:id].to_i).to eq(tag.id) - expect(body_as_json[:name]).to eq(tag.name) + expect(response.parsed_body[:id].to_i).to eq(tag.id) + expect(response.parsed_body[:name]).to eq(tag.name) end context 'when the requested tag does not exist' do @@ -116,8 +116,8 @@ RSpec.describe 'Tags' do it 'returns updated tag' do subject - expect(body_as_json[:id].to_i).to eq(tag.id) - expect(body_as_json[:name]).to eq(tag.name.upcase) + expect(response.parsed_body[:id].to_i).to eq(tag.id) + expect(response.parsed_body[:name]).to eq(tag.name.upcase) end context 'when the updated display name is invalid' do 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 082af785ab..c436b7081e 100644 --- a/spec/requests/api/v1/admin/trends/links/links_spec.rb +++ b/spec/requests/api/v1/admin/trends/links/links_spec.rb @@ -44,7 +44,7 @@ RSpec.describe 'Links' do end def expects_correct_link_data - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including( url: preview_card.url, title: preview_card.title, @@ -98,7 +98,7 @@ RSpec.describe 'Links' do it 'returns the link data' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including( url: preview_card.url, title: preview_card.title, diff --git a/spec/requests/api/v1/annual_reports_spec.rb b/spec/requests/api/v1/annual_reports_spec.rb index bab184787f..8051a65484 100644 --- a/spec/requests/api/v1/annual_reports_spec.rb +++ b/spec/requests/api/v1/annual_reports_spec.rb @@ -34,7 +34,7 @@ RSpec.describe 'API V1 Annual Reports' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present end end diff --git a/spec/requests/api/v1/apps/credentials_spec.rb b/spec/requests/api/v1/apps/credentials_spec.rb index b899999640..1cd6a4178f 100644 --- a/spec/requests/api/v1/apps/credentials_spec.rb +++ b/spec/requests/api/v1/apps/credentials_spec.rb @@ -18,7 +18,7 @@ RSpec.describe 'Credentials' do expect(response).to have_http_status(200) - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including( id: token.application.id.to_s, name: token.application.name, @@ -37,8 +37,8 @@ RSpec.describe 'Credentials' do expect(response).to have_http_status(200) - expect(body_as_json[:client_id]).to_not be_present - expect(body_as_json[:client_secret]).to_not be_present + expect(response.parsed_body[:client_id]).to_not be_present + expect(response.parsed_body[:client_secret]).to_not be_present end end @@ -56,7 +56,7 @@ RSpec.describe 'Credentials' do it 'returns the app information correctly' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including( id: token.application.id.to_s, name: token.application.name, @@ -95,7 +95,7 @@ RSpec.describe 'Credentials' do it 'returns the error in the json response' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including( error: 'The access token was revoked' ) @@ -117,7 +117,7 @@ RSpec.describe 'Credentials' do it 'returns the error in the json response' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including( error: 'The access token is invalid' ) diff --git a/spec/requests/api/v1/apps_spec.rb b/spec/requests/api/v1/apps_spec.rb index 81d6c68126..51a0c3fd0c 100644 --- a/spec/requests/api/v1/apps_spec.rb +++ b/spec/requests/api/v1/apps_spec.rb @@ -35,7 +35,7 @@ RSpec.describe 'Apps' do expect(app.scopes.to_s).to eq scopes expect(app.redirect_uris).to eq redirect_uris - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including( id: app.id.to_s, client_id: app.uid, @@ -61,7 +61,7 @@ RSpec.describe 'Apps' do expect(response).to have_http_status(200) expect(Doorkeeper::Application.find_by(name: client_name)).to be_present - expect(body_as_json) + expect(response.parsed_body) .to include( scopes: Doorkeeper.config.default_scopes.to_a ) @@ -82,7 +82,7 @@ RSpec.describe 'Apps' do expect(app).to be_present expect(app.scopes.to_s).to eq 'read' - expect(body_as_json) + expect(response.parsed_body) .to include( scopes: %w(read) ) @@ -165,7 +165,7 @@ RSpec.describe 'Apps' do expect(app.redirect_uri).to eq redirect_uris expect(app.redirect_uris).to eq redirect_uris.split - expect(body_as_json) + expect(response.parsed_body) .to include( redirect_uri: redirect_uris, redirect_uris: redirect_uris.split @@ -187,7 +187,7 @@ RSpec.describe 'Apps' do expect(app.redirect_uri).to eq redirect_uris.join "\n" expect(app.redirect_uris).to eq redirect_uris - expect(body_as_json) + expect(response.parsed_body) .to include( redirect_uri: redirect_uris.join("\n"), redirect_uris: redirect_uris diff --git a/spec/requests/api/v1/blocks_spec.rb b/spec/requests/api/v1/blocks_spec.rb index 06d2c4d997..d2f1c46a5b 100644 --- a/spec/requests/api/v1/blocks_spec.rb +++ b/spec/requests/api/v1/blocks_spec.rb @@ -26,7 +26,7 @@ RSpec.describe 'Blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end context 'with limit param' do @@ -35,7 +35,7 @@ RSpec.describe 'Blocks' do it 'returns only the requested number of blocked accounts' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end it 'sets correct link header pagination' do @@ -55,7 +55,7 @@ RSpec.describe 'Blocks' do it 'queries the blocks in range according to max_id', :aggregate_failures do subject - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly(include(id: blocks.first.target_account.id.to_s)) end end @@ -66,7 +66,7 @@ RSpec.describe 'Blocks' do it 'queries the blocks in range according to since_id', :aggregate_failures do subject - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly(include(id: blocks[2].target_account.id.to_s)) end end diff --git a/spec/requests/api/v1/bookmarks_spec.rb b/spec/requests/api/v1/bookmarks_spec.rb index dc32820c89..95a71abcac 100644 --- a/spec/requests/api/v1/bookmarks_spec.rb +++ b/spec/requests/api/v1/bookmarks_spec.rb @@ -33,7 +33,7 @@ RSpec.describe 'Bookmarks' do it 'returns the bookmarked statuses' do subject - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end context 'with limit param' do @@ -42,7 +42,7 @@ RSpec.describe 'Bookmarks' do it 'paginates correctly', :aggregate_failures do subject - expect(body_as_json.size) + expect(response.parsed_body.size) .to eq(params[:limit]) expect(response) diff --git a/spec/requests/api/v1/conversations_spec.rb b/spec/requests/api/v1/conversations_spec.rb index f136e1f4e8..bd3cbfd0e7 100644 --- a/spec/requests/api/v1/conversations_spec.rb +++ b/spec/requests/api/v1/conversations_spec.rb @@ -31,8 +31,8 @@ RSpec.describe 'API V1 Conversations' do it 'returns conversations', :aggregate_failures do get '/api/v1/conversations', headers: headers - expect(body_as_json.size).to eq 2 - expect(body_as_json[0][:accounts].size).to eq 1 + expect(response.parsed_body.size).to eq 2 + expect(response.parsed_body.first[:accounts].size).to eq 1 end context 'with since_id' do @@ -40,7 +40,7 @@ RSpec.describe 'API V1 Conversations' do it 'returns conversations' do get '/api/v1/conversations', params: { since_id: Mastodon::Snowflake.id_at(1.hour.ago, with_random: false) }, headers: headers - expect(body_as_json.size).to eq 2 + expect(response.parsed_body.size).to eq 2 end end @@ -48,7 +48,7 @@ RSpec.describe 'API V1 Conversations' do it 'returns no conversation' do get '/api/v1/conversations', params: { since_id: Mastodon::Snowflake.id_at(1.hour.from_now, with_random: false) }, headers: headers - expect(body_as_json.size).to eq 0 + expect(response.parsed_body.size).to eq 0 end end end diff --git a/spec/requests/api/v1/custom_emojis_spec.rb b/spec/requests/api/v1/custom_emojis_spec.rb index 798d8e29ed..0942734ff3 100644 --- a/spec/requests/api/v1/custom_emojis_spec.rb +++ b/spec/requests/api/v1/custom_emojis_spec.rb @@ -19,7 +19,7 @@ RSpec.describe 'Custom Emojis' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and have_attributes( first: include(shortcode: 'coolcat') @@ -34,7 +34,7 @@ RSpec.describe 'Custom Emojis' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and have_attributes( first: include(shortcode: 'coolcat') diff --git a/spec/requests/api/v1/directories_spec.rb b/spec/requests/api/v1/directories_spec.rb index 94306c06ec..aa602a71cd 100644 --- a/spec/requests/api/v1/directories_spec.rb +++ b/spec/requests/api/v1/directories_spec.rb @@ -82,8 +82,8 @@ RSpec.describe 'Directories API' do get '/api/v1/directory', headers: headers expect(response).to have_http_status(200) - expect(body_as_json.size).to eq(2) - expect(body_as_json.pluck(:id)).to contain_exactly(eligible_remote_account.id.to_s, local_discoverable_account.id.to_s) + expect(response.parsed_body.size).to eq(2) + expect(response.parsed_body.pluck(:id)).to contain_exactly(eligible_remote_account.id.to_s, local_discoverable_account.id.to_s) end end @@ -101,8 +101,8 @@ RSpec.describe 'Directories API' do get '/api/v1/directory', headers: headers, params: { local: '1' } expect(response).to have_http_status(200) - expect(body_as_json.size).to eq(1) - expect(body_as_json.first[:id]).to include(local_account.id.to_s) + expect(response.parsed_body.size).to eq(1) + expect(response.parsed_body.first[:id]).to include(local_account.id.to_s) expect(response.body).to_not include(remote_account.id.to_s) end end @@ -115,9 +115,9 @@ RSpec.describe 'Directories API' do get '/api/v1/directory', headers: headers, params: { order: 'active' } expect(response).to have_http_status(200) - expect(body_as_json.size).to eq(2) - expect(body_as_json.first[:id]).to include(new_stat.account_id.to_s) - expect(body_as_json.second[:id]).to include(old_stat.account_id.to_s) + expect(response.parsed_body.size).to eq(2) + expect(response.parsed_body.first[:id]).to include(new_stat.account_id.to_s) + expect(response.parsed_body.second[:id]).to include(old_stat.account_id.to_s) end end @@ -130,9 +130,9 @@ RSpec.describe 'Directories API' do get '/api/v1/directory', headers: headers, params: { order: 'new' } expect(response).to have_http_status(200) - expect(body_as_json.size).to eq(2) - expect(body_as_json.first[:id]).to include(account_new.id.to_s) - expect(body_as_json.second[:id]).to include(account_old.id.to_s) + expect(response.parsed_body.size).to eq(2) + expect(response.parsed_body.first[:id]).to include(account_new.id.to_s) + expect(response.parsed_body.second[:id]).to include(account_old.id.to_s) end end end diff --git a/spec/requests/api/v1/domain_blocks_spec.rb b/spec/requests/api/v1/domain_blocks_spec.rb index 954497ebe1..8184c26bed 100644 --- a/spec/requests/api/v1/domain_blocks_spec.rb +++ b/spec/requests/api/v1/domain_blocks_spec.rb @@ -26,7 +26,7 @@ RSpec.describe 'Domain blocks' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match_array(blocked_domains) + expect(response.parsed_body).to match_array(blocked_domains) end context 'with limit param' do @@ -35,7 +35,7 @@ RSpec.describe 'Domain blocks' do it 'returns only the requested number of blocked domains' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end end diff --git a/spec/requests/api/v1/emails/confirmations_spec.rb b/spec/requests/api/v1/emails/confirmations_spec.rb index 8f5171ee78..0a419a10cf 100644 --- a/spec/requests/api/v1/emails/confirmations_spec.rb +++ b/spec/requests/api/v1/emails/confirmations_spec.rb @@ -111,7 +111,7 @@ RSpec.describe 'Confirmations' do subject expect(response).to have_http_status(200) - expect(body_as_json).to be false + expect(response.parsed_body).to be false end end @@ -122,7 +122,7 @@ RSpec.describe 'Confirmations' do subject expect(response).to have_http_status(200) - expect(body_as_json).to be true + expect(response.parsed_body).to be true end end end @@ -139,7 +139,7 @@ RSpec.describe 'Confirmations' do subject expect(response).to have_http_status(200) - expect(body_as_json).to be false + expect(response.parsed_body).to be false end end @@ -150,7 +150,7 @@ RSpec.describe 'Confirmations' do subject expect(response).to have_http_status(200) - expect(body_as_json).to be true + expect(response.parsed_body).to be true end end end diff --git a/spec/requests/api/v1/endorsements_spec.rb b/spec/requests/api/v1/endorsements_spec.rb index 255211a404..25917f527a 100644 --- a/spec/requests/api/v1/endorsements_spec.rb +++ b/spec/requests/api/v1/endorsements_spec.rb @@ -37,7 +37,7 @@ RSpec.describe 'Endorsements' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and have_attributes( first: include(acct: account_pin.target_account.acct) @@ -52,7 +52,7 @@ RSpec.describe 'Endorsements' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to_not be_present end end diff --git a/spec/requests/api/v1/favourites_spec.rb b/spec/requests/api/v1/favourites_spec.rb index b988ac99db..78e9d61551 100644 --- a/spec/requests/api/v1/favourites_spec.rb +++ b/spec/requests/api/v1/favourites_spec.rb @@ -33,7 +33,7 @@ RSpec.describe 'Favourites' do it 'returns the favourites' do subject - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end context 'with limit param' do @@ -42,7 +42,7 @@ RSpec.describe 'Favourites' do it 'returns only the requested number of favourites' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end it 'sets the correct pagination headers' do diff --git a/spec/requests/api/v1/featured_tags/suggestions_spec.rb b/spec/requests/api/v1/featured_tags/suggestions_spec.rb index 0a7bfe5cda..8815c65cf1 100644 --- a/spec/requests/api/v1/featured_tags/suggestions_spec.rb +++ b/spec/requests/api/v1/featured_tags/suggestions_spec.rb @@ -32,7 +32,7 @@ RSpec.describe 'Featured Tags Suggestions API' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly( include(name: used_tag.name) ) diff --git a/spec/requests/api/v1/featured_tags_spec.rb b/spec/requests/api/v1/featured_tags_spec.rb index 81e99e015b..423cc0c560 100644 --- a/spec/requests/api/v1/featured_tags_spec.rb +++ b/spec/requests/api/v1/featured_tags_spec.rb @@ -37,7 +37,7 @@ RSpec.describe 'FeaturedTags' do it 'returns an empty body' do get '/api/v1/featured_tags', headers: headers - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty end end @@ -47,7 +47,7 @@ RSpec.describe 'FeaturedTags' do it 'returns only the featured tags belonging to the requesting user' do get '/api/v1/featured_tags', headers: headers - expect(body_as_json.pluck(:id)) + expect(response.parsed_body.pluck(:id)) .to match_array( user_featured_tags.pluck(:id).map(&:to_s) ) @@ -67,7 +67,7 @@ RSpec.describe 'FeaturedTags' do it 'returns the correct tag name' do post '/api/v1/featured_tags', headers: headers, params: params - expect(body_as_json) + expect(response.parsed_body) .to include( name: params[:name] ) @@ -141,7 +141,7 @@ RSpec.describe 'FeaturedTags' do it 'returns an empty body' do delete "/api/v1/featured_tags/#{id}", headers: headers - expect(body_as_json).to be_empty + expect(response.parsed_body).to be_empty end it 'deletes the featured tag', :inline_jobs do diff --git a/spec/requests/api/v1/filters_spec.rb b/spec/requests/api/v1/filters_spec.rb index deb6e74217..93ed78b346 100644 --- a/spec/requests/api/v1/filters_spec.rb +++ b/spec/requests/api/v1/filters_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'API V1 Filters' do it 'returns http success' do get '/api/v1/filters', headers: headers expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly( include(id: custom_filter_keyword.id.to_s) ) diff --git a/spec/requests/api/v1/follow_requests_spec.rb b/spec/requests/api/v1/follow_requests_spec.rb index a8898ccb3e..c143ccaec1 100644 --- a/spec/requests/api/v1/follow_requests_spec.rb +++ b/spec/requests/api/v1/follow_requests_spec.rb @@ -36,7 +36,7 @@ RSpec.describe 'Follow requests' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end context 'with limit param' do @@ -45,7 +45,7 @@ RSpec.describe 'Follow requests' do it 'returns only the requested number of follow requests' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end end @@ -66,7 +66,7 @@ RSpec.describe 'Follow requests' do it 'allows the requesting follower to follow', :aggregate_failures do expect { subject }.to change { follower.following?(user.account) }.from(false).to(true) expect(response).to have_http_status(200) - expect(body_as_json[:followed_by]).to be true + expect(response.parsed_body[:followed_by]).to be true end end @@ -88,7 +88,7 @@ RSpec.describe 'Follow requests' do expect(response).to have_http_status(200) expect(FollowRequest.where(target_account: user.account, account: follower)).to_not exist - expect(body_as_json[:followed_by]).to be false + expect(response.parsed_body[:followed_by]).to be false end end end diff --git a/spec/requests/api/v1/followed_tags_spec.rb b/spec/requests/api/v1/followed_tags_spec.rb index 3d2d82d5db..f7787cb763 100644 --- a/spec/requests/api/v1/followed_tags_spec.rb +++ b/spec/requests/api/v1/followed_tags_spec.rb @@ -37,7 +37,7 @@ RSpec.describe 'Followed tags' do it 'returns the followed tags correctly' do subject - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end context 'with limit param' do @@ -46,7 +46,7 @@ RSpec.describe 'Followed tags' do it 'returns only the requested number of follow tags' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end it 'sets the correct pagination headers' do diff --git a/spec/requests/api/v1/instance_spec.rb b/spec/requests/api/v1/instance_spec.rb index e32d8acadb..42b6753bc3 100644 --- a/spec/requests/api/v1/instance_spec.rb +++ b/spec/requests/api/v1/instance_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Instances' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and include(title: 'Mastodon Glitch Edition') end @@ -28,7 +28,7 @@ RSpec.describe 'Instances' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and include(title: 'Mastodon Glitch Edition') end diff --git a/spec/requests/api/v1/instances/activity_spec.rb b/spec/requests/api/v1/instances/activity_spec.rb index 4f2bc91ad6..72e3faeb65 100644 --- a/spec/requests/api/v1/instances/activity_spec.rb +++ b/spec/requests/api/v1/instances/activity_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Activity' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and(be_an(Array)) .and(have_attributes(size: Api::V1::Instances::ActivityController::WEEKS_OF_ACTIVITY)) diff --git a/spec/requests/api/v1/instances/domain_blocks_spec.rb b/spec/requests/api/v1/instances/domain_blocks_spec.rb index 397ecff084..460d338607 100644 --- a/spec/requests/api/v1/instances/domain_blocks_spec.rb +++ b/spec/requests/api/v1/instances/domain_blocks_spec.rb @@ -17,7 +17,7 @@ RSpec.describe 'Domain Blocks' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and(be_an(Array)) .and(have_attributes(size: 1)) diff --git a/spec/requests/api/v1/instances/extended_descriptions_spec.rb b/spec/requests/api/v1/instances/extended_descriptions_spec.rb index 64982de686..bf6d58216a 100644 --- a/spec/requests/api/v1/instances/extended_descriptions_spec.rb +++ b/spec/requests/api/v1/instances/extended_descriptions_spec.rb @@ -10,7 +10,7 @@ RSpec.describe 'Extended Descriptions' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and include(:content) end diff --git a/spec/requests/api/v1/instances/languages_spec.rb b/spec/requests/api/v1/instances/languages_spec.rb index 8ab8bf99ce..79ea62c599 100644 --- a/spec/requests/api/v1/instances/languages_spec.rb +++ b/spec/requests/api/v1/instances/languages_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Languages' do end it 'returns the supported languages' do - expect(body_as_json.pluck(:code)).to match_array LanguagesHelper::SUPPORTED_LOCALES.keys.map(&:to_s) + expect(response.parsed_body.pluck(:code)).to match_array LanguagesHelper::SUPPORTED_LOCALES.keys.map(&:to_s) end end end diff --git a/spec/requests/api/v1/instances/peers_spec.rb b/spec/requests/api/v1/instances/peers_spec.rb index 1a7975f8b7..1140612f0a 100644 --- a/spec/requests/api/v1/instances/peers_spec.rb +++ b/spec/requests/api/v1/instances/peers_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Peers' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_an(Array) end end diff --git a/spec/requests/api/v1/instances/privacy_policies_spec.rb b/spec/requests/api/v1/instances/privacy_policies_spec.rb index 24de98d880..93490542cd 100644 --- a/spec/requests/api/v1/instances/privacy_policies_spec.rb +++ b/spec/requests/api/v1/instances/privacy_policies_spec.rb @@ -10,7 +10,7 @@ RSpec.describe 'Privacy Policy' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and include(:content) end diff --git a/spec/requests/api/v1/instances/rules_spec.rb b/spec/requests/api/v1/instances/rules_spec.rb index 65b8d78c7d..620c991ae2 100644 --- a/spec/requests/api/v1/instances/rules_spec.rb +++ b/spec/requests/api/v1/instances/rules_spec.rb @@ -10,7 +10,7 @@ RSpec.describe 'Rules' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_an(Array) end end diff --git a/spec/requests/api/v1/instances/translation_languages_spec.rb b/spec/requests/api/v1/instances/translation_languages_spec.rb index e5a480c175..0de5ec3bc2 100644 --- a/spec/requests/api/v1/instances/translation_languages_spec.rb +++ b/spec/requests/api/v1/instances/translation_languages_spec.rb @@ -11,7 +11,7 @@ RSpec.describe 'Translation Languages' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to eq({}) end end @@ -25,7 +25,7 @@ RSpec.describe 'Translation Languages' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to match({ und: %w(en de), en: ['de'] }) end diff --git a/spec/requests/api/v1/lists/accounts_spec.rb b/spec/requests/api/v1/lists/accounts_spec.rb index de49982351..d147b21ee7 100644 --- a/spec/requests/api/v1/lists/accounts_spec.rb +++ b/spec/requests/api/v1/lists/accounts_spec.rb @@ -34,7 +34,7 @@ RSpec.describe 'Accounts' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end context 'with limit param' do @@ -43,7 +43,7 @@ RSpec.describe 'Accounts' do it 'returns only the requested number of accounts' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end end diff --git a/spec/requests/api/v1/lists_spec.rb b/spec/requests/api/v1/lists_spec.rb index cf5ac28a56..2042a64d5c 100644 --- a/spec/requests/api/v1/lists_spec.rb +++ b/spec/requests/api/v1/lists_spec.rb @@ -43,7 +43,7 @@ RSpec.describe 'Lists' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end end @@ -60,7 +60,7 @@ RSpec.describe 'Lists' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match({ + expect(response.parsed_body).to match({ id: list.id.to_s, title: list.title, replies_policy: list.replies_policy, @@ -100,7 +100,7 @@ RSpec.describe 'Lists' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match(a_hash_including(title: 'my list', replies_policy: 'none', exclusive: true)) + expect(response.parsed_body).to match(a_hash_including(title: 'my list', replies_policy: 'none', exclusive: true)) expect(List.where(account: user.account).count).to eq(1) end @@ -144,7 +144,7 @@ RSpec.describe 'Lists' do expect(response).to have_http_status(200) list.reload - expect(body_as_json).to match({ + expect(response.parsed_body).to match({ id: list.id.to_s, title: list.title, replies_policy: list.replies_policy, diff --git a/spec/requests/api/v1/markers_spec.rb b/spec/requests/api/v1/markers_spec.rb index 2dbb9d205a..a10d2dc3e2 100644 --- a/spec/requests/api/v1/markers_spec.rb +++ b/spec/requests/api/v1/markers_spec.rb @@ -18,7 +18,7 @@ RSpec.describe 'API Markers' do it 'returns markers', :aggregate_failures do expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( home: include(last_read_id: '123'), notifications: include(last_read_id: '456') @@ -61,7 +61,7 @@ RSpec.describe 'API Markers' do it 'returns error json' do expect(response) .to have_http_status(409) - expect(body_as_json) + expect(response.parsed_body) .to include(error: /Conflict during update/) end end diff --git a/spec/requests/api/v1/media_spec.rb b/spec/requests/api/v1/media_spec.rb index c89c49afdf..d0af334825 100644 --- a/spec/requests/api/v1/media_spec.rb +++ b/spec/requests/api/v1/media_spec.rb @@ -26,7 +26,7 @@ RSpec.describe 'Media' do it 'returns the media information' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including( id: media.id.to_s, description: media.description, @@ -83,7 +83,7 @@ RSpec.describe 'Media' do expect(MediaAttachment.first).to be_present expect(MediaAttachment.first).to have_attached_file(:file) - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: MediaAttachment.first.id.to_s, description: params[:description], type: media_type) ) end diff --git a/spec/requests/api/v1/mutes_spec.rb b/spec/requests/api/v1/mutes_spec.rb index 988bb3c399..6402c908ff 100644 --- a/spec/requests/api/v1/mutes_spec.rb +++ b/spec/requests/api/v1/mutes_spec.rb @@ -29,7 +29,7 @@ RSpec.describe 'Mutes' do muted_accounts = mutes.map(&:target_account) - expect(body_as_json.pluck(:id)).to match_array(muted_accounts.map { |account| account.id.to_s }) + expect(response.parsed_body.pluck(:id)).to match_array(muted_accounts.map { |account| account.id.to_s }) end context 'with limit param' do @@ -38,7 +38,7 @@ RSpec.describe 'Mutes' do it 'returns only the requested number of muted accounts' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end it 'sets the correct pagination headers', :aggregate_failures do @@ -58,7 +58,7 @@ RSpec.describe 'Mutes' do it 'queries mutes in range according to max_id', :aggregate_failures do subject - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly(include(id: mutes.first.target_account_id.to_s)) end end @@ -69,7 +69,7 @@ RSpec.describe 'Mutes' do it 'queries mutes in range according to since_id', :aggregate_failures do subject - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly(include(id: mutes[1].target_account_id.to_s)) end end diff --git a/spec/requests/api/v1/notifications/policies_spec.rb b/spec/requests/api/v1/notifications/policies_spec.rb index a73d4217be..8bafcad2fe 100644 --- a/spec/requests/api/v1/notifications/policies_spec.rb +++ b/spec/requests/api/v1/notifications/policies_spec.rb @@ -26,7 +26,7 @@ RSpec.describe 'Policies' do subject expect(response).to have_http_status(200) - expect(body_as_json).to include( + expect(response.parsed_body).to include( filter_not_following: false, filter_not_followers: false, filter_new_accounts: false, @@ -54,7 +54,7 @@ RSpec.describe 'Policies' do .to change { NotificationPolicy.find_or_initialize_by(account: user.account).for_not_following.to_sym }.from(:accept).to(:filter) expect(response).to have_http_status(200) - expect(body_as_json).to include( + expect(response.parsed_body).to include( filter_not_following: true, filter_not_followers: false, filter_new_accounts: false, diff --git a/spec/requests/api/v1/notifications/requests_spec.rb b/spec/requests/api/v1/notifications/requests_spec.rb index 45bb71adb0..dc125bc7aa 100644 --- a/spec/requests/api/v1/notifications/requests_spec.rb +++ b/spec/requests/api/v1/notifications/requests_spec.rb @@ -133,7 +133,7 @@ RSpec.describe 'Requests' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match({ merged: true }) + expect(response.parsed_body).to match({ merged: true }) end end @@ -146,7 +146,7 @@ RSpec.describe 'Requests' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match({ merged: false }) + expect(response.parsed_body).to match({ merged: false }) end end end diff --git a/spec/requests/api/v1/notifications_spec.rb b/spec/requests/api/v1/notifications_spec.rb index 84e6db1e51..b74adb5dff 100644 --- a/spec/requests/api/v1/notifications_spec.rb +++ b/spec/requests/api/v1/notifications_spec.rb @@ -31,7 +31,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq 5 + expect(response.parsed_body[:count]).to eq 5 end end @@ -45,7 +45,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq 2 + expect(response.parsed_body[:count]).to eq 2 end end @@ -56,7 +56,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq 4 + expect(response.parsed_body[:count]).to eq 4 end end @@ -67,7 +67,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq 2 + expect(response.parsed_body[:count]).to eq 2 end end @@ -80,7 +80,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq Api::V1::NotificationsController::DEFAULT_NOTIFICATIONS_COUNT_LIMIT + expect(response.parsed_body[:count]).to eq Api::V1::NotificationsController::DEFAULT_NOTIFICATIONS_COUNT_LIMIT end end end @@ -111,9 +111,9 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json.size).to eq 5 + expect(response.parsed_body.size).to eq 5 expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow') - expect(body_as_json.any? { |x| x[:filtered] }).to be false + expect(response.parsed_body.any? { |x| x[:filtered] }).to be false end end @@ -124,9 +124,9 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json.size).to eq 6 + expect(response.parsed_body.size).to eq 6 expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow') - expect(body_as_json.any? { |x| x[:filtered] }).to be true + expect(response.parsed_body.any? { |x| x[:filtered] }).to be true end end @@ -141,7 +141,7 @@ RSpec.describe 'Notifications' do end def body_json_account_ids - body_as_json.map { |x| x[:account][:id] } + response.parsed_body.map { |x| x[:account][:id] } end end @@ -152,7 +152,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json.size).to eq 0 + expect(response.parsed_body.size).to eq 0 end end @@ -163,7 +163,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json.size).to_not eq 0 + expect(response.parsed_body.size).to_not eq 0 expect(body_json_types.uniq).to_not include 'mention' end end @@ -187,7 +187,7 @@ RSpec.describe 'Notifications' do notifications = user.account.notifications.browserable.order(id: :asc) - expect(body_as_json.size) + expect(response.parsed_body.size) .to eq(params[:limit]) expect(response) @@ -199,7 +199,7 @@ RSpec.describe 'Notifications' do end def body_json_types - body_as_json.pluck(:type) + response.parsed_body.pluck(:type) end end diff --git a/spec/requests/api/v1/peers/search_spec.rb b/spec/requests/api/v1/peers/search_spec.rb index 87b0dc4f64..dc5f550d0e 100644 --- a/spec/requests/api/v1/peers/search_spec.rb +++ b/spec/requests/api/v1/peers/search_spec.rb @@ -23,7 +23,7 @@ RSpec.describe 'API Peers Search' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_blank end end @@ -34,7 +34,7 @@ RSpec.describe 'API Peers Search' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_blank end end @@ -49,9 +49,9 @@ RSpec.describe 'API Peers Search' do expect(response) .to have_http_status(200) - expect(body_as_json.size) + expect(response.parsed_body.size) .to eq(1) - expect(body_as_json.first) + expect(response.parsed_body.first) .to eq(account.domain) end end diff --git a/spec/requests/api/v1/polls_spec.rb b/spec/requests/api/v1/polls_spec.rb index 1c8a818d59..138a37a73c 100644 --- a/spec/requests/api/v1/polls_spec.rb +++ b/spec/requests/api/v1/polls_spec.rb @@ -23,7 +23,7 @@ RSpec.describe 'Polls' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including( id: poll.id.to_s, voted: false, diff --git a/spec/requests/api/v1/preferences_spec.rb b/spec/requests/api/v1/preferences_spec.rb index 6508b51c04..d6991ca90c 100644 --- a/spec/requests/api/v1/preferences_spec.rb +++ b/spec/requests/api/v1/preferences_spec.rb @@ -34,7 +34,7 @@ RSpec.describe 'Preferences' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present end end diff --git a/spec/requests/api/v1/push/subscriptions_spec.rb b/spec/requests/api/v1/push/subscriptions_spec.rb index 6674b048e8..a9587f8d58 100644 --- a/spec/requests/api/v1/push/subscriptions_spec.rb +++ b/spec/requests/api/v1/push/subscriptions_spec.rb @@ -65,7 +65,7 @@ RSpec.describe 'API V1 Push Subscriptions' do access_token_id: eq(token.id) ) - expect(body_as_json.with_indifferent_access) + expect(response.parsed_body.with_indifferent_access) .to include( { endpoint: create_payload[:subscription][:endpoint], alerts: {}, policy: 'all' } ) @@ -124,7 +124,7 @@ RSpec.describe 'API V1 Push Subscriptions' do ) end - expect(body_as_json.with_indifferent_access) + expect(response.parsed_body.with_indifferent_access) .to include( endpoint: create_payload[:subscription][:endpoint], alerts: alerts_payload[:data][:alerts], diff --git a/spec/requests/api/v1/reports_spec.rb b/spec/requests/api/v1/reports_spec.rb index a72d9bbcd8..a176bd78a6 100644 --- a/spec/requests/api/v1/reports_spec.rb +++ b/spec/requests/api/v1/reports_spec.rb @@ -37,7 +37,7 @@ RSpec.describe 'Reports' do emails = capture_emails { subject } expect(response).to have_http_status(200) - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including( status_ids: [status.id.to_s], category: category, diff --git a/spec/requests/api/v1/scheduled_status_spec.rb b/spec/requests/api/v1/scheduled_status_spec.rb index b35d297a60..eb03827c9a 100644 --- a/spec/requests/api/v1/scheduled_status_spec.rb +++ b/spec/requests/api/v1/scheduled_status_spec.rb @@ -46,7 +46,7 @@ RSpec.describe 'Scheduled Statuses' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to_not be_present end end @@ -60,7 +60,7 @@ RSpec.describe 'Scheduled Statuses' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and have_attributes( first: include(id: scheduled_status.id.to_s) diff --git a/spec/requests/api/v1/statuses/bookmarks_spec.rb b/spec/requests/api/v1/statuses/bookmarks_spec.rb index d3007740a5..f1bcfda0ff 100644 --- a/spec/requests/api/v1/statuses/bookmarks_spec.rb +++ b/spec/requests/api/v1/statuses/bookmarks_spec.rb @@ -28,7 +28,7 @@ RSpec.describe 'Bookmarks' do it 'returns json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, bookmarked: true) ) end @@ -103,7 +103,7 @@ RSpec.describe 'Bookmarks' do it 'returns json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, bookmarked: false) ) end @@ -127,7 +127,7 @@ RSpec.describe 'Bookmarks' do it 'returns json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, bookmarked: false) ) end diff --git a/spec/requests/api/v1/statuses/favourited_by_accounts_spec.rb b/spec/requests/api/v1/statuses/favourited_by_accounts_spec.rb index 2fd79f424b..24bd03d343 100644 --- a/spec/requests/api/v1/statuses/favourited_by_accounts_spec.rb +++ b/spec/requests/api/v1/statuses/favourited_by_accounts_spec.rb @@ -34,9 +34,9 @@ RSpec.describe 'API V1 Statuses Favourited by Accounts' do next: api_v1_status_favourited_by_index_url(limit: 2, max_id: Favourite.first.id) ) - expect(body_as_json.size) + expect(response.parsed_body.size) .to eq(2) - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly( include(id: alice.id.to_s), include(id: bob.id.to_s) @@ -48,9 +48,9 @@ RSpec.describe 'API V1 Statuses Favourited by Accounts' do subject - expect(body_as_json.size) + expect(response.parsed_body.size) .to eq 1 - expect(body_as_json.first[:id]).to eq(alice.id.to_s) + expect(response.parsed_body.first[:id]).to eq(alice.id.to_s) end end end diff --git a/spec/requests/api/v1/statuses/favourites_spec.rb b/spec/requests/api/v1/statuses/favourites_spec.rb index 22d0e4831f..f9f0ff6299 100644 --- a/spec/requests/api/v1/statuses/favourites_spec.rb +++ b/spec/requests/api/v1/statuses/favourites_spec.rb @@ -28,7 +28,7 @@ RSpec.describe 'Favourites', :inline_jobs do it 'returns json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, favourites_count: 1, favourited: true) ) end @@ -95,7 +95,7 @@ RSpec.describe 'Favourites', :inline_jobs do it 'returns json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, favourites_count: 0, favourited: false) ) end @@ -118,7 +118,7 @@ RSpec.describe 'Favourites', :inline_jobs do it 'returns json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, favourites_count: 0, favourited: false) ) end diff --git a/spec/requests/api/v1/statuses/histories_spec.rb b/spec/requests/api/v1/statuses/histories_spec.rb index f13bf79867..4115a52fa8 100644 --- a/spec/requests/api/v1/statuses/histories_spec.rb +++ b/spec/requests/api/v1/statuses/histories_spec.rb @@ -18,7 +18,7 @@ RSpec.describe 'API V1 Statuses Histories' do it 'returns http success' do expect(response).to have_http_status(200) - expect(body_as_json.size).to_not be 0 + expect(response.parsed_body.size).to_not be 0 end end end diff --git a/spec/requests/api/v1/statuses/pins_spec.rb b/spec/requests/api/v1/statuses/pins_spec.rb index 3be1a16ee1..56e60c6d36 100644 --- a/spec/requests/api/v1/statuses/pins_spec.rb +++ b/spec/requests/api/v1/statuses/pins_spec.rb @@ -28,7 +28,7 @@ RSpec.describe 'Pins' do it 'return json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, pinned: true) ) end @@ -96,7 +96,7 @@ RSpec.describe 'Pins' do it 'return json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, pinned: false) ) end diff --git a/spec/requests/api/v1/statuses/reblogged_by_accounts_spec.rb b/spec/requests/api/v1/statuses/reblogged_by_accounts_spec.rb index 5fc54042f9..bd26c22f08 100644 --- a/spec/requests/api/v1/statuses/reblogged_by_accounts_spec.rb +++ b/spec/requests/api/v1/statuses/reblogged_by_accounts_spec.rb @@ -33,9 +33,9 @@ RSpec.describe 'API V1 Statuses Reblogged by Accounts' do next: api_v1_status_reblogged_by_index_url(limit: 2, max_id: alice.statuses.first.id) ) - expect(body_as_json.size) + expect(response.parsed_body.size) .to eq(2) - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly( include(id: alice.id.to_s), include(id: bob.id.to_s) @@ -47,9 +47,9 @@ RSpec.describe 'API V1 Statuses Reblogged by Accounts' do subject - expect(body_as_json.size) + expect(response.parsed_body.size) .to eq 1 - expect(body_as_json.first[:id]).to eq(alice.id.to_s) + expect(response.parsed_body.first[:id]).to eq(alice.id.to_s) end end end diff --git a/spec/requests/api/v1/statuses/reblogs_spec.rb b/spec/requests/api/v1/statuses/reblogs_spec.rb index 0978c890a4..8c7894d875 100644 --- a/spec/requests/api/v1/statuses/reblogs_spec.rb +++ b/spec/requests/api/v1/statuses/reblogs_spec.rb @@ -24,7 +24,7 @@ RSpec.describe 'API V1 Statuses Reblogs' do expect(user.account.reblogged?(status)).to be true - expect(body_as_json) + expect(response.parsed_body) .to include( reblog: include( id: status.id.to_s, @@ -60,7 +60,7 @@ RSpec.describe 'API V1 Statuses Reblogs' do expect(user.account.reblogged?(status)).to be false - expect(body_as_json) + expect(response.parsed_body) .to include( id: status.id.to_s, reblogs_count: 0, @@ -85,7 +85,7 @@ RSpec.describe 'API V1 Statuses Reblogs' do expect(user.account.reblogged?(status)).to be false - expect(body_as_json) + expect(response.parsed_body) .to include( id: status.id.to_s, reblogs_count: 0, diff --git a/spec/requests/api/v1/statuses/sources_spec.rb b/spec/requests/api/v1/statuses/sources_spec.rb index 2852abae64..c23fa91b0d 100644 --- a/spec/requests/api/v1/statuses/sources_spec.rb +++ b/spec/requests/api/v1/statuses/sources_spec.rb @@ -22,7 +22,7 @@ RSpec.describe 'Sources' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match({ + expect(response.parsed_body).to match({ id: status.id.to_s, text: status.text, spoiler_text: status.spoiler_text, @@ -52,7 +52,7 @@ RSpec.describe 'Sources' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match({ + expect(response.parsed_body).to match({ id: status.id.to_s, text: status.text, spoiler_text: status.spoiler_text, diff --git a/spec/requests/api/v1/statuses_spec.rb b/spec/requests/api/v1/statuses_spec.rb index 1a211d14d8..057800a266 100644 --- a/spec/requests/api/v1/statuses_spec.rb +++ b/spec/requests/api/v1/statuses_spec.rb @@ -18,7 +18,7 @@ RSpec.describe '/api/v1/statuses' do get '/api/v1/statuses', headers: headers, params: { id: [status.id, other_status.id, 123_123] } expect(response).to have_http_status(200) - expect(body_as_json).to contain_exactly( + expect(response.parsed_body).to contain_exactly( hash_including(id: status.id.to_s), hash_including(id: other_status.id.to_s) ) @@ -52,7 +52,7 @@ RSpec.describe '/api/v1/statuses' do subject expect(response).to have_http_status(200) - expect(body_as_json[:filtered][0]).to include({ + expect(response.parsed_body[:filtered][0]).to include({ filter: a_hash_including({ id: user.account.custom_filters.first.id.to_s, title: 'filter1', @@ -75,7 +75,7 @@ RSpec.describe '/api/v1/statuses' do subject expect(response).to have_http_status(200) - expect(body_as_json[:filtered][0]).to include({ + expect(response.parsed_body[:filtered][0]).to include({ filter: a_hash_including({ id: user.account.custom_filters.first.id.to_s, title: 'filter1', @@ -97,7 +97,7 @@ RSpec.describe '/api/v1/statuses' do subject expect(response).to have_http_status(200) - expect(body_as_json[:reblog][:filtered][0]).to include({ + expect(response.parsed_body[:reblog][:filtered][0]).to include({ filter: a_hash_including({ id: user.account.custom_filters.first.id.to_s, title: 'filter1', @@ -154,7 +154,7 @@ RSpec.describe '/api/v1/statuses' do subject expect(response).to have_http_status(422) - expect(body_as_json[:unexpected_accounts].map { |a| a.slice(:id, :acct) }).to match [{ id: bob.id.to_s, acct: bob.acct }] + expect(response.parsed_body[:unexpected_accounts].map { |a| a.slice(:id, :acct) }).to match [{ id: bob.id.to_s, acct: bob.acct }] end end diff --git a/spec/requests/api/v1/suggestions_spec.rb b/spec/requests/api/v1/suggestions_spec.rb index b900c910df..8267bb92a0 100644 --- a/spec/requests/api/v1/suggestions_spec.rb +++ b/spec/requests/api/v1/suggestions_spec.rb @@ -32,7 +32,7 @@ RSpec.describe 'Suggestions' do it 'returns accounts' do subject - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly(include(id: bob.id.to_s), include(id: jeff.id.to_s)) end @@ -42,7 +42,7 @@ RSpec.describe 'Suggestions' do it 'returns only the requested number of accounts' do subject - expect(body_as_json.size).to eq 1 + expect(response.parsed_body.size).to eq 1 end end diff --git a/spec/requests/api/v1/tags_spec.rb b/spec/requests/api/v1/tags_spec.rb index db74a6f037..9637823d45 100644 --- a/spec/requests/api/v1/tags_spec.rb +++ b/spec/requests/api/v1/tags_spec.rb @@ -21,7 +21,7 @@ RSpec.describe 'Tags' do subject expect(response).to have_http_status(200) - expect(body_as_json[:name]).to eq(name) + expect(response.parsed_body[:name]).to eq(name) end end diff --git a/spec/requests/api/v1/timelines/home_spec.rb b/spec/requests/api/v1/timelines/home_spec.rb index d158e0801c..afad2988ca 100644 --- a/spec/requests/api/v1/timelines/home_spec.rb +++ b/spec/requests/api/v1/timelines/home_spec.rb @@ -40,7 +40,7 @@ RSpec.describe 'Home', :inline_jobs do it 'returns the statuses of followed users' do subject - expect(body_as_json.pluck(:id)).to match_array(home_statuses.map { |status| status.id.to_s }) + expect(response.parsed_body.pluck(:id)).to match_array(home_statuses.map { |status| status.id.to_s }) end context 'with limit param' do @@ -49,7 +49,7 @@ RSpec.describe 'Home', :inline_jobs do it 'returns only the requested number of statuses' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end it 'sets the correct pagination headers', :aggregate_failures do @@ -94,8 +94,9 @@ RSpec.describe 'Home', :inline_jobs do it 'returns http unprocessable entity', :aggregate_failures do subject - expect(response).to have_http_status(422) - expect(response.headers['Link']).to be_nil + expect(response) + .to have_http_status(422) + .and not_have_http_link_header end end end diff --git a/spec/requests/api/v1/timelines/link_spec.rb b/spec/requests/api/v1/timelines/link_spec.rb index 87072c7caf..d7fd1076fe 100644 --- a/spec/requests/api/v1/timelines/link_spec.rb +++ b/spec/requests/api/v1/timelines/link_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Link' do subject expect(response).to have_http_status(200) - expect(body_as_json.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s }) + expect(response.parsed_body.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s }) end end @@ -131,7 +131,7 @@ RSpec.describe 'Link' do subject expect(response).to have_http_status(200) - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end it 'sets the correct pagination headers', :aggregate_failures do diff --git a/spec/requests/api/v1/timelines/list_spec.rb b/spec/requests/api/v1/timelines/list_spec.rb index 753c784866..eb4395d1f9 100644 --- a/spec/requests/api/v1/timelines/list_spec.rb +++ b/spec/requests/api/v1/timelines/list_spec.rb @@ -47,8 +47,9 @@ RSpec.describe 'API V1 Timelines List' do it 'returns http unprocessable entity' do get "/api/v1/timelines/list/#{list.id}", headers: headers - expect(response).to have_http_status(422) - expect(response.headers['Link']).to be_nil + expect(response) + .to have_http_status(422) + .and not_have_http_link_header end end end diff --git a/spec/requests/api/v1/timelines/public_spec.rb b/spec/requests/api/v1/timelines/public_spec.rb index 91e93f454c..53398b68ec 100644 --- a/spec/requests/api/v1/timelines/public_spec.rb +++ b/spec/requests/api/v1/timelines/public_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Public' do subject expect(response).to have_http_status(200) - expect(body_as_json.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s }) + expect(response.parsed_body.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s }) end end @@ -85,7 +85,7 @@ RSpec.describe 'Public' do subject expect(response).to have_http_status(200) - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end it 'sets the correct pagination headers', :aggregate_failures do diff --git a/spec/requests/api/v1/timelines/tag_spec.rb b/spec/requests/api/v1/timelines/tag_spec.rb index 34e6a92214..554b5fd3e3 100644 --- a/spec/requests/api/v1/timelines/tag_spec.rb +++ b/spec/requests/api/v1/timelines/tag_spec.rb @@ -23,7 +23,7 @@ RSpec.describe 'Tag' do expect(response) .to have_http_status(200) - expect(body_as_json.pluck(:id)) + expect(response.parsed_body.pluck(:id)) .to match_array(expected_statuses.map { |status| status.id.to_s }) .and not_include(private_status.id) end @@ -74,7 +74,7 @@ RSpec.describe 'Tag' do it 'returns only the requested number of statuses' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end it 'sets the correct pagination headers', :aggregate_failures do diff --git a/spec/requests/api/v2/admin/accounts_spec.rb b/spec/requests/api/v2/admin/accounts_spec.rb index 8f52c6a613..17c38e2e55 100644 --- a/spec/requests/api/v2/admin/accounts_spec.rb +++ b/spec/requests/api/v2/admin/accounts_spec.rb @@ -76,7 +76,7 @@ RSpec.describe 'API V2 Admin Accounts' do end def body_json_ids - body_as_json.map { |a| a[:id].to_i } + response.parsed_body.map { |a| a[:id].to_i } end context 'with limit param' do diff --git a/spec/requests/api/v2/filters/keywords_spec.rb b/spec/requests/api/v2/filters/keywords_spec.rb index 69eff5a064..a31accaa5c 100644 --- a/spec/requests/api/v2/filters/keywords_spec.rb +++ b/spec/requests/api/v2/filters/keywords_spec.rb @@ -17,7 +17,7 @@ RSpec.describe 'API V2 Filters Keywords' do it 'returns http success' do get "/api/v2/filters/#{filter.id}/keywords", headers: headers expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly( include(id: keyword.id.to_s) ) @@ -42,7 +42,7 @@ RSpec.describe 'API V2 Filters Keywords' do it 'creates a filter', :aggregate_failures do expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( keyword: 'magic', whole_word: false @@ -73,7 +73,7 @@ RSpec.describe 'API V2 Filters Keywords' do it 'responds with the keyword', :aggregate_failures do expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( keyword: 'foo', whole_word: false diff --git a/spec/requests/api/v2/filters/statuses_spec.rb b/spec/requests/api/v2/filters/statuses_spec.rb index 5969327829..aed8934a5e 100644 --- a/spec/requests/api/v2/filters/statuses_spec.rb +++ b/spec/requests/api/v2/filters/statuses_spec.rb @@ -17,7 +17,7 @@ RSpec.describe 'API V2 Filters Statuses' do it 'returns http success' do get "/api/v2/filters/#{filter.id}/statuses", headers: headers expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to contain_exactly( include(id: status_filter.id.to_s) ) @@ -43,7 +43,7 @@ RSpec.describe 'API V2 Filters Statuses' do it 'creates a filter', :aggregate_failures do expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( status_id: status.id.to_s ) @@ -73,7 +73,7 @@ RSpec.describe 'API V2 Filters Statuses' do it 'responds with the filter', :aggregate_failures do expect(response).to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( status_id: status_filter.status.id.to_s ) diff --git a/spec/requests/api/v2/filters_spec.rb b/spec/requests/api/v2/filters_spec.rb index 036a6a65a9..850c773df3 100644 --- a/spec/requests/api/v2/filters_spec.rb +++ b/spec/requests/api/v2/filters_spec.rb @@ -32,7 +32,7 @@ RSpec.describe 'Filters' do subject expect(response).to have_http_status(200) - expect(body_as_json.pluck(:id)).to match_array(filters.map { |filter| filter.id.to_s }) + expect(response.parsed_body.pluck(:id)).to match_array(filters.map { |filter| filter.id.to_s }) end end @@ -58,7 +58,7 @@ RSpec.describe 'Filters' do it 'returns a filter with keywords', :aggregate_failures do subject - expect(body_as_json) + expect(response.parsed_body) .to include( title: 'magic', filter_action: 'hide', @@ -127,7 +127,10 @@ RSpec.describe 'Filters' do subject expect(response).to have_http_status(200) - expect(body_as_json[:id]).to eq(filter.id.to_s) + expect(response.parsed_body) + .to include( + id: filter.id.to_s + ) end context 'when the filter belongs to someone else' do diff --git a/spec/requests/api/v2/instance_spec.rb b/spec/requests/api/v2/instance_spec.rb index 3fe957ef59..6f7519ad1e 100644 --- a/spec/requests/api/v2/instance_spec.rb +++ b/spec/requests/api/v2/instance_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Instances' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and include(title: 'Mastodon Glitch Edition') .and include_api_versions @@ -30,7 +30,7 @@ RSpec.describe 'Instances' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and include(title: 'Mastodon Glitch Edition') .and include_api_versions diff --git a/spec/requests/api/v2/media_spec.rb b/spec/requests/api/v2/media_spec.rb index 97540413f1..06ce0053e8 100644 --- a/spec/requests/api/v2/media_spec.rb +++ b/spec/requests/api/v2/media_spec.rb @@ -21,7 +21,7 @@ RSpec.describe 'Media API', :attachment_processing do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_a(Hash) end end @@ -38,7 +38,7 @@ RSpec.describe 'Media API', :attachment_processing do expect(response) .to have_http_status(202) - expect(body_as_json) + expect(response.parsed_body) .to be_a(Hash) end end @@ -63,7 +63,7 @@ RSpec.describe 'Media API', :attachment_processing do expect(response) .to have_http_status(422) - expect(body_as_json) + expect(response.parsed_body) .to be_a(Hash) .and include(error: /File type/) end @@ -80,7 +80,7 @@ RSpec.describe 'Media API', :attachment_processing do expect(response) .to have_http_status(500) - expect(body_as_json) + expect(response.parsed_body) .to be_a(Hash) .and include(error: /processing/) end diff --git a/spec/requests/api/v2/notifications/policies_spec.rb b/spec/requests/api/v2/notifications/policies_spec.rb index f9860b5fb4..dc205b6ebb 100644 --- a/spec/requests/api/v2/notifications/policies_spec.rb +++ b/spec/requests/api/v2/notifications/policies_spec.rb @@ -26,7 +26,7 @@ RSpec.describe 'Policies' do subject expect(response).to have_http_status(200) - expect(body_as_json).to include( + expect(response.parsed_body).to include( for_not_following: 'accept', for_not_followers: 'accept', for_new_accounts: 'accept', @@ -56,7 +56,7 @@ RSpec.describe 'Policies' do .and change { NotificationPolicy.find_or_initialize_by(account: user.account).for_limited_accounts.to_sym }.from(:filter).to(:drop) expect(response).to have_http_status(200) - expect(body_as_json).to include( + expect(response.parsed_body).to include( for_not_following: 'filter', for_not_followers: 'accept', for_new_accounts: 'accept', diff --git a/spec/requests/api/v2/search_spec.rb b/spec/requests/api/v2/search_spec.rb index 039e7513cd..a59ec7ca6b 100644 --- a/spec/requests/api/v2/search_spec.rb +++ b/spec/requests/api/v2/search_spec.rb @@ -27,7 +27,7 @@ RSpec.describe 'Search API' do it 'returns all matching accounts' do get '/api/v2/search', headers: headers, params: params - expect(body_as_json[:accounts].pluck(:id)).to contain_exactly(bob.id.to_s, ana.id.to_s, tom.id.to_s) + expect(response.parsed_body[:accounts].pluck(:id)).to contain_exactly(bob.id.to_s, ana.id.to_s, tom.id.to_s) end context 'with truthy `resolve`' do @@ -80,7 +80,7 @@ RSpec.describe 'Search API' do it 'returns only the followed accounts' do get '/api/v2/search', headers: headers, params: params - expect(body_as_json[:accounts].pluck(:id)).to contain_exactly(ana.id.to_s) + expect(response.parsed_body[:accounts].pluck(:id)).to contain_exactly(ana.id.to_s) end end end diff --git a/spec/requests/api/v2/suggestions_spec.rb b/spec/requests/api/v2/suggestions_spec.rb index 8895efd23d..e92507ed66 100644 --- a/spec/requests/api/v2/suggestions_spec.rb +++ b/spec/requests/api/v2/suggestions_spec.rb @@ -22,7 +22,7 @@ RSpec.describe 'Suggestions API' do expect(response).to have_http_status(200) - expect(body_as_json).to match_array( + expect(response.parsed_body).to match_array( [bob, jeff].map do |account| hash_including({ source: 'staff', diff --git a/spec/requests/api/v2_alpha/notifications/accounts_spec.rb b/spec/requests/api/v2_alpha/notifications/accounts_spec.rb index 6a6ce043d3..3c5bcd8996 100644 --- a/spec/requests/api/v2_alpha/notifications/accounts_spec.rb +++ b/spec/requests/api/v2_alpha/notifications/accounts_spec.rb @@ -33,7 +33,7 @@ RSpec.describe 'Accounts in grouped notifications' do # The group we are interested in is only favorites notifications = user.account.notifications.where(type: 'favourite').reorder(id: :desc) - expect(body_as_json).to match( + expect(response.parsed_body).to match( [ a_hash_including( id: notifications.first.from_account_id.to_s @@ -58,7 +58,7 @@ RSpec.describe 'Accounts in grouped notifications' do # The group we are interested in is only favorites notifications = user.account.notifications.where(type: 'favourite').reorder(id: :desc) - expect(body_as_json).to match( + expect(response.parsed_body).to match( [ a_hash_including( id: notifications.first.from_account_id.to_s diff --git a/spec/requests/api/v2_alpha/notifications_spec.rb b/spec/requests/api/v2_alpha/notifications_spec.rb index 8009e7edce..b7821de561 100644 --- a/spec/requests/api/v2_alpha/notifications_spec.rb +++ b/spec/requests/api/v2_alpha/notifications_spec.rb @@ -31,7 +31,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq 4 + expect(response.parsed_body[:count]).to eq 4 end end @@ -42,7 +42,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq 5 + expect(response.parsed_body[:count]).to eq 5 end end @@ -56,7 +56,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq 2 + expect(response.parsed_body[:count]).to eq 2 end end @@ -67,7 +67,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq 3 + expect(response.parsed_body[:count]).to eq 3 end end @@ -78,7 +78,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq 2 + expect(response.parsed_body[:count]).to eq 2 end end @@ -91,7 +91,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:count]).to eq Api::V2Alpha::NotificationsController::DEFAULT_NOTIFICATIONS_COUNT_LIMIT + expect(response.parsed_body[:count]).to eq Api::V2Alpha::NotificationsController::DEFAULT_NOTIFICATIONS_COUNT_LIMIT end end end @@ -125,7 +125,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:notification_groups]).to eq [] + expect(response.parsed_body[:notification_groups]).to eq [] end end @@ -145,7 +145,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:notification_groups]).to contain_exactly( + expect(response.parsed_body[:notification_groups]).to contain_exactly( a_hash_including( type: 'reblog', sample_account_ids: [bob.account_id.to_s] @@ -177,7 +177,7 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json.size).to_not eq 0 + expect(response.parsed_body.size).to_not eq 0 expect(body_json_types.uniq).to_not include 'mention' end end @@ -190,7 +190,7 @@ RSpec.describe 'Notifications' do expect(response).to have_http_status(200) expect(body_json_types.uniq).to eq ['mention'] - expect(body_as_json.dig(:notification_groups, 0, :page_min_id)).to_not be_nil + expect(response.parsed_body.dig(:notification_groups, 0, :page_min_id)).to_not be_nil end end @@ -201,7 +201,7 @@ RSpec.describe 'Notifications' do it 'returns the requested number of notifications paginated', :aggregate_failures do subject - expect(body_as_json[:notification_groups].size) + expect(response.parsed_body[:notification_groups].size) .to eq(params[:limit]) expect(response) @@ -221,7 +221,7 @@ RSpec.describe 'Notifications' do it 'returns the requested number of notifications paginated', :aggregate_failures do subject - expect(body_as_json[:notification_groups].size) + expect(response.parsed_body[:notification_groups].size) .to eq(2) expect(response) @@ -247,10 +247,10 @@ RSpec.describe 'Notifications' do subject expect(response).to have_http_status(200) - expect(body_as_json[:partial_accounts].size).to be > 0 - expect(body_as_json[:partial_accounts][0].keys.map(&:to_sym)).to contain_exactly(:acct, :avatar, :avatar_static, :bot, :id, :locked, :url) - expect(body_as_json[:partial_accounts].pluck(:id)).to_not include(recent_account.id.to_s) - expect(body_as_json[:accounts].pluck(:id)).to include(recent_account.id.to_s) + expect(response.parsed_body[:partial_accounts].size).to be > 0 + expect(response.parsed_body[:partial_accounts][0].keys.map(&:to_sym)).to contain_exactly(:acct, :avatar, :avatar_static, :bot, :id, :locked, :url) + expect(response.parsed_body[:partial_accounts].pluck(:id)).to_not include(recent_account.id.to_s) + expect(response.parsed_body[:accounts].pluck(:id)).to include(recent_account.id.to_s) end end @@ -265,7 +265,7 @@ RSpec.describe 'Notifications' do end def body_json_types - body_as_json[:notification_groups].pluck(:type) + response.parsed_body[:notification_groups].pluck(:type) end end diff --git a/spec/requests/api/web/embeds_spec.rb b/spec/requests/api/web/embeds_spec.rb index 0e6195204b..2b28502835 100644 --- a/spec/requests/api/web/embeds_spec.rb +++ b/spec/requests/api/web/embeds_spec.rb @@ -18,7 +18,7 @@ RSpec.describe '/api/web/embed' do subject expect(response).to have_http_status(200) - expect(body_as_json[:html]).to be_present + expect(response.parsed_body[:html]).to be_present end end @@ -71,7 +71,7 @@ RSpec.describe '/api/web/embed' do subject expect(response).to have_http_status(200) - expect(body_as_json[:html]).to be_present + expect(response.parsed_body[:html]).to be_present end context 'when the requesting user is blocked' do @@ -133,7 +133,7 @@ RSpec.describe '/api/web/embed' do subject expect(response).to have_http_status(200) - expect(body_as_json[:html]).to be_present + expect(response.parsed_body[:html]).to be_present end end diff --git a/spec/requests/emojis_spec.rb b/spec/requests/emojis_spec.rb index b2e4702f2d..644838dc65 100644 --- a/spec/requests/emojis_spec.rb +++ b/spec/requests/emojis_spec.rb @@ -11,7 +11,7 @@ RSpec.describe 'Emojis' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to include( name: ':coolcat:', type: 'Emoji' diff --git a/spec/requests/instance_actor_spec.rb b/spec/requests/instance_actor_spec.rb index bb294b04a4..b4a9b2ce6f 100644 --- a/spec/requests/instance_actor_spec.rb +++ b/spec/requests/instance_actor_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Instance actor endpoint' do .and have_cacheable_headers expect(response.content_type) .to start_with('application/activity+json') - expect(body_as_json) + expect(response.parsed_body) .to include( id: instance_actor_url, type: 'Application', diff --git a/spec/requests/invite_spec.rb b/spec/requests/invite_spec.rb index 4ce6c78e94..ba04645389 100644 --- a/spec/requests/invite_spec.rb +++ b/spec/requests/invite_spec.rb @@ -12,7 +12,7 @@ RSpec.describe 'invites' do expect(response).to have_http_status(200) expect(response.media_type).to eq 'application/json' - expect(body_as_json[:invite_code]).to eq invite.code + expect(response.parsed_body[:invite_code]).to eq invite.code end end diff --git a/spec/requests/link_headers_spec.rb b/spec/requests/link_headers_spec.rb index 3116a54d6a..e20f5e79e5 100644 --- a/spec/requests/link_headers_spec.rb +++ b/spec/requests/link_headers_spec.rb @@ -6,28 +6,12 @@ RSpec.describe 'Link headers' do describe 'on the account show page' do let(:account) { Fabricate(:account, username: 'test') } - before do + it 'contains webfinger and activitypub urls in link header' do get short_account_path(username: account) - end - it 'contains webfinger url in link header' do - link_header = link_header_with_type('application/jrd+json') - - expect(link_header.href).to eq 'https://cb6e6126.ngrok.io/.well-known/webfinger?resource=acct%3Atest%40cb6e6126.ngrok.io' - expect(link_header.attr_pairs.first).to eq %w(rel lrdd) - end - - it 'contains activitypub url in link header' do - link_header = link_header_with_type('application/activity+json') - - expect(link_header.href).to eq 'https://cb6e6126.ngrok.io/users/test' - expect(link_header.attr_pairs.first).to eq %w(rel alternate) - end - - def link_header_with_type(type) - LinkHeader.parse(response.headers['Link'].to_s).links.find do |link| - link.attr_pairs.any?(['type', type]) - end + expect(response) + .to have_http_link_header('https://cb6e6126.ngrok.io/.well-known/webfinger?resource=acct%3Atest%40cb6e6126.ngrok.io').for(rel: 'lrdd', type: 'application/jrd+json') + .and have_http_link_header('https://cb6e6126.ngrok.io/users/test').for(rel: 'alternate', type: 'application/activity+json') end end end diff --git a/spec/requests/log_out_spec.rb b/spec/requests/log_out_spec.rb index 62ede0c106..25291fa796 100644 --- a/spec/requests/log_out_spec.rb +++ b/spec/requests/log_out_spec.rb @@ -24,7 +24,7 @@ RSpec.describe 'Log Out' do expect(response).to have_http_status(200) expect(response.media_type).to eq 'application/json' - expect(body_as_json[:redirect_to]).to eq '/auth/sign_in' + expect(response.parsed_body[:redirect_to]).to eq '/auth/sign_in' end end end diff --git a/spec/requests/manifest_spec.rb b/spec/requests/manifest_spec.rb index fb64e8237a..14ca8c66ee 100644 --- a/spec/requests/manifest_spec.rb +++ b/spec/requests/manifest_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Manifest' do .and have_attributes( content_type: match('application/json') ) - expect(body_as_json) + expect(response.parsed_body) .to include( id: '/home', name: 'Mastodon Glitch Edition' diff --git a/spec/requests/oauth/token_spec.rb b/spec/requests/oauth/token_spec.rb index 39ea9b35ff..18d232e5ab 100644 --- a/spec/requests/oauth/token_spec.rb +++ b/spec/requests/oauth/token_spec.rb @@ -34,7 +34,7 @@ RSpec.describe 'Obtaining OAuth Tokens' do subject expect(response).to have_http_status(200) - expect(body_as_json[:scope]).to eq 'read write' + expect(response.parsed_body[:scope]).to eq 'read write' end end @@ -76,7 +76,7 @@ RSpec.describe 'Obtaining OAuth Tokens' do subject expect(response).to have_http_status(200) - expect(body_as_json[:scope]).to eq('read') + expect(response.parsed_body[:scope]).to eq('read') end end @@ -88,7 +88,7 @@ RSpec.describe 'Obtaining OAuth Tokens' do subject expect(response).to have_http_status(200) - expect(body_as_json[:scope]).to eq 'read write' + expect(response.parsed_body[:scope]).to eq 'read write' end end diff --git a/spec/requests/signature_verification_spec.rb b/spec/requests/signature_verification_spec.rb index 580d028338..128e7c0787 100644 --- a/spec/requests/signature_verification_spec.rb +++ b/spec/requests/signature_verification_spec.rb @@ -50,7 +50,7 @@ RSpec.describe 'signature verification concern' do get '/activitypub/success' expect(response).to have_http_status(200) - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: false, signature_actor_id: nil, error: 'Request not signed' @@ -62,7 +62,7 @@ RSpec.describe 'signature verification concern' do get '/activitypub/signature_required' expect(response).to have_http_status(401) - expect(body_as_json).to match( + expect(response.parsed_body).to match( error: 'Request not signed' ) end @@ -87,7 +87,7 @@ RSpec.describe 'signature verification concern' do } expect(response).to have_http_status(200) - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: actor.id.to_s ) @@ -109,7 +109,7 @@ RSpec.describe 'signature verification concern' do } expect(response).to have_http_status(200) - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: actor.id.to_s ) @@ -131,7 +131,7 @@ RSpec.describe 'signature verification concern' do } expect(response).to have_http_status(200) - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: actor.id.to_s ) @@ -152,7 +152,7 @@ RSpec.describe 'signature verification concern' do 'Signature' => signature_header, } - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: nil, error: anything @@ -168,7 +168,7 @@ RSpec.describe 'signature verification concern' do 'Signature' => 'keyId="https://remote.domain/users/bob#main-key",algorithm="rsa-sha256",headers="date host (request-target)",signature="Z8ilar3J7bOwqZkMp7sL8sRs4B1FT+UorbmvWoE+A5UeoOJ3KBcUmbsh+k3wQwbP5gMNUrra9rEWabpasZGphLsbDxfbsWL3Cf0PllAc7c1c7AFEwnewtExI83/qqgEkfWc2z7UDutXc2NfgAx89Ox8DXU/fA2GG0jILjB6UpFyNugkY9rg6oI31UnvfVi3R7sr3/x8Ea3I9thPvqI2byF6cojknSpDAwYzeKdngX3TAQEGzFHz3SDWwyp3jeMWfwvVVbM38FxhvAnSumw7YwWW4L7M7h4M68isLimoT3yfCn2ucBVL5Dz8koBpYf/40w7QidClAwCafZQFC29yDOg=="', # rubocop:disable Layout/LineLength } - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: nil, error: anything @@ -184,7 +184,7 @@ RSpec.describe 'signature verification concern' do 'Signature' => 'keyId="https://remote.domain/users/bob#main-key",algorithm="rsa-sha256",headers="date host (request-target)",signature="Z8ilar3J7bOwqZkMp7sL8sRs4B1FT+UorbmvWoE+A5UeoOJ3KBcUmbsh+k3wQwbP5gMNUrra9rEWabpasZGphLsbDxfbsWL3Cf0PllAc7c1c7AFEwnewtExI83/qqgEkfWc2z7UDutXc2NfgAx89Ox8DXU/fA2GG0jILjB6UpFyNugkY9rg6oI31UnvfVi3R7sr3/x8Ea3I9thPvqI2byF6cojknSpDAwYzeKdngX3TAQEGzFHz3SDWwyp3jeMWfwvVVbM38FxhvAnSumw7YwWW4L7M7h4M68isLimoT3yfCn2ucBVL5Dz8koBpYf/40w7QidClAwCafZQFC29yDOg=="', # rubocop:disable Layout/LineLength } - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: nil, error: anything @@ -206,7 +206,7 @@ RSpec.describe 'signature verification concern' do 'Signature' => signature_header, } - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: nil, error: 'Invalid Date header: not RFC 2616 compliant date: "wrong date"' @@ -228,7 +228,7 @@ RSpec.describe 'signature verification concern' do 'Signature' => signature_header, } - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: nil, error: 'Signed request date outside acceptable time window' @@ -254,7 +254,7 @@ RSpec.describe 'signature verification concern' do } expect(response).to have_http_status(200) - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: actor.id.to_s ) @@ -278,7 +278,7 @@ RSpec.describe 'signature verification concern' do 'Signature' => signature_header, } - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: nil, error: 'Mastodon requires the Digest header to be signed when doing a POST request' @@ -303,7 +303,7 @@ RSpec.describe 'signature verification concern' do 'Signature' => signature_header, } - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: nil, error: 'Invalid Digest value. Computed SHA-256 digest: wFNeS+K3n/2TKRMFQ2v4iTFOSj+uwF7P/Lt98xrZ5Ro=; given: ZOyIygCyaOW6GjVnihtTFtIS9PNmskdyMlNKiuyjfzw=' @@ -321,7 +321,7 @@ RSpec.describe 'signature verification concern' do } expect(response).to have_http_status(200) - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: nil, error: anything @@ -342,7 +342,7 @@ RSpec.describe 'signature verification concern' do 'Signature' => 'keyId="https://remote.domain/users/alice#main-key",algorithm="rsa-sha256",headers="date host (request-target)",signature="Z8ilar3J7bOwqZkMp7sL8sRs4B1FT+UorbmvWoE+A5UeoOJ3KBcUmbsh+k3wQwbP5gMNUrra9rEWabpasZGphLsbDxfbsWL3Cf0PllAc7c1c7AFEwnewtExI83/qqgEkfWc2z7UDutXc2NfgAx89Ox8DXU/fA2GG0jILjB6UpFyNugkY9rg6oI31UnvfVi3R7sr3/x8Ea3I9thPvqI2byF6cojknSpDAwYzeKdngX3TAQEGzFHz3SDWwyp3jeMWfwvVVbM38FxhvAnSumw7YwWW4L7M7h4M68isLimoT3yfCn2ucBVL5Dz8koBpYf/40w7QidClAwCafZQFC29yDOg=="', # rubocop:disable Layout/LineLength } - expect(body_as_json).to match( + expect(response.parsed_body).to match( signed_request: true, signature_actor_id: nil, error: 'Unable to fetch key JSON at https://remote.domain/users/alice#main-key' diff --git a/spec/requests/well_known/node_info_spec.rb b/spec/requests/well_known/node_info_spec.rb index d02732c32b..3d5afc7e2d 100644 --- a/spec/requests/well_known/node_info_spec.rb +++ b/spec/requests/well_known/node_info_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'The well-known node-info endpoints' do media_type: 'application/json' ) - expect(body_as_json).to include( + expect(response.parsed_body).to include( links: be_an(Array).and( contain_exactly( include( @@ -39,7 +39,7 @@ RSpec.describe 'The well-known node-info endpoints' do expect(non_matching_hash) .to_not match_json_schema('nodeinfo_2.0') - expect(body_as_json) + expect(response.parsed_body) .to match_json_schema('nodeinfo_2.0') .and include( version: '2.0', diff --git a/spec/requests/well_known/oauth_metadata_spec.rb b/spec/requests/well_known/oauth_metadata_spec.rb index 378295b5a3..9c86dbedfe 100644 --- a/spec/requests/well_known/oauth_metadata_spec.rb +++ b/spec/requests/well_known/oauth_metadata_spec.rb @@ -21,7 +21,7 @@ RSpec.describe 'The /.well-known/oauth-authorization-server request' do grant_types_supported = Doorkeeper.configuration.grant_flows.dup grant_types_supported << 'refresh_token' if Doorkeeper.configuration.refresh_token_enabled? - expect(body_as_json).to include( + expect(response.parsed_body).to include( issuer: root_url(protocol: protocol), service_documentation: 'https://docs.joinmastodon.org/', authorization_endpoint: oauth_authorization_url(protocol: protocol), diff --git a/spec/requests/well_known/webfinger_spec.rb b/spec/requests/well_known/webfinger_spec.rb index e5ce352d50..6880ba4b58 100644 --- a/spec/requests/well_known/webfinger_spec.rb +++ b/spec/requests/well_known/webfinger_spec.rb @@ -24,7 +24,7 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do expect(response.media_type).to eq 'application/jrd+json' - expect(body_as_json) + expect(response.parsed_body) .to include( subject: eq('acct:alice@cb6e6126.ngrok.io'), aliases: include('https://cb6e6126.ngrok.io/@alice', 'https://cb6e6126.ngrok.io/users/alice') @@ -129,7 +129,7 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do end it 'returns links for the internal account' do - expect(body_as_json) + expect(response.parsed_body) .to include( subject: 'acct:mastodon.internal@cb6e6126.ngrok.io', aliases: ['https://cb6e6126.ngrok.io/actor'] @@ -168,7 +168,7 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do it 'returns avatar in response' do perform_request! - avatar_link = get_avatar_link(body_as_json) + avatar_link = get_avatar_link(response.parsed_body) expect(avatar_link).to_not be_nil expect(avatar_link[:type]).to eq alice.avatar.content_type expect(avatar_link[:href]).to eq Addressable::URI.new(host: Rails.configuration.x.local_domain, path: alice.avatar.to_s, scheme: 'https').to_s @@ -182,7 +182,7 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do it 'does not return avatar in response' do perform_request! - avatar_link = get_avatar_link(body_as_json) + avatar_link = get_avatar_link(response.parsed_body) expect(avatar_link).to be_nil end end @@ -197,7 +197,7 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do it 'does not return avatar in response' do perform_request! - avatar_link = get_avatar_link(body_as_json) + avatar_link = get_avatar_link(response.parsed_body) expect(avatar_link).to be_nil end end @@ -212,7 +212,7 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do end it 'does not return avatar in response' do - avatar_link = get_avatar_link(body_as_json) + avatar_link = get_avatar_link(response.parsed_body) expect(avatar_link).to be_nil end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 60bec918ea..2a27544407 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -34,10 +34,6 @@ RSpec.configure do |config| end end -def body_as_json - response.parsed_body -end - def serialized_record_json(record, serializer, adapter: nil) options = { serializer: serializer } options[:adapter] = adapter if adapter.present? diff --git a/spec/support/matchers/api_pagination.rb b/spec/support/matchers/api_pagination.rb index f7d552b242..1a4f53a84a 100644 --- a/spec/support/matchers/api_pagination.rb +++ b/spec/support/matchers/api_pagination.rb @@ -3,7 +3,7 @@ RSpec::Matchers.define :include_pagination_headers do |links| match do |response| links.map do |key, value| - response.headers['Link'].find_link(['rel', key.to_s]).href == value + expect(response).to have_http_link_header(value).for(rel: key.to_s) end.all? end diff --git a/spec/support/matchers/http_link_header.rb b/spec/support/matchers/http_link_header.rb new file mode 100644 index 0000000000..3e658071c9 --- /dev/null +++ b/spec/support/matchers/http_link_header.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +RSpec::Matchers.define :have_http_link_header do |href| + match do |response| + @response = response + + header_link&.href == href + end + + match_when_negated do |response| + response.headers['Link'].blank? + end + + chain :for do |attributes| + @attributes = attributes + end + + failure_message do |response| + "Expected `#{response.headers['Link']}` to include `href` value of `#{href}` for `#{@attributes}` but it did not." + end + + failure_message_when_negated do + "Expected response not to have a `Link` header but `#{response.headers['Link']}` is present." + end + + def header_link + LinkHeader + .parse(@response.headers['Link']) + .find_link(*@attributes.stringify_keys) + end +end + +RSpec::Matchers.define_negated_matcher :not_have_http_link_header, :have_http_link_header # Allow chaining diff --git a/spec/system/media_spec.rb b/spec/system/media_spec.rb new file mode 100644 index 0000000000..d014c7e88e --- /dev/null +++ b/spec/system/media_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Media' do + describe 'Player page' do + context 'when signed in' do + before { sign_in Fabricate(:user) } + + it 'visits the media player page and renders the media' do + status = Fabricate :status + media = Fabricate :media_attachment, type: :video + status.media_attachments << media + + visit medium_player_path(media) + + expect(page) + .to have_css('body', class: 'player') + .and have_css('div[data-component="Video"]') + end + end + end +end diff --git a/spec/workers/generate_annual_report_worker_spec.rb b/spec/workers/generate_annual_report_worker_spec.rb new file mode 100644 index 0000000000..69b0d4424b --- /dev/null +++ b/spec/workers/generate_annual_report_worker_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe GenerateAnnualReportWorker do + let(:worker) { described_class.new } + let(:account) { Fabricate :account } + + describe '#perform' do + it 'generates new report for the account' do + expect { worker.perform(account.id, Date.current.year) } + .to change(account_reports, :count).by(1) + end + + it 'returns true for non-existent record' do + result = worker.perform(123_123_123, Date.current.year) + + expect(result).to be(true) + end + + def account_reports + GeneratedAnnualReport + .where(account: account) + .where(year: Date.current.year) + end + end +end