From 9f7f14eab647fd414e30f66b22c34b035c1a09ab Mon Sep 17 00:00:00 2001 From: Vincent Martinez Date: Tue, 28 Feb 2017 14:46:00 +0000 Subject: [PATCH 1/3] Update to rails 4.2.8 (ruby 2.4.0) --- .ruby-version | 2 +- Dockerfile | 2 +- Gemfile | 14 +- Gemfile.lock | 207 +++++++++--------- app/assets/javascripts/application.js | 2 +- spec/requests/api/actions_spec.rb | 2 +- spec/requests/api/braintree/braintree_spec.rb | 2 +- .../api/go_cardless/go_cardless_spec.rb | 2 +- 8 files changed, 112 insertions(+), 121 deletions(-) diff --git a/.ruby-version b/.ruby-version index 0bee604df..197c4d5c2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.3 +2.4.0 diff --git a/Dockerfile b/Dockerfile index f30280090..f90191e81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.3.3 +FROM ruby:2.4.0 # With --build-arg ci=false we'll skip the bundle install part ARG ci diff --git a/Gemfile b/Gemfile index faf63c105..4fae6053d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,9 @@ # coding: utf-8 # frozen_string_literal: true source 'https://rubygems.org' -ruby '2.3.3' +ruby '2.4.0' -gem 'rails', '4.2.7.1' +gem 'rails', '4.2.8' gem 'rake' gem 'rails-observers' gem 'readthis' @@ -34,7 +34,7 @@ gem 'liquid' gem 'remotipart', '~> 1.2' # [Q] Are we using this? gem 'devise' gem 'omniauth-google-oauth2' -gem 'activeadmin', github: 'activeadmin' +gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin' gem 'country_select' gem 'kaminari' @@ -58,14 +58,12 @@ gem 'config' gem 'twilio-ruby' gem 'metamagic' gem 'jwt' -gem 'actionkit_connector', github: 'SumOfUs/actionkit_connector', branch: 'master' +gem 'actionkit_connector', git: 'https://github.com/SumOfUs/actionkit_connector', branch: 'master' gem 'airbrake', '~> 5.7.1' gem 'envyable', require: 'envyable/rails-now' gem 'webpack-rails' gem 'bootstrap-sass', '~> 3.3.5' -# Sprockets 3 breaks Teaspoon. -# see https://github.com/modeset/teaspoon/issues/443 -gem 'sprockets-rails', '< 3.0' +gem 'sprockets-rails' gem 'compass-rails', '~> 3.0.2' # was using git master branch before gem 'sass-rails', '~> 5.0.6' gem 'uglifier', '>= 1.3.0' @@ -80,8 +78,6 @@ group :development, :test do gem 'factory_girl_rails' gem 'faker' gem 'vcr' - gem 'teaspoon' - gem 'teaspoon-mocha' gem 'magic_lamp' gem 'spring-commands-rspec' end diff --git a/Gemfile.lock b/Gemfile.lock index aa1159815..031db9020 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,16 +1,24 @@ GIT - remote: git://github.com/SumOfUs/actionkit_connector.git - revision: 4f822b6de92807f3e654b5c4b6724577c99fe1c3 + remote: https://github.com/SumOfUs/actionkit_connector + revision: b7bc0fb73a7d150ac21c5e4c60749a51b5278d63 branch: master specs: actionkit_connector (0.4.4) httparty (~> 0.13) GIT - remote: git://github.com/activeadmin/activeadmin.git - revision: 0ac35b7ff05246c3bc143c74fab38c4fdc0e875b + remote: https://github.com/SumOfUs/share_progress + revision: f0bf6adc386996355bd3a9f706f7953d63f11c29 + branch: master + specs: + share_progress (0.2.0) + httparty (>= 0.13) + +GIT + remote: https://github.com/activeadmin/activeadmin + revision: 6966a84c950b0c86f713548e78587ea659e13c55 specs: - activeadmin (1.0.0.pre2) + activeadmin (1.0.0.pre4) arbre (~> 1.0, >= 1.0.2) bourbon coffee-rails @@ -19,19 +27,11 @@ GIT inherited_resources (~> 1.6) jquery-rails jquery-ui-rails - kaminari (~> 0.15) - rails (>= 3.2, < 5.0) + kaminari (>= 0.15, < 2.0) + railties (>= 3.2, < 5.1) ransack (~> 1.3) sass-rails - sprockets (< 4) - -GIT - remote: https://github.com/SumOfUs/share_progress - revision: f0bf6adc386996355bd3a9f706f7953d63f11c29 - branch: master - specs: - share_progress (0.2.0) - httparty (>= 0.13) + sprockets (< 4.1) GEM remote: https://rubygems.org/ @@ -41,51 +41,51 @@ GEM action_parameter (0.0.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - actionmailer (4.2.7.1) - actionpack (= 4.2.7.1) - actionview (= 4.2.7.1) - activejob (= 4.2.7.1) + actionmailer (4.2.8) + actionpack (= 4.2.8) + actionview (= 4.2.8) + activejob (= 4.2.8) 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) + actionpack (4.2.8) + actionview (= 4.2.8) + activesupport (= 4.2.8) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.7.1) - activesupport (= 4.2.7.1) + actionview (4.2.8) + activesupport (= 4.2.8) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.7.1) - activesupport (= 4.2.7.1) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (4.2.8) + activesupport (= 4.2.8) globalid (>= 0.3.0) - activemodel (4.2.7.1) - activesupport (= 4.2.7.1) + activemodel (4.2.8) + activesupport (= 4.2.8) builder (~> 3.1) - activerecord (4.2.7.1) - activemodel (= 4.2.7.1) - activesupport (= 4.2.7.1) + activerecord (4.2.8) + activemodel (= 4.2.8) + activesupport (= 4.2.8) arel (~> 6.0) - activesupport (4.2.7.1) + activesupport (4.2.8) 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) + addressable (2.5.0) + public_suffix (~> 2.0, >= 2.0.2) airbrake (5.7.1) airbrake-ruby (~> 1.7) airbrake-ruby (1.8.0) annotate (2.7.1) activerecord (>= 3.2, < 6.0) rake (>= 10.4, < 12.0) - arbre (1.0.3) + arbre (1.1.1) activesupport (>= 3.0.0) - arel (6.0.3) + arel (6.0.4) ast (2.3.0) autoprefixer-rails (6.3.6.2) execjs @@ -104,7 +104,7 @@ GEM bootstrap-sass (3.3.6) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) - bourbon (4.2.7) + bourbon (4.3.3) sass (~> 3.4) thor (~> 0.19) braintree (2.54.0) @@ -113,7 +113,7 @@ GEM browserify-rails (2.2.1) railties (>= 4.0.0, < 5.0) sprockets (> 3.0.2) - builder (3.2.2) + builder (3.2.3) byebug (9.0.5) capybara (2.7.1) addressable @@ -153,7 +153,7 @@ GEM compass (~> 1.0.0) sass-rails (< 5.1) sprockets (< 4.0) - concurrent-ruby (1.0.2) + concurrent-ruby (1.0.5) config (1.2.1) activesupport (>= 3.0) deep_merge (~> 1.0, >= 1.0.1) @@ -164,12 +164,12 @@ GEM country_select (2.5.2) countries (~> 1.2.0) sort_alphabetical (~> 1.0) - coveralls (0.8.13) - json (~> 1.8) - simplecov (~> 0.11.0) + coveralls (0.8.19) + json (>= 1.8, < 3) + simplecov (~> 0.12.0) term-ansicolor (~> 1.3) thor (~> 0.19.1) - tins (~> 1.6.0) + tins (~> 1.6) crack (0.4.3) safe_yaml (~> 1.0.0) currencies (0.4.2) @@ -202,7 +202,7 @@ GEM foreman (0.82.0) thor (~> 0.19.1) formatador (0.2.5) - formtastic (3.1.4) + formtastic (3.1.5) actionpack (>= 3.2.13) formtastic_i18n (0.6.0) friendly_id (5.1.0) @@ -228,10 +228,10 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - has_scope (0.6.0) - actionpack (>= 3.2, < 5) - activesupport (>= 3.2, < 5) - hashdiff (0.3.0) + has_scope (0.7.0) + actionpack (>= 4.1, < 5.1) + activesupport (>= 4.1, < 5.1) + hashdiff (0.3.2) hashie (3.4.4) hiredis (0.6.1) httparty (0.13.7) @@ -241,10 +241,10 @@ GEM i18n-js (3.0.0.rc14) i18n (~> 0.6, >= 0.6.6) i18n_data (0.7.0) - inherited_resources (1.6.0) - actionpack (>= 3.2, < 5) - has_scope (~> 0.6.0.rc) - railties (>= 3.2, < 5) + inherited_resources (1.7.0) + actionpack (>= 3.2, < 5.1) + has_scope (~> 0.6) + railties (>= 3.2, < 5.1) responders jbuilder (2.5.0) activesupport (>= 3.0.0, < 5.1) @@ -254,9 +254,9 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (5.0.5) + jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (1.8.3) + json (1.8.6) jwt (1.5.4) kaminari (0.17.0) actionpack (>= 3.0.0) @@ -288,16 +288,16 @@ GEM mime-types-data (3.2016.0521) mimemagic (0.3.2) mini_portile2 (2.1.0) - minitest (5.9.1) - money (6.7.1) + minitest (5.10.1) + money (6.8.1) i18n (>= 0.6.4, <= 0.7.0) sixarm_ruby_unaccent (>= 1.1.1, < 2) multi_json (1.12.1) multi_xml (0.5.5) multipart-post (2.0.0) nenv (0.3.0) - newrelic_rpm (3.15.2.317) - nokogiri (1.6.8.1) + newrelic_rpm (3.18.1.330) + nokogiri (1.7.0.1) mini_portile2 (~> 2.1.0) notiffany (0.1.0) nenv (~> 0.1) @@ -330,7 +330,7 @@ GEM cocaine (~> 0.5.5) mime-types mimemagic (~> 0.3.0) - parser (2.3.1.2) + parser (2.4.0.0) ast (~> 2.2) pg (0.18.4) phony (2.15.40) @@ -338,28 +338,29 @@ GEM capybara (~> 2.1) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) - polyamorous (1.3.0) + polyamorous (1.3.1) activerecord (>= 3.0) powerpack (0.1.1) pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) + public_suffix (2.0.5) puma (2.15.3) - rack (1.6.4) + rack (1.6.5) rack-cors (0.4.0) rack-test (0.6.3) rack (>= 1.0) - 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) + rails (4.2.8) + actionmailer (= 4.2.8) + actionpack (= 4.2.8) + actionview (= 4.2.8) + activejob (= 4.2.8) + activemodel (= 4.2.8) + activerecord (= 4.2.8) + activesupport (= 4.2.8) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.7.1) + railties (= 4.2.8) sprockets-rails rails-assets-backbone (1.3.3) rails-assets-underscore (>= 1.8.3) @@ -377,9 +378,9 @@ GEM rails-assets-underscore (1.8.3) rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) + rails-dom-testing (1.0.8) activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) + nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) @@ -388,19 +389,19 @@ GEM railties (~> 4.0) rails-observers (0.1.2) activemodel (~> 4.0) - railties (4.2.7.1) - actionpack (= 4.2.7.1) - activesupport (= 4.2.7.1) + railties (4.2.8) + actionpack (= 4.2.8) + activesupport (= 4.2.8) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rainbow (2.1.0) + rainbow (2.2.1) rake (11.3.0) - ransack (1.7.0) + ransack (1.8.2) actionpack (>= 3.0) activerecord (>= 3.0) activesupport (>= 3.0) i18n - polyamorous (~> 1.2) + polyamorous (~> 1.3) rb-fsevent (0.9.7) rb-inotify (0.9.7) ffi (>= 0.5.0) @@ -409,7 +410,7 @@ GEM readthis (1.3.0) connection_pool (~> 2.1) redis (~> 3.0) - redis (3.3.0) + redis (3.3.3) remotipart (1.2.1) request_store (1.3.1) responders (2.2.0) @@ -437,8 +438,8 @@ GEM rspec-mocks (~> 3.4.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) - rubocop (0.41.2) - parser (>= 2.3.1.1, < 3.0) + rubocop (0.47.1) + parser (>= 2.3.3.1, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) @@ -458,9 +459,9 @@ GEM rdoc (~> 4.0) selectize-rails (0.12.1) shellany (0.0.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) sixarm_ruby_unaccent (1.1.1) @@ -477,28 +478,24 @@ GEM spring (1.7.1) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (3.7.0) + sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) + sprockets-rails (3.2.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) summernote-rails (0.8.1.1) railties (>= 3.1) - teaspoon (1.1.5) - railties (>= 3.2.5, < 6) - teaspoon-mocha (2.3.3) - teaspoon (>= 1.0.0) temple (0.7.7) - term-ansicolor (1.3.2) + term-ansicolor (1.4.0) tins (~> 1.0) terminal-notifier-guard (1.7.0) - thor (0.19.1) - thread_safe (0.3.5) + thor (0.19.4) + thread_safe (0.3.6) tilt (2.0.5) timecop (0.8.1) - tins (1.6.0) + tins (1.13.2) twilio-ruby (4.13.0) builder (>= 2.1.2) jwt (~> 1.0) @@ -507,7 +504,7 @@ GEM thread_safe (~> 0.1) uglifier (3.0.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.1.0) + unicode-display_width (1.1.3) unicode_utils (1.4.0) vcr (3.0.3) warden (1.2.6) @@ -517,7 +514,7 @@ GEM binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) - webmock (2.1.0) + webmock (2.3.2) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff @@ -589,7 +586,7 @@ DEPENDENCIES poltergeist puma (~> 2.15.3) rack-cors - rails (= 4.2.7.1) + rails (= 4.2.8) rails-assets-backbone! rails-assets-braintree-web! rails-assets-chai-jquery! @@ -618,10 +615,8 @@ DEPENDENCIES slim-rails (~> 3.1.1) spring spring-commands-rspec - sprockets-rails (< 3.0) + sprockets-rails summernote-rails - teaspoon - teaspoon-mocha terminal-notifier-guard timecop twilio-ruby @@ -632,7 +627,7 @@ DEPENDENCIES webpack-rails RUBY VERSION - ruby 2.3.3p222 + ruby 2.4.0p0 BUNDLED WITH - 1.13.6 + 1.13.7 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 95dfef90d..1592fab24 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,7 +14,7 @@ //= require jquery_ujs //= require underscore //= require backbone -//= require jquery-ui/sortable +//= require jquery-ui/widgets/sortable //= require jquery.remotipart //= require d3 //= require odometer diff --git a/spec/requests/api/actions_spec.rb b/spec/requests/api/actions_spec.rb index d05eaa279..5049e0d02 100644 --- a/spec/requests/api/actions_spec.rb +++ b/spec/requests/api/actions_spec.rb @@ -48,7 +48,7 @@ created_at: be_within(1.second).of(Time.now), country: 'France', subscribed_member: true, - action_id: instance_of(Fixnum)), + action_id: instance_of(Integer)), params: hash_including(page: 'foo-bar-petition', email: 'hello@example.com', diff --git a/spec/requests/api/braintree/braintree_spec.rb b/spec/requests/api/braintree/braintree_spec.rb index 5deea1704..ff8ed3529 100644 --- a/spec/requests/api/braintree/braintree_spec.rb +++ b/spec/requests/api/braintree/braintree_spec.rb @@ -280,7 +280,7 @@ first_name: 'Bernie', last_name: 'Sanders', country: 'United States', - action_id: instance_of(Fixnum)) + action_id: instance_of(Integer)) end let(:action_express_donation) { 0 } diff --git a/spec/requests/api/go_cardless/go_cardless_spec.rb b/spec/requests/api/go_cardless/go_cardless_spec.rb index 48da41d7b..dd4de7986 100644 --- a/spec/requests/api/go_cardless/go_cardless_spec.rb +++ b/spec/requests/api/go_cardless/go_cardless_spec.rb @@ -20,7 +20,7 @@ slug: 'foo-bar', first_name: 'Bernie', last_name: 'Sanders', - action_id: instance_of(Fixnum), + action_id: instance_of(Integer), created_at: be_within(30.seconds).of(Time.now), country: 'United States') end From 8f32651debe5acd0a16dd4753f93df9d7a0ce685 Mon Sep 17 00:00:00 2001 From: Vincent Martinez Date: Tue, 28 Feb 2017 20:25:51 +0000 Subject: [PATCH 2/3] [rubocop] Run autocorrect and fix other issues --- .rubocop.yml | 11 +- .rubocop_todo.yml | 11 ++ Gemfile | 108 +++++++++--------- app/controllers/plugins/forms_controller.rb | 2 +- app/helpers/layout_select_helper.rb | 2 +- app/liquid/champaign_liquid_filters.rb | 2 +- app/liquid/liquid_helper.rb | 2 +- app/models/form.rb | 2 +- app/models/link.rb | 2 +- app/models/page.rb | 4 +- app/models/payment/braintree.rb | 20 ++-- app/models/plugins/fundraiser.rb | 2 +- app/models/plugins/has_form.rb | 2 +- app/models/share/email.rb | 2 +- app/models/share/twitter.rb | 2 +- app/services/page_updater.rb | 30 ++--- .../share_progress_variant_builder.rb | 2 +- config/initializers/airbrake.rb | 96 ++++++++-------- ...dd_master_and_position_to_form_elements.rb | 2 +- lib/action_kit/helper.rb | 2 +- lib/liquid_markup_seeder.rb | 2 +- .../braintree/error_processing.rb | 2 +- .../braintree/one_click_from_uri.rb | 2 +- .../braintree/subscription.rb | 4 +- .../go_cardless/populator.rb | 2 +- lib/tasks/sumofus.rake | 6 +- spec/models/link_spec.rb | 2 +- .../api/go_cardless/go_cardless_spec.rb | 2 +- .../share_progress_variant_builder_spec.rb | 2 +- 29 files changed, 170 insertions(+), 160 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4a1663d5a..c60c13fa2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,7 @@ inherit_from: .rubocop_todo.yml AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.4 Exclude: - 'bin/**/*' - 'db/schema.rb' @@ -28,12 +28,6 @@ Style/MultilineMethodCallIndentation: Style/BracesAroundHashParameters: EnforcedStyle: context_dependent -Lint/BlockAlignment: - AlignWith: start_of_block - -Lint/EndAlignment: - AlignWith: keyword - Lint/InheritException: Enabled: false @@ -43,5 +37,8 @@ Style/GuardClause: Style/IfUnlessModifier: MaxLineLength: 40 +Style/VariableNumber: + Enabled: false + Lint/HandleExceptions: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 45b4faf8b..534ca8490 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -169,6 +169,17 @@ Style/SingleLineBlockParams: Exclude: - 'spec/support/helper_functions.rb' +Style/EmptyMethod: + Enabled: false + +Metrics/BlockLength: + Exclude: + - Guardfile + - app/admin/** + - config/**/* + - lib/**/* + - spec/**/* + - app/controllers/pages_controller.rb Metrics/LineLength: Max: 120 Exclude: diff --git a/Gemfile b/Gemfile index 4fae6053d..3e688b352 100644 --- a/Gemfile +++ b/Gemfile @@ -3,83 +3,83 @@ source 'https://rubygems.org' ruby '2.4.0' -gem 'rails', '4.2.8' -gem 'rake' -gem 'rails-observers' -gem 'readthis' -gem 'hiredis' -gem 'redis', '>= 3.2.0', require: ['redis', 'redis/connection/hiredis'] -gem 'pg' -gem 'jquery-rails' -gem 'selectize-rails' # why not npm? +gem 'aasm' +gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin' +gem 'bcrypt', '~> 3.1.7' +gem 'braintree', '~> 2.54.0' +gem 'browserify-rails', '~> 2.2.0' gem 'codemirror-rails' gem 'countries' -gem 'geocoder' -gem 'phony' -gem 'browserify-rails', '~> 2.2.0' +gem 'country_select' +gem 'devise' gem 'font-awesome-sass' -gem 'money' +gem 'geocoder' +gem 'gocardless_pro' gem 'google_currency' -gem 'rack-cors', require: 'rack/cors' +gem 'hiredis' gem 'httparty' -gem 'jbuilder', '~> 2.0' -gem 'braintree', '~> 2.54.0' -gem 'gocardless_pro' -gem 'aasm' gem 'i18n-js', '>= 3.0.0.rc12' -gem 'rails-i18n', '~> 4.0.0' -gem 'bcrypt', '~> 3.1.7' -gem 'slim-rails', '~> 3.1.1' +gem 'jbuilder', '~> 2.0' +gem 'jquery-rails' +gem 'kaminari' gem 'liquid' -gem 'remotipart', '~> 1.2' # [Q] Are we using this? -gem 'devise' +gem 'money' gem 'omniauth-google-oauth2' -gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin' -gem 'country_select' -gem 'kaminari' +gem 'pg' +gem 'phony' +gem 'rack-cors', require: 'rack/cors' +gem 'rails', '4.2.8' +gem 'rails-i18n', '~> 4.0.0' +gem 'rails-observers' +gem 'rake' +gem 'readthis' +gem 'redis', '>= 3.2.0', require: ['redis', 'redis/connection/hiredis'] +gem 'remotipart', '~> 1.2' # [Q] Are we using this? +gem 'selectize-rails' # why not npm? +gem 'slim-rails', '~> 3.1.1' # Use Paper Trail for containing a full history of our edits. +gem 'action_parameter' +gem 'aws-sdk', '~> 2' +gem 'paperclip', '~> 5.0.0' gem 'paper_trail' gem 'rmagick' # rmagick for image processing -gem 'paperclip', '~> 5.0.0' -gem 'aws-sdk', '~> 2' -gem 'action_parameter' # AWS SDK for Rails - makes SES integration easy +gem 'actionkit_connector', git: 'https://github.com/SumOfUs/actionkit_connector', branch: 'master' +gem 'airbrake', '~> 5.7.1' gem 'aws-sdk-rails' +gem 'bootstrap-sass', '~> 3.3.5' +gem 'browser', '~> 2.0', '>= 2.0.3' +gem 'coffee-rails', '~> 4.1.0' +gem 'compass-rails', '~> 3.0.2' # was using git master branch before +gem 'config' +gem 'envyable', require: 'envyable/rails-now' +gem 'friendly_id' +gem 'jwt' gem 'logger' gem 'lograge' -gem 'summernote-rails' -gem 'browser', '~> 2.0', '>= 2.0.3' -gem 'share_progress', git: 'https://github.com/SumOfUs/share_progress', branch: 'master', require: false +gem 'metamagic' gem 'newrelic_rpm' gem 'puma', '~> 2.15.3' -gem 'friendly_id' -gem 'config' -gem 'twilio-ruby' -gem 'metamagic' -gem 'jwt' -gem 'actionkit_connector', git: 'https://github.com/SumOfUs/actionkit_connector', branch: 'master' -gem 'airbrake', '~> 5.7.1' -gem 'envyable', require: 'envyable/rails-now' -gem 'webpack-rails' -gem 'bootstrap-sass', '~> 3.3.5' -gem 'sprockets-rails' -gem 'compass-rails', '~> 3.0.2' # was using git master branch before gem 'sass-rails', '~> 5.0.6' +gem 'share_progress', git: 'https://github.com/SumOfUs/share_progress', branch: 'master', require: false +gem 'sprockets-rails' +gem 'summernote-rails' +gem 'twilio-ruby' gem 'uglifier', '>= 1.3.0' -gem 'coffee-rails', '~> 4.1.0' +gem 'webpack-rails' group :development, :test do - gem 'rubocop', require: false - gem 'spring' - gem 'rspec-rails' gem 'capybara' # Capybara for integration testing gem 'database_cleaner' gem 'factory_girl_rails' gem 'faker' - gem 'vcr' gem 'magic_lamp' + gem 'rspec-rails' + gem 'rubocop', require: false + gem 'spring' gem 'spring-commands-rspec' + gem 'vcr' end group :doc do @@ -87,20 +87,20 @@ group :doc do end group :development do - gem 'guard-rspec', require: false - gem 'byebug' - gem 'web-console', '~> 2.0' gem 'annotate' + gem 'byebug' gem 'foreman', require: false + gem 'guard-rspec', require: false gem 'terminal-notifier-guard' # [OSX] brew install terminal-notifier + gem 'web-console', '~> 2.0' end group :test do - gem 'webmock' - gem 'timecop' gem 'coveralls', require: false gem 'poltergeist' gem 'rspec-json_expectations' + gem 'timecop' + gem 'webmock' end # Rails Assets - reference any Bower components that you need as gems. diff --git a/app/controllers/plugins/forms_controller.rb b/app/controllers/plugins/forms_controller.rb index d72c406b2..1c333d83c 100644 --- a/app/controllers/plugins/forms_controller.rb +++ b/app/controllers/plugins/forms_controller.rb @@ -15,7 +15,7 @@ def create def show plugin = Plugins.find_for permitted_params[:plugin_type], permitted_params[:plugin_id] - partial_dir = (plugin.name == 'Survey') ? 'surveys' : 'shared' + partial_dir = plugin.name == 'Survey' ? 'surveys' : 'shared' render partial: "plugins/#{partial_dir}/preview", locals: { plugin: plugin } end diff --git a/app/helpers/layout_select_helper.rb b/app/helpers/layout_select_helper.rb index fef7428ff..b96d27000 100644 --- a/app/helpers/layout_select_helper.rb +++ b/app/helpers/layout_select_helper.rb @@ -9,7 +9,7 @@ def construct_layout_select_class(liquid_layout, page, field) end def specify_layout_types(field) - (field == :liquid_layout_id) ? 'primary' : 'follow-up' + field == :liquid_layout_id ? 'primary' : 'follow-up' end private diff --git a/app/liquid/champaign_liquid_filters.rb b/app/liquid/champaign_liquid_filters.rb index 90b5da1aa..482161b6c 100644 --- a/app/liquid/champaign_liquid_filters.rb +++ b/app/liquid/champaign_liquid_filters.rb @@ -2,7 +2,7 @@ module ChampaignLiquidFilters def select_option(tags_string, to_select) # if one is already selected then leave it - return tags_string if tags_string =~ /selected/ + return tags_string if tags_string.match?(/selected/) tags_string.gsub(/(/, '\1 selected \2>') end diff --git a/app/liquid/liquid_helper.rb b/app/liquid/liquid_helper.rb index 34f40958c..e03374843 100644 --- a/app/liquid/liquid_helper.rb +++ b/app/liquid/liquid_helper.rb @@ -15,7 +15,7 @@ def country_option_tags(user_country_code = nil) options = [] names_with_codes = ISO3166::Country.all_names_with_codes(I18n.locale.to_s) names_with_codes.each do |name, code| - selected = (user_country_code == code) ? "selected='selected'" : '' + selected = user_country_code == code ? "selected='selected'" : '' options << "" end options.join("\n") diff --git a/app/models/form.rb b/app/models/form.rb index 0f11317a7..df971244b 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -34,7 +34,7 @@ class Form < ActiveRecord::Base after_touch do formable.try(:page) do |page| - page.touch if page + page&.touch end end diff --git a/app/models/link.rb b/app/models/link.rb index 6599c55a2..69b738679 100644 --- a/app/models/link.rb +++ b/app/models/link.rb @@ -26,7 +26,7 @@ class Link < ActiveRecord::Base private def url_has_protocol - unless %r{^(https?:)?\/\/}i =~ url + unless %r{^(https?:)?\/\/}i.match?(url) errors.add(:url, 'must have a protocol (like http://)') end end diff --git a/app/models/page.rb b/app/models/page.rb index 875ba92f6..108457dac 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -53,7 +53,7 @@ class Page < ActiveRecord::Base has_many :images, dependent: :destroy has_many :links, dependent: :destroy - scope :language, -> (code) { code ? joins(:language).where(languages: { code: code }) : all } + scope :language, ->(code) { code ? joins(:language).where(languages: { code: code }) : all } scope :featured, -> { where(featured: true) } validates :title, presence: true @@ -139,7 +139,7 @@ def language_code def switch_plugins fields = %w(liquid_layout_id follow_up_liquid_layout_id follow_up_plan) if fields.any? { |f| changed.include?(f) } - secondary = (follow_up_plan == 'with_liquid') ? follow_up_liquid_layout : nil + secondary = follow_up_plan == 'with_liquid' ? follow_up_liquid_layout : nil PagePluginSwitcher.new(self).switch(liquid_layout, secondary) end end diff --git a/app/models/payment/braintree.rb b/app/models/payment/braintree.rb index b6e04d6f8..b7f3346ae 100644 --- a/app/models/payment/braintree.rb +++ b/app/models/payment/braintree.rb @@ -55,7 +55,7 @@ def build @customer = Payment::Braintree::Customer.create(customer_attrs) end - payment_method = Payment::Braintree::PaymentMethod.find_or_create_by!(token: @bt_payment_method.token) do |pm| + payment_method = Payment::Braintree::PaymentMethod.find_or_create_by!(token: @bt_payment_method.token) do |pm| pm.customer = @customer pm.store_in_vault = @store_in_vault end @@ -159,15 +159,15 @@ def create_customer end def create_payment_method - if payment_method_token.nil? || @bt_result.transaction.nil? - @local_payment_method_id = nil - else - @local_payment_method_id = BraintreeServices::PaymentMethodBuilder.new( - transaction: @bt_result.transaction, - customer: @customer, - store_in_vault: @store_in_vault - ).create.id - end + @local_payment_method_id = if payment_method_token.nil? || @bt_result.transaction.nil? + nil + else + BraintreeServices::PaymentMethodBuilder.new( + transaction: @bt_result.transaction, + customer: @customer, + store_in_vault: @store_in_vault + ).create.id + end end def create_transaction diff --git a/app/models/plugins/fundraiser.rb b/app/models/plugins/fundraiser.rb index 35cf295cb..4b0b0f8b5 100644 --- a/app/models/plugins/fundraiser.rb +++ b/app/models/plugins/fundraiser.rb @@ -38,7 +38,7 @@ def liquid_data(supplemental_data = {}) end def recurring? - read_attribute(:recurring_default) > 0 + read_attribute(:recurring_default).positive? end def self.donation_default_for_page(page_id) diff --git a/app/models/plugins/has_form.rb b/app/models/plugins/has_form.rb index df678a3e6..c3c93acd7 100644 --- a/app/models/plugins/has_form.rb +++ b/app/models/plugins/has_form.rb @@ -33,7 +33,7 @@ def dup clone = super clone.save! - clone.form.form_elements = form.form_elements.map(&:dup) if clone.form + clone.form&.form_elements = form.form_elements.map(&:dup) clone end diff --git a/app/models/share/email.rb b/app/models/share/email.rb index 594e109a5..17345c2a1 100644 --- a/app/models/share/email.rb +++ b/app/models/share/email.rb @@ -20,6 +20,6 @@ class Share::Email < ActiveRecord::Base validate :has_link def has_link - errors.add(:body, 'does not contain {LINK}') unless body =~ /\{LINK\}/ + errors.add(:body, 'does not contain {LINK}') unless body.match?(/\{LINK\}/) end end diff --git a/app/models/share/twitter.rb b/app/models/share/twitter.rb index 99e9bbaab..0ad8d3462 100644 --- a/app/models/share/twitter.rb +++ b/app/models/share/twitter.rb @@ -20,6 +20,6 @@ class Share::Twitter < ActiveRecord::Base validate :has_link def has_link - errors.add(:description, 'does not contain {LINK}') unless description =~ /\{LINK\}/ + errors.add(:description, 'does not contain {LINK}') unless description.match?(/\{LINK\}/) end end diff --git a/app/services/page_updater.rb b/app/services/page_updater.rb index d797a75b2..c7dc9f369 100644 --- a/app/services/page_updater.rb +++ b/app/services/page_updater.rb @@ -116,21 +116,21 @@ def update_plugin(plugin_params) end def update_share(share_params, _name) - if share_params[:id].present? - variant = ShareProgressVariantBuilder.update( - params: without_name(share_params), - variant_type: share_params[:name], - page: @page, - id: share_params[:id] - ) - else - variant = ShareProgressVariantBuilder.create( - params: without_name(share_params), - variant_type: share_params[:name], - page: @page, - url: @page_url - ) - end + variant = if share_params[:id].present? + ShareProgressVariantBuilder.update( + params: without_name(share_params), + variant_type: share_params[:name], + page: @page, + id: share_params[:id] + ) + else + ShareProgressVariantBuilder.create( + params: without_name(share_params), + variant_type: share_params[:name], + page: @page, + url: @page_url + ) + end variant.errors end diff --git a/app/services/share_progress_variant_builder.rb b/app/services/share_progress_variant_builder.rb index 8a539614a..0fb1f75a1 100644 --- a/app/services/share_progress_variant_builder.rb +++ b/app/services/share_progress_variant_builder.rb @@ -49,7 +49,7 @@ def create if sp_button.save button.update(sp_id: sp_button.id, sp_button_html: sp_button.share_button_html, url: sp_button.page_url) - variant.update(sp_id: sp_button.variants[@variant_type].last[:id]) + variant.update(sp_id: sp_button.variants[@variant_type].last[:id]) else add_sp_errors_to_variant(sp_button, variant) end diff --git a/config/initializers/airbrake.rb b/config/initializers/airbrake.rb index 489c033a4..a9ffffff6 100644 --- a/config/initializers/airbrake.rb +++ b/config/initializers/airbrake.rb @@ -8,53 +8,55 @@ # # Configuration details: # https://github.com/airbrake/airbrake-ruby#configuration -Airbrake.configure do |c| - # You must set both project_id & project_key. To find your project_id and - # project_key navigate to your project's General Settings and copy the values - # from the right sidebar. - # https://github.com/airbrake/airbrake-ruby#project_id--project_key - - c.project_id = Settings.airbrake_project_id - c.project_key = Settings.airbrake_api_key - - # Configures the root directory of your project. Expects a String or a - # Pathname, which represents the path to your project. Providing this option - # helps us to filter out repetitive data from backtrace frames and link to - # GitHub files from our dashboard. - # https://github.com/airbrake/airbrake-ruby#root_directory - c.root_directory = Rails.root - - # By default, Airbrake Ruby outputs to STDOUT. In Rails apps it makes sense to - # use the Rails' logger. - # https://github.com/airbrake/airbrake-ruby#logger - c.logger = Rails.logger - - # Configures the environment the application is running in. Helps the Airbrake - # dashboard to distinguish between exceptions occurring in different - # environments. By default, it's not set. - # NOTE: This option must be set in order to make the 'ignore_environments' - # option work. - # https://github.com/airbrake/airbrake-ruby#environment - c.environment = Rails.env - - # Setting this option allows Airbrake to filter exceptions occurring in - # unwanted environments such as :test. By default, it is equal to an empty - # Array, which means Airbrake Ruby sends exceptions occurring in all - # environments. - # NOTE: This option *does not* work if you don't set the 'environment' option. - # https://github.com/airbrake/airbrake-ruby#ignore_environments - c.ignore_environments = %w(test) - - # A list of parameters that should be filtered out of what is sent to - # Airbrake. By default, all "password" attributes will have their contents - # replaced. - # https://github.com/airbrake/airbrake-ruby#blacklist_keys - c.blacklist_keys = [/password/i] - - # Alternatively, you can integrate with Rails' filter_parameters. - # Read more: https://goo.gl/gqQ1xS - # c.blacklist_keys = Rails.application.config.filter_parameters -end if Settings.airbrake_project_id.present? +if Settings.airbrake_project_id.present? + Airbrake.configure do |c| + # You must set both project_id & project_key. To find your project_id and + # project_key navigate to your project's General Settings and copy the values + # from the right sidebar. + # https://github.com/airbrake/airbrake-ruby#project_id--project_key + + c.project_id = Settings.airbrake_project_id + c.project_key = Settings.airbrake_api_key + + # Configures the root directory of your project. Expects a String or a + # Pathname, which represents the path to your project. Providing this option + # helps us to filter out repetitive data from backtrace frames and link to + # GitHub files from our dashboard. + # https://github.com/airbrake/airbrake-ruby#root_directory + c.root_directory = Rails.root + + # By default, Airbrake Ruby outputs to STDOUT. In Rails apps it makes sense to + # use the Rails' logger. + # https://github.com/airbrake/airbrake-ruby#logger + c.logger = Rails.logger + + # Configures the environment the application is running in. Helps the Airbrake + # dashboard to distinguish between exceptions occurring in different + # environments. By default, it's not set. + # NOTE: This option must be set in order to make the 'ignore_environments' + # option work. + # https://github.com/airbrake/airbrake-ruby#environment + c.environment = Rails.env + + # Setting this option allows Airbrake to filter exceptions occurring in + # unwanted environments such as :test. By default, it is equal to an empty + # Array, which means Airbrake Ruby sends exceptions occurring in all + # environments. + # NOTE: This option *does not* work if you don't set the 'environment' option. + # https://github.com/airbrake/airbrake-ruby#ignore_environments + c.ignore_environments = %w(test) + + # A list of parameters that should be filtered out of what is sent to + # Airbrake. By default, all "password" attributes will have their contents + # replaced. + # https://github.com/airbrake/airbrake-ruby#blacklist_keys + c.blacklist_keys = [/password/i] + + # Alternatively, you can integrate with Rails' filter_parameters. + # Read more: https://goo.gl/gqQ1xS + # c.blacklist_keys = Rails.application.config.filter_parameters + end +end # If Airbrake doesn't send any expected exceptions, we suggest to uncomment the # line below. It might simplify debugging of background Airbrake workers, which diff --git a/db/migrate/20150827085930_add_master_and_position_to_form_elements.rb b/db/migrate/20150827085930_add_master_and_position_to_form_elements.rb index 3e3fc798a..450cd715b 100644 --- a/db/migrate/20150827085930_add_master_and_position_to_form_elements.rb +++ b/db/migrate/20150827085930_add_master_and_position_to_form_elements.rb @@ -2,6 +2,6 @@ class AddMasterAndPositionToFormElements < ActiveRecord::Migration def change add_column :forms, :master, :boolean, default: false - add_column :form_elements, :position, :integer, null: false, default: 0 + add_column :form_elements, :position, :integer, null: false, default: 0 end end diff --git a/lib/action_kit/helper.rb b/lib/action_kit/helper.rb index d668dc548..6ebdb631f 100644 --- a/lib/action_kit/helper.rb +++ b/lib/action_kit/helper.rb @@ -6,7 +6,7 @@ module Helper def check_petition_name_is_available(name) resp = ActionKit::Client.get('petitionpage', params: { _limit: 1, name: name }) if resp.code == 200 - JSON.parse(resp.body)['meta']['total_count'] == 0 + (JSON.parse(resp.body)['meta']['total_count']).zero? else false end diff --git a/lib/liquid_markup_seeder.rb b/lib/liquid_markup_seeder.rb index c4c2ca898..2bc14fbfc 100644 --- a/lib/liquid_markup_seeder.rb +++ b/lib/liquid_markup_seeder.rb @@ -61,7 +61,7 @@ def parse_name(file) end def klass(file) - file =~ /\_\w+\.liquid$/ ? 'LiquidPartial' : 'LiquidLayout' + file.match?(/\_\w+\.liquid$/) ? 'LiquidPartial' : 'LiquidLayout' end def set_metadata_fields(view) diff --git a/lib/payment_processor/braintree/error_processing.rb b/lib/payment_processor/braintree/error_processing.rb index a452b2ee7..62baa7477 100644 --- a/lib/payment_processor/braintree/error_processing.rb +++ b/lib/payment_processor/braintree/error_processing.rb @@ -32,7 +32,7 @@ class ErrorProcessing .flatten .freeze - FILTER = -> (error) { USER_ERROR_CODES.include?(error.code.to_i) } + FILTER = ->(error) { USER_ERROR_CODES.include?(error.code.to_i) } # locale is unused, added to match API for GoCardless def initialize(response, locale: nil) diff --git a/lib/payment_processor/braintree/one_click_from_uri.rb b/lib/payment_processor/braintree/one_click_from_uri.rb index 93b0ebc2a..c13eea829 100644 --- a/lib/payment_processor/braintree/one_click_from_uri.rb +++ b/lib/payment_processor/braintree/one_click_from_uri.rb @@ -27,7 +27,7 @@ def recurring? def one_click? params.fetch(:one_click, '') == 'true' && payment_method_id && - params.fetch(:amount, 0).to_f > 0 && + params.fetch(:amount, 0).to_f.positive? && params[:currency].present? end diff --git a/lib/payment_processor/braintree/subscription.rb b/lib/payment_processor/braintree/subscription.rb index d0e6b9161..b2ef5eb9e 100644 --- a/lib/payment_processor/braintree/subscription.rb +++ b/lib/payment_processor/braintree/subscription.rb @@ -63,9 +63,9 @@ def create_or_retrieve_payment_method_on_braintree(customer_result) if existing_customer.present? payment_method_result = ::Braintree::PaymentMethod.create(payment_method_options) break_if_rejected(payment_method_result) - return payment_method_result.payment_method + payment_method_result.payment_method else - return customer_result.customer.payment_methods.first + customer_result.customer.payment_methods.first end end diff --git a/lib/payment_processor/go_cardless/populator.rb b/lib/payment_processor/go_cardless/populator.rb index 441e3f5d6..51faff619 100644 --- a/lib/payment_processor/go_cardless/populator.rb +++ b/lib/payment_processor/go_cardless/populator.rb @@ -70,7 +70,7 @@ def bacs? def complete_redirect_flow @complete_redirect_flow ||= client.redirect_flows.complete(@redirect_flow_id, params: { session_token: @session_token }) rescue GoCardlessPro::InvalidStateError => e - raise e unless e.message =~ /already completed/ + raise e unless e.message.match?(/already completed/) @complete_redirect_flow = client.redirect_flows.get(@redirect_flow_id) end diff --git a/lib/tasks/sumofus.rake b/lib/tasks/sumofus.rake index abf9528f4..a05f9270d 100644 --- a/lib/tasks/sumofus.rake +++ b/lib/tasks/sumofus.rake @@ -18,7 +18,7 @@ namespace :sumofus do else puts 'Loading page data' page_data_handle = open(args[:action_file]) - page_data = JSON.load(page_data_handle.read) + page_data = JSON.parse(page_data_handle.read) page_data_handle.close puts 'Page data loaded' end @@ -91,7 +91,7 @@ namespace :sumofus do else puts 'Loading page data' page_data_handle = open(args[:action_file]) - page_data = JSON.load(page_data_handle.read) + page_data = JSON.parse(page_data_handle.read) page_data_handle.close puts 'Page data loaded' end @@ -202,7 +202,7 @@ namespace :sumofus do petition.description = entry['petition_ask'].delete('"').gsub('Petition Text:', '') petition.target = entry['petition_target'].gsub(/Sign our petition to /i, '').gsub(/Sign the petition to /, '').delete(':') petition.save! - next unless page.images.count == 0 + next unless page.images.count.zero? if existing_image.blank? existing_image = page.images.create(content: page_image_handle) else diff --git a/spec/models/link_spec.rb b/spec/models/link_spec.rb index f1d0ebf4e..90c12f556 100644 --- a/spec/models/link_spec.rb +++ b/spec/models/link_spec.rb @@ -112,7 +112,7 @@ old_time = Time.now.utc Timecop.travel(1.hour) do - expect { link.update(source: 'BBC') }.to change{ + expect { link.update(source: 'BBC') }.to change { page.reload.updated_at.to_s }.from(old_time.to_s).to((old_time + 1.hour).to_s) end diff --git a/spec/requests/api/go_cardless/go_cardless_spec.rb b/spec/requests/api/go_cardless/go_cardless_spec.rb index dd4de7986..6cf5e405e 100644 --- a/spec/requests/api/go_cardless/go_cardless_spec.rb +++ b/spec/requests/api/go_cardless/go_cardless_spec.rb @@ -59,7 +59,7 @@ URI.parse(assigns(:flow).redirect_flow_instance.success_redirect_url).query ) request.params.each_pair do |key, val| - next if key =~ /controller|action/ + next if key.match?(/controller|action/) expect(success_redirect_params[key]).to eq val end end diff --git a/spec/services/share_progress_variant_builder_spec.rb b/spec/services/share_progress_variant_builder_spec.rb index aaf4d6694..4d8d584a7 100644 --- a/spec/services/share_progress_variant_builder_spec.rb +++ b/spec/services/share_progress_variant_builder_spec.rb @@ -15,7 +15,7 @@ id: '1', share_button_html: '
', page_url: 'http://example.com/foo', - variants: { facebook: sp_variants }) + variants: { facebook: sp_variants }) end let(:failure_sp_button) do From e34840a26daaeae05c47c26722a80e0d754700b8 Mon Sep 17 00:00:00 2001 From: Vincent Martinez Date: Wed, 1 Mar 2017 21:09:32 +0000 Subject: [PATCH 3/3] Only validate `has_link` if body/desc is present --- app/models/share/email.rb | 2 +- app/models/share/twitter.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/share/email.rb b/app/models/share/email.rb index 17345c2a1..22468816e 100644 --- a/app/models/share/email.rb +++ b/app/models/share/email.rb @@ -17,7 +17,7 @@ class Share::Email < ActiveRecord::Base include Share::Variant validates :subject, :body, presence: true - validate :has_link + validate :has_link, unless: -> { body.nil? } def has_link errors.add(:body, 'does not contain {LINK}') unless body.match?(/\{LINK\}/) diff --git a/app/models/share/twitter.rb b/app/models/share/twitter.rb index 0ad8d3462..80cc6ee84 100644 --- a/app/models/share/twitter.rb +++ b/app/models/share/twitter.rb @@ -17,7 +17,7 @@ class Share::Twitter < ActiveRecord::Base include Share::Variant validates :description, presence: true - validate :has_link + validate :has_link, unless: -> { description.nil? } def has_link errors.add(:description, 'does not contain {LINK}') unless description.match?(/\{LINK\}/)