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 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..c809198f --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,45 @@ +require: + - rubocop-capybara + - rubocop-minitest + - rubocop-performance + - rubocop-rails + - standard + +inherit_gem: + 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 6cee0f80..e54f0b13 100644 --- a/Gemfile +++ b/Gemfile @@ -1,59 +1,69 @@ -source 'https://rubygems.org' +# frozen_string_literal: true + +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] + + # 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 # 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..5096dd51 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,11 @@ 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) + lint_roller (1.1.0) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -174,7 +178,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 +192,22 @@ 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-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) + racc psych (5.1.2) stringio public_suffix (5.0.4) @@ -240,6 +256,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 +269,33 @@ GEM rexml (3.2.8) strscan (>= 3.0.9) rollbar (3.5.2) + rubocop (1.63.5) + 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-capybara (2.20.0) + rubocop (~> 1.41) + 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) + ruby-progressbar (1.13.0) ruby-vips (2.1.4) ffi (~> 1.12) rubyzip (2.3.2) @@ -277,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) @@ -287,6 +343,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 +364,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,8 +387,14 @@ DEPENDENCIES rails (~> 7.1.3) rdoc (>= 6.6.3.1) rollbar + 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 dd10c6df..a8d0c8d5 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" } - - # 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] +# frozen_string_literal: true - 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 +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"} - def show - @profile = Profile.friendly.find(params[:id]) - end + # 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.order(:first_name) + end + respond_to do |format| + format.html + format.csv { send_data @profiles.to_csv } + end + end - def new - @profile = Profile.new - @buildings = $buildings - @units = $units - end + def show + @profile = Profile.friendly.find(params[:id]) + 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]) + def create + @profile = Profile.new(profile_params) + @profile.save + redirect_to @profile + end - if @profile.update(profile_params) - redirect_to @profile - else - render 'edit' - end - end + def update + @profile = Profile.friendly.find(params[:id]) - def destroy - @profile = Profile.friendly.find(params[:id]) - @profile.destroy + if @profile.update(profile_params) + redirect_to @profile + else + render "edit" + end + end - redirect_to profiles_path - end + def destroy + @profile = Profile.friendly.find(params[:id]) + @profile.destroy - def units - @unit = params[:id] - @unitname = $units[params[:id].to_sym] - @profiles = Profile.where("unit=?", params[:id]) - 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 + 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 + 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/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 286b2239..5cc63a0c 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,6 @@ +# frozen_string_literal: true + class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' + default from: "from@example.com" + layout "mailer" end 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 16efff46..7d3b6e0a 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -1,16 +1,18 @@ -class Profile < ActiveRecord::Base - extend FriendlyId - friendly_id :full_name, use: :slugged - def full_name - "#{first_name}-#{last_name}" - end +# frozen_string_literal: true - 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 +class Profile < ApplicationRecord + 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 + find_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.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 f6b7ffda..f3e79361 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,6 +1,8 @@ -require_relative 'boot' +# frozen_string_literal: true -require 'rails/all' +require_relative "boot" + +require "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -15,7 +17,7 @@ class Application < Rails::Application # 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.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 c6c7b755..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"] @@ -20,7 +22,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) @@ -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,11 +86,11 @@ # 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. config.active_record.dump_schema_after_migration = false -end \ No newline at end of file +end 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 b6239e79..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. @@ -16,9 +18,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/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 07c0d7cc..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' }) @@ -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..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 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 74b3f210..43385245 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + 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/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 8369f9ca..5de24546 100644 --- a/db/migrate/20181101154531_create_cms.rb +++ b/db/migrate/20181101154531_create_cms.rb @@ -1,16 +1,16 @@ -class CreateCms < ActiveRecord::Migration[5.2] +# 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 @@ -18,15 +18,15 @@ 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] @@ -35,17 +35,17 @@ def change # -- 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] @@ -55,12 +55,12 @@ def change # -- 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] @@ -70,12 +70,12 @@ def change # -- 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] @@ -85,11 +85,11 @@ def change # -- 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 @@ -98,10 +98,10 @@ def change # -- 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] @@ -109,34 +109,34 @@ def change # -- 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" + 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" + 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" + 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 691514af..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 cbb8422c..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 :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..68eede17 100644 --- a/db/migrate/20181101154832_add_slug_to_profiles.rb +++ b/db/migrate/20181101154832_add_slug_to_profiles.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + 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/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/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/test/application_system_test_case.rb b/test/application_system_test_case.rb index d19212ab..c05709af 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase 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..0eb71cbc 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,13 +1,15 @@ -ENV['RAILS_ENV'] ||= 'test' -require_relative '../config/environment' -require 'rails/test_help' +# frozen_string_literal: true + +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 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: