Autofix Rubocop Style/StringLiterals (#23695)
This commit is contained in:
		@@ -3057,88 +3057,6 @@ Style/StringConcatenation:
 | 
			
		||||
    - 'spec/validators/disallowed_hashtags_validator_spec.rb'
 | 
			
		||||
    - 'spec/workers/web/push_notification_worker_spec.rb'
 | 
			
		||||
 | 
			
		||||
# Offense count: 297
 | 
			
		||||
# This cop supports safe autocorrection (--autocorrect).
 | 
			
		||||
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
 | 
			
		||||
# SupportedStyles: single_quotes, double_quotes
 | 
			
		||||
Style/StringLiterals:
 | 
			
		||||
  Exclude:
 | 
			
		||||
    - 'app/lib/webfinger.rb'
 | 
			
		||||
    - 'db/migrate/20160305115639_add_devise_to_users.rb'
 | 
			
		||||
    - 'db/migrate/20161122163057_remove_unneeded_indexes.rb'
 | 
			
		||||
    - 'db/migrate/20170125145934_add_spoiler_text_to_statuses.rb'
 | 
			
		||||
    - 'db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb'
 | 
			
		||||
    - 'db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb'
 | 
			
		||||
    - 'db/migrate/20180617162849_remove_unused_indexes.rb'
 | 
			
		||||
    - 'db/migrate/20200521180606_encrypted_message_ids_to_timestamp_ids.rb'
 | 
			
		||||
    - 'db/migrate/20200622213645_media_attachment_ids_to_timestamp_ids.rb'
 | 
			
		||||
    - 'db/migrate/20210306164523_account_ids_to_timestamp_ids.rb'
 | 
			
		||||
    - 'lib/mastodon/emoji_cli.rb'
 | 
			
		||||
    - 'lib/rails/engine_extensions.rb'
 | 
			
		||||
    - 'lib/tasks/mastodon.rake'
 | 
			
		||||
    - 'spec/controllers/admin/change_email_controller_spec.rb'
 | 
			
		||||
    - 'spec/controllers/api/v1/streaming_controller_spec.rb'
 | 
			
		||||
    - 'spec/controllers/application_controller_spec.rb'
 | 
			
		||||
    - 'spec/controllers/auth/registrations_controller_spec.rb'
 | 
			
		||||
    - 'spec/controllers/auth/sessions_controller_spec.rb'
 | 
			
		||||
    - 'spec/controllers/oauth/authorized_applications_controller_spec.rb'
 | 
			
		||||
    - 'spec/controllers/settings/imports_controller_spec.rb'
 | 
			
		||||
    - 'spec/controllers/settings/profiles_controller_spec.rb'
 | 
			
		||||
    - 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb'
 | 
			
		||||
    - 'spec/controllers/statuses_cleanup_controller_spec.rb'
 | 
			
		||||
    - 'spec/controllers/well_known/nodeinfo_controller_spec.rb'
 | 
			
		||||
    - 'spec/fabricators/account_moderation_note_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/account_note_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/account_stat_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/account_tag_stat_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/account_warning_preset_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/admin_action_log_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/canonical_email_block_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/conversation_account_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/custom_emoji_category_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/domain_allow_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/encrypted_message_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/identity_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/ip_block_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/list_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/relay_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/report_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/report_note_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/session_activation_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/status_edit_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/status_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/status_stat_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/user_fabricator.rb'
 | 
			
		||||
    - 'spec/fabricators/user_role_fabricator.rb'
 | 
			
		||||
    - 'spec/features/log_in_spec.rb'
 | 
			
		||||
    - 'spec/helpers/accounts_helper_spec.rb'
 | 
			
		||||
    - 'spec/helpers/application_helper_spec.rb'
 | 
			
		||||
    - 'spec/lib/feed_manager_spec.rb'
 | 
			
		||||
    - 'spec/mailers/notification_mailer_spec.rb'
 | 
			
		||||
    - 'spec/mailers/user_mailer_spec.rb'
 | 
			
		||||
    - 'spec/models/account_spec.rb'
 | 
			
		||||
    - 'spec/models/media_attachment_spec.rb'
 | 
			
		||||
    - 'spec/models/web/push_subscription_spec.rb'
 | 
			
		||||
    - 'spec/models/webauthn_credentials_spec.rb'
 | 
			
		||||
    - 'spec/presenters/instance_presenter_spec.rb'
 | 
			
		||||
    - 'spec/rails_helper.rb'
 | 
			
		||||
    - 'spec/requests/catch_all_route_request_spec.rb'
 | 
			
		||||
    - 'spec/requests/host_meta_request_spec.rb'
 | 
			
		||||
    - 'spec/requests/localization_spec.rb'
 | 
			
		||||
    - 'spec/services/account_search_service_spec.rb'
 | 
			
		||||
    - 'spec/services/activitypub/fetch_remote_status_service_spec.rb'
 | 
			
		||||
    - 'spec/services/delete_account_service_spec.rb'
 | 
			
		||||
    - 'spec/services/favourite_service_spec.rb'
 | 
			
		||||
    - 'spec/services/fetch_link_card_service_spec.rb'
 | 
			
		||||
    - 'spec/services/fetch_oembed_service_spec.rb'
 | 
			
		||||
    - 'spec/services/fetch_remote_status_service_spec.rb'
 | 
			
		||||
    - 'spec/services/follow_service_spec.rb'
 | 
			
		||||
    - 'spec/services/import_service_spec.rb'
 | 
			
		||||
    - 'spec/services/post_status_service_spec.rb'
 | 
			
		||||
    - 'spec/services/process_mentions_service_spec.rb'
 | 
			
		||||
    - 'spec/services/resolve_account_service_spec.rb'
 | 
			
		||||
    - 'spec/spec_helper.rb'
 | 
			
		||||
 | 
			
		||||
# Offense count: 272
 | 
			
		||||
# This cop supports safe autocorrection (--autocorrect).
 | 
			
		||||
# Configuration parameters: EnforcedStyle, MinSize.
 | 
			
		||||
 
 | 
			
		||||
@@ -99,7 +99,7 @@ class Webfinger
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def standard_url
 | 
			
		||||
    if @domain.end_with? ".onion"
 | 
			
		||||
    if @domain.end_with? '.onion'
 | 
			
		||||
      "http://#{@domain}/.well-known/webfinger?resource=#{@uri}"
 | 
			
		||||
    else
 | 
			
		||||
      "https://#{@domain}/.well-known/webfinger?resource=#{@uri}"
 | 
			
		||||
@@ -107,7 +107,7 @@ class Webfinger
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def host_meta_url
 | 
			
		||||
    if @domain.end_with? ".onion"
 | 
			
		||||
    if @domain.end_with? '.onion'
 | 
			
		||||
      "http://#{@domain}/.well-known/host-meta"
 | 
			
		||||
    else
 | 
			
		||||
      "https://#{@domain}/.well-known/host-meta"
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@ class AddDeviseToUsers < ActiveRecord::Migration[4.2]
 | 
			
		||||
  def self.up
 | 
			
		||||
    change_table(:users) do |t|
 | 
			
		||||
      ## Database authenticatable
 | 
			
		||||
      t.string :encrypted_password, null: false, default: ""
 | 
			
		||||
      t.string :encrypted_password, null: false, default: ''
 | 
			
		||||
 | 
			
		||||
      ## Recoverable
 | 
			
		||||
      t.string   :reset_password_token
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
class RemoveUnneededIndexes < ActiveRecord::Migration[5.0]
 | 
			
		||||
  def change
 | 
			
		||||
    remove_index :notifications, name: "index_notifications_on_account_id"
 | 
			
		||||
    remove_index :settings, name: "index_settings_on_target_type_and_target_id"
 | 
			
		||||
    remove_index :statuses_tags, name: "index_statuses_tags_on_tag_id"
 | 
			
		||||
    remove_index :notifications, name: 'index_notifications_on_account_id'
 | 
			
		||||
    remove_index :settings, name: 'index_settings_on_target_type_and_target_id'
 | 
			
		||||
    remove_index :statuses_tags, name: 'index_statuses_tags_on_tag_id'
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
class AddSpoilerTextToStatuses < ActiveRecord::Migration[5.0]
 | 
			
		||||
  def change
 | 
			
		||||
    add_column :statuses, :spoiler_text, :text, default: "", null: false
 | 
			
		||||
    add_column :statuses, :spoiler_text, :text, default: '', null: false
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
class RemoveDuplicateIndexesInLists < ActiveRecord::Migration[5.1]
 | 
			
		||||
  def change
 | 
			
		||||
    remove_index :list_accounts, name: "index_list_accounts_on_account_id"
 | 
			
		||||
    remove_index :list_accounts, name: "index_list_accounts_on_list_id"
 | 
			
		||||
    remove_index :list_accounts, name: 'index_list_accounts_on_account_id'
 | 
			
		||||
    remove_index :list_accounts, name: 'index_list_accounts_on_list_id'
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -5,11 +5,11 @@ class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecor
 | 
			
		||||
 | 
			
		||||
  def change
 | 
			
		||||
    safety_assured do
 | 
			
		||||
      add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_name_exists?(:statuses, "index_statuses_20180106")
 | 
			
		||||
      add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_name_exists?(:statuses, 'index_statuses_20180106')
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # These index may not exists (see migration 20180514130000)
 | 
			
		||||
    remove_index :statuses, column: [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently if index_exists?(:statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)')
 | 
			
		||||
    remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ["account_id", "id"], where: "(visibility = 3)")
 | 
			
		||||
    remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ['account_id', 'id'], where: '(visibility = 3)')
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
class RemoveUnusedIndexes < ActiveRecord::Migration[5.2]
 | 
			
		||||
  def change
 | 
			
		||||
    remove_index :statuses, name: "index_statuses_on_conversation_id"
 | 
			
		||||
    remove_index :users, name: "index_users_on_filtered_languages"
 | 
			
		||||
    remove_index :backups, name: "index_backups_on_user_id"
 | 
			
		||||
    remove_index :statuses, name: 'index_statuses_on_conversation_id'
 | 
			
		||||
    remove_index :users, name: 'index_users_on_filtered_languages'
 | 
			
		||||
    remove_index :backups, name: 'index_backups_on_user_id'
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ class EncryptedMessageIdsToTimestampIds < ActiveRecord::Migration[5.2]
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def down
 | 
			
		||||
    execute("LOCK encrypted_messages")
 | 
			
		||||
    execute('LOCK encrypted_messages')
 | 
			
		||||
    execute("SELECT setval('encrypted_messages_id_seq', (SELECT MAX(id) FROM encrypted_messages))")
 | 
			
		||||
    execute("ALTER TABLE encrypted_messages ALTER COLUMN id SET DEFAULT nextval('encrypted_messages_id_seq')")
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ class MediaAttachmentIdsToTimestampIds < ActiveRecord::Migration[5.1]
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def down
 | 
			
		||||
    execute("LOCK media_attachments")
 | 
			
		||||
    execute('LOCK media_attachments')
 | 
			
		||||
    execute("SELECT setval('media_attachments_id_seq', (SELECT MAX(id) FROM media_attachments))")
 | 
			
		||||
    execute("ALTER TABLE media_attachments ALTER COLUMN id SET DEFAULT nextval('media_attachments_id_seq')")
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ class AccountIdsToTimestampIds < ActiveRecord::Migration[5.1]
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def down
 | 
			
		||||
    execute("LOCK accounts")
 | 
			
		||||
    execute('LOCK accounts')
 | 
			
		||||
    execute("SELECT setval('accounts_id_seq', (SELECT MAX(id) FROM accounts))")
 | 
			
		||||
    execute("ALTER TABLE accounts ALTER COLUMN id SET DEFAULT nextval('accounts_id_seq')")
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ module Mastodon
 | 
			
		||||
          next if filename.start_with?('._')
 | 
			
		||||
 | 
			
		||||
          shortcode    = [options[:prefix], filename, options[:suffix]].compact.join
 | 
			
		||||
          custom_emoji = CustomEmoji.local.find_by("LOWER(shortcode) = ?", shortcode.downcase)
 | 
			
		||||
          custom_emoji = CustomEmoji.local.find_by('LOWER(shortcode) = ?', shortcode.downcase)
 | 
			
		||||
 | 
			
		||||
          if custom_emoji && !options[:overwrite]
 | 
			
		||||
            skipped += 1
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@ module Rails
 | 
			
		||||
    # Rewrite task loading code to filter digitalocean.rake task
 | 
			
		||||
    def run_tasks_blocks(app)
 | 
			
		||||
      Railtie.instance_method(:run_tasks_blocks).bind_call(self, app)
 | 
			
		||||
      paths["lib/tasks"].existent.reject { |ext| ext.end_with?('digitalocean.rake') }.sort.each { |ext| load(ext) }
 | 
			
		||||
      paths['lib/tasks'].existent.reject { |ext| ext.end_with?('digitalocean.rake') }.sort.each { |ext| load(ext) }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -264,7 +264,7 @@ namespace :mastodon do
 | 
			
		||||
 | 
			
		||||
          env['S3_ENDPOINT'] = prompt.ask('Storj DCS endpoint URL:') do |q|
 | 
			
		||||
            q.required true
 | 
			
		||||
            q.default "https://gateway.storjshare.io"
 | 
			
		||||
            q.default 'https://gateway.storjshare.io'
 | 
			
		||||
            q.modify :strip
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,8 +9,8 @@ RSpec.describe Admin::ChangeEmailsController, type: :controller do
 | 
			
		||||
    sign_in admin
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "GET #show" do
 | 
			
		||||
    it "returns http success" do
 | 
			
		||||
  describe 'GET #show' do
 | 
			
		||||
    it 'returns http success' do
 | 
			
		||||
      user = Fabricate(:user)
 | 
			
		||||
 | 
			
		||||
      get :show, params: { account_id: user.account.id }
 | 
			
		||||
@@ -19,12 +19,12 @@ RSpec.describe Admin::ChangeEmailsController, type: :controller do
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "GET #update" do
 | 
			
		||||
  describe 'GET #update' do
 | 
			
		||||
    before do
 | 
			
		||||
      allow(UserMailer).to receive(:confirmation_instructions).and_return(double('email', deliver_later: nil))
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "returns http success" do
 | 
			
		||||
    it 'returns http success' do
 | 
			
		||||
      user = Fabricate(:user)
 | 
			
		||||
 | 
			
		||||
      previous_email = user.email
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ describe Api::V1::StreamingController do
 | 
			
		||||
        [:scheme, :path, :query, :fragment].each do |part|
 | 
			
		||||
          expect(redirect_to_uri.send(part)).to eq(request_uri.send(part)), "redirect target #{part}"
 | 
			
		||||
        end
 | 
			
		||||
        expect(redirect_to_uri.host).to eq(@streaming_host), "redirect target host"
 | 
			
		||||
        expect(redirect_to_uri.host).to eq(@streaming_host), 'redirect target host'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ describe ApplicationController, type: :controller do
 | 
			
		||||
      expect(response).to have_http_status(code)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "renders template for http" do
 | 
			
		||||
    it 'renders template for http' do
 | 
			
		||||
      is_expected.to render_template("errors/#{code}", layout: 'error')
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
@@ -146,7 +146,7 @@ describe ApplicationController, type: :controller do
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'does not store location for user if it is devise controller' do
 | 
			
		||||
        @request.env["devise.mapping"] = Devise.mappings[:user]
 | 
			
		||||
        @request.env['devise.mapping'] = Devise.mappings[:user]
 | 
			
		||||
        get 'create'
 | 
			
		||||
        expect(controller.stored_location_for(:user)).to be_nil
 | 
			
		||||
      end
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
 | 
			
		||||
 | 
			
		||||
  describe 'GET #edit' do
 | 
			
		||||
    it 'returns http success' do
 | 
			
		||||
      request.env["devise.mapping"] = Devise.mappings[:user]
 | 
			
		||||
      request.env['devise.mapping'] = Devise.mappings[:user]
 | 
			
		||||
      sign_in(Fabricate(:user))
 | 
			
		||||
      get :edit
 | 
			
		||||
      expect(response).to have_http_status(200)
 | 
			
		||||
@@ -41,7 +41,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
 | 
			
		||||
 | 
			
		||||
  describe 'GET #update' do
 | 
			
		||||
    it 'returns http success' do
 | 
			
		||||
      request.env["devise.mapping"] = Devise.mappings[:user]
 | 
			
		||||
      request.env['devise.mapping'] = Devise.mappings[:user]
 | 
			
		||||
      sign_in(Fabricate(:user), scope: :user)
 | 
			
		||||
      post :update
 | 
			
		||||
      expect(response).to have_http_status(200)
 | 
			
		||||
@@ -49,7 +49,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
 | 
			
		||||
 | 
			
		||||
    context 'when suspended' do
 | 
			
		||||
      it 'returns http forbidden' do
 | 
			
		||||
        request.env["devise.mapping"] = Devise.mappings[:user]
 | 
			
		||||
        request.env['devise.mapping'] = Devise.mappings[:user]
 | 
			
		||||
        sign_in(Fabricate(:user, account_attributes: { username: 'test', suspended_at: Time.now.utc }), scope: :user)
 | 
			
		||||
        post :update
 | 
			
		||||
        expect(response).to have_http_status(403)
 | 
			
		||||
@@ -59,7 +59,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
 | 
			
		||||
 | 
			
		||||
  describe 'GET #new' do
 | 
			
		||||
    before do
 | 
			
		||||
      request.env["devise.mapping"] = Devise.mappings[:user]
 | 
			
		||||
      request.env['devise.mapping'] = Devise.mappings[:user]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context do
 | 
			
		||||
@@ -92,7 +92,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
 | 
			
		||||
      I18n.locale = current_locale
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    before { request.env["devise.mapping"] = Devise.mappings[:user] }
 | 
			
		||||
    before { request.env['devise.mapping'] = Devise.mappings[:user] }
 | 
			
		||||
 | 
			
		||||
    context do
 | 
			
		||||
      around do |example|
 | 
			
		||||
@@ -103,7 +103,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
 | 
			
		||||
 | 
			
		||||
      subject do
 | 
			
		||||
        Setting.registrations_mode = 'open'
 | 
			
		||||
        request.headers["Accept-Language"] = accept_language
 | 
			
		||||
        request.headers['Accept-Language'] = accept_language
 | 
			
		||||
        post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@@ -129,7 +129,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
 | 
			
		||||
 | 
			
		||||
      subject do
 | 
			
		||||
        Setting.registrations_mode = 'open'
 | 
			
		||||
        request.headers["Accept-Language"] = accept_language
 | 
			
		||||
        request.headers['Accept-Language'] = accept_language
 | 
			
		||||
        post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'false' } }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@@ -149,7 +149,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
 | 
			
		||||
 | 
			
		||||
      subject do
 | 
			
		||||
        Setting.registrations_mode = 'approved'
 | 
			
		||||
        request.headers["Accept-Language"] = accept_language
 | 
			
		||||
        request.headers['Accept-Language'] = accept_language
 | 
			
		||||
        post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@@ -176,7 +176,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
 | 
			
		||||
 | 
			
		||||
      subject do
 | 
			
		||||
        Setting.registrations_mode = 'approved'
 | 
			
		||||
        request.headers["Accept-Language"] = accept_language
 | 
			
		||||
        request.headers['Accept-Language'] = accept_language
 | 
			
		||||
        invite = Fabricate(:invite, max_uses: nil, expires_at: 1.hour.ago)
 | 
			
		||||
        post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
 | 
			
		||||
      end
 | 
			
		||||
@@ -208,7 +208,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
 | 
			
		||||
        inviter = Fabricate(:user, confirmed_at: 2.days.ago)
 | 
			
		||||
        Setting.registrations_mode = 'approved'
 | 
			
		||||
        Setting.require_invite_text = true
 | 
			
		||||
        request.headers["Accept-Language"] = accept_language
 | 
			
		||||
        request.headers['Accept-Language'] = accept_language
 | 
			
		||||
        invite = Fabricate(:invite, user: inviter, max_uses: nil, expires_at: 1.hour.from_now)
 | 
			
		||||
        post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
 | 
			
		||||
      end
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
 | 
			
		||||
    context 'using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
 | 
			
		||||
      context 'using a valid password' do
 | 
			
		||||
        before do
 | 
			
		||||
          post :create, params: { user: { email: "pam_user1", password: '123456' } }
 | 
			
		||||
          post :create, params: { user: { email: 'pam_user1', password: '123456' } }
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        it 'redirects to home' do
 | 
			
		||||
@@ -68,7 +68,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
 | 
			
		||||
 | 
			
		||||
      context 'using an invalid password' do
 | 
			
		||||
        before do
 | 
			
		||||
          post :create, params: { user: { email: "pam_user1", password: 'WRONGPW' } }
 | 
			
		||||
          post :create, params: { user: { email: 'pam_user1', password: 'WRONGPW' } }
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        it 'shows a login error' do
 | 
			
		||||
@@ -194,7 +194,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
 | 
			
		||||
          post :create, params: { user: { email: user.email, password: user.password } }
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        context "in single user mode" do
 | 
			
		||||
        context 'in single user mode' do
 | 
			
		||||
          let(:single_user_mode) { true }
 | 
			
		||||
 | 
			
		||||
          it 'redirects to home' do
 | 
			
		||||
@@ -202,7 +202,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        context "in non-single user mode" do
 | 
			
		||||
        context 'in non-single user mode' do
 | 
			
		||||
          let(:single_user_mode) { false }
 | 
			
		||||
 | 
			
		||||
          it "redirects back to the user's page" do
 | 
			
		||||
@@ -230,8 +230,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          it 'renders two factor authentication page' do
 | 
			
		||||
            expect(controller).to render_template("two_factor")
 | 
			
		||||
            expect(controller).to render_template(partial: "_otp_authentication_form")
 | 
			
		||||
            expect(controller).to render_template('two_factor')
 | 
			
		||||
            expect(controller).to render_template(partial: '_otp_authentication_form')
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
@@ -246,8 +246,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          it 'renders two factor authentication page' do
 | 
			
		||||
            expect(controller).to render_template("two_factor")
 | 
			
		||||
            expect(controller).to render_template(partial: "_otp_authentication_form")
 | 
			
		||||
            expect(controller).to render_template('two_factor')
 | 
			
		||||
            expect(controller).to render_template(partial: '_otp_authentication_form')
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
@@ -257,8 +257,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          it 'renders two factor authentication page' do
 | 
			
		||||
            expect(controller).to render_template("two_factor")
 | 
			
		||||
            expect(controller).to render_template(partial: "_otp_authentication_form")
 | 
			
		||||
            expect(controller).to render_template('two_factor')
 | 
			
		||||
            expect(controller).to render_template(partial: '_otp_authentication_form')
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
@@ -359,8 +359,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          it 'renders webauthn authentication page' do
 | 
			
		||||
            expect(controller).to render_template("two_factor")
 | 
			
		||||
            expect(controller).to render_template(partial: "_webauthn_form")
 | 
			
		||||
            expect(controller).to render_template('two_factor')
 | 
			
		||||
            expect(controller).to render_template(partial: '_webauthn_form')
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
@@ -370,8 +370,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          it 'renders webauthn authentication page' do
 | 
			
		||||
            expect(controller).to render_template("two_factor")
 | 
			
		||||
            expect(controller).to render_template(partial: "_webauthn_form")
 | 
			
		||||
            expect(controller).to render_template('two_factor')
 | 
			
		||||
            expect(controller).to render_template(partial: '_webauthn_form')
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ describe Oauth::AuthorizedApplicationsController do
 | 
			
		||||
    shared_examples 'stores location for user' do
 | 
			
		||||
      it 'stores location for user' do
 | 
			
		||||
        subject
 | 
			
		||||
        expect(controller.stored_location_for(:user)).to eq "/oauth/authorized_applications"
 | 
			
		||||
        expect(controller.stored_location_for(:user)).to eq '/oauth/authorized_applications'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -7,8 +7,8 @@ RSpec.describe Settings::ImportsController, type: :controller do
 | 
			
		||||
    sign_in Fabricate(:user), scope: :user
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "GET #show" do
 | 
			
		||||
    it "returns http success" do
 | 
			
		||||
  describe 'GET #show' do
 | 
			
		||||
    it 'returns http success' do
 | 
			
		||||
      get :show
 | 
			
		||||
      expect(response).to have_http_status(200)
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
@@ -10,8 +10,8 @@ RSpec.describe Settings::ProfilesController, type: :controller do
 | 
			
		||||
    sign_in user, scope: :user
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "GET #show" do
 | 
			
		||||
    it "returns http success" do
 | 
			
		||||
  describe 'GET #show' do
 | 
			
		||||
    it 'returns http success' do
 | 
			
		||||
      get :show
 | 
			
		||||
      expect(response).to have_http_status(200)
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
@@ -137,7 +137,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
 | 
			
		||||
            expect { get :options }.to_not change { user.webauthn_id }
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          it "includes existing credentials in list of excluded credentials" do
 | 
			
		||||
          it 'includes existing credentials in list of excluded credentials' do
 | 
			
		||||
            get :options
 | 
			
		||||
 | 
			
		||||
            excluded_credentials_ids = JSON.parse(response.body)['excludeCredentials'].map { |credential| credential['id'] }
 | 
			
		||||
 
 | 
			
		||||
@@ -8,8 +8,8 @@ RSpec.describe StatusesCleanupController, type: :controller do
 | 
			
		||||
    sign_in @user, scope: :user
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "GET #show" do
 | 
			
		||||
    it "returns http success" do
 | 
			
		||||
  describe 'GET #show' do
 | 
			
		||||
    it 'returns http success' do
 | 
			
		||||
      get :show
 | 
			
		||||
      expect(response).to have_http_status(200)
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
@@ -27,8 +27,8 @@ describe WellKnown::NodeInfoController, type: :controller do
 | 
			
		||||
 | 
			
		||||
      json = body_as_json
 | 
			
		||||
 | 
			
		||||
      expect({ "foo" => 0 }).not_to match_json_schema("nodeinfo_2.0")
 | 
			
		||||
      expect(json).to match_json_schema("nodeinfo_2.0")
 | 
			
		||||
      expect({ 'foo' => 0 }).not_to match_json_schema('nodeinfo_2.0')
 | 
			
		||||
      expect(json).to match_json_schema('nodeinfo_2.0')
 | 
			
		||||
      expect(json[:version]).to eq '2.0'
 | 
			
		||||
      expect(json[:usage]).to be_a Hash
 | 
			
		||||
      expect(json[:software]).to be_a Hash
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
Fabricator(:account_moderation_note) do
 | 
			
		||||
  content "MyText"
 | 
			
		||||
  content 'MyText'
 | 
			
		||||
  account nil
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
Fabricator(:account_note) do
 | 
			
		||||
  account
 | 
			
		||||
  target_account { Fabricate(:account) }
 | 
			
		||||
  comment        "User note text"
 | 
			
		||||
  comment        'User note text'
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
Fabricator(:account_stat) do
 | 
			
		||||
  account         nil
 | 
			
		||||
  statuses_count  ""
 | 
			
		||||
  following_count ""
 | 
			
		||||
  followers_count ""
 | 
			
		||||
  statuses_count  ''
 | 
			
		||||
  following_count ''
 | 
			
		||||
  followers_count ''
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,3 @@
 | 
			
		||||
Fabricator(:account_tag_stat) do
 | 
			
		||||
  accounts_count ""
 | 
			
		||||
  accounts_count ''
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,3 @@
 | 
			
		||||
Fabricator(:account_warning_preset) do
 | 
			
		||||
  text "MyText"
 | 
			
		||||
  text 'MyText'
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
Fabricator('Admin::ActionLog') do
 | 
			
		||||
  account nil
 | 
			
		||||
  action  "MyString"
 | 
			
		||||
  action  'MyString'
 | 
			
		||||
  target  nil
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
Fabricator(:canonical_email_block) do
 | 
			
		||||
  email "test@example.com"
 | 
			
		||||
  email 'test@example.com'
 | 
			
		||||
  reference_account { Fabricate(:account) }
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
Fabricator(:conversation_account) do
 | 
			
		||||
  account                 nil
 | 
			
		||||
  conversation            nil
 | 
			
		||||
  participant_account_ids ""
 | 
			
		||||
  participant_account_ids ''
 | 
			
		||||
  last_status             nil
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,3 @@
 | 
			
		||||
Fabricator(:custom_emoji_category) do
 | 
			
		||||
  name "MyString"
 | 
			
		||||
  name 'MyString'
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,3 @@
 | 
			
		||||
Fabricator(:domain_allow) do
 | 
			
		||||
  domain "MyString"
 | 
			
		||||
  domain 'MyString'
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,6 @@ Fabricator(:encrypted_message) do
 | 
			
		||||
  from_account
 | 
			
		||||
  from_device_id   { Faker::Number.number(digits: 5) }
 | 
			
		||||
  type             0
 | 
			
		||||
  body             ""
 | 
			
		||||
  message_franking ""
 | 
			
		||||
  body             ''
 | 
			
		||||
  message_franking ''
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
Fabricator(:identity) do
 | 
			
		||||
  user     nil
 | 
			
		||||
  provider "MyString"
 | 
			
		||||
  uid      "MyString"
 | 
			
		||||
  provider 'MyString'
 | 
			
		||||
  uid      'MyString'
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
Fabricator(:ip_block) do
 | 
			
		||||
  ip         ""
 | 
			
		||||
  severity   ""
 | 
			
		||||
  expires_at "2020-10-08 22:20:37"
 | 
			
		||||
  comment    "MyText"
 | 
			
		||||
  ip         ''
 | 
			
		||||
  severity   ''
 | 
			
		||||
  expires_at '2020-10-08 22:20:37'
 | 
			
		||||
  comment    'MyText'
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
Fabricator(:list) do
 | 
			
		||||
  account
 | 
			
		||||
  title "MyString"
 | 
			
		||||
  title 'MyString'
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
Fabricator(:relay) do
 | 
			
		||||
  inbox_url "https://example.com/inbox"
 | 
			
		||||
  inbox_url 'https://example.com/inbox'
 | 
			
		||||
  state :idle
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
Fabricator(:report) do
 | 
			
		||||
  account
 | 
			
		||||
  target_account  { Fabricate(:account) }
 | 
			
		||||
  comment         "You nasty"
 | 
			
		||||
  comment         'You nasty'
 | 
			
		||||
  action_taken_at nil
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
Fabricator(:report_note) do
 | 
			
		||||
  report
 | 
			
		||||
  account { Fabricate(:account) }
 | 
			
		||||
  content "Test Content"
 | 
			
		||||
  content 'Test Content'
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
Fabricator(:session_activation) do
 | 
			
		||||
  user
 | 
			
		||||
  session_id "MyString"
 | 
			
		||||
  session_id 'MyString'
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
Fabricator(:status_edit) do
 | 
			
		||||
  status                    nil
 | 
			
		||||
  account                   nil
 | 
			
		||||
  text                      "MyText"
 | 
			
		||||
  spoiler_text              "MyText"
 | 
			
		||||
  text                      'MyText'
 | 
			
		||||
  spoiler_text              'MyText'
 | 
			
		||||
  media_attachments_changed false
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
Fabricator(:status) do
 | 
			
		||||
  account
 | 
			
		||||
  text "Lorem ipsum dolor sit amet"
 | 
			
		||||
  text 'Lorem ipsum dolor sit amet'
 | 
			
		||||
 | 
			
		||||
  after_build do |status|
 | 
			
		||||
    status.uri = Faker::Internet.device_token if !status.account.local? && status.uri.nil?
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
Fabricator(:status_stat) do
 | 
			
		||||
  status_id        nil
 | 
			
		||||
  replies_count    ""
 | 
			
		||||
  reblogs_count    ""
 | 
			
		||||
  favourites_count ""
 | 
			
		||||
  replies_count    ''
 | 
			
		||||
  reblogs_count    ''
 | 
			
		||||
  favourites_count ''
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
Fabricator(:user) do
 | 
			
		||||
  account      { Fabricate.build(:account, user: nil) }
 | 
			
		||||
  email        { sequence(:email) { |i| "#{i}#{Faker::Internet.email}" } }
 | 
			
		||||
  password     "123456789"
 | 
			
		||||
  password     '123456789'
 | 
			
		||||
  confirmed_at { Time.zone.now }
 | 
			
		||||
  agreement    true
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
Fabricator(:user_role) do
 | 
			
		||||
  name        "MyString"
 | 
			
		||||
  color       ""
 | 
			
		||||
  name        'MyString'
 | 
			
		||||
  color       ''
 | 
			
		||||
  permissions 0
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -7,8 +7,8 @@ describe 'Log in' do
 | 
			
		||||
 | 
			
		||||
  subject { page }
 | 
			
		||||
 | 
			
		||||
  let(:email)        { "test@example.com" }
 | 
			
		||||
  let(:password)     { "password" }
 | 
			
		||||
  let(:email)        { 'test@example.com' }
 | 
			
		||||
  let(:password)     { 'password' }
 | 
			
		||||
  let(:confirmed_at) { Time.zone.now }
 | 
			
		||||
 | 
			
		||||
  before do
 | 
			
		||||
 
 | 
			
		||||
@@ -13,15 +13,15 @@ RSpec.describe AccountsHelper, type: :helper do
 | 
			
		||||
 | 
			
		||||
  describe '#display_name' do
 | 
			
		||||
    it 'uses the display name when it exists' do
 | 
			
		||||
      account = Account.new(display_name: "Display", username: "Username")
 | 
			
		||||
      account = Account.new(display_name: 'Display', username: 'Username')
 | 
			
		||||
 | 
			
		||||
      expect(helper.display_name(account)).to eq "Display"
 | 
			
		||||
      expect(helper.display_name(account)).to eq 'Display'
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'uses the username when display name is nil' do
 | 
			
		||||
      account = Account.new(display_name: nil, username: "Username")
 | 
			
		||||
      account = Account.new(display_name: nil, username: 'Username')
 | 
			
		||||
 | 
			
		||||
      expect(helper.display_name(account)).to eq "Username"
 | 
			
		||||
      expect(helper.display_name(account)).to eq 'Username'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,8 @@ describe ApplicationHelper do
 | 
			
		||||
    it 'returns active when on the current page' do
 | 
			
		||||
      allow(helper).to receive(:current_page?).and_return(true)
 | 
			
		||||
 | 
			
		||||
      result = helper.active_nav_class("/test")
 | 
			
		||||
      expect(result).to eq "active"
 | 
			
		||||
      result = helper.active_nav_class('/test')
 | 
			
		||||
      expect(result).to eq 'active'
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'returns active when on a current page' do
 | 
			
		||||
@@ -14,14 +14,14 @@ describe ApplicationHelper do
 | 
			
		||||
      allow(helper).to receive(:current_page?).with('/test').and_return(true)
 | 
			
		||||
 | 
			
		||||
      result = helper.active_nav_class('/foo', '/test')
 | 
			
		||||
      expect(result).to eq "active"
 | 
			
		||||
      expect(result).to eq 'active'
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'returns empty string when not on current page' do
 | 
			
		||||
      allow(helper).to receive(:current_page?).and_return(false)
 | 
			
		||||
 | 
			
		||||
      result = helper.active_nav_class("/test")
 | 
			
		||||
      expect(result).to eq ""
 | 
			
		||||
      result = helper.active_nav_class('/test')
 | 
			
		||||
      expect(result).to eq ''
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -416,7 +416,7 @@ RSpec.describe FeedManager do
 | 
			
		||||
 | 
			
		||||
      FeedManager.instance.merge_into_home(account, reblog.account)
 | 
			
		||||
 | 
			
		||||
      expect(redis.zscore("feed:home:0", reblog.id)).to eq nil
 | 
			
		||||
      expect(redis.zscore('feed:home:0', reblog.id)).to eq nil
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
require "rails_helper"
 | 
			
		||||
require 'rails_helper'
 | 
			
		||||
 | 
			
		||||
RSpec.describe NotificationMailer, type: :mailer do
 | 
			
		||||
  let(:receiver)       { Fabricate(:user) }
 | 
			
		||||
@@ -19,69 +19,69 @@ RSpec.describe NotificationMailer, type: :mailer do
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "mention" do
 | 
			
		||||
  describe 'mention' do
 | 
			
		||||
    let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
 | 
			
		||||
    let(:mail) { NotificationMailer.mention(receiver.account, Notification.create!(account: receiver.account, activity: mention)) }
 | 
			
		||||
 | 
			
		||||
    include_examples 'localized subject', 'notification_mailer.mention.subject', name: 'bob'
 | 
			
		||||
 | 
			
		||||
    it "renders the headers" do
 | 
			
		||||
      expect(mail.subject).to eq("You were mentioned by bob")
 | 
			
		||||
    it 'renders the headers' do
 | 
			
		||||
      expect(mail.subject).to eq('You were mentioned by bob')
 | 
			
		||||
      expect(mail.to).to eq([receiver.email])
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "renders the body" do
 | 
			
		||||
      expect(mail.body.encoded).to match("You were mentioned by bob")
 | 
			
		||||
    it 'renders the body' do
 | 
			
		||||
      expect(mail.body.encoded).to match('You were mentioned by bob')
 | 
			
		||||
      expect(mail.body.encoded).to include 'The body of the foreign status'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "follow" do
 | 
			
		||||
  describe 'follow' do
 | 
			
		||||
    let(:follow) { sender.follow!(receiver.account) }
 | 
			
		||||
    let(:mail) { NotificationMailer.follow(receiver.account, Notification.create!(account: receiver.account, activity: follow)) }
 | 
			
		||||
 | 
			
		||||
    include_examples 'localized subject', 'notification_mailer.follow.subject', name: 'bob'
 | 
			
		||||
 | 
			
		||||
    it "renders the headers" do
 | 
			
		||||
      expect(mail.subject).to eq("bob is now following you")
 | 
			
		||||
    it 'renders the headers' do
 | 
			
		||||
      expect(mail.subject).to eq('bob is now following you')
 | 
			
		||||
      expect(mail.to).to eq([receiver.email])
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "renders the body" do
 | 
			
		||||
      expect(mail.body.encoded).to match("bob is now following you")
 | 
			
		||||
    it 'renders the body' do
 | 
			
		||||
      expect(mail.body.encoded).to match('bob is now following you')
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "favourite" do
 | 
			
		||||
  describe 'favourite' do
 | 
			
		||||
    let(:favourite) { Favourite.create!(account: sender, status: own_status) }
 | 
			
		||||
    let(:mail) { NotificationMailer.favourite(own_status.account, Notification.create!(account: receiver.account, activity: favourite)) }
 | 
			
		||||
 | 
			
		||||
    include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob'
 | 
			
		||||
 | 
			
		||||
    it "renders the headers" do
 | 
			
		||||
      expect(mail.subject).to eq("bob favourited your post")
 | 
			
		||||
    it 'renders the headers' do
 | 
			
		||||
      expect(mail.subject).to eq('bob favourited your post')
 | 
			
		||||
      expect(mail.to).to eq([receiver.email])
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "renders the body" do
 | 
			
		||||
      expect(mail.body.encoded).to match("Your post was favourited by bob")
 | 
			
		||||
    it 'renders the body' do
 | 
			
		||||
      expect(mail.body.encoded).to match('Your post was favourited by bob')
 | 
			
		||||
      expect(mail.body.encoded).to include 'The body of the own status'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "reblog" do
 | 
			
		||||
  describe 'reblog' do
 | 
			
		||||
    let(:reblog) { Status.create!(account: sender, reblog: own_status) }
 | 
			
		||||
    let(:mail) { NotificationMailer.reblog(own_status.account, Notification.create!(account: receiver.account, activity: reblog)) }
 | 
			
		||||
 | 
			
		||||
    include_examples 'localized subject', 'notification_mailer.reblog.subject', name: 'bob'
 | 
			
		||||
 | 
			
		||||
    it "renders the headers" do
 | 
			
		||||
      expect(mail.subject).to eq("bob boosted your post")
 | 
			
		||||
    it 'renders the headers' do
 | 
			
		||||
      expect(mail.subject).to eq('bob boosted your post')
 | 
			
		||||
      expect(mail.to).to eq([receiver.email])
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "renders the body" do
 | 
			
		||||
      expect(mail.body.encoded).to match("Your post was boosted by bob")
 | 
			
		||||
    it 'renders the body' do
 | 
			
		||||
      expect(mail.body.encoded).to match('Your post was boosted by bob')
 | 
			
		||||
      expect(mail.body.encoded).to include 'The body of the own status'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
