ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
-require 'bundler/setup' # Set up gems listed in the Gemfile.
+require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap' # Speed up boot time by caching expensive operations.
Bootsnap.setup(
saml_options = options
saml_options[:assertion_consumer_service_url] = ENV['SAML_ACS_URL'] if ENV['SAML_ACS_URL']
saml_options[:issuer] = ENV['SAML_ISSUER'] if ENV['SAML_ISSUER']
- saml_options[:idp_sso_target_url] = ENV['SAML_IDP_SSO_TARGET_URL'] if ENV['SAML_IDP_SSO_TARGET_URL']
+ saml_options[:idp_sso_target_url] = ENV['SAML_IDP_SSO_TARGET_URL'] if ENV['SAML_IDP_SSO_TARGET_URL']
saml_options[:idp_sso_target_url_runtime_params] = ENV['SAML_IDP_SSO_TARGET_PARAMS'] if ENV['SAML_IDP_SSO_TARGET_PARAMS'] # FIXME: Should be parsable Hash
saml_options[:idp_cert] = ENV['SAML_IDP_CERT'] if ENV['SAML_IDP_CERT']
saml_options[:idp_cert_fingerprint] = ENV['SAML_IDP_CERT_FINGERPRINT'] if ENV['SAML_IDP_CERT_FINGERPRINT']
saml_options[:uid_attribute] = ENV['SAML_UID_ATTRIBUTE'] if ENV['SAML_UID_ATTRIBUTE']
config.omniauth :saml, saml_options
end
-
end
alternate_domains = ENV.fetch('ALTERNATE_DOMAINS') { '' }
Rails.application.configure do
- https = Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'
+ https = Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'
config.x.local_domain = host
config.x.web_domain = web_host
module Twitter
class Regex
-
REGEXEN[:valid_general_url_path_chars] = /[^\p{White_Space}\(\)\?]/iou
REGEXEN[:valid_url_path_ending_chars] = /[^\p{White_Space}\(\)\?!\*';:=\,\.\$%\[\]~&\|@]|(?:#{REGEXEN[:valid_url_balanced_parens]})/iou
REGEXEN[:valid_url_balanced_parens] = /
# frozen_string_literal: true
Rails.application.configure do
-
# You can generate the keys using the following command (first is the private key, second is the public one)
# You should only generate this once per instance. If you later decide to change it, all push subscription will
# be invalidated, requiring the users to access the website again to resubscribe.
# https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
#
# t.text :token, null: false
- t.string :token, null: false
+ t.string :token, null: false
t.string :refresh_token
t.integer :expires_in
t.datetime :revoked_at
- t.datetime :created_at, null: false
+ t.datetime :created_at, null: false
t.string :scopes
end
class RailsSettingsMigration < MIGRATION_BASE_CLASS
def self.up
create_table :settings do |t|
- t.string :var, :null => false
+ t.string :var, :null => false
t.text :value
t.references :target, :null => false, :polymorphic => true
t.timestamps :null => true
class ChangeTagSearchIndexToBtree < ActiveRecord::Migration[5.1]
-
def up
remove_index :tags, name: :hashtag_search_index
execute 'CREATE INDEX hashtag_search_index ON tags (name text_pattern_ops);'
def up
add_column_with_default :mutes, :hide_notifications, :boolean, default: true, allow_null: false
end
-
+
def down
remove_column :mutes, :hide_notifications
end
-- So, first, we iterate over the user's feed to find any reblogs.
local items = redis.call('zrange', timeline_key, 0, -1, 'withscores')
-
+
for i = 1, #items, 2 do
local reblogged_id = items[i]
local reblogging_id = items[i + 1]
add_column_with_default :follow_requests, :show_reblogs, :boolean, default: true, allow_null: false
end
end
-
+
def down
remove_column :follows, :show_reblogs
remove_column :follow_requests, :show_reblogs
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2018_08_20_232245) do
-
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
RSpec.describe AccountsController, type: :controller do
render_views
- let(:alice) { Fabricate(:account, username: 'alice') }
- let(:eve) { Fabricate(:user) }
+ let(:alice) { Fabricate(:account, username: 'alice') }
+ let(:eve) { Fabricate(:user) }
describe 'GET #show' do
let!(:status1) { Status.create!(account: alice, text: 'Hello world') }
end
end
-
describe 'POST #subscribe' do
subject { post :subscribe, params: { id: account.id } }
describe 'POST #create' do
it 'blocks the domain when succeeded to save' do
- post :create, params: { email_domain_block: { domain: 'example.com'} }
+ post :create, params: { email_domain_block: { domain: 'example.com' } }
expect(flash[:notice]).to eq I18n.t('admin.email_domain_blocks.created_msg')
expect(response).to redirect_to(admin_email_domain_blocks_path)
describe 'DELETE #destroy' do
it 'unblocks the domain' do
email_domain_block = Fabricate(:email_domain_block)
- delete :destroy, params: { id: email_domain_block.id }
+ delete :destroy, params: { id: email_domain_block.id }
expect(flash[:notice]).to eq I18n.t('admin.email_domain_blocks.destroyed_msg')
expect(response).to redirect_to(admin_email_domain_blocks_path)
subject { post :create, params: { invite: { max_uses: '10', expires_in: 1800 } } }
it 'succeeds to create a invite' do
- expect{ subject }.to change { Invite.count }.by(1)
+ expect { subject }.to change { Invite.count }.by(1)
expect(subject).to redirect_to admin_invites_path
expect(Invite.last).to have_attributes(user_id: user.id, max_uses: 10)
end
let(:report) { Fabricate(:report, action_taken: action_taken, action_taken_by_account_id: account_id) }
context 'when parameter is valid' do
-
context 'when report is unsolved' do
let(:action_taken) { false }
let(:account_id) { nil }
let(:params) { { report_note: { content: 'test content', report_id: report.id }, create_and_resolve: nil } }
it 'creates a report note and resolves report' do
- expect{ subject }.to change{ ReportNote.count }.by(1)
+ expect { subject }.to change { ReportNote.count }.by(1)
expect(report.reload).to be_action_taken
expect(subject).to redirect_to admin_reports_path
end
let(:params) { { report_note: { content: 'test content', report_id: report.id } } }
it 'creates a report note and does not resolve report' do
- expect{ subject }.to change{ ReportNote.count }.by(1)
+ expect { subject }.to change { ReportNote.count }.by(1)
expect(report.reload).not_to be_action_taken
expect(subject).to redirect_to admin_report_path(report)
end
let(:params) { { report_note: { content: 'test content', report_id: report.id }, create_and_unresolve: nil } }
it 'creates a report note and unresolves report' do
- expect{ subject }.to change{ ReportNote.count }.by(1)
+ expect { subject }.to change { ReportNote.count }.by(1)
expect(report.reload).not_to be_action_taken
expect(subject).to redirect_to admin_report_path(report)
end
let(:params) { { report_note: { content: 'test content', report_id: report.id } } }
it 'creates a report note and does not unresolve report' do
- expect{ subject }.to change{ ReportNote.count }.by(1)
+ expect { subject }.to change { ReportNote.count }.by(1)
expect(report.reload).to be_action_taken
expect(subject).to redirect_to admin_report_path(report)
end
let!(:report_note) { Fabricate(:report_note) }
it 'deletes note' do
- expect{ subject }.to change{ ReportNote.count }.by(-1)
+ expect { subject }.to change { ReportNote.count }.by(-1)
expect(subject).to redirect_to admin_report_path(report_note.report)
end
end
describe 'POST #create' do
subject do
- -> { post :create, params: { :report_id => report, action => '', :form_status_batch => { status_ids: status_ids } } }
+ -> { post :create, params: { :report_id => report, action => '', :form_status_batch => { status_ids: status_ids } } }
end
let(:action) { 'nsfw_on' }
before do
user.account.follow!(other_account)
- post :mute, params: {id: other_account.id }
+ post :mute, params: { id: other_account.id }
end
it 'returns http success' do
before do
user.account.follow!(other_account)
- post :mute, params: {id: other_account.id, notifications: false }
+ post :mute, params: { id: other_account.id, notifications: false }
end
it 'returns http success' do
expect(response.headers['Link'].links.size).to eq(2)
end
end
-
end
context 'without an oauth token' do
describe 'GET #index' do
it 'redirects to streaming host' do
- get :index, params: {access_token: 'deadbeef', stream: 'public'}
+ get :index, params: { access_token: 'deadbeef', stream: 'public' }
expect(response).to have_http_status(301)
request_uri = URI.parse(request.url)
redirect_to_uri = URI.parse(response.location)
end
end
end
-
end
describe Api::V1::Timelines::HomeController do
render_views
- let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice'), current_sign_in_at: 1.day.ago) }
+ let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice'), current_sign_in_at: 1.day.ago) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
describe Api::V1::Timelines::PublicController do
render_views
- let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
+ let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
context 'when successfully finds status' do
let(:status) { Fabricate(:status) }
- let(:url) { "http://#{ Rails.configuration.x.web_domain }/@#{status.account.username}/#{status.id}" }
+ let(:url) { "http://#{Rails.configuration.x.web_domain}/@#{status.account.username}/#{status.id}" }
it 'returns a right response' do
expect(response).to have_http_status :ok
describe 'helper_method :current_theme' do
it 'returns "default" when theme wasn\'t changed in admin settings' do
- allow(Setting).to receive(:default_settings).and_return({'theme' => 'default'})
+ allow(Setting).to receive(:default_settings).and_return({ 'theme' => 'default' })
expect(controller.view_context.current_theme).to eq 'default'
end
describe 'raise_not_found' do
it 'raises error' do
controller.params[:unmatched_route] = 'unmatched'
- expect{ controller.raise_not_found }.to raise_error(ActionController::RoutingError, 'No route matches unmatched')
+ expect { controller.raise_not_found }.to raise_error(ActionController::RoutingError, 'No route matches unmatched')
end
end
end
describe 'PATCH #finish_signup' do
- subject { patch :finish_signup, params: { user: { email: email }} }
+ subject { patch :finish_signup, params: { user: { email: email } } }
let(:user) { Fabricate(:user) }
before do
let(:user) { Fabricate(:user, moderator: false, admin: true) }
it 'succeeds to create a invite' do
- expect{ subject }.to change { Invite.count }.by(1)
+ expect { subject }.to change { Invite.count }.by(1)
expect(subject).to redirect_to invites_path
expect(Invite.last).to have_attributes(user_id: user.id, max_uses: 10)
end
before do
sign_in current_user
current_account.follow!(remote_account)
- stub_request(:post, 'http://example.com/inbox'){ { status: 200 } }
+ stub_request(:post, 'http://example.com/inbox') { { status: 200 } }
end
context 'when successfully unfollow remote account' do
- let(:acct) {"acct:#{ remote_account.username }@#{ remote_account.domain }"}
+ let(:acct) { "acct:#{remote_account.username}@#{remote_account.domain}" }
it do
is_expected.to render_template :success
end
context 'when fails to unfollow remote account' do
- let(:acct) {"acct:#{ remote_account.username + '_test' }@#{ remote_account.domain }"}
+ let(:acct) { "acct:#{remote_account.username + '_test'}@#{remote_account.domain}" }
it do
is_expected.to render_template :error
end
end
-
describe 'GET #show' do
it 'returns http success' do
get :show, params: { id: app.id }
end
describe 'GET #show' do
-
context 'when user is not sign in' do
subject { get :show }
end
describe 'PUT #update' do
-
context 'when user is not sign in' do
subject { put :update }
describe 'when form_two_factor_confirmation parameter is not provided' do
it 'raises ActionController::ParameterMissing' do
- expect { post :create, params: { } }.to raise_error(ActionController::ParameterMissing)
+ expect { post :create, params: {} }.to raise_error(ActionController::ParameterMissing)
end
end
username { sequence(:username) { |i| "#{Faker::Internet.user_name(nil, %w(_))}#{i}" } }
last_webfingered_at { Time.now.utc }
public_key { public_key }
- private_key { private_key}
+ private_key { private_key }
end
Fabricator(:list) do
account
- title "MyString"
+ title "MyString"
end
Fabricator(:relay) do
inbox_url "https://example.com/inbox"
- state :idle
+ state :idle
end
Fabricator(:site_upload) do
-
end
end
it 'sends push updates' do
- status = Fabricate(:status)
+ status = Fabricate(:status)
FeedManager.instance.push_to_home(receiver, status)
end
end
-
describe '#format_spoiler' do
subject { Formatter.instance.format_spoiler(status) }
context 'given a post containing plain text' do
- let(:status) { Fabricate(:status, text: 'text', spoiler_text: 'Secret!', uri: nil) }
+ let(:status) { Fabricate(:status, text: 'text', spoiler_text: 'Secret!', uri: nil) }
it 'Returns the spoiler text' do
is_expected.to eq 'Secret!'
context 'given a post with an emoji shortcode at the start' do
let!(:emoji) { Fabricate(:custom_emoji) }
- let(:status) { Fabricate(:status, text: 'text', spoiler_text: ':coolcat: Secret!', uri: nil) }
+ let(:status) { Fabricate(:status, text: 'text', spoiler_text: ':coolcat: Secret!', uri: nil) }
let(:text) { ':coolcat: Beep boop' }
it 'converts the shortcode to an image tag' do
end
context 'given a post containing plain text' do
- let(:status) { Fabricate(:status, text: 'text', uri: nil) }
+ let(:status) { Fabricate(:status, text: 'text', uri: nil) }
it 'paragraphizes the text' do
is_expected.to eq '<p>text</p>'
end
context 'given a post containing line feeds' do
- let(:status) { Fabricate(:status, text: "line\nfeed", uri: nil) }
+ let(:status) { Fabricate(:status, text: "line\nfeed", uri: nil) }
it 'removes line feeds' do
is_expected.not_to include "\n"
subject { Formatter.instance.plaintext(status) }
context 'given a post with local status' do
- let(:status) { Fabricate(:status, text: '<p>a text by a nerd who uses an HTML tag in text</p>', uri: nil) }
+ let(:status) { Fabricate(:status, text: '<p>a text by a nerd who uses an HTML tag in text</p>', uri: nil) }
it 'returns the raw text' do
is_expected.to eq '<p>a text by a nerd who uses an HTML tag in text</p>'
end
context 'given a post with remote status' do
- let(:status) { Fabricate(:status, account: remote_account, text: '<script>alert("Hello")</script>') }
+ let(:status) { Fabricate(:status, account: remote_account, text: '<script>alert("Hello")</script>') }
it 'returns tag-stripped text' do
is_expected.to eq ''
end
it 'uses nil when account is present but has no locale' do
- result = described_class.instance.detect('', account_without_user_locale)
+ result = described_class.instance.detect('', account_without_user_locale)
expect(result).to eq nil
end
ProcessInteractionService.new.call(envelope, block.target_account)
- expect{ block.reload }.to raise_error ActiveRecord::RecordNotFound
+ expect { block.reload }.to raise_error ActiveRecord::RecordNotFound
end
end
allow(Addrinfo).to receive(:foreach).with('example.com', nil, nil, :SOCK_STREAM)
.and_yield(Addrinfo.new(["AF_INET", 0, "example.com", "0.0.0.0"], :PF_INET, :SOCK_STREAM))
.and_yield(Addrinfo.new(["AF_INET6", 0, "example.com", "2001:db8::face"], :PF_INET6, :SOCK_STREAM))
- expect{ subject.perform }.to raise_error Mastodon::ValidationError
+ expect { subject.perform }.to raise_error Mastodon::ValidationError
end
end
end
require 'rails_helper'
RSpec.describe AccountModerationNote, type: :model do
-
end
require 'rails_helper'
RSpec.describe Admin::ActionLog, type: :model do
-
end
require 'rails_helper'
RSpec.describe Backup, type: :model do
-
end
require 'rails_helper'
RSpec.describe ConversationMute, type: :model do
-
end
describe '#search' do
let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) }
- subject { described_class.search(search_term) }
+ subject { described_class.search(search_term) }
context 'shortcode is exact' do
let(:shortcode) { 'blobpats' }
require 'rails_helper'
RSpec.describe CustomFilter, type: :model do
-
end
require 'rails_helper'
RSpec.describe ListAccount, type: :model do
-
end
require 'rails_helper'
RSpec.describe List, type: :model do
-
end
expect(media.file.meta["original"]["aspect"]).to eq 1.5
expect(media.file.meta["small"]["width"]).to eq 490
expect(media.file.meta["small"]["height"]).to eq 327
- expect(media.file.meta["small"]["aspect"]).to eq 490.0/327
+ expect(media.file.meta["small"]["aspect"]).to eq 490.0 / 327
end
end
require 'rails_helper'
RSpec.describe Mute, type: :model do
-
end
require 'rails_helper'
RSpec.describe PreviewCard, type: :model do
-
end
subject { remote_follow.valid? }
context 'attrs with acct' do
- let(:attrs) { { acct: 'gargron@quitter.no' }}
+ let(:attrs) { { acct: 'gargron@quitter.no' } }
it do
is_expected.to be true
end
context 'attrs without acct' do
- let(:attrs) { { } }
+ let(:attrs) { {} }
it do
is_expected.to be false
require 'rails_helper'
RSpec.describe Web::Setting, type: :model do
-
end
end
it 'processes payload with actor if valid signature exists' do
- payload['signature'] = {'type' => 'RsaSignature2017'}
+ payload['signature'] = { 'type' => 'RsaSignature2017' }
expect_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_account!).and_return(actor)
expect(ActivityPub::Activity).to receive(:factory).with(instance_of(Hash), actor, instance_of(Hash))
end
it 'does not process payload if invalid signature exists' do
- payload['signature'] = {'type' => 'RsaSignature2017'}
+ payload['signature'] = { 'type' => 'RsaSignature2017' }
expect_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_account!).and_return(nil)
expect(ActivityPub::Activity).not_to receive(:factory)
context 'content type is application/atom+xml' do
let(:content_type) { 'application/atom+xml' }
- it { is_expected.to eq [url, {:prefetched_body=>""}, :ostatus] }
+ it { is_expected.to eq [url, { :prefetched_body => "" }, :ostatus] }
end
context 'content_type is json' do
assign(:account, alice)
assign(:type, reply.stream_entry.activity_type.downcase)
assign(:ancestors, reply.stream_entry.activity.ancestors(1, bob) )
- assign(:descendant_threads, [{ statuses: reply.stream_entry.activity.descendants(1)}])
+ assign(:descendant_threads, [{ statuses: reply.stream_entry.activity.descendants(1) }])
render