From 2cf3f22b82bfd8f55319cf402e544a4164854356 Mon Sep 17 00:00:00 2001 From: Pavlos Kallis Date: Wed, 28 Sep 2016 14:33:00 +0300 Subject: [PATCH 1/5] Upgrade to rails 5.0 --- Gemfile | 4 +- Gemfile.lock | 327 ++++++++++++++++++++++++++------------------------- 2 files changed, 166 insertions(+), 165 deletions(-) diff --git a/Gemfile b/Gemfile index c9c8aa38..f9e7701f 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' ruby '2.3.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 4.2' +gem 'rails', '~> 5.0' gem 'haml-rails' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' @@ -33,7 +33,7 @@ gem 'draper' gem 'bootstrap-sass' gem 'bootstrap-social-rails' gem 'font-awesome-rails' -gem 'exception_notification', '~> 4.1.4' +gem 'exception_notification', '~> 4.2.1' gem 'slack-notifier' gem 'gretel' gem 'rack-timeout' diff --git a/Gemfile.lock b/Gemfile.lock index af9b10fe..e83a0bd6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -24,96 +24,95 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.7.1) - actionpack (= 4.2.7.1) - actionview (= 4.2.7.1) - activejob (= 4.2.7.1) + 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.7.1) - actionview (= 4.2.7.1) - activesupport (= 4.2.7.1) - 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.7.1) - activesupport (= 4.2.7.1) + 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) actionview-encoded_mail_to (1.0.7) rails - activejob (4.2.7.1) - activesupport (= 4.2.7.1) - globalid (>= 0.3.0) - activemodel (4.2.7.1) - activesupport (= 4.2.7.1) - builder (~> 3.1) - activerecord (4.2.7.1) - activemodel (= 4.2.7.1) - activesupport (= 4.2.7.1) - arel (~> 6.0) - activesupport (4.2.7.1) + 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.3.8) + addressable (2.4.0) ansi (1.5.0) - arel (6.0.3) - attr_encrypted (1.3.4) - encryptor (>= 1.3.0) - autoprefixer-rails (5.2.1.1) + arel (7.1.2) + attr_encrypted (3.0.3) + encryptor (~> 3.0.0) + autoprefixer-rails (6.5.0) execjs - json - awesome_print (1.6.1) + awesome_print (1.7.0) babel-source (5.8.35) babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) execjs (~> 2.0) - bcrypt (3.1.10) + bcrypt (3.1.11) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bootstrap-sass (3.3.5.1) - autoprefixer-rails (>= 5.0.0.1) - sass (>= 3.3.0) - bootstrap-social-rails (4.8.0) + bootstrap-sass (3.3.7) + autoprefixer-rails (>= 5.2.1) + sass (>= 3.3.4) + bootstrap-social-rails (4.12.0) railties (>= 3.1) builder (3.2.2) - byebug (5.0.0) - columnize (= 0.9.0) - cancancan (1.12.0) - capybara (2.5.0) + byebug (9.0.5) + cancancan (1.15.0) + capybara (2.9.1) + addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) cliver (0.3.2) - coderay (1.1.0) - coffee-rails (4.1.0) + coderay (1.1.1) + coffee-rails (4.1.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) + railties (>= 4.0.0, < 5.1.x) coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.9.1.1) - columnize (0.9.0) + coffee-script-source (1.10.0) concurrent-ruby (1.0.2) connection_pool (2.2.0) - crack (0.4.2) + crack (0.4.3) safe_yaml (~> 1.0.0) - database_cleaner (1.5.1) + database_cleaner (1.5.3) debug_inspector (0.0.2) - devise (3.5.1) + 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) doorkeeper (3.1.0) railties (>= 3.2) @@ -122,30 +121,30 @@ GEM activemodel (>= 3.0) activesupport (>= 3.0) request_store (~> 1.0) - encryptor (1.3.0) + encryptor (3.0.0) erubis (2.7.0) - exception_notification (4.1.4) - actionmailer (~> 4.0) - activesupport (~> 4.0) - excon (0.48.0) - execjs (2.6.0) - factory_girl (4.5.0) + exception_notification (4.2.1) + actionmailer (>= 4.0, < 6) + activesupport (>= 4.0, < 6) + excon (0.53.0) + execjs (2.7.0) + factory_girl (4.7.0) activesupport (>= 3.0.0) - factory_girl_rails (4.5.0) - factory_girl (~> 4.5.0) + factory_girl_rails (4.7.0) + factory_girl (~> 4.7.0) railties (>= 3.0.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) faraday_middleware (0.9.2) faraday (>= 0.7.4, < 0.10) - fog-aws (0.9.1) - fog-core (~> 1.27) + fog-aws (0.12.0) + fog-core (~> 1.38) fog-json (~> 1.0) fog-xml (~> 0.1) ipaddress (~> 0.8) - fog-core (1.36.0) + fog-core (1.42.0) builder - excon (~> 0.45) + excon (~> 0.49) formatador (~> 0.2) fog-json (1.0.2) fog-core (~> 1.0) @@ -153,14 +152,14 @@ GEM fog-xml (0.1.2) fog-core nokogiri (~> 1.5, >= 1.5.11) - font-awesome-rails (4.4.0.0) - railties (>= 3.2, < 5.0) + font-awesome-rails (4.6.3.1) + railties (>= 3.2, < 5.1) formatador (0.2.5) globalid (0.3.7) activesupport (>= 4.1.0) - gretel (3.0.8) - rails (>= 3.2.0) - haml (4.0.6) + gretel (3.0.9) + rails (>= 3.1.0) + haml (4.0.7) tilt haml-rails (0.9.0) actionpack (>= 4.0.1) @@ -168,7 +167,8 @@ GEM haml (>= 4.0.6, < 5.0) html2haml (>= 1.0.1) railties (>= 4.0.1) - hashie (3.4.4) + hashdiff (0.3.0) + hashie (3.4.6) html2haml (2.0.0) erubis (~> 2.7.0) haml (~> 4.0.0) @@ -176,17 +176,17 @@ GEM ruby_parser (~> 3.5) i18n (0.7.0) ipaddress (0.8.3) - jbuilder (2.3.1) - activesupport (>= 3.0.0, < 5) + jbuilder (2.6.0) + activesupport (>= 3.0.0, < 5.1) multi_json (~> 1.2) - jquery-rails (4.0.4) - rails-dom-testing (~> 1.0) + jquery-rails (4.2.1) + rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (5.0.5) railties (>= 3.2.16) json (1.8.3) - jwt (1.5.1) + jwt (1.5.6) loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.4) @@ -197,27 +197,27 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_portile2 (2.1.0) - minitest (5.9.0) - minitest-capybara (0.7.2) + minitest (5.9.1) + minitest-capybara (0.8.2) capybara (~> 2.2) minitest (~> 5.0) rake - minitest-metadata (0.5.3) + minitest-metadata (0.6.0) minitest (>= 4.7, < 6.0) - minitest-rails (2.2.0) - minitest (~> 5.7) - railties (~> 4.1) - minitest-rails-capybara (2.1.1) - capybara (~> 2.0) - minitest-capybara (~> 0.7.0) - minitest-metadata (~> 0.5.0) - minitest-rails (~> 2.1) - minitest-reporters (1.1.5) + minitest-rails (3.0.0) + minitest (~> 5.8) + railties (~> 5.0) + minitest-rails-capybara (3.0.0) + capybara (~> 2.7) + minitest-capybara (~> 0.8) + minitest-metadata (~> 0.6) + minitest-rails (~> 3.0) + minitest-reporters (1.1.11) ansi builder minitest (>= 5.0) ruby-progressbar - minitest-spec-rails (5.3.0) + minitest-spec-rails (5.4.0) minitest (~> 5.0) rails (>= 4.1) mocha (1.1.0) @@ -225,37 +225,37 @@ GEM multi_json (1.12.1) multi_xml (0.5.5) multipart-post (2.0.0) - newrelic_rpm (3.14.0.305) + newrelic_rpm (3.16.3.323) + nio4r (1.2.1) nokogiri (1.6.8) mini_portile2 (~> 2.1.0) pkg-config (~> 1.1.7) oauth (0.5.1) - oauth2 (1.0.0) + oauth2 (1.2.0) faraday (>= 0.8, < 0.10) jwt (~> 1.0) multi_json (~> 1.3) multi_xml (~> 0.5) - rack (~> 1.2) - octokit (4.1.0) - sawyer (~> 0.6.0, >= 0.5.3) - omniauth (1.2.2) + rack (>= 1.2, < 3) + octokit (4.3.0) + sawyer (~> 0.7.0, >= 0.5.3) + omniauth (1.3.1) hashie (>= 1.2, < 4) - rack (~> 1.0) + rack (>= 1.0, < 3) omniauth-github (1.1.2) omniauth (~> 1.0) omniauth-oauth2 (~> 1.1) - omniauth-oauth2 (1.3.1) + omniauth-oauth2 (1.4.0) oauth2 (~> 1.0) omniauth (~> 1.2) orm_adapter (0.5.0) - pg (0.18.4) + pg (0.19.0) pkg-config (1.1.7) - poltergeist (1.9.0) + poltergeist (1.10.0) capybara (~> 2.1) cliver (~> 0.3.1) - multi_json (~> 1.0) websocket-driver (>= 0.2.0) - pry (0.10.3) + pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) @@ -266,61 +266,61 @@ GEM puma (3.6.0) puma-heroku (1.0.0) puma (~> 3.0) - rack (1.6.4) - rack-attack (4.3.0) + rack (2.0.1) + rack-attack (5.0.1) rack rack-protection (1.5.3) rack rack-test (0.6.3) rack (>= 1.0) - rack-timeout (0.3.2) - rails (4.2.7.1) - actionmailer (= 4.2.7.1) - actionpack (= 4.2.7.1) - actionview (= 4.2.7.1) - activejob (= 4.2.7.1) - activemodel (= 4.2.7.1) - activerecord (= 4.2.7.1) - activesupport (= 4.2.7.1) + rack-timeout (0.4.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.7.1) - 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) rails_serve_static_assets rails_stdout_logging - rails_serve_static_assets (0.0.2) - rails_stdout_logging (0.0.3) - railties (4.2.7.1) - actionpack (= 4.2.7.1) - activesupport (= 4.2.7.1) + rails_serve_static_assets (0.0.5) + 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) - rake (11.2.2) - rdoc (4.2.0) - react-bootstrap-rails (0.28.3) + rake (11.3.0) + rdoc (4.2.2) + json (~> 1.4) + react-bootstrap-rails (0.30.2) rails (>= 3.1) - react-rails (1.6.0) + react-rails (1.6.2) babel-transpiler (>= 0.7.0) coffee-script-source (~> 1.8) connection_pool execjs rails (>= 3.2) tilt - redcarpet (3.3.3) + redcarpet (3.3.4) redis (3.3.1) - request_store (1.2.0) - responders (2.1.0) - railties (>= 4.2.0, < 5) - ruby-progressbar (1.7.5) - ruby_parser (3.7.1) + request_store (1.3.1) + responders (2.3.0) + railties (>= 4.2.0, < 5.1) + ruby-progressbar (1.8.1) + ruby_parser (3.8.2) sexp_processor (~> 4.1) safe_yaml (1.0.4) sass (3.4.22) @@ -330,32 +330,30 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sawyer (0.6.0) - addressable (~> 2.3.5) + sawyer (0.7.0) + addressable (>= 2.3.5, < 2.5) faraday (~> 0.8, < 0.10) - scout_apm (2.1.8) + scout_apm (2.1.12) sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) - select2-rails (4.0.0) + select2-rails (4.0.3) thor (~> 0.14) - sexp_processor (4.6.0) - sidekiq (4.2.0) + sexp_processor (4.7.0) + sidekiq (4.2.2) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) rack-protection (~> 1.5) redis (~> 3.2, >= 3.2.1) - simple_form (3.2.0) - actionpack (~> 4.0) - activemodel (~> 4.0) + simple_form (3.3.1) + actionpack (> 4, < 5.1) + activemodel (> 4, < 5.1) simple_oauth (0.3.1) - sinatra (1.4.7) - rack (~> 1.5) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) + sinatra (1.0) + rack (>= 1.0) slack-notifier (1.5.1) slop (3.6.0) - spring (1.3.6) + spring (1.7.2) sprockets (3.7.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -364,33 +362,33 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) sshkey (1.8.0) - test_after_commit (0.4.2) + test_after_commit (1.1.0) activerecord (>= 3.2) thor (0.19.1) thread_safe (0.3.5) tilt (2.0.5) - timecop (0.8.0) + timecop (0.8.1) tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.7.1) - execjs (>= 0.3.0) - json (>= 1.8.0) + uglifier (3.0.2) + execjs (>= 0.3.0, < 3) underscore-rails (1.8.3) - vcr (2.9.3) - warden (1.2.3) + vcr (3.0.3) + warden (1.2.6) rack (>= 1.0) - web-console (2.2.1) + 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.21.0) + webmock (2.1.0) addressable (>= 2.3.6) crack (>= 0.3.2) - websocket-driver (0.6.3) + hashdiff + websocket-driver (0.6.4) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) - wicked (1.2.1) + wicked (1.3.1) railties (>= 3.0.7) xpath (2.0.0) nokogiri (~> 1.3) @@ -415,7 +413,7 @@ DEPENDENCIES devise doorkeeper (~> 3.1.0) draper - exception_notification (~> 4.1.4) + exception_notification (~> 4.2.1) factory_girl_rails fog-aws font-awesome-rails @@ -442,7 +440,7 @@ DEPENDENCIES puma-heroku rack-attack rack-timeout - rails (~> 4.2) + rails (~> 5.0) rails_12factor react-bootstrap-rails react-rails (~> 1.6.0) @@ -468,5 +466,8 @@ DEPENDENCIES webmock wicked +RUBY VERSION + ruby 2.3.0p0 + BUNDLED WITH - 1.11.2 + 1.12.1 From 6d831e2836d0cbd047945dc9eaf89c141a5fc131 Mon Sep 17 00:00:00 2001 From: Pavlos Kallis Date: Wed, 28 Sep 2016 18:58:28 +0300 Subject: [PATCH 2/5] FIX DEPRECATION Warnings --- Gemfile | 12 ++- Gemfile.lock | 56 ++++++----- app/controllers/.test_runs_controller.rb.swo | Bin 20480 -> 20480 bytes app/controllers/admin_controller.rb | 6 +- app/controllers/api/v1/projects_controller.rb | 4 +- .../api/v1/test_jobs_controller.rb | 4 +- app/controllers/application_controller.rb | 8 +- app/controllers/dashboard_controller.rb | 4 +- app/controllers/oauth_controller.rb | 4 +- app/controllers/project_files_controller.rb | 4 +- .../project_participations_controller.rb | 6 +- app/controllers/project_wizard_controller.rb | 2 +- app/controllers/projects_controller.rb | 6 +- app/controllers/test_jobs_controller.rb | 3 +- app/controllers/test_runs_controller.rb | 17 ++-- .../user_invitations_controller.rb | 6 +- .../users_api/v1/commits_controller.rb | 6 +- app/controllers/webhooks_controller.rb | 4 +- app/controllers/worker_groups_controller.rb | 8 +- app/models/test_job.rb | 2 +- app/models/test_run.rb | 2 +- config/application.rb | 3 - config/cable.yml | 9 ++ config/environments/production.rb | 2 +- config/environments/test.rb | 5 +- .../application_controller_renderer.rb | 6 ++ config/initializers/new_framework_defaults.rb | 23 +++++ config/spring.rb | 6 ++ db/schema.rb | 58 ++++------- lib/tasks/test.rake | 5 +- test/controllers/admin_controller_test.rb | 8 +- .../api/v1/projects_controller_test.rb | 17 ++-- .../api/v1/test_jobs_controller_test.rb | 51 ++++++---- test/controllers/dashboard_controller_test.rb | 10 +- .../email_submissions_controller_test.rb | 4 +- .../feedback_submissions_controller_test.rb | 15 +-- .../live_updates_controller_test.rb | 4 +- .../project_files_controller_test.rb | 26 ++--- .../project_participations_controller_test.rb | 32 +++--- .../project_wizard_controller_test.rb | 66 ++++++------ test/controllers/projects_controller_test.rb | 48 ++++----- test/controllers/settings_controller_test.rb | 16 +-- test/controllers/test_runs_controller_test.rb | 95 ++++++++++++------ .../tracked_branches_controller_test.rb | 30 +++--- .../user_invitations_controller_test.rb | 26 ++--- .../users_api/v1/commits_controller_test.rb | 34 ++++--- .../users_api/v1/users_controller_test.rb | 7 +- test/controllers/webhooks_controller_test.rb | 22 ++-- .../worker_groups_controller_test.rb | 57 +++++------ test/test_helper.rb | 4 +- 50 files changed, 483 insertions(+), 370 deletions(-) create mode 100644 config/cable.yml create mode 100644 config/initializers/application_controller_renderer.rb create mode 100644 config/initializers/new_framework_defaults.rb create mode 100644 config/spring.rb diff --git a/Gemfile b/Gemfile index f9e7701f..3f99cc96 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ gem 'wicked' gem 'sidekiq' gem 'sinatra', require: false gem 'select2-rails' -gem 'draper' +gem 'draper', github: 'drapergem/draper', ref: '957507f' gem 'bootstrap-sass' gem 'bootstrap-social-rails' gem 'font-awesome-rails' @@ -50,7 +50,7 @@ gem 'attr_encrypted' gem 'doorkeeper', '~>3.1.0' gem 'oauth2' gem 'omniauth-github' -gem 'active_model_serializers', github: 'rails-api/active_model_serializers', ref: '1f0886' # 0.10 rc version +gem 'active_model_serializers', github: 'rails-api/active_model_serializers', ref: 'b41df13' # 0.10.2 version gem 'simple_form' gem 'actionview-encoded_mail_to' gem 'fog-aws' @@ -68,7 +68,6 @@ group :production do end group :test do - gem 'test_after_commit' gem 'factory_girl_rails' gem 'capybara' gem 'poltergeist' @@ -83,13 +82,16 @@ group :test do gem 'timecop' end +group :development do + # Access an IRB console on exception pages or by using <%= console %> in views + gem 'web-console', '~> 3.0' +end + group :development, :test do gem 'byebug' # Call 'binding.pry' anywhere in the code to stop execution and get a debugger console gem 'pry-rails' gem 'pry-nav' - # Access an IRB console on exception pages or by using <%= console %> in views - gem 'web-console', '~> 2.0' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' diff --git a/Gemfile.lock b/Gemfile.lock index e83a0bd6..59a39292 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,15 @@ +GIT + remote: git://github.com/drapergem/draper.git + revision: 957507ff81d960dad2ae35ca8a8c727ce6e02996 + ref: 957507f + specs: + draper (3.0.0.pre1) + actionpack (~> 5.0) + activemodel (~> 5.0) + activemodel-serializers-xml (~> 1.0) + activesupport (~> 5.0) + request_store (~> 1.0) + GIT remote: git://github.com/ispyropoulos/bitbucket.git revision: 0a16cf6bbe05d293f954960b329b06e370b4f82b @@ -13,13 +25,14 @@ GIT GIT remote: git://github.com/rails-api/active_model_serializers.git - revision: 1f08865a10bb06648efc170768c8c9937d441f45 - ref: 1f0886 + revision: b41df1334140c19b7864d6679449d3f013457949 + ref: b41df13 specs: - active_model_serializers (0.10.0.rc3) - actionpack (>= 4.0) - activemodel (>= 4.0) - railties (>= 4.0) + active_model_serializers (0.10.2) + actionpack (>= 4.1, < 6) + activemodel (>= 4.1, < 6) + jsonapi (~> 0.1.1.beta2) + railties (>= 4.1, < 6) GEM remote: https://rubygems.org/ @@ -54,6 +67,11 @@ GEM globalid (>= 0.3.6) activemodel (5.0.0.1) activesupport (= 5.0.0.1) + activemodel-serializers-xml (1.0.1) + activemodel (> 5.x) + activerecord (> 5.x) + activesupport (> 5.x) + builder (~> 3.1) activerecord (5.0.0.1) activemodel (= 5.0.0.1) activesupport (= 5.0.0.1) @@ -76,8 +94,6 @@ GEM babel-source (>= 4.0, < 6) execjs (~> 2.0) bcrypt (3.1.11) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) bootstrap-sass (3.3.7) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) @@ -116,11 +132,6 @@ GEM warden (~> 1.2.3) doorkeeper (3.1.0) railties (>= 3.2) - draper (2.1.0) - actionpack (>= 3.0) - activemodel (>= 3.0) - activesupport (>= 3.0) - request_store (~> 1.0) encryptor (3.0.0) erubis (2.7.0) exception_notification (4.2.1) @@ -186,6 +197,8 @@ GEM jquery-ui-rails (5.0.5) railties (>= 3.2.16) json (1.8.3) + jsonapi (0.1.1.beta2) + json (~> 1.8) jwt (1.5.6) loofah (2.0.3) nokogiri (>= 1.5.9) @@ -362,8 +375,6 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) sshkey (1.8.0) - test_after_commit (1.1.0) - activerecord (>= 3.2) thor (0.19.1) thread_safe (0.3.5) tilt (2.0.5) @@ -376,11 +387,11 @@ GEM vcr (3.0.3) 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) + web-console (3.3.1) + actionview (>= 5.0) + activemodel (>= 5.0) + debug_inspector + railties (>= 5.0) webmock (2.1.0) addressable (>= 2.3.6) crack (>= 0.3.2) @@ -412,7 +423,7 @@ DEPENDENCIES database_cleaner devise doorkeeper (~> 3.1.0) - draper + draper! exception_notification (~> 4.2.1) factory_girl_rails fog-aws @@ -457,12 +468,11 @@ DEPENDENCIES slack-notifier spring sshkey - test_after_commit timecop uglifier (>= 1.3.0) underscore-rails vcr - web-console (~> 2.0) + web-console (~> 3.0) webmock wicked diff --git a/app/controllers/.test_runs_controller.rb.swo b/app/controllers/.test_runs_controller.rb.swo index e05fa2e3bfc622dc9435ef795804cb74670cb9b9..4dae90d387ae78517dd938a9033bbaf381d34407 100644 GIT binary patch delta 21 ccmZozz}T>WaYMX5TViraW`5r0RQ=fs09gG92LJ#7 delta 21 ccmZozz}T>WaYMX5TUusLNovvNRQ=fs09jH94*&oF diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 4a6da363..35c12822 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,9 +1,9 @@ class AdminController < ApplicationController - before_filter :authenticate_user! - before_filter :authenticate_admin + before_action :authenticate_user! + before_action :authenticate_admin def become - sign_in(:user, User.find(params[:id]), bypass: true) # do not update last_sign_in + bypass_sign_in(User.find(params[:id])) # do not update last_sign_in redirect_to root_url # or user_root_url end diff --git a/app/controllers/api/v1/projects_controller.rb b/app/controllers/api/v1/projects_controller.rb index 790a78fa..86d12200 100644 --- a/app/controllers/api/v1/projects_controller.rb +++ b/app/controllers/api/v1/projects_controller.rb @@ -11,9 +11,9 @@ class ProjectsController < ApiController def setup_data render json: { current_project: - ActiveModel::SerializableResource.new(current_project), + ActiveModelSerializers::SerializableResource.new(current_project), current_worker_group: - ActiveModel::SerializableResource.new(current_worker_group) + ActiveModelSerializers::SerializableResource.new(current_worker_group) } end diff --git a/app/controllers/api/v1/test_jobs_controller.rb b/app/controllers/api/v1/test_jobs_controller.rb index 0f5da515..93222d10 100644 --- a/app/controllers/api/v1/test_jobs_controller.rb +++ b/app/controllers/api/v1/test_jobs_controller.rb @@ -31,7 +31,7 @@ def bind_next_batch def batch_update test_run_ids = [] - jobs = params[:jobs].map do |id, json| + jobs = params.require(:jobs).to_unsafe_hash.map do |id, json| if (test_run_id_for_setup = id.to_s.match(/^setup_job_(\d+)$/).try(:[], 1)) test_run_ids << test_run_id_for_setup.to_i handle_test_run_setup(test_run_id_for_setup.to_i, json) @@ -41,7 +41,7 @@ def batch_update end end.compact jobs = Hash[jobs] - job_ids = params[:jobs].keys + job_ids = params.require(:jobs).keys test_run_ids += jobs.values.map{|j| j["test_run_id"].to_i}.uniq # Store the TestRun ids of any missing or cancelled TestRuns to let diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0f0ba146..6d791272 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,8 +3,8 @@ class ApplicationController < ActionController::Base # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception - before_filter :set_redirect_url_in_cookie - before_filter :exception_notification_additional_data + before_action :set_redirect_url_in_cookie + before_action :exception_notification_additional_data layout :choose_layout @@ -34,6 +34,10 @@ def current_ability render 'errors/access_denied', status: 403, layout: 'bare' end + def redirect_back_fallback_path + "/" + end + protected def set_redirect_url_in_cookie diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index be716b64..be00ada0 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,10 +1,10 @@ class DashboardController < ApplicationController layout "dashboard" - before_filter :authenticate_user! + before_action :authenticate_user! # Skip setting the redirect_url in cookies in order to avoid redirecting the # user to this intermediate warning page, after returning from the provider's # authorization flow. - skip_before_filter :set_redirect_url_in_cookie, + skip_before_action :set_redirect_url_in_cookie, only: [:github_authorization_required, :bitbucket_authorization_required] rescue_from Octokit::Unauthorized do |exception| diff --git a/app/controllers/oauth_controller.rb b/app/controllers/oauth_controller.rb index 7c47c727..ce1b5f1f 100644 --- a/app/controllers/oauth_controller.rb +++ b/app/controllers/oauth_controller.rb @@ -1,6 +1,6 @@ class OauthController < ApplicationController - before_filter :authenticate_user! - skip_filter :set_redirect_url_in_cookie + before_action :authenticate_user! + skip_before_action :set_redirect_url_in_cookie include ApplicationHelper def github_callback diff --git a/app/controllers/project_files_controller.rb b/app/controllers/project_files_controller.rb index d68461f8..897a93bb 100644 --- a/app/controllers/project_files_controller.rb +++ b/app/controllers/project_files_controller.rb @@ -27,7 +27,7 @@ def create flash[:alert] = file.errors.messages.values.join(', ') end - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end def show @@ -53,7 +53,7 @@ def update flash[:alert] = @project_file.errors.messages.values.join(', ') end - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end private diff --git a/app/controllers/project_participations_controller.rb b/app/controllers/project_participations_controller.rb index 5854d294..f1c46fb4 100644 --- a/app/controllers/project_participations_controller.rb +++ b/app/controllers/project_participations_controller.rb @@ -17,11 +17,11 @@ def destroy redirect_to root_path else flash[:notice] = "User is no longer a member of this project" - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end else flash[:alert] = @participation.errors.full_messages.to_sentence - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end end @@ -32,7 +32,7 @@ def update flash[:alert] = @participation.errors.full_messages.to_sentence end - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end private diff --git a/app/controllers/project_wizard_controller.rb b/app/controllers/project_wizard_controller.rb index 67040d27..4c140f6e 100644 --- a/app/controllers/project_wizard_controller.rb +++ b/app/controllers/project_wizard_controller.rb @@ -75,7 +75,7 @@ def update redirect_to next_wizard_path else flash[:alert] = testributor_yml.errors.full_messages.to_sentence - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end when :add_worker unless @project.present? diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 99c947a0..f24d41a4 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -3,7 +3,7 @@ class ProjectsController < DashboardController include Controllers::EnsureProject # skip devise method - skip_before_filter :authenticate_user!, :only => [:show, :status] + skip_before_action :authenticate_user!, :only => [:show, :status] before_action :authorize_resource! def show @@ -43,7 +43,7 @@ def update fmt.html do flash[:notice] = notice flash[:alert] = alert - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end end end @@ -75,7 +75,7 @@ def toggle_private current_project.is_private = !current_project.is_private if current_project.save flash[:notice] = "Your project is now #{ current_project.is_private? ? 'private' : 'public'}." - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end end diff --git a/app/controllers/test_jobs_controller.rb b/app/controllers/test_jobs_controller.rb index d82e1aef..f5f53263 100644 --- a/app/controllers/test_jobs_controller.rb +++ b/app/controllers/test_jobs_controller.rb @@ -10,7 +10,8 @@ def retry if request.xhr? head :ok and return else - redirect_to :back, notice: 'Test job was successfully updated.' + redirect_back(fallback_location: redirect_back_fallback_path, + notice: 'Test job was successfully updated.') end end diff --git a/app/controllers/test_runs_controller.rb b/app/controllers/test_runs_controller.rb index ea547d19..ac935e59 100644 --- a/app/controllers/test_runs_controller.rb +++ b/app/controllers/test_runs_controller.rb @@ -2,7 +2,7 @@ class TestRunsController < DashboardController include Controllers::EnsureProject # skip devise method - skip_before_filter :authenticate_user!, :only => [:show, :index] + skip_before_action :authenticate_user!, :only => [:show, :index] before_action :set_test_run, only: [:show, :update, :destroy, :retry] before_action :authorize_resource! @@ -58,18 +58,18 @@ def create if test_run head :ok and return if request.xhr? flash[:notice] = 'Your build is being setup' - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) else head :ok and return if request.xhr? flash[:alert] = manager.errors.join(', ') - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end end def update if @test_run.update(test_run_params) head :ok and return if request.xhr? - redirect_to :back, notice: 'Test run was successfully updated.' + redirect_back(fallback_location: redirect_back_fallback_path) else head 422 and return if request.xhr? render :edit @@ -78,7 +78,8 @@ def update def retry unless @test_run.retry? - return redirect_to :back, alert: "Retrying ##{@test_run.id} test run is not allowed at this time" + redirect_back(fallback_location: redirect_back_fallback_path, + alert: "Retrying ##{@test_run.id} test run is not allowed at this time") end # TODO: Consider delete_all here or a custom retry method on TestRun @@ -98,7 +99,8 @@ def retry }) head :ok and return if request.xhr? - redirect_to :back, notice: 'The Build will soon be retried' + redirect_back(fallback_location: redirect_back_fallback_path, + notice: 'The build will soon be retried') end def destroy @@ -106,7 +108,8 @@ def destroy @test_run.destroy - redirect_to :back, notice: 'Test run was successfully cancelled.' + redirect_back(fallback_location: redirect_back_fallback_path, + notice: 'Test run was successfully cancelled.') end private diff --git a/app/controllers/user_invitations_controller.rb b/app/controllers/user_invitations_controller.rb index 048f3d2f..5693dda0 100644 --- a/app/controllers/user_invitations_controller.rb +++ b/app/controllers/user_invitations_controller.rb @@ -21,7 +21,7 @@ def create flash[:alert] = @invitation.errors.full_messages.to_sentence end - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end def destroy @@ -33,7 +33,7 @@ def destroy flash[:alert] = invitation.errors.full_messages.to_sentence end - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end # GET invitations/accept?token=12312312 @@ -64,7 +64,7 @@ def resend invitation.queue_email flash[:notice] = "Invitation will be sent shortly" - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end private diff --git a/app/controllers/users_api/v1/commits_controller.rb b/app/controllers/users_api/v1/commits_controller.rb index cfbd1396..c0c1e250 100644 --- a/app/controllers/users_api/v1/commits_controller.rb +++ b/app/controllers/users_api/v1/commits_controller.rb @@ -3,7 +3,7 @@ module V1 class CommitsController < UsersApiController def status unless params[:id].length >= 6 - render text: "Specify a commit hash with at least the first 6 characters", + render plain: "Specify a commit hash with at least the first 6 characters", status: :bad_request return end @@ -12,7 +12,7 @@ def status current_user.participating_projects.find_by(name: params[:project]) unless project - render text: "Project with name '#{params[:project]}' does not exist", + render plain: "Project with name '#{params[:project]}' does not exist", status: :not_found return end @@ -22,7 +22,7 @@ def status order("created_at DESC").first unless test_run - render text: "No Build found for the specified commit", status: 404 + render plain: "No Build found for the specified commit", status: 404 return end diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rb index 526f81ee..3a2e36ce 100644 --- a/app/controllers/webhooks_controller.rb +++ b/app/controllers/webhooks_controller.rb @@ -1,7 +1,7 @@ class WebhooksController < ApplicationController skip_before_action :verify_authenticity_token, only: [:github, :bitbucket] - skip_filter :set_redirect_url_in_cookie - before_filter :verify_request_from_github!, only: :github + skip_before_action :set_redirect_url_in_cookie + before_action :verify_request_from_github!, only: :github def github # We listen for 'push' and 'delete' events diff --git a/app/controllers/worker_groups_controller.rb b/app/controllers/worker_groups_controller.rb index 7e21d732..c1929161 100644 --- a/app/controllers/worker_groups_controller.rb +++ b/app/controllers/worker_groups_controller.rb @@ -20,7 +20,7 @@ def create flash[:notice] = "A Worker Group has been created." end - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end def update @@ -32,14 +32,14 @@ def update flash[:notice] = "Successfully updated worker group" end - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end def destroy current_project.destroy_oauth_application!(@worker_group.oauth_application_id) flash[:notice] = "The Worker Group was deleted." - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end def reset_ssh_key @@ -49,7 +49,7 @@ def reset_ssh_key "The SSH key for the \"#{@worker_group.friendly_name}\" "\ "Worker Group is now reset." - redirect_to :back + redirect_back(fallback_location: redirect_back_fallback_path) end private diff --git a/app/models/test_job.rb b/app/models/test_job.rb index dcb6da82..9db2b1f6 100644 --- a/app/models/test_job.rb +++ b/app/models/test_job.rb @@ -67,7 +67,7 @@ def total_running_time end def serialized_job - ActiveModel::SerializableResource.new( + ActiveModelSerializers::SerializableResource.new( self, serializer: InternalTestJobsSerializer).serializable_hash end diff --git a/app/models/test_run.rb b/app/models/test_run.rb index d7981acc..009e9354 100644 --- a/app/models/test_run.rb +++ b/app/models/test_run.rb @@ -41,7 +41,7 @@ def total_running_time end def serialized_run - ActiveModel::SerializableResource.new( + ActiveModelSerializers::SerializableResource.new( self, serializer: InternalTestRunsSerializer).serializable_hash end diff --git a/config/application.rb b/config/application.rb index 3c96a6eb..84062c40 100644 --- a/config/application.rb +++ b/config/application.rb @@ -30,9 +30,6 @@ class Application < Rails::Application # 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.active_job.queue_adapter = :sidekiq config.exceptions_app = self.routes config.react.addons = true diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 00000000..0bbde6f7 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,9 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 diff --git a/config/environments/production.rb b/config/environments/production.rb index 1066dfac..17ac9049 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -31,7 +31,7 @@ # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier diff --git a/config/environments/test.rb b/config/environments/test.rb index 008308d4..95bbf1be 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -13,8 +13,9 @@ 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' } # Show full error reports and disable caching. config.consider_all_requests_local = true diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 00000000..51639b67 --- /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/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb new file mode 100644 index 00000000..f6e72335 --- /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/spring.rb b/config/spring.rb new file mode 100644 index 00000000..c9119b40 --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w( + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +).each { |path| Spring.watch(path) } diff --git a/db/schema.rb b/db/schema.rb index d9b43c69..5e0354dc 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. @@ -24,11 +23,10 @@ t.integer "notify_on", default: 0, null: false t.datetime "created_at" t.datetime "updated_at" + t.index ["project_participation_id"], name: "index_branch_notification_settings_on_project_participation_id", using: :btree + t.index ["tracked_branch_id"], name: "index_branch_notification_settings_on_tracked_branch_id", using: :btree end - add_index "branch_notification_settings", ["project_participation_id"], name: "index_branch_notification_settings_on_project_participation_id", using: :btree - add_index "branch_notification_settings", ["tracked_branch_id"], name: "index_branch_notification_settings_on_tracked_branch_id", using: :btree - create_table "docker_images", force: :cascade do |t| t.string "public_name", default: "", null: false t.string "hub_image", default: "", null: false @@ -48,10 +46,9 @@ t.text "body" t.integer "rating" t.integer "user_id" + t.index ["user_id"], name: "index_feedback_submissions_on_user_id", using: :btree end - add_index "feedback_submissions", ["user_id"], name: "index_feedback_submissions_on_user_id", using: :btree - create_table "oauth_access_grants", force: :cascade do |t| t.integer "resource_owner_id", null: false t.integer "application_id", null: false @@ -61,10 +58,9 @@ 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" @@ -74,12 +70,11 @@ 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 @@ -90,11 +85,10 @@ 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 "project_files", force: :cascade do |t| t.integer "project_id" t.string "path", null: false @@ -121,11 +115,10 @@ t.boolean "auto_track_branches", default: true, null: false t.string "repository_url" t.text "custom_docker_compose_yml", default: "", null: false + t.index ["user_id", "repository_provider", "repository_id"], name: "index_projects_on_user_and_provider_and_repository_id", unique: true, using: :btree + t.index ["user_id"], name: "index_projects_on_user_id", using: :btree end - add_index "projects", ["user_id", "repository_provider", "repository_id"], name: "index_projects_on_user_and_provider_and_repository_id", unique: true, using: :btree - add_index "projects", ["user_id"], name: "index_projects_on_user_id", using: :btree - create_table "projects_users", force: :cascade do |t| t.integer "user_id" t.integer "project_id" @@ -134,22 +127,20 @@ t.integer "new_branch_notify_on", default: 0, null: false t.integer "my_builds_notify_on", default: 1, null: false t.integer "others_builds_notify_on", default: 1, null: false + t.index ["project_id"], name: "index_projects_users_on_project_id", using: :btree + t.index ["user_id"], name: "index_projects_users_on_user_id", using: :btree end - add_index "projects_users", ["project_id"], name: "index_projects_users_on_project_id", using: :btree - add_index "projects_users", ["user_id"], name: "index_projects_users_on_user_id", using: :btree - create_table "technology_selections", force: :cascade do |t| t.integer "project_id" t.integer "docker_image_id" t.string "version" t.datetime "created_at" t.datetime "updated_at" + t.index ["docker_image_id"], name: "index_technology_selections_on_docker_image_id", using: :btree + t.index ["project_id"], name: "index_technology_selections_on_project_id", using: :btree end - add_index "technology_selections", ["docker_image_id"], name: "index_technology_selections_on_docker_image_id", using: :btree - add_index "technology_selections", ["project_id"], name: "index_technology_selections_on_project_id", using: :btree - create_table "test_jobs", force: :cascade do |t| t.integer "test_run_id" t.string "command", default: "", null: false @@ -199,20 +190,18 @@ t.string "commit_committer_photo_url", default: "", null: false t.integer "initiator_id" t.string "setup_worker_uuid" + t.index ["tracked_branch_id"], name: "index_test_runs_on_tracked_branch_id", using: :btree end - add_index "test_runs", ["tracked_branch_id"], name: "index_test_runs_on_tracked_branch_id", using: :btree - create_table "tracked_branches", force: :cascade do |t| t.integer "project_id", null: false t.string "branch_name" t.datetime "created_at" t.datetime "updated_at" + t.index ["project_id", "branch_name"], name: "index_tracked_branches_on_project_id_and_branch_name", unique: true, using: :btree + t.index ["project_id"], name: "index_tracked_branches_on_project_id", using: :btree end - add_index "tracked_branches", ["project_id", "branch_name"], name: "index_tracked_branches_on_project_id_and_branch_name", unique: true, using: :btree - add_index "tracked_branches", ["project_id"], name: "index_tracked_branches_on_project_id", using: :btree - create_table "user_invitations", force: :cascade do |t| t.string "token", default: "", null: false t.integer "project_id", null: false @@ -221,10 +210,9 @@ t.datetime "accepted_at" t.datetime "created_at" t.datetime "updated_at" + t.index ["project_id"], name: "index_user_invitations_on_project_id", using: :btree end - add_index "user_invitations", ["project_id"], name: "index_user_invitations_on_project_id", using: :btree - create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false @@ -255,11 +243,10 @@ t.string "encrypted_bitbucket_access_token_secret" t.string "encrypted_bitbucket_access_token_secret_salt" t.string "encrypted_bitbucket_access_token_secret_iv" + 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", ["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 - create_table "worker_groups", force: :cascade do |t| t.integer "oauth_application_id", null: false t.string "friendly_name" @@ -269,8 +256,7 @@ t.text "ssh_key_public" t.integer "ssh_key_provider_reference_id" t.integer "project_id", null: false + t.index ["oauth_application_id"], name: "index_worker_groups_on_oauth_application_id", using: :btree end - add_index "worker_groups", ["oauth_application_id"], name: "index_worker_groups_on_oauth_application_id", using: :btree - end diff --git a/lib/tasks/test.rake b/lib/tasks/test.rake index 03ae6801..0432254d 100644 --- a/lib/tasks/test.rake +++ b/lib/tasks/test.rake @@ -1,6 +1,9 @@ # https://github.com/metaskills/minitest-spec-rails/issues/49 +# The recommended way of using Rails::TestTask doesn't work on rails 5 namespace :test do - Rails::TestTask.new("features" => "test:prepare") do |t| + Rake::TestTask.new("features" => "test:prepare") do |t| + t.libs = ['lib', 'test'] t.pattern = "test/features/**/*_test.rb" + t.verbose = true end end diff --git a/test/controllers/admin_controller_test.rb b/test/controllers/admin_controller_test.rb index e40faa01..ebcfc5e0 100644 --- a/test/controllers/admin_controller_test.rb +++ b/test/controllers/admin_controller_test.rb @@ -5,10 +5,10 @@ class AdminControllerTest < ActionController::TestCase describe "when user is not admin" do let(:user) { FactoryGirl.create(:user, admin: false) } let(:other_user) { FactoryGirl.create(:user, admin: false) } - before { sign_in :user, user } + before { sign_in user, scope: :user } it "returns 401" do - get :become, id: other_user.id + get :become, params: { id: other_user.id } response.status.must_equal 401 end @@ -18,10 +18,10 @@ class AdminControllerTest < ActionController::TestCase let(:admin_user) { FactoryGirl.create(:user, admin: true) } let(:other_user) { FactoryGirl.create(:user, admin: false) } - before { sign_in :user, admin_user } + before { sign_in admin_user, scope: :user } it "changes the logged user" do - get :become, id: other_user.id + get :become, params: { id: other_user.id } response.status.must_equal 302 session["warden.user.user.key"].first.first.must_equal other_user.id end diff --git a/test/controllers/api/v1/projects_controller_test.rb b/test/controllers/api/v1/projects_controller_test.rb index 7a818fac..667318ef 100644 --- a/test/controllers/api/v1/projects_controller_test.rb +++ b/test/controllers/api/v1/projects_controller_test.rb @@ -23,16 +23,16 @@ class Api::V1::ProjectsControllerTest < ActionController::TestCase end it "returns 401 unauthorized when token owner is a User (and current_project does not exist)" do - get :setup_data, access_token: user_token.token, - default: { format: :json } + get :setup_data, params: { access_token: user_token.token , + default: { format: 'json' } } response.status.must_equal 401 end end describe "GET#setup_data" do it "returns the current project with project_files included" do - get :setup_data, access_token: token.token, - default: { format: :json } + get :setup_data, params: { access_token: token.token, + default: { format: 'json' } } result = JSON.parse(response.body)['current_project'] files = result["files"] @@ -52,7 +52,8 @@ class Api::V1::ProjectsControllerTest < ActionController::TestCase point_in_time = Time.current Timecop.freeze(point_in_time) do request.env['HTTP_WORKER_UUID'] = '123' - get :setup_data, access_token: token.token, default: { format: :json } + get :setup_data, params: { access_token: token.token, + default: { format: 'json' } } project.active_workers.count.must_equal 0 end @@ -62,12 +63,14 @@ class Api::V1::ProjectsControllerTest < ActionController::TestCase point_in_time = Time.current Timecop.freeze(point_in_time) do request.env['HTTP_WORKER_UUID'] = '123' - post :beacon, access_token: token.token, default: { format: :json } + post :beacon, params: { access_token: token.token, + default: { format: 'json' } } project.active_workers.count.must_equal 1 request.env['HTTP_WORKER_UUID'] = '124' - post :beacon, access_token: token.token, default: { format: :json } + post :beacon, params: { access_token: token.token, + default: { format: 'json' } } project.active_workers.count.must_equal 2 end diff --git a/test/controllers/api/v1/test_jobs_controller_test.rb b/test/controllers/api/v1/test_jobs_controller_test.rb index 96f9a771..613166c5 100644 --- a/test/controllers/api/v1/test_jobs_controller_test.rb +++ b/test/controllers/api/v1/test_jobs_controller_test.rb @@ -29,7 +29,7 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase @controller.stub :doorkeeper_token, token do # the request will also make this worker active request.env['HTTP_WORKER_UUID'] = 'alive_worker_uuid' - patch :bind_next_batch, default: { format: :json } + patch :bind_next_batch, params: { default: { format: 'json' } } result = JSON.parse(response.body) result.count.must_equal 1 result.first["command"].must_equal _test_jobs[-1].command @@ -49,7 +49,7 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase @controller.stub :doorkeeper_token, token do # the request will also make this worker active request.env['HTTP_WORKER_UUID'] = 'alive_worker_uuid' - patch :bind_next_batch, default: { format: :json } + patch :bind_next_batch, params: { default: { format: 'json' } } result = JSON.parse(response.body) result.count.must_equal 3 _test_jobs[0..-2].each(&:reload).map(&:worker_uuid).uniq. @@ -63,7 +63,7 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase _test_jobs[0..-2].each{|f| f.update_column(:status, TestStatus::RUNNING)} @controller.stub :doorkeeper_token, token do request.env['HTTP_WORKER_UUID'] = 'this_is_a_worker_uuid' - patch :bind_next_batch, default: { format: :json } + patch :bind_next_batch, params: { default: { format: 'json' } } result = JSON.parse(response.body) _test_jobs.each(&:reload).map(&:worker_uuid).compact.uniq. must_equal ['this_is_a_worker_uuid'] @@ -82,7 +82,7 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase terminal_state_test_run.update_column(:status, TestStatus::PASSED) @controller.stub :doorkeeper_token, token do - patch :bind_next_batch, default: { format: :json } + patch :bind_next_batch, params: { default: { format: 'json' } } result = JSON.parse(response.body) result.count.must_equal 4 end @@ -107,7 +107,7 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase @controller.stub :doorkeeper_token, token do # the request will also make this worker active request.env['HTTP_WORKER_UUID'] = 'alive_worker_uuid' - patch :bind_next_batch, default: { format: :json } + patch :bind_next_batch, params: { default: { format: 'json' } } result = JSON.parse(response.body) result.map{|r| r["id"]}.wont_include irrelevant_test_job.id result.count.must_equal 4 @@ -118,7 +118,7 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase it "returns the cost_prediction for each job" do TestJob.update_all(old_avg_worker_command_run_seconds: 2) @controller.stub :doorkeeper_token, token do - patch :bind_next_batch, default: { format: :json } + patch :bind_next_batch, params: { default: { format: 'json' } } result = JSON.parse(response.body) result.count.must_equal 4 result.map{|j| j["cost_prediction"].to_i}.must_equal [2,2,2,2] @@ -147,7 +147,7 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase result = nil @controller.stub :doorkeeper_token, token do request.env['HTTP_WORKER_UUID'] = 'alive_worker_uuid' - patch :bind_next_batch, default: { format: :json } + patch :bind_next_batch, params: { default: { format: 'json' } } result = JSON.parse(response.body) end @@ -172,7 +172,7 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase result = nil @controller.stub :doorkeeper_token, token do request.env['HTTP_WORKER_UUID'] = 'alive_worker_uuid' - patch :bind_next_batch, default: { format: :json } + patch :bind_next_batch, params: { default: { format: 'json' } } result = JSON.parse(response.body) end @@ -206,8 +206,9 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase it "does not update sent_at if already set" do @controller.stub :doorkeeper_token, token do - patch :batch_update, default: { format: :json }, - jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] + patch :batch_update, + params: { default: { format: 'json' }, + jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] } end _test_jobs.last.reload.sent_at.must_equal Date.new(2015, 01,01).beginning_of_day @@ -215,8 +216,9 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase it "does not update worker_in_queue_seconds if already set" do @controller.stub :doorkeeper_token, token do - patch :batch_update, default: { format: :json }, - jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] + patch :batch_update, + params: { default: { format: 'json' }, + jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] } end _test_jobs.last.reload.worker_in_queue_seconds.must_equal 10 @@ -230,16 +232,18 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase ).times(9) @controller.stub :doorkeeper_token, token do - patch :batch_update, default: { format: :json }, - jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] + patch :batch_update, + params: { default: { format: 'json' }, + jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] } end end it "does not update worker_command_run_seconds if already set" do @controller.stub :doorkeeper_token, token do - patch :batch_update, default: { format: :json }, - jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] + patch :batch_update, + params: { default: { format: 'json' }, + jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] } end _test_jobs.last.reload.worker_command_run_seconds.must_equal 10 @@ -247,8 +251,9 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase it "does not update reported_at if already set" do @controller.stub :doorkeeper_token, token do - patch :batch_update, default: { format: :json }, - jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] + patch :batch_update, + params: { default: { format: 'json' }, + jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] } end _test_jobs.last.reload.reported_at.to_i.must_equal report_time.to_i @@ -261,8 +266,9 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase result: '') } @controller.stub :doorkeeper_token, token do request.env['HTTP_WORKER_UUID'] = 'this_is_another_worker_uuid' - patch :batch_update, default: { format: :json }, - jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] + patch :batch_update, + params: { default: { format: 'json' }, + jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] } end _test_jobs.map(&:reload).map(&:result).uniq.must_equal [''] end @@ -272,8 +278,9 @@ class Api::V1::TestJobsControllerTest < ActionController::TestCase result: '') } @controller.stub :doorkeeper_token, token do request.env['HTTP_WORKER_UUID'] = 'the_original_uuid' - patch :batch_update, default: { format: :json }, - jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] + patch :batch_update, + params: { default: { format: 'json' }, + jobs: Hash[_test_jobs.map{|j| [j.id, _test_job_json]}] } end _test_jobs.map(&:reload).map(&:result).uniq.must_equal ['result'] end diff --git a/test/controllers/dashboard_controller_test.rb b/test/controllers/dashboard_controller_test.rb index f1e9cd5a..0ccae9d2 100644 --- a/test/controllers/dashboard_controller_test.rb +++ b/test/controllers/dashboard_controller_test.rb @@ -9,21 +9,21 @@ class DashboardControllerTest < ActionController::TestCase describe "when user has a project" do before do project - sign_in :user, user_with_project + sign_in user_with_project, scope: :user end it "returns 200" do - get :index, id: user_with_project.id + get :index, params: { id: user_with_project.id } response.status.must_equal 200 end end describe "when user has no project" do - before { sign_in :user, user_without_project } + before { sign_in user_without_project, scope: :user } it "returns 302" do - get :index, id: user_without_project.id + get :index, params: { id: user_without_project.id } response.status.must_equal 302 end @@ -34,7 +34,7 @@ class DashboardControllerTest < ActionController::TestCase end it "flashes an error and does not redirect" do - get :index, id: user_without_project.id + get :index, params: { id: user_without_project.id } flash[:alert].must_equal("You can't create any projects. Contact us if you think this is a mistake.") response.status.must_equal 200 diff --git a/test/controllers/email_submissions_controller_test.rb b/test/controllers/email_submissions_controller_test.rb index dc33d326..9e91d29e 100644 --- a/test/controllers/email_submissions_controller_test.rb +++ b/test/controllers/email_submissions_controller_test.rb @@ -4,14 +4,14 @@ class EmailSubmissionsControllerTest < ActionController::TestCase describe "#create" do let(:email) { 'pakallis@gmail.com' } it "creates EmailSubmission if valid" do - xhr :post, :create, { email_submission: { email: email } } + post :create, xhr: true, params: { email_submission: { email: email } } assert_response :ok EmailSubmission.last.email.must_equal email end it "doesn't create EmailSubmission if invalid" do - xhr :post, :create, { email_submission: { email: 'invalid_email' } } + post :create, xhr: true, params: { email_submission: { email: 'invalid_email' } } assert_response :unprocessable_entity EmailSubmission.last.must_equal nil diff --git a/test/controllers/feedback_submissions_controller_test.rb b/test/controllers/feedback_submissions_controller_test.rb index b8eef4cf..71e59657 100644 --- a/test/controllers/feedback_submissions_controller_test.rb +++ b/test/controllers/feedback_submissions_controller_test.rb @@ -8,12 +8,13 @@ class FeedbackSubmissionsControllerTest < ActionController::TestCase let(:rating) { 1 } before do - sign_in :user, user + sign_in user, scope: :user end it "creates FeedbackSubmission if valid" do - xhr :post, :create, - { feedback_submission: { category: category, body: body, rating: rating } } + post :create, xhr: true, + params: { feedback_submission: + { category: category, body: body, rating: rating } } assert_response :ok @@ -25,8 +26,9 @@ class FeedbackSubmissionsControllerTest < ActionController::TestCase end it "sends e-mail if valid" do - xhr :post, :create, - { feedback_submission: { category: category, body: body, rating: rating } } + post :create, xhr: true, + params: { feedback_submission: + { category: category, body: body, rating: rating } } assert_response :ok @@ -34,7 +36,8 @@ class FeedbackSubmissionsControllerTest < ActionController::TestCase end it "doesn't create FeedbackSubmission if invalid" do - xhr :post, :create, { feedback_submission: { category: category, body: '' } } + post :create, xhr: true, + params: { feedback_submission: { category: category, body: '' } } assert_response :unprocessable_entity FeedbackSubmission.last.must_equal nil diff --git a/test/controllers/live_updates_controller_test.rb b/test/controllers/live_updates_controller_test.rb index 725c3c71..5c0b27ad 100644 --- a/test/controllers/live_updates_controller_test.rb +++ b/test/controllers/live_updates_controller_test.rb @@ -19,10 +19,10 @@ class LiveUpdatesControllerTest < ActionController::TestCase end let(:user) { tracked_branch.project.user } - before { sign_in :user, user } + before { sign_in user, scope: :user } it "returns response in proper JSON format" do - post :subscribe, subscription_params + post :subscribe, params: subscription_params successful_subscriptions = JSON. parse(response.body)["successful_subscriptions"] successful_subscriptions["Project"]. diff --git a/test/controllers/project_files_controller_test.rb b/test/controllers/project_files_controller_test.rb index 6684f577..184144ca 100644 --- a/test/controllers/project_files_controller_test.rb +++ b/test/controllers/project_files_controller_test.rb @@ -7,14 +7,14 @@ class ProjectFilesControllerTest < ActionController::TestCase before do project - sign_in :user, user + sign_in user, scope: :user request.env["HTTP_REFERER"] = "previous_path" end describe "GET#index" do it "prevents not logged users" do sign_out :user - get :index, project_id: project.id + get :index, params: { project_id: project.id } response.status.must_equal 302 response.redirect_url.must_match /users\/sign_in/ end @@ -29,15 +29,15 @@ class ProjectFilesControllerTest < ActionController::TestCase create(path: "testributor.yml", contents: contents) project.project_files.create(path: "two", contents: "two contents") - get :index, project_id: project.id + get :index, params: { project_id: project.id } assert_redirected_to project_settings_file_path(project, testributor.id) end it "prevents non members from visiting the page" do sign_out :user - sign_in :user, registered_user - -> { get :index, project_id: project.id }.must_raise ActiveRecord::RecordNotFound + sign_in registered_user, scope: :user + -> { get :index, params: { project_id: project.id } }.must_raise ActiveRecord::RecordNotFound end it "redirects to testributor.yml" do @@ -50,7 +50,7 @@ class ProjectFilesControllerTest < ActionController::TestCase create(path: "testributor.yml", contents: contents) project.project_files.create(path: "two", contents: "two contents") - get :index, project_id: project.id + get :index, params: { project_id: project.id } assert_redirected_to project_settings_file_path(project, testributor.id) end @@ -64,7 +64,7 @@ class ProjectFilesControllerTest < ActionController::TestCase it "creates the files with the specified params" do old_count = ProjectFile.count - post :create, project_id: project.id, project_file: params + post :create, params: { project_id: project.id, project_file: params } flash[:alert].must_be :blank? ProjectFile.count.must_equal old_count + 1 new_file = ProjectFile.last @@ -79,7 +79,7 @@ class ProjectFilesControllerTest < ActionController::TestCase it "destroys the specified file" do old_count = ProjectFile.count - delete :destroy, project_id: project.id, id: subject.id + delete :destroy, params: { project_id: project.id, id: subject.id } ProjectFile.count.must_equal old_count - 1 ProjectFile.find_by(id: subject.id).must_be :nil? end @@ -88,7 +88,7 @@ class ProjectFilesControllerTest < ActionController::TestCase old_count = ProjectFile.count ProjectFile.any_instance. stubs(:testributor_yml?).returns(true) - delete :destroy, project_id: project.id, id: subject.id + delete :destroy, params: { project_id: project.id, id: subject.id } ProjectFile.count.must_equal old_count end @@ -96,7 +96,7 @@ class ProjectFilesControllerTest < ActionController::TestCase other_project_file = FactoryGirl.create(:project_file) old_count = ProjectFile.count - ->{ delete :destroy, project_id: project.id, id: other_project_file.id }. + ->{ delete :destroy, params: { project_id: project.id, id: other_project_file.id } }. must_raise ActiveRecord::RecordNotFound ProjectFile.count.must_equal old_count ProjectFile.find_by(id: other_project_file.id). @@ -104,7 +104,7 @@ class ProjectFilesControllerTest < ActionController::TestCase end it "redirects to project_settings_files_path(project)" do - delete :destroy, project_id: project.id, id: subject.id + delete :destroy, params: { project_id: project.id, id: subject.id } assert_redirected_to project_settings_files_path(project) end end @@ -113,8 +113,8 @@ class ProjectFilesControllerTest < ActionController::TestCase subject { FactoryGirl.create(:project_file, project: project) } it "updates the specified record" do - put :update, project_id: project.id, id: subject.id, - project_file: { path: "the new path", contents: "the new contents" } + put :update, params: { project_id: project.id, id: subject.id, + project_file: { path: "the new path", contents: "the new contents" } } flash[:alert].must_be :blank? subject.reload.path.must_equal 'the new path' diff --git a/test/controllers/project_participations_controller_test.rb b/test/controllers/project_participations_controller_test.rb index 402129b3..cae40e97 100644 --- a/test/controllers/project_participations_controller_test.rb +++ b/test/controllers/project_participations_controller_test.rb @@ -11,11 +11,11 @@ class ProjectParticipationsControllerTest < ActionController::TestCase describe "GET#index" do describe "when current_user is the owner" do before do - sign_in :user, project.user + sign_in project.user, scope: :user end it "lists all members" do - get :index, project_id: project.id + get :index, params: { project_id: project.id } assigns(:participations).map(&:user_id).sort. must_equal [user.id, project.user_id].sort end @@ -23,11 +23,11 @@ class ProjectParticipationsControllerTest < ActionController::TestCase describe "when current_user is not the owner" do before do - sign_in :user, user + sign_in user, scope: :user end it "lists all members" do - get :index, project_id: project.id + get :index, params: { project_id: project.id } assigns(:participations).map(&:user_id).sort. must_equal [user.id, project.user_id].sort end @@ -37,14 +37,14 @@ class ProjectParticipationsControllerTest < ActionController::TestCase describe "GET#destroy" do before do request.env["HTTP_REFERER"] = 'back' - sign_in :user, project.user + sign_in project.user, scope: :user end it "allows the owner to remove members" do project.members.map(&:id).sort. must_equal [project.user_id, user.id].sort - delete :destroy, project_id: project.id, - id: user.project_participations.first.id + delete :destroy, params: { project_id: project.id, + id: user.project_participations.first.id } project.members.reload.map(&:id).must_equal [project.user_id] user.reload # user should not be destroyed end @@ -52,27 +52,29 @@ class ProjectParticipationsControllerTest < ActionController::TestCase it "not allows the owner to remove himself" do project.members.map(&:id).sort. must_equal [project.user_id, user.id].sort - delete :destroy, project_id: project.id, - id: project.project_participations.where(user_id: project.user.id).first.id + delete :destroy, params: { project_id: project.id, + id: project.project_participations. + where(user_id: project.user.id).first.id } assert_response 403 end it "allows the non owner to remove himself" do - sign_in :user, user + sign_in user, scope: :user project.members.map(&:id).sort. must_equal [project.user_id, user.id].sort - delete :destroy, project_id: project.id, - id: user.project_participations.first.id + delete :destroy, params: { project_id: project.id, + id: user.project_participations.first.id } project.members.reload.map(&:id).must_equal [project.user_id] user.reload # user should not be destroyed end it "does not allow non owner to remove the owner" do - sign_in :user, user + sign_in user, scope: :user project.members.map(&:id).sort. must_equal [project.user_id, user.id].sort - delete :destroy, project_id: project.id, - id: project.project_participations.where(user_id: project.user.id).first.id + delete :destroy, params: { project_id: project.id, + id: project.project_participations. + where(user_id: project.user.id).first.id } assert_response 403 end end diff --git a/test/controllers/project_wizard_controller_test.rb b/test/controllers/project_wizard_controller_test.rb index dcf5c0d8..bd5e8d5c 100644 --- a/test/controllers/project_wizard_controller_test.rb +++ b/test/controllers/project_wizard_controller_test.rb @@ -4,7 +4,7 @@ class ProjectWizardControllerTest < ActionController::TestCase let(:user) { FactoryGirl.create(:user, projects_limit: 3) } before do - sign_in :user, user + sign_in user, scope: :user user.update_column(:projects_limit, 3) end @@ -13,7 +13,7 @@ class ProjectWizardControllerTest < ActionController::TestCase user.update_column(:projects_limit, 0) # id doesn't matter here. It could be anything VCR.use_cassette 'github_user' do - get :show, { id: :select_repository } + get :show, params: { id: :select_repository } end flash[:alert].must_equal("You cannot add other projects as you have "\ @@ -22,7 +22,7 @@ class ProjectWizardControllerTest < ActionController::TestCase end it "redirects to the first step if project is missing from cookies" do - get :show, { id: :configure } + get :show, params: { id: :configure } flash[:alert].must_equal "You need to select a repository first" assert_redirected_to project_wizard_path(:select_repository) @@ -30,7 +30,7 @@ class ProjectWizardControllerTest < ActionController::TestCase describe "when the requested step does not exist" do it "renders 404 Not Found" do - ->{ get :show, id: :some_non_existent_step }.must_raise( + ->{ get :show, params: { id: :some_non_existent_step } }.must_raise( ActionController::RoutingError) end end @@ -52,7 +52,7 @@ class ProjectWizardControllerTest < ActionController::TestCase let(:repo_name) { "pakallis/hello" } before do - sign_in :user, user + sign_in user, scope: :user RepositoryManager.any_instance.stubs(:post_add_repository_setup). returns({ }) end @@ -62,7 +62,7 @@ class ProjectWizardControllerTest < ActionController::TestCase let(:next_step) { :configure } it "saves repo_name to Project is valid?" do - put :update, first_step_params + put :update, params: first_step_params project = @controller.current_user.projects.last project.repository_name.must_equal repo_name @@ -73,7 +73,7 @@ class ProjectWizardControllerTest < ActionController::TestCase end it "redirects to next step if Project#valid?" do - put :update, first_step_params + put :update, params: first_step_params assert_redirected_to project_wizard_path(next_step) end @@ -81,7 +81,7 @@ class ProjectWizardControllerTest < ActionController::TestCase it "redirects to previous step and flashes if Project#invalid?" do request.env["HTTP_REFERER"] = project_wizard_path(current_step) VCR.use_cassette('github_user') do - put :update, first_step_params.except(:repository_name) + put :update, params: first_step_params.except(:repository_name) end flash[:alert].must_equal "Name can't be blank" @@ -90,11 +90,11 @@ class ProjectWizardControllerTest < ActionController::TestCase it "creates a new project and an oauth application and a worker group" do private_key = FactoryGirl.build(:worker_group).ssh_key_private request.env["HTTP_REFERER"] = project_wizard_path(current_step) - put :update, { id: :select_repository, - repository_provider: "bare_repo", - repository_name: "My generic repo", - private_key: private_key, - repository_url: "git://example.com/repo.git" } + put :update, params: { id: :select_repository, + repository_provider: "bare_repo", + repository_name: "My generic repo", + private_key: private_key, + repository_url: "git://example.com/repo.git" } flash[:alert].must_equal nil assert_redirected_to project_wizard_path(next_step) @@ -109,10 +109,10 @@ class ProjectWizardControllerTest < ActionController::TestCase it "flashes and error if bare_repo but no SSH key is provided" do request.env["HTTP_REFERER"] = project_wizard_path(current_step) VCR.use_cassette('github_user') do - put :update, { id: :select_repository, - repository_provider: "bare_repo", - repository_name: "My generic repo", - repository_url: "git://example.com/repo.git" } + put :update, params: { id: :select_repository, + repository_provider: "bare_repo", + repository_name: "My generic repo", + repository_url: "git://example.com/repo.git" } end flash[:alert].must_equal "Ssh key private can't be blank" @@ -121,11 +121,11 @@ class ProjectWizardControllerTest < ActionController::TestCase it "flashes an error if SSH key is invalid and it does not create a project" do request.env["HTTP_REFERER"] = project_wizard_path(current_step) VCR.use_cassette 'github_user' do - put :update, { id: :select_repository, - repository_provider: "bare_repo", - repository_name: "My generic repo", - private_key: "invalid_key", - repository_url: "git://example.com/repo.git" } + put :update, params: { id: :select_repository, + repository_provider: "bare_repo", + repository_name: "My generic repo", + private_key: "invalid_key", + repository_url: "git://example.com/repo.git" } end flash[:alert].must_equal "Ssh key private is invalid or passphrase protected" @@ -138,11 +138,12 @@ class ProjectWizardControllerTest < ActionController::TestCase let(:next_step) { :add_worker } before do - put :update, first_step_params + put :update, params: first_step_params end it "saves _testributor_yml contents to ProjectFile if valid?" do - put :update, { id: current_step, testributor_yml: _testributor_yml } + put :update, + params: { id: current_step, testributor_yml: _testributor_yml } @controller.current_user.projects.last.project_files. where(path: ProjectFile::JOBS_YML_PATH).first.contents. @@ -150,14 +151,16 @@ class ProjectWizardControllerTest < ActionController::TestCase end it "redirects to next step if ProjectFile#valid?" do - put :update, { id: current_step, testributor_yml: _testributor_yml } + put :update, + params: { id: current_step, testributor_yml: _testributor_yml } assert_redirected_to project_wizard_path(next_step) end it "redirects to previous step and flashes if ProjectFile#invalid?" do request.env["HTTP_REFERER"] = project_wizard_path(current_step) - put :update, { id: current_step, testributor_yml: '' } + put :update, + params: { id: current_step, testributor_yml: '' } flash[:alert].must_equal "Contents can't be blank" assert_redirected_to project_wizard_path(current_step) @@ -168,19 +171,20 @@ class ProjectWizardControllerTest < ActionController::TestCase let(:current_step) { :add_worker } before do - put :update, first_step_params - put :update, { id: :configure, testributor_yml: _testributor_yml } + put :update, params: first_step_params + put :update, + params: { id: :configure, testributor_yml: _testributor_yml } end it "removes Project id from cookies" do - cookies[:wizard_project_id].must_equal( + cookies[:wizard_project_id].to_i.must_equal( @controller.current_user.projects.last.id) - put :update, { id: current_step } + put :update, params: { id: current_step } cookies[:wizard_project_id].must_equal nil end it "redirects to project path" do - put :update, { id: current_step } + put :update, params: { id: current_step } assert_redirected_to project_path( @controller.current_user.projects.first) end diff --git a/test/controllers/projects_controller_test.rb b/test/controllers/projects_controller_test.rb index 278e1df9..94d8e31b 100644 --- a/test/controllers/projects_controller_test.rb +++ b/test/controllers/projects_controller_test.rb @@ -14,7 +14,7 @@ class ProjectsControllerTest < ActionController::TestCase describe 'when user is registered' do before do request.env["HTTP_REFERER"] = "previous_path" - sign_in :user, owner + sign_in owner, scope: :user end describe "GET#show" do @@ -24,7 +24,7 @@ class ProjectsControllerTest < ActionController::TestCase describe 'when the project repository provider is bare_repo' do it 'redirects to the test_runs/index page' do - get :show, id: project.id + get :show, params: { id: project.id } assert_response 302 response.location.must_equal project_test_runs_url(project) end @@ -36,7 +36,7 @@ class ProjectsControllerTest < ActionController::TestCase it "updates docker_image_id when Project#valid?" do project_params = { id: project.id, project: { docker_image_id: language.id } } - patch :update, project_params + patch :update, params: project_params project.reload project.docker_image_id.must_equal language.id @@ -49,7 +49,7 @@ class ProjectsControllerTest < ActionController::TestCase docker_image_id: language.id, technology_ids: [technology.id]} } - patch :update, project_params + patch :update, params: project_params project.reload project.technology_ids.must_equal [technology.id] @@ -60,7 +60,7 @@ class ProjectsControllerTest < ActionController::TestCase id: project.id, project: { repository_url: "this_is_the_projects_new_home" } } - patch :update, project_params + patch :update, params: project_params project.reload project.repository_url.must_equal "this_is_the_projects_new_home" @@ -70,13 +70,13 @@ class ProjectsControllerTest < ActionController::TestCase describe 'when user is a member' do before do sign_out :user - sign_in :user, member + sign_in member, scope: :user end it "updates docker_image_id when Project#valid?" do project_params = { id: project.id, project: { docker_image_id: language.id } } - patch :update, project_params + patch :update, params: project_params project.reload project.docker_image_id.must_equal language.id @@ -89,7 +89,7 @@ class ProjectsControllerTest < ActionController::TestCase docker_image_id: language.id, technology_ids: [technology.id]} } - patch :update, project_params + patch :update, params: project_params project.reload project.technology_ids.must_equal [technology.id] @@ -100,9 +100,9 @@ class ProjectsControllerTest < ActionController::TestCase it "doesn't destroy the project if user is not the owner" do member = FactoryGirl.create(:user) project.members << member - sign_in :user, member + sign_in member, scope: :user - delete :destroy, { id: project.id } + delete :destroy, params: { id: project.id } assert_response 403 Project.count.must_equal 1 @@ -110,7 +110,7 @@ class ProjectsControllerTest < ActionController::TestCase it "destroys the project if user is the owner" do Octokit::Client.any_instance.stubs(:remove_hook).returns(1) - delete :destroy, { id: project.id } + delete :destroy, params: { id: project.id } Project.count.must_equal 0 end @@ -118,7 +118,7 @@ class ProjectsControllerTest < ActionController::TestCase it "doesn't delete the github webhook if project wasn't destroyed" do Project.any_instance.stubs(:destroy).returns(false) Octokit::Client.any_instance.expects(:remove_hook).never - delete :destroy, { id: project.id } + delete :destroy, params: { id: project.id } end end @@ -127,11 +127,11 @@ class ProjectsControllerTest < ActionController::TestCase before do member = FactoryGirl.create(:user) project.members << member - sign_in :user, member + sign_in member, scope: :user end it 'does not allow that action' do - post :toggle_private, id: project.id + post :toggle_private, params: { id: project.id } assert_response 403 project.reload project.is_private.must_equal true @@ -141,11 +141,11 @@ class ProjectsControllerTest < ActionController::TestCase describe 'when a member tries to toggle private' do before do project - sign_in :user, owner + sign_in owner, scope: :user end it 'allows the user to toggle' do - post :toggle_private, id: project.id + post :toggle_private, params: { id: project.id } project.reload project.is_private.must_equal false flash[:notice].must_equal "Your project is now public." @@ -159,7 +159,7 @@ class ProjectsControllerTest < ActionController::TestCase describe 'when the project is private' do describe "GET#show" do it "returns ok" do - -> { get :show, id: project.id }. + -> { get :show, params: { id: project.id } }. must_raise ActiveRecord::RecordNotFound end end @@ -170,7 +170,7 @@ class ProjectsControllerTest < ActionController::TestCase describe "GET#show" do it "returns ok" do - get :show, id: project.id + get :show, params: { id: project.id } assert_response 302 response.location.must_equal "http://test.host/projects/#{project.to_param}/builds" end @@ -179,7 +179,7 @@ class ProjectsControllerTest < ActionController::TestCase describe "DELETE#destroy" do it "doesn't destroy the project if user is not the owner" do - delete :destroy, { id: project.id } + delete :destroy, params: { id: project.id } assert_response 302 response.location.must_equal 'http://test.host/users/sign_in' Project.count.must_equal 1 @@ -189,7 +189,7 @@ class ProjectsControllerTest < ActionController::TestCase describe 'POST#toggle_private' do describe 'when a member tries to toggle private' do it 'does not allow that action' do - post :toggle_private, id: project.id + post :toggle_private, params: { id: project.id } assert_response 302 response.location.must_equal 'http://test.host/users/sign_in' project.reload @@ -203,7 +203,7 @@ class ProjectsControllerTest < ActionController::TestCase it "updates docker_image_id when Project#valid?" do project_params = { id: project.id, project: { docker_image_id: language.id } } - patch :update, project_params + patch :update, params: project_params assert_response 302 response.location.must_equal 'http://test.host/users/sign_in' end @@ -216,7 +216,7 @@ class ProjectsControllerTest < ActionController::TestCase technology_ids: [technology.id]} } - patch :update, project_params + patch :update, params: project_params assert_response 302 response.location.must_equal 'http://test.host/users/sign_in' end @@ -231,7 +231,7 @@ class ProjectsControllerTest < ActionController::TestCase end it 'returns the uknown status image' do - get :status, id: project.id, branch: 'master' + get :status, params: { id: project.id, branch: 'master' } response.content_type.must_equal 'image/svg+xml' response.header["Content-Disposition"].must_equal( "inline; filename=\"build-status-unknown.svg\"") @@ -248,7 +248,7 @@ class ProjectsControllerTest < ActionController::TestCase end it 'returns the uknown status image' do - get :status, id: project.id, branch: 'master' + get :status, params: { id: project.id, branch: 'master' } response.content_type.must_equal 'image/svg+xml' response.header["Content-Disposition"].must_equal( "inline; filename=\"build-status-passed.svg\"") diff --git a/test/controllers/settings_controller_test.rb b/test/controllers/settings_controller_test.rb index 5713d327..2b291a36 100644 --- a/test/controllers/settings_controller_test.rb +++ b/test/controllers/settings_controller_test.rb @@ -9,36 +9,36 @@ class SettingsControllerTest < ActionController::TestCase let(:user) { FactoryGirl.create(:user) } describe 'when a user is a member of the project' do - before { sign_in :user, member } + before { sign_in member, scope: :user } it 'allows GET#notifications' do - get :notifications, project_id: project + get :notifications, params: { project_id: project } end it 'allows GET#worker_setup' do - get :worker_setup, project_id: project + get :worker_setup, params: { project_id: project } end it 'allows GET#show' do - get :show, project_id: project + get :show, params: { project_id: project } end end describe 'when a user is NOT a member of the project' do - before { sign_in :user, user } + before { sign_in user, scope: :user } it 'does NOT allow GET#notifications' do - -> { get :notifications, project_id: project }.must_raise + -> { get :notifications, params: { project_id: project } }.must_raise ActiveRecord::RecordNotFound end it 'does NOT allow GET#worker_setup' do - -> { get :worker_setup, project_id: project }.must_raise + -> { get :worker_setup, params: { project_id: project } }.must_raise ActiveRecord::RecordNotFound end it 'does NOT allow GET#show' do - -> { get :show, project_id: project }.must_raise + -> { get :show, params: { project_id: project } }.must_raise ActiveRecord::RecordNotFound end end diff --git a/test/controllers/test_runs_controller_test.rb b/test/controllers/test_runs_controller_test.rb index 88608223..c885c0d5 100644 --- a/test/controllers/test_runs_controller_test.rb +++ b/test/controllers/test_runs_controller_test.rb @@ -69,21 +69,22 @@ class TestRunsControllerTest < ActionController::TestCase }.to_yaml project.project_files.create!( path: ProjectFile::JOBS_YML_PATH, contents: contents) - sign_in :user, project.user + sign_in project.user, scope: :user request.env["HTTP_REFERER"] = "previous_path" end describe 'When the user is the owner of the project' do describe "GET#show" do it "returns 200" do - get :show, { project_id: project.id, id: _test_run.id } + get :show, params: { project_id: project.id, id: _test_run.id } assert_response :ok end it "returns 404 when requesting a test_run of a different project" do different_project_run = FactoryGirl.create(:testributor_run) ->{ - get :show, { project_id: project.id, id: different_project_run.id } + get :show, params: { project_id: project.id, + id: different_project_run.id } }.must_raise ActiveRecord::RecordNotFound end end @@ -91,7 +92,8 @@ class TestRunsControllerTest < ActionController::TestCase describe "POST#create" do it "sets :notice when RepositoryManager#create_test_run! is true" do RepositoryManager.any_instance.stubs(:create_test_run!).returns(true) - post :create, { project_id: project.to_param, branch_id: branch.id } + post :create, params: { project_id: project.to_param, + branch_id: branch.id } flash[:notice].must_equal "Your build is being setup" end @@ -100,7 +102,8 @@ class TestRunsControllerTest < ActionController::TestCase RepositoryManager.any_instance.stubs(:create_test_run!).returns(nil) RepositoryManager.any_instance.stubs(:errors).returns( ["#{branch.branch_name} doesn't exist anymore on github"]) - post :create, { project_id: project.to_param, branch_id: branch.id } + post :create, params: { project_id: project.to_param, + branch_id: branch.id } flash[:alert]. must_equal("#{branch.branch_name} doesn't exist anymore on github") @@ -109,7 +112,8 @@ class TestRunsControllerTest < ActionController::TestCase it "creates a TestRun with correct attributes" do GithubRepositoryManager.any_instance.stubs(:sha_history). returns(branch_github_response) - post :create, { project_id: project.to_param, branch_id: branch.id } + post :create, params: { project_id: project.to_param, + branch_id: branch.id } TestRun.count.must_equal 2 _test_run = TestRun.last @@ -122,7 +126,8 @@ class TestRunsControllerTest < ActionController::TestCase it "does not allow retying queued runs" do job_ids = _test_run.test_jobs.pluck(:id).sort _test_run.update_column(:status, TestStatus::QUEUED) - post :retry, { project_id: project.to_param, id: _test_run.id } + post :retry, params: { project_id: project.to_param, + id: _test_run.id } flash[:alert].must_equal "Retrying ##{_test_run.id} test run is not allowed at this time" _test_run.reload.status.code.must_equal TestStatus::QUEUED @@ -133,7 +138,8 @@ class TestRunsControllerTest < ActionController::TestCase it "does not allow retying cancelled runs" do job_ids = _test_run.test_jobs.pluck(:id).sort _test_run.update_column(:status, TestStatus::CANCELLED) - post :retry, { project_id: project.to_param, id: _test_run.id } + post :retry, params: { project_id: project.to_param, + id: _test_run.id } flash[:alert].must_equal "Retrying ##{_test_run.id} test run is not allowed at this time" _test_run.reload.status.code.must_equal TestStatus::CANCELLED @@ -144,7 +150,8 @@ class TestRunsControllerTest < ActionController::TestCase it "does not allow retying running runs" do job_ids = _test_run.test_jobs.pluck(:id).sort _test_run.update_column(:status, TestStatus::RUNNING) - post :retry, { project_id: project.to_param, id: _test_run.id } + post :retry, params: { project_id: project.to_param, + id: _test_run.id } flash[:alert].must_equal "Retrying ##{_test_run.id} test run is not allowed at this time" _test_run.reload.status.code.must_equal TestStatus::RUNNING @@ -155,7 +162,8 @@ class TestRunsControllerTest < ActionController::TestCase job_ids = _test_run.test_jobs.pluck(:id).sort _test_run.update_columns(status: TestStatus::PASSED, setup_worker_uuid: "some uuid") - post :retry, { project_id: project.to_param, id: _test_run.id } + post :retry, params: { project_id: project.to_param, + id: _test_run.id } flash[:notice].must_equal "The Build will soon be retried" _test_run.reload.setup_worker_uuid.must_equal nil @@ -164,7 +172,8 @@ class TestRunsControllerTest < ActionController::TestCase it "returns 404 when retrying a test_run of a different project" do different_project_run = FactoryGirl.create(:testributor_run) ->{ - post :retry, { project_id: project.id, id: different_project_run.id } + post :retry, params: { project_id: project.id, + id: different_project_run.id } }.must_raise ActiveRecord::RecordNotFound end end @@ -173,49 +182,65 @@ class TestRunsControllerTest < ActionController::TestCase it "returns 404 when updating a test_run of a different project" do different_project_run = FactoryGirl.create(:testributor_run) ->{ - put :update, { project_id: project.id, id: different_project_run.id } + put :update, params: { project_id: project.id, + id: different_project_run.id } }.must_raise ActiveRecord::RecordNotFound end end end describe 'When user is a random registered user' do - before { sign_in :user, random_user } + before { sign_in random_user, scope: :user } describe "GET#show" do it "returns 302" do - -> { get :show, { project_id: project.id, id: _test_run.id } }.must_raise ActiveRecord::RecordNotFound + -> { + get :show, params: { project_id: project.id, + id: _test_run.id } + }.must_raise ActiveRecord::RecordNotFound end end describe "GET#index" do it "returns 302" do - -> { get :index, { project_id: project.id, branch_id: branch.id } }.must_raise ActiveRecord::RecordNotFound + -> { + get :index, params: { project_id: project.id, + branch_id: branch.id } + }.must_raise ActiveRecord::RecordNotFound end end describe "POST#create" do it "sets :notice when RepositoryManager#create_test_run! is true" do - -> { post :create, { project_id: project.id, branch_id: branch.id } }.must_raise ActiveRecord::RecordNotFound + -> { + post :create, params: { project_id: project.id, + branch_id: branch.id } + }.must_raise ActiveRecord::RecordNotFound end end describe "POST#retry" do it 'does not allow the user to retry the test run' do - -> { post :retry, { project_id: project.id, id: _test_run.id } }.must_raise ActiveRecord::RecordNotFound + -> { + post :retry, params: { project_id: project.id, + id: _test_run.id } + }.must_raise ActiveRecord::RecordNotFound end end describe "POST#destroy" do it 'does not allow the user to retry the test run' do - -> { post :destroy, { project_id: project.id, id: _test_run.id } }.must_raise ActiveRecord::RecordNotFound + -> { post :destroy, params: { project_id: project.id, + id: _test_run.id } + }.must_raise ActiveRecord::RecordNotFound end end end it "creates a TestRun with correct attributes when repo provider is bare_repo and branch is missing" do project.update_column(:repository_provider, "bare_repo") - post :create, { project_id: project.to_param, test_run: { commit_sha: '1234' } } + post :create, params: { project_id: project.to_param, + test_run: { commit_sha: '1234' } } TestRun.count.must_equal 2 _test_run = TestRun.last @@ -244,39 +269,44 @@ class TestRunsControllerTest < ActionController::TestCase end describe 'when the user is registered' do - before { sign_in :user, random_user } + before { sign_in random_user, scope: :user } describe "GET#show" do it "returns 200" do - get :show, { project_id: public_project.id, id: _test_run.id } + get :show, params: { project_id: public_project.id, + id: _test_run.id } assert_response :ok end end describe "GET#index" do it "returns 200" do - get :index, { project_id: public_project.id, branch_id: branch.id } + get :index, params: { project_id: public_project.id, + branch_id: branch.id } assert_response :ok end end describe "POST#create" do it "sets :notice when RepositoryManager#create_test_run! is true" do - post :create, { project_id: public_project.to_param, branch_id: branch.id } + post :create, params: { project_id: public_project.to_param, + branch_id: branch.id } assert_response 403 end end describe "POST#retry" do it 'does not allow the user to retry the test run' do - post :retry, { project_id: public_project.to_param, id: _test_run.id } + post :retry, params: { project_id: public_project.to_param, + id: _test_run.id } assert_response 403 end end describe "POST#destroy" do it 'does not allow the user to retry the test run' do - post :destroy, { project_id: public_project.to_param, id: _test_run.id } + post :destroy, params: { project_id: public_project.to_param, + id: _test_run.id } assert_response 403 end end @@ -285,21 +315,24 @@ class TestRunsControllerTest < ActionController::TestCase describe 'when the user is not registered' do describe "GET#show" do it "returns 200" do - get :show, { project_id: public_project.id, id: _test_run.id } + get 'show', params: { project_id: public_project.id, + id: _test_run.id } assert_response :ok end end describe "GET#index" do it "returns 200" do - get :index, { project_id: public_project.id, branch_id: branch.id } + get 'index', params: { project_id: public_project.id, + branch_id: branch.id } assert_response :ok end end describe "POST#create" do it "sets an alert and redirects to sign in page" do - post :create, { project_id: public_project.to_param, branch_id: branch.id } + post :create, params: { project_id: public_project.to_param, + branch_id: branch.id } flash[:alert].must_equal 'You need to sign in or sign up before continuing.' assert_response 302 end @@ -307,7 +340,8 @@ class TestRunsControllerTest < ActionController::TestCase describe "POST#retry" do it 'does not allow the user to retry the test run' do - post :retry, { project_id: public_project.to_param, id: _test_run.id } + post :retry, params: { project_id: public_project.to_param, + id: _test_run.id } flash[:alert].must_equal 'You need to sign in or sign up before continuing.' assert_response 302 end @@ -315,7 +349,8 @@ class TestRunsControllerTest < ActionController::TestCase describe "POST#destroy" do it 'does not allow the user to retry the test run' do - post :destroy, { project_id: public_project.to_param, id: _test_run.id } + post :destroy, params: { project_id: public_project.to_param, + id: _test_run.id } flash[:alert].must_equal 'You need to sign in or sign up before continuing.' assert_response 302 end diff --git a/test/controllers/tracked_branches_controller_test.rb b/test/controllers/tracked_branches_controller_test.rb index 9834b74f..3b5d33a5 100644 --- a/test/controllers/tracked_branches_controller_test.rb +++ b/test/controllers/tracked_branches_controller_test.rb @@ -49,39 +49,39 @@ class TrackedBranchesControllerTest < ActionController::TestCase project GithubRepositoryManager.any_instance.stubs(:sha_history). returns(branch_github_response) - sign_in :user, owner + sign_in owner, scope: :user end it "adds errors to flash when tracked_branch.invalid?" do # Create a branch with same branch_name so that uniqueness validation # is triggered project.tracked_branches.create(branch_name: branch_name) - post :create, branch_params + post :create, params: branch_params flash[:alert].wont_be :empty? end it "doesn't call build_test_run_and_jobs when tracked_branch.invalid?" do TrackedBranch.any_instance.stubs(:invalid?).returns(true) TrackedBranch.any_instance.expects(:build_test_run_and_jobs).never - post :create, branch_params + post :create, params: branch_params end it "adds errors to flash when build_test_run_and_jobs returns nil" do GithubRepositoryManager.any_instance.stubs(:create_test_run!).returns(nil) RepositoryManager.any_instance.stubs(:errors).returns( ["#{branch_name} doesn't exist anymore on github"]) - post :create, branch_params + post :create, params: branch_params flash[:alert].must_equal "#{branch_name} doesn't exist anymore on github" end describe "on success" do it "creates tracked branch" do - post :create, branch_params + post :create, params: branch_params TrackedBranch.last.branch_name.must_equal branch_name end it "creates a TestRun with correct attributes" do - post :create, branch_params + post :create, params: branch_params _test_run = TestRun.last _test_run.commit_sha.must_equal commit_sha @@ -89,13 +89,13 @@ class TrackedBranchesControllerTest < ActionController::TestCase end it "does not create TestJobs" do - post :create, branch_params + post :create, params: branch_params TestRun.last.test_jobs.count.must_equal 0 end it "displays flash notice" do - post :create, branch_params + post :create, params: branch_params flash[:notice].wont_be :empty? end end @@ -105,7 +105,7 @@ class TrackedBranchesControllerTest < ActionController::TestCase it "creates tracked branch" do GithubRepositoryManager.any_instance.stubs(:fetch_branches). returns([FactoryGirl.create(:tracked_branch, branch_name: branch_name)]) - get :new, branch_params + get :new, params: branch_params TrackedBranch.last.branch_name.must_equal branch_name end end @@ -116,18 +116,18 @@ class TrackedBranchesControllerTest < ActionController::TestCase let(:project_id) { project.id } let(:owner) { project.user } before do - sign_in :user, owner + sign_in owner, scope: :user request.env['HTTP_REFERER'] = 'a-random-path' end it "destroys branch if it belongs to current_project" do old_count = TrackedBranch.count - delete :destroy, { project_id: project_id, id: branch.id } + delete :destroy, params: { project_id: project_id, id: branch.id } TrackedBranch.count.must_equal old_count - 1 end it "flashes notice on success and redirects to project_path" do - delete :destroy, { project_id: project_id, id: branch.id } + delete :destroy, params: { project_id: project_id, id: branch.id } flash[:notice].must_equal "#{branch.branch_name} branch was removed" assert_redirected_to project_path(project) @@ -135,7 +135,7 @@ class TrackedBranchesControllerTest < ActionController::TestCase it "flashes alert on failure and redirects to project_branch_path" do TrackedBranch.any_instance.stubs(:destroy).returns(false) - delete :destroy, { project_id: project_id, id: branch.id } + delete :destroy, params: { project_id: project_id, id: branch.id } flash[:alert].must_equal "Can't remove #{branch.branch_name} branch" assert_redirected_to project_branch_path(project, branch) @@ -143,8 +143,8 @@ class TrackedBranchesControllerTest < ActionController::TestCase it "doesn't destroy branch if it doesn't belong to current_project" do old_count = TrackedBranch.count - delete_branch = -> { delete :destroy, - { project_id: project_id + 1, id: branch.id } } + delete_branch = -> { + delete :destroy, params: { project_id: project_id + 1, id: branch.id } } delete_branch.must_raise ActiveRecord::RecordNotFound branch.reload TrackedBranch.count.must_equal old_count diff --git a/test/controllers/user_invitations_controller_test.rb b/test/controllers/user_invitations_controller_test.rb index cc5f9bf3..b061d1f8 100644 --- a/test/controllers/user_invitations_controller_test.rb +++ b/test/controllers/user_invitations_controller_test.rb @@ -6,15 +6,15 @@ class UserInvitationsControllerTest < ActionController::TestCase before do project - sign_in :user, user + sign_in user, scope: :user request.env["HTTP_REFERER"] = "previous_path" end describe "POST#create" do it "creates a new invitation for the given email" do - post :create, project_id: project.id, user_invitation: { - email: "someone@example.com" - } + post :create, + params: { project_id: project.id, + user_invitation: { email: "someone@example.com" } } flash[:notice].must_equal "Invitation will be sent shortly" UserInvitation.last.email.must_equal 'someone@example.com' end @@ -23,9 +23,9 @@ class UserInvitationsControllerTest < ActionController::TestCase FactoryGirl.create(:user_invitation, email: 'someone@example.com', project: project) - post :create, project_id: project.id, user_invitation: { - email: "someone@example.com" - } + post :create, + params: { project_id: project.id, + user_invitation: { email: "someone@example.com" } } flash[:notice].must_be :nil? flash[:alert].must_equal "Email An invitation for this user already exists" end @@ -35,7 +35,7 @@ class UserInvitationsControllerTest < ActionController::TestCase subject { FactoryGirl.create(:user_invitation, project: project) } it "destroys the invitation" do - delete :destroy, project_id: project.id, id: subject.id + delete :destroy, params: { project_id: project.id, id: subject.id } flash[:notice].must_equal 'Invitation was cancelled' ->{ subject.reload }.must_raise ActiveRecord::RecordNotFound end @@ -46,7 +46,7 @@ class UserInvitationsControllerTest < ActionController::TestCase it "sends an email for an existing invitation" do perform_enqueued_jobs do - post :resend, project_id: project.id, id: subject.id + post :resend, params: { project_id: project.id, id: subject.id } end flash[:notice].must_equal "Invitation will be sent shortly" ActionMailer::Base.deliveries.last.body.to_s.must_match(subject.token) @@ -59,7 +59,7 @@ class UserInvitationsControllerTest < ActionController::TestCase describe "when the user is not logged in" do it "asks the user to login" do sign_out :user - get :accept, token: subject.token + get :accept, params: { token: subject.token } flash[:alert].must_equal "You need to sign in or sign up before continuing." end end @@ -67,7 +67,7 @@ class UserInvitationsControllerTest < ActionController::TestCase describe "when the user is logged in" do describe "but is already a member" do it "flashes a message" do - get :accept, token: subject.token + get :accept, params: { token: subject.token } flash[:alert].must_equal "You are already a member of this project!" end end @@ -75,8 +75,8 @@ class UserInvitationsControllerTest < ActionController::TestCase it "adds current_user to members" do subject.accepted_at.must_be :nil? user = FactoryGirl.create(:user) - sign_in :user, user - get :accept, token: subject.token + sign_in user, scope: :user + get :accept, params: { token: subject.token } flash[:notice].must_equal "Welcome to #{project.name}" user.participating_projects.must_equal [project] subject.reload.accepted_at.wont_be :nil? diff --git a/test/controllers/users_api/v1/commits_controller_test.rb b/test/controllers/users_api/v1/commits_controller_test.rb index b0d0bbaa..82eb05db 100644 --- a/test/controllers/users_api/v1/commits_controller_test.rb +++ b/test/controllers/users_api/v1/commits_controller_test.rb @@ -18,8 +18,9 @@ class UsersApi::V1::CommitsControllerTest < ActionController::TestCase describe "when no project is specified" do it "returns an error message" do - get :status, access_token: user_token.token, default: { format: :json }, - id: _test_run.commit_sha + get :status, params: { access_token: user_token.token, + default: { format: 'json' }, + id: _test_run.commit_sha } response.status.must_equal 404 response.body.must_equal( "Project with name '' does not exist") @@ -28,8 +29,10 @@ class UsersApi::V1::CommitsControllerTest < ActionController::TestCase describe "when the specified project does not exist" do it "returns an error message" do - get :status, access_token: user_token.token, default: { format: :json }, - id: _test_run.commit_sha, project: 'some_non_existent_project' + get :status, params: { access_token: user_token.token, + default: { format: 'json' }, + id: _test_run.commit_sha, + project: 'some_non_existent_project' } response.status.must_equal 404 response.body.must_equal( "Project with name 'some_non_existent_project' does not exist") @@ -38,8 +41,9 @@ class UsersApi::V1::CommitsControllerTest < ActionController::TestCase describe "when :id (commit sha) is shorter than 6 characters" do it "returns an error message" do - get :status, access_token: user_token.token, default: { format: :json }, - id: _test_run.commit_sha[0..2] + get :status, params: { access_token: user_token.token, + default: { format: 'json' }, + id: _test_run.commit_sha[0..2] } response.status.must_equal 400 response.body.must_equal( 'Specify a commit hash with at least the first 6 characters') @@ -48,8 +52,10 @@ class UsersApi::V1::CommitsControllerTest < ActionController::TestCase describe "when the specified commit does not exist" do it "returns an error message" do - get :status, access_token: user_token.token, default: { format: :json }, - id: 'non_existent_commit_sha', project: project.name + get :status, params: { access_token: user_token.token, + default: { format: 'json' }, + id: 'non_existent_commit_sha', + project: project.name } response.status.must_equal 404 response.body.must_equal( 'No Build found for the specified commit') @@ -58,8 +64,10 @@ class UsersApi::V1::CommitsControllerTest < ActionController::TestCase describe "when the commit exists but not in the specified project" do it "still returns an error" do - get :status, access_token: user_token.token, default: { format: :json }, - id: _test_run_2.commit_sha, project: project.name + get :status, params: { access_token: user_token.token, + default: { format: 'json' }, + id: _test_run_2.commit_sha, + project: project.name } response.status.must_equal 404 response.body.must_equal( 'No Build found for the specified commit') @@ -68,8 +76,10 @@ class UsersApi::V1::CommitsControllerTest < ActionController::TestCase describe "when the specified project has a test run for the specified commit" do it "returns the status of the test run" do - get :status, access_token: user_token.token, default: { format: :json }, - id: _test_run.commit_sha, project: project.name + get :status, params: { access_token: user_token.token, + default: { format: 'json' }, + id: _test_run.commit_sha, + project: project.name } response.status.must_equal 200 JSON.parse(response.body).must_equal({"status" => "Setup"}) end diff --git a/test/controllers/users_api/v1/users_controller_test.rb b/test/controllers/users_api/v1/users_controller_test.rb index 7e10937f..7990ddaa 100644 --- a/test/controllers/users_api/v1/users_controller_test.rb +++ b/test/controllers/users_api/v1/users_controller_test.rb @@ -9,8 +9,8 @@ class UsersApi::V1::UsersControllerTest < ActionController::TestCase let(:worker_token) { application.access_tokens.create } it "returns 401 unauthorized when token does not have an resource_owner_id" do - get :current, access_token: worker_token.token, - default: { format: :json } + get :current, params: { access_token: worker_token.token, + default: { format: 'json' } } response.status.must_equal 401 end end @@ -22,7 +22,8 @@ class UsersApi::V1::UsersControllerTest < ActionController::TestCase end it "returns the current user's data" do - get :current, access_token: user_token.token, default: { format: :json } + get :current, params: { access_token: user_token.token, + default: { format: 'json' } } response.status.must_equal 200 JSON.parse(response.body).must_equal( {"email" => "dannydevito@example.com"}) diff --git a/test/controllers/webhooks_controller_test.rb b/test/controllers/webhooks_controller_test.rb index d8c63962..d9e335fa 100644 --- a/test/controllers/webhooks_controller_test.rb +++ b/test/controllers/webhooks_controller_test.rb @@ -22,9 +22,9 @@ class WebhooksControllerTest < ActionController::TestCase GithubRepositoryManager.any_instance.stubs(:project_file_names). returns([filename_1, filename_2]) post :github, - { repository: { id: project.repository_id }, - ref_type: 'branch', - ref: "#{tracked_branch.branch_name}" } + params: { repository: { id: project.repository_id }, + ref_type: 'branch', + ref: "#{tracked_branch.branch_name}" } end it "destroys the branch" do @@ -97,7 +97,7 @@ class WebhooksControllerTest < ActionController::TestCase project.update_column(:auto_track_branches, true) new_branch_name = "a_new_branch" github_params[:ref] = "refs/head/ispyropoulos/#{new_branch_name}" - post :github, github_params + post :github, params: github_params branch = TrackedBranch.last branch.project.must_equal project @@ -109,7 +109,7 @@ class WebhooksControllerTest < ActionController::TestCase project.update_column(:auto_track_branches, false) new_branch_name = "a_new_branch" github_params[:ref] = "refs/head/ispyropoulos/#{new_branch_name}" - post :github, github_params + post :github, params: github_params branch = TrackedBranch.last branch.project.must_equal project @@ -119,7 +119,7 @@ class WebhooksControllerTest < ActionController::TestCase end it "creates a test run with correct attributes" do - post :github, github_params + post :github, params: github_params testrun = TestRun.last testrun.tracked_branch_id.must_equal tracked_branch.id @@ -128,7 +128,7 @@ class WebhooksControllerTest < ActionController::TestCase end it "responds with :ok" do - post :github, github_params + post :github, params: github_params assert_response :ok end @@ -258,7 +258,7 @@ class WebhooksControllerTest < ActionController::TestCase project.update_column(:auto_track_branches, true) new_branch_name = "a_new_branch" bitbucket_params[:push][:changes].first[:new][:name] = new_branch_name - post :bitbucket, { + post :bitbucket, params: { repository: { name: project.repository_slug } @@ -274,7 +274,7 @@ class WebhooksControllerTest < ActionController::TestCase project.update_column(:auto_track_branches, false) new_branch_name = "a_new_branch" bitbucket_params[:push][:changes].first[:new][:name] = new_branch_name - post :bitbucket, { + post :bitbucket, params: { repository: { name: project.repository_slug } @@ -288,7 +288,7 @@ class WebhooksControllerTest < ActionController::TestCase end it "creates a test run with correct attributes" do - post :bitbucket, { + post :bitbucket, params: { repository: { name: project.repository_slug } @@ -300,7 +300,7 @@ class WebhooksControllerTest < ActionController::TestCase end it "responds with :ok" do - post :bitbucket, { + post :bitbucket, params: { repository: { name: project.repository_slug } diff --git a/test/controllers/worker_groups_controller_test.rb b/test/controllers/worker_groups_controller_test.rb index fb5abddc..c4e3cc55 100644 --- a/test/controllers/worker_groups_controller_test.rb +++ b/test/controllers/worker_groups_controller_test.rb @@ -9,28 +9,29 @@ class WorkerGroupsControllerTest < ActionController::TestCase before do project.worker_groups << worker_group request.env["HTTP_REFERER"] = "previous_path" - sign_in :user, user + sign_in user, scope: :user end describe 'POST#create' do it 'allows if member of the project and flashes success' do project.members << user - post :create, { project_id: project.id } + post :create, params: { project_id: project.id } assert_response 302 flash[:alert].must_equal nil flash[:notice].must_equal "A Worker Group has been created." end it 'does not allow if not member of the project' do - -> { post :create, { project_id: project.id } }.must_raise ActiveRecord::RecordNotFound + -> { post :create, params: { project_id: project.id } }. + must_raise ActiveRecord::RecordNotFound end it "flashes validation errors" do project.members << user - post :create, { project_id: project.id, - worker_group: { friendly_name: "" } } + post :create, params: { project_id: project.id, + worker_group: { friendly_name: "" } } assert_response 302 flash[:alert].must_equal "Friendly name can't be blank" flash[:notice].must_equal nil @@ -41,9 +42,9 @@ class WorkerGroupsControllerTest < ActionController::TestCase it 'allows if member of the project' do project.members << user - put :update, { project_id: project.id, - id: project.worker_groups.first.id, - worker_group: worker_group.attributes } + put :update, params: { project_id: project.id, + id: project.worker_groups.first.id, + worker_group: worker_group.attributes } assert_response 302 flash[:alert].must_equal nil flash[:notice].must_equal "Successfully updated worker group" @@ -51,18 +52,18 @@ class WorkerGroupsControllerTest < ActionController::TestCase it 'does not allow if not member of the project' do -> { - put :update, { project_id: project.id, - id: project.worker_groups.first.id, - worker_group: worker_group.attributes } + put :update, params: { project_id: project.id, + id: project.worker_groups.first.id, + worker_group: worker_group.attributes } }.must_raise ActiveRecord::RecordNotFound end it "flashes validation errors" do project.members << user - put :update, { project_id: project.id, - id: project.worker_groups.first.id, - worker_group: { friendly_name: '' } } + put :update, params: { project_id: project.id, + id: project.worker_groups.first.id, + worker_group: { friendly_name: '' } } assert_response 302 flash[:alert].must_equal "Friendly name can't be blank" flash[:notice].must_equal nil @@ -77,18 +78,16 @@ class WorkerGroupsControllerTest < ActionController::TestCase it 'allows if member of the project' do project.members << user - post :destroy, { - project_id: project.id, - id: project.worker_groups.first.id, - worker_group: worker_group.attributes } + post :destroy, params: { project_id: project.id, + id: project.worker_groups.first.id, + worker_group: worker_group.attributes } assert_response 302 end it 'does not allow if not member of the project' do - -> { post :destroy, - project_id: project.id, - id: project.worker_groups.first.id, - worker_group: worker_group.attributes + -> { post :destroy, params: { project_id: project.id, + id: project.worker_groups.first.id, + worker_group: worker_group.attributes } }.must_raise ActiveRecord::RecordNotFound end @@ -96,10 +95,9 @@ class WorkerGroupsControllerTest < ActionController::TestCase cookies[:redirect_to_url] = "some_url" project.members << user - post :destroy, { - project_id: project.id, - id: project.worker_groups.first.id, - worker_group: worker_group.attributes } + post :destroy, params: { project_id: project.id, + id: project.worker_groups.first.id, + worker_group: worker_group.attributes } assert_response 302 cookies[:redirect_to_url].must_equal "some_url" @@ -112,10 +110,9 @@ class WorkerGroupsControllerTest < ActionController::TestCase end it 'does not allow if not member of the project' do - -> { post :reset_ssh_key, - project_id: project.id, - id: project.worker_groups.first.id, - worker_group: worker_group.attributes + -> { post :reset_ssh_key, params: { project_id: project.id, + id: project.worker_groups.first.id, + worker_group: worker_group.attributes } }.must_raise ActiveRecord::RecordNotFound end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 27c94797..880a6b98 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -20,7 +20,7 @@ # Inherits from ActiveSupport::TestCase class ActionController::TestCase - include Devise::TestHelpers + include Devise::Test::ControllerHelpers def setup # Clean everything in "test" redis database before each test @@ -73,7 +73,7 @@ class Capybara::Rails::TestCase # # uses a separate server thread, which the transactions would be hidden # from. We hence use DatabaseCleaner to truncate our test database. # @see http://stackoverflow.com/questions/10904996/difference-between-truncation-transaction-and-deletion-database-strategies - self.use_transactional_fixtures = false + self.use_transactional_tests = false before do RepositoryManager.any_instance.stubs(:post_add_repository_setup). From ef31896e14e21cfbcca7a87512f9d7cebb262670 Mon Sep 17 00:00:00 2001 From: Pavlos Kallis Date: Wed, 28 Sep 2016 19:51:41 +0300 Subject: [PATCH 3/5] Add rails-controller-testing gem to fix deprecation warnings --- Gemfile | 3 +++ Gemfile.lock | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/Gemfile b/Gemfile index 3f99cc96..51bf50ca 100644 --- a/Gemfile +++ b/Gemfile @@ -68,6 +68,9 @@ group :production do end group :test do + # As of rails 5 the `assigns` method of ActionController::TestCase is + # deprecated. To continue using it, we us the rails-controller-testing gem + gem 'rails-controller-testing' gem 'factory_girl_rails' gem 'capybara' gem 'poltergeist' diff --git a/Gemfile.lock b/Gemfile.lock index 59a39292..92432543 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -299,6 +299,10 @@ GEM bundler (>= 1.3.0, < 2.0) railties (= 5.0.0.1) sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.1) + actionpack (~> 5.x) + actionview (~> 5.x) + activesupport (~> 5.x) rails-dom-testing (2.0.1) activesupport (>= 4.2.0, < 6.0) nokogiri (~> 1.6.0) @@ -452,6 +456,7 @@ DEPENDENCIES rack-attack rack-timeout rails (~> 5.0) + rails-controller-testing rails_12factor react-bootstrap-rails react-rails (~> 1.6.0) From 5b1a54e57f0eec5a679f8af7f94029490d420f48 Mon Sep 17 00:00:00 2001 From: Pavlos Kallis Date: Wed, 28 Sep 2016 19:53:03 +0300 Subject: [PATCH 4/5] Use require_relative instead of require File.expand_path(...) --- config/application.rb | 2 +- config/environment.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/application.rb b/config/application.rb index 84062c40..786d5ca3 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' diff --git a/config/environment.rb b/config/environment.rb index ee8d90dc..426333bb 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! From 338b905d902b46a30af4ce5fb58e9daf09e91486 Mon Sep 17 00:00:00 2001 From: Pavlos Kallis Date: Wed, 28 Sep 2016 20:02:04 +0300 Subject: [PATCH 5/5] Add default configuration for rails 5.0 --- config/initializers/new_framework_defaults.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index f6e72335..254c8b15 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -7,17 +7,17 @@ # 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 +Rails.application.config.action_controller.per_form_csrf_tokens = true # Enable origin-checking CSRF mitigation. Previous versions had false. -Rails.application.config.action_controller.forgery_protection_origin_check = false +Rails.application.config.action_controller.forgery_protection_origin_check = true # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. # Previous versions had false. -ActiveSupport.to_time_preserves_timezone = false +ActiveSupport.to_time_preserves_timezone = true # Require `belongs_to` associations by default. Previous versions had false. -Rails.application.config.active_record.belongs_to_required_by_default = false +Rails.application.config.active_record.belongs_to_required_by_default = true # Do not halt callback chains when a callback returns false. Previous versions had true. -ActiveSupport.halt_callback_chains_on_return_false = true +ActiveSupport.halt_callback_chains_on_return_false = false