@@ -98,7 +98,7 @@ RSpec.describe NotificationMailer, type: :mailer do
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'renders the body' do
 | 
			
		||||
      expect(mail.body.encoded).to match("bob has requested to follow you")
 | 
			
		||||
      expect(mail.body.encoded).to match('bob has requested to follow you')
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -90,7 +90,7 @@ describe UserMailer, type: :mailer do
 | 
			
		||||
 | 
			
		||||
    it 'renders warning notification' do
 | 
			
		||||
      receiver.update!(locale: nil)
 | 
			
		||||
      expect(mail.body.encoded).to include I18n.t("user_mailer.warning.title.suspend", acct: receiver.account.acct)
 | 
			
		||||
      expect(mail.body.encoded).to include I18n.t('user_mailer.warning.title.suspend', acct: receiver.account.acct)
 | 
			
		||||
      expect(mail.body.encoded).to include strike.text
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -345,9 +345,9 @@ RSpec.describe Account, type: :model do
 | 
			
		||||
    before do
 | 
			
		||||
      _missing = Fabricate(
 | 
			
		||||
        :account,
 | 
			
		||||
        display_name: "Missing",
 | 
			
		||||
        username: "missing",
 | 
			
		||||
        domain: "missing.com"
 | 
			
		||||
        display_name: 'Missing',
 | 
			
		||||
        username: 'missing',
 | 
			
		||||
        domain: 'missing.com'
 | 
			
		||||
      )
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@@ -405,58 +405,58 @@ RSpec.describe Account, type: :model do
 | 
			
		||||
    it 'finds accounts with matching display_name' do
 | 
			
		||||
      match = Fabricate(
 | 
			
		||||
        :account,
 | 
			
		||||
        display_name: "Display Name",
 | 
			
		||||
        username: "username",
 | 
			
		||||
        domain: "example.com"
 | 
			
		||||
        display_name: 'Display Name',
 | 
			
		||||
        username: 'username',
 | 
			
		||||
        domain: 'example.com'
 | 
			
		||||
      )
 | 
			
		||||
 | 
			
		||||
      results = Account.search_for("display")
 | 
			
		||||
      results = Account.search_for('display')
 | 
			
		||||
      expect(results).to eq [match]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'finds accounts with matching username' do
 | 
			
		||||
      match = Fabricate(
 | 
			
		||||
        :account,
 | 
			
		||||
        display_name: "Display Name",
 | 
			
		||||
        username: "username",
 | 
			
		||||
        domain: "example.com"
 | 
			
		||||
        display_name: 'Display Name',
 | 
			
		||||
        username: 'username',
 | 
			
		||||
        domain: 'example.com'
 | 
			
		||||
      )
 | 
			
		||||
 | 
			
		||||
      results = Account.search_for("username")
 | 
			
		||||
      results = Account.search_for('username')
 | 
			
		||||
      expect(results).to eq [match]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'finds accounts with matching domain' do
 | 
			
		||||
      match = Fabricate(
 | 
			
		||||
        :account,
 | 
			
		||||
        display_name: "Display Name",
 | 
			
		||||
        username: "username",
 | 
			
		||||
        domain: "example.com"
 | 
			
		||||
        display_name: 'Display Name',
 | 
			
		||||
        username: 'username',
 | 
			
		||||
        domain: 'example.com'
 | 
			
		||||
      )
 | 
			
		||||
 | 
			
		||||
      results = Account.search_for("example")
 | 
			
		||||
      results = Account.search_for('example')
 | 
			
		||||
      expect(results).to eq [match]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'limits by 10 by default' do
 | 
			
		||||
      11.times.each { Fabricate(:account, display_name: "Display Name") }
 | 
			
		||||
      results = Account.search_for("display")
 | 
			
		||||
      11.times.each { Fabricate(:account, display_name: 'Display Name') }
 | 
			
		||||
      results = Account.search_for('display')
 | 
			
		||||
      expect(results.size).to eq 10
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'accepts arbitrary limits' do
 | 
			
		||||
      2.times.each { Fabricate(:account, display_name: "Display Name") }
 | 
			
		||||
      results = Account.search_for("display", limit: 1)
 | 
			
		||||
      2.times.each { Fabricate(:account, display_name: 'Display Name') }
 | 
			
		||||
      results = Account.search_for('display', limit: 1)
 | 
			
		||||
      expect(results.size).to eq 1
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'ranks multiple matches higher' do
 | 
			
		||||
      matches = [
 | 
			
		||||
        { username: "username", display_name: "username" },
 | 
			
		||||
        { display_name: "Display Name", username: "username", domain: "example.com" },
 | 
			
		||||
        { username: 'username', display_name: 'username' },
 | 
			
		||||
        { display_name: 'Display Name', username: 'username', domain: 'example.com' },
 | 
			
		||||
      ].map(&method(:Fabricate).curry(2).call(:account))
 | 
			
		||||
 | 
			
		||||
      results = Account.search_for("username")
 | 
			
		||||
      results = Account.search_for('username')
 | 
			
		||||
      expect(results).to eq matches
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
@@ -582,23 +582,23 @@ RSpec.describe Account, type: :model do
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'limits by 10 by default' do
 | 
			
		||||
      11.times { Fabricate(:account, display_name: "Display Name") }
 | 
			
		||||
      results = Account.advanced_search_for("display", account)
 | 
			
		||||
      11.times { Fabricate(:account, display_name: 'Display Name') }
 | 
			
		||||
      results = Account.advanced_search_for('display', account)
 | 
			
		||||
      expect(results.size).to eq 10
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'accepts arbitrary limits' do
 | 
			
		||||
      2.times { Fabricate(:account, display_name: "Display Name") }
 | 
			
		||||
      results = Account.advanced_search_for("display", account, limit: 1)
 | 
			
		||||
      2.times { Fabricate(:account, display_name: 'Display Name') }
 | 
			
		||||
      results = Account.advanced_search_for('display', account, limit: 1)
 | 
			
		||||
      expect(results.size).to eq 1
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'ranks followed accounts higher' do
 | 
			
		||||
      match = Fabricate(:account, username: "Matching")
 | 
			
		||||
      followed_match = Fabricate(:account, username: "Matcher")
 | 
			
		||||
      match = Fabricate(:account, username: 'Matching')
 | 
			
		||||
      followed_match = Fabricate(:account, username: 'Matcher')
 | 
			
		||||
      Fabricate(:follow, account: account, target_account: followed_match)
 | 
			
		||||
 | 
			
		||||
      results = Account.advanced_search_for("match", account)
 | 
			
		||||
      results = Account.advanced_search_for('match', account)
 | 
			
		||||
      expect(results).to eq [followed_match, match]
 | 
			
		||||
      expect(results.first.rank).to be > results.last.rank
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
@@ -94,8 +94,8 @@ RSpec.describe MediaAttachment, type: :model do
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'sets meta' do
 | 
			
		||||
      expect(media.file.meta["original"]["width"]).to eq 128
 | 
			
		||||
      expect(media.file.meta["original"]["height"]).to eq 128
 | 
			
		||||
      expect(media.file.meta['original']['width']).to eq 128
 | 
			
		||||
      expect(media.file.meta['original']['height']).to eq 128
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@@ -118,9 +118,9 @@ RSpec.describe MediaAttachment, type: :model do
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        it 'sets meta' do
 | 
			
		||||
          expect(media.file.meta["original"]["width"]).to eq fixture[:width]
 | 
			
		||||
          expect(media.file.meta["original"]["height"]).to eq fixture[:height]
 | 
			
		||||
          expect(media.file.meta["original"]["aspect"]).to eq fixture[:aspect]
 | 
			
		||||
          expect(media.file.meta['original']['width']).to eq fixture[:width]
 | 
			
		||||
          expect(media.file.meta['original']['height']).to eq fixture[:height]
 | 
			
		||||
          expect(media.file.meta['original']['aspect']).to eq fixture[:aspect]
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
@@ -154,12 +154,12 @@ RSpec.describe MediaAttachment, type: :model do
 | 
			
		||||
    let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }
 | 
			
		||||
 | 
			
		||||
    it 'sets meta for different style' do
 | 
			
		||||
      expect(media.file.meta["original"]["width"]).to eq 600
 | 
			
		||||
      expect(media.file.meta["original"]["height"]).to eq 400
 | 
			
		||||
      expect(media.file.meta["original"]["aspect"]).to eq 1.5
 | 
			
		||||
      expect(media.file.meta["small"]["width"]).to eq 588
 | 
			
		||||
      expect(media.file.meta["small"]["height"]).to eq 392
 | 
			
		||||
      expect(media.file.meta["small"]["aspect"]).to eq 1.5
 | 
			
		||||
      expect(media.file.meta['original']['width']).to eq 600
 | 
			
		||||
      expect(media.file.meta['original']['height']).to eq 400
 | 
			
		||||
      expect(media.file.meta['original']['aspect']).to eq 1.5
 | 
			
		||||
      expect(media.file.meta['small']['width']).to eq 588
 | 
			
		||||
      expect(media.file.meta['small']['height']).to eq 392
 | 
			
		||||
      expect(media.file.meta['small']['aspect']).to eq 1.5
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'gives the file a random name' do
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ RSpec.describe Web::PushSubscription, type: :model do
 | 
			
		||||
      context "when notification is a #{type}" do
 | 
			
		||||
        let(:notification_type) { type }
 | 
			
		||||
 | 
			
		||||
        it "returns boolean corresponding to alert setting" do
 | 
			
		||||
        it 'returns boolean corresponding to alert setting' do
 | 
			
		||||
          expect(subject.pushable?(notification)).to eq data[:alerts][type]
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 
 | 
			
		||||
@@ -35,8 +35,8 @@ RSpec.describe WebauthnCredential, type: :model do
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'is invalid if already exist a webauthn credential with the same external id' do
 | 
			
		||||
      existing_webauthn_credential = Fabricate(:webauthn_credential, external_id: "_Typ0ygudDnk9YUVWLQayw")
 | 
			
		||||
      new_webauthn_credential = Fabricate.build(:webauthn_credential, external_id: "_Typ0ygudDnk9YUVWLQayw")
 | 
			
		||||
      existing_webauthn_credential = Fabricate(:webauthn_credential, external_id: '_Typ0ygudDnk9YUVWLQayw')
 | 
			
		||||
      new_webauthn_credential = Fabricate.build(:webauthn_credential, external_id: '_Typ0ygudDnk9YUVWLQayw')
 | 
			
		||||
 | 
			
		||||
      new_webauthn_credential.valid?
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,9 +10,9 @@ describe InstancePresenter do
 | 
			
		||||
      Setting.site_short_description = site_description
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "delegates site_description to Setting" do
 | 
			
		||||
      Setting.site_short_description = "Site desc"
 | 
			
		||||
      expect(instance_presenter.description).to eq "Site desc"
 | 
			
		||||
    it 'delegates site_description to Setting' do
 | 
			
		||||
      Setting.site_short_description = 'Site desc'
 | 
			
		||||
      expect(instance_presenter.description).to eq 'Site desc'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@@ -23,9 +23,9 @@ describe InstancePresenter do
 | 
			
		||||
      Setting.site_extended_description = site_extended_description
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "delegates site_extended_description to Setting" do
 | 
			
		||||
      Setting.site_extended_description = "Extended desc"
 | 
			
		||||
      expect(instance_presenter.extended_description).to eq "Extended desc"
 | 
			
		||||
    it 'delegates site_extended_description to Setting' do
 | 
			
		||||
      Setting.site_extended_description = 'Extended desc'
 | 
			
		||||
      expect(instance_presenter.extended_description).to eq 'Extended desc'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@@ -36,9 +36,9 @@ describe InstancePresenter do
 | 
			
		||||
      Setting.site_contact_email = site_contact_email
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "delegates contact_email to Setting" do
 | 
			
		||||
      Setting.site_contact_email = "admin@example.com"
 | 
			
		||||
      expect(instance_presenter.contact.email).to eq "admin@example.com"
 | 
			
		||||
    it 'delegates contact_email to Setting' do
 | 
			
		||||
      Setting.site_contact_email = 'admin@example.com'
 | 
			
		||||
      expect(instance_presenter.contact.email).to eq 'admin@example.com'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@@ -49,15 +49,15 @@ describe InstancePresenter do
 | 
			
		||||
      Setting.site_contact_username = site_contact_username
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "returns the account for the site contact username" do
 | 
			
		||||
      Setting.site_contact_username = "aaa"
 | 
			
		||||
      account = Fabricate(:account, username: "aaa")
 | 
			
		||||
    it 'returns the account for the site contact username' do
 | 
			
		||||
      Setting.site_contact_username = 'aaa'
 | 
			
		||||
      account = Fabricate(:account, username: 'aaa')
 | 
			
		||||
      expect(instance_presenter.contact.account).to eq(account)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe '#user_count' do
 | 
			
		||||
    it "returns the number of site users" do
 | 
			
		||||
    it 'returns the number of site users' do
 | 
			
		||||
      Rails.cache.write 'user_count', 123
 | 
			
		||||
 | 
			
		||||
      expect(instance_presenter.user_count).to eq(123)
 | 
			
		||||
@@ -65,7 +65,7 @@ describe InstancePresenter do
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe '#status_count' do
 | 
			
		||||
    it "returns the number of local statuses" do
 | 
			
		||||
    it 'returns the number of local statuses' do
 | 
			
		||||
      Rails.cache.write 'local_status_count', 234
 | 
			
		||||
 | 
			
		||||
      expect(instance_presenter.status_count).to eq(234)
 | 
			
		||||
@@ -73,7 +73,7 @@ describe InstancePresenter do
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe '#domain_count' do
 | 
			
		||||
    it "returns the number of known domains" do
 | 
			
		||||
    it 'returns the number of known domains' do
 | 
			
		||||
      Rails.cache.write 'distinct_domain_count', 345
 | 
			
		||||
 | 
			
		||||
      expect(instance_presenter.domain_count).to eq(345)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
ENV['RAILS_ENV'] ||= 'test'
 | 
			
		||||
require File.expand_path('../config/environment', __dir__)
 | 
			
		||||
 | 
			
		||||
