From 96ae4d35404f12824dba363625e0614bb89b4c64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:08:49 +0000 Subject: [PATCH 1/4] Bump webpack-dev-server from 4.15.1 to 4.15.2 Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.15.1 to 4.15.2. - [Release notes](https://github.com/webpack/webpack-dev-server/releases) - [Changelog](https://github.com/webpack/webpack-dev-server/blob/v4.15.2/CHANGELOG.md) - [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.15.1...v4.15.2) --- updated-dependencies: - dependency-name: webpack-dev-server dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 7178c65a..85d90fdd 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,6 @@ "popper.js": "^1.16.1" }, "devDependencies": { - "webpack-dev-server": "^4.15.1" + "webpack-dev-server": "^4.15.2" } } diff --git a/yarn.lock b/yarn.lock index 99ef9f2f..dcfeb498 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7082,7 +7082,7 @@ webpack-cli@^3.3.12: v8-compile-cache "^2.1.1" yargs "^13.3.2" -webpack-dev-middleware@^5.3.1: +webpack-dev-middleware@^5.3.4: version "5.3.4" resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz#eb7b39281cbce10e104eb2b8bf2b63fce49a3517" integrity sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q== @@ -7093,10 +7093,10 @@ webpack-dev-middleware@^5.3.1: range-parser "^1.2.1" schema-utils "^4.0.0" -webpack-dev-server@^4.15.1: - version "4.15.1" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.15.1.tgz#8944b29c12760b3a45bdaa70799b17cb91b03df7" - integrity sha512-5hbAst3h3C3L8w6W4P96L5vaV0PxSmJhxZvWKYIdgxOQm8pNZ5dEOmmSLBVpP85ReeyRt6AS1QJNyo/oFFPeVA== +webpack-dev-server@^4.15.2: + version "4.15.2" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.15.2.tgz#9e0c70a42a012560860adb186986da1248333173" + integrity sha512-0XavAZbNJ5sDrCbkpWL8mia0o5WPOd2YGtxrEiZkBK9FjLppIUK2TgxK6qGD2P3hUXTJNNPVibrerKcx5WkR1g== dependencies: "@types/bonjour" "^3.5.9" "@types/connect-history-api-fallback" "^1.3.5" @@ -7126,7 +7126,7 @@ webpack-dev-server@^4.15.1: serve-index "^1.9.1" sockjs "^0.3.24" spdy "^4.0.2" - webpack-dev-middleware "^5.3.1" + webpack-dev-middleware "^5.3.4" ws "^8.13.0" webpack-sources@^1.0.0, webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3: From 92236045f97561248e311c4d4822232cbe98be8e Mon Sep 17 00:00:00 2001 From: Shane Murnaghan <1930474+murny@users.noreply.github.com> Date: Wed, 29 May 2024 19:50:31 -0600 Subject: [PATCH 2/4] Add rubocop-rails-omakase, autofix violations and turn on CI job --- .github/workflows/ci.yml | 24 +-- .rubocop.yml | 3 + Gemfile | 46 ++-- Gemfile.lock | 51 ++++- app/controllers/profiles_controller.rb | 200 +++++++++--------- app/mailers/application_mailer.rb | 4 +- app/models/profile.rb | 24 +-- bin/bundle | 110 +++++++++- bin/rubocop | 27 +++ config/application.rb | 6 +- config/environments/staging.rb | 4 +- config/initializers/friendly_id.rb | 6 +- config/initializers/rollbar.rb | 4 +- config/initializers/wrap_parameters.rb | 2 +- config/routes.rb | 8 +- db/migrate/20181101154531_create_cms.rb | 36 ++-- ...20181101154602_create_friendly_id_slugs.rb | 10 +- db/migrate/20181101154627_create_profiles.rb | 36 ++-- .../20181101154832_add_slug_to_profiles.rb | 2 +- test/application_system_test_case.rb | 2 +- test/integration/cms_test.rb | 4 +- test/test_helper.rb | 10 +- 22 files changed, 399 insertions(+), 220 deletions(-) create mode 100644 .rubocop.yml create mode 100755 bin/rubocop diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f0f4d62..59d69e0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,20 +6,20 @@ on: branches: [ main ] jobs: - # lint: - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 - # - name: Set up Ruby - # uses: ruby/setup-ruby@v1 - # with: - # ruby-version: .ruby-version - # bundler-cache: true + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: .ruby-version + bundler-cache: true - # - name: Lint code for consistent style - # run: bin/rubocop -f github + - name: Lint code for consistent style + run: bin/rubocop -f github test: runs-on: ubuntu-latest diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..d9125f47 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,3 @@ +# Omakase Ruby styling for Rails +inherit_gem: + rubocop-rails-omakase: rubocop.yml diff --git a/Gemfile b/Gemfile index 6cee0f80..aa9451df 100644 --- a/Gemfile +++ b/Gemfile @@ -1,59 +1,61 @@ -source 'https://rubygems.org' +source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '3.1.4' +ruby "3.1.4" -gem 'rails', '~> 7.1.3' +gem "rails", "~> 7.1.3" -gem 'mysql2', '~> 0.5.6' +gem "mysql2", "~> 0.5.6" # Use Puma as the app server -gem 'puma', '~> 6.4' +gem "puma", "~> 6.4" # Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' +gem "uglifier", ">= 1.3.0" -gem 'rollbar' +gem "rollbar" # See https://github.com/rails/execjs#readme for more supported runtimes -gem 'execjs' +gem "execjs" # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 2.12' +gem "jbuilder", "~> 2.12" # Use ActiveStorage variant -gem 'image_processing', '~> 1.12', '>= 1.12.2' +gem "image_processing", "~> 1.12", ">= 1.12.2" -gem 'comfortable_mexican_sofa', github: 'restarone/comfortable-mexican-sofa', tag: '3.5' +gem "comfortable_mexican_sofa", github: "restarone/comfortable-mexican-sofa", tag: "3.5" -gem 'friendly_id' +gem "friendly_id" -gem 'htmlentities' +gem "htmlentities" # Reduces boot times through caching; required in config/boot.rb -gem 'bootsnap', '>= 1.4.2', require: false +gem "bootsnap", ">= 1.4.2", require: false -gem 'webpacker', '~> 5.4' +gem "webpacker", "~> 5.4" gem "rdoc", ">= 6.6.3.1" group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] + gem "byebug", platforms: [ :mri, :mingw, :x64_mingw ] end group :development do + gem "rubocop-rails-omakase", require: false + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. - gem 'web-console', '>= 3.3.0' + gem "web-console", ">= 3.3.0" - gem 'listen', '>= 3.0.5', '< 3.10' + gem "listen", ">= 3.0.5", "< 3.10" # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring', '>= 3.0' + gem "spring", ">= 3.0" end group :test do # Adds support for Capybara system testing and selenium driver - gem 'capybara', '>= 2.15' - gem 'selenium-webdriver' + gem "capybara", ">= 2.15" + gem "selenium-webdriver" end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem "tzinfo-data", platforms: [ :mingw, :mswin, :x64_mingw, :jruby ] diff --git a/Gemfile.lock b/Gemfile.lock index 9db1b85e..aa04ee29 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,6 +98,7 @@ GEM tzinfo (~> 2.0) addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) + ast (2.4.2) base64 (0.2.0) bigdecimal (3.1.8) bindex (0.8.1) @@ -154,8 +155,10 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + json (2.7.2) kramdown (2.4.0) rexml + language_server-protocol (3.17.0.3) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -174,7 +177,6 @@ GEM rake mini_magick (4.12.0) mini_mime (1.1.5) - mini_portile2 (2.8.7) minitest (5.23.1) msgpack (1.7.2) mutex_m (0.2.0) @@ -189,9 +191,12 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) - nokogiri (1.16.5) - mini_portile2 (~> 2.8.2) + nokogiri (1.16.5-x86_64-darwin) racc (~> 1.4) + parallel (1.24.0) + parser (3.3.1.0) + ast (~> 2.4.1) + racc psych (5.1.2) stringio public_suffix (5.0.4) @@ -240,6 +245,7 @@ GEM rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) + rainbow (3.1.1) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.10.1) @@ -252,6 +258,36 @@ GEM rexml (3.2.8) strscan (>= 3.0.9) rollbar (3.5.2) + rubocop (1.64.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-minitest (0.35.0) + rubocop (>= 1.61, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-performance (1.21.0) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.25.0) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.33.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails-omakase (1.0.0) + rubocop + rubocop-minitest + rubocop-performance + rubocop-rails + ruby-progressbar (1.13.0) ruby-vips (2.1.4) ffi (~> 1.12) rubyzip (2.3.2) @@ -287,6 +323,7 @@ GEM concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) + unicode-display_width (2.5.0) web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) @@ -307,7 +344,12 @@ GEM zeitwerk (2.6.15) PLATFORMS - ruby + aarch64-linux + arm-linux + arm64-darwin + x86-linux + x86_64-darwin + x86_64-linux DEPENDENCIES bootsnap (>= 1.4.2) @@ -325,6 +367,7 @@ DEPENDENCIES rails (~> 7.1.3) rdoc (>= 6.6.3.1) rollbar + rubocop-rails-omakase selenium-webdriver spring (>= 3.0) tzinfo-data diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index cf42dc71..50d26768 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -1,113 +1,113 @@ class ProfilesController < ApplicationController - $units = {:access => "Access Services", - :archives => "Archives", - :bib => "Cataloguing Strategies", - :collections => "Collection Strategies", - :copyright => "Copyright", - :digital => "Digital Production & Preservation Services", - :digrepo => "Digital Repository & Data Services", - :dsc => "Digital Scholarship Centre", - :facilities => "Facilities", - :health => "Faculty Engagement (Health Sciences)", - :science => "Faculty Engagement (Natural + Applied Sciences)", - :humanities => "Faculty Engagement (Social Sciences + Humanities)", - :iss => "Information Services & User Engagement", - :admin => "Library Administration", - :lad => "Library Application Development", - :las => "Library Application Support", - :metadata => "Metadata Strategies", - :open => "Open Publishing & Digitization Services", - :rdm => "Research Data Management", - :researchimpact => "Research Impact", - :its => "Specialized Technical Support", - :special => "Special Collections", - :stratigic => "Strategic Partnerships", - :tl => "Teaching & Learning", - :ux => "User Experience"} - $buildings = {:augustana => "Augustana Campus Library", - :bsj => "Bibliothèque Saint-Jean", - :bpsc=> "Bruce Peel Special Collections", - :cameron => "Cameron Library", - :sperber => "Sperber Library", - :rcrf => "Research & Collections Resource Facility", - :rutherford => "Rutherford Library", - :stjosephs => "St. Joseph's Library" } + $units = { access: "Access Services", + archives: "Archives", + bib: "Cataloguing Strategies", + collections: "Collection Strategies", + copyright: "Copyright", + digital: "Digital Production & Preservation Services", + digrepo: "Digital Repository & Data Services", + dsc: "Digital Scholarship Centre", + facilities: "Facilities", + health: "Faculty Engagement (Health Sciences)", + science: "Faculty Engagement (Natural + Applied Sciences)", + humanities: "Faculty Engagement (Social Sciences + Humanities)", + iss: "Information Services & User Engagement", + admin: "Library Administration", + lad: "Library Application Development", + las: "Library Application Support", + metadata: "Metadata Strategies", + open: "Open Publishing & Digitization Services", + rdm: "Research Data Management", + researchimpact: "Research Impact", + its: "Specialized Technical Support", + special: "Special Collections", + stratigic: "Strategic Partnerships", + tl: "Teaching & Learning", + ux: "User Experience" } + $buildings = { augustana: "Augustana Campus Library", + bsj: "Bibliothèque Saint-Jean", + bpsc: "Bruce Peel Special Collections", + cameron: "Cameron Library", + sperber: "Sperber Library", + rcrf: "Research & Collections Resource Facility", + rutherford: "Rutherford Library", + stjosephs: "St. Joseph's Library" } - # You'll have to define "cmsPassword" in secrets.yml, or this will fail. Thanks, ansible. - http_basic_authenticate_with name: Rails.application.secrets.cms_user, password: Rails.application.secrets.cms_password, except: [:index, :show] + # You'll have to define "cmsPassword" in secrets.yml, or this will fail. Thanks, ansible. + http_basic_authenticate_with name: Rails.application.secrets.cms_user, password: Rails.application.secrets.cms_password, except: [ :index, :show ] - def index - path = request.url - if path.include? "unit" - @unit = params[:unit] - @unitname = $units[params[:unit].to_sym] - @allunit = Profile.where(unit: @unit) - @heads = @allunit.where(opt_in: true).order(:last_name) - @staff = @allunit.where(opt_in: nil).order(:last_name) - @profiles = @heads + @staff - elsif path.include? "building" - @building = params[:building] - @buildingname = $buildings[params[:building].to_sym] - @profiles = Profile.where("campus_address=?", params[:building]).order(:first_name) - else - @profiles = Profile.all.order(:first_name) - end - respond_to do |format| - format.html - format.csv { send_data @profiles.to_csv } - end - end - - def show - @profile = Profile.friendly.find(params[:id]) - end + def index + path = request.url + if path.include? "unit" + @unit = params[:unit] + @unitname = $units[params[:unit].to_sym] + @allunit = Profile.where(unit: @unit) + @heads = @allunit.where(opt_in: true).order(:last_name) + @staff = @allunit.where(opt_in: nil).order(:last_name) + @profiles = @heads + @staff + elsif path.include? "building" + @building = params[:building] + @buildingname = $buildings[params[:building].to_sym] + @profiles = Profile.where("campus_address=?", params[:building]).order(:first_name) + else + @profiles = Profile.all.order(:first_name) + end + respond_to do |format| + format.html + format.csv { send_data @profiles.to_csv } + end + end + def show + @profile = Profile.friendly.find(params[:id]) + end - def new - @profile = Profile.new - @buildings = $buildings - @units = $units - end - def edit - @profile = Profile.friendly.find(params[:id]) - @buildings = $buildings - @units = $units - end + def new + @profile = Profile.new + @buildings = $buildings + @units = $units + end - def create - @profile = Profile.new(profile_params) - @profile.save - redirect_to @profile - end + def edit + @profile = Profile.friendly.find(params[:id]) + @buildings = $buildings + @units = $units + end - def update - @profile = Profile.friendly.find(params[:id]) - - if @profile.update(profile_params) - redirect_to @profile - else - render 'edit' - end - end + def create + @profile = Profile.new(profile_params) + @profile.save + redirect_to @profile + end - def destroy - @profile = Profile.friendly.find(params[:id]) - @profile.destroy - - redirect_to profiles_path - end + def update + @profile = Profile.friendly.find(params[:id]) - def units - @unit = params[:id] - @unitname = $units[params[:id].to_sym] - @profiles = Profile.where("unit=?", params[:id]) - end + if @profile.update(profile_params) + redirect_to @profile + else + render "edit" + end + end + def destroy + @profile = Profile.friendly.find(params[:id]) + @profile.destroy - private - - def profile_params - params.require(:profile).permit(:first_name,:last_name, :job_title, :unit, :email, :phone, :campus_address, :expertise, :introduction, :publications, :staff_since, :liason, :links, :orcid, :committees, :personal_interests, :opt_in) - end + redirect_to profiles_path + end + + def units + @unit = params[:id] + @unitname = $units[params[:id].to_sym] + @profiles = Profile.where("unit=?", params[:id]) + end + + + private + + def profile_params + params.require(:profile).permit(:first_name, :last_name, :job_title, :unit, :email, :phone, :campus_address, :expertise, :introduction, :publications, :staff_since, :liason, :links, :orcid, :committees, :personal_interests, :opt_in) + end end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b2239..3c34c814 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' + default from: "from@example.com" + layout "mailer" end diff --git a/app/models/profile.rb b/app/models/profile.rb index 16efff46..e6037ee8 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -1,16 +1,16 @@ class Profile < ActiveRecord::Base - extend FriendlyId - friendly_id :full_name, use: :slugged - def full_name - "#{first_name}-#{last_name}" - end + extend FriendlyId + friendly_id :full_name, use: :slugged + def full_name + "#{first_name}-#{last_name}" + end - def self.to_csv(options = {}) - CSV.generate(options) do |csv| - csv << column_names - all.each do |product| - csv << product.attributes.values_at(*column_names) - end - end + def self.to_csv(options = {}) + CSV.generate(options) do |csv| + csv << column_names + all.each do |product| + csv << product.attributes.values_at(*column_names) + end + end end end diff --git a/bin/bundle b/bin/bundle index f19acf5b..42c7fd7c 100755 --- a/bin/bundle +++ b/bin/bundle @@ -1,3 +1,109 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) -load Gem.bin_path('bundler', 'bundle') +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'bundle' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "rubygems" + +m = Module.new do + module_function + + def invoked_as_script? + File.expand_path($0) == File.expand_path(__FILE__) + end + + def env_var_version + ENV["BUNDLER_VERSION"] + end + + def cli_arg_version + return unless invoked_as_script? # don't want to hijack other binstubs + return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + bundler_version = nil + update_index = nil + ARGV.each_with_index do |a, i| + if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN + bundler_version = a + end + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + bundler_version = $1 + update_index = i + end + bundler_version + end + + def gemfile + gemfile = ENV["BUNDLE_GEMFILE"] + return gemfile if gemfile && !gemfile.empty? + + File.expand_path("../Gemfile", __dir__) + end + + def lockfile + lockfile = + case File.basename(gemfile) + when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") + else "#{gemfile}.lock" + end + File.expand_path(lockfile) + end + + def lockfile_version + return unless File.file?(lockfile) + lockfile_contents = File.read(lockfile) + return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + Regexp.last_match(1) + end + + def bundler_requirement + @bundler_requirement ||= + env_var_version || + cli_arg_version || + bundler_requirement_for(lockfile_version) + end + + def bundler_requirement_for(version) + return "#{Gem::Requirement.default}.a" unless version + + bundler_gem_version = Gem::Version.new(version) + + bundler_gem_version.approximate_recommendation + end + + def load_bundler! + ENV["BUNDLE_GEMFILE"] ||= gemfile + + activate_bundler + end + + def activate_bundler + gem_error = activation_error_handling do + gem "bundler", bundler_requirement + end + return if gem_error.nil? + require_error = activation_error_handling do + require "bundler/version" + end + return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" + exit 42 + end + + def activation_error_handling + yield + nil + rescue StandardError, LoadError => e + e + end +end + +m.load_bundler! + +if m.invoked_as_script? + load Gem.bin_path("bundler", "bundle") +end diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 00000000..369a05be --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rubocop' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rubocop", "rubocop") diff --git a/config/application.rb b/config/application.rb index f6b7ffda..dc710c77 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,6 +1,6 @@ -require_relative 'boot' +require_relative "boot" -require 'rails/all' +require "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -14,7 +14,7 @@ class Application < Rails::Application # Configuration for the application, engines, and railties goes here. # Ensuring that ActiveStorage routes are loaded before Comfy's globbing # route. Without this file serving routes are inaccessible. - config.railties_order = [ActiveStorage::Engine, :main_app, :all] + config.railties_order = [ ActiveStorage::Engine, :main_app, :all ] config.exceptions_app = self.routes # These settings can be overridden in specific environments using the files diff --git a/config/environments/staging.rb b/config/environments/staging.rb index c6c7b755..3c8a5933 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -20,7 +20,7 @@ # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # Compress JavaScripts and CSS. config.assets.js_compressor = Uglifier.new(harmony: true) @@ -91,4 +91,4 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false -end \ No newline at end of file +end diff --git a/config/initializers/friendly_id.rb b/config/initializers/friendly_id.rb index b6239e79..988b6d8f 100644 --- a/config/initializers/friendly_id.rb +++ b/config/initializers/friendly_id.rb @@ -16,9 +16,9 @@ # undesirable to allow as slugs. Edit this list as needed for your app. config.use :reserved - config.reserved_words = %w(new edit index session login logout users admin - stylesheets assets javascripts images) - + config.reserved_words = %w[new edit index session login logout users admin + stylesheets assets javascripts images] + # This adds an option to to treat reserved words as conflicts rather than exceptions. # When there is no good candidate, a UUID will be appended, matching the existing # conflict behavior. diff --git a/config/initializers/rollbar.rb b/config/initializers/rollbar.rb index 07c0d7cc..6fa548c5 100644 --- a/config/initializers/rollbar.rb +++ b/config/initializers/rollbar.rb @@ -32,7 +32,7 @@ # config.exception_level_filters.merge!('MyCriticalException' => 'critical') # config.exception_level_filters.merge!({ - 'ActionController::RoutingError' => 'ignore' + "ActionController::RoutingError" => "ignore" }) # You can also specify a callable, which will be called with the exception instance. @@ -71,5 +71,5 @@ # environment variable like this: `ROLLBAR_ENV=staging`. This is a recommended # setup for Heroku. See: # https://devcenter.heroku.com/articles/deploying-to-a-custom-rails-environment - config.environment = ENV['ROLLBAR_ENV'].presence || Rails.env + config.environment = ENV["ROLLBAR_ENV"].presence || Rails.env end diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index bbfc3961..6d55fe75 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -5,7 +5,7 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] + wrap_parameters format: [ :json ] end # To enable root element in JSON for ActiveRecord objects. diff --git a/config/routes.rb b/config/routes.rb index 74b3f210..d7bb3453 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,10 +1,10 @@ Rails.application.routes.draw do - resources :staff, :as => :profiles, :controller => :profiles + resources :staff, as: :profiles, controller: :profiles comfy_route :cms_admin, path: "/admin" - match '/404', to: 'errors#file_not_found', via: :all - match '/422', to: 'errors#unprocessable', via: :all - match '/500', to: 'errors#internal_server_error', via: :all + match "/404", to: "errors#file_not_found", via: :all + match "/422", to: "errors#unprocessable", via: :all + match "/500", to: "errors#internal_server_error", via: :all # Ensure that this route is defined last comfy_route :cms, path: "/" end diff --git a/db/migrate/20181101154531_create_cms.rb b/db/migrate/20181101154531_create_cms.rb index 8369f9ca..a0434da2 100644 --- a/db/migrate/20181101154531_create_cms.rb +++ b/db/migrate/20181101154531_create_cms.rb @@ -1,9 +1,7 @@ class CreateCms < ActiveRecord::Migration[5.2] - LIMIT = 16777215 def change - # -- Sites ----------------------------------------------------------------- create_table :comfy_cms_sites, force: true do |t| t.string :label, null: false @@ -29,8 +27,8 @@ def change t.integer :position, null: false, default: 0 t.timestamps - t.index [:parent_id, :position] - t.index [:site_id, :identifier], unique: true + t.index [ :parent_id, :position ] + t.index [ :site_id, :identifier ], unique: true end # -- Pages ----------------------------------------------------------------- @@ -48,9 +46,9 @@ def change t.boolean :is_published, null: false, default: true t.timestamps - t.index [:site_id, :full_path] - t.index [:parent_id, :position] - t.index [:is_published] + t.index [ :site_id, :full_path ] + t.index [ :parent_id, :position ] + t.index [ :is_published ] end # -- Translations ---------------------------------------------------------- @@ -63,9 +61,9 @@ def change t.boolean :is_published, null: false, default: true t.timestamps - t.index [:page_id] - t.index [:locale] - t.index [:is_published] + t.index [ :page_id ] + t.index [ :locale ] + t.index [ :is_published ] end # -- Fragments ------------------------------------------------------------- @@ -78,9 +76,9 @@ def change t.datetime :datetime t.timestamps - t.index [:identifier] - t.index [:datetime] - t.index [:boolean] + t.index [ :identifier ] + t.index [ :datetime ] + t.index [ :boolean ] end # -- Snippets -------------------------------------------------------------- @@ -92,8 +90,8 @@ def change t.integer :position, null: false, default: 0 t.timestamps - t.index [:site_id, :identifier], unique: true - t.index [:site_id, :position] + t.index [ :site_id, :identifier ], unique: true + t.index [ :site_id, :position ] end # -- Files ----------------------------------------------------------------- @@ -104,7 +102,7 @@ def change t.integer :position, null: false, default: 0 t.timestamps - t.index [:site_id, :position] + t.index [ :site_id, :position ] end # -- Revisions ------------------------------------------------------------- @@ -114,7 +112,7 @@ def change t.text :data, limit: LIMIT t.datetime :created_at - t.index [:record_type, :record_id, :created_at], + t.index [ :record_type, :record_id, :created_at ], name: "index_cms_revisions_on_rtype_and_rid_and_created_at" end @@ -124,7 +122,7 @@ def change t.string :label, null: false t.string :categorized_type, null: false - t.index [:site_id, :categorized_type, :label], + t.index [ :site_id, :categorized_type, :label ], unique: true, name: "index_cms_categories_on_site_id_and_cat_type_and_label" end @@ -134,7 +132,7 @@ def change t.string :categorized_type, null: false t.integer :categorized_id, null: false - t.index [:category_id, :categorized_type, :categorized_id], + t.index [ :category_id, :categorized_type, :categorized_id ], unique: true, name: "index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id" end diff --git a/db/migrate/20181101154602_create_friendly_id_slugs.rb b/db/migrate/20181101154602_create_friendly_id_slugs.rb index 691514af..9d51b6de 100644 --- a/db/migrate/20181101154602_create_friendly_id_slugs.rb +++ b/db/migrate/20181101154602_create_friendly_id_slugs.rb @@ -8,15 +8,15 @@ class CreateFriendlyIdSlugs < migration_class def change create_table :friendly_id_slugs do |t| - t.string :slug, :null => false - t.integer :sluggable_id, :null => false - t.string :sluggable_type, :limit => 50 + t.string :slug, null: false + t.integer :sluggable_id, null: false + t.string :sluggable_type, limit: 50 t.string :scope t.datetime :created_at end add_index :friendly_id_slugs, :sluggable_id - add_index :friendly_id_slugs, [:slug, :sluggable_type], length: { slug: 140, sluggable_type: 50 } - add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], length: { slug: 70, sluggable_type: 50, scope: 70 }, unique: true + add_index :friendly_id_slugs, [ :slug, :sluggable_type ], length: { slug: 140, sluggable_type: 50 } + add_index :friendly_id_slugs, [ :slug, :sluggable_type, :scope ], length: { slug: 70, sluggable_type: 50, scope: 70 }, unique: true add_index :friendly_id_slugs, :sluggable_type end end diff --git a/db/migrate/20181101154627_create_profiles.rb b/db/migrate/20181101154627_create_profiles.rb index cbb8422c..77038f52 100644 --- a/db/migrate/20181101154627_create_profiles.rb +++ b/db/migrate/20181101154627_create_profiles.rb @@ -1,24 +1,24 @@ class CreateProfiles < ActiveRecord::Migration[5.2] def change create_table :profiles do |t| - t.string :first_name - t.string :last_name - t.string :job_title - t.string :unit - t.string :email - t.string :phone - t.string :campus_address - t.string :expertise - t.text :introduction - t.text :publications - t.integer :staff_since - t.string :links - t.string :orcid - t.string :committees - t.text :personal_interests - t.boolean :opt_in - t.string :liason - t.timestamps null: false + t.string :first_name + t.string :last_name + t.string :job_title + t.string :unit + t.string :email + t.string :phone + t.string :campus_address + t.string :expertise + t.text :introduction + t.text :publications + t.integer :staff_since + t.string :links + t.string :orcid + t.string :committees + t.text :personal_interests + t.boolean :opt_in + t.string :liason + t.timestamps null: false end end end diff --git a/db/migrate/20181101154832_add_slug_to_profiles.rb b/db/migrate/20181101154832_add_slug_to_profiles.rb index e8059f48..e7669d34 100644 --- a/db/migrate/20181101154832_add_slug_to_profiles.rb +++ b/db/migrate/20181101154832_add_slug_to_profiles.rb @@ -1,6 +1,6 @@ class AddSlugToProfiles < ActiveRecord::Migration[5.2] def change - add_column :profiles, :slug, :string + add_column :profiles, :slug, :string add_index :profiles, :slug end end diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index d19212ab..d7e6bba8 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,5 +1,5 @@ require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :chrome, screen_size: [1400, 1400] + driven_by :selenium, using: :chrome, screen_size: [ 1400, 1400 ] end diff --git a/test/integration/cms_test.rb b/test/integration/cms_test.rb index 028e1f85..5498841c 100644 --- a/test/integration/cms_test.rb +++ b/test/integration/cms_test.rb @@ -11,14 +11,14 @@ class CmsTest < ActionDispatch::IntegrationTest end test "hours and locations page" do - get comfy_cms_render_page_path(cms_path: 'hours-locations') + get comfy_cms_render_page_path(cms_path: "hours-locations") assert_response :success assert_select "h1", /Hours & Locations/ end test "about us page" do - get comfy_cms_render_page_path(cms_path: 'about-us') + get comfy_cms_render_page_path(cms_path: "about-us") assert_response :success assert_select "h1", /About Us/ diff --git a/test/test_helper.rb b/test/test_helper.rb index 490d5e14..c18d075f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,13 +1,13 @@ -ENV['RAILS_ENV'] ||= 'test' -require_relative '../config/environment' -require 'rails/test_help' +ENV["RAILS_ENV"] ||= "test" +require_relative "../config/environment" +require "rails/test_help" # Seed the database with our CMS seed data, if it's not already there if Rake::Task.tasks.empty? && Comfy::Cms::Site.count.zero? HomeCms::Application.load_tasks - Comfy::Cms::Site.create!(identifier: 'ualberta-libraries', hostname: 'localhost') - Rake::Task['comfy:cms_seeds:import'].invoke('library-cms-seeds', 'ualberta-libraries') + Comfy::Cms::Site.create!(identifier: "ualberta-libraries", hostname: "localhost") + Rake::Task["comfy:cms_seeds:import"].invoke("library-cms-seeds", "ualberta-libraries") end class ActiveSupport::TestCase From 1f16575a024f28a06197e83fb96649c6520ee138 Mon Sep 17 00:00:00 2001 From: Shane Murnaghan <1930474+murny@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:05:26 -0600 Subject: [PATCH 3/4] Switch to StandardRB rubocop linter --- .rubocop.yml | 46 +++++- Gemfile | 16 +- Gemfile.lock | 39 ++++- Rakefile | 4 +- app/channels/application_cable/channel.rb | 2 + app/channels/application_cable/connection.rb | 2 + app/controllers/application_controller.rb | 2 + app/controllers/errors_controller.rb | 2 + app/controllers/profiles_controller.rb | 112 +++++++------- app/helpers/application_helper.rb | 2 + app/jobs/application_job.rb | 2 + app/mailers/application_mailer.rb | 2 + app/models/application_record.rb | 2 + app/models/profile.rb | 16 +- config.ru | 4 +- config/application.rb | 6 +- config/boot.rb | 2 + config/environment.rb | 2 + config/environments/development.rb | 2 + config/environments/production.rb | 10 +- config/environments/staging.rb | 10 +- config/environments/test.rb | 4 +- .../application_controller_renderer.rb | 2 + config/initializers/assets.rb | 2 + config/initializers/backtrace_silencers.rb | 2 + .../initializers/content_security_policy.rb | 2 + config/initializers/cookies_serializer.rb | 2 + .../initializers/filter_parameter_logging.rb | 2 + config/initializers/friendly_id.rb | 2 + config/initializers/inflections.rb | 2 + config/initializers/mime_types.rb | 2 + config/initializers/permissions_policy.rb | 2 + config/initializers/rollbar.rb | 6 +- config/initializers/wrap_parameters.rb | 4 +- config/puma.rb | 4 +- config/routes.rb | 2 + config/spring.rb | 2 + db/migrate/20181101154531_create_cms.rb | 146 +++++++++--------- ...20181101154602_create_friendly_id_slugs.rb | 14 +- db/migrate/20181101154627_create_profiles.rb | 36 +++-- .../20181101154832_add_slug_to_profiles.rb | 2 + ...te_active_storage_tables.active_storage.rb | 24 +-- ..._to_active_storage_blobs.active_storage.rb | 4 +- ..._storage_variant_records.active_storage.rb | 23 +-- ...e_storage_blobs_checksum.active_storage.rb | 2 + db/seeds.rb | 6 +- test/application_system_test_case.rb | 4 +- test/test_helper.rb | 2 + 48 files changed, 376 insertions(+), 214 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d9125f47..c809198f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,45 @@ -# Omakase Ruby styling for Rails +require: + - rubocop-capybara + - rubocop-minitest + - rubocop-performance + - rubocop-rails + - standard + inherit_gem: - rubocop-rails-omakase: rubocop.yml + standard: config/base.yml + +AllCops: + SuggestExtensions: false + TargetRubyVersion: 3.3 + NewCops: enable + +Minitest/MultipleAssertions: + Max: 10 # default 3 + +Style/FrozenStringLiteralComment: + Enabled: true + +# These below cops are good practice going forward, but due to legacy we exclude some migrations +Rails/CreateTableWithTimestamps: + Exclude: + - db/migrate/20181101154531_create_cms.rb + - db/migrate/20220603215833_create_active_storage_variant_records.active_storage.rb + +Rails/SkipsModelValidations: + Exclude: + - db/migrate/20220603215832_add_service_name_to_active_storage_blobs.active_storage.rb + +Rails/BulkChangeTable: + Exclude: + - db/migrate/20181101154602_create_friendly_id_slugs.rb + - db/migrate/20181101154832_add_slug_to_profiles.rb + +Rails/ThreeStateBooleanColumn: + Exclude: + - db/migrate/20181101154627_create_profiles.rb + +# Below are cops that are currently disabled, where we should fix in the future +# TODO: Fix ProfilesController so we don't need to use global vars +Style/GlobalVars: + Exclude: + - app/controllers/profiles_controller.rb diff --git a/Gemfile b/Gemfile index aa9451df..e54f0b13 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } @@ -37,12 +39,18 @@ gem "rdoc", ">= 6.6.3.1" group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem "byebug", platforms: [ :mri, :mingw, :x64_mingw ] + gem "byebug", platforms: [:mri, :mingw, :x64_mingw] + + # Linters + gem "rubocop", require: false + gem "rubocop-capybara", require: false + gem "rubocop-minitest", require: false + gem "rubocop-performance", require: false + gem "rubocop-rails", require: false + gem "standard", ">= 1.35.1", require: false end group :development do - gem "rubocop-rails-omakase", require: false - # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem "web-console", ">= 3.3.0" @@ -58,4 +66,4 @@ group :test do end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: [ :mingw, :mswin, :x64_mingw, :jruby ] +gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index aa04ee29..5096dd51 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -159,6 +159,7 @@ GEM kramdown (2.4.0) rexml language_server-protocol (3.17.0.3) + lint_roller (1.1.0) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -191,8 +192,18 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) + nokogiri (1.16.5-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.5-arm-linux) + racc (~> 1.4) + nokogiri (1.16.5-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.5-x86-linux) + racc (~> 1.4) nokogiri (1.16.5-x86_64-darwin) racc (~> 1.4) + nokogiri (1.16.5-x86_64-linux) + racc (~> 1.4) parallel (1.24.0) parser (3.3.1.0) ast (~> 2.4.1) @@ -258,7 +269,7 @@ GEM rexml (3.2.8) strscan (>= 3.0.9) rollbar (3.5.2) - rubocop (1.64.0) + rubocop (1.63.5) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -271,6 +282,8 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.31.3) parser (>= 3.3.1.0) + rubocop-capybara (2.20.0) + rubocop (~> 1.41) rubocop-minitest (0.35.0) rubocop (>= 1.61, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) @@ -282,11 +295,6 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails-omakase (1.0.0) - rubocop - rubocop-minitest - rubocop-performance - rubocop-rails ruby-progressbar (1.13.0) ruby-vips (2.1.4) ffi (~> 1.12) @@ -313,6 +321,18 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + standard (1.36.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.63.0) + standard-custom (~> 1.0.0) + standard-performance (~> 1.4) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.4.0) + lint_roller (~> 1.1) + rubocop-performance (~> 1.21.0) stringio (3.1.0) strscan (3.1.0) temple (0.10.3) @@ -367,9 +387,14 @@ DEPENDENCIES rails (~> 7.1.3) rdoc (>= 6.6.3.1) rollbar - rubocop-rails-omakase + rubocop + rubocop-capybara + rubocop-minitest + rubocop-performance + rubocop-rails selenium-webdriver spring (>= 3.0) + standard (>= 1.35.1) tzinfo-data uglifier (>= 1.3.0) web-console (>= 3.3.0) diff --git a/Rakefile b/Rakefile index e85f9139..d2a78aa2 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,8 @@ +# frozen_string_literal: true + # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require_relative 'config/application' +require_relative "config/application" Rails.application.load_tasks diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index d6726972..9aec2305 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Channel < ActionCable::Channel::Base end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index 0ff5442f..8d6c2a1b 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Connection < ActionCable::Connection::Base end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d12..7944f9f9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::Base end diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 19f649b9..7c4c2bb7 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ErrorsController < ApplicationController def file_not_found end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 50d26768..a8d0c8d5 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -1,68 +1,69 @@ +# frozen_string_literal: true + class ProfilesController < ApplicationController - $units = { access: "Access Services", - archives: "Archives", - bib: "Cataloguing Strategies", - collections: "Collection Strategies", - copyright: "Copyright", - digital: "Digital Production & Preservation Services", - digrepo: "Digital Repository & Data Services", - dsc: "Digital Scholarship Centre", - facilities: "Facilities", - health: "Faculty Engagement (Health Sciences)", - science: "Faculty Engagement (Natural + Applied Sciences)", - humanities: "Faculty Engagement (Social Sciences + Humanities)", - iss: "Information Services & User Engagement", - admin: "Library Administration", - lad: "Library Application Development", - las: "Library Application Support", - metadata: "Metadata Strategies", - open: "Open Publishing & Digitization Services", - rdm: "Research Data Management", - researchimpact: "Research Impact", - its: "Specialized Technical Support", - special: "Special Collections", - stratigic: "Strategic Partnerships", - tl: "Teaching & Learning", - ux: "User Experience" } - $buildings = { augustana: "Augustana Campus Library", - bsj: "Bibliothèque Saint-Jean", - bpsc: "Bruce Peel Special Collections", - cameron: "Cameron Library", - sperber: "Sperber Library", - rcrf: "Research & Collections Resource Facility", - rutherford: "Rutherford Library", - stjosephs: "St. Joseph's Library" } + $units = {access: "Access Services", + archives: "Archives", + bib: "Cataloguing Strategies", + collections: "Collection Strategies", + copyright: "Copyright", + digital: "Digital Production & Preservation Services", + digrepo: "Digital Repository & Data Services", + dsc: "Digital Scholarship Centre", + facilities: "Facilities", + health: "Faculty Engagement (Health Sciences)", + science: "Faculty Engagement (Natural + Applied Sciences)", + humanities: "Faculty Engagement (Social Sciences + Humanities)", + iss: "Information Services & User Engagement", + admin: "Library Administration", + lad: "Library Application Development", + las: "Library Application Support", + metadata: "Metadata Strategies", + open: "Open Publishing & Digitization Services", + rdm: "Research Data Management", + researchimpact: "Research Impact", + its: "Specialized Technical Support", + special: "Special Collections", + stratigic: "Strategic Partnerships", + tl: "Teaching & Learning", + ux: "User Experience"} + $buildings = {augustana: "Augustana Campus Library", + bsj: "Bibliothèque Saint-Jean", + bpsc: "Bruce Peel Special Collections", + cameron: "Cameron Library", + sperber: "Sperber Library", + rcrf: "Research & Collections Resource Facility", + rutherford: "Rutherford Library", + stjosephs: "St. Joseph's Library"} # You'll have to define "cmsPassword" in secrets.yml, or this will fail. Thanks, ansible. - http_basic_authenticate_with name: Rails.application.secrets.cms_user, password: Rails.application.secrets.cms_password, except: [ :index, :show ] + http_basic_authenticate_with name: Rails.application.secrets.cms_user, password: Rails.application.secrets.cms_password, except: [:index, :show] def index path = request.url - if path.include? "unit" - @unit = params[:unit] + if path.include? "unit" + @unit = params[:unit] @unitname = $units[params[:unit].to_sym] @allunit = Profile.where(unit: @unit) @heads = @allunit.where(opt_in: true).order(:last_name) @staff = @allunit.where(opt_in: nil).order(:last_name) @profiles = @heads + @staff - elsif path.include? "building" - @building = params[:building] + elsif path.include? "building" + @building = params[:building] @buildingname = $buildings[params[:building].to_sym] @profiles = Profile.where("campus_address=?", params[:building]).order(:first_name) - else - @profiles = Profile.all.order(:first_name) - end - respond_to do |format| - format.html - format.csv { send_data @profiles.to_csv } - end + else + @profiles = Profile.order(:first_name) + end + respond_to do |format| + format.html + format.csv { send_data @profiles.to_csv } end + end def show - @profile = Profile.friendly.find(params[:id]) + @profile = Profile.friendly.find(params[:id]) end - def new @profile = Profile.new @buildings = $buildings @@ -76,26 +77,26 @@ def edit end def create - @profile = Profile.new(profile_params) - @profile.save - redirect_to @profile + @profile = Profile.new(profile_params) + @profile.save + redirect_to @profile end def update - @profile = Profile.friendly.find(params[:id]) + @profile = Profile.friendly.find(params[:id]) if @profile.update(profile_params) redirect_to @profile else - render "edit" + render "edit" end end def destroy - @profile = Profile.friendly.find(params[:id]) - @profile.destroy + @profile = Profile.friendly.find(params[:id]) + @profile.destroy - redirect_to profiles_path + redirect_to profiles_path end def units @@ -104,7 +105,6 @@ def units @profiles = Profile.where("unit=?", params[:id]) end - private def profile_params diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be794..15b06f0f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module ApplicationHelper end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index a009ace5..d92ffddc 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class ApplicationJob < ActiveJob::Base end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 3c34c814..5cc63a0c 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationMailer < ActionMailer::Base default from: "from@example.com" layout "mailer" diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 10a4cba8..71fbba5b 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end diff --git a/app/models/profile.rb b/app/models/profile.rb index e6037ee8..7d3b6e0a 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -1,16 +1,18 @@ -class Profile < ActiveRecord::Base +# frozen_string_literal: true + +class Profile < ApplicationRecord extend FriendlyId friendly_id :full_name, use: :slugged def full_name - "#{first_name}-#{last_name}" - end + "#{first_name}-#{last_name}" + end def self.to_csv(options = {}) - CSV.generate(options) do |csv| + CSV.generate(options) do |csv| csv << column_names - all.each do |product| - csv << product.attributes.values_at(*column_names) + find_each do |product| + csv << product.attributes.values_at(*column_names) end end -end + end end diff --git a/config.ru b/config.ru index f7ba0b52..bff88d60 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,7 @@ +# frozen_string_literal: true + # This file is used by Rack-based servers to start the application. -require_relative 'config/environment' +require_relative "config/environment" run Rails.application diff --git a/config/application.rb b/config/application.rb index dc710c77..f3e79361 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "boot" require "rails/all" @@ -14,8 +16,8 @@ class Application < Rails::Application # Configuration for the application, engines, and railties goes here. # Ensuring that ActiveStorage routes are loaded before Comfy's globbing # route. Without this file serving routes are inaccessible. - config.railties_order = [ ActiveStorage::Engine, :main_app, :all ] - config.exceptions_app = self.routes + config.railties_order = [ActiveStorage::Engine, :main_app, :all] + config.exceptions_app = routes # These settings can be overridden in specific environments using the files # in config/environments, which are processed later. diff --git a/config/boot.rb b/config/boot.rb index 988a5ddc..aef6d031 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/config/environment.rb b/config/environment.rb index cac53157..7df99e89 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Load the Rails application. require_relative "application" diff --git a/config/environments/development.rb b/config/environments/development.rb index 8500f459..c8758cee 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/integer/time" Rails.application.configure do diff --git a/config/environments/production.rb b/config/environments/production.rb index 5f343067..e66d8c90 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/integer/time" Rails.application.configure do @@ -13,7 +15,7 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false config.action_controller.perform_caching = true # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] @@ -53,7 +55,7 @@ config.log_level = :info # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -83,9 +85,9 @@ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) + logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) + config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 3c8a5933..9e7168c9 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -11,7 +13,7 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false config.action_controller.perform_caching = true # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] @@ -54,7 +56,7 @@ config.log_level = :debug # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -84,9 +86,9 @@ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) + logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) + config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. diff --git a/config/environments/test.rb b/config/environments/test.rb index 6ea4d1e7..539d945c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/integer/time" # The test environment is used exclusively to run your application's @@ -23,7 +25,7 @@ } # Show full error reports and disable caching. - config.consider_all_requests_local = true + config.consider_all_requests_local = true config.action_controller.perform_caching = false config.cache_store = :null_store diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index 89d2efab..6d56e439 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 2eeef966..101a2902 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cdf..4b63f289 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 54f47cf1..53538c14 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Define an application-wide content security policy. diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 5a6a32d3..ee8dff9c 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Specify a serializer for the signed and encrypted cookie jars. diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index a9a173b9..d329850d 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Configure parameters to be filtered from the log file. Use this to limit dissemination of diff --git a/config/initializers/friendly_id.rb b/config/initializers/friendly_id.rb index 988b6d8f..6d4bab6b 100644 --- a/config/initializers/friendly_id.rb +++ b/config/initializers/friendly_id.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # FriendlyId Global Configuration # # Use this to set up shared configuration options for your entire application. diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 3860f659..9e049dcc 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index dc189968..be6fedc5 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 00f64d71..810aadeb 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Define an application-wide HTTP permissions policy. For further # information see https://developers.google.com/web/updates/2018/06/feature-policy # diff --git a/config/initializers/rollbar.rb b/config/initializers/rollbar.rb index 6fa548c5..a1ba07c2 100644 --- a/config/initializers/rollbar.rb +++ b/config/initializers/rollbar.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rollbar.configure do |config| # Without configuration, Rollbar is enabled in all environments. # To disable in specific environments, set config.enabled=false. @@ -31,9 +33,7 @@ # 'ignore' will cause the exception to not be reported at all. # config.exception_level_filters.merge!('MyCriticalException' => 'critical') # - config.exception_level_filters.merge!({ - "ActionController::RoutingError" => "ignore" - }) + config.exception_level_filters["ActionController::RoutingError"] = "ignore" # You can also specify a callable, which will be called with the exception instance. # config.exception_level_filters.merge!('MyCriticalException' => lambda { |e| 'critical' }) diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 6d55fe75..2f3c0db4 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which @@ -5,7 +7,7 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [ :json ] + wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. diff --git a/config/puma.rb b/config/puma.rb index a5eccf81..7fae8274 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match @@ -9,7 +11,7 @@ # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch("PORT") { 3000 } # Specifies the `environment` that Puma will run in. # diff --git a/config/routes.rb b/config/routes.rb index d7bb3453..43385245 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.routes.draw do resources :staff, as: :profiles, controller: :profiles comfy_route :cms_admin, path: "/admin" diff --git a/config/spring.rb b/config/spring.rb index 9fa7863f..c5933e49 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + %w[ .ruby-version .rbenv-vars diff --git a/db/migrate/20181101154531_create_cms.rb b/db/migrate/20181101154531_create_cms.rb index a0434da2..5de24546 100644 --- a/db/migrate/20181101154531_create_cms.rb +++ b/db/migrate/20181101154531_create_cms.rb @@ -1,14 +1,16 @@ +# frozen_string_literal: true + class CreateCms < ActiveRecord::Migration[5.2] LIMIT = 16777215 def change # -- Sites ----------------------------------------------------------------- create_table :comfy_cms_sites, force: true do |t| - t.string :label, null: false - t.string :identifier, null: false - t.string :hostname, null: false + t.string :label, null: false + t.string :identifier, null: false + t.string :hostname, null: false t.string :path - t.string :locale, null: false, default: "en" + t.string :locale, null: false, default: "en" t.timestamps t.index :hostname @@ -16,125 +18,125 @@ def change # -- Layouts --------------------------------------------------------------- create_table :comfy_cms_layouts, force: true do |t| - t.integer :site_id, null: false + t.integer :site_id, null: false t.integer :parent_id - t.string :app_layout - t.string :label, null: false - t.string :identifier, null: false - t.text :content, limit: LIMIT - t.text :css, limit: LIMIT - t.text :js, limit: LIMIT - t.integer :position, null: false, default: 0 + t.string :app_layout + t.string :label, null: false + t.string :identifier, null: false + t.text :content, limit: LIMIT + t.text :css, limit: LIMIT + t.text :js, limit: LIMIT + t.integer :position, null: false, default: 0 t.timestamps - t.index [ :parent_id, :position ] - t.index [ :site_id, :identifier ], unique: true + t.index [:parent_id, :position] + t.index [:site_id, :identifier], unique: true end # -- Pages ----------------------------------------------------------------- create_table :comfy_cms_pages, force: true do |t| - t.integer :site_id, null: false + t.integer :site_id, null: false t.integer :layout_id t.integer :parent_id t.integer :target_page_id - t.string :label, null: false - t.string :slug - t.string :full_path, null: false - t.text :content_cache, limit: LIMIT - t.integer :position, null: false, default: 0 - t.integer :children_count, null: false, default: 0 - t.boolean :is_published, null: false, default: true + t.string :label, null: false + t.string :slug + t.string :full_path, null: false + t.text :content_cache, limit: LIMIT + t.integer :position, null: false, default: 0 + t.integer :children_count, null: false, default: 0 + t.boolean :is_published, null: false, default: true t.timestamps - t.index [ :site_id, :full_path ] - t.index [ :parent_id, :position ] - t.index [ :is_published ] + t.index [:site_id, :full_path] + t.index [:parent_id, :position] + t.index [:is_published] end # -- Translations ---------------------------------------------------------- create_table :comfy_cms_translations, force: true do |t| - t.string :locale, null: false - t.integer :page_id, null: false + t.string :locale, null: false + t.integer :page_id, null: false t.integer :layout_id - t.string :label, null: false - t.text :content_cache, limit: LIMIT - t.boolean :is_published, null: false, default: true + t.string :label, null: false + t.text :content_cache, limit: LIMIT + t.boolean :is_published, null: false, default: true t.timestamps - t.index [ :page_id ] - t.index [ :locale ] - t.index [ :is_published ] + t.index [:page_id] + t.index [:locale] + t.index [:is_published] end # -- Fragments ------------------------------------------------------------- create_table :comfy_cms_fragments, force: true do |t| - t.references :record, polymorphic: true - t.string :identifier, null: false - t.string :tag, null: false, default: "text" - t.text :content, limit: LIMIT - t.boolean :boolean, null: false, default: false - t.datetime :datetime + t.references :record, polymorphic: true + t.string :identifier, null: false + t.string :tag, null: false, default: "text" + t.text :content, limit: LIMIT + t.boolean :boolean, null: false, default: false + t.datetime :datetime t.timestamps - t.index [ :identifier ] - t.index [ :datetime ] - t.index [ :boolean ] + t.index [:identifier] + t.index [:datetime] + t.index [:boolean] end # -- Snippets -------------------------------------------------------------- create_table :comfy_cms_snippets, force: true do |t| - t.integer :site_id, null: false - t.string :label, null: false - t.string :identifier, null: false - t.text :content, limit: LIMIT - t.integer :position, null: false, default: 0 + t.integer :site_id, null: false + t.string :label, null: false + t.string :identifier, null: false + t.text :content, limit: LIMIT + t.integer :position, null: false, default: 0 t.timestamps - t.index [ :site_id, :identifier ], unique: true - t.index [ :site_id, :position ] + t.index [:site_id, :identifier], unique: true + t.index [:site_id, :position] end # -- Files ----------------------------------------------------------------- create_table :comfy_cms_files, force: true do |t| - t.integer :site_id, null: false - t.string :label, null: false, default: "" - t.text :description, limit: 2048 - t.integer :position, null: false, default: 0 + t.integer :site_id, null: false + t.string :label, null: false, default: "" + t.text :description, limit: 2048 + t.integer :position, null: false, default: 0 t.timestamps - t.index [ :site_id, :position ] + t.index [:site_id, :position] end # -- Revisions ------------------------------------------------------------- create_table :comfy_cms_revisions, force: true do |t| - t.string :record_type, null: false - t.integer :record_id, null: false - t.text :data, limit: LIMIT - t.datetime :created_at + t.string :record_type, null: false + t.integer :record_id, null: false + t.text :data, limit: LIMIT + t.datetime :created_at - t.index [ :record_type, :record_id, :created_at ], - name: "index_cms_revisions_on_rtype_and_rid_and_created_at" + t.index [:record_type, :record_id, :created_at], + name: "index_cms_revisions_on_rtype_and_rid_and_created_at" end # -- Categories ------------------------------------------------------------ create_table :comfy_cms_categories, force: true do |t| - t.integer :site_id, null: false - t.string :label, null: false - t.string :categorized_type, null: false + t.integer :site_id, null: false + t.string :label, null: false + t.string :categorized_type, null: false - t.index [ :site_id, :categorized_type, :label ], - unique: true, - name: "index_cms_categories_on_site_id_and_cat_type_and_label" + t.index [:site_id, :categorized_type, :label], + unique: true, + name: "index_cms_categories_on_site_id_and_cat_type_and_label" end create_table :comfy_cms_categorizations, force: true do |t| - t.integer :category_id, null: false - t.string :categorized_type, null: false - t.integer :categorized_id, null: false + t.integer :category_id, null: false + t.string :categorized_type, null: false + t.integer :categorized_id, null: false - t.index [ :category_id, :categorized_type, :categorized_id ], - unique: true, - name: "index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id" + t.index [:category_id, :categorized_type, :categorized_id], + unique: true, + name: "index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id" end end end diff --git a/db/migrate/20181101154602_create_friendly_id_slugs.rb b/db/migrate/20181101154602_create_friendly_id_slugs.rb index 9d51b6de..56f1608c 100644 --- a/db/migrate/20181101154602_create_friendly_id_slugs.rb +++ b/db/migrate/20181101154602_create_friendly_id_slugs.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + migration_class = if ActiveRecord::VERSION::MAJOR >= 5 ActiveRecord::Migration[4.2] @@ -8,15 +10,15 @@ class CreateFriendlyIdSlugs < migration_class def change create_table :friendly_id_slugs do |t| - t.string :slug, null: false - t.integer :sluggable_id, null: false - t.string :sluggable_type, limit: 50 - t.string :scope + t.string :slug, null: false + t.integer :sluggable_id, null: false + t.string :sluggable_type, limit: 50 + t.string :scope t.datetime :created_at end add_index :friendly_id_slugs, :sluggable_id - add_index :friendly_id_slugs, [ :slug, :sluggable_type ], length: { slug: 140, sluggable_type: 50 } - add_index :friendly_id_slugs, [ :slug, :sluggable_type, :scope ], length: { slug: 70, sluggable_type: 50, scope: 70 }, unique: true + add_index :friendly_id_slugs, [:slug, :sluggable_type], length: {slug: 140, sluggable_type: 50} + add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], length: {slug: 70, sluggable_type: 50, scope: 70}, unique: true add_index :friendly_id_slugs, :sluggable_type end end diff --git a/db/migrate/20181101154627_create_profiles.rb b/db/migrate/20181101154627_create_profiles.rb index 77038f52..36982388 100644 --- a/db/migrate/20181101154627_create_profiles.rb +++ b/db/migrate/20181101154627_create_profiles.rb @@ -1,24 +1,26 @@ +# frozen_string_literal: true + class CreateProfiles < ActiveRecord::Migration[5.2] def change create_table :profiles do |t| t.string :first_name - t.string :last_name - t.string :job_title - t.string :unit - t.string :email - t.string :phone - t.string :campus_address - t.string :expertise - t.text :introduction - t.text :publications - t.integer :staff_since - t.string :links - t.string :orcid - t.string :committees - t.text :personal_interests - t.boolean :opt_in - t.string :liason - t.timestamps null: false + t.string :last_name + t.string :job_title + t.string :unit + t.string :email + t.string :phone + t.string :campus_address + t.string :expertise + t.text :introduction + t.text :publications + t.integer :staff_since + t.string :links + t.string :orcid + t.string :committees + t.text :personal_interests + t.boolean :opt_in + t.string :liason + t.timestamps null: false end end end diff --git a/db/migrate/20181101154832_add_slug_to_profiles.rb b/db/migrate/20181101154832_add_slug_to_profiles.rb index e7669d34..68eede17 100644 --- a/db/migrate/20181101154832_add_slug_to_profiles.rb +++ b/db/migrate/20181101154832_add_slug_to_profiles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSlugToProfiles < ActiveRecord::Migration[5.2] def change add_column :profiles, :slug, :string diff --git a/db/migrate/20200114203539_create_active_storage_tables.active_storage.rb b/db/migrate/20200114203539_create_active_storage_tables.active_storage.rb index 0b2ce257..344c574b 100644 --- a/db/migrate/20200114203539_create_active_storage_tables.active_storage.rb +++ b/db/migrate/20200114203539_create_active_storage_tables.active_storage.rb @@ -1,26 +1,28 @@ +# frozen_string_literal: true + # This migration comes from active_storage (originally 20170806125915) class CreateActiveStorageTables < ActiveRecord::Migration[5.2] def change create_table :active_storage_blobs do |t| - t.string :key, null: false - t.string :filename, null: false - t.string :content_type - t.text :metadata - t.bigint :byte_size, null: false - t.string :checksum, null: false + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.bigint :byte_size, null: false + t.string :checksum, null: false t.datetime :created_at, null: false - t.index [ :key ], unique: true + t.index [:key], unique: true end create_table :active_storage_attachments do |t| - t.string :name, null: false - t.references :record, null: false, polymorphic: true, index: false - t.references :blob, null: false + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false + t.references :blob, null: false t.datetime :created_at, null: false - t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true + t.index [:record_type, :record_id, :name, :blob_id], name: "index_active_storage_attachments_uniqueness", unique: true t.foreign_key :active_storage_blobs, column: :blob_id end end diff --git a/db/migrate/20220603215832_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20220603215832_add_service_name_to_active_storage_blobs.active_storage.rb index a15c6ce8..685bb572 100644 --- a/db/migrate/20220603215832_add_service_name_to_active_storage_blobs.active_storage.rb +++ b/db/migrate/20220603215832_add_service_name_to_active_storage_blobs.active_storage.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration comes from active_storage (originally 20190112182829) class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] def up @@ -6,7 +8,7 @@ def up unless column_exists?(:active_storage_blobs, :service_name) add_column :active_storage_blobs, :service_name, :string - if configured_service = ActiveStorage::Blob.service.name + if (configured_service = ActiveStorage::Blob.service.name) ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) end diff --git a/db/migrate/20220603215833_create_active_storage_variant_records.active_storage.rb b/db/migrate/20220603215833_create_active_storage_variant_records.active_storage.rb index 94ac83af..6068380d 100644 --- a/db/migrate/20220603215833_create_active_storage_variant_records.active_storage.rb +++ b/db/migrate/20220603215833_create_active_storage_variant_records.active_storage.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration comes from active_storage (originally 20191206030411) class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] def change @@ -8,20 +10,21 @@ def change t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type t.string :variation_digest, null: false - t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true + t.index %i[blob_id variation_digest], name: "index_active_storage_variant_records_uniqueness", unique: true t.foreign_key :active_storage_blobs, column: :blob_id end end private - def primary_key_type - config = Rails.configuration.generators - config.options[config.orm][:primary_key_type] || :primary_key - end - def blobs_primary_key_type - pkey_name = connection.primary_key(:active_storage_blobs) - pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } - pkey_column.bigint? ? :bigint : pkey_column.type - end + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end end diff --git a/db/migrate/20220603215834_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb b/db/migrate/20220603215834_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb index 93c8b85a..6f318221 100644 --- a/db/migrate/20220603215834_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb +++ b/db/migrate/20220603215834_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration comes from active_storage (originally 20211119233751) class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0] def change diff --git a/db/seeds.rb b/db/seeds.rb index d1137de9..e11487aa 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # @@ -6,5 +8,5 @@ # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) -Comfy::Cms::Site.create!(identifier: 'ualberta-libraries', hostname: 'localhost') -Rake::Task['comfy:cms_seeds:import'].invoke('library-cms-seeds', 'ualberta-libraries') +Comfy::Cms::Site.create!(identifier: "ualberta-libraries", hostname: "localhost") +Rake::Task["comfy:cms_seeds:import"].invoke("library-cms-seeds", "ualberta-libraries") diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index d7e6bba8..c05709af 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :chrome, screen_size: [ 1400, 1400 ] + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] end diff --git a/test/test_helper.rb b/test/test_helper.rb index c18d075f..0eb71cbc 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV["RAILS_ENV"] ||= "test" require_relative "../config/environment" require "rails/test_help" From f89fbd5cab808c56d641af89a83229a16d5d08d3 Mon Sep 17 00:00:00 2001 From: Shane Murnaghan <1930474+murny@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:58:35 -0600 Subject: [PATCH 4/4] Remove ignores and add github actions to dependabot config --- .github/dependabot.yml | 40 +++++----------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0233d1f3..65a84188 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,44 +4,14 @@ updates: directory: "/" schedule: interval: daily - time: "10:00" open-pull-requests-limit: 10 - ignore: - - dependency-name: nokogiri - versions: - - 1.11.1 - - 1.11.2 - - dependency-name: listen - versions: - - 3.4.1 - - 3.5.0 - - dependency-name: bootsnap - versions: - - 1.6.0 - - 1.7.0 - - 1.7.1 - - 1.7.2 - - 1.7.3 - - dependency-name: rails - versions: - - 6.1.1 - - 6.1.2 - - 6.1.2.1 - - 6.1.3 - - dependency-name: puma - versions: - - 5.2.0 - - 5.2.1 - - dependency-name: capybara - versions: - - 3.35.1 - package-ecosystem: npm directory: "/" schedule: interval: daily - time: "10:00" open-pull-requests-limit: 10 - ignore: - - dependency-name: "@fortawesome/fontawesome-free" - versions: - - 5.15.2 +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10