Upgrade to Rails 5.0.0.1

This commit is contained in:
Eugen Rochko 2016-08-17 17:56:23 +02:00
parent ff2cbc0753
commit 10ba09f546
47 changed files with 398 additions and 291 deletions

11
Gemfile
View file

@ -1,6 +1,6 @@
source 'https://rubygems.org'
gem 'rails', '4.2.5.2'
gem 'rails', '5.0.0.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
@ -15,7 +15,6 @@ gem 'pg'
gem 'dotenv-rails'
gem 'font-awesome-rails'
gem 'paranoia', '~> 2.0'
gem 'paperclip', '~> 4.3'
gem 'http'
@ -34,15 +33,14 @@ gem 'fast_blank'
gem 'htmlentities'
gem 'onebox'
gem 'simple_form'
gem 'will_paginate', '~> 3.0.6'
gem 'will_paginate'
gem 'rack-attack'
gem 'turbolinks', '~> 5.0.0.beta'
gem 'turbolinks'
gem 'sidekiq'
gem 'sinatra', :require => nil
gem 'sinatra', require: nil, github: 'sinatra'
group :development, :test do
gem 'rspec-rails'
gem 'quiet_assets'
gem 'pry-rails'
gem 'fuubar'
gem 'fabrication'
@ -55,7 +53,6 @@ group :test do
end
group :development do
gem 'web-console', '~> 2.0'
gem 'rubocop', require: false
gem 'better_errors'
gem 'binding_of_caller'

View file