abort("The Rails environment is running in production mode!") if Rails.env.production?
 | 
			
		||||
abort('The Rails environment is running in production mode!') if Rails.env.production?
 | 
			
		||||
 | 
			
		||||
require 'spec_helper'
 | 
			
		||||
require 'rspec/rails'
 | 
			
		||||
 
 | 
			
		||||
@@ -1,21 +1,21 @@
 | 
			
		||||
require "rails_helper"
 | 
			
		||||
require 'rails_helper'
 | 
			
		||||
 | 
			
		||||
describe "The catch all route" do
 | 
			
		||||
  describe "with a simple value" do
 | 
			
		||||
    it "returns a 404 page as html" do
 | 
			
		||||
      get "/test"
 | 
			
		||||
describe 'The catch all route' do
 | 
			
		||||
  describe 'with a simple value' do
 | 
			
		||||
    it 'returns a 404 page as html' do
 | 
			
		||||
      get '/test'
 | 
			
		||||
 | 
			
		||||
      expect(response.status).to eq 404
 | 
			
		||||
      expect(response.media_type).to eq "text/html"
 | 
			
		||||
      expect(response.media_type).to eq 'text/html'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "with an implied format" do
 | 
			
		||||
    it "returns a 404 page as html" do
 | 
			
		||||
      get "/test.test"
 | 
			
		||||
  describe 'with an implied format' do
 | 
			
		||||
    it 'returns a 404 page as html' do
 | 
			
		||||
      get '/test.test'
 | 
			
		||||
 | 
			
		||||
      expect(response.status).to eq 404
 | 
			
		||||
      expect(response.media_type).to eq "text/html"
 | 
			
		||||
      expect(response.media_type).to eq 'text/html'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,12 @@
 | 
			
		||||
require "rails_helper"
 | 
			
		||||
require 'rails_helper'
 | 
			
		||||
 | 
			
		||||
describe "The host_meta route" do
 | 
			
		||||
  describe "requested without accepts headers" do
 | 
			
		||||
    it "returns an xml response" do
 | 
			
		||||
