diff --git a/.rubocop.yml b/.rubocop.yml index 7286e89..783fc60 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,26 +1,5 @@ # This is the configuration used to check the rubocop source code. # See https://github.com/bbatsov/rubocop/blob/master/config/default.yml for info -AllCops: - Include: - - '**/Rakefile' - - '**/config.ru' - Exclude: - - 'config/**/*' - - 'db/**/*' - - 'script/**/*' - - 'spec/fixtures/**/*' - - 'vendor/**/*' - RunRailsCops: true - -Style/StringLiterals: - EnforcedStyle: double_quotes - SupportedStyles: - - single_quotes - - double_quotes - -Style/StringLiteralsInInterpolation: - EnforcedStyle: double_quotes - SupportedStyles: - - single_quotes - - double_quotes +Rails: + Enabled: true \ No newline at end of file diff --git a/.ruby-version b/.ruby-version index eca07e4..aedc15b 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.1.2 +2.5.3 diff --git a/Gemfile b/Gemfile index 1c1cee8..78843b1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,47 +1,53 @@ -source "https://rubygems.org" -ruby "2.1.2" +# frozen_string_literal: true -gem "rails", "~> 4.1" +source 'https://rubygems.org' +ruby '2.5.3' -gem "pg" +gem 'rails', '~> 5.2' -gem "activeadmin", github: "gregbell/active_admin" -gem "active_admin_editor", github: "boontdustie/active_admin_editor" -gem "acts_as_list", github: "swanandp/acts_as_list" -gem "aws-sdk", '< 2.0' -gem "coffee-rails" # , '~> 3.2.1' -gem "compass-rails" -gem "devise" -gem "friendly_id" -gem "haml-rails" -gem "jquery-rails" # , '~> 2.3.0' -gem "rails_12factor", group: :production -gem "sass-rails" -gem "uglifier" # , '>= 1.0.3' -gem "paperclip" # , '~> 3.0' -gem "kaminari" -gem "font-awesome-rails" +gem 'pg' + +gem 'active_admin_editor', github: 'ejholmes/active_admin_editor' +gem 'activeadmin' +gem 'acts_as_list' +gem 'aws-sdk', '< 2.0' +gem 'bootsnap' +gem 'coffee-rails' +gem 'compass-rails' +gem 'devise' +gem 'font-awesome-rails' +gem 'friendly_id' +gem 'haml-rails' +gem 'jquery-rails' +gem 'kaminari' +gem 'listen' +gem 'paperclip' +gem 'rails_12factor', group: :production +gem 'sass-rails' +gem 'uglifier' group :development, :test do - gem "pry-rails" - gem "rspec-rails" - gem "factory_girl_rails", "~> 4.0" + gem 'factory_bot_rails' + gem 'pry-rails' + gem 'rspec-rails' end group :development do - gem "pry-remote" - gem "rails_best_practices" - gem "better_errors" - gem "traceroute" - gem "rack-mini-profiler" - gem "bullet" - gem "brakeman", require: false - gem "rubocop", require: false - gem "rubycritic", require: false + gem 'better_errors' + gem 'brakeman', require: false + gem 'bullet' + gem 'bumbler' + gem 'pry-remote' + gem 'rack-mini-profiler' + gem 'rails_best_practices' + gem 'rubocop', require: false + gem 'rubycritic', require: false + gem 'traceroute' end group :test do - gem "faker" - gem "simplecov", require: false - gem "database_cleaner" + gem 'database_cleaner' + gem 'faker' + gem 'rails-controller-testing' + gem 'simplecov', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index f49ac71..1fd3c97 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,123 +1,114 @@ GIT - remote: git://github.com/boontdustie/active_admin_editor.git - revision: efc7df212173cbac65dc95ed50e6f5917ae049c0 + remote: git://github.com/ejholmes/active_admin_editor.git + revision: 86f964be3071cd938c3cd17ad00df94ece3a50c0 specs: active_admin_editor (1.1.0) activeadmin (>= 0.4.0) ejs rails (>= 3.0.0) -GIT - remote: git://github.com/gregbell/active_admin.git - revision: 1c85c5654a2ce1d43d4c64d98b928ff133d46406 - specs: - activeadmin (1.0.0.pre2) - 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.0) - ransack (~> 1.3) - sass-rails - sprockets (< 4) - -GIT - remote: git://github.com/swanandp/acts_as_list.git - revision: d605d17f6966c03d4e547fc43f6c52c774dde706 - specs: - acts_as_list (0.7.2) - activerecord (>= 3.0) - GEM remote: https://rubygems.org/ specs: - actionmailer (4.1.15) - actionpack (= 4.1.15) - actionview (= 4.1.15) + actioncable (5.2.2) + actionpack (= 5.2.2) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.15) - actionview (= 4.1.15) - activesupport (= 4.1.15) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - actionview (4.1.15) - activesupport (= 4.1.15) - builder (~> 3.1) - erubis (~> 2.7.0) - activemodel (4.1.15) - activesupport (= 4.1.15) + rails-dom-testing (~> 2.0) + actionpack (5.2.2) + actionview (= 5.2.2) + activesupport (= 5.2.2) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.2) + activesupport (= 5.2.2) builder (~> 3.1) - activerecord (4.1.15) - activemodel (= 4.1.15) - activesupport (= 4.1.15) - arel (~> 5.0.0) - activesupport (4.1.15) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activeadmin (1.4.3) + arbre (>= 1.1.1) + coffee-rails + formtastic (~> 3.1) + formtastic_i18n + inherited_resources (>= 1.9.0) + jquery-rails (>= 4.2.0) + kaminari (>= 0.15) + railties (>= 4.2, < 5.3) + ransack (>= 1.8.7) + sass (~> 3.1) + sprockets (< 4.1) + activejob (5.2.2) + activesupport (= 5.2.2) + globalid (>= 0.3.6) + activemodel (5.2.2) + activesupport (= 5.2.2) + activerecord (5.2.2) + activemodel (= 5.2.2) + activesupport (= 5.2.2) + arel (>= 9.0) + activestorage (5.2.2) + actionpack (= 5.2.2) + activerecord (= 5.2.2) + marcel (~> 0.3.1) + activesupport (5.2.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.1) tzinfo (~> 1.1) - addressable (2.4.0) - arbre (1.0.3) + acts_as_list (0.9.17) + activerecord (>= 3.0) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) + arbre (1.1.1) activesupport (>= 3.0.0) - arel (5.0.1.20140414130214) - ast (2.2.0) - aws-sdk (1.60.2) - aws-sdk-v1 (= 1.60.2) - aws-sdk-v1 (1.60.2) + arel (9.0.0) + ast (2.4.0) + aws-sdk (1.67.0) + aws-sdk-v1 (= 1.67.0) + aws-sdk-v1 (1.67.0) json (~> 1.4) - nokogiri (>= 1.4.4) + nokogiri (~> 1) axiom-types (0.1.1) descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) - bcrypt (3.1.11) - better_errors (2.1.1) + bcrypt (3.1.12) + better_errors (2.5.0) coderay (>= 1.0.0) - erubis (>= 2.6.6) + erubi (>= 1.0.0) rack (>= 0.9.0) - bourbon (4.2.6) - sass (~> 3.4) - thor (~> 0.19) - brakeman (3.2.1) - erubis (~> 2.6) - haml (>= 3.0, < 5.0) - highline (>= 1.6.20, < 2.0) - ruby2ruby (~> 2.3.0) - ruby_parser (~> 3.8.1) - safe_yaml (>= 1.0) - sass (~> 3.0) - slim (>= 1.3.6, < 4.0) - terminal-table (~> 1.4) - builder (3.2.2) - bullet (5.0.0) + bootsnap (1.3.2) + msgpack (~> 1.0) + brakeman (4.3.1) + builder (3.2.3) + bullet (5.9.0) activesupport (>= 3.0.0) - uniform_notifier (~> 1.9.0) - chunky_png (1.3.5) - climate_control (0.0.3) - activesupport (>= 3.0) - cocaine (0.5.8) - climate_control (>= 0.0.3, < 1.0) - code_analyzer (0.4.5) + uniform_notifier (~> 1.11) + bumbler (0.4.0) + chunky_png (1.3.11) + climate_control (0.2.0) + code_analyzer (0.4.8) sexp_processor - codeclimate-engine-rb (0.3.1) + codeclimate-engine-rb (0.4.1) virtus (~> 1.0) - coderay (1.1.1) + coderay (1.1.2) coercible (1.0.0) descendants_tracker (~> 0.0.1) - coffee-rails (4.1.1) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.1.x) + railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.10.0) - colorize (0.7.7) + coffee-script-source (1.12.2) compass (1.0.3) chunky_png (~> 1.2) compass-core (~> 1.0.2) @@ -130,280 +121,327 @@ GEM sass (>= 3.3.0, < 3.5) compass-import-once (1.0.5) sass (>= 3.2, < 3.5) - compass-rails (3.0.2) + compass-rails (3.1.0) compass (~> 1.0.0) sass-rails (< 5.1) sprockets (< 4.0) - concurrent-ruby (1.0.1) - database_cleaner (1.5.1) + concurrent-ruby (1.1.4) + crass (1.0.4) + database_cleaner (1.7.0) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - devise (3.5.6) + devise (4.5.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) + railties (>= 4.1.0, < 6.0) responders - thread_safe (~> 0.1) warden (~> 1.2.3) - diff-lcs (1.2.5) - docile (1.1.5) + diff-lcs (1.3) + docile (1.3.1) ejs (1.1.1) equalizer (0.0.11) + erubi (1.8.0) erubis (2.7.0) - execjs (2.6.0) - factory_girl (4.5.0) + execjs (2.7.0) + factory_bot (4.11.1) activesupport (>= 3.0.0) - factory_girl_rails (4.6.0) - factory_girl (~> 4.5.0) + factory_bot_rails (4.11.1) + factory_bot (~> 4.11.1) railties (>= 3.0.0) - faker (1.6.3) - i18n (~> 0.5) - ffi (1.9.10) - flay (2.7.0) + faker (1.9.1) + i18n (>= 0.7) + ffi (1.9.25) + flay (2.12.0) erubis (~> 2.7.0) + path_expander (~> 1.0) ruby_parser (~> 3.0) sexp_processor (~> 4.0) - flog (4.3.2) + flog (4.6.2) + path_expander (~> 1.0) ruby_parser (~> 3.1, > 3.1.0) - sexp_processor (~> 4.4) - font-awesome-rails (4.5.0.1) - railties (>= 3.2, < 5.1) - formtastic (3.1.3) + sexp_processor (~> 4.8) + font-awesome-rails (4.7.0.4) + railties (>= 3.2, < 6.0) + formtastic (3.1.5) actionpack (>= 3.2.13) formtastic_i18n (0.6.0) - friendly_id (5.1.0) + friendly_id (5.2.5) activerecord (>= 4.0.0) - haml (4.0.7) + globalid (0.4.1) + activesupport (>= 4.2.0) + haml (5.0.4) + temple (>= 0.8.0) tilt - haml-rails (0.9.0) + haml-rails (1.0.0) actionpack (>= 4.0.1) activesupport (>= 4.0.1) - haml (>= 4.0.6, < 5.0) + haml (>= 4.0.6, < 6.0) html2haml (>= 1.0.1) railties (>= 4.0.1) - has_scope (0.6.0) - actionpack (>= 3.2, < 5) - activesupport (>= 3.2, < 5) - highline (1.7.8) - html2haml (2.0.0) + has_scope (0.7.2) + actionpack (>= 4.1) + activesupport (>= 4.1) + html2haml (2.2.0) erubis (~> 2.7.0) - haml (~> 4.0.0) - nokogiri (~> 1.6.0) + haml (>= 4.0, < 6) + nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - i18n (0.7.0) + i18n (1.4.0) + concurrent-ruby (~> 1.0) ice_nine (0.11.2) - inherited_resources (1.6.0) - actionpack (>= 3.2, < 5) - has_scope (~> 0.6.0.rc) - railties (>= 3.2, < 5) + inherited_resources (1.9.0) + actionpack (>= 4.2, < 5.3) + has_scope (~> 0.6) + railties (>= 4.2, < 5.3) responders - jquery-rails (3.1.4) - railties (>= 3.0, < 5.0) + jaro_winkler (1.5.2) + jquery-rails (4.3.3) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (5.0.5) - railties (>= 3.2.16) - json (1.8.3) - kaminari (0.16.3) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) + json (1.8.6) + kaminari (1.1.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.1.1) + kaminari-activerecord (= 1.1.1) + kaminari-core (= 1.1.1) + kaminari-actionview (1.1.1) + actionview + kaminari-core (= 1.1.1) + kaminari-activerecord (1.1.1) + activerecord + kaminari-core (= 1.1.1) + kaminari-core (1.1.1) launchy (2.4.3) addressable (~> 2.3) - mail (2.6.3) - mime-types (>= 1.16, < 3) - method_source (0.8.2) - mime-types (2.99.1) - mimemagic (0.3.0) - mini_portile2 (2.0.0) - minitest (5.8.4) - multi_json (1.11.2) - nokogiri (1.6.7.2) - mini_portile2 (~> 2.0.0.rc2) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.2.3) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (0.9.2) + mime-types (3.2.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2018.0812) + mimemagic (0.3.3) + mini_mime (1.0.1) + mini_portile2 (2.4.0) + minitest (5.11.3) + msgpack (1.2.4) + multi_json (1.13.1) + nio4r (2.3.1) + nokogiri (1.10.0) + mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) - paperclip (4.3.6) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - cocaine (~> 0.5.5) + paperclip (6.1.0) + activemodel (>= 4.2.0) + activesupport (>= 4.2.0) mime-types - mimemagic (= 0.3.0) - parser (2.3.0.6) - ast (~> 2.2) - pg (0.18.4) - polyamorous (1.3.0) - activerecord (>= 3.0) - powerpack (0.1.1) - pry (0.10.3) + mimemagic (~> 0.3.0) + terrapin (~> 0.6.0) + parallel (1.12.1) + parser (2.5.3.0) + ast (~> 2.4.0) + path_expander (1.0.3) + pg (1.1.3) + powerpack (0.1.2) + pry (0.12.2) coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - pry-rails (0.3.4) - pry (>= 0.9.10) + method_source (~> 0.9.0) + pry-rails (0.3.9) + pry (>= 0.10.4) pry-remote (0.1.8) pry (~> 0.9) slop (~> 3.0) - rack (1.5.5) - rack-mini-profiler (0.9.9.2) + public_suffix (3.0.3) + rack (2.0.6) + rack-mini-profiler (1.0.1) rack (>= 1.2.0) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.1.15) - actionmailer (= 4.1.15) - actionpack (= 4.1.15) - actionview (= 4.1.15) - activemodel (= 4.1.15) - activerecord (= 4.1.15) - activesupport (= 4.1.15) - bundler (>= 1.3.0, < 2.0) - railties (= 4.1.15) - sprockets-rails (~> 2.0) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.2) + actioncable (= 5.2.2) + actionmailer (= 5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) + activemodel (= 5.2.2) + activerecord (= 5.2.2) + activestorage (= 5.2.2) + activesupport (= 5.2.2) + bundler (>= 1.3.0) + railties (= 5.2.2) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.4) + actionpack (>= 5.0.1.x) + actionview (>= 5.0.1.x) + activesupport (>= 5.0.1.x) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging - rails_best_practices (1.16.0) + rails_best_practices (1.19.4) activesupport - code_analyzer (>= 0.4.3) + code_analyzer (>= 0.4.8) erubis i18n json - require_all + require_all (~> 2.0) ruby-progressbar rails_serve_static_assets (0.0.5) - rails_stdout_logging (0.0.4) - railties (4.1.15) - actionpack (= 4.1.15) - activesupport (= 4.1.15) + rails_stdout_logging (0.0.5) + railties (5.2.2) + actionpack (= 5.2.2) + activesupport (= 5.2.2) + method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (2.1.0) - rake (11.1.1) - ransack (1.7.0) - actionpack (>= 3.0) - activerecord (>= 3.0) - activesupport (>= 3.0) + thor (>= 0.19.0, < 2.0) + rainbow (3.0.0) + rake (12.3.2) + ransack (2.1.1) + actionpack (>= 5.0) + activerecord (>= 5.0) + activesupport (>= 5.0) i18n - polyamorous (~> 1.2) - rb-fsevent (0.9.7) - rb-inotify (0.9.7) - ffi (>= 0.5.0) - reek (3.11) - codeclimate-engine-rb (~> 0.3.1) - parser (~> 2.3, >= 2.3.0.6) - rainbow (~> 2.0) - require_all (1.3.3) - responders (1.1.2) - railties (>= 3.2, < 4.2) - rspec-core (3.4.4) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + reek (4.8.2) + codeclimate-engine-rb (~> 0.4.0) + parser (>= 2.5.0.0, < 2.6) + rainbow (>= 2.0, < 4.0) + require_all (2.0.0) + responders (2.4.0) + actionpack (>= 4.2.0, < 5.3) + railties (>= 4.2.0, < 5.3) + rspec-core (3.8.0) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-mocks (3.4.1) + rspec-support (~> 3.8.0) + rspec-mocks (3.8.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-rails (3.4.2) - actionpack (>= 3.0, < 4.3) - activesupport (>= 3.0, < 4.3) - railties (>= 3.0, < 4.3) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-support (~> 3.4.0) - rspec-support (3.4.1) - rubocop (0.38.0) - parser (>= 2.3.0.6, < 3.0) + rspec-support (~> 3.8.0) + rspec-rails (3.8.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) + rspec-support (~> 3.8.0) + rspec-support (3.8.0) + rubocop (0.62.0) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.5, != 2.5.1.1) powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.7.5) - ruby2ruby (2.3.0) - ruby_parser (~> 3.1) - sexp_processor (~> 4.0) - ruby_parser (3.8.1) - sexp_processor (~> 4.1) - rubycritic (2.8.0) - colorize - flay (= 2.7.0) - flog (= 4.3.2) + unicode-display_width (~> 1.4.0) + ruby-progressbar (1.10.0) + ruby_dep (1.5.0) + ruby_parser (3.12.0) + sexp_processor (~> 4.9) + rubycritic (3.5.2) + flay (~> 2.8) + flog (~> 4.4) launchy (= 2.4.3) - parser (~> 2.3) - reek (= 3.11) + parser (~> 2.5.0) + rainbow (~> 3.0) + reek (~> 4.4) ruby_parser (~> 3.8) + tty-which (~> 0.3.0) virtus (~> 1.0) - safe_yaml (1.0.4) - sass (3.4.21) - sass-rails (5.0.4) - railties (>= 4.0.0, < 5.0) + sass (3.4.25) + sass-rails (5.0.7) + railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sexp_processor (4.7.0) - simplecov (0.11.2) - docile (~> 1.1.0) - json (~> 1.8) + sexp_processor (4.11.0) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) - slim (3.0.6) - temple (~> 0.7.3) - tilt (>= 1.3.3, < 2.1) + simplecov-html (0.10.2) slop (3.6.0) - sprockets (3.5.2) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) - temple (0.7.6) - terminal-table (1.5.2) - thor (0.19.1) - thread_safe (0.3.5) - tilt (2.0.2) - traceroute (0.5.0) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + temple (0.8.0) + terrapin (0.6.0) + climate_control (>= 0.0.3, < 1.0) + thor (0.20.3) + thread_safe (0.3.6) + tilt (2.0.9) + traceroute (0.8.0) rails (>= 3.0.0) - tzinfo (1.2.2) + tty-which (0.3.0) + tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (2.7.2) - execjs (>= 0.3.0) - json (>= 1.8.0) - unicode-display_width (1.0.2) - uniform_notifier (1.9.0) + uglifier (4.1.20) + execjs (>= 0.3.0, < 3) + unicode-display_width (1.4.1) + uniform_notifier (1.12.1) virtus (1.0.5) axiom-types (~> 0.1) coercible (~> 1.0) descendants_tracker (~> 0.0, >= 0.0.3) equalizer (~> 0.0, >= 0.0.9) - warden (1.2.6) - rack (>= 1.0) + warden (1.2.8) + rack (>= 2.0.6) + websocket-driver (0.7.0) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) PLATFORMS ruby DEPENDENCIES active_admin_editor! - activeadmin! - acts_as_list! + activeadmin + acts_as_list aws-sdk (< 2.0) better_errors + bootsnap brakeman bullet + bumbler coffee-rails compass-rails database_cleaner devise - factory_girl_rails (~> 4.0) + factory_bot_rails faker font-awesome-rails friendly_id haml-rails jquery-rails kaminari + listen paperclip pg pry-rails pry-remote rack-mini-profiler - rails (~> 4.1) + rails (~> 5.2) + rails-controller-testing rails_12factor rails_best_practices rspec-rails @@ -413,3 +451,9 @@ DEPENDENCIES simplecov traceroute uglifier + +RUBY VERSION + ruby 2.5.3p105 + +BUNDLED WITH + 1.17.1 diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 index d3eb86c..83abc8d --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,10 @@ #!/usr/bin/env rake +# frozen_string_literal: true + # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be # available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path('config/application', __dir__) FuntimeApp::Application.load_tasks diff --git a/app/admin/admin_user.rb b/app/admin/admin_user.rb index 95c32cb..bf5bfd0 100644 --- a/app/admin/admin_user.rb +++ b/app/admin/admin_user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActiveAdmin.register AdminUser do permit_params :email, :password, :password_confirmation diff --git a/app/admin/dashboard.rb b/app/admin/dashboard.rb index d5675be..63a5720 100644 --- a/app/admin/dashboard.rb +++ b/app/admin/dashboard.rb @@ -1,5 +1,6 @@ -ActiveAdmin.register_page 'Dashboard' do +# frozen_string_literal: true +ActiveAdmin.register_page 'Dashboard' do menu priority: 1, label: proc { I18n.t('active_admin.dashboard') } content title: proc { I18n.t('active_admin.dashboard') } do @@ -25,7 +26,7 @@ column do panel t('admin.dashboard.things_to_do') do ul do - Person.alphabetical.select{|p| !p.image.exists?}.map do |person| + Person.alphabetical.reject { |p| p.image.exists? }.map do |person| li link_to(person.name, edit_admin_person_path(person)) + ' needs an image' end end diff --git a/app/admin/inputs/file_input.rb b/app/admin/inputs/file_input.rb index 6713824..63d8896 100644 --- a/app/admin/inputs/file_input.rb +++ b/app/admin/inputs/file_input.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Source: http://viget.com/extend/8-insanely-useful-activeadmin-customizations class FileInput < Formtastic::Inputs::FileInput def to_html diff --git a/app/admin/inputs/page_sorting_input.rb b/app/admin/inputs/page_sorting_input.rb index f319ac8..6bc332c 100644 --- a/app/admin/inputs/page_sorting_input.rb +++ b/app/admin/inputs/page_sorting_input.rb @@ -1,12 +1,13 @@ +# frozen_string_literal: true + class PageSortingInput < Formtastic::Inputs::StringInput include ActionView::Helpers::UrlHelper def to_html input_wrapping do label_html << - builder.text_field(method, input_html_options.merge({readonly: 'true'})) << + builder.text_field(method, input_html_options.merge(readonly: 'true')) << image_preview_content << - link_to("Edit page", Rails.application.routes.url_helpers.edit_admin_page_path(@object)) - + link_to('Edit page', Rails.application.routes.url_helpers.edit_admin_page_path(@object)) end end @@ -14,7 +15,8 @@ def to_html def image_preview_content image = @object.image - return "" unless image.present? - template.image_tag(image.url(:medium), class: "image-preview") + return '' if image.blank? + + template.image_tag(image.url(:medium), class: 'image-preview') end end diff --git a/app/admin/issues.rb b/app/admin/issues.rb index c4a61a5..26f6729 100644 --- a/app/admin/issues.rb +++ b/app/admin/issues.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActiveAdmin.register Issue do permit_params :cover_image, :cover_image_file_name, @@ -11,10 +13,10 @@ :rating, :title, :issue_pages, - pages_attributes: [:id, :issue_page_number, :issue_id] + pages_attributes: %i[id issue_page_number issue_id] + + config.sort_order = 'position_asc' - config.sort_order = "position_asc" - index do selectable_column column :issue do |issue| @@ -36,7 +38,7 @@ end end - form html: {multipart: true} do |f| + form html: { multipart: true } do |f| f.actions f.inputs t('admin.issue.form_title'), class: 'inputs issue' do f.semantic_errors(*f.object.errors.keys) @@ -98,7 +100,7 @@ def create def update @issue = Issue.friendly.find(params[:id]) respond_to do |format| - if @issue.update_attributes(permitted_params[:issue]) + if @issue.update(permitted_params[:issue]) format.html do redirect_to admin_issues_url, notice: 'Issue successfully updated.' end @@ -108,5 +110,4 @@ def update end end end - end diff --git a/app/admin/page.rb b/app/admin/page.rb index e196081..ed83b09 100644 --- a/app/admin/page.rb +++ b/app/admin/page.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActiveAdmin.register Page do permit_params :id, :image_content_type, @@ -20,27 +22,27 @@ end column :story do |page| story = page.story - page_number = " page " + page.story_page_number.to_s + page_number = ' page ' + page.story_page_number.to_s link_to story.name + page_number, edit_admin_story_path(story) end column :issue do |page| issue = page.try(:issue) if issue - page_number = " page " + page.issue_page_number.to_s + page_number = ' page ' + page.issue_page_number.to_s link_to issue.title + page_number, edit_admin_issue_path(issue) else - "None" + 'None' end end actions end - form html: { enctype: "multipart/form-data" } do |f| - f.inputs t("admin.page.form_title"), multipart: true do + form html: { enctype: 'multipart/form-data' } do |f| + f.inputs t('admin.page.form_title'), multipart: true do f.semantic_errors(*f.object.errors.keys) f.input :image, image_preview: true, - hint: t("admin.page.image_hint") + hint: t('admin.page.image_hint') f.input :story, as: :select, collection: Story.alphabetical f.input :story_page_number f.input :issue, as: :select, collection: Issue.ordered @@ -61,10 +63,10 @@ def create respond_to do |format| if @page.save format.html do - redirect_to admin_pages_url, notice: "Page successfully created." + redirect_to admin_pages_url, notice: 'Page successfully created.' end else - format.html { render action: "new" } + format.html { render action: 'new' } end end end @@ -73,12 +75,12 @@ def create def update @page = Page.find(params[:id]) respond_to do |format| - if @page.update_attributes(permitted_params[:page]) + if @page.update(permitted_params[:page]) format.html do - redirect_to admin_pages_url, notice: "Page successfully updated." + redirect_to admin_pages_url, notice: 'Page successfully updated.' end else - format.html { render action: "edit" } + format.html { render action: 'edit' } end end end diff --git a/app/admin/people.rb b/app/admin/people.rb index d6df0ad..325c66c 100644 --- a/app/admin/people.rb +++ b/app/admin/people.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActiveAdmin.register Person do permit_params :bio, :image, :name diff --git a/app/admin/stories.rb b/app/admin/stories.rb index dff280b..2411445 100644 --- a/app/admin/stories.rb +++ b/app/admin/stories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActiveAdmin.register Story do permit_params :cover_image, :cover_image_file_name, @@ -10,7 +12,7 @@ :rating, :unfinished, :story_pages, - pages_attributes: [:id, :story_page_number, :story_id] + pages_attributes: %i[id story_page_number story_id] index do selectable_column @@ -20,9 +22,7 @@ column :cover_image do |story| image_tag(story.cover_image.url(:thumb)) end - column :rating do |story| - story.rating - end + column :rating, &:rating column :people do |story| content_tag :ul do content_tag_for :li, story.people.alphabetical do |person| @@ -42,7 +42,7 @@ end end - form html: {multipart: true} do |f| + form html: { multipart: true } do |f| f.actions f.inputs t('admin.story.form_title'), class: 'inputs story' do f.semantic_errors(*f.object.errors.keys) @@ -114,7 +114,7 @@ def create def update @story = Story.friendly.find(params[:id]) respond_to do |format| - if @story.update_attributes(permitted_params[:story]) + if @story.update(permitted_params[:story]) format.html do redirect_to admin_stories_url, notice: 'Story successfully updated.' end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3f0725e..535d56f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Base controller for app class ApplicationController < ActionController::Base protect_from_forgery with: :exception diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 8040bcf..023be39 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Front-end controller for 404, 500 etc. errors class ErrorsController < ApplicationController def show diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index b027530..38f1785 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class IssuesController < InheritedResources::Base # GET /issues # GET /stories.json diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 98cc922..4bf416b 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # API controller for pages class PagesController < InheritedResources::Base # GET /pages/1.json @@ -5,7 +7,7 @@ def show @page = Page.find(params[:id]) respond_to do |format| format.json do - render json: @page.as_json(only: [:id, :image], methods: [:image_url]) + render json: @page.as_json(only: %i[id image], methods: [:image_url]) end end end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 501b7d9..a0f10ae 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Front-end controller for people class PeopleController < InheritedResources::Base # GET /people diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 1f76438..b64eec6 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Front-end controller for home page class SiteController < InheritedResources::Base # GET /pages diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index b520a60..69cd001 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Front-end controller for static pages # e.g. publications, workshops, submissions class StaticController < ApplicationController diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 44fdac4..ecbcd95 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Front-end controller for stories class StoriesController < InheritedResources::Base # GET /stories diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d06cda0..7bb255f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # General helpers module ApplicationHelper def nav_link(link_text, link_path) @@ -17,6 +19,7 @@ def rating_dot(story) def rating_info(rateable) rateable_class = rateable.class.name.downcase return t("#{rateable_class}.rating.unrated") unless rateable.rating + case rateable.rating.to_sym when :green then t("#{rateable_class}.rating.green") when :yellow then t("#{rateable_class}.rating.yellow") @@ -34,22 +37,21 @@ def badge(badgeable) end end - def creator_list(creators, current_creator=nil) + def creator_list(creators, current_creator = nil) if current_creator - creators = creators.to_a.delete_if{|p| p == current_creator} + creators = creators.to_a.delete_if { |p| p == current_creator } if creators.size > 1 - "(with others)" - elsif creators.size > 0 - creator_links = creators.map{|creator| link_to creator.name, creator}.join(', ').html_safe + '(with others)' + elsif !creators.empty? + creator_links = creators.map { |creator| link_to creator.name, creator }.join(', ').html_safe "(with #{creator_links})".html_safe end else if creators.count > 2 - "Various Artists" + 'Various Artists' else - creators.map{|creator| link_to creator.name, creator}.join(', ').html_safe + creators.map { |creator| link_to creator.name, creator }.join(', ').html_safe end end - end end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index bfb9d25..fd90767 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module IssuesHelper end diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb index 080c05c..ee42d87 100644 --- a/app/models/admin_user.rb +++ b/app/models/admin_user.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + # A user who can log in to edit the site -class AdminUser < ActiveRecord::Base +class AdminUser < ApplicationRecord # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 0000000..71fbba5 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/concerns/filterable.rb b/app/models/concerns/filterable.rb index d973dea..5619708 100644 --- a/app/models/concerns/filterable.rb +++ b/app/models/concerns/filterable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # For classes that can be filtered through scopes module Filterable extend ActiveSupport::Concern diff --git a/app/models/concerns/rateable.rb b/app/models/concerns/rateable.rb index 6b8ae9d..2b7e30e 100644 --- a/app/models/concerns/rateable.rb +++ b/app/models/concerns/rateable.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + # For classes that can be given a colour rating for age-appropriateness module Rateable extend ActiveSupport::Concern included do - enum rating: [:green, :yellow, :red, :blue] - scope :rating, -> (rating_text) { where(rating: Story.ratings[rating_text]) } + enum rating: %i[green yellow red blue] + scope :rating, ->(rating_text) { where(rating: Story.ratings[rating_text]) } end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 9d70569..7866c03 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1,24 +1,26 @@ +# frozen_string_literal: true + # A Funtime issue, showing how the stories were originally published. -class Issue < ActiveRecord::Base +class Issue < ApplicationRecord extend FriendlyId - friendly_id :title, use: [:slugged, :history] + friendly_id :title, use: %i[slugged history] include Filterable include Rateable has_attached_file :cover_image, - styles: { medium: "500x500>", thumb: "300x300>" }, - default_url: "/default_images/:style/issue.png" + styles: { medium: '500x500>', thumb: '300x300>' }, + default_url: '/default_images/:style/issue.png' has_many :pages accepts_nested_attributes_for :pages - scope :ordered, -> { order("position ASC") } + scope :ordered, -> { order('position ASC') } validates_attachment :cover_image, - content_type: { content_type: ["image/jpg", - "image/jpeg", - "image/gif", - "image/png"] }, + content_type: { content_type: ['image/jpg', + 'image/jpeg', + 'image/gif', + 'image/png'] }, size: { in: 0..5.megabytes } validates :title, presence: true, uniqueness: true validates :issue_number, uniqueness: true diff --git a/app/models/page.rb b/app/models/page.rb index d571897..476440f 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + # A single comics page -class Page < ActiveRecord::Base +class Page < ApplicationRecord delegate :name, to: :story, prefix: true has_attached_file :image, diff --git a/app/models/person.rb b/app/models/person.rb index 78c5a44..e4de217 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # An author, artistor other creator -class Person < ActiveRecord::Base +class Person < ApplicationRecord extend FriendlyId - friendly_id :name, use: [:slugged, :history] + friendly_id :name, use: %i[slugged history] has_attached_file :image, styles: { original: '300x300>', thumb: '100x100>' }, diff --git a/app/models/story.rb b/app/models/story.rb index 1fec265..af2e4fc 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # A Story is a collection of pages, with one or more people as creators. -class Story < ActiveRecord::Base +class Story < ApplicationRecord extend FriendlyId - friendly_id :name, use: [:slugged, :history] + friendly_id :name, use: %i[slugged history] include Filterable include Rateable @@ -28,8 +30,8 @@ class Story < ActiveRecord::Base def page_count page_count = pages.count - page_count += 1 if self.blue? - page_count += 1 if self.unfinished? + page_count += 1 if blue? + page_count += 1 if unfinished? page_count end @@ -56,11 +58,10 @@ def badge month_ago = 1.month.ago.utc if created_at > month_ago :new - elsif pages.last(2).all?{|page| page.created_at > month_ago} + elsif pages.last(2).all? { |page| page.created_at > month_ago } :new_pages elsif pages.last.created_at > month_ago :new_page end end - end diff --git a/bin/bundle b/bin/bundle index 66e9889..2dbb717 100755 --- a/bin/bundle +++ b/bin/bundle @@ -1,3 +1,5 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +# frozen_string_literal: true + +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails index 728cd85..a31728a 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,6 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) +# frozen_string_literal: true + +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 1724048..c199955 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..c2e43ce --- /dev/null +++ b/bin/setup @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +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. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + 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/bin/update b/bin/update new file mode 100755 index 0000000..313c74b --- /dev/null +++ b/bin/update @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +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') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + 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/bin/yarn b/bin/yarn new file mode 100755 index 0000000..4cac416 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + exec 'yarnpkg', *ARGV +rescue Errno::ENOENT + warn 'Yarn executable was not detected in the system.' + warn 'Download Yarn at https://yarnpkg.com/en/docs/install' + exit 1 +end diff --git a/config.ru b/config.ru index a034a4b..a24c22a 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,6 @@ +# frozen_string_literal: true + # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require ::File.expand_path('../config/environment', __FILE__) run FuntimeApp::Application diff --git a/config/application.rb b/config/application.rb index e2c9dec..b29eb1f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,71 +1,21 @@ -require File.expand_path('../boot', __FILE__) +# frozen_string_literal: true + +require_relative 'boot' require 'rails/all' -if defined?(Bundler) - # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(assets: %w(development test))) - # If you want your assets lazily compiled in production, use this line - # Bundler.require(:default, :assets, Rails.env) -end +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) module FuntimeApp class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named. - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Activate observers that should always be running. - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de - - # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" - - # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters += [:password] - - # Enable escaping HTML in JSON. - config.active_support.escape_html_entities_in_json = true - - # Use SQL instead of Active Record's schema dumper when creating the database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql - - # Enable the asset pipeline - config.assets.enabled = true - - # Version of your assets, change this if you want to expire all your assets - config.assets.version = '1.0' - - config.generators do |g| - g.test_framework :rspec, - fixtures: true, - view_specs: false, - helper_specs: true, - routing_specs: true, - controller_specs: true, - request_specs: true - g.fixture_replacement :factory_girl, dir: "spec/factories" - end - - # http://wearestac.com/blog/dynamic-error-pages-in-rails - config.exceptions_app = self.routes + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.0 + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. end end diff --git a/config/boot.rb b/config/boot.rb index 4489e58..c04863f 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,6 +1,6 @@ -require 'rubygems' +# frozen_string_literal: true -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 0000000..fc34ae5 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: funtime_app_production diff --git a/config/compass.rb b/config/compass.rb index 2b22d5d..81dc9bd 100644 --- a/config/compass.rb +++ b/config/compass.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + # Require any additional compass plugins here. project_type = :rails diff --git a/config/environment.rb b/config/environment.rb index bcd0a1c..d5abe55 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,7 @@ -# Load the rails application -require File.expand_path('../application', __FILE__) +# frozen_string_literal: true -# Initialize the rails application -FuntimeApp::Application.initialize! +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 4fbf56d..33c8acf 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,5 +1,7 @@ -FuntimeApp::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +# frozen_string_literal: true + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development @@ -9,46 +11,53 @@ # Do not eager load code on boot. config.eager_load = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + 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=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false - # Show full error reports and disable caching - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local - # Don't care if the mailer can't send + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false - # Print deprecation notices to the Rails logger - config.active_support.deprecation = :log + config.action_mailer.perform_caching = false - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - # config.active_record.auto_explain_threshold_in_seconds = 0.5 + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load - # Do not compress assets - config.assets.compress = false + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true - # Expands the lines which load the assets + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. config.assets.debug = true - - config.after_initialize do - Bullet.enable = true - # Bullet.alert = true - Bullet.bullet_logger = true - Bullet.console = true - # Bullet.growl = true - # Bullet.xmpp = { :account => 'bullets_account@jabber.org', - # :password => 'bullets_password_for_jabber', - # :receiver => 'your_account@jabber.org', - # :show_online_status => true } - Bullet.rails_logger = true - # Bullet.bugsnag = true - # Bullet.airbrake = true - Bullet.add_footer = true - # Bullet.stacktrace_includes = [ 'your_gem', 'your_middleware' ] - end + + # 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 end diff --git a/config/environments/production.rb b/config/environments/production.rb index 7ffb76c..e3dc380 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,82 +1,96 @@ -FuntimeApp::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +# frozen_string_literal: true - # Code is not reloaded between requests +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both thread web servers + # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true - # Full error reports are disabled and caching is turned on + # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? - # Compress JavaScripts and CSS - config.assets.compress = true + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass - # Don't fallback to assets pipeline if a precompiled asset is missed + # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Generate digests for assets URLs - config.assets.digest = true + # `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' - # Defaults to nil and saved in location specified by config.assets.prefix - # config.assets.manifest = YOUR_PATH + # 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 - # 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 + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # 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 - # See everything in the log (default is :info) - # config.log_level = :debug - - # Prepend all log lines with the following tags - # config.log_tags = [ :subdomain, :uuid ] + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug - # Use a different logger for distributed setups - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + # Prepend all log lines with the following tags. + config.log_tags = [:request_id] - # Use a different cache store in production + # 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 = "funtime_app_#{Rails.env}" - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) + config.action_mailer.perform_caching = false - # Disable delivery errors, bad email addresses will be ignored + # 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. # config.action_mailer.raise_delivery_errors = false - # Enable threaded mode - # config.threadsafe! - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners + # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - # config.active_record.auto_explain_threshold_in_seconds = 0.5 - - config.paperclip_defaults = { - :storage => :s3, - :s3_credentials => { - :bucket => ENV['S3_BUCKET_NAME'], - :access_key_id => ENV['AWS_ACCESS_KEY_ID'], - :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'] - } - } + # 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 end diff --git a/config/environments/test.rb b/config/environments/test.rb index 14cc4aa..611059c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,5 +1,7 @@ -FuntimeApp::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +# frozen_string_literal: true + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that @@ -12,28 +14,35 @@ # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true - config.static_cache_control = "public, max-age=3600" - - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true + # 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=#{1.hour.to_i}" + } - # Show full error reports and disable caching + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - # Raise exceptions instead of rendering exception templates + # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + 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 - # Print deprecation notices to the stderr + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + + # Raises error for missing translations + config.action_view.raise_on_missing_translations = true end diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb index fd20105..5765457 100644 --- a/config/initializers/active_admin.rb +++ b/config/initializers/active_admin.rb @@ -1,11 +1,12 @@ -ActiveAdmin.setup do |config| +# frozen_string_literal: true +ActiveAdmin.setup do |config| # == Site Title # # Set the title that is displayed on the main layout # for each of the active admin pages. # - config.site_title = "Funtime Comics Admin" + config.site_title = 'Funtime Comics Admin' # Set the link url for the title. For example, to take # users to your main site. Defaults to no link. @@ -84,7 +85,6 @@ # (within the application controller) to return the currently logged in user. config.current_user_method = :current_admin_user - # == Logging Out # # Active Admin displays a logout link on each screen. These @@ -103,7 +103,6 @@ # Default: # config.logout_link_method = :get - # == Root # # Set the action to call for the root path. You can set different @@ -112,7 +111,6 @@ # Default: # config.root_to = 'dashboard#index' - # == Admin Comments # # This allows your users to comment on any resource registered with Active Admin. @@ -126,14 +124,12 @@ # You can change the name under which comments are registered: # config.comments_registration_name = 'AdminComment' - # == Batch Actions # # Enable and disable Batch Actions # config.batch_actions = true - # == Controller Filters # # You can add before, after and around filters to all of your @@ -141,12 +137,10 @@ # # config.before_filter :do_something_awesome - # == Setting a Favicon # # config.favicon = '/assets/favicon.ico' - # == Removing Breadcrumbs # # Breadcrumbs are enabled by default. You can customize them for individual @@ -154,7 +148,6 @@ # # config.breadcrumb = false - # == Register Stylesheets & Javascripts # # We recommend using the built in Active Admin layout and loading @@ -170,7 +163,6 @@ # To load a javascript file: # config.register_javascript 'my_javascript.js' - # == CSV options # # Set the CSV builder separator @@ -179,7 +171,6 @@ # Force the use of quotes # config.csv_options = { :force_quotes => true } - # == Menu System # # You can add a navigation menu to be used in your application, or configure a provided menu @@ -201,7 +192,6 @@ # end # end - # == Download Links # # You can disable download links on resource listing pages, @@ -223,7 +213,6 @@ # # end - # == Pagination # # Pagination is enabled by default for all resources. @@ -231,7 +220,6 @@ # # config.default_per_page = 30 - # == Filters # # By default the index screen includes a “Filters” sidebar on the right @@ -239,13 +227,12 @@ # You can enable or disable them for all resources here. # # config.filters = true - end # Source: http://blog.jerodsanto.net/2013/11/make-active-admin-and-friendy-id-play-nice/ ActiveAdmin::ResourceController.class_eval do def find_resource - id_field = "id" + id_field = 'id' if scoped_collection.is_a? FriendlyId id_field = scoped_collection.friendly_id_config.query_field diff --git a/config/initializers/active_admin_editor.rb b/config/initializers/active_admin_editor.rb index 3815a08..f8ac23b 100644 --- a/config/initializers/active_admin_editor.rb +++ b/config/initializers/active_admin_editor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActiveAdmin::Editor.configure do |config| # config.s3_bucket = '' # config.aws_access_key_id = '' diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..6d56e43 --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000..a9b0d0f --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cd..4b63f28 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..e3c9649 --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..20a704a --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +# 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 = :marshal diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 6886c51..3ad675c 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. - config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" + config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' # Configure the class responsible to send e-mails. # config.mailer = "Devise::Mailer" @@ -35,12 +37,12 @@ # Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. - config.case_insensitive_keys = [ :email ] + config.case_insensitive_keys = [:email] # Configure which authentication keys should have whitespace stripped. # These keys will have whitespace before and after removed upon creating or # modifying a user and when used to authenticate or find a user. Default is :email. - config.strip_whitespace_keys = [ :email ] + config.strip_whitespace_keys = [:email] # Tell if authentication through request.params is enabled. True by default. # It can be set to an array that will enable params authentication only for the diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..7a4f47b --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 5d8d9be..dc84742 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,15 +1,18 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end -# + # These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections do |inflect| +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb index a28987a..f2b289c 100644 --- a/config/initializers/kaminari_config.rb +++ b/config/initializers/kaminari_config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Kaminari.configure do |config| config.default_per_page = 24 # config.max_per_page = nil diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e..be6fedc 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,5 +1,6 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb new file mode 100644 index 0000000..c300f21 --- /dev/null +++ b/config/initializers/new_framework_defaults_5_2.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.2 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Make Active Record use stable #cache_key alongside new #cache_version method. +# This is needed for recyclable cache keys. +# Rails.application.config.active_record.cache_versioning = true + +# Use AES-256-GCM authenticated encryption for encrypted cookies. +# Also, embed cookie expiry in signed or encrypted cookies for increased security. +# +# This option is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 5.2. +# +# Existing cookies will be converted on read then written with the new scheme. +# Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true + +# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages +# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true. +# Rails.application.config.active_support.use_authenticated_message_encryption = true + +# Add default protection from forgery to ActionController::Base instead of in +# ApplicationController. +# Rails.application.config.action_controller.default_protect_from_forgery = true + +# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and +# 'f' after migrating old data. +# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true + +# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header. +# Rails.application.config.active_support.use_sha1_digests = true + +# Make `form_with` generate id attributes for any generated HTML tags. +# Rails.application.config.action_view.form_with_generates_ids = true diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 5a907a6..236ef77 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # config/initializers/paperclip.rb # Paperclip::Attachment.default_options[:url] = ':s3_domain_url' # Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename' diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index e3b9f39..368ac31 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -1,11 +1,13 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -FuntimeApp::Application.config.secret_token = if Rails.env.development? or Rails.env.test? - ('x' * 30) # meets minimum requirement of 30 chars long -else - ENV['SECRET_TOKEN'] -end \ No newline at end of file +FuntimeApp::Application.config.secret_token = if Rails.env.development? || Rails.env.test? + ('x' * 30) # meets minimum requirement of 30 chars long + else + ENV['SECRET_TOKEN'] +end diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index c5bddb2..7694303 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. FuntimeApp::Application.config.session_store :cookie_store, key: '_funtime_app_session' diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 999df20..2f3c0db 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. -# + # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. @@ -8,7 +10,7 @@ wrap_parameters format: [:json] end -# Disable root element in JSON by default. -ActiveSupport.on_load(:active_record) do - self.include_root_in_json = false -end +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/en.yml b/config/locales/en.yml index b405dc6..259dc31 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,33 @@ -# Sample localization file for English. Add more files in this directory for other locales. -# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. en: admin: diff --git a/config/routes.rb b/config/routes.rb index edbc5b2..884c4a7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,75 +1,24 @@ -FuntimeApp::Application.routes.draw do +# frozen_string_literal: true + +Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + resources :issues devise_for :admin_users, ActiveAdmin::Devise.config resources :people - resources :stories, only: [:index, :show] + resources :stories, only: %i[index show] resources :pages, only: [:show] root to: 'site#index' ActiveAdmin.routes(self) - # The priority is based upon order of creation: - # first created -> highest priority. - - # Sample of regular route: - # match 'products/:id' => 'catalog#view' - # Keep in mind you can assign values other than :controller and :action - - # Sample of named route: - # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase - # This route can be invoked with purchase_url(:id => product.id) - - # Sample resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Sample resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Sample resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Sample resource route with more complex sub-resources - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', :on => :collection - # end - # end - - # Sample resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end - - - # See how all your routes lay out with "rake routes" - - # This is a legacy wild controller route that's not recommended for RESTful applications. - # Note: This route will make all actions in every controller accessible via GET requests. - # match ':controller(/:action(/:id))(.:format)' - - %w( 404 422 500 ).each do |code| - get code, to: "errors#show", code: code + %w[404 422 500].each do |code| + get code, to: 'errors#show', code: code end # If all else fails, check for static pages get ':action' => 'static#:action' - end diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/db/migrate/20130630013810_devise_create_admin_users.rb b/db/migrate/20130630013810_devise_create_admin_users.rb index 9738faf..d63d795 100644 --- a/db/migrate/20130630013810_devise_create_admin_users.rb +++ b/db/migrate/20130630013810_devise_create_admin_users.rb @@ -1,4 +1,6 @@ -class DeviseCreateAdminUsers < ActiveRecord::Migration +# frozen_string_literal: true + +class DeviseCreateAdminUsers < ActiveRecord::Migration[4.2][4.2] # def migrate(direction) # super # # Create a default user @@ -8,8 +10,8 @@ class DeviseCreateAdminUsers < ActiveRecord::Migration def change create_table(:admin_users) do |t| ## Database authenticatable - t.string :email, :null => false, :default => "" - t.string :encrypted_password, :null => false, :default => "" + t.string :email, null: false, default: '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token @@ -19,7 +21,7 @@ def change t.datetime :remember_created_at ## Trackable - t.integer :sign_in_count, :default => 0 + t.integer :sign_in_count, default: 0 t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -39,12 +41,11 @@ def change ## Token authenticatable # t.string :authentication_token - t.timestamps end - add_index :admin_users, :email, :unique => true - add_index :admin_users, :reset_password_token, :unique => true + add_index :admin_users, :email, unique: true + add_index :admin_users, :reset_password_token, unique: true # add_index :admin_users, :confirmation_token, :unique => true # add_index :admin_users, :unlock_token, :unique => true # add_index :admin_users, :authentication_token, :unique => true diff --git a/db/migrate/20130630013812_create_admin_notes.rb b/db/migrate/20130630013812_create_admin_notes.rb index e106af3..8e9aaaf 100644 --- a/db/migrate/20130630013812_create_admin_notes.rb +++ b/db/migrate/20130630013812_create_admin_notes.rb @@ -1,14 +1,16 @@ -class CreateAdminNotes < ActiveRecord::Migration +# frozen_string_literal: true + +class CreateAdminNotes < ActiveRecord::Migration[4.2] def self.up create_table :admin_notes do |t| - t.string :resource_id, :null => false - t.string :resource_type, :null => false - t.references :admin_user, :polymorphic => true + t.string :resource_id, null: false + t.string :resource_type, null: false + t.references :admin_user, polymorphic: true t.text :body t.timestamps end - add_index :admin_notes, [:resource_type, :resource_id] - add_index :admin_notes, [:admin_user_type, :admin_user_id] + add_index :admin_notes, %i[resource_type resource_id] + add_index :admin_notes, %i[admin_user_type admin_user_id] end def self.down diff --git a/db/migrate/20130630013813_move_admin_notes_to_comments.rb b/db/migrate/20130630013813_move_admin_notes_to_comments.rb index 8833359..997ba51 100644 --- a/db/migrate/20130630013813_move_admin_notes_to_comments.rb +++ b/db/migrate/20130630013813_move_admin_notes_to_comments.rb @@ -1,26 +1,28 @@ -class MoveAdminNotesToComments < ActiveRecord::Migration +# frozen_string_literal: true + +class MoveAdminNotesToComments < ActiveRecord::Migration[4.2] def self.up - remove_index :admin_notes, [:admin_user_type, :admin_user_id] + remove_index :admin_notes, %i[admin_user_type admin_user_id] rename_table :admin_notes, :active_admin_comments rename_column :active_admin_comments, :admin_user_type, :author_type rename_column :active_admin_comments, :admin_user_id, :author_id add_column :active_admin_comments, :namespace, :string add_index :active_admin_comments, [:namespace] - add_index :active_admin_comments, [:author_type, :author_id] + add_index :active_admin_comments, %i[author_type author_id] # Update all the existing comments to the default namespace say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace." - comments_table_name = ActiveRecord::Migrator.proper_table_name("active_admin_comments") + comments_table_name = ActiveRecord::Migration.proper_table_name('active_admin_comments') execute "UPDATE #{comments_table_name} SET namespace='#{ActiveAdmin.application.default_namespace}'" end def self.down - remove_index :active_admin_comments, :column => [:author_type, :author_id] - remove_index :active_admin_comments, :column => [:namespace] + remove_index :active_admin_comments, column: %i[author_type author_id] + remove_index :active_admin_comments, column: [:namespace] remove_column :active_admin_comments, :namespace rename_column :active_admin_comments, :author_id, :admin_user_id rename_column :active_admin_comments, :author_type, :admin_user_type rename_table :active_admin_comments, :admin_notes - add_index :admin_notes, [:admin_user_type, :admin_user_id] + add_index :admin_notes, %i[admin_user_type admin_user_id] end end diff --git a/db/migrate/20130630033710_create_pages.rb b/db/migrate/20130630033710_create_pages.rb index b8ec14b..9793b6f 100644 --- a/db/migrate/20130630033710_create_pages.rb +++ b/db/migrate/20130630033710_create_pages.rb @@ -1,4 +1,6 @@ -class CreatePages < ActiveRecord::Migration +# frozen_string_literal: true + +class CreatePages < ActiveRecord::Migration[4.2] def change create_table :pages do |t| t.belongs_to :story diff --git a/db/migrate/20130630034301_add_image_to_page.rb b/db/migrate/20130630034301_add_image_to_page.rb index a288960..9bfbeeb 100644 --- a/db/migrate/20130630034301_add_image_to_page.rb +++ b/db/migrate/20130630034301_add_image_to_page.rb @@ -1,4 +1,6 @@ -class AddImageToPage < ActiveRecord::Migration +# frozen_string_literal: true + +class AddImageToPage < ActiveRecord::Migration[4.2] def self.up add_attachment :pages, :image end diff --git a/db/migrate/20130630041556_create_controllers.rb b/db/migrate/20130630041556_create_controllers.rb index 9967373..b312536 100644 --- a/db/migrate/20130630041556_create_controllers.rb +++ b/db/migrate/20130630041556_create_controllers.rb @@ -1,4 +1,6 @@ -class CreateControllers < ActiveRecord::Migration +# frozen_string_literal: true + +class CreateControllers < ActiveRecord::Migration[4.2] def change create_table :controllers do |t| t.string :Pages diff --git a/db/migrate/20130630044219_create_stories.rb b/db/migrate/20130630044219_create_stories.rb index a5db8c0..704998a 100644 --- a/db/migrate/20130630044219_create_stories.rb +++ b/db/migrate/20130630044219_create_stories.rb @@ -1,4 +1,6 @@ -class CreateStories < ActiveRecord::Migration +# frozen_string_literal: true + +class CreateStories < ActiveRecord::Migration[4.2] def change create_table :stories do |t| t.string :name diff --git a/db/migrate/20130630054705_create_people.rb b/db/migrate/20130630054705_create_people.rb index 326338b..2db87c4 100644 --- a/db/migrate/20130630054705_create_people.rb +++ b/db/migrate/20130630054705_create_people.rb @@ -1,4 +1,6 @@ -class CreatePeople < ActiveRecord::Migration +# frozen_string_literal: true + +class CreatePeople < ActiveRecord::Migration[4.2] def change create_table :people do |t| t.string :name diff --git a/db/migrate/20130630061605_add_images_to_people.rb b/db/migrate/20130630061605_add_images_to_people.rb index 2e3921f..41d8662 100644 --- a/db/migrate/20130630061605_add_images_to_people.rb +++ b/db/migrate/20130630061605_add_images_to_people.rb @@ -1,4 +1,6 @@ -class AddImagesToPeople < ActiveRecord::Migration +# frozen_string_literal: true + +class AddImagesToPeople < ActiveRecord::Migration[4.2] def self.up add_attachment :people, :image end diff --git a/db/migrate/20130907063121_add_position_to_page.rb b/db/migrate/20130907063121_add_position_to_page.rb index 310f5f6..90fe2e3 100644 --- a/db/migrate/20130907063121_add_position_to_page.rb +++ b/db/migrate/20130907063121_add_position_to_page.rb @@ -1,4 +1,6 @@ -class AddPositionToPage < ActiveRecord::Migration +# frozen_string_literal: true + +class AddPositionToPage < ActiveRecord::Migration[4.2] def change add_column :pages, :position, :integer end diff --git a/db/migrate/20131229202743_add_image_to_story.rb b/db/migrate/20131229202743_add_image_to_story.rb index 17c4374..3b0ffae 100644 --- a/db/migrate/20131229202743_add_image_to_story.rb +++ b/db/migrate/20131229202743_add_image_to_story.rb @@ -1,4 +1,6 @@ -class AddImageToStory < ActiveRecord::Migration +# frozen_string_literal: true + +class AddImageToStory < ActiveRecord::Migration[4.2] def self.up add_attachment :stories, :cover_image end diff --git a/db/migrate/20140103021434_add_slug_to_stories.rb b/db/migrate/20140103021434_add_slug_to_stories.rb index 6acc5bd..8cc7911 100644 --- a/db/migrate/20140103021434_add_slug_to_stories.rb +++ b/db/migrate/20140103021434_add_slug_to_stories.rb @@ -1,4 +1,6 @@ -class AddSlugToStories < ActiveRecord::Migration +# frozen_string_literal: true + +class AddSlugToStories < ActiveRecord::Migration[4.2] def change add_column :stories, :slug, :string add_index :stories, :slug diff --git a/db/migrate/20140103021717_create_friendly_id_slugs.rb b/db/migrate/20140103021717_create_friendly_id_slugs.rb index bb80e48..8319ca9 100644 --- a/db/migrate/20140103021717_create_friendly_id_slugs.rb +++ b/db/migrate/20140103021717_create_friendly_id_slugs.rb @@ -1,14 +1,15 @@ -class CreateFriendlyIdSlugs < ActiveRecord::Migration +# frozen_string_literal: true +class CreateFriendlyIdSlugs < ActiveRecord::Migration[4.2] def self.up create_table :friendly_id_slugs do |t| - t.string :slug, :null => false - t.integer :sluggable_id, :null => false - t.string :sluggable_type, :limit => 40 + t.string :slug, null: false + t.integer :sluggable_id, null: false + t.string :sluggable_type, limit: 40 t.datetime :created_at end add_index :friendly_id_slugs, :sluggable_id - add_index :friendly_id_slugs, [:slug, :sluggable_type], :unique => true + add_index :friendly_id_slugs, %i[slug sluggable_type], unique: true add_index :friendly_id_slugs, :sluggable_type end diff --git a/db/migrate/20140103021749_add_slug_to_people.rb b/db/migrate/20140103021749_add_slug_to_people.rb index 9deb257..26dff3a 100644 --- a/db/migrate/20140103021749_add_slug_to_people.rb +++ b/db/migrate/20140103021749_add_slug_to_people.rb @@ -1,4 +1,6 @@ -class AddSlugToPeople < ActiveRecord::Migration +# frozen_string_literal: true + +class AddSlugToPeople < ActiveRecord::Migration[4.2] def change add_column :people, :slug, :string add_index :people, :slug diff --git a/db/migrate/20140306045321_add_story_index_to_pages.rb b/db/migrate/20140306045321_add_story_index_to_pages.rb index fdd778e..07b8c3a 100644 --- a/db/migrate/20140306045321_add_story_index_to_pages.rb +++ b/db/migrate/20140306045321_add_story_index_to_pages.rb @@ -1,4 +1,6 @@ -class AddStoryIndexToPages < ActiveRecord::Migration +# frozen_string_literal: true + +class AddStoryIndexToPages < ActiveRecord::Migration[4.2] def change add_index :pages, :story_id end diff --git a/db/migrate/20140306045819_add_indices_to_people_stories.rb b/db/migrate/20140306045819_add_indices_to_people_stories.rb index 3c65cc6..f632c4d 100644 --- a/db/migrate/20140306045819_add_indices_to_people_stories.rb +++ b/db/migrate/20140306045819_add_indices_to_people_stories.rb @@ -1,4 +1,6 @@ -class AddIndicesToPeopleStories < ActiveRecord::Migration +# frozen_string_literal: true + +class AddIndicesToPeopleStories < ActiveRecord::Migration[4.2] def change add_index :people_stories, :story_id add_index :people_stories, :person_id diff --git a/db/migrate/20140323214706_change_people_bio_to_text.rb b/db/migrate/20140323214706_change_people_bio_to_text.rb index 465c4bd..b5c0c9a 100644 --- a/db/migrate/20140323214706_change_people_bio_to_text.rb +++ b/db/migrate/20140323214706_change_people_bio_to_text.rb @@ -1,10 +1,13 @@ -class ChangePeopleBioToText < ActiveRecord::Migration -def up +# frozen_string_literal: true + +class ChangePeopleBioToText < ActiveRecord::Migration[4.2] + def up change_column :people, :bio, :text -end -def down + end + + def down # This might cause trouble if you have strings longer # than 255 characters. change_column :people, :bio, :string -end + end end diff --git a/db/migrate/20140427060246_add_description_to_stories.rb b/db/migrate/20140427060246_add_description_to_stories.rb index 904090a..081ebde 100644 --- a/db/migrate/20140427060246_add_description_to_stories.rb +++ b/db/migrate/20140427060246_add_description_to_stories.rb @@ -1,4 +1,6 @@ -class AddDescriptionToStories < ActiveRecord::Migration +# frozen_string_literal: true + +class AddDescriptionToStories < ActiveRecord::Migration[4.2] def change add_column :stories, :description, :text end diff --git a/db/migrate/20140630101132_add_page_counter_cache_to_stories.rb b/db/migrate/20140630101132_add_page_counter_cache_to_stories.rb index 333793e..3aa5b81 100644 --- a/db/migrate/20140630101132_add_page_counter_cache_to_stories.rb +++ b/db/migrate/20140630101132_add_page_counter_cache_to_stories.rb @@ -1,4 +1,6 @@ -class AddPageCounterCacheToStories < ActiveRecord::Migration +# frozen_string_literal: true + +class AddPageCounterCacheToStories < ActiveRecord::Migration[4.2] def change add_column :stories, :pages_count, :integer end diff --git a/db/migrate/20140726011515_add_rating_to_stories.rb b/db/migrate/20140726011515_add_rating_to_stories.rb index d8f087c..d53c0ea 100644 --- a/db/migrate/20140726011515_add_rating_to_stories.rb +++ b/db/migrate/20140726011515_add_rating_to_stories.rb @@ -1,4 +1,6 @@ -class AddRatingToStories < ActiveRecord::Migration +# frozen_string_literal: true + +class AddRatingToStories < ActiveRecord::Migration[4.2] def change add_column :stories, :rating, :integer end diff --git a/db/migrate/20141020061254_add_unfinished_to_story.rb b/db/migrate/20141020061254_add_unfinished_to_story.rb index 3aae8ea..b360ab7 100644 --- a/db/migrate/20141020061254_add_unfinished_to_story.rb +++ b/db/migrate/20141020061254_add_unfinished_to_story.rb @@ -1,4 +1,6 @@ -class AddUnfinishedToStory < ActiveRecord::Migration +# frozen_string_literal: true + +class AddUnfinishedToStory < ActiveRecord::Migration[4.2] def change add_column :stories, :unfinished, :boolean end diff --git a/db/migrate/20160318035722_create_issues.rb b/db/migrate/20160318035722_create_issues.rb index af97798..829a96e 100644 --- a/db/migrate/20160318035722_create_issues.rb +++ b/db/migrate/20160318035722_create_issues.rb @@ -1,4 +1,6 @@ -class CreateIssues < ActiveRecord::Migration +# frozen_string_literal: true + +class CreateIssues < ActiveRecord::Migration[4.2] def change create_table :issues do |t| t.string :title diff --git a/db/migrate/20160318043150_add_slug_to_issues.rb b/db/migrate/20160318043150_add_slug_to_issues.rb index baf3d2a..e19d10d 100644 --- a/db/migrate/20160318043150_add_slug_to_issues.rb +++ b/db/migrate/20160318043150_add_slug_to_issues.rb @@ -1,4 +1,6 @@ -class AddSlugToIssues < ActiveRecord::Migration +# frozen_string_literal: true + +class AddSlugToIssues < ActiveRecord::Migration[4.2] def change add_column :issues, :slug, :string add_index :issues, :slug diff --git a/db/migrate/20160318201858_add_rating_to_issues.rb b/db/migrate/20160318201858_add_rating_to_issues.rb index af56fa7..36e6486 100644 --- a/db/migrate/20160318201858_add_rating_to_issues.rb +++ b/db/migrate/20160318201858_add_rating_to_issues.rb @@ -1,4 +1,6 @@ -class AddRatingToIssues < ActiveRecord::Migration +# frozen_string_literal: true + +class AddRatingToIssues < ActiveRecord::Migration[4.2] def change add_column :issues, :rating, :integer end diff --git a/db/migrate/20160318224613_add_issue_id_to_pages.rb b/db/migrate/20160318224613_add_issue_id_to_pages.rb index 3645655..6ae7bac 100644 --- a/db/migrate/20160318224613_add_issue_id_to_pages.rb +++ b/db/migrate/20160318224613_add_issue_id_to_pages.rb @@ -1,4 +1,6 @@ -class AddIssueIdToPages < ActiveRecord::Migration +# frozen_string_literal: true + +class AddIssueIdToPages < ActiveRecord::Migration[4.2] def change add_belongs_to :pages, :issue end diff --git a/db/migrate/20160318230403_add_page_counter_cache_to_issues.rb b/db/migrate/20160318230403_add_page_counter_cache_to_issues.rb index d3b8de6..2da0897 100644 --- a/db/migrate/20160318230403_add_page_counter_cache_to_issues.rb +++ b/db/migrate/20160318230403_add_page_counter_cache_to_issues.rb @@ -1,4 +1,6 @@ -class AddPageCounterCacheToIssues < ActiveRecord::Migration +# frozen_string_literal: true + +class AddPageCounterCacheToIssues < ActiveRecord::Migration[4.2] def change add_column :issues, :pages_count, :integer end diff --git a/db/migrate/20160318232514_add_page_numbers.rb b/db/migrate/20160318232514_add_page_numbers.rb index db275f7..5048c91 100644 --- a/db/migrate/20160318232514_add_page_numbers.rb +++ b/db/migrate/20160318232514_add_page_numbers.rb @@ -1,4 +1,6 @@ -class AddPageNumbers < ActiveRecord::Migration +# frozen_string_literal: true + +class AddPageNumbers < ActiveRecord::Migration[4.2] def change rename_column :pages, :position, :story_page_number add_column :pages, :issue_page_number, :integer diff --git a/db/migrate/20160319063617_add_purchase_url_to_issues.rb b/db/migrate/20160319063617_add_purchase_url_to_issues.rb index b857ed3..56f8186 100644 --- a/db/migrate/20160319063617_add_purchase_url_to_issues.rb +++ b/db/migrate/20160319063617_add_purchase_url_to_issues.rb @@ -1,4 +1,6 @@ -class AddPurchaseUrlToIssues < ActiveRecord::Migration +# frozen_string_literal: true + +class AddPurchaseUrlToIssues < ActiveRecord::Migration[4.2] def change add_column :issues, :purchase_url, :string end diff --git a/db/migrate/20160319083703_add_description_to_issues.rb b/db/migrate/20160319083703_add_description_to_issues.rb index e47e3f8..ff81214 100644 --- a/db/migrate/20160319083703_add_description_to_issues.rb +++ b/db/migrate/20160319083703_add_description_to_issues.rb @@ -1,4 +1,6 @@ -class AddDescriptionToIssues < ActiveRecord::Migration +# frozen_string_literal: true + +class AddDescriptionToIssues < ActiveRecord::Migration[4.2] def change add_column :issues, :description, :text end diff --git a/db/migrate/20160319090117_add_description_to_pages.rb b/db/migrate/20160319090117_add_description_to_pages.rb index 9055160..2176880 100644 --- a/db/migrate/20160319090117_add_description_to_pages.rb +++ b/db/migrate/20160319090117_add_description_to_pages.rb @@ -1,4 +1,6 @@ -class AddDescriptionToPages < ActiveRecord::Migration +# frozen_string_literal: true + +class AddDescriptionToPages < ActiveRecord::Migration[4.2] def change add_column :pages, :description, :text end diff --git a/db/schema.rb b/db/schema.rb index 67b5fae..cea341d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,5 @@ -# encoding: UTF-8 +# frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -11,147 +12,123 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160319090117) do - +ActiveRecord::Schema.define(version: 20_160_319_090_117) do # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" - enable_extension "hstore" - - create_table "active_admin_comments", force: true do |t| - t.string "resource_id", null: false - t.string "resource_type", null: false - t.integer "author_id" - t.string "author_type" - t.text "body" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "namespace" - end - - add_index "active_admin_comments", ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id", using: :btree - add_index "active_admin_comments", ["namespace"], name: "index_active_admin_comments_on_namespace", using: :btree - add_index "active_admin_comments", ["resource_type", "resource_id"], name: "index_admin_notes_on_resource_type_and_resource_id", using: :btree - - create_table "admin_users", force: true do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0 - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - add_index "admin_users", ["email"], name: "index_admin_users_on_email", unique: true, using: :btree - add_index "admin_users", ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true, using: :btree - - create_table "controllers", force: true do |t| - t.string "Pages" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + enable_extension 'plpgsql' + + create_table 'active_admin_comments', id: :serial, force: :cascade do |t| + t.string 'resource_id', null: false + t.string 'resource_type', null: false + t.string 'author_type' + t.integer 'author_id' + t.text 'body' + t.datetime 'created_at' + t.datetime 'updated_at' + t.string 'namespace' + t.index %w[author_type author_id], name: 'index_active_admin_comments_on_author_type_and_author_id' + t.index ['namespace'], name: 'index_active_admin_comments_on_namespace' + t.index %w[resource_type resource_id], name: 'index_active_admin_comments_on_resource_type_and_resource_id' end - create_table "friendly_id_slugs", force: true do |t| - t.string "slug", null: false - t.integer "sluggable_id", null: false - t.string "sluggable_type", limit: 40 - t.datetime "created_at" + create_table 'admin_users', id: :serial, force: :cascade do |t| + t.string 'email', default: '', null: false + t.string 'encrypted_password', default: '', null: false + t.string 'reset_password_token' + t.datetime 'reset_password_sent_at' + t.datetime 'remember_created_at' + t.integer 'sign_in_count', default: 0 + t.datetime 'current_sign_in_at' + t.datetime 'last_sign_in_at' + t.string 'current_sign_in_ip' + t.string 'last_sign_in_ip' + t.datetime 'created_at' + t.datetime 'updated_at' + t.index ['email'], name: 'index_admin_users_on_email', unique: true + t.index ['reset_password_token'], name: 'index_admin_users_on_reset_password_token', unique: true end - add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type", unique: true, using: :btree - add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id", using: :btree - add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type", using: :btree - - create_table "issues", force: true do |t| - t.string "title" - t.string "issue_number" - t.integer "position" - t.string "cover_image_file_name" - t.string "cover_image_content_type" - t.integer "cover_image_file_size" - t.datetime "cover_image_updated_at" - t.datetime "created_at" - t.datetime "updated_at" - t.string "slug" - t.integer "rating" - t.integer "pages_count" - t.string "purchase_url" - t.text "description" + create_table 'controllers', id: :serial, force: :cascade do |t| + t.string 'Pages' + t.datetime 'created_at' + t.datetime 'updated_at' end - add_index "issues", ["slug"], name: "index_issues_on_slug", using: :btree - - create_table "pages", force: true do |t| - t.integer "story_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "image_file_name" - t.string "image_content_type" - t.integer "image_file_size" - t.datetime "image_updated_at" - t.integer "story_page_number" - t.integer "issue_id" - t.integer "issue_page_number" - t.text "description" + create_table 'friendly_id_slugs', id: :serial, force: :cascade do |t| + t.string 'slug', null: false + t.integer 'sluggable_id', null: false + t.string 'sluggable_type', limit: 40 + t.datetime 'created_at' + t.index %w[slug sluggable_type], name: 'index_friendly_id_slugs_on_slug_and_sluggable_type', unique: true + t.index ['sluggable_id'], name: 'index_friendly_id_slugs_on_sluggable_id' + t.index ['sluggable_type'], name: 'index_friendly_id_slugs_on_sluggable_type' end - add_index "pages", ["story_id"], name: "index_pages_on_story_id", using: :btree - - create_table "people", force: true do |t| - t.string "name" - t.text "bio" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "image_file_name" - t.string "image_content_type" - t.integer "image_file_size" - t.datetime "image_updated_at" - t.string "slug" + create_table 'issues', id: :serial, force: :cascade do |t| + t.string 'title' + t.string 'issue_number' + t.integer 'position' + t.string 'cover_image_file_name' + t.string 'cover_image_content_type' + t.bigint 'cover_image_file_size' + t.datetime 'cover_image_updated_at' + t.datetime 'created_at' + t.datetime 'updated_at' + t.string 'slug' + t.integer 'rating' + t.integer 'pages_count' + t.string 'purchase_url' + t.text 'description' + t.index ['slug'], name: 'index_issues_on_slug' end - add_index "people", ["slug"], name: "index_people_on_slug", using: :btree - - create_table "people_stories", force: true do |t| - t.integer "story_id" - t.integer "person_id" + create_table 'pages', id: :serial, force: :cascade do |t| + t.integer 'story_id' + t.datetime 'created_at' + t.datetime 'updated_at' + t.string 'image_file_name' + t.string 'image_content_type' + t.bigint 'image_file_size' + t.datetime 'image_updated_at' + t.integer 'story_page_number' + t.integer 'issue_id' + t.integer 'issue_page_number' + t.text 'description' + t.index ['story_id'], name: 'index_pages_on_story_id' end - add_index "people_stories", ["person_id"], name: "index_people_stories_on_person_id", using: :btree - add_index "people_stories", ["story_id"], name: "index_people_stories_on_story_id", using: :btree - - create_table "stories", force: true do |t| - t.string "name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "cover_image_file_name" - t.string "cover_image_content_type" - t.integer "cover_image_file_size" - t.datetime "cover_image_updated_at" - t.string "slug" - t.text "description" - t.integer "pages_count" - t.integer "rating" - t.boolean "unfinished" + create_table 'people', id: :serial, force: :cascade do |t| + t.string 'name' + t.text 'bio' + t.datetime 'created_at' + t.datetime 'updated_at' + t.string 'image_file_name' + t.string 'image_content_type' + t.bigint 'image_file_size' + t.datetime 'image_updated_at' + t.string 'slug' + t.index ['slug'], name: 'index_people_on_slug' end - add_index "stories", ["slug"], name: "index_stories_on_slug", using: :btree - - create_table "stories_people", force: true do |t| - t.integer "story_id" - t.integer "person_id" + create_table 'people_stories', id: :serial, force: :cascade do |t| + t.integer 'story_id' + t.integer 'person_id' + t.index ['person_id'], name: 'index_people_stories_on_person_id' + t.index ['story_id'], name: 'index_people_stories_on_story_id' end - create_table "story_pages", force: true do |t| - t.integer "story_id" - t.integer "page_id" - t.integer "page_number" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table 'stories', id: :serial, force: :cascade do |t| + t.string 'name' + t.datetime 'created_at' + t.datetime 'updated_at' + t.string 'cover_image_file_name' + t.string 'cover_image_content_type' + t.bigint 'cover_image_file_size' + t.datetime 'cover_image_updated_at' + t.string 'slug' + t.text 'description' + t.integer 'pages_count' + t.integer 'rating' + t.boolean 'unfinished' + t.index ['slug'], name: 'index_stories_on_slug' end - end diff --git a/db/seeds.rb b/db/seeds.rb index 03f1e43..24d5e6e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file should contain all the record creation needed to seed the database # with its default values. The data can then be loaded with the rake db:seed # (or created alongside the db with db:setup). diff --git a/script/rails b/script/rails index cb00211..d30580c 100755 --- a/script/rails +++ b/script/rails @@ -1,7 +1,9 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + # This command will automatically be run when you run "rails" with Rails 3 gems # installed from the root of your application. -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) +require File.expand_path('../config/boot', __dir__) require 'rails/commands' diff --git a/spec/controllers/issues_controller_spec.rb b/spec/controllers/issues_controller_spec.rb index 33a0787..e460f2e 100644 --- a/spec/controllers/issues_controller_spec.rb +++ b/spec/controllers/issues_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' # This spec was generated by rspec-rails when you ran the scaffold generator. @@ -19,40 +21,39 @@ # that an instance is receiving a specific message. RSpec.describe IssuesController, type: :controller do - # This should return the minimal set of attributes required to create a valid # Issue. As you add validations to Issue, be sure to # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end # This should return the minimal set of values that should be in the session # in order to pass any filters (e.g. authentication) defined in # IssuesController. Be sure to keep this updated too. let(:valid_session) { {} } - describe "GET #index" do - it "assigns all issues as @issues" do + describe 'GET #index' do + it 'assigns all issues as @issues' do issue = Issue.create! valid_attributes - get :index, {}, valid_session + get :index, session: valid_session expect(assigns(:issues)).to eq([issue]) end end - describe "GET #show" do - it "assigns the requested issue as @issue" do + describe 'GET #show' do + it 'assigns the requested issue as @issue' do issue = Issue.create! valid_attributes - get :show, { id: issue.to_param }, valid_session + get :show, params: { id: issue.to_param } expect(assigns(:issue)).to eq(issue) end it 'renders the :show view' do - issue = FactoryGirl.create(:issue) - get :show, { id: issue.to_param }, valid_session + issue = FactoryBot.create(:issue) + get :show, params: { id: issue.to_param } expect(response).to render_template :show end end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index e146ae3..fa68909 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + # spec/controllers/people_controller_spec.rb require 'spec_helper' describe PeopleController, type: :controller do describe 'GET #index' do it 'populates an array of people' do - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) get :index expect(assigns(:people)).to eq([person]) end @@ -15,13 +17,13 @@ end describe 'GET #show' do it 'assigns the requested person to @person' do - person = FactoryGirl.create(:person) - get :show, id: person.id + person = FactoryBot.create(:person) + get :show, params: { id: person.id } expect(assigns(:person)).to eq(person) end it 'renders the :show view' do - person = FactoryGirl.create(:person) - get :show, id: person.id + person = FactoryBot.create(:person) + get :show, params: { id: person.id } expect(response).to render_template :show end end diff --git a/spec/controllers/site_controller_spec.rb b/spec/controllers/site_controller_spec.rb index 17f1c30..2214eb0 100644 --- a/spec/controllers/site_controller_spec.rb +++ b/spec/controllers/site_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # spec/controllers/site_controller_spec.rb require 'spec_helper' @@ -5,12 +7,12 @@ describe 'GET #index' do describe '@recent_stories array' do it 'includes stories with pages' do - page = FactoryGirl.create(:page) + page = FactoryBot.create(:page) get :index expect(assigns(:recent_stories)).to include(page.story) end it 'excludes stories with no pages' do - story = FactoryGirl.create(:story) + story = FactoryBot.create(:story) get :index expect(assigns(:recent_stories)).not_to include(story) end @@ -22,7 +24,7 @@ end describe 'GET #index' do it 'populates an array of people' do - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) get :index expect(assigns(:people)).to eq([person]) end diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 0312489..4290152 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # spec/controllers/stories_controller_spec.rb require 'spec_helper' @@ -5,12 +7,12 @@ describe 'GET #index' do describe '@stories array' do it 'includes stories with pages' do - page = FactoryGirl.create(:page) + page = FactoryBot.create(:page) get :index expect(assigns(:stories)).to include(page.story) end it 'excludes stories with no pages' do - story = FactoryGirl.create(:story) + story = FactoryBot.create(:story) get :index expect(assigns(:stories)).not_to include(story) end @@ -22,13 +24,13 @@ end describe 'GET #show' do it 'assigns the requested story to @story' do - story = FactoryGirl.create(:story) - get :show, id: story.id + story = FactoryBot.create(:story) + get :show, params: { id: story.id } expect(assigns(:story)).to eq(story) end it 'renders the :show view' do - story = FactoryGirl.create(:story) - get :show, id: story.id + story = FactoryBot.create(:story) + get :show, params: { id: story.id } expect(response).to render_template :show end end diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index b3cee3d..1618d98 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -1,11 +1,13 @@ -FactoryGirl.define do +# frozen_string_literal: true + +FactoryBot.define do factory :issue do title { Faker::Lorem.sentence } slug { Faker::Internet.slug } - sequence(:issue_number) { |n| "#{n}" } - cover_image_file_name "foo.png" - cover_image_content_type "image/jpg" - cover_image_file_size 2.megabytes - position 1 + sequence(:issue_number, &:to_s) + cover_image_file_name { 'foo.png' } + cover_image_content_type { 'image/jpg' } + cover_image_file_size { 2.megabytes } + position { 1 } end end diff --git a/spec/factories/pages.rb b/spec/factories/pages.rb index c4e7ce0..6dc228f 100644 --- a/spec/factories/pages.rb +++ b/spec/factories/pages.rb @@ -1,13 +1,15 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl +# frozen_string_literal: true -FactoryGirl.define do +# Read about factories at https://github.com/thoughtbot/factory_bot + +FactoryBot.define do factory :page do - image_file_name 'foo.png' - image_content_type 'image/jpg' - image_file_size 2.megabytes - story_page_number 1 + image_file_name { 'foo.png' } + image_content_type { 'image/jpg' } + image_file_size { 2.megabytes } + story_page_number { 1 } story - issue_page_number 1 + issue_page_number { 1 } issue end end diff --git a/spec/factories/people.rb b/spec/factories/people.rb index 520cc6b..76731dd 100644 --- a/spec/factories/people.rb +++ b/spec/factories/people.rb @@ -1,9 +1,11 @@ -FactoryGirl.define do +# frozen_string_literal: true + +FactoryBot.define do factory :person do name { Faker::Name.name } bio { Faker::Lorem.paragraph } - image_file_name 'foo.png' - image_content_type 'image/png' - image_file_size 2.megabytes + image_file_name { 'foo.png' } + image_content_type { 'image/png' } + image_file_size { 2.megabytes } end end diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb index 2332dd2..9602926 100644 --- a/spec/factories/stories.rb +++ b/spec/factories/stories.rb @@ -1,9 +1,11 @@ -FactoryGirl.define do +# frozen_string_literal: true + +FactoryBot.define do factory :story do name { Faker::Lorem.sentence } slug { Faker::Internet.slug } - cover_image_file_name 'foo.png' - cover_image_content_type 'image/jpg' - cover_image_file_size 2.megabytes + cover_image_file_name { 'foo.png' } + cover_image_content_type { 'image/jpg' } + cover_image_file_size { 2.megabytes } end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index d26c710..822b8bb 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ApplicationHelper, type: :helper do diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 190ac3d..5100b65 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' # Specs in this file have access to a helper object that includes diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 2cd6044..9caa8ba 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -1,43 +1,45 @@ +# frozen_string_literal: true + # spec/models/contact.rb -require "spec_helper" +require 'spec_helper' describe Issue do - it "has a valid factory" do - issue = FactoryGirl.create(:issue) + it 'has a valid factory' do + issue = FactoryBot.create(:issue) expect(issue).to be_valid end - it "is invalid with a non-image MIME type" do - issue = FactoryGirl.build(:issue, cover_image_content_type: "audio/mp4") + it 'is invalid with a non-image MIME type' do + issue = FactoryBot.build(:issue, cover_image_content_type: 'audio/mp4') expect(issue).not_to be_valid end - it "is valid with a MIME type image/jpeg" do - issue = FactoryGirl.build(:issue, cover_image_content_type: "image/jpeg") + it 'is valid with a MIME type image/jpeg' do + issue = FactoryBot.build(:issue, cover_image_content_type: 'image/jpeg') expect(issue).to be_valid end - it "is valid with a MIME type image/jpg" do - issue = FactoryGirl.build(:issue, cover_image_content_type: "image/jpg") + it 'is valid with a MIME type image/jpg' do + issue = FactoryBot.build(:issue, cover_image_content_type: 'image/jpg') expect(issue).to be_valid end it "is invalid with an image that's too large" do - issue = FactoryGirl.build(:issue, cover_image_file_size: 10.megabytes) + issue = FactoryBot.build(:issue, cover_image_file_size: 10.megabytes) expect(issue).not_to be_valid end - it "is invalid without a title" do - issue = FactoryGirl.build(:issue, title: nil) + it 'is invalid without a title' do + issue = FactoryBot.build(:issue, title: nil) expect(issue).not_to be_valid end - it "does not allow duplicate titles" do - FactoryGirl.create(:issue, title: "foo") - issue = FactoryGirl.build(:issue, title: "foo") + it 'does not allow duplicate titles' do + FactoryBot.create(:issue, title: 'foo') + issue = FactoryBot.build(:issue, title: 'foo') expect(issue).not_to be_valid end - it "does not allow duplicate issue numbers" do - FactoryGirl.create(:issue, issue_number: "11") - issue = FactoryGirl.build(:issue, issue_number: "11") + it 'does not allow duplicate issue numbers' do + FactoryBot.create(:issue, issue_number: '11') + issue = FactoryBot.build(:issue, issue_number: '11') expect(issue).not_to be_valid end - it "is invalid without a position" do - issue = FactoryGirl.build(:issue, position: nil) + it 'is invalid without a position' do + issue = FactoryBot.build(:issue, position: nil) expect(issue).not_to be_valid end end diff --git a/spec/models/page_spec.rb b/spec/models/page_spec.rb index bab8034..0ba9cd5 100644 --- a/spec/models/page_spec.rb +++ b/spec/models/page_spec.rb @@ -1,29 +1,31 @@ +# frozen_string_literal: true + # spec/models/contact.rb require 'spec_helper' describe Page do it 'has a valid factory' do - page = FactoryGirl.create(:page) + page = FactoryBot.create(:page) expect(page).to be_valid end it 'is invalid without an image' do - page = FactoryGirl.build(:page, image_file_name: nil) + page = FactoryBot.build(:page, image_file_name: nil) expect(page).not_to be_valid end it 'is invalid with a non-image MIME type' do - page = FactoryGirl.build(:page, image_content_type: 'audio/mp4') + page = FactoryBot.build(:page, image_content_type: 'audio/mp4') expect(page).not_to be_valid end it 'is valid with a MIME type image/jpeg' do - page = FactoryGirl.build(:page, image_content_type: 'image/jpeg') + page = FactoryBot.build(:page, image_content_type: 'image/jpeg') expect(page).to be_valid end it 'is valid with a MIME type image/jpg' do - page = FactoryGirl.build(:page, image_content_type: 'image/jpg') + page = FactoryBot.build(:page, image_content_type: 'image/jpg') expect(page).to be_valid end it "is invalid with an image that's too large" do - page = FactoryGirl.build(:page, image_file_size: 10.megabytes) + page = FactoryBot.build(:page, image_file_size: 10.megabytes) expect(page).not_to be_valid end end diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 2c31e89..50591e1 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -1,42 +1,44 @@ +# frozen_string_literal: true + # spec/models/contact.rb require 'spec_helper' describe Person do it 'has a valid factory' do - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) expect(person).to be_valid end it 'is valid without an image' do - person = FactoryGirl.build(:person, image_file_name: nil) + person = FactoryBot.build(:person, image_file_name: nil) expect(person).to be_valid end it 'is invalid with a non-image MIME type' do - person = FactoryGirl.build(:person, image_content_type: 'audio/mp4') + person = FactoryBot.build(:person, image_content_type: 'audio/mp4') expect(person).not_to be_valid end it 'is valid with a MIME type image/jpeg' do - person = FactoryGirl.build(:person, image_content_type: 'image/jpeg') + person = FactoryBot.build(:person, image_content_type: 'image/jpeg') expect(person).to be_valid end it 'is valid with a MIME type image/jpg' do - person = FactoryGirl.build(:person, image_content_type: 'image/jpg') + person = FactoryBot.build(:person, image_content_type: 'image/jpg') expect(person).to be_valid end it "is invalid with an image that's too large" do - person = FactoryGirl.build(:person, image_file_size: 10.megabytes) + person = FactoryBot.build(:person, image_file_size: 10.megabytes) expect(person).not_to be_valid end it 'is invalid without a name' do - person = FactoryGirl.build(:person, name: nil) + person = FactoryBot.build(:person, name: nil) expect(person).not_to be_valid end it 'does not allow duplicate names' do - FactoryGirl.create(:person, name: 'foo') - person = FactoryGirl.build(:person, name: 'foo') + FactoryBot.create(:person, name: 'foo') + person = FactoryBot.build(:person, name: 'foo') expect(person).not_to be_valid end it 'allows long bio text' do - person = FactoryGirl.build(:person, bio: Faker::Lorem.characters(1024)) + person = FactoryBot.build(:person, bio: Faker::Lorem.characters(1024)) expect(person.save).to eq true end end diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index 29f9537..5e3bc56 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -1,89 +1,91 @@ +# frozen_string_literal: true + # spec/models/contact.rb -require "spec_helper" +require 'spec_helper' describe Story do - it "has a valid factory" do - story = FactoryGirl.create(:story) + it 'has a valid factory' do + story = FactoryBot.create(:story) expect(story).to be_valid end - it "is invalid with a non-image MIME type" do - story = FactoryGirl.build(:story, cover_image_content_type: "audio/mp4") + it 'is invalid with a non-image MIME type' do + story = FactoryBot.build(:story, cover_image_content_type: 'audio/mp4') expect(story).not_to be_valid end - it "is valid with a MIME type image/jpeg" do - story = FactoryGirl.build(:story, cover_image_content_type: "image/jpeg") + it 'is valid with a MIME type image/jpeg' do + story = FactoryBot.build(:story, cover_image_content_type: 'image/jpeg') expect(story).to be_valid end - it "is valid with a MIME type image/jpg" do - story = FactoryGirl.build(:story, cover_image_content_type: "image/jpg") + it 'is valid with a MIME type image/jpg' do + story = FactoryBot.build(:story, cover_image_content_type: 'image/jpg') expect(story).to be_valid end it "is invalid with an image that's too large" do - story = FactoryGirl.build(:story, cover_image_file_size: 10.megabytes) + story = FactoryBot.build(:story, cover_image_file_size: 10.megabytes) expect(story).not_to be_valid end - it "is invalid without a name" do - story = FactoryGirl.build(:story, name: nil) + it 'is invalid without a name' do + story = FactoryBot.build(:story, name: nil) expect(story).not_to be_valid end - it "does not allow duplicate names" do - FactoryGirl.create(:story, name: "foo") - story = FactoryGirl.build(:story, name: "foo") + it 'does not allow duplicate names' do + FactoryBot.create(:story, name: 'foo') + story = FactoryBot.build(:story, name: 'foo') expect(story).not_to be_valid end - describe "#page_count" do + describe '#page_count' do before :each do - @story = FactoryGirl.create(:story) - FactoryGirl.create(:page, story: @story, story_page_number: 1) + @story = FactoryBot.create(:story) + FactoryBot.create(:page, story: @story, story_page_number: 1) end - it "counts number of pages for a standard story" do + it 'counts number of pages for a standard story' do expect(@story.page_count).to eq 1 end - it "counts an extra page for a blue story" do + it 'counts an extra page for a blue story' do @story.rating = :blue expect(@story.page_count).to eq 2 end - it "counts an extra page for an unfinished story" do + it 'counts an extra page for an unfinished story' do @story.unfinished = true expect(@story.page_count).to eq 2 end end - describe "#length_category" do + describe '#length_category' do before :each do - @story = FactoryGirl.create(:story) + @story = FactoryBot.create(:story) end - it "is empty for a 0 page story" do + it 'is empty for a 0 page story' do expect(@story.length_category).to eq :empty end - it "is one_page for a 1 page story" do + it 'is one_page for a 1 page story' do add_pages(@story, 1) expect(@story.length_category).to eq :one_page end - it "is short for a 2..7 page story" do + it 'is short for a 2..7 page story' do add_pages(@story, 2) expect(@story.length_category).to eq :short end - it "is medium for a 8..15 page story" do + it 'is medium for a 8..15 page story' do add_pages(@story, 8) expect(@story.length_category).to eq :medium end - it "is long for a 16..31 page story" do + it 'is long for a 16..31 page story' do add_pages(@story, 16) expect(@story.length_category).to eq :long end - it "is epic for a >31 page story" do + it 'is epic for a >31 page story' do add_pages(@story, 32) expect(@story.length_category).to eq :epic end end - describe "by_same_creators" do - it "includes stories by each creator" do - story = FactoryGirl.create(:story) - other_story = FactoryGirl.create(:story) - person = FactoryGirl.create(:person) + describe 'by_same_creators' do + it 'includes stories by each creator' do + story = FactoryBot.create(:story) + other_story = FactoryBot.create(:story) + person = FactoryBot.create(:person) story.people << person other_story.people << person expect(story.by_same_creators).to include other_story @@ -93,6 +95,6 @@ def add_pages(story, num_stories) (1..num_stories).each do |story_page_number| - FactoryGirl.create(:page, story: story, story_page_number: story_page_number) + FactoryBot.create(:page, story: story, story_page_number: story_page_number) end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index bc7fb04..efdccee 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,20 +1,24 @@ +# frozen_string_literal: true + # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] ||= "test" +ENV['RAILS_ENV'] ||= 'test' # SimpleCov must start before any application code is required -require "simplecov" -SimpleCov.start "rails" do - add_group "ActiveAdmin", "app/admin" +require 'simplecov' +SimpleCov.start 'rails' do + add_group 'ActiveAdmin', 'app/admin' end -require File.expand_path("../../config/environment", __FILE__) +require File.expand_path('../config/environment', __dir__) # Prevent database truncation if the environment is production -abort( - "The Rails environment is running in production mode!" -) if Rails.env.production? +if Rails.env.production? + abort( + 'The Rails environment is running in production mode!' + ) +end -require "spec_helper" -require "rspec/rails" +require 'spec_helper' +require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! # Requires supporting ruby files with custom matchers and macros, etc, in diff --git a/spec/requests/issues_spec.rb b/spec/requests/issues_spec.rb index 1130280..639ad62 100644 --- a/spec/requests/issues_spec.rb +++ b/spec/requests/issues_spec.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + require 'rails_helper' -RSpec.describe "Issues", type: :request do - describe "GET /issues" do - it "works! (now write some real specs)" do +RSpec.describe 'Issues', type: :request do + describe 'GET /issues' do + it 'works! (now write some real specs)' do get issues_path expect(response).to have_http_status(200) end diff --git a/spec/routing/issues_routing_spec.rb b/spec/routing/issues_routing_spec.rb index e272b60..9b3f0b9 100644 --- a/spec/routing/issues_routing_spec.rb +++ b/spec/routing/issues_routing_spec.rb @@ -1,39 +1,39 @@ -require "rails_helper" +# frozen_string_literal: true -RSpec.describe IssuesController, type: :routing do - describe "routing" do +require 'rails_helper' - it "routes to #index" do - expect(:get => "/issues").to route_to("issues#index") +RSpec.describe IssuesController, type: :routing do + describe 'routing' do + it 'routes to #index' do + expect(get: '/issues').to route_to('issues#index') end - it "routes to #new" do - expect(:get => "/issues/new").to route_to("issues#new") + it 'routes to #new' do + expect(get: '/issues/new').to route_to('issues#new') end - it "routes to #show" do - expect(:get => "/issues/1").to route_to("issues#show", :id => "1") + it 'routes to #show' do + expect(get: '/issues/1').to route_to('issues#show', id: '1') end - it "routes to #edit" do - expect(:get => "/issues/1/edit").to route_to("issues#edit", :id => "1") + it 'routes to #edit' do + expect(get: '/issues/1/edit').to route_to('issues#edit', id: '1') end - it "routes to #create" do - expect(:post => "/issues").to route_to("issues#create") + it 'routes to #create' do + expect(post: '/issues').to route_to('issues#create') end - it "routes to #update via PUT" do - expect(:put => "/issues/1").to route_to("issues#update", :id => "1") + it 'routes to #update via PUT' do + expect(put: '/issues/1').to route_to('issues#update', id: '1') end - it "routes to #update via PATCH" do - expect(:patch => "/issues/1").to route_to("issues#update", :id => "1") + it 'routes to #update via PATCH' do + expect(patch: '/issues/1').to route_to('issues#update', id: '1') end - it "routes to #destroy" do - expect(:delete => "/issues/1").to route_to("issues#destroy", :id => "1") + it 'routes to #destroy' do + expect(delete: '/issues/1').to route_to('issues#destroy', id: '1') end - end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 43ec6f8..d0ba612 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # This file is copied to spec/ when you run 'rails generate rspec:install' ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../config/environment', __FILE__) +require File.expand_path('../config/environment', __dir__) require 'rspec/rails' # Requires supporting ruby files with custom matchers and macros, etc, @@ -36,15 +38,12 @@ # --seed 1234 config.order = 'random' - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods config.before(:suite) do - begin - DatabaseCleaner.start - FactoryGirl.lint - ensure - DatabaseCleaner.clean - end + DatabaseCleaner.start + FactoryBot.lint + ensure + DatabaseCleaner.clean end - end