From 6c4e856a93cc9436dbded1f447350f6a43958153 Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Wed, 6 Jul 2016 13:44:05 +0300 Subject: [PATCH 01/11] update ruby from 2.2.2 to 2.3.0 --- .ruby-version | 2 +- .travis.yml | 2 +- Gemfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.ruby-version b/.ruby-version index 85076ae9..5c6959f6 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.2.2 \ No newline at end of file +ruby-2.3.0 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index bb24aeb5..79e4424f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: ruby rvm: - - 2.2.2 + - 2.3.0 addons: postgresql: "9.4" cache: bundler diff --git a/Gemfile b/Gemfile index 31e197bc..b1fb5c4f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -ruby '2.2.2' +ruby '2.3.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.6' From a17943689c40bb5c6667e4c08a17a679375f58be Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Wed, 6 Jul 2016 13:44:33 +0300 Subject: [PATCH 02/11] update gems and rails to v5 --- Gemfile | 23 +++-- Gemfile.lock | 247 +++++++++++++++++++++++++++++---------------------- 2 files changed, 158 insertions(+), 112 deletions(-) diff --git a/Gemfile b/Gemfile index b1fb5c4f..20e5e177 100644 --- a/Gemfile +++ b/Gemfile @@ -3,25 +3,25 @@ source 'https://rubygems.org' ruby '2.3.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.2.6' +gem 'rails', '5.0.0' # Use postgres as the database for Active Record gem 'pg' -gem 'schema_plus_pg_indexes' -gem 'schema_plus_foreign_keys' +gem 'schema_plus_core', github: 'SchemaPlus/schema_plus_core', branch: 'activerecord-5.0' +# gem 'schema_plus_foreign_keys', github: 'SchemaPlus/schema_plus_foreign_keys', branch: 'activerecord-5.0' # Add enumerize gem -gem 'enumerize' +gem 'enumerize', github: 'brainspec/enumerize', branch: 'rails-5' # Use bootstrap gem 'bootstrap-sass', '~> 3.3.6' gem 'font-awesome-sass' # Use SCSS for stylesheets -gem 'sass-rails', '~> 5.0.1' +gem 'sass-rails' #, '~> 5.0.1' # Sprokets gem 'sprockets-rails' # Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' +gem 'uglifier' #, '>= 1.3.0' # Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.2.1' +gem 'coffee-rails' #, '~> 4.1.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby gem 'haml-rails' @@ -29,6 +29,14 @@ gem 'haml-rails' # jquery form validation plugin gem 'jquery-validation-rails' gem 'activeadmin', '~> 1.0.0.pre4' +# TODO remove these once activeamdin is rails 5 ready +# activeadmin dependencies that have rails 5 support +gem 'inherited_resources', github: 'activeadmin/inherited_resources' +gem 'ransack', github: 'activerecord-hackery/ransack' +gem 'formtastic', github: 'justinfrench/formtastic' +gem 'activemodel-serializers-xml', github: 'rails/activemodel-serializers-xml' +gem 'draper', github: 'audionerd/draper', branch: 'rails5' #, ref: 'e816e0e587' +# END depedencies # Use jquery as the JavaScript library gem 'jquery-rails' @@ -99,6 +107,7 @@ group :test do gem 'timecop' gem 'shoulda-matchers', require: false gem 'codecov', require: false + gem 'rails-controller-testing' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 11d9d1c2..d39e3bb0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,24 +1,94 @@ +GIT + remote: git://github.com/SchemaPlus/schema_plus_core.git + revision: a5310a6524001549855c27cf85eb26f5afe0dc28 + branch: activerecord-5.0 + specs: + schema_plus_core (1.0.0) + activerecord (>= 4.2, < 6) + schema_monkey (~> 2.1) + +GIT + remote: git://github.com/activeadmin/inherited_resources.git + revision: d50b05f7e9e36dd45f065871e836a57a33ba4118 + specs: + inherited_resources (1.6.0) + actionpack (>= 3.2, < 5.1) + has_scope (~> 0.6) + railties (>= 3.2, < 5.1) + responders + +GIT + remote: git://github.com/activerecord-hackery/ransack.git + revision: fd94685abc0d18d30a730a57fb3dbd8aff048f7d + specs: + ransack (1.7.0) + actionpack (>= 3.0) + activerecord (>= 3.0) + activesupport (>= 3.0) + i18n + polyamorous (~> 1.3) + +GIT + remote: git://github.com/audionerd/draper.git + revision: e816e0e5876b76c648c0928f1c3f2aa2c7a3d1f2 + branch: rails5 + specs: + draper (2.1.0) + actionpack (>= 3.0) + activemodel (>= 3.0) + activesupport (>= 3.0) + request_store (~> 1.0) + +GIT + remote: git://github.com/brainspec/enumerize.git + revision: dc3c2a7dee8d30754b706329d49fe742507f6aee + branch: rails-5 + specs: + enumerize (1.1.1) + activesupport (>= 3.2) + +GIT + remote: git://github.com/justinfrench/formtastic.git + revision: f591abe68fe0d3de338425b910e4316b5dcf8fd7 + specs: + formtastic (3.2.0.pre) + actionpack (>= 4.1.0) + +GIT + remote: git://github.com/rails/activemodel-serializers-xml.git + revision: 570ee7ed33d60e44ca1f3ccbec3d1fbf61d52cbf + specs: + activemodel-serializers-xml (1.0.1) + activemodel (> 5.x) + activerecord (> 5.x) + activesupport (> 5.x) + builder (~> 3.1) + GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.6) - actionpack (= 4.2.6) - actionview (= 4.2.6) - activejob (= 4.2.6) + actioncable (5.0.0) + actionpack (= 5.0.0) + nio4r (~> 1.2) + websocket-driver (~> 0.6.1) + actionmailer (5.0.0) + actionpack (= 5.0.0) + actionview (= 5.0.0) + activejob (= 5.0.0) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.6) - actionview (= 4.2.6) - activesupport (= 4.2.6) - 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) + actionview (= 5.0.0) + activesupport (= 5.0.0) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.6) - activesupport (= 4.2.6) + actionview (5.0.0) + activesupport (= 5.0.0) 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) activeadmin (1.0.0.pre4) arbre (~> 1.0, >= 1.0.2) @@ -34,26 +104,24 @@ GEM ransack (~> 1.3) sass-rails sprockets (< 4) - activejob (4.2.6) - activesupport (= 4.2.6) - globalid (>= 0.3.0) - activemodel (4.2.6) - activesupport (= 4.2.6) - builder (~> 3.1) - activerecord (4.2.6) - activemodel (= 4.2.6) - activesupport (= 4.2.6) - arel (~> 6.0) - activesupport (4.2.6) + activejob (5.0.0) + activesupport (= 5.0.0) + globalid (>= 0.3.6) + activemodel (5.0.0) + activesupport (= 5.0.0) + activerecord (5.0.0) + activemodel (= 5.0.0) + activesupport (= 5.0.0) + arel (~> 7.0) + activesupport (5.0.0) + concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.4.0) arbre (1.1.1) activesupport (>= 3.0.0) - arel (6.0.3) + arel (7.0.0) autoprefixer-rails (6.3.7) execjs bcrypt (3.1.11) @@ -104,8 +172,6 @@ GEM docile (1.1.5) domain_name (0.5.20160615) unf (>= 0.0.5, < 1.0.0) - enumerize (2.0.0) - activesupport (>= 3.2) erubis (2.7.0) eventmachine (1.2.0.1) execjs (2.7.0) @@ -122,8 +188,6 @@ GEM thor (~> 0.14) font-awesome-sass (4.6.2) sass (>= 3.2) - formtastic (3.1.4) - actionpack (>= 3.2.13) formtastic_i18n (0.6.0) friendly_id (5.1.0) activerecord (>= 4.0.0) @@ -144,9 +208,9 @@ GEM haml (>= 4.0.6, < 5.0) html2haml (>= 1.0.1) railties (>= 4.0.1) - has_scope (0.6.0) - actionpack (>= 3.2, < 5) - activesupport (>= 3.2, < 5) + has_scope (0.7.0) + actionpack (>= 4.1, < 5.1) + activesupport (>= 4.1, < 5.1) hashdiff (0.3.0) hashie (3.4.4) heroku-deflater (0.6.2) @@ -159,13 +223,7 @@ GEM http-cookie (1.0.2) domain_name (~> 0.5) i18n (0.7.0) - inherited_resources (1.6.0) - actionpack (>= 3.2, < 5) - has_scope (~> 0.6.0.rc) - railties (>= 3.2, < 5) - responders - its-it (1.2.1) - jbuilder (2.6.0) + jbuilder (2.5.0) activesupport (>= 3.0.0, < 5.1) multi_json (~> 1.2) jquery-rails (4.1.1) @@ -177,8 +235,7 @@ GEM turbolinks jquery-ui-rails (5.0.5) railties (>= 3.2.16) - jquery-validation-rails (1.13.1) - railties (>= 3.2, < 5.0) + jquery-validation-rails (1.11.1) thor (~> 0.14) json (1.8.3) jwt (1.5.4) @@ -208,6 +265,7 @@ GEM multi_xml (0.5.5) multipart-post (2.0.0) netrc (0.11.0) + nio4r (1.2.1) nokogiri (1.6.8) mini_portile2 (~> 2.1.0) pkg-config (~> 1.1.7) @@ -239,30 +297,30 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - rack (1.6.4) + rack (2.0.1) rack-host-redirect (1.2.1) rack - rack-protection (1.5.3) - rack rack-test (0.6.3) rack (>= 1.0) - rails (4.2.6) - actionmailer (= 4.2.6) - actionpack (= 4.2.6) - actionview (= 4.2.6) - activejob (= 4.2.6) - activemodel (= 4.2.6) - activerecord (= 4.2.6) - activesupport (= 4.2.6) + rails (5.0.0) + actioncable (= 5.0.0) + actionmailer (= 5.0.0) + actionpack (= 5.0.0) + actionview (= 5.0.0) + activejob (= 5.0.0) + activemodel (= 5.0.0) + activerecord (= 5.0.0) + activesupport (= 5.0.0) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.6) - 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) + sprockets-rails (>= 2.0.0) + rails-controller-testing (0.1.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) - rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) rails_12factor (0.0.3) @@ -272,18 +330,13 @@ GEM rails_stdout_logging (0.0.5) rails_warden (0.5.8) warden (>= 1.0.0) - railties (4.2.6) - actionpack (= 4.2.6) - activesupport (= 4.2.6) + railties (5.0.0) + actionpack (= 5.0.0) + activesupport (= 5.0.0) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (11.2.2) - ransack (1.7.0) - actionpack (>= 3.0) - activerecord (>= 3.0) - activesupport (>= 3.0) - i18n - polyamorous (~> 1.2) rdoc (4.2.2) json (~> 1.4) redis (3.3.1) @@ -324,24 +377,6 @@ GEM schema_monkey (2.1.5) activerecord (>= 4.2) modware (~> 0.1) - schema_plus_core (1.0.2) - activerecord (~> 4.2) - its-it (~> 1.2) - schema_monkey (~> 2.1) - schema_plus_foreign_keys (0.1.6) - activerecord (~> 4.2) - its-it (~> 1.2) - schema_plus_core (~> 1.0) - valuable - schema_plus_indexes (0.2.3) - activerecord (~> 4.2) - its-it (~> 1.2) - schema_plus_core (~> 1.0) - schema_plus_pg_indexes (0.1.12) - activerecord (~> 4.2) - its-it (~> 1.2) - schema_plus_core (~> 1.0) - schema_plus_indexes (~> 0.1, >= 0.1.3) sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) @@ -350,23 +385,18 @@ GEM sexp_processor (4.7.0) shoulda-matchers (3.1.1) activesupport (>= 4.0.0) - sidekiq (4.1.4) + sidekiq (4.1.2) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) redis (~> 3.2, >= 3.2.1) - sinatra (>= 1.4.7) simple_form (3.2.1) actionpack (> 4, < 5.1) activemodel (> 4, < 5.1) - simplecov (0.11.2) + simplecov (0.12.0) docile (~> 1.1.0) - json (~> 1.8) + json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) - sinatra (1.4.7) - rack (~> 1.5) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) slop (3.6.0) sprockets (3.7.0) concurrent-ruby (~> 1.0) @@ -396,7 +426,6 @@ GEM unf_ext (0.0.7.2) url (0.3.2) useragent (0.16.7) - valuable (0.9.12) warden (1.2.6) rack (>= 1.0) warden_omniauth (0.1.0) @@ -406,6 +435,9 @@ GEM addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff + websocket-driver (0.6.4) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) wicked (1.3.0) railties (>= 3.0.7) xpath (2.0.0) @@ -416,6 +448,7 @@ PLATFORMS DEPENDENCIES activeadmin (~> 1.0.0.pre4) + activemodel-serializers-xml! addressable bcrypt (~> 3.1.7) better_errors @@ -426,19 +459,22 @@ DEPENDENCIES capybara chartkick codecov - coffee-rails (~> 4.2.1) + coffee-rails dalli database_cleaner - enumerize + draper! + enumerize! factory_girl_rails faker figaro font-awesome-sass + formtastic! friendly_id (~> 5.1.0) gon groupdate haml-rails heroku-deflater + inherited_resources! jbuilder (~> 2.0) jquery-rails jquery-turbolinks @@ -452,14 +488,15 @@ DEPENDENCIES pg pry rack-host-redirect - rails (= 4.2.6) + rails (= 5.0.0) + rails-controller-testing rails_12factor rails_warden + ransack! rest-client rspec-rails (~> 3.5) - sass-rails (~> 5.0.1) - schema_plus_foreign_keys - schema_plus_pg_indexes + sass-rails + schema_plus_core! sdoc (~> 0.4.0) sentry-raven shoulda-matchers @@ -470,7 +507,7 @@ DEPENDENCIES thin timecop turbolinks - uglifier (>= 1.3.0) + uglifier useragent warden_omniauth webmock From ac1f9c12cc0061122a7e0719d52e1106de6b910f Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Wed, 6 Jul 2016 13:45:06 +0300 Subject: [PATCH 03/11] change before_filter to before_action --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5c9cb484..ba8eab38 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :null_session - before_filter :set_gon + before_action :set_gon before_action :authenticate! before_action :set_raven_context From 443a37b1119166bf686ecb844e974fdd568cde8b Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Wed, 6 Jul 2016 13:45:18 +0300 Subject: [PATCH 04/11] render nothing does not work we need to call head :ok --- app/controllers/errors_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index fa71ee3a..dae3c398 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -48,7 +48,7 @@ def show def update @error.update_attributes(status: error_params[:status], resolved_at: Time.now.utc) - render nothing: true + head :ok end def notify_subscribers From 3b1e6518337d74f243371bb6c30ffc5cced3a7e5 Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Wed, 6 Jul 2016 13:46:05 +0300 Subject: [PATCH 05/11] activerecord 5 now uses distinct instead of uniq --- app/models/grouped_issue.rb | 2 +- app/models/user.rb | 2 +- app/models/website.rb | 4 ++-- lib/tasks/notification.thor | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/grouped_issue.rb b/app/models/grouped_issue.rb index 3f321864..7324b9a3 100644 --- a/app/models/grouped_issue.rb +++ b/app/models/grouped_issue.rb @@ -3,7 +3,7 @@ class GroupedIssue < ActiveRecord::Base extend FriendlyId belongs_to :website belongs_to :release - has_many :subscribers, -> { uniq }, through: :issues, foreign_key: 'group_id' + has_many :subscribers, -> { distinct }, through: :issues, foreign_key: 'group_id' has_many :issues, foreign_key: 'group_id', dependent: :destroy has_many :messages, through: :issues enumerize :level, in: [:debug, :error, :fatal, :info, :warning], default: :error diff --git a/app/models/user.rb b/app/models/user.rb index 0b3b1cf4..9fc6fe6e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ class User < ActiveRecord::Base # include the TokenGenerator extension extend Enumerize include TokenGenerator - has_many :website_members, -> { uniq }, dependent: :destroy, autosave: true + has_many :website_members, -> { distinct }, dependent: :destroy, autosave: true has_many :websites, through: :website_members has_many :invites, foreign_key: :invited_by_id diff --git a/app/models/website.rb b/app/models/website.rb index 239d1a4d..f2470ff6 100644 --- a/app/models/website.rb +++ b/app/models/website.rb @@ -8,7 +8,7 @@ class Website < ActiveRecord::Base has_many :releases, dependent: :destroy has_many :grouped_issues, dependent: :destroy has_many :integrations, dependent: :destroy - has_many :website_members, -> { uniq }, autosave: true + has_many :website_members, -> { distinct }, autosave: true has_many :users, through: :website_members has_many :invites, dependent: :destroy @@ -88,7 +88,7 @@ def check_release(version) def self.custom_report(date, field) WebsiteMember.joins(website: :grouped_issues) .where('grouped_issues.updated_at > ? AND muted = ?', date, false) - .uniq + .distinct .group_by(&:user_id) .each do |user_id, members| if field == :daily diff --git a/lib/tasks/notification.thor b/lib/tasks/notification.thor index d60ec777..762437f4 100644 --- a/lib/tasks/notification.thor +++ b/lib/tasks/notification.thor @@ -22,7 +22,7 @@ class Notification < Thor WebsiteMember.with_frequent_event .joins(website: :issues) .where('issues.created_at > ?', Time.now - 1.hour) - .uniq.find_each(batch_size: 500) do |member| + .distinct.find_each(batch_size: 500) do |member| Issue.more_than_10_errors(member) end end From e76fe405594e39561a90414a1752283f24ced43f Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Wed, 6 Jul 2016 13:46:37 +0300 Subject: [PATCH 06/11] update controller requests to a hash format --- spec/controllers/errors_controller_spec.rb | 6 ++-- spec/controllers/invites_controller_spec.rb | 4 +-- .../reset_password_controller_spec.rb | 28 +++++++++---------- spec/controllers/sessions_controller_spec.rb | 8 +++--- spec/controllers/users_controller_spec.rb | 14 +++++----- spec/controllers/websites_controller_spec.rb | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/spec/controllers/errors_controller_spec.rb b/spec/controllers/errors_controller_spec.rb index 7996ce42..c3dc236c 100644 --- a/spec/controllers/errors_controller_spec.rb +++ b/spec/controllers/errors_controller_spec.rb @@ -97,7 +97,7 @@ let(:params) { { current_issue: issue_error.id } } it 'should give error if not logged in' do - get :index, params + get :index, params: params expect(response).to have_http_status(302) end end @@ -269,7 +269,7 @@ end it 'should give error if not logged in' do - get :show, params, { epiclogger_website_id: website.id} + get :show, params: params, session: { epiclogger_website_id: website.id} expect(response).to have_http_status(302) end end @@ -297,7 +297,7 @@ context 'not logged in' do let(:params) { { status: 'resolved', id: group.id, website_id: website.id } } it 'throws unauthorized' do - get :update, params + get :update, params: params expect(response).to have_http_status(302) end end diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb index 4a69613e..5ec3f95b 100644 --- a/spec/controllers/invites_controller_spec.rb +++ b/spec/controllers/invites_controller_spec.rb @@ -75,8 +75,8 @@ context 'logged out' do it 'should redirect to errors' do - expect(get :accept, params).to redirect_to(signup_url(token: invite.token)) + expect(get :accept, params: params).to redirect_to(signup_url(token: invite.token)) end end end -end \ No newline at end of file +end diff --git a/spec/controllers/reset_password_controller_spec.rb b/spec/controllers/reset_password_controller_spec.rb index ddd02efe..48f04632 100644 --- a/spec/controllers/reset_password_controller_spec.rb +++ b/spec/controllers/reset_password_controller_spec.rb @@ -18,7 +18,7 @@ describe "POST #create" do context 'blank email field' do it "should notice and render new" do - post :create, { user: { email: '' } } + post :create, params: { user: { email: '' } } expect(flash[:alert]).to eq('Specify an email address') expect(response).to render_template('new') end @@ -29,14 +29,14 @@ it 'should generate token' do expect{ - post :create, params + post :create, params: params user.reload }.to change(user, :reset_password_token).from(nil) end it 'should update reset_password_sent_at column' do expect{ - post :create, params + post :create, params: params user.reload }.to change(user, :reset_password_sent_at).from(nil) end @@ -46,22 +46,22 @@ expect(mailer).to receive(:deliver_later) expect(UserMailer).to receive(:reset_password).with(user).and_return(mailer).once - post :create, params + post :create, params: params end it 'should redirect to login' do - expect(post :create, params).to redirect_to(login_url) + expect(post :create, params: params).to redirect_to(login_url) end it 'should flash' do - post :create, params + post :create, params: params expect(flash[:alert]).to eq('Email sent with password reset instructions') end end context 'user not found' do it "should notice and render new" do - post :create, { user: { email: 'user@not-existent.com' } } + post :create, params: { user: { email: 'user@not-existent.com' } } expect(flash[:alert]).to eq('No such user here') expect(response).to render_template('new') end @@ -71,12 +71,12 @@ describe "GET #edit" do let(:user2) { create :user, reset_password_token: 'vJq2UGPUDBZYcO7RiuxkAw', reset_password_sent_at: Time.now } it 'assigns user' do - get :edit, id: user2.reset_password_token + get :edit, params: { id: user2.reset_password_token } expect(assigns(:user)).to eq(user2) end it 'should redirect and notice' do - expect( get :edit, id: 'random-token' ).to redirect_to(login_url) + expect( get :edit, params: { id: 'random-token' } ).to redirect_to(login_url) expect(flash[:alert]).to eq('User not found') end end @@ -87,30 +87,30 @@ let(:params) { { id: user2.reset_password_token, user: { password: 'password', password_confirmation: 'password' } } } it 'assigns user' do - get :update, params + get :update, params: params expect(assigns(:user)).to eq(user2) end it 'should update password' do expect{ - put :update, params + put :update, params: params user2.reload }.to change(user2, :password_digest) end it 'should redirect' do - expect( put :update, params ).to redirect_to(login_url) + expect( put :update, params: params ).to redirect_to(login_url) end it 'should notice' do - put :update, params + put :update, params: params expect(flash[:alert]).to eq('Your password has been changed') end end context 'user not found or period expired' do it 'should redirect and notice' do - put :update, id: 'random-token' + put :update, params: { id: 'random-token' } expect(flash[:alert]).to eq("Period expired or Password don't match") end end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index f4c36093..389f08cb 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -34,21 +34,21 @@ allow(request.env['warden']).to receive(:authenticate!).and_return(user) allow(controller).to receive(:current_user).and_return(user) - post :create, params + post :create, params: params end it 'should set current_website' do - post :create, params + post :create, params: params expect(session[:epiclogger_website_id]).to eq(website.id) end it 'should redirect to create' do user2 = create :user, email: "user@email.com" - expect( post :create, user: { email: user2.email, password: user2.password } ).to redirect_to(website_wizard_path(:create)) + expect( post :create, params: { user: { email: user2.email, password: user2.password } } ).to redirect_to(website_wizard_path(:create)) end it 'should redirect to errors' do - expect( post :create, user: { email: user.email, password: user.password } ).to redirect_to(errors_path) + expect( post :create, params: { user: { email: user.email, password: user.password } } ).to redirect_to(errors_path) end end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 4ecf93cf..76d28118 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -33,12 +33,12 @@ end it "returns http success" do - get :new, params + get :new, params: params expect(response).to be_success end it "creates new user instance" do - get :new, params + get :new, params: params expect( subject.instance_variable_get(:@user).id ).to be_nil end @@ -59,12 +59,12 @@ it "returns http success" do expect{ - post :create, params + post :create, params: params }.to change(User, :count).by(1) end it "redirects to /create" do - expect( post :create, params ).to redirect_to(website_wizard_path(:create)) + expect( post :create, params: params ).to redirect_to(website_wizard_path(:create)) end end @@ -72,7 +72,7 @@ let(:params) { default_params.merge({ token: invite.token, user: { name: 'Name for user', email: 'example@email.com', password: 'password', provider: 'email' } }) } it 'should update attributes' do - post :create, params + post :create, params: params user = User.find_by_email('example@email.com') expect(user.confirmation_token).not_to be_nil @@ -84,14 +84,14 @@ expect(mailer).to receive(:deliver_later) expect(UserMailer).to receive(:email_confirmation).with(anything()).and_return(mailer).once - post :create, params + post :create, params: params end end context 'wrong creentials' do let(:params) { default_params.merge({ user: { name: 'Name for user', email: 'example@email.com', password: 'pass', provider: 'email' } }) } it 'should render #new' do - expect( post :create, params ).to render_template(:new) + expect( post :create, params: params ).to render_template(:new) end end end diff --git a/spec/controllers/websites_controller_spec.rb b/spec/controllers/websites_controller_spec.rb index 02dd6c00..2d9c5212 100644 --- a/spec/controllers/websites_controller_spec.rb +++ b/spec/controllers/websites_controller_spec.rb @@ -61,7 +61,7 @@ end it 'gives error if not logged in' do - delete :destroy, params + delete :destroy, params: params expect(response).to have_http_status(302) end end From 162f7ff2cf51cddecdfd01ff4b1f41847ef67653 Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Wed, 6 Jul 2016 13:47:21 +0300 Subject: [PATCH 07/11] update core rails files to their rails 5 versions --- bin/rails | 6 +-- bin/rake | 4 -- bin/setup | 29 +++++++----- bin/update | 29 ++++++++++++ config/application.rb | 5 +- config/boot.rb | 2 +- config/cable.yml | 9 ++++ config/environment.rb | 2 +- config/environments/development.rb | 37 +++++++++++---- config/environments/production.rb | 39 +++++++++------ config/environments/test.rb | 19 ++++---- .../application_controller_renderer.rb | 6 +++ config/initializers/cookies_serializer.rb | 2 + config/initializers/new_framework_defaults.rb | 23 +++++++++ config/initializers/wrap_parameters.rb | 4 +- config/puma.rb | 47 +++++++++++++++++++ config/secrets.yml | 6 +-- config/spring.rb | 6 +++ 18 files changed, 209 insertions(+), 66 deletions(-) create mode 100755 bin/update create mode 100644 config/cable.yml create mode 100644 config/initializers/application_controller_renderer.rb create mode 100644 config/initializers/new_framework_defaults.rb create mode 100644 config/puma.rb create mode 100644 config/spring.rb diff --git a/bin/rails b/bin/rails index 4d608ede..07396602 100755 --- a/bin/rails +++ b/bin/rails @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path("../spring", __FILE__) -rescue LoadError -end -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 8017a027..17240489 100755 --- a/bin/rake +++ b/bin/rake @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path("../spring", __FILE__) -rescue LoadError -end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/setup b/bin/setup index acdb2c13..e620b4da 100755 --- a/bin/setup +++ b/bin/setup @@ -1,29 +1,34 @@ #!/usr/bin/env ruby require 'pathname' +require 'fileutils' +include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) -Dir.chdir APP_ROOT do +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do # This script is a starting point to setup your application. - # Add necessary setup steps to this file: + # Add necessary setup steps to this file. - puts "== Installing dependencies ==" - system "gem install bundler --conservative" - system "bundle check || bundle install" + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # system "cp config/database.yml.sample config/database.yml" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system "bin/rake db:setup" + system! 'bin/rails db:setup' puts "\n== Removing old logs and tempfiles ==" - system "rm -f log/*" - system "rm -rf tmp/cache" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system "touch tmp/restart.txt" + system! 'bin/rails restart' end diff --git a/bin/update b/bin/update new file mode 100755 index 00000000..a8e4462f --- /dev/null +++ b/bin/update @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/config/application.rb b/config/application.rb index 5e337782..aba275ee 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' @@ -30,9 +30,6 @@ class Application < Rails::Application password: ENV['MEMCACHEDCLOUD_PASSWORD'] } - # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true - config.action_dispatch.default_headers.merge!({ 'Access-Control-Allow-Origin' => '*', 'Access-Control-Request-Method' => '*' diff --git a/config/boot.rb b/config/boot.rb index 6b750f00..30f5120d 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 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/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! diff --git a/config/environments/development.rb b/config/environments/development.rb index 55f6d909..b439c076 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -9,13 +9,28 @@ # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=172800' + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + config.action_mailer.perform_caching = false + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -27,14 +42,16 @@ # number of complex assets. config.assets.debug = true - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + # config.file_watcher = ActiveSupport::EventedFileUpdateChecker - # Adds additional error checking when serving assets at runtime. - # Checks for improperly declared sprockets dependencies. - # Raises helpful error messages. - config.assets.raise_runtime_errors = true config.action_mailer.delivery_method = :letter_opener config.action_mailer.perform_deliveries = true config.action_mailer.preview_path = "#{Rails.root}/spec/mailer_previews" diff --git a/config/environments/production.rb b/config/environments/production.rb index 3ac58d1d..dfc8176b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,15 +14,9 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true - # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.serve_static_files = 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 @@ -37,10 +31,18 @@ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true @@ -49,16 +51,15 @@ config.log_level = :debug # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "epiclogger_#{Rails.env}" + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. @@ -74,11 +75,19 @@ # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false config.action_mailer.default_url_options = { host: ENV['MAILER_HOST'] } - # config.action_mailer.delivery_method = :postmark - # config.action_mailer.postmark_settings = { :api_key => ENV['POSTMARK_API_KEY']} config.action_mailer.smtp_settings = { address: ENV['SMTP_SERVER'], diff --git a/config/environments/test.rb b/config/environments/test.rb index bf16602e..ba9c4b14 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,9 +12,11 @@ # preloads Rails for running tests, you may have to set it to true. 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' + # Configure public file server for tests with Cache-Control for performance. + 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 @@ -25,21 +27,20 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Randomize the order test cases are executed. - config.active_support.test_order = :random - config.action_mailer.default_url_options = { host: ENV['MAILER_HOST'] } - # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - config.cache_store = :null_store - # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + + # Randomize the order test cases are executed. + config.active_support.test_order = :random + config.action_mailer.default_url_options = { host: ENV['MAILER_HOST'] } end 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/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7f70458d..5a6a32d3 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ # Be sure to restart your server when you modify this file. +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb new file mode 100644 index 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/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 33725e95..bbfc3961 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -5,10 +5,10 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] if respond_to?(:wrap_parameters) + wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do -# self.include_root_in_json = true +# self.include_root_in_json = true # end diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 00000000..c7f311f8 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,47 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum, this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests, default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted this block will be run, if you are using `preload_app!` +# option you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/secrets.yml b/config/secrets.yml index aacf22a9..35b8bf4b 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -5,16 +5,16 @@ # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -# You can use `rake secret` to generate a secure secret key. +# You can use `rails secret` to generate a secure secret key. # Make sure the secrets in this file are kept private # if you're sharing your code publicly. development: - secret_key_base: df48760d3d34db6cd6685c50a9140cf14c573627a0c1dd797152f9f68d4774e9f3d0876c8fc16c8e14a3ce844933a1c27c2a791847c8b63c97a131320410dd46 + secret_key_base: 90a75d90c45132de0e8aa42c5dc866436ab9d1bd94f7cadea5c881fbf06121e9e76fde973738d384addf4235aff0b019384caf4292e3382188d0788254fc582b test: - secret_key_base: 15f25491edff01e977bb89970497635f30b30f4a10135b8f8252e2032fb30d8c7fd94c954372df9db7e5463e42e6b3d2964d25ad84a579bdd5c98ab4b5ea5883 + secret_key_base: f2bba2b6fae18eb47aff5baa16966d2aa5e8ae2d60efef5995e4fa796950b5505c8e0c8bee49636d7fb95d61155f6168bc024eeafa33ce9af08928fe2ffa2179 # Do not keep production secrets in the repository, # instead read values from the environment. 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) } From a9df8730c4f7d2c056761cfbf600a32a80643443 Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Wed, 6 Jul 2016 13:48:00 +0300 Subject: [PATCH 08/11] returning false on model callbaks does not stop the chain we need to use throw :abort --- app/models/website_member.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/website_member.rb b/app/models/website_member.rb index 025288cd..fa535864 100644 --- a/app/models/website_member.rb +++ b/app/models/website_member.rb @@ -14,14 +14,14 @@ def valid_url valid = (self.website.domain =~ /\A#{URI::regexp(['http', 'https'])}\z/).nil? return true unless valid errors.add :domain, 'Invalid url' if valid - false + throw :abort end def validate_destroy owners = WebsiteMember.with_role(:owner).where('website_id=?', website.id) if owners.count == 1 && website.website_members.count == 1 errors.add :base, 'Website must have at least one owner' - return false + throw :abort end return true end From f9cc26382cd156cf22d55bf1ae232569aaf9bead Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Wed, 6 Jul 2016 13:48:15 +0300 Subject: [PATCH 09/11] update passenger status service agent --- bin/passenger-status-service-agent | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/passenger-status-service-agent diff --git a/bin/passenger-status-service-agent b/bin/passenger-status-service-agent old mode 100644 new mode 100755 From 5673c7cf2a7893f411aa85e0591fd5ca086972e3 Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Wed, 6 Jul 2016 13:48:28 +0300 Subject: [PATCH 10/11] update auth_helper to use the hash format for process --- spec/support/auth_helper.rb | 2 +- spec/support/warden.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/support/auth_helper.rb b/spec/support/auth_helper.rb index 47eb8ef7..f41e70e3 100644 --- a/spec/support/auth_helper.rb +++ b/spec/support/auth_helper.rb @@ -1,7 +1,7 @@ module Authorization def request_with(user, http_method, action, parameters = {}, session = {}, flash = {} ) warden.set_user user - process action, http_method.to_s.upcase, parameters, session, flash + process action, method: http_method.to_s.upcase, params: parameters, session: session, flash: flash end [:get, :put, :post, :delete].each do |method| diff --git a/spec/support/warden.rb b/spec/support/warden.rb index 8208c528..73d6816b 100644 --- a/spec/support/warden.rb +++ b/spec/support/warden.rb @@ -38,12 +38,12 @@ def _catch_warden(&block) if result.is_a?(Hash) && !warden.custom_failure? && !@controller.send(:performed?) result[:action] ||= :unauthenticated - env = @controller.request.env - env['PATH_INFO'] = "/#{result[:action]}" - env['warden.options'] = result - Warden::Manager._run_callbacks(:before_failure, env, result) + request_env = @controller.request.env + request_env['PATH_INFO'] = "/#{result[:action]}" + request_env['warden.options'] = result + Warden::Manager._run_callbacks(:before_failure, request_env, result) - status, headers, body = warden.config[:failure_app].call(env).to_a + status, headers, body = warden.config[:failure_app].call(request_env).to_a @controller.send :render, :status => status, :text => body, :content_type => headers['Content-Type'], :location => headers['Location'] From 2f4601deb8e23e837aec3c6b2a365621dac38347 Mon Sep 17 00:00:00 2001 From: Razvan Ciocanel Date: Fri, 12 Aug 2016 10:52:12 +0300 Subject: [PATCH 11/11] enumerize supports rails 5 now, and friendly_id uses the master branch - also updated activeadmin to use the master branch as that has rails 5 support --- Gemfile | 10 ++--- Gemfile.lock | 105 ++++++++++++++++++--------------------------------- 2 files changed, 40 insertions(+), 75 deletions(-) diff --git a/Gemfile b/Gemfile index 20e5e177..1389cf98 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem 'pg' gem 'schema_plus_core', github: 'SchemaPlus/schema_plus_core', branch: 'activerecord-5.0' # gem 'schema_plus_foreign_keys', github: 'SchemaPlus/schema_plus_foreign_keys', branch: 'activerecord-5.0' # Add enumerize gem -gem 'enumerize', github: 'brainspec/enumerize', branch: 'rails-5' +gem 'enumerize' # Use bootstrap gem 'bootstrap-sass', '~> 3.3.6' @@ -28,14 +28,10 @@ gem 'haml-rails' # jquery form validation plugin gem 'jquery-validation-rails' -gem 'activeadmin', '~> 1.0.0.pre4' +gem 'activeadmin', github: 'activeadmin' # TODO remove these once activeamdin is rails 5 ready # activeadmin dependencies that have rails 5 support gem 'inherited_resources', github: 'activeadmin/inherited_resources' -gem 'ransack', github: 'activerecord-hackery/ransack' -gem 'formtastic', github: 'justinfrench/formtastic' -gem 'activemodel-serializers-xml', github: 'rails/activemodel-serializers-xml' -gem 'draper', github: 'audionerd/draper', branch: 'rails5' #, ref: 'e816e0e587' # END depedencies # Use jquery as the JavaScript library @@ -82,7 +78,7 @@ gem 'useragent' gem 'addressable' #better urls -gem 'friendly_id', '~> 5.1.0' +gem 'friendly_id', github: 'norman/friendly_id' #group objects by time frames gem 'groupdate' diff --git a/Gemfile.lock b/Gemfile.lock index d39e3bb0..a84e21b0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,6 +7,25 @@ GIT activerecord (>= 4.2, < 6) schema_monkey (~> 2.1) +GIT + remote: git://github.com/activeadmin/activeadmin.git + revision: 15820510e4ba3c81dbfeb966f237380123304404 + specs: + activeadmin (1.0.0.pre4) + arbre (~> 1.0, >= 1.0.2) + bourbon + coffee-rails + formtastic (~> 3.1) + formtastic_i18n + inherited_resources (~> 1.6) + jquery-rails + jquery-ui-rails + kaminari (~> 0.15) + railties (>= 3.2, < 5.1) + ransack (~> 1.3) + sass-rails + sprockets (< 4.1) + GIT remote: git://github.com/activeadmin/inherited_resources.git revision: d50b05f7e9e36dd45f065871e836a57a33ba4118 @@ -18,51 +37,11 @@ GIT responders GIT - remote: git://github.com/activerecord-hackery/ransack.git - revision: fd94685abc0d18d30a730a57fb3dbd8aff048f7d - specs: - ransack (1.7.0) - actionpack (>= 3.0) - activerecord (>= 3.0) - activesupport (>= 3.0) - i18n - polyamorous (~> 1.3) - -GIT - remote: git://github.com/audionerd/draper.git - revision: e816e0e5876b76c648c0928f1c3f2aa2c7a3d1f2 - branch: rails5 - specs: - draper (2.1.0) - actionpack (>= 3.0) - activemodel (>= 3.0) - activesupport (>= 3.0) - request_store (~> 1.0) - -GIT - remote: git://github.com/brainspec/enumerize.git - revision: dc3c2a7dee8d30754b706329d49fe742507f6aee - branch: rails-5 + remote: git://github.com/norman/friendly_id.git + revision: aff0564584e84ffa505e6e278b65ca3c4ee5d698 specs: - enumerize (1.1.1) - activesupport (>= 3.2) - -GIT - remote: git://github.com/justinfrench/formtastic.git - revision: f591abe68fe0d3de338425b910e4316b5dcf8fd7 - specs: - formtastic (3.2.0.pre) - actionpack (>= 4.1.0) - -GIT - remote: git://github.com/rails/activemodel-serializers-xml.git - revision: 570ee7ed33d60e44ca1f3ccbec3d1fbf61d52cbf - specs: - activemodel-serializers-xml (1.0.1) - activemodel (> 5.x) - activerecord (> 5.x) - activesupport (> 5.x) - builder (~> 3.1) + friendly_id (5.2.0.beta.1) + activerecord (>= 4.0.0) GEM remote: https://rubygems.org/ @@ -90,20 +69,6 @@ GEM erubis (~> 2.7.0) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activeadmin (1.0.0.pre4) - arbre (~> 1.0, >= 1.0.2) - bourbon - coffee-rails - formtastic (~> 3.1) - formtastic_i18n - inherited_resources (~> 1.6) - jquery-rails - jquery-ui-rails - kaminari (~> 0.15) - rails (>= 3.2, < 5.1) - ransack (~> 1.3) - sass-rails - sprockets (< 4) activejob (5.0.0) activesupport (= 5.0.0) globalid (>= 0.3.6) @@ -172,6 +137,8 @@ GEM docile (1.1.5) domain_name (0.5.20160615) unf (>= 0.0.5, < 1.0.0) + enumerize (2.0.0) + activesupport (>= 3.2) erubis (2.7.0) eventmachine (1.2.0.1) execjs (2.7.0) @@ -188,9 +155,9 @@ GEM thor (~> 0.14) font-awesome-sass (4.6.2) sass (>= 3.2) + formtastic (3.1.4) + actionpack (>= 3.2.13) formtastic_i18n (0.6.0) - friendly_id (5.1.0) - activerecord (>= 4.0.0) globalid (0.3.6) activesupport (>= 4.1.0) gon (6.1.0) @@ -291,7 +258,7 @@ GEM rake (>= 0.8.1) pg (0.18.4) pkg-config (1.1.7) - polyamorous (1.3.0) + polyamorous (1.3.1) activerecord (>= 3.0) pry (0.10.4) coderay (~> 1.1.0) @@ -337,6 +304,12 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (11.2.2) + ransack (1.8.2) + actionpack (>= 3.0) + activerecord (>= 3.0) + activesupport (>= 3.0) + i18n + polyamorous (~> 1.3) rdoc (4.2.2) json (~> 1.4) redis (3.3.1) @@ -447,8 +420,7 @@ PLATFORMS ruby DEPENDENCIES - activeadmin (~> 1.0.0.pre4) - activemodel-serializers-xml! + activeadmin! addressable bcrypt (~> 3.1.7) better_errors @@ -462,14 +434,12 @@ DEPENDENCIES coffee-rails dalli database_cleaner - draper! - enumerize! + enumerize factory_girl_rails faker figaro font-awesome-sass - formtastic! - friendly_id (~> 5.1.0) + friendly_id! gon groupdate haml-rails @@ -492,7 +462,6 @@ DEPENDENCIES rails-controller-testing rails_12factor rails_warden - ransack! rest-client rspec-rails (~> 3.5) sass-rails