@ -1,44 +1,58 @@
GIT
remote: git://github.com/sinatra/sinatra.git
revision: 6b5a0ef3a4598366138fefe3f2b696ddeb371f3c
specs:
rack-protection (2.0.0)
rack
sinatra (2.0.0.pre.alpha)
mustermann (~> 0.4)
rack (~> 2.0)
rack-protection (~> 2.0)
tilt (~> 2.0)
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.5.2)
actionpack (= 4.2.5.2)
actionview (= 4.2.5.2)
activejob (= 4.2.5.2)
actioncable (5.0.0.1)
actionpack (= 5.0.0.1)
nio4r (~> 1.2)
websocket-driver (~> 0.6.1)
actionmailer (5.0.0.1)
actionpack (= 5.0.0.1)
actionview (= 5.0.0.1)
activejob (= 5.0.0.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.5.2)
actionview (= 4.2.5.2)
activesupport (= 4.2.5.2)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.0.0.1)
actionview (= 5.0.0.1)
activesupport (= 5.0.0.1)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.5.2)
activesupport (= 4.2.5.2)
actionview (5.0.0.1)
activesupport (= 5.0.0.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.5.2)
activesupport (= 4.2.5.2)
globalid (>= 0.3.0)
activemodel (4.2.5.2)
activesupport (= 4.2.5.2)
builder (~> 3.1)
activerecord (4.2.5.2)
activemodel (= 4.2.5.2)
activesupport (= 4.2.5.2)
arel (~> 6.0)
activesupport (4.2.5.2)
activejob (5.0.0.1)
activesupport (= 5.0.0.1)
globalid (>= 0.3.6)
activemodel (5.0.0.1)
activesupport (= 5.0.0.1)
activerecord (5.0.0.1)
activemodel (= 5.0.0.1)
activesupport (= 5.0.0.1)
arel (~> 7.0)
activesupport (5.0.0.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
arel (6.0.3)
ast (2.2.0)
arel (7.1.1)
ast (2.3.0)
bcrypt (3.1.11)
better_errors (2.1.1)
coderay (>= 1.0.0)
@ -47,9 +61,9 @@ GEM
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
bullet (5.0.0)
bullet (5.3.0)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.9.0)
uniform_notifier (~> 1.10.0)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.8)
@ -62,38 +76,37 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.1)
concurrent-ruby (1.0.2)
connection_pool (2.2.0)
crack (0.4.3)
safe_yaml (~> 1.0.0)
debug_inspector (0.0.2)
devise (3.5.6)
devise (4.2.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
railties (>= 4.1.0, < 5.1)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
diff-lcs (1.2.5)
docile (1.1.5)
domain_name (0.5.20160310)
domain_name (0.5.20160615)
unf (>= 0.0.5, < 1.0.0)
doorkeeper (3.1.0)
railties (>= 3.2)
dotenv (2.1.0)
dotenv-rails (2.1.0)
dotenv (= 2.1.0)
doorkeeper (4.1.0)
railties (>= 4.2)
dotenv (2.1.1)
dotenv-rails (2.1.1)
dotenv (= 2.1.1)
railties (>= 4.0, < 5.1)
erubis (2.7.0)
execjs (2.6.0)
fabrication (2.15.0)
execjs (2.7.0)
fabrication (2.15.2)
fast_blank (1.0.0)
font-awesome-rails (4.5.0.1)
font-awesome-rails (4.6.3.1)
railties (>= 3.2, < 5.1)
fuubar (2.0.0)
fuubar (2.1.1)
rspec (~> 3.0)
ruby-progressbar (~> 1.4)
globalid (0.3.6)
globalid (0.3.7)
activesupport (>= 4.1.0)
goldfinger (1.0.2)
addressable (~> 2.4)
@ -125,7 +138,7 @@ GEM
http-form_data (1.0.1)
http_parser.rb (0.6.0)
i18n (0.7.0)
jbuilder (2.4.1)
jbuilder (2.6.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jquery-rails (4.1.1)
@ -137,24 +150,30 @@ GEM
addressable (~> 2.3)
letter_opener (1.4.1)
launchy (~> 2.2)
libv8 (3.16.14.13)
libv8 (3.16.14.15)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mail (2.6.4)
mime-types (>= 1.16, < 4)
memory_profiler (0.9.6)
method_source (0.8.2)
mime-types (2.99.1)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mimemagic (0.3.0)
mini_portile2 (2.0.0)
minitest (5.8.4)
mini_portile2 (2.1.0)
minitest (5.9.0)
moneta (0.8.0)
multi_json (1.11.2)
mustache (1.0.2)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oj (2.14.6)
onebox (1.5.35)
multi_json (1.12.1)
mustache (1.0.3)
mustermann (0.4.0)
tool (~> 0.2)
nio4r (1.2.1)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
oj (2.17.3)
onebox (1.5.48)
htmlentities (~> 4.3.4)
moneta (~> 0.8)
multi_json (~> 1.11)
@ -165,55 +184,48 @@ GEM
addressable (~> 2.4)
http (~> 1.0)
nokogiri (~> 1.6)
paperclip (4.3.6)
paperclip (4.3.7)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
cocaine (~> 0.5.5)
mime-types
mimemagic (= 0.3.0)
paranoia (2.1.5)
activerecord (~> 4.0)
parser (2.3.0.6)
parser (2.3.1.2)
ast (~> 2.2)
pg (0.18.4)
pkg-config (1.1.7)
powerpack (0.1.1)
pry (0.10.3)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-rails (0.3.4)
pry (>= 0.9.10)
puma (3.2.0)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rabl (0.12.0)
puma (3.6.0)
rabl (0.13.0)
activesupport (>= 2.3.14)
rack (1.6.4)
rack-attack (4.4.1)
rack (2.0.1)
rack-attack (5.0.1)
rack
rack-mini-profiler (0.9.9.2)
rack-mini-profiler (0.10.1)
rack (>= 1.2.0)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.5.2)
actionmailer (= 4.2.5.2)
actionpack (= 4.2.5.2)
actionview (= 4.2.5.2)
activejob (= 4.2.5.2)
activemodel (= 4.2.5.2)
activerecord (= 4.2.5.2)
activesupport (= 4.2.5.2)
rails (5.0.0.1)
actioncable (= 5.0.0.1)
actionmailer (= 5.0.0.1)
actionpack (= 5.0.0.1)
actionview (= 5.0.0.1)
activejob (= 5.0.0.1)
activemodel (= 5.0.0.1)
activerecord (= 5.0.0.1)
activesupport (= 5.0.0.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.5.2)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
railties (= 5.0.0.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.1)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails_12factor (0.0.3)
@ -222,57 +234,58 @@ GEM
rails_autolink (1.1.6)
rails (> 3.1)
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.4)
railties (4.2.5.2)
actionpack (= 4.2.5.2)
activesupport (= 4.2.5.2)
rails_stdout_logging (0.0.5)
railties (5.0.0.1)
actionpack (= 5.0.0.1)
activesupport (= 5.0.0.1)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.1.0)
rake (11.1.1)
rake (11.2.2)
rdoc (4.2.2)
json (~> 1.4)
redis (3.2.2)
redis (3.3.1)
ref (2.0.0)
responders (2.1.1)
responders (2.3.0)
railties (>= 4.2.0, < 5.1)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.4)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.2)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.1)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-rails (3.4.2)
actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-support (~> 3.4.0)
rspec-support (~> 3.5.0)
rspec-rails (3.5.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-support (~> 3.5.0)
rspec-sidekiq (2.2.0)
rspec (~> 3.0, >= 3.0.0)
sidekiq (>= 2.4.0)
rspec-support (3.4.1)
rubocop (0.38.0)
parser (>= 2.3.0.6, < 3.0)
rspec-support (3.5.0)
rubocop (0.42.0)
parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.7.5)
ruby_parser (3.8.1)
ruby-progressbar (1.8.1)
ruby_parser (3.8.2)
sexp_processor (~> 4.1)
safe_yaml (1.0.4)
sass (3.4.21)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
@ -281,27 +294,23 @@ GEM
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
sexp_processor (4.7.0)
sidekiq (4.1.1)
sidekiq (4.1.2)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
redis (~> 3.2, >= 3.2.1)
simple_form (3.2.1)
actionpack (> 4, < 5.1)
activemodel (> 4, < 5.1)
simplecov (0.11.2)
simplecov (0.12.0)
docile (~> 1.1.0)
json (~> 1.8)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
sinatra (1.4.7)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
slop (3.6.0)
sprockets (3.5.2)
sprockets (3.7.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.0.4)
sprockets-rails (3.1.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
@ -310,32 +319,30 @@ GEM
ref
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.2)
turbolinks (5.0.0.beta2)
turbolinks-source
turbolinks-source (5.0.0.beta3)
tilt (2.0.5)
tool (0.2.3)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.2)
execjs (>= 0.3.0)
json (>= 1.8.0)
uglifier (3.0.1)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
unicode-display_width (1.0.2)
uniform_notifier (1.9.0)
unicode-display_width (1.1.0)
uniform_notifier (1.10.0)
warden (1.2.6)
rack (>= 1.0)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
webmock (1.24.2)
webmock (2.1.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
will_paginate (3.0.7)
websocket-driver (0.6.4)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
will_paginate (3.1.0)
PLATFORMS
ruby
@ -367,15 +374,13 @@ DEPENDENCIES
onebox
ostatus2
paperclip (~> 4.3)
paranoia (~> 2.0)
pg
pry-rails
puma
quiet_assets
rabl
rack-attack
rack-mini-profiler
rails (= 4.2.5.2)
rails (= 5.0.0.1)
rails_12factor
rails_autolink
redis (~> 3.2)
@ -387,13 +392,12 @@ DEPENDENCIES
sidekiq
simple_form
simplecov
sinatra
sinatra!
therubyracer
turbolinks (~> 5.0.0.beta)
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)
webmock
will_paginate (~> 3.0.6)
will_paginate
BUNDLED WITH
1.11.2
1.12.5

View file

@ -4,7 +4,7 @@ class Api::SalmonController < ApiController
def update
ProcessInteractionService.new.(request.body.read, @account)
render nothing: true, status: 201
head 201
end
private

View file

@ -4,9 +4,9 @@ class Api::SubscriptionsController < ApiController
def show
if @account.subscription(api_subscription_url(@account.id)).valid?(params['hub.topic'], params['hub.verify_token'])
render text: HTMLEntities.new.encode(params['hub.challenge']), status: 200
render plain: HTMLEntities.new.encode(params['hub.challenge']), status: 200
else
render nothing: true, status: 404
head 404
end
end
@ -15,9 +15,9 @@ class Api::SubscriptionsController < ApiController
if @account.subscription(api_subscription_url(@account.id)).verify(body, request.headers['HTTP_X_HUB_SIGNATURE'])
ProcessFeedService.new.(body, @account)
render nothing: true, status: 201
head 201
else
render nothing: true, status: 202
head 202
end
end

View file

@ -1,6 +1,6 @@
class ApiController < ApplicationController
protect_from_forgery with: :null_session
skip_before_filter :verify_authenticity_token
skip_before_action :verify_authenticity_token
protected

View file

@ -11,8 +11,8 @@ class Auth::RegistrationsController < Devise::RegistrationsController
end
def configure_sign_up_params
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(:email, :password, :password_confirmation, account_attributes: [:username])
devise_parameter_sanitizer.permit(:sign_up) do |u|
u.permit({ account_attributes: [:username] }, :email, :password, :password_confirmation)
end
end

View file

@ -1,5 +1,5 @@
class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
before_filter :authenticate_user!
before_action :authenticate_user!
def index
@applications = current_user.oauth_applications

View file

@ -1,5 +1,5 @@
class XrdController < ApplicationController
before_filter :set_format
before_action :set_format
def host_meta
@webfinger_template = "#{webfinger_url}?resource={uri}"
@ -10,7 +10,7 @@ class XrdController < ApplicationController
@canonical_account_uri = "acct:#{@account.username}@#{Rails.configuration.x.local_domain}"
@magic_key = pem_to_magic_key(@account.keypair.public_key)
rescue ActiveRecord::RecordNotFound
render nothing: true, status: 404
head 404
end
private

View file

@ -1,10 +1,10 @@
class Account < ActiveRecord::Base
class Account < ApplicationRecord
include Targetable
# Local users
has_one :user, inverse_of: :account
validates :username, uniqueness: { scope: :domain, case_sensitive: false }, if: 'local?'
validates :username, uniqueness: { scope: :domain, case_sensitive: true }, unless: 'local?'
validates :username, presence: true, uniqueness: { scope: :domain, case_sensitive: false }, if: 'local?'
validates :username, presence: true, uniqueness: { scope: :domain, case_sensitive: true }, unless: 'local?'
# Avatar upload
has_attached_file :avatar, styles: { large: '300x300#', medium: '96x96#', small: '48x48#' }, default_url: 'avatars/missing.png'

View file

@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end

View file

@ -1,4 +1,4 @@
class Favourite < ActiveRecord::Base
class Favourite < ApplicationRecord
include Streamable
belongs_to :account, inverse_of: :favourites

View file

@ -1,4 +1,4 @@
class Follow < ActiveRecord::Base
class Follow < ApplicationRecord
include Streamable
belongs_to :account

View file

@ -1,4 +1,4 @@
class Mention < ActiveRecord::Base
class Mention < ApplicationRecord
belongs_to :account, inverse_of: :mentions
belongs_to :status

View file

@ -1,4 +1,4 @@
class Status < ActiveRecord::Base
class Status < ApplicationRecord
include Paginable
include Streamable

View file

@ -1,4 +1,4 @@
class StreamEntry < ActiveRecord::Base
class StreamEntry < ApplicationRecord
include Paginable
belongs_to :account, inverse_of: :stream_entries

View file

@ -1,4 +1,4 @@
class User < ActiveRecord::Base
class User < ApplicationRecord
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
belongs_to :account, inverse_of: :user

View file

@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'

View file

@ -1,29 +1,34 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
# Add necessary setup steps to this file.
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install"
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system "bin/rake db:setup"
system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
system! 'bin/rails restart'
end

29
bin/update Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "\n== Updating database =="
system! 'bin/rails db:migrate'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

View file

@ -1,4 +1,4 @@
require File.expand_path('../boot', __FILE__)
require_relative 'boot'
require 'rails/all'
@ -22,9 +22,6 @@ module Mastodon
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]

View file

@ -1,3 +1,3 @@
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.

9
config/cable.yml Normal file
View file

@ -0,0 +1,9 @@
development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: redis://<%= ENV['REDIS_HOST'] || 'localhost' %>:<%= ENV['REDIS_PORT'] || 6379 %>/1

View file

@ -1,5 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!

View file

@ -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

View file

@ -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'],

View file

@ -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

View file

@ -0,0 +1,6 @@
# Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )

View file

@ -1,3 +1,5 @@
# 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

View file

@ -0,0 +1,23 @@
# 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

View file

@ -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

View file

@ -1,13 +1,47 @@
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

View file

@ -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.

View file

@ -1,4 +1,3 @@
# 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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 }