diff --git a/.rubocop.yml b/.rubocop.yml index f9c528076..fba1c4a28 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,4 @@ AllCops: - RunRailsCops: true Include: - '**/Rakefile' - '**/config.ru' @@ -33,4 +32,6 @@ TrivialAccessors: AllowPredicates: true # allow has_and_belongs_to_many HasAndBelongsToMany: - Enabled: false \ No newline at end of file + Enabled: false +Rails: + Enabled: true diff --git a/.ruby-version b/.ruby-version index 585940699..2bf1c1ccf 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.2.3 +2.3.1 diff --git a/.travis.yml b/.travis.yml index 2e74ccff9..501b6a199 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: ruby rvm: - - 2.2.3 + - 2.3.1 env: global: diff --git a/Gemfile b/Gemfile index 1818e6d39..2f88b0ec6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,20 +1,20 @@ source 'https://rubygems.org' -ruby '2.2.3' # Version in .ruby-version must match +ruby '2.3.1' # Version in .ruby-version must match # standard gems -gem 'rails', '~> 4.2.5' -gem 'mysql2', '~> 0.4.2' -gem 'rake', '~> 10.4.2' +gem 'rails', '~> 4.2.6' +gem 'mysql2', '~> 0.4.4' +gem 'rake', '~> 11.1.2' gem 'jbuilder', '~> 2.4.0' # simulate environment variables -gem 'dotenv-rails', '~> 2.0.2', :require => 'dotenv/rails-now' +gem 'dotenv-rails', '~> 2.1.1', :require => 'dotenv/rails-now' # authentication / authorization -gem 'devise', '~> 3.5.3' -gem 'devise_cas_authenticatable', '~> 1.7.1' -gem 'cancancan', '~> 1.13.1' +gem 'devise', '~> 4.1.1' +gem 'devise_cas_authenticatable', '~> 1.9.1' +gem 'cancancan', '~> 1.14.0' # scheduling gem 'whenever', '~> 0.9.4' @@ -23,33 +23,33 @@ gem 'whenever', '~> 0.9.4' gem 'rails_admin', '~> 0.8.1' # ldap integration -gem 'net-ldap', '~> 0.13.0' +gem 'net-ldap', '~> 0.14.0' # attachments -gem 'paperclip', '~> 4.3.2' +gem 'paperclip', '~> 4.3.6' # for exporting multiple files -gem 'rubyzip', '~> 1.1.7' +gem 'rubyzip', '~> 1.2.0' # soft deletion -gem 'permanent_records', '~> 4.1.0' +gem 'permanent_records', '~> 4.1.5' gem 'nilify_blanks', '~> 1.2.1' # ui -gem 'jquery-rails', '~> 4.0.5' +gem 'jquery-rails', '~> 4.1.1' gem 'jquery-ui-rails', '~> 5.0.5' -gem 'jquery-datatables-rails', '~> 3.3.0' -gem 'fullcalendar-rails', '~> 2.5.0.0' -gem 'momentjs-rails', '~> 2.10.6' +gem 'jquery-datatables-rails', '~> 3.4.0' +gem 'fullcalendar-rails', '~> 2.6.1.0' +gem 'momentjs-rails', '~> 2.11.1' gem 'rails4-autocomplete', '~> 1.1.1' -gem 'select2-rails', '~> 4.0.1' +gem 'select2-rails', '~> 4.0.2' gem 'kaminari', '~> 0.16.3' gem 'draper', '~> 2.1.0' -gem 'inline_svg', '~> 0.6.2' +gem 'inline_svg', '~> 0.8.0' # forms / formatting gem 'simple_form', '~> 3.2.1' -gem 'cocoon', '~> 1.2.6' +gem 'cocoon', '~> 1.2.9' gem 'redcarpet', '~> 3.3.4' # iCalendar export @@ -58,49 +58,49 @@ gem 'icalendar', '~> 2.3.0' group :development, :test do gem 'pry', '~> 0.10.3' gem 'pry-rails', '~> 0.3.4' - gem 'pry-byebug', '~> 3.3.0' + gem 'pry-byebug', '~> 3.4.0' gem 'pry-stack_explorer', '~> 0.4.9.2' gem 'pry-remote', '~> 0.1.8' gem 'letter_opener', '~> 1.4.1' gem 'letter_opener_web', '~> 1.3.0' - gem 'factory_girl_rails', '~> 4.5.0' - gem 'rspec-rails', '~> 3.4.0' - gem 'shoulda-matchers', '~> 3.0.1' - gem 'capybara', '~> 2.5.0' - gem 'capybara-webkit', '~> 1.7.1' - gem 'guard-rspec', '~> 4.6.4' - gem 'spring', '~> 1.6.2' + gem 'factory_girl_rails', '~> 4.7.0' + gem 'rspec-rails', '~> 3.4.2' + gem 'shoulda-matchers', '~> 3.1.1' + gem 'capybara', '~> 2.7.1' + gem 'capybara-webkit', '~> 1.11.1' + gem 'guard-rspec', '~> 4.7.0' + gem 'spring', '~> 1.7.1' gem 'spring-commands-rspec', '~> 1.0.4' gem 'fuubar', '~> 2.0.0' - gem 'guard-livereload', '~> 2.5.1' - gem 'capistrano', '3.4.0', require: false + gem 'guard-livereload', '~> 2.5.2' + gem 'capistrano', '3.5.0', require: false gem 'capistrano-bundler', '~> 1.1.4', require: false - gem 'capistrano-rails', '~> 1.1.5', require: false + gem 'capistrano-rails', '~> 1.1.6', require: false gem 'capistrano-rvm', '~> 0.1.2', require: false gem 'highline', '~> 1.7.8', require: false gem 'awesome_print', '~> 1.6.1' - gem 'codeclimate-test-reporter', '~> 0.4.8' - gem 'database_cleaner', '~> 1.5.1' - gem 'rubocop', '~> 0.35.1', require: false + gem 'codeclimate-test-reporter', '~> 0.5.0' + gem 'database_cleaner', '~> 1.5.3' + gem 'rubocop', '~> 0.40.0', require: false end group :development, :test, :heroku do # seed script gems - gem 'ffaker', '~> 2.1.0', require: false - gem 'ruby-progressbar', '~> 1.7.5', require: false + gem 'ffaker', '~> 2.2.0', require: false + gem 'ruby-progressbar', '~> 1.8.1', require: false end # assets gem 'sass-rails', '~> 5.0.4' gem 'coffee-rails', '~> 4.1.1' -gem 'uglifier', '~> 2.7.2' +gem 'uglifier', '~> 3.0.0' gem 'bootstrap-sass', '~> 3.3.6' -gem 'font-awesome-rails', '~> 4.5.0' +gem 'font-awesome-rails', '~> 4.6.3.0' group :development do gem 'thin', '~> 1.6.4' - gem 'rack-mini-profiler', '~> 0.9.8' - gem 'bullet', '~> 5.0.0' + gem 'rack-mini-profiler', '~> 0.10.1' + gem 'bullet', '~> 5.1.0' end group :production do @@ -110,8 +110,8 @@ end group :heroku do gem 'pg', '~> 0.18.4' - gem 'unicorn', '~> 5.0.1' - gem 'rack-timeout', '~> 0.3.2' + gem 'unicorn', '~> 5.1.0' + gem 'rack-timeout', '~> 0.4.2' gem 'aws-sdk', '< 2.0' gem 'rails_12factor', '~> 0.0.3' end diff --git a/Gemfile.lock b/Gemfile.lock index 73625d9ba..a422d2ce5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,98 +1,101 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.5) - actionpack (= 4.2.5) - actionview (= 4.2.5) - activejob (= 4.2.5) + actionmailer (4.2.6) + actionpack (= 4.2.6) + actionview (= 4.2.6) + activejob (= 4.2.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.5) - actionview (= 4.2.5) - activesupport (= 4.2.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-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.5) - activesupport (= 4.2.5) + actionview (4.2.6) + activesupport (= 4.2.6) 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.5) - activesupport (= 4.2.5) + activejob (4.2.6) + activesupport (= 4.2.6) globalid (>= 0.3.0) - activemodel (4.2.5) - activesupport (= 4.2.5) + activemodel (4.2.6) + activesupport (= 4.2.6) builder (~> 3.1) - activerecord (4.2.5) - activemodel (= 4.2.5) - activesupport (= 4.2.5) + activerecord (4.2.6) + activemodel (= 4.2.6) + activesupport (= 4.2.6) arel (~> 6.0) - activesupport (4.2.5) + activesupport (4.2.6) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.8) + airbrussh (1.0.2) + sshkit (>= 1.6.1, != 1.7.0) arel (6.0.3) ast (2.2.0) - astrolabe (1.3.1) - parser (~> 2.2) - autoprefixer-rails (6.2.3) + autoprefixer-rails (6.3.6.1) execjs - json awesome_print (1.6.1) aws-sdk (1.66.0) aws-sdk-v1 (= 1.66.0) aws-sdk-v1 (1.66.0) json (~> 1.4) nokogiri (>= 1.4.4) - bcrypt (3.1.10) + bcrypt (3.1.11) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) bootstrap-sass (3.3.6) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) builder (3.2.2) - bullet (5.0.0) + bullet (5.1.0) activesupport (>= 3.0.0) - uniform_notifier (~> 1.9.0) - byebug (8.2.1) - cancancan (1.13.1) - capistrano (3.4.0) + uniform_notifier (~> 1.10.0) + byebug (9.0.4) + cancancan (1.14.0) + capistrano (3.5.0) + airbrussh (>= 1.0.0) + capistrano-harrow i18n rake (>= 10.0.0) - sshkit (~> 1.3) + sshkit (>= 1.9.0) capistrano-bundler (1.1.4) capistrano (~> 3.1) sshkit (~> 1.2) - capistrano-rails (1.1.5) + capistrano-harrow (0.5.1) + capistrano-rails (1.1.6) capistrano (~> 3.1) capistrano-bundler (~> 1.1) capistrano-rvm (0.1.2) capistrano (~> 3.0) sshkit (~> 1.2) - capybara (2.5.0) + capybara (2.7.1) + addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - capybara-webkit (1.7.1) - capybara (>= 2.3.0, < 2.6.0) + capybara-webkit (1.11.1) + capybara (>= 2.3.0, < 2.8.0) json chronic (0.10.2) climate_control (0.0.3) activesupport (>= 3.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) - cocoon (1.2.6) - codeclimate-test-reporter (0.4.8) + cocoon (1.2.9) + codeclimate-test-reporter (0.5.0) simplecov (>= 0.7.1, < 1.0.0) - coderay (1.1.0) + coderay (1.1.1) coffee-rails (4.1.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.1.x) @@ -100,26 +103,25 @@ GEM coffee-script-source execjs coffee-script-source (1.10.0) - concurrent-ruby (1.0.0) + concurrent-ruby (1.0.2) daemons (1.2.3) - database_cleaner (1.5.1) + database_cleaner (1.5.3) debug_inspector (0.0.2) - devise (3.5.3) + devise (4.1.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) + railties (>= 4.1.0, < 5.1) responders - thread_safe (~> 0.1) warden (~> 1.2.3) - devise_cas_authenticatable (1.7.1) + devise_cas_authenticatable (1.9.1) devise (>= 1.2.0) rubycas-client (>= 2.2.1) diff-lcs (1.2.5) docile (1.1.5) - dotenv (2.0.2) - dotenv-rails (2.0.2) - dotenv (= 2.0.2) - railties (~> 4.0) + dotenv (2.1.1) + dotenv-rails (2.1.1) + dotenv (= 2.1.1) + railties (>= 4.0, < 5.1) draper (2.1.0) actionpack (>= 3.0) activemodel (>= 3.0) @@ -129,21 +131,21 @@ GEM eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) erubis (2.7.0) - eventmachine (1.0.8) - execjs (2.6.0) - factory_girl (4.5.0) + eventmachine (1.2.0.1) + execjs (2.7.0) + factory_girl (4.7.0) activesupport (>= 3.0.0) - factory_girl_rails (4.5.0) - factory_girl (~> 4.5.0) + factory_girl_rails (4.7.0) + factory_girl (~> 4.7.0) railties (>= 3.0.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) - ffaker (2.1.0) + ffaker (2.2.0) ffi (1.9.10) - font-awesome-rails (4.5.0.0) - railties (>= 3.2, < 5.0) + font-awesome-rails (4.6.3.0) + railties (>= 3.2, < 5.1) formatador (0.2.5) - fullcalendar-rails (2.5.0.0) + fullcalendar-rails (2.6.1.0) jquery-rails (>= 4.0.5, < 5.0.0) jquery-ui-rails (>= 5.0.2) momentjs-rails (>= 2.9.0) @@ -152,9 +154,9 @@ GEM ruby-progressbar (~> 1.4) globalid (0.3.6) activesupport (>= 4.1.0) - guard (2.13.0) + guard (2.14.0) formatador (>= 0.2.4) - listen (>= 2.7, <= 4.0) + listen (>= 2.7, < 4.0) lumberjack (~> 1.0) nenv (~> 0.1) notiffany (~> 0.0) @@ -162,12 +164,12 @@ GEM shellany (~> 0.0) thor (>= 0.18.1) guard-compat (1.2.1) - guard-livereload (2.5.1) + guard-livereload (2.5.2) em-websocket (~> 0.5) guard (~> 2.8) guard-compat (~> 1.0) multi_json (~> 1.8) - guard-rspec (4.6.4) + guard-rspec (4.7.0) guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) @@ -177,20 +179,20 @@ GEM http_parser.rb (0.6.0) i18n (0.7.0) icalendar (2.3.0) - inline_svg (0.6.2) + inline_svg (0.8.0) activesupport (>= 4.0.4) loofah (>= 2.0) nokogiri (~> 1.6) jbuilder (2.4.1) activesupport (>= 3.0.0, < 5.1) multi_json (~> 1.2) - jquery-datatables-rails (3.3.0) + jquery-datatables-rails (3.4.0) actionpack (>= 3.1) jquery-rails railties (>= 3.1) sass-rails - jquery-rails (4.0.5) - rails-dom-testing (~> 1.0) + jquery-rails (4.1.1) + rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (5.0.5) @@ -208,53 +210,56 @@ GEM actionmailer (>= 3.2) letter_opener (~> 1.0) railties (>= 3.2) - libv8 (3.16.14.13) - listen (3.0.5) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9) + libv8 (3.16.14.15) + 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) lumberjack (1.0.10) - mail (2.6.3) - mime-types (>= 1.16, < 3) + mail (2.6.4) + mime-types (>= 1.16, < 4) method_source (0.8.2) - mime-types (2.99) + mime-types (3.0) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) mimemagic (0.3.0) mini_portile2 (2.0.0) - minitest (5.8.4) - momentjs-rails (2.10.6) + minitest (5.9.0) + momentjs-rails (2.11.1) railties (>= 3.1) - multi_json (1.11.2) + multi_json (1.12.1) multipart-post (2.0.0) - mysql2 (0.4.2) - nenv (0.2.0) + mysql2 (0.4.4) + nenv (0.3.0) nested_form (0.3.2) - net-ldap (0.13.0) + net-ldap (0.14.0) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (3.0.2) + net-ssh (3.1.1) nilify_blanks (1.2.1) activerecord (>= 3.0.0) activesupport (>= 3.0.0) nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) - notiffany (0.0.8) + notiffany (0.1.0) nenv (~> 0.1) shellany (~> 0.0) octokit (3.8.0) sawyer (~> 0.6.0, >= 0.5.3) orm_adapter (0.5.0) - paperclip (4.3.2) + paperclip (4.3.6) activemodel (>= 3.2.0) activesupport (>= 3.2.0) cocaine (~> 0.5.5) mime-types mimemagic (= 0.3.0) - parser (2.2.3.0) - ast (>= 1.1, < 3.0) + parser (2.3.1.0) + ast (~> 2.2) party_foul (1.5.5) octokit (~> 3.1) - permanent_records (4.1.0) + permanent_records (4.1.5) activerecord (>= 4.2.0) activesupport (>= 4.2.0) pg (0.18.4) @@ -263,8 +268,8 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - pry-byebug (3.3.0) - byebug (~> 8.0) + pry-byebug (3.4.0) + byebug (~> 9.0) pry (~> 0.10) pry-rails (0.3.4) pry (>= 0.9.10) @@ -275,24 +280,24 @@ GEM binding_of_caller (>= 0.7) pry (>= 0.9.11) rack (1.6.4) - rack-mini-profiler (0.9.8) - rack (>= 1.1.3) + rack-mini-profiler (0.10.1) + rack (>= 1.2.0) rack-pjax (0.8.0) nokogiri (~> 1.5) rack (~> 1.1) rack-test (0.6.3) rack (>= 1.0) - rack-timeout (0.3.2) - rails (4.2.5) - actionmailer (= 4.2.5) - actionpack (= 4.2.5) - actionview (= 4.2.5) - activejob (= 4.2.5) - activemodel (= 4.2.5) - activerecord (= 4.2.5) - activesupport (= 4.2.5) + rack-timeout (0.4.2) + 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) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.5) + railties (= 4.2.6) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) @@ -300,7 +305,7 @@ GEM activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) + rails-html-sanitizer (1.0.3) loofah (~> 2.0) rails4-autocomplete (1.1.1) rails (>= 3.0) @@ -321,30 +326,30 @@ GEM remotipart (~> 1.0) safe_yaml (~> 1.0) sass-rails (>= 4.0, < 6) - rails_serve_static_assets (0.0.4) - rails_stdout_logging (0.0.4) - railties (4.2.5) - actionpack (= 4.2.5) - activesupport (= 4.2.5) + 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) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rainbow (2.0.0) - raindrops (0.15.0) - rake (10.4.2) + rainbow (2.1.0) + raindrops (0.16.0) + rake (11.1.2) rb-fsevent (0.9.7) - rb-inotify (0.9.5) + rb-inotify (0.9.7) ffi (>= 0.5.0) redcarpet (3.3.4) ref (2.0.0) remotipart (1.2.1) - request_store (1.3.0) - responders (2.1.1) + request_store (1.3.1) + responders (2.2.0) railties (>= 4.2.0, < 5.1) rspec (3.4.0) rspec-core (~> 3.4.0) rspec-expectations (~> 3.4.0) rspec-mocks (~> 3.4.0) - rspec-core (3.4.1) + rspec-core (3.4.4) rspec-support (~> 3.4.0) rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) @@ -352,7 +357,7 @@ GEM rspec-mocks (3.4.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) - rspec-rails (3.4.0) + rspec-rails (3.4.2) actionpack (>= 3.0, < 4.3) activesupport (>= 3.0, < 4.3) railties (>= 3.0, < 4.3) @@ -361,19 +366,19 @@ GEM rspec-mocks (~> 3.4.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) - rubocop (0.35.1) - astrolabe (~> 1.3) - parser (>= 2.2.3.0, < 3.0) + rubocop (0.40.0) + parser (>= 2.3.1.0, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) - tins (<= 1.6.0) - ruby-progressbar (1.7.5) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.8.1) + ruby_dep (1.3.1) rubycas-client (2.3.9) activesupport - rubyzip (1.1.7) + rubyzip (1.2.0) safe_yaml (1.0.4) - sass (3.4.21) + sass (3.4.22) sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) sass (~> 3.1) @@ -383,31 +388,31 @@ GEM sawyer (0.6.0) addressable (~> 2.3.5) faraday (~> 0.8, < 0.10) - select2-rails (4.0.1) + select2-rails (4.0.2) thor (~> 0.14) shellany (0.0.1) - shoulda-matchers (3.0.1) + shoulda-matchers (3.1.1) activesupport (>= 4.0.0) simple_form (3.2.1) actionpack (> 4, < 5.1) activemodel (> 4, < 5.1) - simplecov (0.11.1) + simplecov (0.11.2) docile (~> 1.1.0) json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) slop (3.6.0) - spring (1.6.2) + spring (1.7.1) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (3.5.2) + sprockets (3.6.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.0.0) + sprockets-rails (3.0.4) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sshkit (1.8.1) + sshkit (1.10.0) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) therubyracer (0.12.2) @@ -419,19 +424,17 @@ GEM rack (~> 1.0) thor (0.19.1) thread_safe (0.3.5) - tilt (2.0.2) - tins (1.6.0) + tilt (2.0.4) tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.7.2) - execjs (>= 0.3.0) - json (>= 1.8.0) - unicorn (5.0.1) + uglifier (3.0.0) + execjs (>= 0.3.0, < 3) + unicode-display_width (1.0.5) + unicorn (5.1.0) kgio (~> 2.6) - rack raindrops (~> 0.7) - uniform_notifier (1.9.0) - warden (1.2.4) + uniform_notifier (1.10.0) + warden (1.2.6) rack (>= 1.0) whenever (0.9.4) chronic (>= 0.6.3) @@ -445,75 +448,78 @@ DEPENDENCIES awesome_print (~> 1.6.1) aws-sdk (< 2.0) bootstrap-sass (~> 3.3.6) - bullet (~> 5.0.0) - cancancan (~> 1.13.1) - capistrano (= 3.4.0) + bullet (~> 5.1.0) + cancancan (~> 1.14.0) + capistrano (= 3.5.0) capistrano-bundler (~> 1.1.4) - capistrano-rails (~> 1.1.5) + capistrano-rails (~> 1.1.6) capistrano-rvm (~> 0.1.2) - capybara (~> 2.5.0) - capybara-webkit (~> 1.7.1) - cocoon (~> 1.2.6) - codeclimate-test-reporter (~> 0.4.8) + capybara (~> 2.7.1) + capybara-webkit (~> 1.11.1) + cocoon (~> 1.2.9) + codeclimate-test-reporter (~> 0.5.0) coffee-rails (~> 4.1.1) - database_cleaner (~> 1.5.1) - devise (~> 3.5.3) - devise_cas_authenticatable (~> 1.7.1) - dotenv-rails (~> 2.0.2) + database_cleaner (~> 1.5.3) + devise (~> 4.1.1) + devise_cas_authenticatable (~> 1.9.1) + dotenv-rails (~> 2.1.1) draper (~> 2.1.0) - factory_girl_rails (~> 4.5.0) - ffaker (~> 2.1.0) - font-awesome-rails (~> 4.5.0) - fullcalendar-rails (~> 2.5.0.0) + factory_girl_rails (~> 4.7.0) + ffaker (~> 2.2.0) + font-awesome-rails (~> 4.6.3.0) + fullcalendar-rails (~> 2.6.1.0) fuubar (~> 2.0.0) - guard-livereload (~> 2.5.1) - guard-rspec (~> 4.6.4) + guard-livereload (~> 2.5.2) + guard-rspec (~> 4.7.0) highline (~> 1.7.8) icalendar (~> 2.3.0) - inline_svg (~> 0.6.2) + inline_svg (~> 0.8.0) jbuilder (~> 2.4.0) - jquery-datatables-rails (~> 3.3.0) - jquery-rails (~> 4.0.5) + jquery-datatables-rails (~> 3.4.0) + jquery-rails (~> 4.1.1) jquery-ui-rails (~> 5.0.5) kaminari (~> 0.16.3) letter_opener (~> 1.4.1) letter_opener_web (~> 1.3.0) - momentjs-rails (~> 2.10.6) - mysql2 (~> 0.4.2) - net-ldap (~> 0.13.0) + momentjs-rails (~> 2.11.1) + mysql2 (~> 0.4.4) + net-ldap (~> 0.14.0) nilify_blanks (~> 1.2.1) - paperclip (~> 4.3.2) + paperclip (~> 4.3.6) party_foul (~> 1.5.5) - permanent_records (~> 4.1.0) + permanent_records (~> 4.1.5) pg (~> 0.18.4) pry (~> 0.10.3) - pry-byebug (~> 3.3.0) + pry-byebug (~> 3.4.0) pry-rails (~> 0.3.4) pry-remote (~> 0.1.8) pry-stack_explorer (~> 0.4.9.2) - rack-mini-profiler (~> 0.9.8) - rack-timeout (~> 0.3.2) - rails (~> 4.2.5) + rack-mini-profiler (~> 0.10.1) + rack-timeout (~> 0.4.2) + rails (~> 4.2.6) rails4-autocomplete (~> 1.1.1) rails_12factor (~> 0.0.3) rails_admin (~> 0.8.1) - rake (~> 10.4.2) + rake (~> 11.1.2) redcarpet (~> 3.3.4) - rspec-rails (~> 3.4.0) - rubocop (~> 0.35.1) - ruby-progressbar (~> 1.7.5) - rubyzip (~> 1.1.7) + rspec-rails (~> 3.4.2) + rubocop (~> 0.40.0) + ruby-progressbar (~> 1.8.1) + rubyzip (~> 1.2.0) sass-rails (~> 5.0.4) - select2-rails (~> 4.0.1) - shoulda-matchers (~> 3.0.1) + select2-rails (~> 4.0.2) + shoulda-matchers (~> 3.1.1) simple_form (~> 3.2.1) - spring (~> 1.6.2) + spring (~> 1.7.1) spring-commands-rspec (~> 1.0.4) therubyracer (~> 0.12.2) thin (~> 1.6.4) - uglifier (~> 2.7.2) - unicorn (~> 5.0.1) + uglifier (~> 3.0.0) + unicorn (~> 5.1.0) whenever (~> 0.9.4) +RUBY VERSION + ruby 2.3.1p112 + BUNDLED WITH - 1.11.2 + 1.12.4 diff --git a/app/controllers/app_configs_controller.rb b/app/controllers/app_configs_controller.rb index 2ce4cfb48..836d98cf9 100644 --- a/app/controllers/app_configs_controller.rb +++ b/app/controllers/app_configs_controller.rb @@ -39,19 +39,20 @@ def update def app_config_params params.require(:app_config) - .permit(:site_title, :admin_email, :department_name, - :contact_link_location, :home_link_text, :home_link_location, - :upcoming_checkin_email_body, :upcoming_checkin_email_active, - :upcoming_checkout_email_body, :upcoming_checkout_email_active, - :overdue_checkin_email_body, :overdue_checkin_email_active, - :reservation_confirmation_email_active, :request_text, - :enable_new_users, :res_exp_time, :blackout_exp_time, - :send_notifications_for_deleted_missed_reservations, - :deleted_missed_reservation_email_body, :enable_guests, - :default_per_cat_page, :terms_of_service, :favicon, - :checkout_persons_can_edit, :enable_renewals, - :override_on_create, :override_at_checkout, :require_phone, - :notify_admin_on_create, :disable_user_emails, - :autodeactivate_on_archive) + .permit(:site_title, :admin_email, :department_name, + :contact_link_location, :home_link_text, :home_link_location, + :upcoming_checkin_email_body, :upcoming_checkin_email_active, + :upcoming_checkout_email_body, + :upcoming_checkout_email_active, + :overdue_checkin_email_body, :overdue_checkin_email_active, + :reservation_confirmation_email_active, :request_text, + :enable_new_users, :res_exp_time, :blackout_exp_time, + :send_notifications_for_deleted_missed_reservations, + :deleted_missed_reservation_email_body, :enable_guests, + :default_per_cat_page, :terms_of_service, :favicon, + :checkout_persons_can_edit, :enable_renewals, + :override_on_create, :override_at_checkout, :require_phone, + :notify_admin_on_create, :disable_user_emails, + :autodeactivate_on_archive) end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b8abad91e..86572b6e0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -101,7 +101,7 @@ def set_view_mode def check_active_admin_permission return if can? :access, :active_admin - fail CanCan::AccessDenied.new, 'Access Denied.' + raise CanCan::AccessDenied.new, 'Access Denied.' end def check_view_mode @@ -116,7 +116,7 @@ def check_view_mode end def fix_cart_date - cart.start_date = (Time.zone.today) if cart.start_date < Time.zone.today + cart.start_date = Time.zone.today if cart.start_date < Time.zone.today cart.fix_due_date end @@ -210,11 +210,13 @@ def current_ability # rubocop:disable MethodLength, AbcSize def prepare_catalog_index_vars(eq_models = nil) # prepare the catalog - eq_models ||= EquipmentModel.active - .order('categories.sort_order ASC, equipment_models.name ASC') - .includes(:category, :requirements) - .page(params[:page]) - .per(session[:items_per_page]) + eq_models ||= + EquipmentModel.active + .order('categories.sort_order ASC, '\ + 'equipment_models.name ASC') + .includes(:category, :requirements) + .page(params[:page]) + .per(session[:items_per_page]) @eq_models_by_category = eq_models.to_a.group_by(&:category) @available_string = 'available from '\ @@ -251,10 +253,9 @@ def prepare_catalog_index_vars(eq_models = nil) # have requirements as part of equipment model itself restricted = em.model_restricted?(cart.reserver_id) - if restricted - @qualifications_hash[em.id] = Requirement.list_requirement_admins( - reserver, em).html_safe - end + next unless restricted + @qualifications_hash[em.id] = + Requirement.list_requirement_admins(reserver, em).html_safe end @page_eq_models_by_category = eq_models @@ -285,7 +286,7 @@ def deactivate # Finds the current model (EM, EI, Category) @items_class2 = params[:controller].singularize.titleize.delete(' ') - .constantize.find(params[:id]) + .constantize.find(params[:id]) # Deactivate the model you had originally intended to deactivate @items_class2.destroy flash[:notice] = 'Successfully deactivated '\ @@ -299,7 +300,7 @@ def activate # Finds the current model (EM, EI, Category) @model_to_activate = params[:controller].singularize.titleize.delete(' ') - .constantize.find(params[:id]) + .constantize.find(params[:id]) activate_parents(@model_to_activate) @model_to_activate.revive flash[:notice] = 'Successfully reactivated '\ @@ -336,6 +337,7 @@ def create_guest_user first_name: 'Guest', last_name: 'User', role: 'guest', - view_mode: 'guest') + view_mode: 'guest' + ) end end diff --git a/app/controllers/blackouts_controller.rb b/app/controllers/blackouts_controller.rb index 516a111e2..1bbca5513 100644 --- a/app/controllers/blackouts_controller.rb +++ b/app/controllers/blackouts_controller.rb @@ -69,7 +69,7 @@ def create # rubocop:disable MethodLength # check for conflicts res = Reservation.overlaps_with_date_range(p[:start_date], p[:end_date]) - .active + .active # save and exit if res.empty? && @blackout.save @@ -118,7 +118,7 @@ def destroy_recurring def blackout_params params.require(:blackout) - .permit(:start_date, :end_date, :notice, :blackout_type, :created_by, - :set_id) + .permit(:start_date, :end_date, :notice, :blackout_type, :created_by, + :set_id) end end diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index e8f7f4550..a99bce7ab 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -15,11 +15,11 @@ def set_current_category # --------- end before filter methods -------- # def index - if params[:show_deleted] - @categories = Category.all - else - @categories = Category.active - end + @categories = if params[:show_deleted] + Category.all + else + Category.active + end respond_to do |format| format.html format.zip { download_equipment_data } @@ -72,7 +72,7 @@ def deactivate @category.equipment_models.each do |em| Reservation.for_eq_model(em.id).finalized.each do |r| r.archive(current_user, 'The category was deactivated.') - .save(validate: false) + .save(validate: false) end end super @@ -86,9 +86,9 @@ def deactivate def category_params params.require(:category) - .permit(:name, :max_per_user, :max_checkout_length, :deleted_at, - :max_renewal_times, :max_renewal_length, :sort_order, - :renewal_days_before_due) + .permit(:name, :max_per_user, :max_checkout_length, :deleted_at, + :max_renewal_times, :max_renewal_length, :sort_order, + :renewal_days_before_due) end def generate_calendar_reservations diff --git a/app/controllers/concerns/calendarable.rb b/app/controllers/concerns/calendarable.rb index b8ad5617b..f305d5c82 100644 --- a/app/controllers/concerns/calendarable.rb +++ b/app/controllers/concerns/calendarable.rb @@ -105,14 +105,14 @@ def calendar_end_date # This method should return the relevant list of reservations to display in # the calendar def generate_calendar_reservations - fail NotImplementedError + raise NotImplementedError end ## # This method should return the relevant instance of the current controller's # model (e.g. the equipment model whose calendar is being requested) def generate_calendar_resource - fail NotImplementedError + raise NotImplementedError end ## @@ -127,6 +127,6 @@ def generate_source_path # is a symbol that will be called on an instance of Reservation whose return # value should accept a #name method (e.g. `reserver` or `equipment_model`) def calendar_name_method - fail NotImplementedError + raise NotImplementedError end end diff --git a/app/controllers/equipment_items_controller.rb b/app/controllers/equipment_items_controller.rb index 1ccae164b..8a8dfe9d4 100644 --- a/app/controllers/equipment_items_controller.rb +++ b/app/controllers/equipment_items_controller.rb @@ -87,7 +87,8 @@ def deactivate @equipment_item.current_reservation.archive( current_user, 'The equipment item was deactivated for the following reason: '\ - "**#{params[:deactivation_reason]}**").save(validate: false) + "**#{params[:deactivation_reason]}**" + ).save(validate: false) end super elsif params[:deactivation_cancelled] @@ -112,8 +113,8 @@ def activate def equipment_item_params params.require(:equipment_item) - .permit(:name, :serial, :deleted_at, :equipment_model_id, - :deactivation_reason, :notes) + .permit(:name, :serial, :deleted_at, :equipment_model_id, + :deactivation_reason, :notes) end def generate_calendar_reservations diff --git a/app/controllers/equipment_models_controller.rb b/app/controllers/equipment_models_controller.rb index a8933dc30..960b2963b 100644 --- a/app/controllers/equipment_models_controller.rb +++ b/app/controllers/equipment_models_controller.rb @@ -47,11 +47,11 @@ def show # rubocop:disable AbcSize, MethodLength calendar_length = 1.month @reservation_data = relevant_reservations.collect do |r| - if r.overdue - end_date = Time.zone.today + calendar_length - else - end_date = r.due_date - end + end_date = if r.overdue + Time.zone.today + calendar_length + else + r.due_date + end { start: r.start_date, end: end_date } # the above code mimics the current available? setup to show overdue # equipment as permanently 'out'. @@ -68,9 +68,10 @@ def show # rubocop:disable AbcSize, MethodLength @restricted = @equipment_model.model_restricted?(cart.reserver_id) # For pending reservations table - @pending = relevant_reservations.reserved - .overlaps_with_date_range(Time.zone.today, - Time.zone.today + 8.days) + @pending = + relevant_reservations.reserved + .overlaps_with_date_range(Time.zone.today, + Time.zone.today + 8.days) # Future reservations using Query object @future = @pending.future end @@ -118,7 +119,7 @@ def deactivate elsif params[:deactivation_confirmed] Reservation.for_eq_model(@equipment_model.id).finalized.each do |r| r.archive(current_user, 'The equipment model was deactivated.') - .save(validate: false) + .save(validate: false) end super else @@ -149,7 +150,7 @@ def delete_files 'clear_photo' => :photo } # only keep pairs that occur as keys with non-nil values in params - types.select! { |k, v| params.keys.member?((k)) && !v.nil? } + types.select! { |k, v| params.keys.member?(k) && !v.nil? } types.each { |_k, attr| params[:equipment_model][attr] = nil } end @@ -158,13 +159,13 @@ def equipment_model_params # don't have fixed hash keys (check to see if they exist first # to resolve test failures) params.require(:equipment_model) - .permit(:name, :category_id, :category, :description, :late_fee, - :replacement_fee, :max_per_user, :document_attributes, - :deleted_at, :photo, :documentation, :max_renewal_times, - :max_renewal_length, :renewal_days_before_due, :late_fee_max, - { associated_equipment_model_ids: [] }, :requirement_ids, - :requirements, :max_checkout_length) - .tap do |whitelisted| + .permit(:name, :category_id, :category, :description, :late_fee, + :replacement_fee, :max_per_user, :document_attributes, + :deleted_at, :photo, :documentation, :max_renewal_times, + :max_renewal_length, :renewal_days_before_due, :late_fee_max, + { associated_equipment_model_ids: [] }, :requirement_ids, + :requirements, :max_checkout_length) + .tap do |whitelisted| whitelisted[:checkin_procedures_attributes] = params[:equipment_model][:checkin_procedures_attributes] if params[:equipment_model][:checkin_procedures_attributes] diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index b7cee54f6..078b6a535 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -7,8 +7,7 @@ class ReportsController < ApplicationController ['Returned On Time', :returned_on_time, :count], ['Returned Overdue', :returned_overdue, :count], ['Avg Planned Duration', :all, :duration], - ['Avg Time Checked Out', :all, :time_checked_out] - ] + ['Avg Time Checked Out', :all, :time_checked_out]].freeze RES_COLUMNS = [['Reserver', :all, :name, :reserver], ['Equipment Model', :all, :name, :equipment_model], ['Equipment Item', :all, :name, :equipment_item], @@ -16,7 +15,7 @@ class ReportsController < ApplicationController ['Start Date', :all, :display, :start_date], ['Checked Out', :all, :display, :checked_out], ['Due Date', :all, :display, :due_date], - ['Checked In', :all, :display, :checked_in]] + ['Checked In', :all, :display, :checked_in]].freeze before_action :set_dates, only: [:index, :subreport] @@ -70,7 +69,7 @@ def subreport end reservations = Reservation.starts_on_days(@start_date, @end_date) - .where(id_symbol => id) + .where(id_symbol => id) @data_tables = build_subreports reservations diff --git a/app/controllers/requirements_controller.rb b/app/controllers/requirements_controller.rb index 55f5fe72d..1a0f4e307 100644 --- a/app/controllers/requirements_controller.rb +++ b/app/controllers/requirements_controller.rb @@ -49,7 +49,8 @@ def destroy def requirement_params params.require(:requirement) - .permit(:user_id, :user_ids, :description, { equipment_model_ids: [] }, - :equipment_model_id, :notes, :contact_info, :contact_name) + .permit(:user_id, :user_ids, :equipment_model_id, :contact_info, + :description, { equipment_model_ids: [] }, :notes, + :contact_name) end end diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb index 1d7139460..5d5d65c06 100644 --- a/app/controllers/reservations_controller.rb +++ b/app/controllers/reservations_controller.rb @@ -69,17 +69,17 @@ def index @filter = set_filter @view_all = session[:all_dates] - if can? :manage, Reservation - source = Reservation - else - source = current_user.reservations - end - - if session[:all_dates] - time = source - else - time = source.starts_on_days(@start_date, @end_date) - end + source = if can? :manage, Reservation + Reservation + else + current_user.reservations + end + + time = if session[:all_dates] + source + else + source.starts_on_days(@start_date, @end_date) + end set_counts(source, time) @reservations_set = time.send(@filter) @@ -181,7 +181,7 @@ def create # rubocop:disable all def edit @option_array = @reservation.equipment_model.equipment_items - .collect { |e| [e.name, e.id] } + .collect { |e| [e.name, e.id] } end # for editing reservations; not for checkout or check-in @@ -297,7 +297,7 @@ def checkout # rubocop:disable all checked_out_reservations.each do |r| r.save! # update equipment item notes - new_notes = params[:reservations]["#{r.id}"][:notes] + new_notes = params[:reservations][r.id.to_s][:notes] r.equipment_item.make_reservation_notes('checked out', r, r.checkout_handler, new_notes, r.checked_out) @@ -354,7 +354,7 @@ def checkin # rubocop:disable all checked_in_reservations.each do |r| r.save! # update equipment item notes - new_notes = params[:reservations]["#{r.id}"][:notes] + new_notes = params[:reservations][r.id.to_s][:notes] r.equipment_item.make_reservation_notes('checked in', r, r.checkin_handler, new_notes, r.checked_in) @@ -409,7 +409,7 @@ def current def send_receipt if UserMailer.reservation_status_update(@reservation, 'checked out') - .deliver_now + .deliver_now flash[:notice] = 'Successfully delivered receipt email.' else flash[:error] = 'Unable to deliver receipt email. Please contact '\ @@ -487,13 +487,14 @@ def archive # rubocop:disable all begin @reservation.archive(current_user, params[:archive_note]) - .save(validate: false) + .save(validate: false) # archive equipment item if checked out if @reservation.equipment_item @reservation.equipment_item - .make_reservation_notes('archived', @reservation, current_user, - params[:archive_note], - @reservation.checked_in) + .make_reservation_notes('archived', + @reservation, current_user, + params[:archive_note], + @reservation.checked_in) if AppConfig.check(:autodeactivate_on_archive) @reservation.equipment_item.deactivate(user: current_user, reason: params[:archive_note]) @@ -511,10 +512,10 @@ def archive # rubocop:disable all def reservation_params params.require(:reservation) - .permit(:checkout_handler_id, :checkin_handler_id, - :checked_out, :checked_in, :equipment_item, :due_date, - :equipment_item_id, :notes, :notes_unsent, :times_renewed, - :reserver_id, :reserver, :start_date, :equipment_model_id) + .permit(:checkout_handler_id, :checkin_handler_id, + :checked_out, :checked_in, :equipment_item, :due_date, + :equipment_item_id, :notes, :notes_unsent, :times_renewed, + :reserver_id, :reserver, :start_date, :equipment_model_id) end def format_errors(errors) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e979964a8..69bb2dacf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,11 +30,11 @@ def check_cas_auth # ------------ end before filter methods ------------ # def index - if params[:show_banned] - @users = User.order('username ASC') - else - @users = User.active.order('username ASC') - end + @users = if params[:show_banned] + User.order('username ASC') + else + User.active.order('username ASC') + end respond_to do |format| format.html diff --git a/app/decorators/application_decorator.rb b/app/decorators/application_decorator.rb index 8e86573bc..113ae573a 100644 --- a/app/decorators/application_decorator.rb +++ b/app/decorators/application_decorator.rb @@ -8,7 +8,7 @@ def make_deactivate_btn(onclick_str = nil) else link_to 'Deactivate', [:deactivate, object], class: 'btn btn-danger', method: :put, - onclick: "#{onclick_str}" + onclick: onclick_str.to_s end end end diff --git a/app/decorators/category_decorator.rb b/app/decorators/category_decorator.rb index 33e1f08f2..76fc3779e 100644 --- a/app/decorators/category_decorator.rb +++ b/app/decorators/category_decorator.rb @@ -15,10 +15,11 @@ def make_deactivate_btn # find reservations for models in the category in the next week res = 0 object.equipment_models.each do |em| - res += Reservation.for_eq_model(em.id).active - .overlaps_with_date_range(Time.zone.today - 1.day, - Time.zone.today + 7.days) - .count + res += + Reservation.for_eq_model(em.id).active + .overlaps_with_date_range(Time.zone.today - 1.day, + Time.zone.today + 7.days) + .count end onclick_str = "handleBigDeactivation(this, #{res}, 'category');" end diff --git a/app/decorators/equipment_model_decorator.rb b/app/decorators/equipment_model_decorator.rb index 7f489e12d..af1bc1a51 100644 --- a/app/decorators/equipment_model_decorator.rb +++ b/app/decorators/equipment_model_decorator.rb @@ -13,10 +13,11 @@ class EquipmentModelDecorator < ApplicationDecorator def make_deactivate_btn unless object.deleted_at # find reservations in the next week - res = Reservation.for_eq_model(object.id).active - .overlaps_with_date_range(Time.zone.today - 1.day, - Time.zone.today + 7.days) - .count + res = + Reservation.for_eq_model(object.id).active + .overlaps_with_date_range(Time.zone.today - 1.day, + Time.zone.today + 7.days) + .count onclick_str = "handleBigDeactivation(this, #{res}, 'equipment model');" end super(onclick_str) diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index 8203d633b..d55813b90 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -37,8 +37,9 @@ def reservations_count else # this variable is called in _navbar.html.erb to list a user's current # reservations in the dropdown. - @current_reservations = current_or_guest_user.reservations - .active_or_requested.includes(:equipment_model) + @current_reservations = + current_or_guest_user.reservations + .active_or_requested.includes(:equipment_model) count = @current_reservations.size end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 3a88f6af6..73d977ea6 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -13,7 +13,7 @@ class UserMailer < ActionMailer::Base VALID_STATUSES = ['checked out', 'denied', 'due today', 'missed', 'overdue', 'request approved', 'requested', 'returned', - 'returned overdue', 'starts today'] + 'returned overdue', 'starts today'].freeze def reservation_status_update(reservation, force = '') # rubocop:disable all if AppConfig.get(:disable_user_emails) diff --git a/app/models/blackout.rb b/app/models/blackout.rb index b7dd0c639..2f097b801 100644 --- a/app/models/blackout.rb +++ b/app/models/blackout.rb @@ -20,13 +20,13 @@ class Blackout < ActiveRecord::Base def self.get_notices_for_date(date, type = :all) # get a string of all notices for a given date # default to all blackouts - if type == :soft - blackouts = Blackout.soft.for_date(date) - elsif type == :hard - blackouts = Blackout.hard.for_date(date) - else - blackouts = Blackout.for_date(date) - end + blackouts = if type == :soft + Blackout.soft.for_date(date) + elsif type == :hard + Blackout.hard.for_date(date) + else + Blackout.for_date(date) + end messages = [] blackouts.for_date(date).each do |b| messages << b.notice diff --git a/app/models/cart_validations.rb b/app/models/cart_validations.rb index 6aa58dc3c..bad40ba3b 100644 --- a/app/models/cart_validations.rb +++ b/app/models/cart_validations.rb @@ -26,7 +26,7 @@ def validate_all(renew = false) # rubocop:disable AbcSize, MethodLength source_res = Reservation.where(equipment_model_id: items.keys) - .overlaps_with_date_range(start_date, due_date).active.all + .overlaps_with_date_range(start_date, due_date).active.all models.each do |model, quantity| errors += check_availability(model, quantity, source_res) @@ -52,8 +52,9 @@ def check_consecutive # rubocop:disable AbcSize models = get_items.keys models.each do |model| next unless model.maximum_per_user == 1 && model.maximum_checkout_length - consecutive = Reservation.for_reserver(reserver).for_eq_model(model) - .consecutive_with(start_date, due_date) + consecutive = + Reservation.for_reserver(reserver).for_eq_model(model) + .consecutive_with(start_date, due_date) consecutive.each do |c| next unless c.duration + duration > model.maximum_checkout_length @@ -162,7 +163,7 @@ def check_availability(model = EquipmentModel.find(items.keys.first), quantity = 1, source_res = Reservation.for_eq_model(items.keys.first) - .active.all) + .active.all) # checks that the model is available for the given quantity given the # existence of the source_reservations diff --git a/app/models/category.rb b/app/models/category.rb index a5e97ea4a..fe03e3f92 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -6,16 +6,10 @@ class Category < ActiveRecord::Base validates :name, presence: true, uniqueness: true - validates :max_per_user, - :max_checkout_length, - :max_renewal_length, - :max_renewal_times, - :renewal_days_before_due, - :sort_order, - numericality: { - allow_nil: true, - integer_only: true, - greater_than_or_equal_to: 0 } + validates :max_per_user, :max_checkout_length, :max_renewal_length, + :max_renewal_times, :renewal_days_before_due, :sort_order, + numericality: { allow_nil: true, integer_only: true, + greater_than_or_equal_to: 0 } nilify_blanks only: [:deleted_at] diff --git a/app/models/concerns/linkable.rb b/app/models/concerns/linkable.rb index c6a38942d..489c44c07 100644 --- a/app/models/concerns/linkable.rb +++ b/app/models/concerns/linkable.rb @@ -9,7 +9,7 @@ def default_url_options def md_link(text = name) url_method = "#{self.class.to_s.underscore}_url" - id ? "[#{text}](#{send(url_method, self, only_path: false)})" : "#{text}" + id ? "[#{text}](#{send(url_method, self, only_path: false)})" : text.to_s end end end diff --git a/app/models/equipment_item.rb b/app/models/equipment_item.rb index 99fca7331..3f6880c95 100644 --- a/app/models/equipment_item.rb +++ b/app/models/equipment_item.rb @@ -20,9 +20,9 @@ class EquipmentItem < ActiveRecord::Base searchable_on(:name, :serial) def status - if self.deleted? && deactivation_reason + if deleted? && deactivation_reason "Deactivated (#{deactivation_reason})" - elsif self.deleted? + elsif deleted? 'Deactivated' elsif r = current_reservation # rubocop:disable AssignmentInCondition "checked out by #{r.reserver.name} through "\ @@ -57,11 +57,11 @@ def make_reservation_notes(procedure_verb, reservation, handler, new_notes, new_str = "#### #{reservation.md_link(procedure_verb.capitalize)} by "\ "#{handler.md_link} for #{reservation.reserver.md_link} on "\ "#{time.to_s(:long)}\n" - if new_notes.empty? - new_str += "\n" - else - new_str += "##### Notes:\n#{new_notes}\n\n" - end + new_str += if new_notes.empty? + "\n" + else + "##### Notes:\n#{new_notes}\n\n" + end new_str += notes update_attributes(notes: new_str) end @@ -71,37 +71,34 @@ def make_switch_notes(old_res, new_res, handler) old_res_msg = old_res ? old_res.md_link : 'available' new_res_msg = new_res ? new_res.md_link : 'available' update_attributes(notes: "#### Switched by #{handler.md_link} from "\ - "#{old_res_msg} to #{new_res_msg} on "\ - "#{Time.zone.now.to_s(:long)}\n\n" + notes) + "#{old_res_msg} to #{new_res_msg} on "\ + "#{Time.zone.now.to_s(:long)}\n\n" + notes) end def update(current_user, new_params) # rubocop:disable all assign_attributes(new_params) changes = self.changes - if changes.empty? - return self - else - new_notes = "#### Edited at #{Time.zone.now.to_s(:long)} by "\ - "#{current_user.md_link}\n\n" - new_notes += "\n\n#### Changes:" - changes.each do |param, diff| - case param - when 'name' - name = 'Name' - old_val = diff[0].to_s - new_val = diff[1].to_s - when 'serial' - name = 'Serial' - old_val = diff[0].to_s - new_val = diff[1].to_s - when 'equipment_model_id' - name = 'Equipment Model' - old_val = diff[0] ? EquipmentModel.find(diff[0]).name : 'nil' - new_val = diff[1] ? EquipmentModel.find(diff[1]).name : 'nil' - end - new_notes += "\n#{name} changed from " + old_val + ' to ' + new_val\ - + '.' if old_val && new_val + return self if changes.empty? + new_notes = "#### Edited at #{Time.zone.now.to_s(:long)} by "\ + "#{current_user.md_link}\n\n" + new_notes += "\n\n#### Changes:" + changes.each do |param, diff| + case param + when 'name' + name = 'Name' + old_val = diff[0].to_s + new_val = diff[1].to_s + when 'serial' + name = 'Serial' + old_val = diff[0].to_s + new_val = diff[1].to_s + when 'equipment_model_id' + name = 'Equipment Model' + old_val = diff[0] ? EquipmentModel.find(diff[0]).name : 'nil' + new_val = diff[1] ? EquipmentModel.find(diff[1]).name : 'nil' end + new_notes += "\n#{name} changed from " + old_val + ' to ' + new_val\ + + '.' if old_val && new_val end new_notes += "\n\n" + notes self.notes = new_notes.strip @@ -126,7 +123,7 @@ def deactivate(options = {}) "#{options[:user].md_link}\n#{options[:reason]}\n\n" + notes self.notes = new_notes self.deactivation_reason = options[:reason] - self.save! + save! destroy self end diff --git a/app/models/equipment_model.rb b/app/models/equipment_model.rb index b130cb9b8..a69b6dd7c 100644 --- a/app/models/equipment_model.rb +++ b/app/models/equipment_model.rb @@ -74,7 +74,8 @@ def not_associated_with_self large: { geometry: '500x500', format: 'png' }, medium: { geometry: '250x250', format: 'png' }, small: { geometry: '150x150', format: 'png' }, - thumbnail: { geometry: '260x180', format: 'png' } }, + thumbnail: { geometry: '260x180', format: 'png' } + }, convert_options: { large: '-background none -gravity center -extent 500x500', @@ -83,7 +84,8 @@ def not_associated_with_self small: '-background none -gravity center -extent 150x150', thumbnail: - '-background none -gravity center -extent 260x180' }, + '-background none -gravity center -extent 260x180' + }, url: '/attachments/equipment_models/:attachment/:id/'\ ':style/:basename.:extension', path: ':rails_root/public/attachments/equipment_models/'\ @@ -213,8 +215,10 @@ def model_restricted?(reserver_id) def available_item_select_options equipment_items.includes(:reservations).active.select(&:available?)\ - .sort_by(&:name)\ - .collect { |item| "" }\ - .join.html_safe + .sort_by(&:name)\ + .collect do |item| + "" + end\ + .join.html_safe end end diff --git a/app/models/report.rb b/app/models/report.rb index 1c109e680..8d2449fe1 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -6,7 +6,7 @@ class Report ['Overdue', :overdue, :count], ['Returned On Time', :returned_on_time, :count], ['Returned Overdue', :returned_overdue, :count], - ['User Count', :all, :count, :reserver_id]] + ['User Count', :all, :count, :reserver_id]].freeze # Reports are extremely powerful 2D reservation statistics tables # See #build_new for the main constructor method used in the controller. @@ -46,7 +46,8 @@ class Row def self.item_to_row(item) r = Row.new r.link_path = Rails.application.routes.url_helpers.subreport_path( - id: item.id, class: item.class.to_s.underscore.downcase) + id: item.id, class: item.class.to_s.underscore.downcase + ) begin r.name = item.name if item.class == Reservation @@ -63,12 +64,9 @@ def self.item_to_row(item) # get the average of an array of values, discounting nil values def self.average2(arr) - arr = arr.reject(&:nil?) - if arr.size == 0 - 'N/A' - else - (arr.inject { |a, e| a + e }.to_f / arr.size).round(2) - end + arr.compact! + return 'N/A' if arr.empty? + (arr.inject { |a, e| a + e }.to_f / arr.size).round(2) end def self.avg_duration(res_set) @@ -158,11 +156,11 @@ def initialize_columns(col_array, reservations, row_item_type) columns.each do |col| # only instantiate the fields that we need relation = reservations.send(col.filter) - if col.data_type == :count && col.data_field.nil? - col.res_set = relation.collect(&row_item_type) - else - col.res_set = relation.to_a - end + col.res_set = if col.data_type == :count && col.data_field.nil? + relation.collect(&row_item_type) + else + relation.to_a + end end end diff --git a/app/models/reservation.rb b/app/models/reservation.rb index d9361ef26..7f563d923 100644 --- a/app/models/reservation.rb +++ b/app/models/reservation.rb @@ -45,7 +45,7 @@ class Reservation < ActiveRecord::Base # or where('flags & ? = 0', FLAGS[:flag]) for not flagged FLAGS = { request: (1 << 1), broken: (1 << 2), lost: (1 << 3), fined: (1 << 4), missed_email_sent: (1 << 5), - expired: (1 << 6) } + expired: (1 << 6) }.freeze ## Scopes ## # general scopes @@ -66,7 +66,8 @@ class Reservation < ActiveRecord::Base } scope :active_or_requested, lambda { where(status: Reservation.statuses.values_at( - *%w(requested reserved checked_out))) + *%w(requested reserved checked_out) + )) } # overdue / request scopes @@ -196,12 +197,7 @@ def time_checked_out def late_fee return 0 unless overdue - if checked_in - end_date = checked_in.to_date - else - end_date = Time.zone.today - end - fee = equipment_model.late_fee * (end_date - due_date) + fee = equipment_model.late_fee * (end_date.to_date - due_date) if fee < 0 fee = 0 elsif equipment_model.late_fee_max > 0 @@ -276,11 +272,9 @@ def to_cart def renew(user) # renew the reservation and return error messages if unsuccessful - unless self.eligible_for_renew? - return 'Reservation not eligible for renewal' - end + return 'Reservation not eligible for renewal' unless eligible_for_renew? self.due_date = find_renewal_date - self.notes = "#{notes}" + "\n\n### Renewed on "\ + self.notes = notes.to_s + "\n\n### Renewed on "\ "#{Time.zone.now.to_s(:long)} by #{user.md_link}\n\nThe new due date "\ "is #{due_date.to_s(:long)}." self.times_renewed += 1 @@ -370,56 +364,53 @@ def update(current_user, new_params, new_notes) # rubocop:disable all assign_attributes(new_params) changes = self.changes new_notes = '' unless new_notes - if new_notes.empty? && changes.empty? - return self - else - # write notes header - header = "### Edited on #{Time.zone.now.to_s(:long)} by "\ - "#{current_user.md_link}\n" - self.notes = notes ? notes + "\n\n" + header : header - - # add notes if they exist - self.notes += "\n\n#### Notes:\n#{new_notes}" unless new_notes.empty? - - # record changes - # rubocop:disable BlockNesting - unless changes.empty? - self.notes += "\n\n#### Changes:" - changes.each do |param, diff| - case param - when 'reserver_id' - name = 'Reserver' - old_val = diff[0] ? User.find(diff[0]).md_link : 'nil' - new_val = diff[1] ? User.find(diff[1]).md_link : 'nil' - when 'start_date' - name = 'Start Date' - old_val = diff[0].to_s(:long) - new_val = diff[1].to_s(:long) - when 'due_date' - name = 'Due Date' - old_val = diff[0].to_s(:long) - new_val = diff[1].to_s(:long) - if checked_out? - if overdue? && diff[1] >= Time.zone.today - overdue_str = "\nReservation marked as not overdue." - elsif !overdue? && diff[1] < Time.zone.today - overdue_str = "\nReservation marked as overdue." - end - end - when 'equipment_item_id' - name = 'Item' - old_val = diff[0] ? EquipmentItem.find(diff[0]).md_link : 'nil' - new_val = diff[1] ? EquipmentItem.find(diff[1]).md_link : 'nil' + return self if new_notes.empty? && changes.empty? + # write notes header + header = "### Edited on #{Time.zone.now.to_s(:long)} by "\ + "#{current_user.md_link}\n" + self.notes = notes ? notes + "\n\n" + header : header + + # add notes if they exist + self.notes += "\n\n#### Notes:\n#{new_notes}" unless new_notes.empty? + + # record changes + # rubocop:disable BlockNesting + unless changes.empty? + self.notes += "\n\n#### Changes:" + changes.each do |param, diff| + case param + when 'reserver_id' + name = 'Reserver' + old_val = diff[0] ? User.find(diff[0]).md_link : 'nil' + new_val = diff[1] ? User.find(diff[1]).md_link : 'nil' + when 'start_date' + name = 'Start Date' + old_val = diff[0].to_s(:long) + new_val = diff[1].to_s(:long) + when 'due_date' + name = 'Due Date' + old_val = diff[0].to_s(:long) + new_val = diff[1].to_s(:long) + if checked_out? + overdue_str = if overdue? && diff[1] >= Time.zone.today + "\nReservation marked as not overdue." + elsif !overdue? && diff[1] < Time.zone.today + "\nReservation marked as overdue." + end end - self.notes += "\n#{name} changed from " + old_val + ' to '\ - + new_val + '.' + overdue_str.to_s + when 'equipment_item_id' + name = 'Item' + old_val = diff[0] ? EquipmentItem.find(diff[0]).md_link : 'nil' + new_val = diff[1] ? EquipmentItem.find(diff[1]).md_link : 'nil' end + self.notes += "\n#{name} changed from " + old_val + ' to '\ + + new_val + '.' + overdue_str.to_s end - # rubocop:enable BlockNesting - - self.notes = self.notes.strip - self end + # rubocop:enable BlockNesting + + self.notes = self.notes.strip + self end # rubocop:disable PerceivedComplexity diff --git a/app/models/user.rb b/app/models/user.rb index ab3e7c0b7..259707f34 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -93,11 +93,11 @@ def self.search_ldap(login) return nil if login.blank? return nil unless ENV['USE_LDAP'] - if ENV['CAS_AUTH'] - filter_param = Rails.application.secrets.ldap_login - else - filter_param = Rails.application.secrets.ldap_email - end + filter_param = if ENV['CAS_AUTH'] + Rails.application.secrets.ldap_login + else + Rails.application.secrets.ldap_email + end # store affiliation parameters aff_params = Rails.application.secrets.ldap_affiliation @@ -135,15 +135,14 @@ def self.search_ldap(login) # deal with affiliation out[:affiliation] = aff_params.map { |param| result[param.to_sym][0] } - .select { |s| s && s.length > 0 }.join(' ') + .select { |s| s && !s.empty? }.join(' ') # define username based on authentication method - if ENV['CAS_AUTH'] - out[:username] = - result[Rails.application.secrets.ldap_login.to_sym][0] - else - out[:username] = out[:email] - end + out[:username] = if ENV['CAS_AUTH'] + result[Rails.application.secrets.ldap_login.to_sym][0] + else + out[:email] + end # return hash return out @@ -154,11 +153,11 @@ def self.search_ldap(login) def self.select_options User.order('last_name ASC').all - .collect { |item| ["#{item.last_name}, #{item.first_name}", item.id] } + .collect { |item| ["#{item.last_name}, #{item.first_name}", item.id] } end def render_name - ENV['CAS_AUTH'] ? "#{name} #{username}" : "#{name}" + ENV['CAS_AUTH'] ? "#{name} #{username}" : name.to_s end # ---- Reservation methods ---- # diff --git a/app/queries/query_base.rb b/app/queries/query_base.rb index fdea62f00..a5a7274f5 100644 --- a/app/queries/query_base.rb +++ b/app/queries/query_base.rb @@ -4,10 +4,10 @@ class << self end def initialize - fail NotImplementedError + raise NotImplementedError end def call - fail NotImplementedError + raise NotImplementedError end end diff --git a/app/queries/reservations/future_query.rb b/app/queries/reservations/future_query.rb index 901bb9308..de3a2a6f0 100644 --- a/app/queries/reservations/future_query.rb +++ b/app/queries/reservations/future_query.rb @@ -2,7 +2,7 @@ module Reservations class FutureQuery < Reservations::ReservationsQueryBase def call @relation.where('start_date > ?', Time.zone.today.beginning_of_day) - .reserved + .reserved end end end diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index c7d7f6f04..6248a9c7a 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -133,7 +133,7 @@ diff --git a/config/deploy.rb b/config/deploy.rb index 965f082ef..520ab70b4 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,5 +1,5 @@ # config valid only for Capistrano 3.1 -lock '3.4.0' +lock '3.5.0' set :application, "reservations-#{ENV['IDENTIFIER']}" set :repo_url, 'https://github.com/YaleSTC/reservations.git' diff --git a/config/initializers/00_devise.rb b/config/initializers/00_devise.rb index 3a01c095a..ce0289ece 100644 --- a/config/initializers/00_devise.rb +++ b/config/initializers/00_devise.rb @@ -10,11 +10,11 @@ # 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. - if AppConfig.table_exists? && !AppConfig.first.nil? - config.mailer_sender = AppConfig.first.admin_email - else - config.mailer_sender = 'admin@reservations.app' - end + config.mailer_sender = if AppConfig.table_exists? && !AppConfig.first.nil? + AppConfig.first.admin_email + else + 'admin@reservations.app' + end # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and diff --git a/config/initializers/authentication.rb b/config/initializers/authentication.rb index 72ad7deed..52bfd48a2 100644 --- a/config/initializers/authentication.rb +++ b/config/initializers/authentication.rb @@ -10,7 +10,7 @@ if ENV['CAS_AUTH'] && user && (user.username != user.cas_login) # if there are any users that don't have cas_logins, we can't use CAS if User.where(cas_login: ['', nil]).count > 0 - fail 'There are users missing their CAS logins, you cannot use CAS '\ + raise 'There are users missing their CAS logins, you cannot use CAS '\ 'authentication.' else User.update_all 'username = cas_login' diff --git a/config/initializers/days_of_the_week.rb b/config/initializers/days_of_the_week.rb index 8c8a5c493..7a13a6d3d 100644 --- a/config/initializers/days_of_the_week.rb +++ b/config/initializers/days_of_the_week.rb @@ -9,8 +9,8 @@ def days_of_the_week_short end def days_of_the_week_short_with_index - days_of_the_week_short_with_index = [ - [0, 'Sun'], [1, 'Mon'], [2, 'Tues'], [3, 'Wed'], [4, 'Thurs'], [5, 'Fri'], - [6, 'Sat']] + days_of_the_week_short_with_index = [[0, 'Sun'], [1, 'Mon'], [2, 'Tues'], + [3, 'Wed'], [4, 'Thurs'], [5, 'Fri'], + [6, 'Sat']] end # rubocop:enable UselessAssignment diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb index 1ef39bc6d..b4b5c7835 100644 --- a/config/initializers/rails_admin.rb +++ b/config/initializers/rails_admin.rb @@ -40,11 +40,7 @@ elsif request.delete? # DESTROY # optionally pass the force parameter - if @object.has_attribute?(:deleted_at) - opt = :force - else - opt = nil - end + opt = :force if @object.has_attribute?(:deleted_at) redirect_path = nil @auditing_adapter && diff --git a/db/seeds.rb b/db/seeds.rb index 8d8cd7fdd..aeda43460 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -75,7 +75,7 @@ IMAGES = Dir.glob(File.join(Rails.root, 'db', 'seed_images', '*')) # Progress bar format string -PROGRESS_STR = '%t: [%B] %P%% | %c / %C | %E' +PROGRESS_STR = '%t: [%B] %P%% | %c / %C | %E'.freeze #-------METHODS @@ -258,8 +258,8 @@ def mark_checked_in(res, checkout_length) res.checked_in = time_rand(res.checked_out, res.checked_out.next_week, checkout_length).to_datetime res.checkin_handler_id = User.where('role = ? OR role = ? OR role = ?', - 'checkout', 'admin', 'superuser' - ).all.sample.id + 'checkout', 'admin', 'superuser') + .all.sample.id end end @@ -272,8 +272,8 @@ def mark_checked_out(res) res.checked_out = res.start_date res.equipment_item = res.equipment_model.equipment_items.all.sample res.checkout_handler_id = User.where('role = ? OR role = ? OR role = ?', - 'checkout', 'admin', 'superuser' - ).all.sample.id + 'checkout', 'admin', 'superuser') + .all.sample.id end end @@ -324,7 +324,7 @@ def generate_reservation def generate_objs(method, obj, n) return if n == 0 progress = ProgressBar.create(format: PROGRESS_STR, total: n) - n.times.map do + n.times do progress.increment send(method) end @@ -358,13 +358,12 @@ def generate_objs(method, obj, n) if ENV['CAS_AUTH'] prompt_field(u, :cas_login) u.username = u.cas_login - u.save else u.username = u.email u.password = 'passw0rd' u.password_confirmation = u.password - u.save end + u.save else puts 'We need to create an account for you first.' \ 'Please enter the following info:' diff --git a/lib/activation_helper.rb b/lib/activation_helper.rb index a6aa42ad5..0a2a90ab0 100644 --- a/lib/activation_helper.rb +++ b/lib/activation_helper.rb @@ -6,7 +6,8 @@ def activate_parents(current_item) # Reactivate the current item's category and/or Equipment Model if # deactivated category = Category.find( - EquipmentModel.find(current_item.equipment_model_id).category_id) + EquipmentModel.find(current_item.equipment_model_id).category_id + ) category.revive if category.deleted_at em = EquipmentModel.find(current_item.equipment_model_id) if em.deleted_at diff --git a/lib/autocomplete.rb b/lib/autocomplete.rb index c31fcf2f9..c07343bb1 100644 --- a/lib/autocomplete.rb +++ b/lib/autocomplete.rb @@ -5,6 +5,7 @@ def get_autocomplete_items(parameters) 'nickname LIKE ? OR first_name LIKE ? OR last_name LIKE ? OR username '\ "LIKE ? OR CONCAT_WS(' ',first_name,last_name) LIKE ? OR "\ "CONCAT_WS(' ',nickname,last_name) LIKE ?", query, query, query, query, - query, query) + query, query + ) end end diff --git a/lib/capistrano/tasks/deployment_tasks.rake b/lib/capistrano/tasks/deployment_tasks.rake index f21564848..cdd6fc5ce 100644 --- a/lib/capistrano/tasks/deployment_tasks.rake +++ b/lib/capistrano/tasks/deployment_tasks.rake @@ -9,7 +9,7 @@ namespace :config do if test "[ -e #{fetch(:param_file)} ]" execute "cp -rf #{fetch(:param_file)} #{release_path}/.env" else - fail Capistrano::Error, 'You must specify a valid parameter file.' + raise Capistrano::Error, 'You must specify a valid parameter file.' end end end @@ -35,7 +35,7 @@ namespace :config do on roles(:app) do # check for Party Foul parameter in .env file env_lines = File.foreach("#{release_path}/.env") - if env_lines.grep(/PARTY_FOUL_TOKEN/).length > 0 + unless env_lines.grep(/PARTY_FOUL_TOKEN/).empty? # copy initializer execute "cp -rf #{release_path}/config/initializers/party_foul.rb"\ ".example #{release_path}/config/initializers/party_foul.rb" diff --git a/lib/csv_export.rb b/lib/csv_export.rb index 1f9313876..a469f5ab3 100644 --- a/lib/csv_export.rb +++ b/lib/csv_export.rb @@ -3,7 +3,7 @@ module CsvExport require 'zip' PROTECTED_COLS = %w(id encrypted_password reset_password_token - reset_password_sent_at) + reset_password_sent_at).freeze # generates a csv from the given model data # columns is optional; defaults to all columns except protected diff --git a/lib/csv_import.rb b/lib/csv_import.rb index 092c6c575..b0d3ddf29 100644 --- a/lib/csv_import.rb +++ b/lib/csv_import.rb @@ -47,15 +47,11 @@ def import_users(array_of_user_data, overwrite = false, user_type = 'normal') array_of_user_data.each do |user_data| user_data[:role] = user_type user_data[:csv_import] = true - if attempt_save_with_csv_data?(user_data) - next + next if attempt_save_with_csv_data?(user_data) + if ENV['USE_LDAP'] + attempt_save_with_ldap(user_data) else - if ENV['USE_LDAP'] - attempt_save_with_ldap(user_data) - else - @array_of_fail << [user_data, 'Invalid user parameters.'] - end - next + @array_of_fail << [user_data, 'Invalid user parameters.'] end end @@ -101,13 +97,10 @@ def attempt_save_with_csv_data?(user_data) user.update_attributes(user_data) # if the updated or new user is valid, save to database and add to array # of successful imports - if user.valid? - user.save - @array_of_success << user - return true - else - return false - end + return false unless user.valid? + user.save + @array_of_success << user + true end # attempts to save a user with ldap lookup @@ -127,24 +120,24 @@ def attempt_save_with_ldap(user_data) if user.valid? user.save @array_of_success << user - return else @array_of_fail << [user_data, user.errors.full_messages.to_sentence.capitalize\ + '.'] - return end + nil end # sets the user based on the overwrite parameter # rubocop:disable AccessorMethodName def set_or_create_user_for_import(user_data) # set the user and attempt to save with given data - if @overwrite && (User.where('username = ?', user_data[:username]).size > 0) - user = User.where('username = ?', user_data[:username]).first - else - user = User.new(user_data) - end + user = if @overwrite && + !User.where('username = ?', user_data[:username]).empty? + User.where('username = ?', user_data[:username]).first + else + User.new(user_data) + end user end # rubocop:enable AccessorMethodName diff --git a/lib/equipment_import.rb b/lib/equipment_import.rb index beb37af8f..d7c2be195 100644 --- a/lib/equipment_import.rb +++ b/lib/equipment_import.rb @@ -4,6 +4,7 @@ module EquipmentImport # separately for now and we can always refactor later. # import categories + # rubocop:disable MethodLength def import_cats(processed_cats, cat_overwrite = false) # let's make sure that we're consistent w/ scope on these variables array_of_success = [] # will contain category items @@ -13,11 +14,12 @@ def import_cats(processed_cats, cat_overwrite = false) cat_data[:csv_import] = true # pick or create new category based on overwrite parameter - if cat_overwrite && (Category.where('name = ?', cat_data[:name]).size > 0) - cat = Category.where('name = ?', cat_data[:name]).first - else - cat = Category.new(cat_data) - end + cat = if cat_overwrite && + !Category.where('name = ?', cat_data[:name]).empty? + Category.where('name = ?', cat_data[:name]).first + else + Category.new(cat_data) + end cat.update_attributes(cat_data) # if updated / new category is valid, save to database and add to array @@ -36,6 +38,7 @@ def import_cats(processed_cats, cat_overwrite = false) # return hash of status arrays { success: array_of_success, fail: array_of_fail } end + # rubocop:enable MethodLength # import models # rubocop:disable MethodLength, PerceivedComplexity @@ -53,12 +56,12 @@ def import_models(processed_models, model_overwrite = false) Category.where('name = ?', model_data[:category]).first # pick or create new model based on overwrite parameter - if model_overwrite && (EquipmentModel.where('name = ?', - model_data[:name]).size > 0) - model = EquipmentModel.where('name = ?', model_data[:name]).first - else - model = EquipmentModel.new(model_data) - end + model = if model_overwrite && + !EquipmentModel.where('name = ?', model_data[:name]).empty? + EquipmentModel.where('name = ?', model_data[:name]).first + else + EquipmentModel.new(model_data) + end model.update_attributes(model_data) # if updated / new model is valid, save to database and add to array of @@ -68,11 +71,11 @@ def import_models(processed_models, model_overwrite = false) array_of_success << model # else, store to array of fail with error messages else - if model_data[:category].nil? - error = 'Category not found.' - else - error = model.errors.full_messages.to_sentence.capitalize + '.' - end + error = if model_data[:category].nil? + 'Category not found.' + else + model.errors.full_messages.to_sentence.capitalize + '.' + end array_of_fail << [model_data, error] end end @@ -107,11 +110,11 @@ def import_items(processed_items) # rubocop:disable MethodLength array_of_success << item # else, store to array of fail with error messages else - if item_data[:equipment_model].nil? - error = 'Equipment Model not found.' - else - error = item.errors.full_messages.to_sentence.capitalize + '.' - end + error = if item_data[:equipment_model].nil? + 'Equipment Model not found.' + else + item.errors.full_messages.to_sentence.capitalize + '.' + end array_of_fail << [item_data, error] end end diff --git a/lib/extras/simple_form_extensions.rb b/lib/extras/simple_form_extensions.rb index 8e940c1cb..ee2e8575f 100644 --- a/lib/extras/simple_form_extensions.rb +++ b/lib/extras/simple_form_extensions.rb @@ -7,7 +7,8 @@ def submit_button(*args, &block) if cancel = options.delete(:cancel) submit(*args, &block) + ' ' + template.link_to( template.button_tag(I18n.t('simple_form.buttons.cancel'), - type: 'button', class: 'btn btn-default'), cancel) + type: 'button', class: 'btn btn-default'), cancel + ) else submit(*args, &block) end diff --git a/lib/rails_extensions.rb b/lib/rails_extensions.rb index 829d69b63..55a43d064 100644 --- a/lib/rails_extensions.rb +++ b/lib/rails_extensions.rb @@ -5,5 +5,5 @@ def intersection(other) return nil if max < other.begin || other.max < self.begin [self.begin, other.begin].max..[max, other.max].min end - alias_method :&, :intersection + alias & intersection end diff --git a/lib/tasks/delete_missed_reservations.rake b/lib/tasks/delete_missed_reservations.rake index e2d64a041..e7f28e97a 100644 --- a/lib/tasks/delete_missed_reservations.rake +++ b/lib/tasks/delete_missed_reservations.rake @@ -9,8 +9,8 @@ end def delete_missed_reservations return if AppConfig.first.blank? || AppConfig.first.res_exp_time.blank? time = AppConfig.first.res_exp_time - missed_reservations = Reservation.where( - 'start_date < ?', Time.zone.today - time.days).missed + missed_reservations = + Reservation.where('start_date < ?', Time.zone.today - time.days).missed Rails.logger.info "Found #{missed_reservations.size} reservations" missed_reservations.each do |missed_reservation| diff --git a/lib/tasks/flag_missed.rake b/lib/tasks/flag_missed.rake index 70a0d7d84..4ec04df72 100644 --- a/lib/tasks/flag_missed.rake +++ b/lib/tasks/flag_missed.rake @@ -1,7 +1,7 @@ desc 'Flag not checked out reservations starting yesterday as missed' task flag_missed: :environment do - new_missed = Reservation.where( - 'start_date <= ?', Time.zone.today - 1.day).reserved + new_missed = + Reservation.where('start_date <= ?', Time.zone.today - 1.day).reserved Rails.logger.info "Found #{new_missed.size} newly missed reservations" diff --git a/lib/tasks/setup_application.rake b/lib/tasks/setup_application.rake index 6a5447ce3..39b3b82d2 100644 --- a/lib/tasks/setup_application.rake +++ b/lib/tasks/setup_application.rake @@ -97,19 +97,17 @@ namespace :app do terms_of_service_text = File.read(File.join(DEFAULT_MSGS, 'tos_text')) - upcoming_checkin_email_body = File.read(File.join(DEFAULT_MSGS, - 'upcoming_checkin_email')) + upcoming_checkin_email_body = + File.read(File.join(DEFAULT_MSGS, 'upcoming_checkin_email')) - upcoming_checkout_email_body = File.read(File.join(DEFAULT_MSGS, - 'upcoming_checkout_email' - )) + upcoming_checkout_email_body = + File.read(File.join(DEFAULT_MSGS, 'upcoming_checkout_email')) - overdue_checkin_email_body = File.read(File.join(DEFAULT_MSGS, - 'overdue_email')) + overdue_checkin_email_body = + File.read(File.join(DEFAULT_MSGS, 'overdue_email')) - deleted_missed_reservation_email_body = File.read(File.join( - DEFAULT_MSGS, - 'deleted_missed_email')) + deleted_missed_reservation_email_body = + File.read(File.join(DEFAULT_MSGS, 'deleted_missed_email')) request_text = 'The following equipment cannot be reserved because of admin '\ diff --git a/spec/controllers/app_configs_controller_spec.rb b/spec/controllers/app_configs_controller_spec.rb index 0ed59ef6f..e29d9bad0 100644 --- a/spec/controllers/app_configs_controller_spec.rb +++ b/spec/controllers/app_configs_controller_spec.rb @@ -62,11 +62,12 @@ before(:each) do sign_in FactoryGirl.create(:admin) # Except paperclip attributes that trigger MassAssignment errors - @params = FactoryGirl.attributes_for(:app_config) - .reject do |k, _v| - [:favicon_file_name, :favicon_content_type, - :favicon_file_size, :favicon_updated_at].include? k - end + @params = + FactoryGirl.attributes_for(:app_config) + .reject do |k, _v| + [:favicon_file_name, :favicon_content_type, + :favicon_file_size, :favicon_updated_at].include? k + end end it 'assigns current configuration to @app_config' do @@ -116,11 +117,12 @@ # TODO: Simulate update_attributes failure before(:each) do # Except paperclip attributes that trigger MassAssignment errors - @params = FactoryGirl.attributes_for(:app_config, site_title: nil) - .reject do |k, _v| - [:favicon_file_name, :favicon_content_type, - :favicon_file_size, :favicon_updated_at].include? k - end + @params = + FactoryGirl.attributes_for(:app_config, site_title: nil) + .reject do |k, _v| + [:favicon_file_name, :favicon_content_type, + :favicon_file_size, :favicon_updated_at].include? k + end post :update, @params end # it { should render_template(:edit) } diff --git a/spec/controllers/blackouts_controller_spec.rb b/spec/controllers/blackouts_controller_spec.rb index a32b37d48..4f0a03012 100644 --- a/spec/controllers/blackouts_controller_spec.rb +++ b/spec/controllers/blackouts_controller_spec.rb @@ -102,7 +102,8 @@ @res = FactoryGirl.create(:valid_reservation, due_date: Time.zone.today + 1.day) @attributes = FactoryGirl.attributes_for( - :blackout, days: ["#{(Time.zone.today + 1.day).wday}"]) + :blackout, days: [(Time.zone.today + 1.day).wday.to_s] + ) post :create_recurring, blackout: @attributes end diff --git a/spec/controllers/equipment_items_controller_spec.rb b/spec/controllers/equipment_items_controller_spec.rb index 25d2549d0..7bedc2290 100644 --- a/spec/controllers/equipment_items_controller_spec.rb +++ b/spec/controllers/equipment_items_controller_spec.rb @@ -178,7 +178,8 @@ it 'should save item with notes' do expect do post :create, equipment_item: FactoryGirl.attributes_for( - :equipment_item, equipment_model_id: item.equipment_model.id) + :equipment_item, equipment_model_id: item.equipment_model.id + ) end.to change(EquipmentItem, :count).by(1) expect(EquipmentItem.last.notes).not_to be_nil expect(EquipmentItem.last.notes).not_to be('') @@ -188,15 +189,17 @@ end context 'without valid attributes' do before do - post :create, equipment_item: FactoryGirl.attributes_for( - :equipment_item, name: nil) + post :create, + equipment_item: FactoryGirl.attributes_for(:equipment_item, + name: nil) end it { is_expected.not_to set_flash } it { is_expected.to render_template(:new) } it 'should not save' do expect do - post :create, equipment_item: FactoryGirl.attributes_for( - :equipment_item, name: nil) + post :create, + equipment_item: FactoryGirl.attributes_for(:equipment_item, + name: nil) end.not_to change(EquipmentItem, :count) end it { is_expected.to render_template(:new) } diff --git a/spec/controllers/equipment_models_controller_spec.rb b/spec/controllers/equipment_models_controller_spec.rb index c21166f0c..d8035cdcc 100644 --- a/spec/controllers/equipment_models_controller_spec.rb +++ b/spec/controllers/equipment_models_controller_spec.rb @@ -147,13 +147,13 @@ FactoryGirl.create(:equipment_item, equipment_model: model) FactoryGirl.create(:missed_reservation, equipment_model: model) res_starting_today = - FactoryGirl.create(:reservation, equipment_model: model, - start_date: Time.zone.today, - due_date: Time.zone.today + 2.days) + FactoryGirl.create(:reservation, equipment_model: model, + start_date: Time.zone.today, + due_date: Time.zone.today + 2.days) res_starting_this_week = - FactoryGirl.create(:reservation, equipment_model: model, - start_date: Time.zone.today + 2.days, - due_date: Time.zone.today + 4.days) + FactoryGirl.create(:reservation, equipment_model: model, + start_date: Time.zone.today + 2.days, + due_date: Time.zone.today + 4.days) FactoryGirl.create(:reservation, equipment_model: model, start_date: Time.zone.today + 10.days, @@ -334,12 +334,14 @@ context 'with valid attributes' do before do post :create, equipment_model: FactoryGirl.attributes_for( - :equipment_model, category_id: model.category) + :equipment_model, category_id: model.category + ) end it 'should save model' do expect do post :create, equipment_model: FactoryGirl.attributes_for( - :equipment_model, category_id: model.category) + :equipment_model, category_id: model.category + ) end.to change(EquipmentModel, :count).by(1) end it { is_expected.to set_flash } @@ -348,15 +350,17 @@ context 'without valid attributes' do before do - post :create, equipment_model: FactoryGirl.attributes_for( - :equipment_model, name: nil) + post :create, + equipment_model: FactoryGirl.attributes_for(:equipment_model, + name: nil) end it { is_expected.to set_flash } it { is_expected.to render_template(:new) } it 'should not save' do expect do - post :create, equipment_model: FactoryGirl.attributes_for( - :equipment_model, name: nil) + post :create, + equipment_model: FactoryGirl.attributes_for(:equipment_model, + name: nil) end.not_to change(EquipmentModel, :count) end it { is_expected.to render_template(:new) } diff --git a/spec/controllers/reservations_controller_spec.rb b/spec/controllers/reservations_controller_spec.rb index 0b7e96fbe..67d94577d 100644 --- a/spec/controllers/reservations_controller_spec.rb +++ b/spec/controllers/reservations_controller_spec.rb @@ -84,7 +84,7 @@ # depending on admin status, source of reservations (all v. own) changes FILTERS = [:reserved, :checked_out, :overdue, :missed, - :returned, :upcoming, :archived] + :returned, :upcoming, :archived].freeze context 'when accessed by non-banned user' do subject { get :index } @@ -486,7 +486,7 @@ it 'assigns @option_array with the correct contents' do expect(assigns(:option_array)).to\ eq @reservation.equipment_model.equipment_items - .collect { |e| [e.name, e.id] } + .collect { |e| [e.name, e.id] } end it { is_expected.to render_template(:edit) } end @@ -1592,7 +1592,8 @@ context 'successfully emails' do before do @reservation.update_attributes( - FactoryGirl.attributes_for(:checked_out_reservation)) + FactoryGirl.attributes_for(:checked_out_reservation) + ) get :send_receipt, id: @reservation.id end it { is_expected.to redirect_to(@reservation) } @@ -1601,8 +1602,9 @@ context 'fails to send email' do before do - allow(UserMailer).to receive_message_chain( - 'reservation_status_update.deliver_now').and_return(false) + allow(UserMailer).to \ + receive_message_chain('reservation_status_update.deliver_now') + .and_return(false) get :send_receipt, id: @reservation.id end it { is_expected.to redirect_to(@reservation) } @@ -1619,7 +1621,7 @@ it 'should assign all current requests except itself' do expect(assigns(:all_current_requests_by_user)).to\ eq @reservation.reserver.reservations.requested - .reject { |r| r.id == @reservation.id } + .reject { |r| r.id == @reservation.id } end it 'should assign errors' do expect(assigns(:errors)).to eq assigns(:reservation).validate diff --git a/spec/features/eq_model_spec.rb b/spec/features/eq_model_spec.rb index 2f5ccc3a6..01d15b4d3 100644 --- a/spec/features/eq_model_spec.rb +++ b/spec/features/eq_model_spec.rb @@ -37,13 +37,13 @@ page.all(:css, 'section#pending_reservations .giant-numbers div') expect(num_divs[0].text).to eq('1') expect(num_divs[1].text).to eq('2') - expect(page).to have_link "#{@today_res.id}", + expect(page).to have_link @today_res.id.to_s, href: reservation_path(@today_res) - expect(page).to have_link "#{@pending_res_1.id}", + expect(page).to have_link @pending_res_1.id.to_s, href: reservation_path(@pending_res_1) - expect(page).to have_link "#{@pending_res_2.id}", + expect(page).to have_link @pending_res_2.id.to_s, href: reservation_path(@pending_res_2) - expect(page).not_to have_link "#{@far_future_res.id}", + expect(page).not_to have_link @far_future_res.id.to_s, href: reservation_path(@far_future_res) end end diff --git a/spec/features/equipment_model_calendar_spec.rb b/spec/features/equipment_model_calendar_spec.rb index 683f88b71..138c42711 100644 --- a/spec/features/equipment_model_calendar_spec.rb +++ b/spec/features/equipment_model_calendar_spec.rb @@ -76,7 +76,7 @@ end def create_res_in_current_month(count = 1) - fail ArgumentError if count > 28 + raise ArgumentError if count > 28 day0 = Time.zone.today.beginning_of_month # to ensure it's in this month (1..count).each do |i| # make sure it's a 1-day reservation so there's only a single cell diff --git a/spec/features/guest_spec.rb b/spec/features/guest_spec.rb index a9985107c..2782b4cda 100644 --- a/spec/features/guest_spec.rb +++ b/spec/features/guest_spec.rb @@ -86,9 +86,8 @@ end it 'can add items to cart' do - expect(page.find(:css, '#list_items_in_cart')).to have_link( - @eq_model.name, - href: equipment_model_path(@eq_model)) + expect(page.find(:css, '#list_items_in_cart')).to \ + have_link(@eq_model.name, href: equipment_model_path(@eq_model)) end it 'can remove items from cart' do @@ -97,9 +96,8 @@ fill_in "quantity_field_#{EquipmentModel.first.id}", with: quantity.to_s find('#quantity_form').submit_form! visit '/' - expect(page.find(:css, '#list_items_in_cart')).not_to have_link( - @eq_model.name, - href: equipment_model_path(@eq_model)) + expect(page.find(:css, '#list_items_in_cart')).not_to \ + have_link(@eq_model.name, href: equipment_model_path(@eq_model)) end it 'can change item quantities' do diff --git a/spec/features/rails_admin_spec.rb b/spec/features/rails_admin_spec.rb index 5ff62f5d7..d622785d8 100644 --- a/spec/features/rails_admin_spec.rb +++ b/spec/features/rails_admin_spec.rb @@ -3,7 +3,7 @@ describe 'Active Admin', type: :feature do VALID_MODELS = [:announcement, :app_config, :blackout, :category, :checkin_procedure, :checkout_procedure, :equipment_item, - :equipment_model, :requirement, :reservation, :user] + :equipment_model, :requirement, :reservation, :user].freeze context 'as superuser' do before { sign_in_as_user(@superuser) } diff --git a/spec/features/reservations_spec.rb b/spec/features/reservations_spec.rb index dc871c87c..8ae2c9979 100644 --- a/spec/features/reservations_spec.rb +++ b/spec/features/reservations_spec.rb @@ -203,7 +203,7 @@ equipment_model: @eq_model @user.update_attributes(role: 'banned') visit manage_reservations_for_user_path(@user) - check "#{@checked_out_res.equipment_item.name}" + check @checked_out_res.equipment_item.name.to_s click_button 'Check-In Equipment' expect(page).to have_content 'Check-In Receipt' @@ -218,7 +218,7 @@ @user.update_attributes(role: 'banned') # check out visit manage_reservations_for_user_path(@user) - select "#{@eq_model.equipment_items.first.name}", from: 'Equipment Item' + select @eq_model.equipment_items.first.name.to_s, from: 'Equipment Item' click_button 'Check-Out Equipment' expect(page).to have_content 'Banned users cannot check out equipment' end @@ -257,7 +257,7 @@ it 'checks out and checks in successfully' do # check out visit manage_reservations_for_user_path(@user) - select "#{@eq_model.equipment_items.first.name}", from: 'Equipment Item' + select @eq_model.equipment_items.first.name.to_s, from: 'Equipment Item' click_button 'Check-Out Equipment' expect(page).to have_content 'Check-Out Receipt' @@ -276,7 +276,7 @@ # check in visit manage_reservations_for_user_path(@user) - check "#{@res.equipment_item.name}" + check @res.equipment_item.name.to_s click_button 'Check-In Equipment' expect(page).to have_content 'Check-In Receipt' @@ -294,7 +294,7 @@ it 'does not update equipment items for missing ToS checkbox' do @user.update_attributes(terms_of_service_accepted: false) visit manage_reservations_for_user_path(@user) - select "#{@eq_model.equipment_items.first.name}", from: 'Equipment Item' + select @eq_model.equipment_items.first.name.to_s, from: 'Equipment Item' click_button 'Check-Out Equipment' expect(page).to have_content 'You must confirm that the user accepts '\ @@ -310,9 +310,9 @@ reserver: @user, equipment_model: @eq_model visit manage_reservations_for_user_path(@user) - select "#{@eq_model.equipment_items.first.name}", + select @eq_model.equipment_items.first.name.to_s, from: "reservations_#{@res.id}_equipment_item_id" - select "#{@eq_model.equipment_items.first.name}", + select @eq_model.equipment_items.first.name.to_s, from: "reservations_#{@res2.id}_equipment_item_id" click_button 'Check-Out Equipment' @@ -374,7 +374,7 @@ it 'fails when the box isn\'t checked off' do # skip the checkbox - select "#{@eq_model.equipment_items.first.name}", + select @eq_model.equipment_items.first.name.to_s, from: 'Equipment Item' click_button 'Check-Out Equipment' @@ -386,7 +386,7 @@ it 'succeeds when the box is checked off' do check 'terms_of_service_accepted' - select "#{@eq_model.equipment_items.first.name}", + select @eq_model.equipment_items.first.name.to_s, from: 'Equipment Item' click_button 'Check-Out Equipment' @@ -578,7 +578,7 @@ avail_quantity = @eq_model.num_available(Time.zone.today, Time.zone.today + 1.day) fill_in "quantity_field_#{@eq_model.id}", # edit and submit - with: (avail_quantity) + with: avail_quantity quantity_forms[0].submit_form! # loading right page @@ -666,13 +666,14 @@ # valid change due_date = Time.zone.today + 2.days fill_in 'cart_due_date_cart', with: due_date - find(:xpath, "//input[@id='date_end_alt']").set due_date + find(:xpath, "//input[@id='date_end_alt']", visible: :all).set due_date find('#dates_form').submit_form! # loads right page expect(page).to have_content 'Confirm Reservation' expect(page).not_to have_content 'Confirm Reservation Request' # has correct date - expect(page).to have_selector("input[value='#{due_date}']") + expect(page).to have_selector("input[value='#{due_date}']", + visible: :all) end end @@ -689,13 +690,15 @@ bad_due_date = Time.zone.today + (@eq_model.maximum_checkout_length + 1).days fill_in 'cart_due_date_cart', with: bad_due_date - find(:xpath, "//input[@id='date_end_alt']").set bad_due_date + find(:xpath, "//input[@id='date_end_alt']", visible: :all) + .set bad_due_date find('#dates_form').submit_form! # loads right page expect(page).to have_content 'Confirm Reservation Request' expect(page).to have_content AppConfig.get(:request_text) # has altered date - expect(page).to have_selector("input[value='#{bad_due_date}']") + expect(page).to have_selector("input[value='#{bad_due_date}']", + visible: :all) end end @@ -711,18 +714,20 @@ bad_due_date = Time.zone.today + (@eq_model.maximum_checkout_length + 1).days fill_in 'cart_due_date_cart', with: bad_due_date - find(:xpath, "//input[@id='date_end_alt']").set bad_due_date + find(:xpath, "//input[@id='date_end_alt']", visible: :all) + .set bad_due_date find('#dates_form').submit_form! # changes back to valid date due_date = Time.zone.today + 1.day fill_in 'cart_due_date_cart', with: due_date - find(:xpath, "//input[@id='date_end_alt']").set due_date + find(:xpath, "//input[@id='date_end_alt']", visible: :all).set due_date find('#dates_form').submit_form! # redirect to right page expect(page).to have_content 'Confirm Reservation' expect(page).not_to have_content 'Confirm Reservation Request' # has correct dates - expect(page).to have_selector("input[value='#{due_date}']") + expect(page).to have_selector("input[value='#{due_date}']", + visible: :all) end end @@ -777,7 +782,7 @@ # change cart to have invalid properties, and check if it loads request quantity_forms = page.all('#quantity_form') fill_in "quantity_field_#{@eq_model.id}", - with: (@eq_model.max_per_user) + with: @eq_model.max_per_user quantity_forms[0].submit_form! expect(page).to have_content 'Confirm Reservation' end diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index 9f44cf0d8..0403023d0 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -5,7 +5,7 @@ shared_examples 'can ban other users' do it do visit user_path(@user) - expect(page).to have_link 'Ban', ban_user_path(@user) + expect(page).to have_link 'Ban', href: ban_user_path(@user) click_link 'Ban' expect { @user.reload }.to change { @user.role }.to('banned') end diff --git a/spec/lib/csv_export_spec.rb b/spec/lib/csv_export_spec.rb index ed898e9da..abeb9c1ee 100644 --- a/spec/lib/csv_export_spec.rb +++ b/spec/lib/csv_export_spec.rb @@ -2,9 +2,9 @@ include CsvExport describe CsvExport do - MODELS = [:user, :category, :equipment_model, :equipment_item] + MODELS = [:user, :category, :equipment_model, :equipment_item].freeze PROTECTED_COLS = %w(id encrypted_password reset_password_token - reset_password_sent_at) + reset_password_sent_at).freeze shared_examples 'builds a csv' do |model| let(:csv) do @@ -16,8 +16,8 @@ end it 'has the appropriate columns' do - expect(csv.first.split(',')).to eq( - FactoryGirl.build(model).attributes.keys - PROTECTED_COLS) + expect(csv.first.split(',')).to \ + eq(FactoryGirl.build(model).attributes.keys - PROTECTED_COLS) end it "doesn't include protected columns" do diff --git a/spec/lib/tasks/email_checkin_reminder_rake_spec.rb b/spec/lib/tasks/email_checkin_reminder_rake_spec.rb index fd0300b36..4fe392542 100644 --- a/spec/lib/tasks/email_checkin_reminder_rake_spec.rb +++ b/spec/lib/tasks/email_checkin_reminder_rake_spec.rb @@ -16,23 +16,24 @@ it 'sends emails for checked-out reservations that end today' do allow(@ac).to receive(:upcoming_checkin_email_active?).and_return(true) - expect { subject.invoke }.to( - change { ActionMailer::Base.deliveries.count }.by(1)) + expect { subject.invoke }.to \ + change { ActionMailer::Base.deliveries.count }.by(1) end it "doesn't send emails for non-checked-out reservations that end today" do @upcoming.update_attributes( FactoryGirl.attributes_for(:valid_reservation, start_date: Time.zone.today - 1.day, - due_date: Time.zone.today)) + due_date: Time.zone.today) + ) allow(@ac).to receive(:upcoming_checkin_email_active?).and_return(true) expect(@upcoming.reserved?).to be_truthy - expect { subject.invoke }.not_to( - change { ActionMailer::Base.deliveries.count }) + expect { subject.invoke }.not_to \ + change { ActionMailer::Base.deliveries.count } end it "doesn't send emails when upcoming_checkin_email_active is false" do allow(@ac).to receive(:upcoming_checkin_email_active?).and_return(false) - expect { subject.invoke }.not_to( - change { ActionMailer::Base.deliveries.count }) + expect { subject.invoke }.not_to \ + change { ActionMailer::Base.deliveries.count } end end diff --git a/spec/lib/tasks/email_checkout_reminder_rake_spec.rb b/spec/lib/tasks/email_checkout_reminder_rake_spec.rb index 8ae72df43..4afab5f3e 100644 --- a/spec/lib/tasks/email_checkout_reminder_rake_spec.rb +++ b/spec/lib/tasks/email_checkout_reminder_rake_spec.rb @@ -17,13 +17,13 @@ it 'sends emails for reservations that start today' do allow(@ac).to receive(:upcoming_checkout_email_active?).and_return(true) - expect { subject.invoke }.to( - change { ActionMailer::Base.deliveries.count }.by(1)) + expect { subject.invoke }.to \ + change { ActionMailer::Base.deliveries.count }.by(1) end it "doesn't send emails when upcoming_checkout_email_active is false" do allow(@ac).to receive(:upcoming_checkout_email_active?).and_return(false) - expect { subject.invoke }.not_to( - change { ActionMailer::Base.deliveries.count }) + expect { subject.invoke }.not_to \ + change { ActionMailer::Base.deliveries.count } end end diff --git a/spec/lib/tasks/email_missed_reservations_rake_spec.rb b/spec/lib/tasks/email_missed_reservations_rake_spec.rb index fecccf47a..9f37999c5 100644 --- a/spec/lib/tasks/email_missed_reservations_rake_spec.rb +++ b/spec/lib/tasks/email_missed_reservations_rake_spec.rb @@ -14,21 +14,21 @@ end it 'updates flags after email is sent' do - expect { subject.invoke }.to( + expect { subject.invoke }.to \ change { Reservation.find(@missed.id).flagged?(:missed_email_sent) } - .from(false).to(true)) + .from(false).to(true) end it 'sends emails for reservations that were missed' do expect(@missed.missed?).to be_truthy - expect { subject.invoke }.to( - change { ActionMailer::Base.deliveries.count }.by(1)) + expect { subject.invoke }.to \ + change { ActionMailer::Base.deliveries.count }.by(1) end it "doesn't send emails if the missed_email_sent flag is set" do @missed.flag(:missed_email_sent) @missed.save! - expect { subject.invoke }.to_not( - change { ActionMailer::Base.deliveries.count }) + expect { subject.invoke }.not_to \ + change { ActionMailer::Base.deliveries.count } end end diff --git a/spec/lib/tasks/email_notes_to_admins_rake_spec.rb b/spec/lib/tasks/email_notes_to_admins_rake_spec.rb index e6c951f4f..0ff3e0c62 100644 --- a/spec/lib/tasks/email_notes_to_admins_rake_spec.rb +++ b/spec/lib/tasks/email_notes_to_admins_rake_spec.rb @@ -6,7 +6,7 @@ before(:each) { mock_app_config(admin_email: 'admin@email.com') } - STATUSES = [:checked_out_reservation, :checked_in_reservation] + STATUSES = [:checked_out_reservation, :checked_in_reservation].freeze shared_examples 'sends appropriate emails' do |status| let(:notes) do @@ -22,16 +22,16 @@ it "doesn't sends emails for reservations without unsent notes" do expect(notes.notes_unsent).to be_falsey - expect { subject.invoke }.to_not( - change { ActionMailer::Base.deliveries.count }) + expect { subject.invoke }.to_not \ + change { ActionMailer::Base.deliveries.count } end it 'sends emails for appropriate reservations with unsent notes' do notes.update_attributes(notes_unsent: true) expect(notes.notes_unsent).to be_truthy notes.save!(validate: false) - expect { subject.invoke }.to( - change { ActionMailer::Base.deliveries.count }.by(1)) + expect { subject.invoke }.to \ + change { ActionMailer::Base.deliveries.count }.by(1) end end diff --git a/spec/lib/tasks/email_overdue_reminder_rake_spec.rb b/spec/lib/tasks/email_overdue_reminder_rake_spec.rb index 6ea6920b2..930baff96 100644 --- a/spec/lib/tasks/email_overdue_reminder_rake_spec.rb +++ b/spec/lib/tasks/email_overdue_reminder_rake_spec.rb @@ -14,13 +14,13 @@ it 'sends emails for reservations that are overdue' do allow(@ac).to receive(:overdue_checkin_email_active?).and_return(true) - expect { subject.invoke }.to( - change { ActionMailer::Base.deliveries.count }.by(1)) + expect { subject.invoke }.to \ + change { ActionMailer::Base.deliveries.count }.by(1) end it "doesn't send emails when overdue_checkin_email_active is false" do allow(@ac).to receive(:overdue_checkin_email_active?).and_return(false) - expect { subject.invoke }.not_to( - change { ActionMailer::Base.deliveries.count }) + expect { subject.invoke }.not_to \ + change { ActionMailer::Base.deliveries.count } end end diff --git a/spec/lib/tasks/flag_rake_spec.rb b/spec/lib/tasks/flag_rake_spec.rb index 2c33cd6e4..05f1b15f7 100644 --- a/spec/lib/tasks/flag_rake_spec.rb +++ b/spec/lib/tasks/flag_rake_spec.rb @@ -10,16 +10,15 @@ end it 'flags reservations due yesterday as overdue' do - @res.update_attributes( - FactoryGirl.attributes_for(:overdue_reservation)) + @res.update_attributes(FactoryGirl.attributes_for(:overdue_reservation)) @res.update_columns(overdue: false) - expect { subject.invoke }.to( - change { Reservation.find(@res.id).overdue }.from(false).to(true)) + expect { subject.invoke }.to \ + change { Reservation.find(@res.id).overdue }.from(false).to(true) end it "doesn't flag not overdue reservations" do - expect { subject.invoke }.not_to( - change { Reservation.find(@res.id).overdue }) + expect { subject.invoke }.not_to \ + change { Reservation.find(@res.id).overdue } end it 'flags past overdue reservations' do @@ -45,8 +44,8 @@ it 'flags missed reservations as missed' do @res.update_attributes(start_date: Time.zone.yesterday, due_date: Time.zone.today) - expect { subject.invoke }.to( - change { Reservation.find(@res.id).status }.from('reserved').to('missed')) + expect { subject.invoke }.to \ + change { Reservation.find(@res.id).status }.from('reserved').to('missed') end it "doesn't flag not missed reservations" do @@ -54,8 +53,7 @@ end it "doesn't flag checked out reservations" do - @res.update_attributes( - FactoryGirl.attributes_for(:checked_out_reservation)) + @res.update_attributes(FactoryGirl.attributes_for(:checked_out_reservation)) expect { subject.invoke }.not_to change { Reservation.find(@res.id).status } end end @@ -72,15 +70,13 @@ @res.update_attributes(FactoryGirl.attributes_for(:request)) @res.update_attributes(start_date: Time.zone.yesterday, due_date: Time.zone.today) - expect { subject.invoke }.to( - change { Reservation.find(@res.id).status }.from( - 'requested').to('denied')) + expect { subject.invoke }.to \ + change { Reservation.find(@res.id).status }.from('requested').to('denied') expect(Reservation.find(@res.id).flagged?(:expired)).to be_truthy end it "doesn't flag missed non-requests" do - @res.update_attributes( - FactoryGirl.attributes_for(:missed_reservation)) + @res.update_attributes(FactoryGirl.attributes_for(:missed_reservation)) expect { subject.invoke }.not_to change { Reservation.find(@res.id).status } end @@ -96,7 +92,7 @@ @res.update_attributes(start_date: Time.zone.yesterday, due_date: Time.zone.today) @no_email = FactoryGirl.create(:missed_reservation) - expect { subject.invoke }.to( - change { ActionMailer::Base.deliveries.count }.by(1)) + expect { subject.invoke }.to \ + change { ActionMailer::Base.deliveries.count }.by(1) end end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index cfd0b3947..1678363e8 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -54,7 +54,7 @@ end it 'logs if the env is set' do - env_wrapper('LOG_EMAILS' => '1') do + env_wrapper('LOG_EMAILS' => '1') do expect(Rails.logger).to receive(:info).with(/Sent/).once # force a request email; there is not an email for a basic reservation @mail = UserMailer.reservation_status_update(@res, @@ -74,16 +74,16 @@ @res.update_attributes(status: 'denied') expect(@res.denied?).to be_truthy @mail = UserMailer.reservation_status_update(@res).deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Denied") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Denied") end it 'sends approved request notifications' do @res.update_attributes(status: 'reserved', flags: Reservation::FLAGS[:request]) @mail = UserMailer.reservation_status_update(@res).deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Request Approved") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Request Approved") end it 'sends approved request notifications for requests starting today' do @@ -94,8 +94,8 @@ @mail = UserMailer.reservation_status_update(@res, 'request approved').deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Request Approved") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Request Approved") end it 'sends expired request notifications' do @@ -103,36 +103,35 @@ flags: (Reservation::FLAGS[:request] | Reservation::FLAGS[:expired])) @mail = UserMailer.reservation_status_update(@res).deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Request Expired") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Request Expired") end it 'sends reminders to check-out' do - @res.update_attributes( - FactoryGirl.attributes_for(:upcoming_reservation)) + @res.update_attributes(FactoryGirl.attributes_for(:upcoming_reservation)) @mail = UserMailer.reservation_status_update(@res).deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Starts Today") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Starts Today") end it 'sends missed notifications' do @res.update_attributes(FactoryGirl.attributes_for(:missed_reservation)) @mail = UserMailer.reservation_status_update(@res).deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Missed") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Missed") end it 'sends check-out receipts' do @res.update_attributes( - FactoryGirl.attributes_for(:checked_out_reservation)) + FactoryGirl.attributes_for(:checked_out_reservation) + ) @mail = UserMailer.reservation_status_update(@res).deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Checked Out") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Checked Out") end it "doesn't sends check-out receipts if not checked out" do - @res.update_attributes( - FactoryGirl.attributes_for(:valid_reservation)) + @res.update_attributes(FactoryGirl.attributes_for(:valid_reservation)) expect(@res.checked_out).to be_nil @mail = UserMailer.reservation_status_update(@res, 'checked out').deliver_now @@ -142,51 +141,54 @@ it 'sends check-out receipts for reservations due today' do @res.update_attributes( FactoryGirl.attributes_for(:checked_out_reservation, - due_date: Time.zone.today)) + due_date: Time.zone.today) + ) @mail = UserMailer.reservation_status_update(@res, 'checked out').deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Checked Out") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Checked Out") end it 'sends check-out receipts for overdue reservations' do @res.update_attributes(FactoryGirl.attributes_for(:overdue_reservation)) @mail = UserMailer.reservation_status_update(@res, 'checked out').deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Checked Out") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Checked Out") end it 'sends reminders to check-in' do @res.update_attributes( FactoryGirl.attributes_for(:checked_out_reservation, - due_date: Time.zone.today)) + due_date: Time.zone.today) + ) @mail = UserMailer.reservation_status_update(@res).deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Due Today") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Due Today") end it 'sends check-in receipts' do @res.update_attributes( - FactoryGirl.attributes_for(:checked_in_reservation)) + FactoryGirl.attributes_for(:checked_in_reservation) + ) @mail = UserMailer.reservation_status_update(@res).deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Returned") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Returned") end it 'sends overdue equipment reminders' do @res.update_attributes(FactoryGirl.attributes_for(:overdue_reservation)) @mail = UserMailer.reservation_status_update(@res).deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Overdue") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Overdue") end it 'sends fine emails for overdue equipment' do @res.update_attributes(FactoryGirl.attributes_for(:checked_in_reservation, :overdue)) @mail = UserMailer.reservation_status_update(@res).deliver_now - expect(@mail.subject).to eq( - "[Reservations] #{@res.equipment_model.name} Returned Overdue") + expect(@mail.subject).to \ + eq("[Reservations] #{@res.equipment_model.name} Returned Overdue") end it "doesn't send fine emails when there is no late fee" do diff --git a/spec/models/cart_spec.rb b/spec/models/cart_spec.rb index 07a96078b..f70a6af17 100644 --- a/spec/models/cart_spec.rb +++ b/spec/models/cart_spec.rb @@ -154,7 +154,7 @@ FactoryGirl.build(:reservation, equipment_model: @em, start_date: @start_date, due_date: @due_date) - .save(validate: false) + .save(validate: false) expect(@cart.check_availability).not_to eq([]) expect(@cart.validate_all).not_to eq([]) @@ -165,7 +165,7 @@ equipment_model: @em, start_date: @start_date, due_date: @due_date, equipment_item: @em.equipment_items.first) - .save(validate: false) + .save(validate: false) expect(@cart.check_availability).not_to eq([]) expect(@cart.validate_all).not_to eq([]) diff --git a/spec/models/equipment_model_spec.rb b/spec/models/equipment_model_spec.rb index 637a3812f..115a21a06 100644 --- a/spec/models/equipment_model_spec.rb +++ b/spec/models/equipment_model_spec.rb @@ -168,39 +168,43 @@ end it 'only increments once per reservation' do @res.update_attributes(overdue: true) - expect { @res.update_attribute(:notes, 'test') }.not_to( - change { @model.overdue_count }) + expect { @res.update_attribute(:notes, 'test') }.not_to \ + change { @model.overdue_count } end it 'decrements when an overdue reservation is checked in' do @res.update_attributes(overdue: true) expect do @res.update_attributes( FactoryGirl.attributes_for(:overdue_returned_reservation, - equipment_model: @model)) + equipment_model: @model) + ) end.to change { @model.overdue_count }.from(1).to(0) end it 'only decrements once per reservation' do @res.update_attributes(overdue: true) @res.update_attributes( FactoryGirl.attributes_for(:overdue_returned_reservation, - equipment_model: @model)) + equipment_model: @model) + ) expect { @res.update_attribute(:notes, 'test') } .not_to change { @model.overdue_count } end it "doesn't change when a normal reservation is checked in" do @res.update_attributes( FactoryGirl.attributes_for(:checked_out_reservation, - equipment_model: @model)) + equipment_model: @model) + ) expect do @res.update_attributes( FactoryGirl.attributes_for(:checked_in_reservation, - equipment_model: @model)) + equipment_model: @model) + ) end.not_to change { @model.overdue_count } end it 'decrements when a reservation is extended' do @res.update_attributes(overdue: true) - expect { @res.update_attribute(:due_date, Time.zone.today + 1.day) }.to( - change { @model.overdue_count }.from(1).to(0)) + expect { @res.update_attribute(:due_date, Time.zone.today + 1.day) }.to \ + change { @model.overdue_count }.from(1).to(0) end end @@ -213,14 +217,16 @@ name: 'Tumblr hipster woodstock PBR messenger bag', description: "You probably haven't heard of them jean shorts. "\ "Raw denim you probably haven't heard of them vegan 8-bit "\ - 'occupy mustache four loko.') + 'occupy mustache four loko.' + ) @another_model = FactoryGirl.create( :equipment_model, name: 'Tumblr hipster starbucks alternative music', description: 'Craft beer sartorial four loko blog jean shorts '\ 'chillwave aesthetic. Roof party art party banh mi '\ - 'aesthetic, ennui Marfa kitsch readymade vegan food truck bag.') + 'aesthetic, ennui Marfa kitsch readymade vegan food truck bag.' + ) end it 'Should return equipment_models with all of the query words in '\ 'either name or description' do @@ -339,9 +345,9 @@ context 'methods involving reservations' do # @model and @category are already set. - ACTIVE = [:valid_reservation, :checked_out_reservation] + ACTIVE = [:valid_reservation, :checked_out_reservation].freeze INACTIVE = [:checked_in_reservation, :overdue_returned_reservation, - :missed_reservation, :request] + :missed_reservation, :request].freeze describe '.num_available' do shared_examples 'overlapping' do |start_offset, due_offset| it 'is correct' do diff --git a/spec/models/message_spec.rb b/spec/models/message_spec.rb index 9e1142572..ecc35aa7d 100644 --- a/spec/models/message_spec.rb +++ b/spec/models/message_spec.rb @@ -8,7 +8,7 @@ it { is_expected.to validate_presence_of(:body) } it do is_expected.not_to\ - allow_value('abc', '!s@abc.com', 'a@!d.com', 'a@a.c0m').for(:email) + allow_value('abc', '!s@abc.com', 'a@!d.com').for(:email) end it do is_expected.to\ diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb index 38f767df5..d3731f28a 100644 --- a/spec/models/report_spec.rb +++ b/spec/models/report_spec.rb @@ -37,19 +37,19 @@ describe '.average2' do it 'returns N/A for arrays of size 0' do - expect(Report.average2 []).to eq('N/A') + expect(Report.average2([])).to eq('N/A') end it 'returns N/A for arrays consisting of nil' do - expect(Report.average2 [nil, nil]).to eq('N/A') + expect(Report.average2([nil, nil])).to eq('N/A') end it 'calculates averages correctly' do - expect(Report.average2 [1, 2, 3]).to eq(2) + expect(Report.average2([1, 2, 3])).to eq(2) end it 'throws out nils' do - expect(Report.average2 [1, 2, 3, nil]).to eq(2) + expect(Report.average2([1, 2, 3, nil])).to eq(2) end it 'rounds to 2 decimal places' do - expect(Report.average2 [0.12, 1.799, 4.3]).to eq(2.07) + expect(Report.average2([0.12, 1.799, 4.3])).to eq(2.07) end end @@ -72,7 +72,7 @@ ['Overdue', :overdue, :count], ['Returned On Time', :returned_on_time, :count], ['Returned Overdue', :returned_overdue, :count], - ['User Count', :all, :count, :reserver_id]] + ['User Count', :all, :count, :reserver_id]].freeze before(:each) do @id = :equipment_item_id @class = EquipmentItem @@ -113,7 +113,7 @@ it 'has the correctly headed rows' do items = @class.all items.each do |item| - expect(@report.rows).to include?(Report::Row.item_to_row item) + expect(@report.rows).to include?(Report::Row.item_to_row(item)) end end end diff --git a/spec/models/reservation_spec.rb b/spec/models/reservation_spec.rb index a0aa4da87..5c3456cef 100644 --- a/spec/models/reservation_spec.rb +++ b/spec/models/reservation_spec.rb @@ -31,12 +31,12 @@ it 'counts the number that overlap with a given day' do @source.last.assign_attributes(start_date: Time.zone.today + 2, due_date: Time.zone.today + 3) - expect(Reservation.number_for(@source, date: Time.zone.today + 2.days) - ).to eq(1) + expect(Reservation.number_for(@source, date: Time.zone.today + 2.days)) + .to eq(1) end it 'can count only not overdue reservations' do - @source.last.attributes = FactoryGirl.attributes_for( - :overdue_reservation) + @source.last.attributes = + FactoryGirl.attributes_for(:overdue_reservation) @source.first.start_date = @source.last.start_date expect(Reservation.number_for(@source, date: @source.last.start_date + 1, overdue: false)).to eq(1) @@ -47,8 +47,8 @@ expect(Reservation.number_for(@source, equipment_model_id: 1)).to eq(1) end it 'can count not overdue reservations on a model' do - @source.last.attributes = FactoryGirl.attributes_for( - :overdue_reservation, equipment_model_id: 1) + @source.last.attributes = + FactoryGirl.attributes_for(:overdue_reservation, equipment_model_id: 1) @source.first.attributes = { start_date: @source.last.start_date, equipment_model_id: 1 } expect(Reservation.number_for(@source, @@ -613,13 +613,15 @@ end it 'the status should not be able to be changed if missed' do reservation.update_attributes( - FactoryGirl.attributes_for(:missed_reservation)) + FactoryGirl.attributes_for(:missed_reservation) + ) reservation.status = 'reserved' expect { reservation.save! }.to raise_error ActiveRecord::RecordInvalid end it 'the status should not be able to be changed if returned' do reservation.update_attributes( - FactoryGirl.attributes_for(:checked_in_reservation)) + FactoryGirl.attributes_for(:checked_in_reservation) + ) reservation.status = 'reserved' expect { reservation.save! }.to raise_error ActiveRecord::RecordInvalid end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a8a9a9c77..20439a091 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -22,11 +22,11 @@ it { is_expected.to validate_presence_of(:affiliation) } it { is_expected.to validate_presence_of(:email) } it do - is_expected.not_to\ - allow_value('abc', '!s@abc.com', 'a@!d.com', 'a@a.c0m').for(:email) + is_expected.not_to \ + allow_value('abc', '!s@abc.com', 'a@!d.com').for(:email) end it do - is_expected.to\ + is_expected.to \ allow_value('example@example.com', '1a@a.edu', 'a@2a.net').for(:email) end diff --git a/spec/support/capybara_form_helper.rb b/spec/support/capybara_form_helper.rb index 627e4766b..8701b03be 100644 --- a/spec/support/capybara_form_helper.rb +++ b/spec/support/capybara_form_helper.rb @@ -4,7 +4,7 @@ module Capybara module Driver class Node def submit_form! - fail NotImplementedError + raise NotImplementedError end end end diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index c92a06321..035cd4c5b 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -37,14 +37,15 @@ def fill_in_login(user = @user) def update_cart_start_date(new_date_str) # fill in both visible / datepicker and hidden field fill_in 'cart_start_date_cart', with: new_date_str - find(:xpath, "//input[@id='date_start_alt']").set new_date_str + find(:xpath, "//input[@id='date_start_alt']", visible: :all) + .set new_date_str find('#cart_form').submit_form! end def update_cart_due_date(new_date_str) # fill in both visible / datepicker and hidden field fill_in 'cart_due_date_cart', with: new_date_str - find(:xpath, "//input[@id='date_end_alt']").set new_date_str + find(:xpath, "//input[@id='date_end_alt']", visible: :all).set new_date_str find('#cart_form').submit_form! end