describe 'The host_meta route' do
 | 
			
		||||
  describe 'requested without accepts headers' do
 | 
			
		||||
    it 'returns an xml response' do
 | 
			
		||||
      get host_meta_url
 | 
			
		||||
 | 
			
		||||
      expect(response).to have_http_status(200)
 | 
			
		||||
      expect(response.media_type).to eq "application/xrd+xml"
 | 
			
		||||
      expect(response.media_type).to eq 'application/xrd+xml'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ describe 'Localization' do
 | 
			
		||||
  it 'uses a specific region when provided' do
 | 
			
		||||
    headers = { 'Accept-Language' => 'zh-HK' }
 | 
			
		||||
 | 
			
		||||
    get "/auth/sign_in", headers: headers
 | 
			
		||||
    get '/auth/sign_in', headers: headers
 | 
			
		||||
 | 
			
		||||
    expect(response.body).to include(
 | 
			
		||||
      I18n.t('auth.login', locale: 'zh-HK')
 | 
			
		||||
@@ -20,7 +20,7 @@ describe 'Localization' do
 | 
			
		||||
  it 'falls back to a locale when region missing' do
 | 
			
		||||
    headers = { 'Accept-Language' => 'es-FAKE' }
 | 
			
		||||
 | 
			
		||||
    get "/auth/sign_in", headers: headers
 | 
			
		||||
    get '/auth/sign_in', headers: headers
 | 
			
		||||
 | 
			
		||||
    expect(response.body).to include(
 | 
			
		||||
      I18n.t('auth.login', locale: 'es')
 | 
			
		||||
@@ -30,7 +30,7 @@ describe 'Localization' do
 | 
			
		||||
  it 'falls back to english when locale is missing' do
 | 
			
		||||
    headers = { 'Accept-Language' => '12-FAKE' }
 | 
			
		||||
 | 
			
		||||
    get "/auth/sign_in", headers: headers
 | 
			
		||||
    get '/auth/sign_in', headers: headers
 | 
			
		||||
 | 
			
		||||
    expect(response.body).to include(
 | 
			
		||||
      I18n.t('auth.login', locale: 'en')
 | 
			
		||||
 
 | 
			
		||||
@@ -76,7 +76,7 @@ describe AccountSearchService, type: :service do
 | 
			
		||||
      expect(results).to eq [partial]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "does not return suspended remote accounts" do
 | 
			
		||||
    it 'does not return suspended remote accounts' do
 | 
			
		||||
      remote  = Fabricate(:account, username: 'a', domain: 'remote', display_name: 'e', suspended: true)
 | 
			
		||||
      results = subject.call('a@example.com', nil, limit: 2)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
  let(:note) do
 | 
			
		||||
    {
 | 
			
		||||
      '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
      id: "https://foo.bar/@foo/1234",
 | 
			
		||||
      id: 'https://foo.bar/@foo/1234',
 | 
			
		||||
      type: 'Note',
 | 
			
		||||
      content: 'Lorem ipsum',
 | 
			
		||||
      attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
 | 
			
		||||
@@ -46,7 +46,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
      let(:object) do
 | 
			
		||||
        {
 | 
			
		||||
          '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
          id: "https://foo.bar/@foo/1234",
 | 
			
		||||
          id: 'https://foo.bar/@foo/1234',
 | 
			
		||||
          type: 'Video',
 | 
			
		||||
          name: 'Nyan Cat 10 hours remix',
 | 
			
		||||
          attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
 | 
			
		||||
@@ -54,13 +54,13 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
            {
 | 
			
		||||
              type: 'Link',
 | 
			
		||||
              mimeType: 'application/x-bittorrent',
 | 
			
		||||
              href: "https://foo.bar/12345.torrent",
 | 
			
		||||
              href: 'https://foo.bar/12345.torrent',
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
            {
 | 
			
		||||
              type: 'Link',
 | 
			
		||||
              mimeType: 'text/html',
 | 
			
		||||
              href: "https://foo.bar/watch?v=12345",
 | 
			
		||||
              href: 'https://foo.bar/watch?v=12345',
 | 
			
		||||
            },
 | 
			
		||||
          ],
 | 
			
		||||
        }
 | 
			
		||||
@@ -70,8 +70,8 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
        status = sender.statuses.first
 | 
			
		||||
 | 
			
		||||
        expect(status).to_not be_nil
 | 
			
		||||
        expect(status.url).to eq "https://foo.bar/watch?v=12345"
 | 
			
		||||
        expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345"
 | 
			
		||||
        expect(status.url).to eq 'https://foo.bar/watch?v=12345'
 | 
			
		||||
        expect(strip_tags(status.text)).to eq 'Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@@ -79,7 +79,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
      let(:object) do
 | 
			
		||||
        {
 | 
			
		||||
          '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
          id: "https://foo.bar/@foo/1234",
 | 
			
		||||
          id: 'https://foo.bar/@foo/1234',
 | 
			
		||||
          type: 'Audio',
 | 
			
		||||
          name: 'Nyan Cat 10 hours remix',
 | 
			
		||||
          attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
 | 
			
		||||
@@ -87,13 +87,13 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
            {
 | 
			
		||||
              type: 'Link',
 | 
			
		||||
              mimeType: 'application/x-bittorrent',
 | 
			
		||||
              href: "https://foo.bar/12345.torrent",
 | 
			
		||||
              href: 'https://foo.bar/12345.torrent',
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
            {
 | 
			
		||||
              type: 'Link',
 | 
			
		||||
              mimeType: 'text/html',
 | 
			
		||||
              href: "https://foo.bar/watch?v=12345",
 | 
			
		||||
              href: 'https://foo.bar/watch?v=12345',
 | 
			
		||||
            },
 | 
			
		||||
          ],
 | 
			
		||||
        }
 | 
			
		||||
@@ -103,8 +103,8 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
        status = sender.statuses.first
 | 
			
		||||
 | 
			
		||||
        expect(status).to_not be_nil
 | 
			
		||||
        expect(status.url).to eq "https://foo.bar/watch?v=12345"
 | 
			
		||||
        expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345"
 | 
			
		||||
        expect(status.url).to eq 'https://foo.bar/watch?v=12345'
 | 
			
		||||
        expect(strip_tags(status.text)).to eq 'Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@@ -112,7 +112,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
      let(:object) do
 | 
			
		||||
        {
 | 
			
		||||
          '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
          id: "https://foo.bar/@foo/1234",
 | 
			
		||||
          id: 'https://foo.bar/@foo/1234',
 | 
			
		||||
          type: 'Event',
 | 
			
		||||
          name: "Let's change the world",
 | 
			
		||||
          attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
 | 
			
		||||
@@ -123,7 +123,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
        status = sender.statuses.first
 | 
			
		||||
 | 
			
		||||
        expect(status).to_not be_nil
 | 
			
		||||
        expect(status.url).to eq "https://foo.bar/@foo/1234"
 | 
			
		||||
        expect(status.url).to eq 'https://foo.bar/@foo/1234'
 | 
			
		||||
        expect(strip_tags(status.text)).to eq "Let's change the worldhttps://foo.bar/@foo/1234"
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
@@ -132,7 +132,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
      let(:note) do
 | 
			
		||||
        {
 | 
			
		||||
          '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
          id: "https://real.address/@foo/1234",
 | 
			
		||||
          id: 'https://real.address/@foo/1234',
 | 
			
		||||
          type: 'Note',
 | 
			
		||||
          content: 'Lorem ipsum',
 | 
			
		||||
          attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
 | 
			
		||||
@@ -154,7 +154,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
      let(:object) do
 | 
			
		||||
        {
 | 
			
		||||
          '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
          id: "https://foo.bar/@foo/1234/create",
 | 
			
		||||
          id: 'https://foo.bar/@foo/1234/create',
 | 
			
		||||
          type: 'Create',
 | 
			
		||||
          actor: ActivityPub::TagManager.instance.uri_for(sender),
 | 
			
		||||
          object: note,
 | 
			
		||||
@@ -174,11 +174,11 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
      let(:object) do
 | 
			
		||||
        {
 | 
			
		||||
          '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
          id: "https://foo.bar/@foo/1234/create",
 | 
			
		||||
          id: 'https://foo.bar/@foo/1234/create',
 | 
			
		||||
          type: 'Create',
 | 
			
		||||
          actor: ActivityPub::TagManager.instance.uri_for(sender),
 | 
			
		||||
          object: {
 | 
			
		||||
            id: "https://real.address/@foo/1234",
 | 
			
		||||
            id: 'https://real.address/@foo/1234',
 | 
			
		||||
            type: 'Note',
 | 
			
		||||
            content: 'Lorem ipsum',
 | 
			
		||||
            attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
 | 
			
		||||
@@ -208,7 +208,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
        let(:object) do
 | 
			
		||||
          {
 | 
			
		||||
            '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
            id: "https://foo.bar/@foo/1234/create",
 | 
			
		||||
            id: 'https://foo.bar/@foo/1234/create',
 | 
			
		||||
            type: 'Create',
 | 
			
		||||
            actor: ActivityPub::TagManager.instance.uri_for(sender),
 | 
			
		||||
            object: note.merge(updated: '2021-09-08T22:39:25Z'),
 | 
			
		||||
@@ -233,7 +233,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
      let(:object) do
 | 
			
		||||
        {
 | 
			
		||||
          '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
          id: "https://foo.bar/@foo/1",
 | 
			
		||||
          id: 'https://foo.bar/@foo/1',
 | 
			
		||||
          type: 'Note',
 | 
			
		||||
          content: 'Lorem ipsum',
 | 
			
		||||
          inReplyTo: 'https://foo.bar/@foo/2',
 | 
			
		||||
@@ -269,7 +269,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
 | 
			
		||||
      let(:object) do
 | 
			
		||||
        {
 | 
			
		||||
          '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
          id: "https://foo.bar/@foo/1",
 | 
			
		||||
          id: 'https://foo.bar/@foo/1',
 | 
			
		||||
          type: 'Note',
 | 
			
		||||
          content: 'Lorem ipsum',
 | 
			
		||||
          replies: {
 | 
			
		||||
 
 | 
			
		||||
@@ -59,8 +59,8 @@ RSpec.describe DeleteAccountService, type: :service do
 | 
			
		||||
 | 
			
		||||
  describe '#call on local account' do
 | 
			
		||||
    before do
 | 
			
		||||
      stub_request(:post, "https://alice.com/inbox").to_return(status: 201)
 | 
			
		||||
      stub_request(:post, "https://bob.com/inbox").to_return(status: 201)
 | 
			
		||||
      stub_request(:post, 'https://alice.com/inbox').to_return(status: 201)
 | 
			
		||||
      stub_request(:post, 'https://bob.com/inbox').to_return(status: 201)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    let!(:remote_alice) { Fabricate(:account, inbox_url: 'https://alice.com/inbox', protocol: :activitypub) }
 | 
			
		||||
@@ -72,16 +72,16 @@ RSpec.describe DeleteAccountService, type: :service do
 | 
			
		||||
 | 
			
		||||
      it 'sends a delete actor activity to all known inboxes' do
 | 
			
		||||
        subject
 | 
			
		||||
        expect(a_request(:post, "https://alice.com/inbox")).to have_been_made.once
 | 
			
		||||
        expect(a_request(:post, "https://bob.com/inbox")).to have_been_made.once
 | 
			
		||||
        expect(a_request(:post, 'https://alice.com/inbox')).to have_been_made.once
 | 
			
		||||
        expect(a_request(:post, 'https://bob.com/inbox')).to have_been_made.once
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe '#call on remote account' do
 | 
			
		||||
    before do
 | 
			
		||||
      stub_request(:post, "https://alice.com/inbox").to_return(status: 201)
 | 
			
		||||
      stub_request(:post, "https://bob.com/inbox").to_return(status: 201)
 | 
			
		||||
      stub_request(:post, 'https://alice.com/inbox').to_return(status: 201)
 | 
			
		||||
      stub_request(:post, 'https://bob.com/inbox').to_return(status: 201)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    include_examples 'common behavior' do
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ RSpec.describe FavouriteService, type: :service do
 | 
			
		||||
    let(:status) { Fabricate(:status, account: bob) }
 | 
			
		||||
 | 
			
		||||
    before do
 | 
			
		||||
      stub_request(:post, "http://example.com/inbox").to_return(status: 200, body: "", headers: {})
 | 
			
		||||
      stub_request(:post, 'http://example.com/inbox').to_return(status: 200, body: '', headers: {})
 | 
			
		||||
      subject.call(sender, status)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@@ -32,7 +32,7 @@ RSpec.describe FavouriteService, type: :service do
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'sends a like activity' do
 | 
			
		||||
      expect(a_request(:post, "http://example.com/inbox")).to have_been_made.once
 | 
			
		||||
      expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ RSpec.describe FetchLinkCardService, type: :service do
 | 
			
		||||
 | 
			
		||||
      it 'works with SJIS' do
 | 
			
		||||
        expect(a_request(:get, 'http://example.com/sjis')).to have_been_made.at_least_once
 | 
			
		||||
        expect(status.preview_cards.first.title).to eq("SJISのページ")
 | 
			
		||||
        expect(status.preview_cards.first.title).to eq('SJISのページ')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@@ -39,7 +39,7 @@ RSpec.describe FetchLinkCardService, type: :service do
 | 
			
		||||
 | 
			
		||||
      it 'works with SJIS even with wrong charset header' do
 | 
			
		||||
        expect(a_request(:get, 'http://example.com/sjis_with_wrong_charset')).to have_been_made.at_least_once
 | 
			
		||||
        expect(status.preview_cards.first.title).to eq("SJISのページ")
 | 
			
		||||
        expect(status.preview_cards.first.title).to eq('SJISのページ')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@@ -48,7 +48,7 @@ RSpec.describe FetchLinkCardService, type: :service do
 | 
			
		||||
 | 
			
		||||
      it 'works with koi8-r' do
 | 
			
		||||
        expect(a_request(:get, 'http://example.com/koi8-r')).to have_been_made.at_least_once
 | 
			
		||||
        expect(status.preview_cards.first.title).to eq("Московя начинаетъ только въ XVI ст. привлекать внимане иностранцевъ.")
 | 
			
		||||
        expect(status.preview_cards.first.title).to eq('Московя начинаетъ только въ XVI ст. привлекать внимане иностранцевъ.')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@@ -66,7 +66,7 @@ RSpec.describe FetchLinkCardService, type: :service do
 | 
			
		||||
 | 
			
		||||
      it 'works with Japanese path string' do
 | 
			
		||||
        expect(a_request(:get, 'http://example.com/日本語')).to have_been_made.at_least_once
 | 
			
		||||
        expect(status.preview_cards.first.title).to eq("SJISのページ")
 | 
			
		||||
        expect(status.preview_cards.first.title).to eq('SJISのページ')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -6,9 +6,9 @@ describe FetchOEmbedService, type: :service do
 | 
			
		||||
  subject { described_class.new }
 | 
			
		||||
 | 
			
		||||
  before do
 | 
			
		||||
    stub_request(:get, "https://host.test/provider.json").to_return(status: 404)
 | 
			
		||||
    stub_request(:get, "https://host.test/provider.xml").to_return(status: 404)
 | 
			
		||||
    stub_request(:get, "https://host.test/empty_provider.json").to_return(status: 200)
 | 
			
		||||
    stub_request(:get, 'https://host.test/provider.json').to_return(status: 404)
 | 
			
		||||
    stub_request(:get, 'https://host.test/provider.xml').to_return(status: 404)
 | 
			
		||||
    stub_request(:get, 'https://host.test/empty_provider.json').to_return(status: 200)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe 'discover_provider' do
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ RSpec.describe FetchRemoteStatusService, type: :service do
 | 
			
		||||
  let(:note) do
 | 
			
		||||
    {
 | 
			
		||||
      '@context': 'https://www.w3.org/ns/activitystreams',
 | 
			
		||||
      id: "https://example.org/@foo/1234",
 | 
			
		||||
      id: 'https://example.org/@foo/1234',
 | 
			
		||||
      type: 'Note',
 | 
			
		||||
      content: 'Lorem ipsum',
 | 
			
		||||
      attributedTo: ActivityPub::TagManager.instance.uri_for(account),
 | 
			
		||||
 
 | 
			
		||||
@@ -140,7 +140,7 @@ RSpec.describe FollowService, type: :service do
 | 
			
		||||
    let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
 | 
			
		||||
 | 
			
		||||
    before do
 | 
			
		||||
      stub_request(:post, "http://example.com/inbox").to_return(status: 200, body: "", headers: {})
 | 
			
		||||
      stub_request(:post, 'http://example.com/inbox').to_return(status: 200, body: '', headers: {})
 | 
			
		||||
      subject.call(sender, bob)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ RSpec.describe ImportService, type: :service do
 | 
			
		||||
  let!(:eve)     { Fabricate(:account, username: 'eve', domain: 'example.com', locked: false, protocol: :activitypub, inbox_url: 'https://example.com/inbox') }
 | 
			
		||||
 | 
			
		||||
  before do
 | 
			
		||||
    stub_request(:post, "https://example.com/inbox").to_return(status: 200)
 | 
			
		||||
    stub_request(:post, 'https://example.com/inbox').to_return(status: 200)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context 'import old-style list of muted users' do
 | 
			
		||||
@@ -186,7 +186,7 @@ RSpec.describe ImportService, type: :service do
 | 
			
		||||
 | 
			
		||||
    # Make sure to not actually go to the remote server
 | 
			
		||||
    before do
 | 
			
		||||
      stub_request(:post, "https://թութ.հայ/inbox").to_return(status: 200)
 | 
			
		||||
      stub_request(:post, 'https://թութ.հայ/inbox').to_return(status: 200)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    let(:csv) { attachment_fixture('utf8-followers.txt') }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
 | 
			
		||||
  it 'creates a new status' do
 | 
			
		||||
    account = Fabricate(:account)
 | 
			
		||||
    text = "test status update"
 | 
			
		||||
    text = 'test status update'
 | 
			
		||||
 | 
			
		||||
    status = subject.call(account, text: text)
 | 
			
		||||
 | 
			
		||||
@@ -16,7 +16,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
  it 'creates a new response status' do
 | 
			
		||||
    in_reply_to_status = Fabricate(:status)
 | 
			
		||||
    account = Fabricate(:account)
 | 
			
		||||
    text = "test status update"
 | 
			
		||||
    text = 'test status update'
 | 
			
		||||
 | 
			
		||||
    status = subject.call(account, text: text, thread: in_reply_to_status)
 | 
			
		||||
 | 
			
		||||
@@ -58,7 +58,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
    boosted_status = Fabricate(:status)
 | 
			
		||||
    in_reply_to_status = Fabricate(:status, reblog: boosted_status)
 | 
			
		||||
    account = Fabricate(:account)
 | 
			
		||||
    text = "test status update"
 | 
			
		||||
    text = 'test status update'
 | 
			
		||||
 | 
			
		||||
    status = subject.call(account, text: text, thread: in_reply_to_status)
 | 
			
		||||
 | 
			
		||||
@@ -75,7 +75,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it 'creates a status with spoiler text' do
 | 
			
		||||
    spoiler_text = "spoiler text"
 | 
			
		||||
    spoiler_text = 'spoiler text'
 | 
			
		||||
 | 
			
		||||
    status = create_status_with_options(spoiler_text: spoiler_text)
 | 
			
		||||
 | 
			
		||||
@@ -101,14 +101,14 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
    status = create_status_with_options(visibility: :private)
 | 
			
		||||
 | 
			
		||||
    expect(status).to be_persisted
 | 
			
		||||
    expect(status.visibility).to eq "private"
 | 
			
		||||
    expect(status.visibility).to eq 'private'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it 'creates a status with limited visibility for silenced users' do
 | 
			
		||||
    status = subject.call(Fabricate(:account, silenced: true), text: 'test', visibility: :public)
 | 
			
		||||
 | 
			
		||||
    expect(status).to be_persisted
 | 
			
		||||
    expect(status.visibility).to eq "unlisted"
 | 
			
		||||
    expect(status.visibility).to eq 'unlisted'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it 'creates a status for the given application' do
 | 
			
		||||
@@ -135,7 +135,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
    allow(ProcessMentionsService).to receive(:new).and_return(mention_service)
 | 
			
		||||
    account = Fabricate(:account)
 | 
			
		||||
 | 
			
		||||
    status = subject.call(account, text: "test status update")
 | 
			
		||||
    status = subject.call(account, text: 'test status update')
 | 
			
		||||
 | 
			
		||||
    expect(ProcessMentionsService).to have_received(:new)
 | 
			
		||||
    expect(mention_service).to have_received(:call).with(status, save_records: false)
 | 
			
		||||
@@ -166,7 +166,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
    allow(ProcessHashtagsService).to receive(:new).and_return(hashtags_service)
 | 
			
		||||
    account = Fabricate(:account)
 | 
			
		||||
 | 
			
		||||
    status = subject.call(account, text: "test status update")
 | 
			
		||||
    status = subject.call(account, text: 'test status update')
 | 
			
		||||
 | 
			
		||||
    expect(ProcessHashtagsService).to have_received(:new)
 | 
			
		||||
    expect(hashtags_service).to have_received(:call).with(status)
 | 
			
		||||
@@ -178,7 +178,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
 | 
			
		||||
    account = Fabricate(:account)
 | 
			
		||||
 | 
			
		||||
    status = subject.call(account, text: "test status update")
 | 
			
		||||
    status = subject.call(account, text: 'test status update')
 | 
			
		||||
 | 
			
		||||
    expect(DistributionWorker).to have_received(:perform_async).with(status.id)
 | 
			
		||||
    expect(ActivityPub::DistributionWorker).to have_received(:perform_async).with(status.id)
 | 
			
		||||
@@ -188,7 +188,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
    allow(LinkCrawlWorker).to receive(:perform_async)
 | 
			
		||||
    account = Fabricate(:account)
 | 
			
		||||
 | 
			
		||||
    status = subject.call(account, text: "test status update")
 | 
			
		||||
    status = subject.call(account, text: 'test status update')
 | 
			
		||||
 | 
			
		||||
    expect(LinkCrawlWorker).to have_received(:perform_async).with(status.id)
 | 
			
		||||
  end
 | 
			
		||||
@@ -199,7 +199,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
 | 
			
		||||
    status = subject.call(
 | 
			
		||||
      account,
 | 
			
		||||
      text: "test status update",
 | 
			
		||||
      text: 'test status update',
 | 
			
		||||
      media_ids: [media.id]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
@@ -212,7 +212,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
 | 
			
		||||
    status = subject.call(
 | 
			
		||||
      account,
 | 
			
		||||
      text: "test status update",
 | 
			
		||||
      text: 'test status update',
 | 
			
		||||
      media_ids: [media.id]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
@@ -225,7 +225,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
    expect do
 | 
			
		||||
      subject.call(
 | 
			
		||||
        account,
 | 
			
		||||
        text: "test status update",
 | 
			
		||||
        text: 'test status update',
 | 
			
		||||
        media_ids: [
 | 
			
		||||
          Fabricate(:media_attachment, account: account),
 | 
			
		||||
          Fabricate(:media_attachment, account: account),
 | 
			
		||||
@@ -250,7 +250,7 @@ RSpec.describe PostStatusService, type: :service do
 | 
			
		||||
    expect do
 | 
			
		||||
      subject.call(
 | 
			
		||||
        account,
 | 
			
		||||
        text: "test status update",
 | 
			
		||||
        text: 'test status update',
 | 
			
		||||
        media_ids: [
 | 
			
		||||
          video,
 | 
			
		||||
          image,
 | 
			
		||||
 
 | 
			
		||||
@@ -62,7 +62,7 @@ RSpec.describe ProcessMentionsService, type: :service do
 | 
			
		||||
 | 
			
		||||
      context 'with an IDN domain' do
 | 
			
		||||
        let!(:remote_user) { Fabricate(:account, username: 'sneak', protocol: :activitypub, domain: 'xn--hresiar-mxa.ch', inbox_url: 'http://example.com/inbox') }
 | 
			
		||||
        let!(:status) { Fabricate(:status, account: account, text: "Hello @sneak@hæresiar.ch") }
 | 
			
		||||
        let!(:status) { Fabricate(:status, account: account, text: 'Hello @sneak@hæresiar.ch') }
 | 
			
		||||
 | 
			
		||||
        before do
 | 
			
		||||
          subject.call(status)
 | 
			
		||||
@@ -75,7 +75,7 @@ RSpec.describe ProcessMentionsService, type: :service do
 | 
			
		||||
 | 
			
		||||
      context 'with an IDN TLD' do
 | 
			
		||||
        let!(:remote_user) { Fabricate(:account, username: 'foo', protocol: :activitypub, domain: 'xn--y9a3aq.xn--y9a3aq', inbox_url: 'http://example.com/inbox') }
 | 
			
		||||
        let!(:status) { Fabricate(:status, account: account, text: "Hello @foo@հայ.հայ") }
 | 
			
		||||
        let!(:status) { Fabricate(:status, account: account, text: 'Hello @foo@հայ.հայ') }
 | 
			
		||||
 | 
			
		||||
        before do
 | 
			
		||||
          subject.call(status)
 | 
			
		||||
@@ -91,8 +91,8 @@ RSpec.describe ProcessMentionsService, type: :service do
 | 
			
		||||
      let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox', last_webfingered_at: nil) }
 | 
			
		||||
 | 
			
		||||
      before do
 | 
			
		||||
        stub_request(:get, "https://example.com/.well-known/host-meta").to_return(status: 404)
 | 
			
		||||
        stub_request(:get, "https://example.com/.well-known/webfinger?resource=acct:remote_user@example.com").to_return(status: 500)
 | 
			
		||||
        stub_request(:get, 'https://example.com/.well-known/host-meta').to_return(status: 404)
 | 
			
		||||
        stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:remote_user@example.com').to_return(status: 500)
 | 
			
		||||
        subject.call(status)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,11 +4,11 @@ RSpec.describe ResolveAccountService, type: :service do
 | 
			
		||||
  subject { described_class.new }
 | 
			
		||||
 | 
			
		||||
  before do
 | 
			
		||||
    stub_request(:get, "https://example.com/.well-known/host-meta").to_return(status: 404)
 | 
			
		||||
    stub_request(:get, "https://quitter.no/avatar/7477-300-20160211190340.png").to_return(request_fixture('avatar.txt'))
 | 
			
		||||
    stub_request(:get, "https://ap.example.com/.well-known/webfinger?resource=acct:foo@ap.example.com").to_return(request_fixture('activitypub-webfinger.txt'))
 | 
			
		||||
    stub_request(:get, "https://ap.example.com/users/foo").to_return(request_fixture('activitypub-actor.txt'))
 | 
			
		||||
    stub_request(:get, "https://ap.example.com/users/foo.atom").to_return(request_fixture('activitypub-feed.txt'))
 | 
			
		||||
    stub_request(:get, 'https://example.com/.well-known/host-meta').to_return(status: 404)
 | 
			
		||||
    stub_request(:get, 'https://quitter.no/avatar/7477-300-20160211190340.png').to_return(request_fixture('avatar.txt'))
 | 
			
		||||
    stub_request(:get, 'https://ap.example.com/.well-known/webfinger?resource=acct:foo@ap.example.com').to_return(request_fixture('activitypub-webfinger.txt'))
 | 
			
		||||
    stub_request(:get, 'https://ap.example.com/users/foo').to_return(request_fixture('activitypub-actor.txt'))
 | 
			
		||||
    stub_request(:get, 'https://ap.example.com/users/foo.atom').to_return(request_fixture('activitypub-feed.txt'))
 | 
			
		||||
    stub_request(:get, %r{https://ap.example.com/users/foo/\w+}).to_return(status: 404)
 | 
			
		||||
    stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:hoge@example.com').to_return(status: 410)
 | 
			
		||||
  end
 | 
			
		||||
@@ -56,8 +56,8 @@ RSpec.describe ResolveAccountService, type: :service do
 | 
			
		||||
 | 
			
		||||
  context 'when there is an LRDD endpoint but no resolvable account' do
 | 
			
		||||
    before do
 | 
			
		||||
      stub_request(:get, "https://quitter.no/.well-known/host-meta").to_return(request_fixture('.host-meta.txt'))
 | 
			
		||||
      stub_request(:get, "https://quitter.no/.well-known/webfinger?resource=acct:catsrgr8@quitter.no").to_return(status: 404)
 | 
			
		||||
      stub_request(:get, 'https://quitter.no/.well-known/host-meta').to_return(request_fixture('.host-meta.txt'))
 | 
			
		||||
      stub_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:catsrgr8@quitter.no').to_return(status: 404)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'returns nil' do
 | 
			
		||||
@@ -67,7 +67,7 @@ RSpec.describe ResolveAccountService, type: :service do
 | 
			
		||||
 | 
			
		||||
  context 'when there is no LRDD endpoint nor resolvable account' do
 | 
			
		||||
    before do
 | 
			
		||||
      stub_request(:get, "https://example.com/.well-known/webfinger?resource=acct:catsrgr8@example.com").to_return(status: 404)
 | 
			
		||||
      stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:catsrgr8@example.com').to_return(status: 404)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'returns nil' do
 | 
			
		||||
@@ -153,7 +153,7 @@ RSpec.describe ResolveAccountService, type: :service do
 | 
			
		||||
 | 
			
		||||
    context 'with multiple types' do
 | 
			
		||||
      before do
 | 
			
		||||
        stub_request(:get, "https://ap.example.com/users/foo").to_return(request_fixture('activitypub-actor-individual.txt'))
 | 
			
		||||
        stub_request(:get, 'https://ap.example.com/users/foo').to_return(request_fixture('activitypub-actor-individual.txt'))
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'returns new remote account' do
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ end
 | 
			
		||||
gc_counter = -1
 | 
			
		||||
 | 
			
		||||
RSpec.configure do |config|
 | 
			
		||||
  config.example_status_persistence_file_path = "tmp/rspec/examples.txt"
 | 
			
		||||
  config.example_status_persistence_file_path = 'tmp/rspec/examples.txt'
 | 
			
		||||
  config.expect_with :rspec do |expectations|
 | 
			
		||||
    expectations.include_chain_clauses_in_custom_matcher_descriptions = true
 | 
			
		||||
  end
 | 
			
		||||
@@ -60,7 +60,7 @@ end
 | 
			
		||||
 | 
			
		||||
def expect_push_bulk_to_match(klass, matcher)
 | 
			
		||||
  expect(Sidekiq::Client).to receive(:push_bulk).with(hash_including({
 | 
			
		||||
    "class" => klass,
 | 
			
		||||
    "args" => matcher,
 | 
			
		||||
    'class' => klass,
 | 
			
		||||
    'args' => matcher,
 | 
			
		||||
  }))
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user