diff --git a/Gemfile b/Gemfile index 802debb..afc59df 100644 --- a/Gemfile +++ b/Gemfile @@ -1,22 +1,22 @@ source 'https://rubygems.org' -gem 'rails', '4.2.6' +gem 'rails', '~> 5.0.0' +gem 'puma', '~> 3.7' gem 'pg' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' -gem 'coffee-rails', '~> 4.1.0' -gem 'devise' +gem 'coffee-rails', '~> 4.2' +gem 'devise', '~> 4.3.0' gem 'cancancan', '~> 1.10' gem 'bootstrap-sass', '~> 3.3.6' source 'https://rails-assets.org' do gem 'rails-assets-tether', '>= 1.1.0' end - gem 'jquery-rails' gem 'turbolinks' gem 'jquery-turbolinks' -gem 'jbuilder', '~> 2.0' +gem 'jbuilder', '~> 2.5' gem 'paperclip' gem 'sdoc', '~> 0.4.0', group: :doc gem 'dotenv' @@ -31,17 +31,23 @@ gem 'rails_12factor', group: :production group :development, :test do gem 'byebug' gem 'dotenv-rails' - gem 'pry' + gem 'pry-rails' gem 'pry-remote' - gem 'pry-byebug' + gem 'pry-byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'rspec-rails' gem 'factory_girl_rails' gem 'faker' - gem 'quiet_assets' + gem 'rails-controller-testing' end group :development do - gem 'web-console', '~> 2.0' + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' - + gem 'spring-watcher-listen', '~> 2.0.0' end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 922c3a1..7a2a4fd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,173 +2,179 @@ GEM remote: https://rubygems.org/ remote: https://rails-assets.org/ specs: - actionmailer (4.2.6) - actionpack (= 4.2.6) - actionview (= 4.2.6) - activejob (= 4.2.6) + actioncable (5.0.3) + actionpack (= 5.0.3) + nio4r (>= 1.2, < 3.0) + websocket-driver (~> 0.6.1) + actionmailer (5.0.3) + actionpack (= 5.0.3) + actionview (= 5.0.3) + activejob (= 5.0.3) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.6) - actionview (= 4.2.6) - activesupport (= 4.2.6) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.0.3) + actionview (= 5.0.3) + activesupport (= 5.0.3) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.6) - activesupport (= 4.2.6) + actionview (5.0.3) + activesupport (= 5.0.3) builder (~> 3.1) erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.6) - activesupport (= 4.2.6) - globalid (>= 0.3.0) - activemodel (4.2.6) - activesupport (= 4.2.6) - builder (~> 3.1) - activerecord (4.2.6) - activemodel (= 4.2.6) - activesupport (= 4.2.6) - arel (~> 6.0) - activesupport (4.2.6) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.0.3) + activesupport (= 5.0.3) + globalid (>= 0.3.6) + activemodel (5.0.3) + activesupport (= 5.0.3) + activerecord (5.0.3) + activemodel (= 5.0.3) + activesupport (= 5.0.3) + arel (~> 7.0) + activesupport (5.0.3) + concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - acts_as_list (0.7.4) + acts_as_list (0.9.5) activerecord (>= 3.0) - arel (6.0.3) - autoprefixer-rails (6.3.6.2) + arel (7.1.4) + autoprefixer-rails (7.1.0) execjs - aws-sdk (2.3.14) - aws-sdk-resources (= 2.3.14) - aws-sdk-core (2.3.14) + aws-sdk (2.9.17) + aws-sdk-resources (= 2.9.17) + aws-sdk-core (2.9.17) + aws-sigv4 (~> 1.0) jmespath (~> 1.0) - aws-sdk-resources (2.3.14) - aws-sdk-core (= 2.3.14) - aws-sdk-v1 (1.66.0) + aws-sdk-resources (2.9.17) + aws-sdk-core (= 2.9.17) + aws-sdk-v1 (1.67.0) json (~> 1.4) - nokogiri (>= 1.4.4) + nokogiri (~> 1) + aws-sigv4 (1.0.0) bcrypt (3.1.11) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) - bootstrap-sass (3.3.6) + bindex (0.5.0) + bootstrap-sass (3.3.7) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) - builder (3.2.2) - byebug (9.0.5) - cancancan (1.15.0) - climate_control (0.0.3) - activesupport (>= 3.0) + builder (3.2.3) + byebug (9.0.6) + cancancan (1.16.0) + climate_control (0.2.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) coderay (1.1.1) - coffee-rails (4.1.1) + coffee-rails (4.2.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.1.x) + railties (>= 4.0.0, < 5.2.x) coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.10.0) - concurrent-ruby (1.0.2) - debug_inspector (0.0.2) - devise (4.1.1) + coffee-script-source (1.12.2) + concurrent-ruby (1.0.5) + devise (4.3.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.1) + railties (>= 4.1.0, < 5.2) responders warden (~> 1.2.3) - diff-lcs (1.2.5) - dotenv (2.1.1) - dotenv-rails (2.1.1) - dotenv (= 2.1.1) - railties (>= 4.0, < 5.1) + diff-lcs (1.3) + dotenv (2.2.1) + dotenv-rails (2.2.1) + dotenv (= 2.2.1) + railties (>= 3.2, < 5.2) erubis (2.7.0) execjs (2.7.0) - factory_girl (4.7.0) + factory_girl (4.8.0) activesupport (>= 3.0.0) - factory_girl_rails (4.7.0) - factory_girl (~> 4.7.0) + factory_girl_rails (4.8.0) + factory_girl (~> 4.8.0) railties (>= 3.0.0) - faker (1.6.3) + faker (1.7.3) i18n (~> 0.5) - geocoder (1.3.7) - globalid (0.3.6) - activesupport (>= 4.1.0) - i18n (0.7.0) - jbuilder (2.5.0) - activesupport (>= 3.0.0, < 5.1) - multi_json (~> 1.2) - jmespath (1.2.4) - json_pure (>= 1.8.1) - jquery-rails (4.1.1) + ffi (1.9.18) + geocoder (1.4.3) + globalid (0.4.0) + activesupport (>= 4.2.0) + i18n (0.8.1) + jbuilder (2.6.4) + activesupport (>= 3.0.0) + multi_json (>= 1.2) + jmespath (1.3.1) + jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-turbolinks (2.1.0) railties (>= 3.1.0) turbolinks - json (1.8.3) - json_pure (1.8.3) + json (1.8.6) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) loofah (2.0.3) nokogiri (>= 1.5.9) - mail (2.6.4) + mail (2.6.5) mime-types (>= 1.16, < 4) method_source (0.8.2) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mimemagic (0.3.0) + mimemagic (0.3.2) mini_portile2 (2.1.0) - minitest (5.9.0) + minitest (5.10.2) multi_json (1.12.1) - nokogiri (1.6.8) + nio4r (2.0.0) + nokogiri (1.7.2) mini_portile2 (~> 2.1.0) - pkg-config (~> 1.1.7) orm_adapter (0.5.0) - paperclip (4.3.6) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) + paperclip (5.1.0) + activemodel (>= 4.2.0) + activesupport (>= 4.2.0) cocaine (~> 0.5.5) mime-types - mimemagic (= 0.3.0) - pg (0.18.4) - pkg-config (1.1.7) - pry (0.10.3) + mimemagic (~> 0.3.0) + pg (0.20.0) + pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - pry-byebug (3.4.0) + pry-byebug (3.4.2) byebug (~> 9.0) pry (~> 0.10) + pry-rails (0.3.6) + pry (>= 0.10.4) pry-remote (0.1.8) pry (~> 0.9) slop (~> 3.0) - quiet_assets (1.1.0) - railties (>= 3.1, < 5.0) - rack (1.6.4) + puma (3.8.2) + rack (2.0.2) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.6) - actionmailer (= 4.2.6) - actionpack (= 4.2.6) - actionview (= 4.2.6) - activejob (= 4.2.6) - activemodel (= 4.2.6) - activerecord (= 4.2.6) - activesupport (= 4.2.6) + rails (5.0.3) + actioncable (= 5.0.3) + actionmailer (= 5.0.3) + actionpack (= 5.0.3) + actionview (= 5.0.3) + activejob (= 5.0.3) + activemodel (= 5.0.3) + activerecord (= 5.0.3) + activesupport (= 5.0.3) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.6) - sprockets-rails - rails-assets-tether (1.3.2) - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) + railties (= 5.0.3) + sprockets-rails (>= 2.0.0) + rails-assets-tether (1.4.0) + rails-controller-testing (1.0.1) + actionpack (~> 5.x) + actionview (~> 5.x) + activesupport (~> 5.x) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) rails-html-sanitizer (1.0.3) loofah (~> 2.0) rails_12factor (0.0.3) @@ -176,71 +182,84 @@ GEM rails_stdout_logging rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (4.2.6) - actionpack (= 4.2.6) - activesupport (= 4.2.6) + railties (5.0.3) + actionpack (= 5.0.3) + activesupport (= 5.0.3) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (11.2.2) - rdoc (4.2.2) - json (~> 1.4) - responders (2.2.0) - railties (>= 4.2.0, < 5.1) - rspec-core (3.4.4) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + rake (12.0.0) + rb-fsevent (0.9.8) + rb-inotify (0.9.8) + ffi (>= 0.5.0) + rdoc (4.3.0) + responders (2.4.0) + actionpack (>= 4.2.0, < 5.3) + railties (>= 4.2.0, < 5.3) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-mocks (3.4.1) + rspec-support (~> 3.6.0) + rspec-mocks (3.6.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) - sass (3.4.22) - sass-rails (5.0.4) - railties (>= 4.0.0, < 5.0) + rspec-support (~> 3.6.0) + rspec-rails (3.6.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) + ruby_dep (1.5.0) + sass (3.4.23) + sass-rails (5.0.6) + railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sdoc (0.4.1) + sdoc (0.4.2) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) - simple_form (3.2.1) + simple_form (3.4.0) actionpack (> 4, < 5.1) activemodel (> 4, < 5.1) slop (3.6.0) - spring (1.7.1) - sprockets (3.6.1) + spring (2.0.1) + activesupport (>= 4.2) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.0.4) + sprockets-rails (3.2.0) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - thor (0.19.1) - thread_safe (0.3.5) - tilt (2.0.5) - turbolinks (2.5.3) - coffee-rails - tzinfo (1.2.2) + thor (0.19.4) + thread_safe (0.3.6) + tilt (2.0.7) + turbolinks (5.0.1) + turbolinks-source (~> 5) + turbolinks-source (5.0.3) + tzinfo (1.2.3) thread_safe (~> 0.1) - uglifier (3.0.0) + uglifier (3.2.0) execjs (>= 0.3.0, < 3) - warden (1.2.6) + warden (1.2.7) rack (>= 1.0) - web-console (2.3.0) - activemodel (>= 4.0) - binding_of_caller (>= 0.7.2) - railties (>= 4.0) - sprockets-rails (>= 2.0, < 4.0) + web-console (3.5.1) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) PLATFORMS ruby @@ -252,33 +271,37 @@ DEPENDENCIES bootstrap-sass (~> 3.3.6) byebug cancancan (~> 1.10) - coffee-rails (~> 4.1.0) - devise + coffee-rails (~> 4.2) + devise (~> 4.3.0) dotenv dotenv-rails factory_girl_rails faker geocoder - jbuilder (~> 2.0) + jbuilder (~> 2.5) jquery-rails jquery-turbolinks + listen (>= 3.0.5, < 3.2) paperclip pg - pry pry-byebug + pry-rails pry-remote - quiet_assets - rails (= 4.2.6) + puma (~> 3.7) + rails (~> 5.0.0) rails-assets-tether (>= 1.1.0)! + rails-controller-testing rails_12factor rspec-rails sass-rails (~> 5.0) sdoc (~> 0.4.0) simple_form spring + spring-watcher-listen (~> 2.0.0) turbolinks + tzinfo-data uglifier (>= 1.3.0) - web-console (~> 2.0) + web-console (>= 3.3.0) BUNDLED WITH - 1.12.5 + 1.14.6 diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/app/assets/javascripts/channels/.keep b/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/app/models/animal.rb b/app/models/animal.rb index f151ae6..613dab0 100644 --- a/app/models/animal.rb +++ b/app/models/animal.rb @@ -1,4 +1,4 @@ -class Animal < ActiveRecord::Base +class Animal < ApplicationRecord include Searchable Animal.search_endpoint = ENV['CLOUDSEARCH_ANIMALS_SEARCH_URL'] diff --git a/app/models/animal_match.rb b/app/models/animal_match.rb index 046b378..5e1c93c 100644 --- a/app/models/animal_match.rb +++ b/app/models/animal_match.rb @@ -1,4 +1,4 @@ -class AnimalMatch < ActiveRecord::Base +class AnimalMatch < ApplicationRecord belongs_to :animal belongs_to :potential_mate end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/facility.rb b/app/models/facility.rb index 9587c41..b000e34 100644 --- a/app/models/facility.rb +++ b/app/models/facility.rb @@ -1,4 +1,4 @@ -class Facility < ActiveRecord::Base +class Facility < ApplicationRecord has_many :animals has_many :facilities_users has_many :users, through: :facilities_users diff --git a/app/models/facility_user.rb b/app/models/facility_user.rb index b3e1deb..55e4df9 100644 --- a/app/models/facility_user.rb +++ b/app/models/facility_user.rb @@ -1,4 +1,4 @@ -class FacilityUser < ActiveRecord::Base +class FacilityUser < ApplicationRecord belongs_to :user belongs_to :facility end diff --git a/app/models/picture.rb b/app/models/picture.rb index 0405e2f..3fa8c9e 100644 --- a/app/models/picture.rb +++ b/app/models/picture.rb @@ -1,4 +1,4 @@ -class Picture < ActiveRecord::Base +class Picture < ApplicationRecord belongs_to :animal belongs_to :facility diff --git a/app/models/setting.rb b/app/models/setting.rb index 95d6dca..734579d 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -1,4 +1,4 @@ -class Setting < ActiveRecord::Base +class Setting < ApplicationRecord acts_as_list scope: [:type] #validates :name, presence: true, uniqueness: { case_sensitive: false, scope: :type } diff --git a/app/models/user.rb b/app/models/user.rb index 7c74876..4de5f29 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,4 @@ -class User < ActiveRecord::Base +class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, diff --git a/bin/rails b/bin/rails index 0138d79..5badb2f 100755 --- a/bin/rails +++ b/bin/rails @@ -4,6 +4,6 @@ begin rescue LoadError => e raise unless e.message.include?('spring') end -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/setup b/bin/setup index acdb2c1..78c4e86 100755 --- a/bin/setup +++ b/bin/setup @@ -1,29 +1,38 @@ #!/usr/bin/env ruby require 'pathname' +require 'fileutils' +include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) -Dir.chdir APP_ROOT do +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do # This script is a starting point to setup your application. - # Add necessary setup steps to this file: + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') - puts "== Installing dependencies ==" - system "gem install bundler --conservative" - system "bundle check || bundle install" # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # system "cp config/database.yml.sample config/database.yml" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system "bin/rake db:setup" + system! 'bin/rails db:setup' puts "\n== Removing old logs and tempfiles ==" - system "rm -f log/*" - system "rm -rf tmp/cache" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system "touch tmp/restart.txt" + system! 'bin/rails restart' end diff --git a/bin/spring b/bin/spring index 7fe232c..fb2ec2e 100755 --- a/bin/spring +++ b/bin/spring @@ -7,9 +7,11 @@ unless defined?(Spring) require 'rubygems' require 'bundler' - if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)) - Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) } - gem 'spring', match[1] + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == "spring" } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version require 'spring/binstub' end end diff --git a/bin/update b/bin/update new file mode 100755 index 0000000..a8e4462 --- /dev/null +++ b/bin/update @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 0000000..c2bacef --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +VENDOR_PATH = File.expand_path('..', __dir__) +Dir.chdir(VENDOR_PATH) do + begin + exec "yarnpkg #{ARGV.join(" ")}" + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config/application.rb b/config/application.rb index 8442821..5bc8310 100644 --- a/config/application.rb +++ b/config/application.rb @@ -17,19 +17,11 @@ module ScimitarOryx class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + # config.load_defaults 5.1 + # 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. - - # 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 - - # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/boot.rb b/config/boot.rb index 6b750f0..30f5120 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 0000000..ba5d666 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 + channel_prefix: scimitar_oryx_production diff --git a/config/environment.rb b/config/environment.rb index ee8d90d..426333b 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('../application', __FILE__) +require_relative 'application' # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index f4b3cc8..049e3b9 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -28,6 +28,9 @@ # number of complex assets. config.assets.debug = true + # Suppress logger output for asset requests. + config.assets.quiet = true + # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. # Raises helpful error messages. @@ -37,6 +40,9 @@ # 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 env_var_missing = -> { "xxx".tap { STDERR.puts "ENV VAR MISSING! SHOULDN'T MATTER THOUGH SINCE WE'RE IN DEVELOPMENT" } } diff --git a/config/environments/production.rb b/config/environments/production.rb index 8e7ffd1..5d65501 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -49,7 +49,7 @@ config.log_level = :debug # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] + config.log_tags = [ :request_id ] # Use a different logger for distributed setups. # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) @@ -57,6 +57,11 @@ # Use a different cache store in production. # config.cache_store = :mem_cache_store + # 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 = "scimitar_oryx_#{Rails.env}" + config.action_mailer.perform_caching = false + # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' @@ -74,6 +79,12 @@ # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + 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 diff --git a/config/environments/test.rb b/config/environments/test.rb index 1c19f08..bfd6ca5 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,10 +12,11 @@ # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static file server for tests with Cache-Control for performance. - config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' - + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" + } # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false @@ -25,7 +26,8 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false - + config.action_mailer.perform_caching = false + # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..51639b6 --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,6 @@ +# Be sure to restart your server when you modify this file. + +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e6..4b828e8 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,9 +3,12 @@ # 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 +# 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 app/assets folder are already added. -# Rails.application.config.assets.precompile += %w( search.js ) +# 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/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7f70458..5a6a32d 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ # Be sure to restart your server when you modify this file. +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000..1e19380 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,56 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# If you are preloading your application and using Active Record, it's +# recommended that you close any connections to the database before workers +# are forked to prevent connection leakage. +# +# before_fork do +# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) +# end + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted, this block will be run. If you are using the `preload_app!` +# option, you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, as Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end +# + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 0000000..c9119b4 --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w( + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +).each { |path| Spring.watch(path) } diff --git a/spec/controllers/animals_controller_spec.rb b/spec/controllers/animals_controller_spec.rb index 9c551f8..b1ec172 100644 --- a/spec/controllers/animals_controller_spec.rb +++ b/spec/controllers/animals_controller_spec.rb @@ -12,12 +12,12 @@ end it "assigns all animals as @animals" do animal = create(:animal) - get :index, { facility_id: animal.facility_id }, valid_session + get :index, params: { facility_id: animal.facility_id }, session: valid_session expect(assigns(:animals)).to eq([animal]) end it "renders the index template" do animal = create(:animal) - get :index, { facility_id: animal.facility_id }, valid_session + get :index, params: { facility_id: animal.facility_id }, session: valid_session expect(response).to render_template(:index) end end @@ -28,12 +28,12 @@ end it "assigns the requested animal as @animal" do animal = create(:animal) - get :show, {id: animal.id, facility_id: animal.facility_id}, valid_session + get :show, params: {id: animal.id, facility_id: animal.facility_id}, session: valid_session expect(assigns(:animal)).to eq(animal) end it "renders the show template" do animal = create(:animal) - get :show, {id: animal.id, facility_id: animal.facility_id}, valid_session + get :show, params: {id: animal.id, facility_id: animal.facility_id}, session: valid_session expect(response).to render_template(:show) end end @@ -44,12 +44,12 @@ end it "assigns a new animal as @animal" do facility = create(:facility) - get :new, {facility_id: facility.id}, valid_session + get :new, params: {facility_id: facility.id}, session: valid_session expect(assigns(:animal)).to be_a_new(Animal) end it "renders the new template" do facility = create(:facility) - get :new, {facility_id: facility.id}, valid_session + get :new, params: {facility_id: facility.id}, session: valid_session expect(response).to render_template(:new) end end @@ -60,12 +60,12 @@ end it "assigns the requested animal as @animal" do animal = create(:animal) - get :edit, {id: animal.id, facility_id: animal.facility_id}, valid_session + get :edit, params: {id: animal.id, facility_id: animal.facility_id}, session: valid_session expect(assigns(:animal)).to eq(animal) end it "renders the edit template" do animal = create(:animal) - get :edit, {id: animal.id, facility_id: animal.facility_id}, valid_session + get :edit, params: {id: animal.id, facility_id: animal.facility_id}, session: valid_session expect(response).to render_template(:edit) end end @@ -78,20 +78,20 @@ it "creates a new Animal" do facility = create(:facility) expect { - post :create, {facility_id: facility.id, :animal => valid_animal.attributes}, valid_session + post :create, params: {facility_id: facility.id, :animal => valid_animal.attributes}, session: valid_session }.to change(Animal, :count).by(1) end it "assigns a newly created animal as @animal" do facility = create(:facility) - post :create, {facility_id: facility.id, :animal => valid_animal.attributes}, valid_session + post :create, params: {facility_id: facility.id, :animal => valid_animal.attributes}, session: valid_session expect(assigns(:animal)).to be_a(Animal) expect(assigns(:animal)).to be_persisted end it "redirects to the created animal" do facility = create(:facility) - post :create, {facility_id: facility.id, :animal => valid_animal.attributes}, valid_session + post :create, params: {facility_id: facility.id, :animal => valid_animal.attributes}, session: valid_session expect(response).to redirect_to(facility_animal_path(facility, Animal.last)) end end @@ -99,13 +99,13 @@ context "with invalid params" do it "assigns a newly created but unsaved animal as @animal" do facility = create(:facility) - post :create, {facility_id: facility.id, :animal => invalid_animal.attributes}, valid_session + post :create, params: {facility_id: facility.id, :animal => invalid_animal.attributes}, session: valid_session expect(assigns(:animal)).to be_a_new(Animal) end it "re-renders the 'new' template" do facility = create(:facility) - post :create, {facility_id: facility.id, :animal => invalid_animal.attributes}, valid_session + post :create, params: {facility_id: facility.id, :animal => invalid_animal.attributes}, session: valid_session expect(response).to render_template("new") end end @@ -120,20 +120,20 @@ it "updates the requested animal" do animal = create(:animal) - put :update, {facility_id: animal.facility.id, :id => animal.id, :animal => new_attributes}, valid_session + put :update, params: {facility_id: animal.facility.id, :id => animal.id, :animal => new_attributes}, session: valid_session animal.reload expect(response).to redirect_to(facility_animal_path(animal.facility, animal)) end it "assigns the requested animal as @animal" do animal = create(:animal) - put :update, {facility_id: animal.facility.id, :id => animal.id, :animal => new_attributes}, valid_session + put :update, params: {facility_id: animal.facility.id, :id => animal.id, :animal => new_attributes}, session: valid_session expect(assigns(:animal)).to eq(animal) end it "redirects to the animal" do animal = create(:animal) - put :update, {facility_id: animal.facility.id, :id => animal.id, :animal => new_attributes}, valid_session + put :update, params: {facility_id: animal.facility.id, :id => animal.id, :animal => new_attributes}, session: valid_session expect(response).to redirect_to(facility_animal_path(animal.facility, animal)) end end @@ -142,13 +142,13 @@ bad_attributes = { name: nil } it "assigns the animal as @animal" do animal = create(:animal) - put :update, {facility_id: animal.facility.id, :id => animal.id, :animal => bad_attributes}, valid_session + put :update, params: {facility_id: animal.facility.id, :id => animal.id, :animal => bad_attributes}, session: valid_session expect(assigns(:animal)).to eq(animal) end it "re-renders the 'edit' template" do animal = create(:animal) - put :update, {facility_id: animal.facility.id, :id => animal.id, :animal => bad_attributes}, valid_session + put :update, params: {facility_id: animal.facility.id, :id => animal.id, :animal => bad_attributes}, session: valid_session expect(response).to render_template("edit") end end @@ -161,13 +161,13 @@ it "destroys the requested animal" do animal = create(:animal) expect { - delete :destroy, {facility_id: animal.facility_id, :id => animal.to_param}, valid_session + delete :destroy, params: {facility_id: animal.facility_id, :id => animal.to_param}, session: valid_session }.to change(Animal, :count).by(-1) end it "redirects to the animals list" do animal = create(:animal) - delete :destroy, {facility_id: animal.facility_id, :id => animal.to_param}, valid_session + delete :destroy, params: {facility_id: animal.facility_id, :id => animal.to_param}, session: valid_session expect(response).to redirect_to(facility_animals_path(animal.facility, notice: "Animal was successfully destroyed.")) end end diff --git a/spec/controllers/facilities_controller_spec.rb b/spec/controllers/facilities_controller_spec.rb index 9fa02dd..1ecfdb9 100644 --- a/spec/controllers/facilities_controller_spec.rb +++ b/spec/controllers/facilities_controller_spec.rb @@ -12,12 +12,12 @@ end it "assigns all facilities as @facilities" do facility = Facility.create! valid_facility.attributes - get :index, {}, valid_session + get :index, params: {}, session: valid_session expect(assigns(:facilities)).to eq(Facility.all) end it "renders the index template" do facility = Facility.create! valid_facility.attributes - get :index, {}, valid_session + get :index, params: {}, session: valid_session expect(response).to render_template(:index) end end @@ -28,13 +28,13 @@ end it "assigns the requested facility as @facility" do facility = Facility.create! valid_facility.attributes - get :show, {:id => facility.to_param}, valid_session + get :show, params: {:id => facility.to_param}, session: valid_session expect(assigns(:facility)).to eq(facility) end it "renders the show template" do facility = Facility.create! valid_facility.attributes - get :show, {:id => facility.to_param}, valid_session + get :show, params: {:id => facility.to_param}, session: valid_session expect(response).to render_template(:show) end end @@ -44,11 +44,11 @@ sign_in(create(:user)) end it "assigns a new facility as @facility" do - get :new, {}, valid_session + get :new, params: {}, session: valid_session expect(assigns(:facility)).to be_a_new(Facility) end it "renders the new template" do - get :new, {}, valid_session + get :new, params: {}, session: valid_session expect(response).to render_template(:new) end end @@ -59,12 +59,12 @@ end it "assigns the requested facility as @facility" do facility = Facility.create! valid_facility.attributes - get :edit, {:id => facility.to_param}, valid_session + get :edit, params: {:id => facility.to_param}, session: valid_session expect(assigns(:facility)).to eq(facility) end it "renders the edit template" do facility = Facility.create! valid_facility.attributes - get :edit, {:id => facility.to_param}, valid_session + get :edit, params: {:id => facility.to_param}, session: valid_session expect(response).to render_template(:edit) end end @@ -76,30 +76,30 @@ context "with valid params" do it "creates a new Facility" do expect { - post :create, {:facility => valid_facility.attributes}, valid_session + post :create, params: {:facility => valid_facility.attributes}, session: valid_session }.to change(Facility, :count).by(1) end it "assigns a newly created facility as @facility" do - post :create, {:facility => valid_facility.attributes}, valid_session + post :create, params: {:facility => valid_facility.attributes}, session: valid_session expect(assigns(:facility)).to be_a(Facility) expect(assigns(:facility)).to be_persisted end it "redirects to the created facility" do - post :create, {:facility => valid_facility.attributes}, valid_session + post :create, params: {:facility => valid_facility.attributes}, session: valid_session expect(response).to redirect_to(Facility.last) end end context "with invalid params" do it "assigns a newly created but unsaved facility as @facility" do - post :create, {:facility => invalid_facility.attributes}, valid_session + post :create, params: {:facility => invalid_facility.attributes}, session: valid_session expect(assigns(:facility)).to be_a_new(Facility) end it "re-renders the 'new' template" do - post :create, {:facility => invalid_facility.attributes}, valid_session + post :create, params: {:facility => invalid_facility.attributes}, session: valid_session expect(response).to render_template("new") end end @@ -114,7 +114,7 @@ it "updates the requested facility" do facility = Facility.create! valid_facility.attributes - put :update, {:id => facility.to_param, :facility => new_attributes}, valid_session + put :update, params: {:id => facility.to_param, :facility => new_attributes}, session: valid_session facility.reload expect(facility.name).to eql new_attributes[:name] expect(response).to redirect_to(facility) @@ -122,13 +122,13 @@ it "assigns the requested facility as @facility" do facility = Facility.create! valid_facility.attributes - put :update, {:id => facility.to_param, :facility => valid_facility.attributes}, valid_session + put :update, params: {:id => facility.to_param, :facility => valid_facility.attributes}, session: valid_session expect(assigns(:facility)).to eq(facility) end it "redirects to the facility" do facility = Facility.create! valid_facility.attributes - put :update, {:id => facility.to_param, :facility => valid_facility.attributes}, valid_session + put :update, params: {:id => facility.to_param, :facility => valid_facility.attributes}, session: valid_session expect(response).to redirect_to(facility) end end @@ -136,13 +136,13 @@ context "with invalid params" do it "assigns the facility as @facility" do facility = Facility.create! valid_facility.attributes - put :update, {:id => facility.to_param, :facility => invalid_facility.attributes}, valid_session + put :update, params: {:id => facility.to_param, :facility => invalid_facility.attributes}, session: valid_session expect(assigns(:facility)).to eq(facility) end it "re-renders the 'edit' template" do facility = Facility.create! valid_facility.attributes - put :update, {:id => facility.to_param, :facility => invalid_facility.attributes}, valid_session + put :update, params: {:id => facility.to_param, :facility => invalid_facility.attributes}, session: valid_session expect(response).to render_template("edit") end end @@ -155,13 +155,13 @@ it "destroys the requested facility" do facility = Facility.create! valid_facility.attributes expect { - delete :destroy, {:id => facility.to_param}, valid_session + delete :destroy, params: {:id => facility.to_param}, session: valid_session }.to change(Facility, :count).by(-1) end it "redirects to the facilities list" do facility = Facility.create! valid_facility.attributes - delete :destroy, {:id => facility.to_param}, valid_session + delete :destroy, params: {:id => facility.to_param}, session: valid_session expect(response).to redirect_to(facilities_url) end end diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index c75ca86..1a08f78 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -4,7 +4,7 @@ describe "GET #animals" do it "returns http success" do - get :animals, q: 'foobar' + get :animals, params: { q: 'foobar' } expect(response).to have_http_status(:success) end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 453a599..0941034 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -31,8 +31,8 @@ RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods - config.include Devise::TestHelpers, :type => :controller - config.include Devise::TestHelpers, type: :view + config.include Devise::Test::ControllerHelpers, type: :controller + config.include Devise::Test::ControllerHelpers, type: :view config.include ControllerHelpers, :type => :controller Aws.config.update(stub_responses: true) diff --git a/spec/views/facilities/index.html.erb_spec.rb b/spec/views/facilities/index.html.erb_spec.rb index d661268..0adca2c 100644 --- a/spec/views/facilities/index.html.erb_spec.rb +++ b/spec/views/facilities/index.html.erb_spec.rb @@ -2,6 +2,15 @@ RSpec.describe "facilities/index", type: :view do + before do + controller.singleton_class.class_eval do + include ActionView::Helpers::TagHelper + include ChartHelper + include ApplicationHelper + helper_method :chart, :map_chart_styles + end + end + it "renders a list of facilities" do assign(:facilities, [ create(:facility, :name => "john"), diff --git a/spec/views/facilities/show.html.erb_spec.rb b/spec/views/facilities/show.html.erb_spec.rb index 7c5ae70..313e8f6 100644 --- a/spec/views/facilities/show.html.erb_spec.rb +++ b/spec/views/facilities/show.html.erb_spec.rb @@ -2,6 +2,14 @@ RSpec.describe "facilities/show", type: :view do + before do + controller.singleton_class.class_eval do + include ActionView::Helpers::TagHelper + include ChartHelper + helper_method :chart + end + end + it "renders attributes in
" do @facility = build(:facility, :name => "Name")