Skip to content
Snippets Groups Projects
Commit 10ba09f5 authored by Eugen Rochko's avatar Eugen Rochko
Browse files

Upgrade to Rails 5.0.0.1

parent ff2cbc07
No related branches found
No related tags found
No related merge requests found
Showing
with 155 additions and 83 deletions
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: redis://<%= ENV['REDIS_HOST'] || 'localhost' %>:<%= ENV['REDIS_PORT'] || 6379 %>/1
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
......@@ -9,12 +9,26 @@ Rails.application.configure do
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Show full error reports.
config.consider_all_requests_local= true
# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
......@@ -27,9 +41,8 @@ Rails.application.configure do
# number of complex assets.
config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
......@@ -39,6 +52,10 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.action_mailer.delivery_method = :letter_opener
config.after_initialize do
......
......@@ -14,15 +14,9 @@ Rails.application.configure do
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = true
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
......@@ -31,10 +25,6 @@ Rails.application.configure do
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
......@@ -49,7 +39,7 @@ Rails.application.configure do
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
config.log_tags = [ :request_id ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
......@@ -77,6 +67,8 @@ Rails.application.configure do
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
config.action_mailer.perform_caching = false
# E-mails
config.action_mailer.smtp_settings = {
:port => ENV['SMTP_PORT'],
......
......@@ -13,8 +13,10 @@ Rails.application.configure do
config.eager_load = false
# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=3600'
}
config.assets.digest = false
# Show full error reports and disable caching.
......@@ -31,9 +33,7 @@ Rails.application.configure do
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Randomize the order test cases are executed.
config.active_support.test_order = :random
config.action_mailer.perform_caching = false
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
......
# Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Rails 5.0 release notes for more info on each option.
# Enable per-form CSRF tokens. Previous versions had false.
Rails.application.config.action_controller.per_form_csrf_tokens = false
# Enable origin-checking CSRF mitigation. Previous versions had false.
Rails.application.config.action_controller.forgery_protection_origin_check = false
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
ActiveSupport.to_time_preserves_timezone = false
# Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = false
# Do not halt callback chains when a callback returns false. Previous versions had true.
ActiveSupport.halt_callback_chains_on_return_false = true
......@@ -5,10 +5,10 @@
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# self.include_root_in_json = true
# end
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
preload_app!
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
#
port ENV.fetch("PORT") { 3000 }
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
on_worker_boot do
ActiveRecord::Base.establish_connection
end
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# preload_app!
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted this block will be run, if you are using `preload_app!`
# option you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
......@@ -5,7 +5,7 @@
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# You can use `rails secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
......
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
......@@ -41,37 +40,33 @@ ActiveRecord::Schema.define(version: 20160325130944) do
t.integer "header_file_size"
t.datetime "header_updated_at"
t.string "avatar_remote_url"
t.index ["username", "domain"], name: "index_accounts_on_username_and_domain", unique: true, using: :btree
end
add_index "accounts", ["username", "domain"], name: "index_accounts_on_username_and_domain", unique: true, using: :btree
create_table "favourites", force: :cascade do |t|
t.integer "account_id", null: false
t.integer "status_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "status_id"], name: "index_favourites_on_account_id_and_status_id", unique: true, using: :btree
end
add_index "favourites", ["account_id", "status_id"], name: "index_favourites_on_account_id_and_status_id", unique: true, using: :btree
create_table "follows", force: :cascade do |t|
t.integer "account_id", null: false
t.integer "target_account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true, using: :btree
end
add_index "follows", ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true, using: :btree
create_table "mentions", force: :cascade do |t|
t.integer "account_id"
t.integer "status_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "status_id"], name: "index_mentions_on_account_id_and_status_id", unique: true, using: :btree
end
add_index "mentions", ["account_id", "status_id"], name: "index_mentions_on_account_id_and_status_id", unique: true, using: :btree
create_table "oauth_access_grants", force: :cascade do |t|
t.integer "resource_owner_id", null: false
t.integer "application_id", null: false
......@@ -81,10 +76,9 @@ ActiveRecord::Schema.define(version: 20160325130944) do
t.datetime "created_at", null: false
t.datetime "revoked_at"
t.string "scopes"
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree
end
add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree
create_table "oauth_access_tokens", force: :cascade do |t|
t.integer "resource_owner_id"
t.integer "application_id"
......@@ -94,12 +88,11 @@ ActiveRecord::Schema.define(version: 20160325130944) do
t.datetime "revoked_at"
t.datetime "created_at", null: false
t.string "scopes"
t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree
t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", using: :btree
t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree
end
add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree
add_index "oauth_access_tokens", ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", using: :btree
add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree
create_table "oauth_applications", force: :cascade do |t|
t.string "name", null: false
t.string "uid", null: false
......@@ -110,11 +103,10 @@ ActiveRecord::Schema.define(version: 20160325130944) do
t.datetime "updated_at"
t.integer "owner_id"
t.string "owner_type"
t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree
end
add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree
add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree
create_table "statuses", force: :cascade do |t|
t.string "uri"
t.integer "account_id", null: false
......@@ -124,24 +116,22 @@ ActiveRecord::Schema.define(version: 20160325130944) do
t.integer "in_reply_to_id"
t.integer "reblog_of_id"
t.string "url"
t.index ["account_id"], name: "index_statuses_on_account_id", using: :btree
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id", using: :btree
t.index ["reblog_of_id"], name: "index_statuses_on_reblog_of_id", using: :btree
t.index ["uri"], name: "index_statuses_on_uri", unique: true, using: :btree
end
add_index "statuses", ["account_id"], name: "index_statuses_on_account_id", using: :btree
add_index "statuses", ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id", using: :btree
add_index "statuses", ["reblog_of_id"], name: "index_statuses_on_reblog_of_id", using: :btree
add_index "statuses", ["uri"], name: "index_statuses_on_uri", unique: true, using: :btree
create_table "stream_entries", force: :cascade do |t|
t.integer "account_id"
t.integer "activity_id"
t.string "activity_type"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_stream_entries_on_account_id", using: :btree
t.index ["activity_id", "activity_type"], name: "index_stream_entries_on_activity_id_and_activity_type", using: :btree
end
add_index "stream_entries", ["account_id"], name: "index_stream_entries_on_account_id", using: :btree
add_index "stream_entries", ["activity_id", "activity_type"], name: "index_stream_entries_on_activity_id_and_activity_type", using: :btree
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.integer "account_id", null: false
......@@ -157,10 +147,9 @@ ActiveRecord::Schema.define(version: 20160325130944) do
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.boolean "admin", default: false
t.index ["account_id"], name: "index_users_on_account_id", using: :btree
t.index ["email"], name: "index_users_on_email", unique: true, using: :btree
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
end
add_index "users", ["account_id"], name: "index_users_on_account_id", using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
end
......@@ -5,26 +5,26 @@ RSpec.describe AccountsController, type: :controller do
describe 'GET #show' do
it 'returns http success' do
get :show, username: alice.username
get :show, params: { username: alice.username }
expect(response).to have_http_status(:success)
end
it 'returns http success with Atom' do
get :show, username: alice.username, format: 'atom'
get :show, params: { username: alice.username }, format: 'atom'
expect(response).to have_http_status(:success)
end
end
describe 'GET #followers' do
it 'returns http success' do
get :followers, username: alice.username
get :followers, params: { username: alice.username }
expect(response).to have_http_status(:success)
end
end
describe 'GET #following' do
it 'returns http success' do
get :following, username: alice.username
get :following, params: { username: alice.username }
expect(response).to have_http_status(:success)
end
end
......
......@@ -12,7 +12,7 @@ RSpec.describe Api::Accounts::LookupController, type: :controller do
before do
Fabricate(:account, username: 'bob')
Fabricate(:account, username: 'mcbeth')
get :index, usernames: 'alice,bob,mcbeth'
get :index, params: { usernames: 'alice,bob,mcbeth' }
end
it 'returns http success' do
......
......@@ -10,28 +10,28 @@ RSpec.describe Api::AccountsController, type: :controller do
describe 'GET #show' do
it 'returns http success' do
get :show, id: user.account.id
get :show, params: { id: user.account.id }
expect(response).to have_http_status(:success)
end
end
describe 'GET #statuses' do
it 'returns http success' do
get :statuses, id: user.account.id
get :statuses, params: { id: user.account.id }
expect(response).to have_http_status(:success)
end
end
describe 'GET #followers' do
it 'returns http success' do
get :followers, id: user.account.id
get :followers, params: { id: user.account.id }
expect(response).to have_http_status(:success)
end
end
describe 'GET #following' do
it 'returns http success' do
get :following, id: user.account.id
get :following, params: { id: user.account.id }
expect(response).to have_http_status(:success)
end
end
......@@ -40,7 +40,7 @@ RSpec.describe Api::AccountsController, type: :controller do
let(:other_account) { Fabricate(:account, username: 'bob') }
before do
post :follow, id: other_account.id
post :follow, params: { id: other_account.id }
end
it 'returns http success' do
......@@ -57,7 +57,7 @@ RSpec.describe Api::AccountsController, type: :controller do
before do
user.account.follow!(other_account)
post :unfollow, id: other_account.id
post :unfollow, params: { id: other_account.id }
end
it 'returns http success' do
......
......@@ -18,7 +18,7 @@ RSpec.describe Api::FollowsController, type: :controller do
stub_request(:post, "https://quitter.no/main/salmon/user/7477").to_return(:status => 200, :body => "", :headers => {})
stub_request(:post, "https://pubsubhubbub.superfeedr.com/").to_return(:status => 200, :body => "", :headers => {})
post :create, uri: 'gargron@quitter.no'
post :create, params: { uri: 'gargron@quitter.no' }
end
it 'returns http success' do
......
......@@ -13,7 +13,7 @@ RSpec.describe Api::SalmonController, type: :controller do
describe 'POST #update' do
before do
request.env['RAW_POST_DATA'] = File.read(File.join(Rails.root, 'spec', 'fixtures', 'salmon', 'mention.xml'))
post :update, id: account.id
post :update, params: { id: account.id }
end
it 'returns http success' do
......
......@@ -12,7 +12,7 @@ RSpec.describe Api::StatusesController, type: :controller do
let(:status) { Fabricate(:status, account: user.account) }
it 'returns http success' do
get :show, id: status.id
get :show, params: { id: status.id }
expect(response).to have_http_status(:success)
end
end
......
......@@ -5,7 +5,7 @@ RSpec.describe Api::SubscriptionsController, type: :controller do
describe 'GET #show' do
before do
get :show, :id => account.id, 'hub.topic' => 'topic_url', 'hub.verify_token' => 123, 'hub.challenge' => '456'
get :show, params: { :id => account.id, 'hub.topic' => 'topic_url', 'hub.verify_token' => 123, 'hub.challenge' => '456' }
end
it 'returns http success' do
......@@ -26,7 +26,7 @@ RSpec.describe Api::SubscriptionsController, type: :controller do
request.env['HTTP_X_HUB_SIGNATURE'] = "sha1=#{OpenSSL::HMAC.hexdigest('sha1', 'abc', feed)}"
request.env['RAW_POST_DATA'] = feed
post :update, id: account.id
post :update, params: { id: account.id }
end
it 'returns http created' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment