From 10ba09f5466fe3d34a5ed78202c35f4e4f9d30e6 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 17 Aug 2016 17:56:23 +0200 Subject: [PATCH] Upgrade to Rails 5.0.0.1 --- Gemfile | 11 +- Gemfile.lock | 312 +++++++++--------- app/controllers/api/salmon_controller.rb | 2 +- .../api/subscriptions_controller.rb | 8 +- app/controllers/api_controller.rb | 2 +- .../auth/registrations_controller.rb | 4 +- .../oauth/applications_controller.rb | 2 +- app/controllers/xrd_controller.rb | 4 +- app/models/account.rb | 6 +- app/models/application_record.rb | 3 + app/models/favourite.rb | 2 +- app/models/follow.rb | 2 +- app/models/mention.rb | 2 +- app/models/status.rb | 2 +- app/models/stream_entry.rb | 2 +- app/models/user.rb | 2 +- bin/rails | 2 +- bin/setup | 29 +- bin/update | 29 ++ config/application.rb | 5 +- config/boot.rb | 2 +- config/cable.yml | 9 + config/environment.rb | 2 +- config/environments/development.rb | 29 +- config/environments/production.rb | 16 +- config/environments/test.rb | 10 +- .../application_controller_renderer.rb | 6 + config/initializers/cookies_serializer.rb | 2 + config/initializers/new_framework_defaults.rb | 23 ++ config/initializers/wrap_parameters.rb | 4 +- config/puma.rb | 52 ++- config/secrets.yml | 2 +- db/schema.rb | 49 ++- spec/controllers/accounts_controller_spec.rb | 8 +- .../api/accounts/lookup_controller_spec.rb | 2 +- .../api/accounts_controller_spec.rb | 12 +- .../api/follows_controller_spec.rb | 2 +- .../controllers/api/salmon_controller_spec.rb | 2 +- .../api/statuses_controller_spec.rb | 2 +- .../api/subscriptions_controller_spec.rb | 4 +- .../auth/sessions_controller_spec.rb | 2 +- spec/controllers/settings_controller_spec.rb | 2 +- spec/controllers/statuses_controller_spec.rb | 4 +- .../stream_entries_controller_spec.rb | 4 +- spec/controllers/xrd_controller_spec.rb | 4 +- spec/fabricators/account_fabricator.rb | 2 +- spec/rails_helper.rb | 2 +- 47 files changed, 398 insertions(+), 291 deletions(-) create mode 100644 app/models/application_record.rb create mode 100755 bin/update create mode 100644 config/cable.yml create mode 100644 config/initializers/application_controller_renderer.rb create mode 100644 config/initializers/new_framework_defaults.rb diff --git a/Gemfile b/Gemfile index 4fb7b2a730f..a0c8de164f3 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 37ec40b4849..93ff50b6c93 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/controllers/api/salmon_controller.rb b/app/controllers/api/salmon_controller.rb index b15aefee9e1..329b258a41f 100644 --- a/app/controllers/api/salmon_controller.rb +++ b/app/controllers/api/salmon_controller.rb @@ -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 diff --git a/app/controllers/api/subscriptions_controller.rb b/app/controllers/api/subscriptions_controller.rb index 91b987ce43f..e923b9b663f 100644 --- a/app/controllers/api/subscriptions_controller.rb +++ b/app/controllers/api/subscriptions_controller.rb @@ -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 diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 35f1e62c562..8a27124760a 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -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 diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index ad0fd4437b5..8472edc6920 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -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 diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb index 4614ef2f751..47935bf7cfd 100644 --- a/app/controllers/oauth/applications_controller.rb +++ b/app/controllers/oauth/applications_controller.rb @@ -1,5 +1,5 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController - before_filter :authenticate_user! + before_action :authenticate_user! def index @applications = current_user.oauth_applications diff --git a/app/controllers/xrd_controller.rb b/app/controllers/xrd_controller.rb index fa67b2baa2c..1e39a3e4c79 100644 --- a/app/controllers/xrd_controller.rb +++ b/app/controllers/xrd_controller.rb @@ -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 diff --git a/app/models/account.rb b/app/models/account.rb index f61f4c7656b..cc050dfa32c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -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' diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 00000000000..10a4cba84df --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/favourite.rb b/app/models/favourite.rb index 46310a5ff50..6032e539cf5 100644 --- a/app/models/favourite.rb +++ b/app/models/favourite.rb @@ -1,4 +1,4 @@ -class Favourite < ActiveRecord::Base +class Favourite < ApplicationRecord include Streamable belongs_to :account, inverse_of: :favourites diff --git a/app/models/follow.rb b/app/models/follow.rb index 94263b1a7c1..456e2c4f46e 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -1,4 +1,4 @@ -class Follow < ActiveRecord::Base +class Follow < ApplicationRecord include Streamable belongs_to :account diff --git a/app/models/mention.rb b/app/models/mention.rb index 9fefa657a40..b39fa2cbbc7 100644 --- a/app/models/mention.rb +++ b/app/models/mention.rb @@ -1,4 +1,4 @@ -class Mention < ActiveRecord::Base +class Mention < ApplicationRecord belongs_to :account, inverse_of: :mentions belongs_to :status diff --git a/app/models/status.rb b/app/models/status.rb index 7ea92df2c99..14a698aae81 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -1,4 +1,4 @@ -class Status < ActiveRecord::Base +class Status < ApplicationRecord include Paginable include Streamable diff --git a/app/models/stream_entry.rb b/app/models/stream_entry.rb index 2972d94f61a..165f62f2008 100644 --- a/app/models/stream_entry.rb +++ b/app/models/stream_entry.rb @@ -1,4 +1,4 @@ -class StreamEntry < ActiveRecord::Base +class StreamEntry < ApplicationRecord include Paginable belongs_to :account, inverse_of: :stream_entries diff --git a/app/models/user.rb b/app/models/user.rb index a80efb50d19..71e310cc86f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/bin/rails b/bin/rails index 5191e6927af..07396602377 100755 --- a/bin/rails +++ b/bin/rails @@ -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' diff --git a/bin/setup b/bin/setup index acdb2c1389c..e620b4dadb2 100755 --- a/bin/setup +++ b/bin/setup @@ -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 diff --git a/bin/update b/bin/update new file mode 100755 index 00000000000..a8e4462f203 --- /dev/null +++ b/bin/update @@ -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 diff --git a/config/application.rb b/config/application.rb index 7d6182ecca3..c3ea5851a40 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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', '*')] diff --git a/config/boot.rb b/config/boot.rb index 6b750f00b1d..30f5120df69 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -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. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 00000000000..b544be4b4ea --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,9 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://<%= ENV['REDIS_HOST'] || 'localhost' %>:<%= ENV['REDIS_PORT'] || 6379 %>/1 diff --git a/config/environment.rb b/config/environment.rb index ee8d90dc651..426333bb469 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('../application', __FILE__) +require_relative 'application' # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 5646308135a..1affeca118b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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 diff --git a/config/environments/production.rb b/config/environments/production.rb index 182f154934a..4c4ed760c61 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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'], diff --git a/config/environments/test.rb b/config/environments/test.rb index 1ef379f40d6..fea1c51fdff 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -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 diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 00000000000..51639b67a00 --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -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 +# ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7f70458dee6..5a6a32d371f 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -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 diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb new file mode 100644 index 00000000000..f6e72335f6a --- /dev/null +++ b/config/initializers/new_framework_defaults.rb @@ -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 diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 33725e95fd2..bbfc3961bff 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -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 diff --git a/config/puma.rb b/config/puma.rb index 49f4b974da9..e8212125f94 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -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 diff --git a/config/secrets.yml b/config/secrets.yml index 68c9408d578..51681d7a5c8 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -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. diff --git a/db/schema.rb b/db/schema.rb index 03d336d5a86..45ab70855ab 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index b0a5181dac0..c5abe63a8d0 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -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 diff --git a/spec/controllers/api/accounts/lookup_controller_spec.rb b/spec/controllers/api/accounts/lookup_controller_spec.rb index 46c904b5a3e..043df8c86ce 100644 --- a/spec/controllers/api/accounts/lookup_controller_spec.rb +++ b/spec/controllers/api/accounts/lookup_controller_spec.rb @@ -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 diff --git a/spec/controllers/api/accounts_controller_spec.rb b/spec/controllers/api/accounts_controller_spec.rb index 7bcb1a788d2..dd060ddaa4a 100644 --- a/spec/controllers/api/accounts_controller_spec.rb +++ b/spec/controllers/api/accounts_controller_spec.rb @@ -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 diff --git a/spec/controllers/api/follows_controller_spec.rb b/spec/controllers/api/follows_controller_spec.rb index e9bb1bfa535..28646525131 100644 --- a/spec/controllers/api/follows_controller_spec.rb +++ b/spec/controllers/api/follows_controller_spec.rb @@ -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 diff --git a/spec/controllers/api/salmon_controller_spec.rb b/spec/controllers/api/salmon_controller_spec.rb index d5be69c014e..8b356640f9f 100644 --- a/spec/controllers/api/salmon_controller_spec.rb +++ b/spec/controllers/api/salmon_controller_spec.rb @@ -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 diff --git a/spec/controllers/api/statuses_controller_spec.rb b/spec/controllers/api/statuses_controller_spec.rb index 75a8b999a3a..c02c1d889bd 100644 --- a/spec/controllers/api/statuses_controller_spec.rb +++ b/spec/controllers/api/statuses_controller_spec.rb @@ -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 diff --git a/spec/controllers/api/subscriptions_controller_spec.rb b/spec/controllers/api/subscriptions_controller_spec.rb index de4c8f56def..e13ec4939e3 100644 --- a/spec/controllers/api/subscriptions_controller_spec.rb +++ b/spec/controllers/api/subscriptions_controller_spec.rb @@ -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 diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb index 004a44fba6c..48c9b34a1a9 100644 --- a/spec/controllers/auth/sessions_controller_spec.rb +++ b/spec/controllers/auth/sessions_controller_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Auth::SessionsController, type: :controller do before do request.env["devise.mapping"] = Devise.mappings[:user] - post :create, user: { email: user.email, password: user.password } + post :create, params: { user: { email: user.email, password: user.password } } end it 'redirects to home page' do diff --git a/spec/controllers/settings_controller_spec.rb b/spec/controllers/settings_controller_spec.rb index b417cbdafe7..0b41a2111c8 100644 --- a/spec/controllers/settings_controller_spec.rb +++ b/spec/controllers/settings_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe SettingsController, type: :controller do before do - sign_in :user, Fabricate(:user) + sign_in Fabricate(:user), scope: :user end describe "GET #show" do diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rb index 05566a30e0d..812d75127b4 100644 --- a/spec/controllers/statuses_controller_spec.rb +++ b/spec/controllers/statuses_controller_spec.rb @@ -4,13 +4,13 @@ RSpec.describe StatusesController, type: :controller do let(:user) { Fabricate(:user) } before do - sign_in :user, user + sign_in user, scope: :user end describe 'POST #create' do before do stub_request(:post, "https://pubsubhubbub.superfeedr.com/").to_return(:status => 200, :body => "", :headers => {}) - post :create, status: { text: 'Hello world' } + post :create, params: { status: { text: 'Hello world' } } end it 'redirects back to homepage' do diff --git a/spec/controllers/stream_entries_controller_spec.rb b/spec/controllers/stream_entries_controller_spec.rb index 1b5f1fd7a7b..56b636ab402 100644 --- a/spec/controllers/stream_entries_controller_spec.rb +++ b/spec/controllers/stream_entries_controller_spec.rb @@ -6,12 +6,12 @@ RSpec.describe StreamEntriesController, type: :controller do describe 'GET #show' do it 'returns http success with HTML' do - get :show, account_username: alice.username, id: status.stream_entry.id + get :show, params: { account_username: alice.username, id: status.stream_entry.id } expect(response).to have_http_status(:success) end it 'returns http success with Atom' do - get :show, account_username: alice.username, id: status.stream_entry.id, format: 'atom' + get :show, params: { account_username: alice.username, id: status.stream_entry.id }, format: 'atom' expect(response).to have_http_status(:success) end end diff --git a/spec/controllers/xrd_controller_spec.rb b/spec/controllers/xrd_controller_spec.rb index c6bc5eab52f..9152a714b5e 100644 --- a/spec/controllers/xrd_controller_spec.rb +++ b/spec/controllers/xrd_controller_spec.rb @@ -12,12 +12,12 @@ RSpec.describe XrdController, type: :controller do let(:alice) { Fabricate(:account, username: 'alice') } it 'returns http success when account can be found' do - get :webfinger, resource: "acct:#{alice.username}@anything.com" + get :webfinger, params: { resource: "acct:#{alice.username}@anything.com" } expect(response).to have_http_status(:success) end it 'returns http not found when account cannot be found' do - get :webfinger, resource: 'acct:not@existing.com' + get :webfinger, params: { resource: 'acct:not@existing.com' } expect(response).to have_http_status(:not_found) end end diff --git a/spec/fabricators/account_fabricator.rb b/spec/fabricators/account_fabricator.rb index 5f87ea522a8..3a7c00bf552 100644 --- a/spec/fabricators/account_fabricator.rb +++ b/spec/fabricators/account_fabricator.rb @@ -1,3 +1,3 @@ Fabricator(:account) do - + username "alice" end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 71e99e16e5f..e9c732f6f7f 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -17,7 +17,7 @@ RSpec.configure do |config| config.infer_spec_type_from_file_location! config.filter_rails_from_backtrace! - config.include Devise::TestHelpers, type: :controller + config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::TestHelpers, type: :view end