lint pass 2 (#8878)

* Code quality pass

* Typofix

* Update applications_controller_spec.rb

* Update applications_controller_spec.rb
This commit is contained in:
aus-social 2018-10-05 01:38:04 +10:00 committed by Eugen Rochko
parent a46ab86adf
commit 0a4739c732
15 changed files with 47 additions and 46 deletions

View file

@ -42,7 +42,7 @@ Rails.application.configure do
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Allow to specify public IP of reverse proxy if it's needed # Allow to specify public IP of reverse proxy if it's needed
config.action_dispatch.trusted_proxies = ENV['TRUSTED_PROXY_IP'].split.map { |item| IPAddr.new(item) } unless ENV['TRUSTED_PROXY_IP'].blank? config.action_dispatch.trusted_proxies = ENV['TRUSTED_PROXY_IP'].split.map { |item| IPAddr.new(item) } if ENV['TRUSTED_PROXY_IP'].present?
# Use the lowest log level to ensure availability of diagnostic information # Use the lowest log level to ensure availability of diagnostic information
# when problems arise. # when problems arise.

View file

@ -6,7 +6,7 @@ Rails.application.configure do
raise "No proxy host" unless proxy.host raise "No proxy host" unless proxy.host
host = proxy.host host = proxy.host
host = host[1...-1] if host[0] == '[' #for IPv6 address host = host[1...-1] if host[0] == '[' # for IPv6 address
config.x.http_client_proxy[:proxy] = { proxy_address: host, proxy_port: proxy.port, proxy_username: proxy.user, proxy_password: proxy.password }.compact config.x.http_client_proxy[:proxy] = { proxy_address: host, proxy_port: proxy.port, proxy_username: proxy.user, proxy_password: proxy.password }.compact
end end

View file

@ -3,7 +3,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do
end end
Devise.setup do |config| Devise.setup do |config|
# Devise omniauth strategies # Devise omniauth strategies
options = {} options = {}
options[:redirect_at_sign_in] = ENV['OAUTH_REDIRECT_AT_SIGN_IN'] == 'true' options[:redirect_at_sign_in] = ENV['OAUTH_REDIRECT_AT_SIGN_IN'] == 'true'

View file

@ -1,7 +1,7 @@
require 'open-uri' require 'open-uri'
module OpenURI module OpenURI
def OpenURI.redirectable?(uri1, uri2) # :nodoc: def self.redirectable?(uri1, uri2) # :nodoc:
uri1.scheme.downcase == uri2.scheme.downcase || uri1.scheme.downcase == uri2.scheme.downcase ||
(/\A(?:http|https|ftp)\z/i =~ uri1.scheme && /\A(?:http|https|ftp)\z/i =~ uri2.scheme) (/\A(?:http|https|ftp)\z/i =~ uri1.scheme && /\A(?:http|https|ftp)\z/i =~ uri2.scheme)
end end

View file

@ -42,7 +42,7 @@ class Rack::Attack
# (blocklist & throttles are skipped) # (blocklist & throttles are skipped)
Rack::Attack.safelist('allow from localhost') do |req| Rack::Attack.safelist('allow from localhost') do |req|
# Requests are allowed if the return value is truthy # Requests are allowed if the return value is truthy
'127.0.0.1' == req.ip || '::1' == req.ip req.ip == '127.0.0.1' || req.ip == '::1'
end end
throttle('throttle_authenticated_api', limit: 300, period: 5.minutes) do |req| throttle('throttle_authenticated_api', limit: 300, period: 5.minutes) do |req|

View file

@ -19,4 +19,4 @@ Sidekiq.configure_client do |config|
config.redis = redis_params config.redis = redis_params
end end
Sidekiq::Logging.logger.level = ::Logger::const_get(ENV.fetch('RAILS_LOG_LEVEL', 'info').upcase.to_s) Sidekiq::Logging.logger.level = ::Logger.const_get(ENV.fetch('RAILS_LOG_LEVEL', 'info').upcase.to_s)

View file

@ -1,7 +1,7 @@
threads_count = ENV.fetch('MAX_THREADS') { 5 }.to_i threads_count = ENV.fetch('MAX_THREADS') { 5 }.to_i
threads threads_count, threads_count threads threads_count, threads_count
if ENV['SOCKET'] then if ENV['SOCKET']
bind 'unix://' + ENV['SOCKET'] bind 'unix://' + ENV['SOCKET']
else else
port ENV.fetch('PORT') { 3000 } port ENV.fetch('PORT') { 3000 }

View file

@ -24,7 +24,7 @@ describe Admin::StatusesController do
end end
it 'returns http success with media' do it 'returns http success with media' do
get :index, params: { account_id: account.id , media: true } get :index, params: { account_id: account.id, media: true }
statuses = assigns(:statuses).to_a statuses = assigns(:statuses).to_a
expect(statuses.size).to eq 1 expect(statuses.size).to eq 1

View file

@ -8,6 +8,7 @@ describe ApplicationController, type: :controller do
def index def index
send_export_file send_export_file
end end
def export_data def export_data
@export.account.username @export.account.username
end end

View file

@ -275,7 +275,7 @@ RSpec.describe Account, type: :model do
subject { Fabricate(:account) } subject { Fabricate(:account) }
context 'when the status is a reblog of another status'do context 'when the status is a reblog of another status' do
let(:original_reblog) do let(:original_reblog) do
author = Fabricate(:account, username: 'original_reblogger') author = Fabricate(:account, username: 'original_reblogger')
Fabricate(:status, reblog: original_status, account: author) Fabricate(:status, reblog: original_status, account: author)

View file

@ -254,7 +254,7 @@ RSpec.describe User, type: :model do
it_behaves_like 'Settings-extended' do it_behaves_like 'Settings-extended' do
def create! def create!
User.create!(account: Fabricate(:account), email: 'foo@mastodon.space', password: 'abcd1234' ) User.create!(account: Fabricate(:account), email: 'foo@mastodon.space', password: 'abcd1234')
end end
def fabricate def fabricate

View file

@ -49,7 +49,7 @@ describe 'stream_entries/show.html.haml', without_verify_partial_doubles: true d
assign(:stream_entry, reply.stream_entry) assign(:stream_entry, reply.stream_entry)
assign(:account, alice) assign(:account, alice)
assign(:type, reply.stream_entry.activity_type.downcase) assign(:type, reply.stream_entry.activity_type.downcase)
assign(:ancestors, reply.stream_entry.activity.ancestors(1, bob) ) 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 render