Autofix Rubocop Style/StringLiterals (#23695)
parent
ac3561098e
commit
81ad6c2e39
|
@ -3057,88 +3057,6 @@ Style/StringConcatenation:
|
||||||
- 'spec/validators/disallowed_hashtags_validator_spec.rb'
|
- 'spec/validators/disallowed_hashtags_validator_spec.rb'
|
||||||
- 'spec/workers/web/push_notification_worker_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
|
# Offense count: 272
|
||||||
# This cop supports safe autocorrection (--autocorrect).
|
# This cop supports safe autocorrection (--autocorrect).
|
||||||
# Configuration parameters: EnforcedStyle, MinSize.
|
# Configuration parameters: EnforcedStyle, MinSize.
|
||||||
|
|
|
@ -99,7 +99,7 @@ class Webfinger
|
||||||
end
|
end
|
||||||
|
|
||||||
def standard_url
|
def standard_url
|
||||||
if @domain.end_with? ".onion"
|
if @domain.end_with? '.onion'
|
||||||
"http://#{@domain}/.well-known/webfinger?resource=#{@uri}"
|
"http://#{@domain}/.well-known/webfinger?resource=#{@uri}"
|
||||||
else
|
else
|
||||||
"https://#{@domain}/.well-known/webfinger?resource=#{@uri}"
|
"https://#{@domain}/.well-known/webfinger?resource=#{@uri}"
|
||||||
|
@ -107,7 +107,7 @@ class Webfinger
|
||||||
end
|
end
|
||||||
|
|
||||||
def host_meta_url
|
def host_meta_url
|
||||||
if @domain.end_with? ".onion"
|
if @domain.end_with? '.onion'
|
||||||
"http://#{@domain}/.well-known/host-meta"
|
"http://#{@domain}/.well-known/host-meta"
|
||||||
else
|
else
|
||||||
"https://#{@domain}/.well-known/host-meta"
|
"https://#{@domain}/.well-known/host-meta"
|
||||||
|
|
|
@ -2,7 +2,7 @@ class AddDeviseToUsers < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
change_table(:users) do |t|
|
change_table(:users) do |t|
|
||||||
## Database authenticatable
|
## Database authenticatable
|
||||||
t.string :encrypted_password, null: false, default: ""
|
t.string :encrypted_password, null: false, default: ''
|
||||||
|
|
||||||
## Recoverable
|
## Recoverable
|
||||||
t.string :reset_password_token
|
t.string :reset_password_token
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class RemoveUnneededIndexes < ActiveRecord::Migration[5.0]
|
class RemoveUnneededIndexes < ActiveRecord::Migration[5.0]
|
||||||
def change
|
def change
|
||||||
remove_index :notifications, name: "index_notifications_on_account_id"
|
remove_index :notifications, name: 'index_notifications_on_account_id'
|
||||||
remove_index :settings, name: "index_settings_on_target_type_and_target_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 :statuses_tags, name: 'index_statuses_tags_on_tag_id'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class AddSpoilerTextToStatuses < ActiveRecord::Migration[5.0]
|
class AddSpoilerTextToStatuses < ActiveRecord::Migration[5.0]
|
||||||
def change
|
def change
|
||||||
add_column :statuses, :spoiler_text, :text, default: "", null: false
|
add_column :statuses, :spoiler_text, :text, default: '', null: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class RemoveDuplicateIndexesInLists < ActiveRecord::Migration[5.1]
|
class RemoveDuplicateIndexesInLists < ActiveRecord::Migration[5.1]
|
||||||
def change
|
def change
|
||||||
remove_index :list_accounts, name: "index_list_accounts_on_account_id"
|
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_list_id'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,11 +5,11 @@ class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecor
|
||||||
|
|
||||||
def change
|
def change
|
||||||
safety_assured do
|
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
|
end
|
||||||
|
|
||||||
# These index may not exists (see migration 20180514130000)
|
# 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, :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
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class RemoveUnusedIndexes < ActiveRecord::Migration[5.2]
|
class RemoveUnusedIndexes < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
remove_index :statuses, name: "index_statuses_on_conversation_id"
|
remove_index :statuses, name: 'index_statuses_on_conversation_id'
|
||||||
remove_index :users, name: "index_users_on_filtered_languages"
|
remove_index :users, name: 'index_users_on_filtered_languages'
|
||||||
remove_index :backups, name: "index_backups_on_user_id"
|
remove_index :backups, name: 'index_backups_on_user_id'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ class EncryptedMessageIdsToTimestampIds < ActiveRecord::Migration[5.2]
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
execute("LOCK encrypted_messages")
|
execute('LOCK encrypted_messages')
|
||||||
execute("SELECT setval('encrypted_messages_id_seq', (SELECT MAX(id) FROM 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')")
|
execute("ALTER TABLE encrypted_messages ALTER COLUMN id SET DEFAULT nextval('encrypted_messages_id_seq')")
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ class MediaAttachmentIdsToTimestampIds < ActiveRecord::Migration[5.1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
execute("LOCK media_attachments")
|
execute('LOCK media_attachments')
|
||||||
execute("SELECT setval('media_attachments_id_seq', (SELECT MAX(id) FROM 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')")
|
execute("ALTER TABLE media_attachments ALTER COLUMN id SET DEFAULT nextval('media_attachments_id_seq')")
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ class AccountIdsToTimestampIds < ActiveRecord::Migration[5.1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
execute("LOCK accounts")
|
execute('LOCK accounts')
|
||||||
execute("SELECT setval('accounts_id_seq', (SELECT MAX(id) FROM 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')")
|
execute("ALTER TABLE accounts ALTER COLUMN id SET DEFAULT nextval('accounts_id_seq')")
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,7 +49,7 @@ module Mastodon
|
||||||
next if filename.start_with?('._')
|
next if filename.start_with?('._')
|
||||||
|
|
||||||
shortcode = [options[:prefix], filename, options[:suffix]].compact.join
|
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]
|
if custom_emoji && !options[:overwrite]
|
||||||
skipped += 1
|
skipped += 1
|
||||||
|
|
|
@ -3,7 +3,7 @@ module Rails
|
||||||
# Rewrite task loading code to filter digitalocean.rake task
|
# Rewrite task loading code to filter digitalocean.rake task
|
||||||
def run_tasks_blocks(app)
|
def run_tasks_blocks(app)
|
||||||
Railtie.instance_method(:run_tasks_blocks).bind_call(self, 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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -264,7 +264,7 @@ namespace :mastodon do
|
||||||
|
|
||||||
env['S3_ENDPOINT'] = prompt.ask('Storj DCS endpoint URL:') do |q|
|
env['S3_ENDPOINT'] = prompt.ask('Storj DCS endpoint URL:') do |q|
|
||||||
q.required true
|
q.required true
|
||||||
q.default "https://gateway.storjshare.io"
|
q.default 'https://gateway.storjshare.io'
|
||||||
q.modify :strip
|
q.modify :strip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ RSpec.describe Admin::ChangeEmailsController, type: :controller do
|
||||||
sign_in admin
|
sign_in admin
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET #show" do
|
describe 'GET #show' do
|
||||||
it "returns http success" do
|
it 'returns http success' do
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
|
|
||||||
get :show, params: { account_id: user.account.id }
|
get :show, params: { account_id: user.account.id }
|
||||||
|
@ -19,12 +19,12 @@ RSpec.describe Admin::ChangeEmailsController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET #update" do
|
describe 'GET #update' do
|
||||||
before do
|
before do
|
||||||
allow(UserMailer).to receive(:confirmation_instructions).and_return(double('email', deliver_later: nil))
|
allow(UserMailer).to receive(:confirmation_instructions).and_return(double('email', deliver_later: nil))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns http success" do
|
it 'returns http success' do
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
|
|
||||||
previous_email = user.email
|
previous_email = user.email
|
||||||
|
|
|
@ -38,7 +38,7 @@ describe Api::V1::StreamingController do
|
||||||
[:scheme, :path, :query, :fragment].each do |part|
|
[:scheme, :path, :query, :fragment].each do |part|
|
||||||
expect(redirect_to_uri.send(part)).to eq(request_uri.send(part)), "redirect target #{part}"
|
expect(redirect_to_uri.send(part)).to eq(request_uri.send(part)), "redirect target #{part}"
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe ApplicationController, type: :controller do
|
||||||
expect(response).to have_http_status(code)
|
expect(response).to have_http_status(code)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders template for http" do
|
it 'renders template for http' do
|
||||||
is_expected.to render_template("errors/#{code}", layout: 'error')
|
is_expected.to render_template("errors/#{code}", layout: 'error')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -146,7 +146,7 @@ describe ApplicationController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not store location for user if it is devise controller' do
|
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'
|
get 'create'
|
||||||
expect(controller.stored_location_for(:user)).to be_nil
|
expect(controller.stored_location_for(:user)).to be_nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||||
|
|
||||||
describe 'GET #edit' do
|
describe 'GET #edit' do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
request.env['devise.mapping'] = Devise.mappings[:user]
|
||||||
sign_in(Fabricate(:user))
|
sign_in(Fabricate(:user))
|
||||||
get :edit
|
get :edit
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
|
@ -41,7 +41,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||||
|
|
||||||
describe 'GET #update' do
|
describe 'GET #update' do
|
||||||
it 'returns http success' 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)
|
sign_in(Fabricate(:user), scope: :user)
|
||||||
post :update
|
post :update
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
|
@ -49,7 +49,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||||
|
|
||||||
context 'when suspended' do
|
context 'when suspended' do
|
||||||
it 'returns http forbidden' 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)
|
sign_in(Fabricate(:user, account_attributes: { username: 'test', suspended_at: Time.now.utc }), scope: :user)
|
||||||
post :update
|
post :update
|
||||||
expect(response).to have_http_status(403)
|
expect(response).to have_http_status(403)
|
||||||
|
@ -59,7 +59,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||||
|
|
||||||
describe 'GET #new' do
|
describe 'GET #new' do
|
||||||
before do
|
before do
|
||||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
request.env['devise.mapping'] = Devise.mappings[:user]
|
||||||
end
|
end
|
||||||
|
|
||||||
context do
|
context do
|
||||||
|
@ -92,7 +92,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||||
I18n.locale = current_locale
|
I18n.locale = current_locale
|
||||||
end
|
end
|
||||||
|
|
||||||
before { request.env["devise.mapping"] = Devise.mappings[:user] }
|
before { request.env['devise.mapping'] = Devise.mappings[:user] }
|
||||||
|
|
||||||
context do
|
context do
|
||||||
around do |example|
|
around do |example|
|
||||||
|
@ -103,7 +103,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
Setting.registrations_mode = 'open'
|
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' } }
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
Setting.registrations_mode = 'open'
|
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' } }
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'false' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
Setting.registrations_mode = 'approved'
|
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' } }
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
Setting.registrations_mode = 'approved'
|
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)
|
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' } }
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
|
||||||
end
|
end
|
||||||
|
@ -208,7 +208,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||||
inviter = Fabricate(:user, confirmed_at: 2.days.ago)
|
inviter = Fabricate(:user, confirmed_at: 2.days.ago)
|
||||||
Setting.registrations_mode = 'approved'
|
Setting.registrations_mode = 'approved'
|
||||||
Setting.require_invite_text = true
|
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)
|
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' } }
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,7 +54,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
||||||
context 'using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
|
context 'using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
|
||||||
context 'using a valid password' do
|
context 'using a valid password' do
|
||||||
before do
|
before do
|
||||||
post :create, params: { user: { email: "pam_user1", password: '123456' } }
|
post :create, params: { user: { email: 'pam_user1', password: '123456' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to home' do
|
it 'redirects to home' do
|
||||||
|
@ -68,7 +68,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
||||||
|
|
||||||
context 'using an invalid password' do
|
context 'using an invalid password' do
|
||||||
before do
|
before do
|
||||||
post :create, params: { user: { email: "pam_user1", password: 'WRONGPW' } }
|
post :create, params: { user: { email: 'pam_user1', password: 'WRONGPW' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows a login error' do
|
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 } }
|
post :create, params: { user: { email: user.email, password: user.password } }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "in single user mode" do
|
context 'in single user mode' do
|
||||||
let(:single_user_mode) { true }
|
let(:single_user_mode) { true }
|
||||||
|
|
||||||
it 'redirects to home' do
|
it 'redirects to home' do
|
||||||
|
@ -202,7 +202,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "in non-single user mode" do
|
context 'in non-single user mode' do
|
||||||
let(:single_user_mode) { false }
|
let(:single_user_mode) { false }
|
||||||
|
|
||||||
it "redirects back to the user's page" do
|
it "redirects back to the user's page" do
|
||||||
|
@ -230,8 +230,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders two factor authentication page' do
|
it 'renders two factor authentication page' do
|
||||||
expect(controller).to render_template("two_factor")
|
expect(controller).to render_template('two_factor')
|
||||||
expect(controller).to render_template(partial: "_otp_authentication_form")
|
expect(controller).to render_template(partial: '_otp_authentication_form')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -246,8 +246,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders two factor authentication page' do
|
it 'renders two factor authentication page' do
|
||||||
expect(controller).to render_template("two_factor")
|
expect(controller).to render_template('two_factor')
|
||||||
expect(controller).to render_template(partial: "_otp_authentication_form")
|
expect(controller).to render_template(partial: '_otp_authentication_form')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -257,8 +257,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders two factor authentication page' do
|
it 'renders two factor authentication page' do
|
||||||
expect(controller).to render_template("two_factor")
|
expect(controller).to render_template('two_factor')
|
||||||
expect(controller).to render_template(partial: "_otp_authentication_form")
|
expect(controller).to render_template(partial: '_otp_authentication_form')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -359,8 +359,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders webauthn authentication page' do
|
it 'renders webauthn authentication page' do
|
||||||
expect(controller).to render_template("two_factor")
|
expect(controller).to render_template('two_factor')
|
||||||
expect(controller).to render_template(partial: "_webauthn_form")
|
expect(controller).to render_template(partial: '_webauthn_form')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -370,8 +370,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders webauthn authentication page' do
|
it 'renders webauthn authentication page' do
|
||||||
expect(controller).to render_template("two_factor")
|
expect(controller).to render_template('two_factor')
|
||||||
expect(controller).to render_template(partial: "_webauthn_form")
|
expect(controller).to render_template(partial: '_webauthn_form')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe Oauth::AuthorizedApplicationsController do
|
||||||
shared_examples 'stores location for user' do
|
shared_examples 'stores location for user' do
|
||||||
it 'stores location for user' do
|
it 'stores location for user' do
|
||||||
subject
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ RSpec.describe Settings::ImportsController, type: :controller do
|
||||||
sign_in Fabricate(:user), scope: :user
|
sign_in Fabricate(:user), scope: :user
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET #show" do
|
describe 'GET #show' do
|
||||||
it "returns http success" do
|
it 'returns http success' do
|
||||||
get :show
|
get :show
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,8 +10,8 @@ RSpec.describe Settings::ProfilesController, type: :controller do
|
||||||
sign_in user, scope: :user
|
sign_in user, scope: :user
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET #show" do
|
describe 'GET #show' do
|
||||||
it "returns http success" do
|
it 'returns http success' do
|
||||||
get :show
|
get :show
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
|
@ -137,7 +137,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
|
||||||
expect { get :options }.to_not change { user.webauthn_id }
|
expect { get :options }.to_not change { user.webauthn_id }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "includes existing credentials in list of excluded credentials" do
|
it 'includes existing credentials in list of excluded credentials' do
|
||||||
get :options
|
get :options
|
||||||
|
|
||||||
excluded_credentials_ids = JSON.parse(response.body)['excludeCredentials'].map { |credential| credential['id'] }
|
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
|
sign_in @user, scope: :user
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET #show" do
|
describe 'GET #show' do
|
||||||
it "returns http success" do
|
it 'returns http success' do
|
||||||
get :show
|
get :show
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,8 +27,8 @@ describe WellKnown::NodeInfoController, type: :controller do
|
||||||
|
|
||||||
json = body_as_json
|
json = body_as_json
|
||||||
|
|
||||||
expect({ "foo" => 0 }).not_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).to match_json_schema('nodeinfo_2.0')
|
||||||
expect(json[:version]).to eq '2.0'
|
expect(json[:version]).to eq '2.0'
|
||||||
expect(json[:usage]).to be_a Hash
|
expect(json[:usage]).to be_a Hash
|
||||||
expect(json[:software]).to be_a Hash
|
expect(json[:software]).to be_a Hash
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Fabricator(:account_moderation_note) do
|
Fabricator(:account_moderation_note) do
|
||||||
content "MyText"
|
content 'MyText'
|
||||||
account nil
|
account nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Fabricator(:account_note) do
|
Fabricator(:account_note) do
|
||||||
account
|
account
|
||||||
target_account { Fabricate(:account) }
|
target_account { Fabricate(:account) }
|
||||||
comment "User note text"
|
comment 'User note text'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Fabricator(:account_stat) do
|
Fabricator(:account_stat) do
|
||||||
account nil
|
account nil
|
||||||
statuses_count ""
|
statuses_count ''
|
||||||
following_count ""
|
following_count ''
|
||||||
followers_count ""
|
followers_count ''
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Fabricator(:account_tag_stat) do
|
Fabricator(:account_tag_stat) do
|
||||||
accounts_count ""
|
accounts_count ''
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Fabricator(:account_warning_preset) do
|
Fabricator(:account_warning_preset) do
|
||||||
text "MyText"
|
text 'MyText'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Fabricator('Admin::ActionLog') do
|
Fabricator('Admin::ActionLog') do
|
||||||
account nil
|
account nil
|
||||||
action "MyString"
|
action 'MyString'
|
||||||
target nil
|
target nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Fabricator(:canonical_email_block) do
|
Fabricator(:canonical_email_block) do
|
||||||
email "test@example.com"
|
email 'test@example.com'
|
||||||
reference_account { Fabricate(:account) }
|
reference_account { Fabricate(:account) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Fabricator(:conversation_account) do
|
Fabricator(:conversation_account) do
|
||||||
account nil
|
account nil
|
||||||
conversation nil
|
conversation nil
|
||||||
participant_account_ids ""
|
participant_account_ids ''
|
||||||
last_status nil
|
last_status nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Fabricator(:custom_emoji_category) do
|
Fabricator(:custom_emoji_category) do
|
||||||
name "MyString"
|
name 'MyString'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Fabricator(:domain_allow) do
|
Fabricator(:domain_allow) do
|
||||||
domain "MyString"
|
domain 'MyString'
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,6 @@ Fabricator(:encrypted_message) do
|
||||||
from_account
|
from_account
|
||||||
from_device_id { Faker::Number.number(digits: 5) }
|
from_device_id { Faker::Number.number(digits: 5) }
|
||||||
type 0
|
type 0
|
||||||
body ""
|
body ''
|
||||||
message_franking ""
|
message_franking ''
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Fabricator(:identity) do
|
Fabricator(:identity) do
|
||||||
user nil
|
user nil
|
||||||
provider "MyString"
|
provider 'MyString'
|
||||||
uid "MyString"
|
uid 'MyString'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Fabricator(:ip_block) do
|
Fabricator(:ip_block) do
|
||||||
ip ""
|
ip ''
|
||||||
severity ""
|
severity ''
|
||||||
expires_at "2020-10-08 22:20:37"
|
expires_at '2020-10-08 22:20:37'
|
||||||
comment "MyText"
|
comment 'MyText'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Fabricator(:list) do
|
Fabricator(:list) do
|
||||||
account
|
account
|
||||||
title "MyString"
|
title 'MyString'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Fabricator(:relay) do
|
Fabricator(:relay) do
|
||||||
inbox_url "https://example.com/inbox"
|
inbox_url 'https://example.com/inbox'
|
||||||
state :idle
|
state :idle
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Fabricator(:report) do
|
Fabricator(:report) do
|
||||||
account
|
account
|
||||||
target_account { Fabricate(:account) }
|
target_account { Fabricate(:account) }
|
||||||
comment "You nasty"
|
comment 'You nasty'
|
||||||
action_taken_at nil
|
action_taken_at nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Fabricator(:report_note) do
|
Fabricator(:report_note) do
|
||||||
report
|
report
|
||||||
account { Fabricate(:account) }
|
account { Fabricate(:account) }
|
||||||
content "Test Content"
|
content 'Test Content'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Fabricator(:session_activation) do
|
Fabricator(:session_activation) do
|
||||||
user
|
user
|
||||||
session_id "MyString"
|
session_id 'MyString'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Fabricator(:status_edit) do
|
Fabricator(:status_edit) do
|
||||||
status nil
|
status nil
|
||||||
account nil
|
account nil
|
||||||
text "MyText"
|
text 'MyText'
|
||||||
spoiler_text "MyText"
|
spoiler_text 'MyText'
|
||||||
media_attachments_changed false
|
media_attachments_changed false
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Fabricator(:status) do
|
Fabricator(:status) do
|
||||||
account
|
account
|
||||||
text "Lorem ipsum dolor sit amet"
|
text 'Lorem ipsum dolor sit amet'
|
||||||
|
|
||||||
after_build do |status|
|
after_build do |status|
|
||||||
status.uri = Faker::Internet.device_token if !status.account.local? && status.uri.nil?
|
status.uri = Faker::Internet.device_token if !status.account.local? && status.uri.nil?
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Fabricator(:status_stat) do
|
Fabricator(:status_stat) do
|
||||||
status_id nil
|
status_id nil
|
||||||
replies_count ""
|
replies_count ''
|
||||||
reblogs_count ""
|
reblogs_count ''
|
||||||
favourites_count ""
|
favourites_count ''
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Fabricator(:user) do
|
Fabricator(:user) do
|
||||||
account { Fabricate.build(:account, user: nil) }
|
account { Fabricate.build(:account, user: nil) }
|
||||||
email { sequence(:email) { |i| "#{i}#{Faker::Internet.email}" } }
|
email { sequence(:email) { |i| "#{i}#{Faker::Internet.email}" } }
|
||||||
password "123456789"
|
password '123456789'
|
||||||
confirmed_at { Time.zone.now }
|
confirmed_at { Time.zone.now }
|
||||||
agreement true
|
agreement true
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Fabricator(:user_role) do
|
Fabricator(:user_role) do
|
||||||
name "MyString"
|
name 'MyString'
|
||||||
color ""
|
color ''
|
||||||
permissions 0
|
permissions 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,8 +7,8 @@ describe 'Log in' do
|
||||||
|
|
||||||
subject { page }
|
subject { page }
|
||||||
|
|
||||||
let(:email) { "test@example.com" }
|
let(:email) { 'test@example.com' }
|
||||||
let(:password) { "password" }
|
let(:password) { 'password' }
|
||||||
let(:confirmed_at) { Time.zone.now }
|
let(:confirmed_at) { Time.zone.now }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -13,15 +13,15 @@ RSpec.describe AccountsHelper, type: :helper do
|
||||||
|
|
||||||
describe '#display_name' do
|
describe '#display_name' do
|
||||||
it 'uses the display name when it exists' 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
|
end
|
||||||
|
|
||||||
it 'uses the username when display name is nil' do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ describe ApplicationHelper do
|
||||||
it 'returns active when on the current page' do
|
it 'returns active when on the current page' do
|
||||||
allow(helper).to receive(:current_page?).and_return(true)
|
allow(helper).to receive(:current_page?).and_return(true)
|
||||||
|
|
||||||
result = helper.active_nav_class("/test")
|
result = helper.active_nav_class('/test')
|
||||||
expect(result).to eq "active"
|
expect(result).to eq 'active'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns active when on a current page' do
|
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)
|
allow(helper).to receive(:current_page?).with('/test').and_return(true)
|
||||||
|
|
||||||
result = helper.active_nav_class('/foo', '/test')
|
result = helper.active_nav_class('/foo', '/test')
|
||||||
expect(result).to eq "active"
|
expect(result).to eq 'active'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns empty string when not on current page' do
|
it 'returns empty string when not on current page' do
|
||||||
allow(helper).to receive(:current_page?).and_return(false)
|
allow(helper).to receive(:current_page?).and_return(false)
|
||||||
|
|
||||||
result = helper.active_nav_class("/test")
|
result = helper.active_nav_class('/test')
|
||||||
expect(result).to eq ""
|
expect(result).to eq ''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -416,7 +416,7 @@ RSpec.describe FeedManager do
|
||||||
|
|
||||||
FeedManager.instance.merge_into_home(account, reblog.account)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require "rails_helper"
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe NotificationMailer, type: :mailer do
|
RSpec.describe NotificationMailer, type: :mailer do
|
||||||
let(:receiver) { Fabricate(:user) }
|
let(:receiver) { Fabricate(:user) }
|
||||||
|
@ -19,69 +19,69 @@ RSpec.describe NotificationMailer, type: :mailer do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "mention" do
|
describe 'mention' do
|
||||||
let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
|
let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
|
||||||
let(:mail) { NotificationMailer.mention(receiver.account, Notification.create!(account: receiver.account, activity: mention)) }
|
let(:mail) { NotificationMailer.mention(receiver.account, Notification.create!(account: receiver.account, activity: mention)) }
|
||||||
|
|
||||||
include_examples 'localized subject', 'notification_mailer.mention.subject', name: 'bob'
|
include_examples 'localized subject', 'notification_mailer.mention.subject', name: 'bob'
|
||||||
|
|
||||||
it "renders the headers" do
|
it 'renders the headers' do
|
||||||
expect(mail.subject).to eq("You were mentioned by bob")
|
expect(mail.subject).to eq('You were mentioned by bob')
|
||||||
expect(mail.to).to eq([receiver.email])
|
expect(mail.to).to eq([receiver.email])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders the body" do
|
it 'renders the body' do
|
||||||
expect(mail.body.encoded).to match("You were mentioned by bob")
|
expect(mail.body.encoded).to match('You were mentioned by bob')
|
||||||
expect(mail.body.encoded).to include 'The body of the foreign status'
|
expect(mail.body.encoded).to include 'The body of the foreign status'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "follow" do
|
describe 'follow' do
|
||||||
let(:follow) { sender.follow!(receiver.account) }
|
let(:follow) { sender.follow!(receiver.account) }
|
||||||
let(:mail) { NotificationMailer.follow(receiver.account, Notification.create!(account: receiver.account, activity: follow)) }
|
let(:mail) { NotificationMailer.follow(receiver.account, Notification.create!(account: receiver.account, activity: follow)) }
|
||||||
|
|
||||||
include_examples 'localized subject', 'notification_mailer.follow.subject', name: 'bob'
|
include_examples 'localized subject', 'notification_mailer.follow.subject', name: 'bob'
|
||||||
|
|
||||||
it "renders the headers" do
|
it 'renders the headers' do
|
||||||
expect(mail.subject).to eq("bob is now following you")
|
expect(mail.subject).to eq('bob is now following you')
|
||||||
expect(mail.to).to eq([receiver.email])
|
expect(mail.to).to eq([receiver.email])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders the body" do
|
it 'renders the body' do
|
||||||
expect(mail.body.encoded).to match("bob is now following you")
|
expect(mail.body.encoded).to match('bob is now following you')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "favourite" do
|
describe 'favourite' do
|
||||||
let(:favourite) { Favourite.create!(account: sender, status: own_status) }
|
let(:favourite) { Favourite.create!(account: sender, status: own_status) }
|
||||||
let(:mail) { NotificationMailer.favourite(own_status.account, Notification.create!(account: receiver.account, activity: favourite)) }
|
let(:mail) { NotificationMailer.favourite(own_status.account, Notification.create!(account: receiver.account, activity: favourite)) }
|
||||||
|
|
||||||
include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob'
|
include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob'
|
||||||
|
|
||||||
it "renders the headers" do
|
it 'renders the headers' do
|
||||||
expect(mail.subject).to eq("bob favourited your post")
|
expect(mail.subject).to eq('bob favourited your post')
|
||||||
expect(mail.to).to eq([receiver.email])
|
expect(mail.to).to eq([receiver.email])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders the body" do
|
it 'renders the body' do
|
||||||
expect(mail.body.encoded).to match("Your post was favourited by bob")
|
expect(mail.body.encoded).to match('Your post was favourited by bob')
|
||||||
expect(mail.body.encoded).to include 'The body of the own status'
|
expect(mail.body.encoded).to include 'The body of the own status'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "reblog" do
|
describe 'reblog' do
|
||||||
let(:reblog) { Status.create!(account: sender, reblog: own_status) }
|
let(:reblog) { Status.create!(account: sender, reblog: own_status) }
|
||||||
let(:mail) { NotificationMailer.reblog(own_status.account, Notification.create!(account: receiver.account, activity: reblog)) }
|
let(:mail) { NotificationMailer.reblog(own_status.account, Notification.create!(account: receiver.account, activity: reblog)) }
|
||||||
|
|
||||||
include_examples 'localized subject', 'notification_mailer.reblog.subject', name: 'bob'
|
include_examples 'localized subject', 'notification_mailer.reblog.subject', name: 'bob'
|
||||||
|
|
||||||
it "renders the headers" do
|
it 'renders the headers' do
|
||||||
expect(mail.subject).to eq("bob boosted your post")
|
expect(mail.subject).to eq('bob boosted your post')
|
||||||
expect(mail.to).to eq([receiver.email])
|
expect(mail.to).to eq([receiver.email])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders the body" do
|
it 'renders the body' do
|
||||||
expect(mail.body.encoded).to match("Your post was boosted by bob")
|
expect(mail.body.encoded).to match('Your post was boosted by bob')
|
||||||
expect(mail.body.encoded).to include 'The body of the own status'
|
expect(mail.body.encoded).to include 'The body of the own status'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -98,7 +98,7 @@ RSpec.describe NotificationMailer, type: :mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders the body' do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -90,7 +90,7 @@ describe UserMailer, type: :mailer do
|
||||||
|
|
||||||
it 'renders warning notification' do
|
it 'renders warning notification' do
|
||||||
receiver.update!(locale: nil)
|
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
|
expect(mail.body.encoded).to include strike.text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -345,9 +345,9 @@ RSpec.describe Account, type: :model do
|
||||||
before do
|
before do
|
||||||
_missing = Fabricate(
|
_missing = Fabricate(
|
||||||
:account,
|
:account,
|
||||||
display_name: "Missing",
|
display_name: 'Missing',
|
||||||
username: "missing",
|
username: 'missing',
|
||||||
domain: "missing.com"
|
domain: 'missing.com'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -405,58 +405,58 @@ RSpec.describe Account, type: :model do
|
||||||
it 'finds accounts with matching display_name' do
|
it 'finds accounts with matching display_name' do
|
||||||
match = Fabricate(
|
match = Fabricate(
|
||||||
:account,
|
:account,
|
||||||
display_name: "Display Name",
|
display_name: 'Display Name',
|
||||||
username: "username",
|
username: 'username',
|
||||||
domain: "example.com"
|
domain: 'example.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.search_for("display")
|
results = Account.search_for('display')
|
||||||
expect(results).to eq [match]
|
expect(results).to eq [match]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds accounts with matching username' do
|
it 'finds accounts with matching username' do
|
||||||
match = Fabricate(
|
match = Fabricate(
|
||||||
:account,
|
:account,
|
||||||
display_name: "Display Name",
|
display_name: 'Display Name',
|
||||||
username: "username",
|
username: 'username',
|
||||||
domain: "example.com"
|
domain: 'example.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.search_for("username")
|
results = Account.search_for('username')
|
||||||
expect(results).to eq [match]
|
expect(results).to eq [match]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds accounts with matching domain' do
|
it 'finds accounts with matching domain' do
|
||||||
match = Fabricate(
|
match = Fabricate(
|
||||||
:account,
|
:account,
|
||||||
display_name: "Display Name",
|
display_name: 'Display Name',
|
||||||
username: "username",
|
username: 'username',
|
||||||
domain: "example.com"
|
domain: 'example.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.search_for("example")
|
results = Account.search_for('example')
|
||||||
expect(results).to eq [match]
|
expect(results).to eq [match]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'limits by 10 by default' do
|
it 'limits by 10 by default' do
|
||||||
11.times.each { Fabricate(:account, display_name: "Display Name") }
|
11.times.each { Fabricate(:account, display_name: 'Display Name') }
|
||||||
results = Account.search_for("display")
|
results = Account.search_for('display')
|
||||||
expect(results.size).to eq 10
|
expect(results.size).to eq 10
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts arbitrary limits' do
|
it 'accepts arbitrary limits' do
|
||||||
2.times.each { Fabricate(:account, display_name: "Display Name") }
|
2.times.each { Fabricate(:account, display_name: 'Display Name') }
|
||||||
results = Account.search_for("display", limit: 1)
|
results = Account.search_for('display', limit: 1)
|
||||||
expect(results.size).to eq 1
|
expect(results.size).to eq 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'ranks multiple matches higher' do
|
it 'ranks multiple matches higher' do
|
||||||
matches = [
|
matches = [
|
||||||
{ username: "username", display_name: "username" },
|
{ username: 'username', display_name: 'username' },
|
||||||
{ display_name: "Display Name", username: "username", domain: "example.com" },
|
{ display_name: 'Display Name', username: 'username', domain: 'example.com' },
|
||||||
].map(&method(:Fabricate).curry(2).call(:account))
|
].map(&method(:Fabricate).curry(2).call(:account))
|
||||||
|
|
||||||
results = Account.search_for("username")
|
results = Account.search_for('username')
|
||||||
expect(results).to eq matches
|
expect(results).to eq matches
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -582,23 +582,23 @@ RSpec.describe Account, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'limits by 10 by default' do
|
it 'limits by 10 by default' do
|
||||||
11.times { Fabricate(:account, display_name: "Display Name") }
|
11.times { Fabricate(:account, display_name: 'Display Name') }
|
||||||
results = Account.advanced_search_for("display", account)
|
results = Account.advanced_search_for('display', account)
|
||||||
expect(results.size).to eq 10
|
expect(results.size).to eq 10
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts arbitrary limits' do
|
it 'accepts arbitrary limits' do
|
||||||
2.times { Fabricate(:account, display_name: "Display Name") }
|
2.times { Fabricate(:account, display_name: 'Display Name') }
|
||||||
results = Account.advanced_search_for("display", account, limit: 1)
|
results = Account.advanced_search_for('display', account, limit: 1)
|
||||||
expect(results.size).to eq 1
|
expect(results.size).to eq 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'ranks followed accounts higher' do
|
it 'ranks followed accounts higher' do
|
||||||
match = Fabricate(:account, username: "Matching")
|
match = Fabricate(:account, username: 'Matching')
|
||||||
followed_match = Fabricate(:account, username: "Matcher")
|
followed_match = Fabricate(:account, username: 'Matcher')
|
||||||
Fabricate(:follow, account: account, target_account: followed_match)
|
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).to eq [followed_match, match]
|
||||||
expect(results.first.rank).to be > results.last.rank
|
expect(results.first.rank).to be > results.last.rank
|
||||||
end
|
end
|
||||||
|
|
|
@ -94,8 +94,8 @@ RSpec.describe MediaAttachment, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets meta' do
|
it 'sets meta' do
|
||||||
expect(media.file.meta["original"]["width"]).to eq 128
|
expect(media.file.meta['original']['width']).to eq 128
|
||||||
expect(media.file.meta["original"]["height"]).to eq 128
|
expect(media.file.meta['original']['height']).to eq 128
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -118,9 +118,9 @@ RSpec.describe MediaAttachment, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets meta' do
|
it 'sets meta' do
|
||||||
expect(media.file.meta["original"]["width"]).to eq fixture[:width]
|
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']['height']).to eq fixture[:height]
|
||||||
expect(media.file.meta["original"]["aspect"]).to eq fixture[:aspect]
|
expect(media.file.meta['original']['aspect']).to eq fixture[:aspect]
|
||||||
end
|
end
|
||||||
end
|
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')) }
|
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }
|
||||||
|
|
||||||
it 'sets meta for different style' do
|
it 'sets meta for different style' do
|
||||||
expect(media.file.meta["original"]["width"]).to eq 600
|
expect(media.file.meta['original']['width']).to eq 600
|
||||||
expect(media.file.meta["original"]["height"]).to eq 400
|
expect(media.file.meta['original']['height']).to eq 400
|
||||||
expect(media.file.meta["original"]["aspect"]).to eq 1.5
|
expect(media.file.meta['original']['aspect']).to eq 1.5
|
||||||
expect(media.file.meta["small"]["width"]).to eq 588
|
expect(media.file.meta['small']['width']).to eq 588
|
||||||
expect(media.file.meta["small"]["height"]).to eq 392
|
expect(media.file.meta['small']['height']).to eq 392
|
||||||
expect(media.file.meta["small"]["aspect"]).to eq 1.5
|
expect(media.file.meta['small']['aspect']).to eq 1.5
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'gives the file a random name' do
|
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
|
context "when notification is a #{type}" do
|
||||||
let(:notification_type) { type }
|
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]
|
expect(subject.pushable?(notification)).to eq data[:alerts][type]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,8 +35,8 @@ RSpec.describe WebauthnCredential, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is invalid if already exist a webauthn credential with the same external id' do
|
it 'is invalid if already exist a webauthn credential with the same external id' do
|
||||||
existing_webauthn_credential = Fabricate(: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 = Fabricate.build(:webauthn_credential, external_id: '_Typ0ygudDnk9YUVWLQayw')
|
||||||
|
|
||||||
new_webauthn_credential.valid?
|
new_webauthn_credential.valid?
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ describe InstancePresenter do
|
||||||
Setting.site_short_description = site_description
|
Setting.site_short_description = site_description
|
||||||
end
|
end
|
||||||
|
|
||||||
it "delegates site_description to Setting" do
|
it 'delegates site_description to Setting' do
|
||||||
Setting.site_short_description = "Site desc"
|
Setting.site_short_description = 'Site desc'
|
||||||
expect(instance_presenter.description).to eq "Site desc"
|
expect(instance_presenter.description).to eq 'Site desc'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ describe InstancePresenter do
|
||||||
Setting.site_extended_description = site_extended_description
|
Setting.site_extended_description = site_extended_description
|
||||||
end
|
end
|
||||||
|
|
||||||
it "delegates site_extended_description to Setting" do
|
it 'delegates site_extended_description to Setting' do
|
||||||
Setting.site_extended_description = "Extended desc"
|
Setting.site_extended_description = 'Extended desc'
|
||||||
expect(instance_presenter.extended_description).to eq "Extended desc"
|
expect(instance_presenter.extended_description).to eq 'Extended desc'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ describe InstancePresenter do
|
||||||
Setting.site_contact_email = site_contact_email
|
Setting.site_contact_email = site_contact_email
|
||||||
end
|
end
|
||||||
|
|
||||||
it "delegates contact_email to Setting" do
|
it 'delegates contact_email to Setting' do
|
||||||
Setting.site_contact_email = "admin@example.com"
|
Setting.site_contact_email = 'admin@example.com'
|
||||||
expect(instance_presenter.contact.email).to eq "admin@example.com"
|
expect(instance_presenter.contact.email).to eq 'admin@example.com'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -49,15 +49,15 @@ describe InstancePresenter do
|
||||||
Setting.site_contact_username = site_contact_username
|
Setting.site_contact_username = site_contact_username
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the account for the site contact username" do
|
it 'returns the account for the site contact username' do
|
||||||
Setting.site_contact_username = "aaa"
|
Setting.site_contact_username = 'aaa'
|
||||||
account = Fabricate(:account, username: "aaa")
|
account = Fabricate(:account, username: 'aaa')
|
||||||
expect(instance_presenter.contact.account).to eq(account)
|
expect(instance_presenter.contact.account).to eq(account)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#user_count' do
|
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
|
Rails.cache.write 'user_count', 123
|
||||||
|
|
||||||
expect(instance_presenter.user_count).to eq(123)
|
expect(instance_presenter.user_count).to eq(123)
|
||||||
|
@ -65,7 +65,7 @@ describe InstancePresenter do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#status_count' do
|
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
|
Rails.cache.write 'local_status_count', 234
|
||||||
|
|
||||||
expect(instance_presenter.status_count).to eq(234)
|
expect(instance_presenter.status_count).to eq(234)
|
||||||
|
@ -73,7 +73,7 @@ describe InstancePresenter do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#domain_count' do
|
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
|
Rails.cache.write 'distinct_domain_count', 345
|
||||||
|
|
||||||
expect(instance_presenter.domain_count).to eq(345)
|
expect(instance_presenter.domain_count).to eq(345)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
ENV['RAILS_ENV'] ||= 'test'
|
ENV['RAILS_ENV'] ||= 'test'
|
||||||
require File.expand_path('../config/environment', __dir__)
|
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 'spec_helper'
|
||||||
require 'rspec/rails'
|
require 'rspec/rails'
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
require "rails_helper"
|
require 'rails_helper'
|
||||||
|
|
||||||
describe "The catch all route" do
|
describe 'The catch all route' do
|
||||||
describe "with a simple value" do
|
describe 'with a simple value' do
|
||||||
it "returns a 404 page as html" do
|
it 'returns a 404 page as html' do
|
||||||
get "/test"
|
get '/test'
|
||||||
|
|
||||||
expect(response.status).to eq 404
|
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
|
end
|
||||||
|
|
||||||
describe "with an implied format" do
|
describe 'with an implied format' do
|
||||||
it "returns a 404 page as html" do
|
it 'returns a 404 page as html' do
|
||||||
get "/test.test"
|
get '/test.test'
|
||||||
|
|
||||||
expect(response.status).to eq 404
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
require "rails_helper"
|
require 'rails_helper'
|
||||||
|
|
||||||
describe "The host_meta route" do
|
describe 'The host_meta route' do
|
||||||
describe "requested without accepts headers" do
|
describe 'requested without accepts headers' do
|
||||||
it "returns an xml response" do
|
it 'returns an xml response' do
|
||||||
get host_meta_url
|
get host_meta_url
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ describe 'Localization' do
|
||||||
it 'uses a specific region when provided' do
|
it 'uses a specific region when provided' do
|
||||||
headers = { 'Accept-Language' => 'zh-HK' }
|
headers = { 'Accept-Language' => 'zh-HK' }
|
||||||
|
|
||||||
get "/auth/sign_in", headers: headers
|
get '/auth/sign_in', headers: headers
|
||||||
|
|
||||||
expect(response.body).to include(
|
expect(response.body).to include(
|
||||||
I18n.t('auth.login', locale: 'zh-HK')
|
I18n.t('auth.login', locale: 'zh-HK')
|
||||||
|
@ -20,7 +20,7 @@ describe 'Localization' do
|
||||||
it 'falls back to a locale when region missing' do
|
it 'falls back to a locale when region missing' do
|
||||||
headers = { 'Accept-Language' => 'es-FAKE' }
|
headers = { 'Accept-Language' => 'es-FAKE' }
|
||||||
|
|
||||||
get "/auth/sign_in", headers: headers
|
get '/auth/sign_in', headers: headers
|
||||||
|
|
||||||
expect(response.body).to include(
|
expect(response.body).to include(
|
||||||
I18n.t('auth.login', locale: 'es')
|
I18n.t('auth.login', locale: 'es')
|
||||||
|
@ -30,7 +30,7 @@ describe 'Localization' do
|
||||||
it 'falls back to english when locale is missing' do
|
it 'falls back to english when locale is missing' do
|
||||||
headers = { 'Accept-Language' => '12-FAKE' }
|
headers = { 'Accept-Language' => '12-FAKE' }
|
||||||
|
|
||||||
get "/auth/sign_in", headers: headers
|
get '/auth/sign_in', headers: headers
|
||||||
|
|
||||||
expect(response.body).to include(
|
expect(response.body).to include(
|
||||||
I18n.t('auth.login', locale: 'en')
|
I18n.t('auth.login', locale: 'en')
|
||||||
|
|
|
@ -76,7 +76,7 @@ describe AccountSearchService, type: :service do
|
||||||
expect(results).to eq [partial]
|
expect(results).to eq [partial]
|
||||||
end
|
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)
|
remote = Fabricate(:account, username: 'a', domain: 'remote', display_name: 'e', suspended: true)
|
||||||
results = subject.call('a@example.com', nil, limit: 2)
|
results = subject.call('a@example.com', nil, limit: 2)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
let(:note) do
|
let(:note) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://foo.bar/@foo/1234",
|
id: 'https://foo.bar/@foo/1234',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
|
@ -46,7 +46,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
let(:object) do
|
let(:object) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://foo.bar/@foo/1234",
|
id: 'https://foo.bar/@foo/1234',
|
||||||
type: 'Video',
|
type: 'Video',
|
||||||
name: 'Nyan Cat 10 hours remix',
|
name: 'Nyan Cat 10 hours remix',
|
||||||
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
|
@ -54,13 +54,13 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
{
|
{
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
mimeType: 'application/x-bittorrent',
|
mimeType: 'application/x-bittorrent',
|
||||||
href: "https://foo.bar/12345.torrent",
|
href: 'https://foo.bar/12345.torrent',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
mimeType: 'text/html',
|
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
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
expect(status.url).to eq "https://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"
|
expect(strip_tags(status.text)).to eq 'Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
let(:object) do
|
let(:object) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://foo.bar/@foo/1234",
|
id: 'https://foo.bar/@foo/1234',
|
||||||
type: 'Audio',
|
type: 'Audio',
|
||||||
name: 'Nyan Cat 10 hours remix',
|
name: 'Nyan Cat 10 hours remix',
|
||||||
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
|
@ -87,13 +87,13 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
{
|
{
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
mimeType: 'application/x-bittorrent',
|
mimeType: 'application/x-bittorrent',
|
||||||
href: "https://foo.bar/12345.torrent",
|
href: 'https://foo.bar/12345.torrent',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
mimeType: 'text/html',
|
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
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
expect(status.url).to eq "https://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"
|
expect(strip_tags(status.text)).to eq 'Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
let(:object) do
|
let(:object) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://foo.bar/@foo/1234",
|
id: 'https://foo.bar/@foo/1234',
|
||||||
type: 'Event',
|
type: 'Event',
|
||||||
name: "Let's change the world",
|
name: "Let's change the world",
|
||||||
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
|
@ -123,7 +123,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
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"
|
expect(strip_tags(status.text)).to eq "Let's change the worldhttps://foo.bar/@foo/1234"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -132,7 +132,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
let(:note) do
|
let(:note) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://real.address/@foo/1234",
|
id: 'https://real.address/@foo/1234',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
|
@ -154,7 +154,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
let(:object) do
|
let(:object) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://foo.bar/@foo/1234/create",
|
id: 'https://foo.bar/@foo/1234/create',
|
||||||
type: 'Create',
|
type: 'Create',
|
||||||
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
object: note,
|
object: note,
|
||||||
|
@ -174,11 +174,11 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
let(:object) do
|
let(:object) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://foo.bar/@foo/1234/create",
|
id: 'https://foo.bar/@foo/1234/create',
|
||||||
type: 'Create',
|
type: 'Create',
|
||||||
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
object: {
|
object: {
|
||||||
id: "https://real.address/@foo/1234",
|
id: 'https://real.address/@foo/1234',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
|
@ -208,7 +208,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
let(:object) do
|
let(:object) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://foo.bar/@foo/1234/create",
|
id: 'https://foo.bar/@foo/1234/create',
|
||||||
type: 'Create',
|
type: 'Create',
|
||||||
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
object: note.merge(updated: '2021-09-08T22:39:25Z'),
|
object: note.merge(updated: '2021-09-08T22:39:25Z'),
|
||||||
|
@ -233,7 +233,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
let(:object) do
|
let(:object) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://foo.bar/@foo/1",
|
id: 'https://foo.bar/@foo/1',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
inReplyTo: 'https://foo.bar/@foo/2',
|
inReplyTo: 'https://foo.bar/@foo/2',
|
||||||
|
@ -269,7 +269,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
let(:object) do
|
let(:object) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://foo.bar/@foo/1",
|
id: 'https://foo.bar/@foo/1',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
replies: {
|
replies: {
|
||||||
|
|
|
@ -59,8 +59,8 @@ RSpec.describe DeleteAccountService, type: :service do
|
||||||
|
|
||||||
describe '#call on local account' do
|
describe '#call on local account' do
|
||||||
before do
|
before do
|
||||||
stub_request(:post, "https://alice.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)
|
stub_request(:post, 'https://bob.com/inbox').to_return(status: 201)
|
||||||
end
|
end
|
||||||
|
|
||||||
let!(:remote_alice) { Fabricate(:account, inbox_url: 'https://alice.com/inbox', protocol: :activitypub) }
|
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
|
it 'sends a delete actor activity to all known inboxes' do
|
||||||
subject
|
subject
|
||||||
expect(a_request(:post, "https://alice.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
|
expect(a_request(:post, 'https://bob.com/inbox')).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#call on remote account' do
|
describe '#call on remote account' do
|
||||||
before do
|
before do
|
||||||
stub_request(:post, "https://alice.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)
|
stub_request(:post, 'https://bob.com/inbox').to_return(status: 201)
|
||||||
end
|
end
|
||||||
|
|
||||||
include_examples 'common behavior' do
|
include_examples 'common behavior' do
|
||||||
|
|
|
@ -23,7 +23,7 @@ RSpec.describe FavouriteService, type: :service do
|
||||||
let(:status) { Fabricate(:status, account: bob) }
|
let(:status) { Fabricate(:status, account: bob) }
|
||||||
|
|
||||||
before do
|
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)
|
subject.call(sender, status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ RSpec.describe FavouriteService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends a like activity' do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,7 +30,7 @@ RSpec.describe FetchLinkCardService, type: :service do
|
||||||
|
|
||||||
it 'works with SJIS' do
|
it 'works with SJIS' do
|
||||||
expect(a_request(:get, 'http://example.com/sjis')).to have_been_made.at_least_once
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ RSpec.describe FetchLinkCardService, type: :service do
|
||||||
|
|
||||||
it 'works with SJIS even with wrong charset header' 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(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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ RSpec.describe FetchLinkCardService, type: :service do
|
||||||
|
|
||||||
it 'works with koi8-r' do
|
it 'works with koi8-r' do
|
||||||
expect(a_request(:get, 'http://example.com/koi8-r')).to have_been_made.at_least_once
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ RSpec.describe FetchLinkCardService, type: :service do
|
||||||
|
|
||||||
it 'works with Japanese path string' do
|
it 'works with Japanese path string' do
|
||||||
expect(a_request(:get, 'http://example.com/日本語')).to have_been_made.at_least_once
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ describe FetchOEmbedService, type: :service do
|
||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, "https://host.test/provider.json").to_return(status: 404)
|
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/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/empty_provider.json').to_return(status: 200)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'discover_provider' do
|
describe 'discover_provider' do
|
||||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe FetchRemoteStatusService, type: :service do
|
||||||
let(:note) do
|
let(:note) do
|
||||||
{
|
{
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: "https://example.org/@foo/1234",
|
id: 'https://example.org/@foo/1234',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
attributedTo: ActivityPub::TagManager.instance.uri_for(account),
|
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') }
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
|
||||||
|
|
||||||
before do
|
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)
|
subject.call(sender, bob)
|
||||||
end
|
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') }
|
let!(:eve) { Fabricate(:account, username: 'eve', domain: 'example.com', locked: false, protocol: :activitypub, inbox_url: 'https://example.com/inbox') }
|
||||||
|
|
||||||
before do
|
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
|
end
|
||||||
|
|
||||||
context 'import old-style list of muted users' do
|
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
|
# Make sure to not actually go to the remote server
|
||||||
before do
|
before do
|
||||||
stub_request(:post, "https://թութ.հայ/inbox").to_return(status: 200)
|
stub_request(:post, 'https://թութ.հայ/inbox').to_return(status: 200)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:csv) { attachment_fixture('utf8-followers.txt') }
|
let(:csv) { attachment_fixture('utf8-followers.txt') }
|
||||||
|
|
|
@ -5,7 +5,7 @@ RSpec.describe PostStatusService, type: :service do
|
||||||
|
|
||||||
it 'creates a new status' do
|
it 'creates a new status' do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
text = "test status update"
|
text = 'test status update'
|
||||||
|
|
||||||
status = subject.call(account, text: text)
|
status = subject.call(account, text: text)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ RSpec.describe PostStatusService, type: :service do
|
||||||
it 'creates a new response status' do
|
it 'creates a new response status' do
|
||||||
in_reply_to_status = Fabricate(:status)
|
in_reply_to_status = Fabricate(:status)
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
text = "test status update"
|
text = 'test status update'
|
||||||
|
|
||||||
status = subject.call(account, text: text, thread: in_reply_to_status)
|
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)
|
boosted_status = Fabricate(:status)
|
||||||
in_reply_to_status = Fabricate(:status, reblog: boosted_status)
|
in_reply_to_status = Fabricate(:status, reblog: boosted_status)
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
text = "test status update"
|
text = 'test status update'
|
||||||
|
|
||||||
status = subject.call(account, text: text, thread: in_reply_to_status)
|
status = subject.call(account, text: text, thread: in_reply_to_status)
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ RSpec.describe PostStatusService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a status with spoiler text' do
|
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)
|
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)
|
status = create_status_with_options(visibility: :private)
|
||||||
|
|
||||||
expect(status).to be_persisted
|
expect(status).to be_persisted
|
||||||
expect(status.visibility).to eq "private"
|
expect(status.visibility).to eq 'private'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a status with limited visibility for silenced users' do
|
it 'creates a status with limited visibility for silenced users' do
|
||||||
status = subject.call(Fabricate(:account, silenced: true), text: 'test', visibility: :public)
|
status = subject.call(Fabricate(:account, silenced: true), text: 'test', visibility: :public)
|
||||||
|
|
||||||
expect(status).to be_persisted
|
expect(status).to be_persisted
|
||||||
expect(status.visibility).to eq "unlisted"
|
expect(status.visibility).to eq 'unlisted'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a status for the given application' do
|
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)
|
allow(ProcessMentionsService).to receive(:new).and_return(mention_service)
|
||||||
account = Fabricate(:account)
|
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(ProcessMentionsService).to have_received(:new)
|
||||||
expect(mention_service).to have_received(:call).with(status, save_records: false)
|
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)
|
allow(ProcessHashtagsService).to receive(:new).and_return(hashtags_service)
|
||||||
account = Fabricate(:account)
|
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(ProcessHashtagsService).to have_received(:new)
|
||||||
expect(hashtags_service).to have_received(:call).with(status)
|
expect(hashtags_service).to have_received(:call).with(status)
|
||||||
|
@ -178,7 +178,7 @@ RSpec.describe PostStatusService, type: :service do
|
||||||
|
|
||||||
account = Fabricate(:account)
|
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(DistributionWorker).to have_received(:perform_async).with(status.id)
|
||||||
expect(ActivityPub::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)
|
allow(LinkCrawlWorker).to receive(:perform_async)
|
||||||
account = Fabricate(:account)
|
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)
|
expect(LinkCrawlWorker).to have_received(:perform_async).with(status.id)
|
||||||
end
|
end
|
||||||
|
@ -199,7 +199,7 @@ RSpec.describe PostStatusService, type: :service do
|
||||||
|
|
||||||
status = subject.call(
|
status = subject.call(
|
||||||
account,
|
account,
|
||||||
text: "test status update",
|
text: 'test status update',
|
||||||
media_ids: [media.id]
|
media_ids: [media.id]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ RSpec.describe PostStatusService, type: :service do
|
||||||
|
|
||||||
status = subject.call(
|
status = subject.call(
|
||||||
account,
|
account,
|
||||||
text: "test status update",
|
text: 'test status update',
|
||||||
media_ids: [media.id]
|
media_ids: [media.id]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ RSpec.describe PostStatusService, type: :service do
|
||||||
expect do
|
expect do
|
||||||
subject.call(
|
subject.call(
|
||||||
account,
|
account,
|
||||||
text: "test status update",
|
text: 'test status update',
|
||||||
media_ids: [
|
media_ids: [
|
||||||
Fabricate(:media_attachment, account: account),
|
Fabricate(:media_attachment, account: account),
|
||||||
Fabricate(:media_attachment, account: account),
|
Fabricate(:media_attachment, account: account),
|
||||||
|
@ -250,7 +250,7 @@ RSpec.describe PostStatusService, type: :service do
|
||||||
expect do
|
expect do
|
||||||
subject.call(
|
subject.call(
|
||||||
account,
|
account,
|
||||||
text: "test status update",
|
text: 'test status update',
|
||||||
media_ids: [
|
media_ids: [
|
||||||
video,
|
video,
|
||||||
image,
|
image,
|
||||||
|
|
|
@ -62,7 +62,7 @@ RSpec.describe ProcessMentionsService, type: :service do
|
||||||
|
|
||||||
context 'with an IDN domain' 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!(: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
|
before do
|
||||||
subject.call(status)
|
subject.call(status)
|
||||||
|
@ -75,7 +75,7 @@ RSpec.describe ProcessMentionsService, type: :service do
|
||||||
|
|
||||||
context 'with an IDN TLD' 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!(: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
|
before do
|
||||||
subject.call(status)
|
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) }
|
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
|
before do
|
||||||
stub_request(:get, "https://example.com/.well-known/host-meta").to_return(status: 404)
|
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/webfinger?resource=acct:remote_user@example.com').to_return(status: 500)
|
||||||
subject.call(status)
|
subject.call(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@ RSpec.describe ResolveAccountService, type: :service do
|
||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, "https://example.com/.well-known/host-meta").to_return(status: 404)
|
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://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/.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').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://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, %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)
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:hoge@example.com').to_return(status: 410)
|
||||||
end
|
end
|
||||||
|
@ -56,8 +56,8 @@ RSpec.describe ResolveAccountService, type: :service do
|
||||||
|
|
||||||
context 'when there is an LRDD endpoint but no resolvable account' do
|
context 'when there is an LRDD endpoint but no resolvable account' do
|
||||||
before 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/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/webfinger?resource=acct:catsrgr8@quitter.no').to_return(status: 404)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns nil' do
|
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
|
context 'when there is no LRDD endpoint nor resolvable account' do
|
||||||
before 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
|
end
|
||||||
|
|
||||||
it 'returns nil' do
|
it 'returns nil' do
|
||||||
|
@ -153,7 +153,7 @@ RSpec.describe ResolveAccountService, type: :service do
|
||||||
|
|
||||||
context 'with multiple types' do
|
context 'with multiple types' do
|
||||||
before 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
|
end
|
||||||
|
|
||||||
it 'returns new remote account' do
|
it 'returns new remote account' do
|
||||||
|
|
|
@ -12,7 +12,7 @@ end
|
||||||
gc_counter = -1
|
gc_counter = -1
|
||||||
|
|
||||||
RSpec.configure do |config|
|
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|
|
config.expect_with :rspec do |expectations|
|
||||||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||||
end
|
end
|
||||||
|
@ -60,7 +60,7 @@ end
|
||||||
|
|
||||||
def expect_push_bulk_to_match(klass, matcher)
|
def expect_push_bulk_to_match(klass, matcher)
|
||||||
expect(Sidekiq::Client).to receive(:push_bulk).with(hash_including({
|
expect(Sidekiq::Client).to receive(:push_bulk).with(hash_including({
|
||||||
"class" => klass,
|
'class' => klass,
|
||||||
"args" => matcher,
|
'args' => matcher,
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue