diff --git a/Gemfile b/Gemfile index 10a38e3..effc892 100644 --- a/Gemfile +++ b/Gemfile @@ -1,20 +1,22 @@ -source "https://rubygems.org" +# frozen_string_literal: true + +source 'https://rubygems.org' # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 7.2.1" +gem 'rails', '~> 7.2.1' # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] -gem "sprockets-rails" +gem 'sprockets-rails' # Use sqlite3 as the database for Active Record # Use the Puma web server [https://github.com/puma/puma] -gem "puma", ">= 5.0" +gem 'puma', '>= 5.0' # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] -gem "importmap-rails" +gem 'importmap-rails' # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] -gem "turbo-rails" +gem 'turbo-rails' # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] -gem "stimulus-rails" +gem 'stimulus-rails' # Build JSON APIs with ease [https://github.com/rails/jbuilder] -gem "jbuilder" +gem 'jbuilder' # Use Redis adapter to run Action Cable in production # gem "redis", ">= 4.0.1" @@ -25,10 +27,10 @@ gem "jbuilder" # gem "bcrypt", "~> 3.1.7" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ windows jruby ] +gem 'tzinfo-data', platforms: %i[windows jruby] # Reduces boot times through caching; required in config/boot.rb -gem "bootsnap", require: false +gem 'bootsnap', require: false # OmniAuth for Google login gem 'omniauth' @@ -40,31 +42,30 @@ gem 'omniauth-rails_csrf_protection' group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[ mri windows ], require: "debug/prelude" + gem 'debug', platforms: %i[mri windows], require: 'debug/prelude' # Static analysis for security vulnerabilities [https://brakemanscanner.org/] - gem "brakeman", require: false + gem 'brakeman', require: false # Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/] - gem "rubocop-rails-omakase", require: false + gem 'rubocop-rails-omakase', require: false - gem "sqlite3", "~> 1.4" + gem 'sqlite3', '~> 1.4' end group :development do # Use console on exceptions pages [https://github.com/rails/web-console] - gem "web-console" + gem 'web-console' end group :test do # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] - gem "capybara" - gem "selenium-webdriver" + gem 'capybara' gem 'cucumber-rails', require: false gem 'database_cleaner' gem 'rails-controller-testing' gem 'rspec-rails' + gem 'selenium-webdriver' gem 'simplecov', require: false gem 'ZenTest' end - diff --git a/Rakefile b/Rakefile index 9a5ea73..488c551 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/controllers/application_controller.rb b/app/controllers/application_controller.rb index d380775..1012a6f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,8 @@ +# frozen_string_literal: true + +# ApplicationController serves as the base controller for all other controllers in the application. +# It enforces user authentication for all actions unless overridden, and supports browser version +# restrictions for modern features like webp images, web push, badges, etc. class ApplicationController < ActionController::Base # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. allow_browser versions: :modern @@ -5,20 +10,21 @@ class ApplicationController < ActionController::Base before_action :require_login private - def current_user - # if @current _user is undefined or falsy, evaluate the RHS - # Look up user by id if user id is in the session hash - @current_user ||= User.find(session[:user_id]) if session[:user_id] - end - def logged_in? - current_user - end + def current_user + # if @current _user is undefined or falsy, evaluate the RHS + # Look up user by id if user id is in the session hash + @current_user ||= User.find(session[:user_id]) if session[:user_id] + end + + def logged_in? + current_user + end + + def require_login + # redirect to the welcome page unless user is logged in + return if logged_in? - def require_login - # redirect to the welcome page unless user is logged in - unless logged_in? - redirect_to welcome_path, alert: 'You must be logged in to access this section.' - end - end + redirect_to welcome_path, alert: 'You must be logged in to access this section.' + end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 353bbc2..6a62855 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,23 +1,17 @@ +# frozen_string_literal: true + +# SessionsController handles user authentication with OmniAuth for Google OAuth2. class SessionsController < ApplicationController - # Don't require login for login page skip_before_action :require_login, only: [:omniauth] - # GET /logout def logout reset_session redirect_to welcome_path, notice: 'You are logged out' end - # GET /auth/google_oauth2/callback def omniauth - auth = request.env['omniauth.auth'] - @user = User.find_or_create_by(uid: auth['uid'], provider: auth['provider']) do |u| - u.email = auth['info']['email'] - names = auth['info']['name'].split - u.first_name = names[0] - u.last_name = names[1..].join(' ') - end - + @user = find_or_create_user_from_auth(auth_info) + if @user.valid? session[:user_id] = @user.id redirect_to user_path(@user), notice: 'You are logged in' @@ -25,4 +19,19 @@ def omniauth redirect_to welcome_path, alert: 'Login failed' end end + + private + + def auth_info + request.env['omniauth.auth'] + end + + def find_or_create_user_from_auth(auth) + User.find_or_create_by(uid: auth['uid'], provider: auth['provider']) do |user| + user.email = auth['info']['email'] + names = auth['info']['name'].split + user.first_name = names[0] + user.last_name = names[1..].join(' ') + end + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9de0a0b..ba219f5 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,3 +1,7 @@ +# frozen_string_literal: true + +# UsersController handles displaying user-related data. +# The show action retrieves and displays the current user based on the ID provided in the parameters. class UsersController < ApplicationController def show @current_user = User.find(params[:id]) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index ba7c4ec..cdef493 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -1,9 +1,14 @@ +# frozen_string_literal: true + +# WelcomeController handles displaying the public welcome page. +# It skips the login requirement for the index action and redirects logged-in users +# to their user page with a personalized welcome message. class WelcomeController < ApplicationController # Don't require login for the public welcome page skip_before_action :require_login, only: [:index] def index - if logged_in? - redirect_to user_path(@current_user), notice: "Welcome back, #{@current_user.first_name}!" - end + return unless logged_in? + + redirect_to user_path(@current_user), notice: "Welcome back, #{@current_user.first_name}!" end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..1568d59 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,5 @@ +# frozen_string_literal: true + +# ApplicationHelper is used to store helper methods that can be used across views. module ApplicationHelper end diff --git a/app/models/application_record.rb b/app/models/application_record.rb index b63caeb..5e3faa0 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,6 @@ +# frozen_string_literal: true + +# ApplicationRecord serves as the base class for all models in the application. class ApplicationRecord < ActiveRecord::Base primary_abstract_class end diff --git a/app/models/user.rb b/app/models/user.rb index 603da69..afdd48f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,6 @@ +# frozen_string_literal: true + +# The User model represents users in the application. class User < ApplicationRecord validates :email, presence: true end diff --git a/bin/brakeman b/bin/brakeman old mode 100644 new mode 100755 index ace1c9b..ae3a448 --- a/bin/brakeman +++ b/bin/brakeman @@ -1,7 +1,9 @@ #!/usr/bin/env ruby -require "rubygems" -require "bundler/setup" +# frozen_string_literal: true -ARGV.unshift("--ensure-latest") +require 'rubygems' +require 'bundler/setup' -load Gem.bin_path("brakeman", "brakeman") +ARGV.unshift('--ensure-latest') + +load Gem.bin_path('brakeman', 'brakeman') diff --git a/bin/bundle b/bin/bundle old mode 100644 new mode 100755 index 50da5fd..2ffa02a --- a/bin/bundle +++ b/bin/bundle @@ -8,55 +8,62 @@ # this file is here to facilitate running it. # -require "rubygems" +require 'rubygems' m = Module.new do module_function def invoked_as_script? - File.expand_path($0) == File.expand_path(__FILE__) + File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__) end def env_var_version - ENV["BUNDLER_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` + return unless invoked_as_script? && 'update'.start_with?(ARGV.first || ' ') + + extract_bundler_version + end + + def extract_bundler_version bundler_version = nil update_index = nil - ARGV.each_with_index do |a, i| - if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN) - bundler_version = a + + ARGV.each_with_index do |arg, index| + if update_index && update_index.succ == index && arg.match?(Gem::Version::ANCHORED_VERSION_PATTERN) + bundler_version = arg + end + + if arg =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + bundler_version = Regexp.last_match(1) + update_index = index 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__) + gemfile = ENV['BUNDLE_GEMFILE'] + gemfile && !gemfile.empty? ? gemfile : 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 + 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 @@ -71,29 +78,34 @@ m = Module.new do 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 - + ENV['BUNDLE_GEMFILE'] ||= gemfile activate_bundler end def activate_bundler - gem_error = activation_error_handling do - gem "bundler", bundler_requirement - end + gem_error = activation_error_handling { gem 'bundler', bundler_requirement } return if gem_error.nil? - require_error = activation_error_handling do - require "bundler/version" + + require_error = activation_error_handling { require 'bundler/version' } + if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + return 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}'`" + + warn_bundler_activation_error(gem_error) exit 42 end + def warn_bundler_activation_error(gem_error) + warn "Activating bundler (#{bundler_requirement}) failed:\n" \ + "#{gem_error.message}\n\n" \ + 'To install the version of bundler this project requires, run ' \ + "`gem install bundler -v '#{bundler_requirement}'`" + end + def activation_error_handling yield nil @@ -104,6 +116,4 @@ end m.load_bundler! -if m.invoked_as_script? - load Gem.bin_path("bundler", "bundle") -end +load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script? diff --git a/bin/importmap b/bin/importmap old mode 100644 new mode 100755 index 36502ab..d423864 --- a/bin/importmap +++ b/bin/importmap @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true -require_relative "../config/application" -require "importmap/commands" +require_relative '../config/application' +require 'importmap/commands' diff --git a/bin/rails b/bin/rails index efc0377..a31728a 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,6 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path("../config/application", __dir__) -require_relative "../config/boot" -require "rails/commands" +# frozen_string_literal: true + +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake old mode 100644 new mode 100755 index 4fbf10b..c199955 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,6 @@ #!/usr/bin/env ruby -require_relative "../config/boot" -require "rake" +# frozen_string_literal: true + +require_relative '../config/boot' +require 'rake' Rake.application.run diff --git a/bin/rubocop b/bin/rubocop old mode 100644 new mode 100755 index 40330c0..f45b065 --- a/bin/rubocop +++ b/bin/rubocop @@ -1,8 +1,10 @@ #!/usr/bin/env ruby -require "rubygems" -require "bundler/setup" +# frozen_string_literal: true + +require 'rubygems' +require 'bundler/setup' # explicit rubocop config increases performance slightly while avoiding config confusion. -ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) +ARGV.unshift('--config', File.expand_path('../.rubocop.yml', __dir__)) -load Gem.bin_path("rubocop", "rubocop") +load Gem.bin_path('rubocop', 'rubocop') diff --git a/bin/setup b/bin/setup old mode 100644 new mode 100755 index c0b21a2..3a79d9e --- a/bin/setup +++ b/bin/setup @@ -1,8 +1,10 @@ #!/usr/bin/env ruby -require "fileutils" +# frozen_string_literal: true -APP_ROOT = File.expand_path("..", __dir__) -APP_NAME = "aggie-assign" +require 'fileutils' + +APP_ROOT = File.expand_path('..', __dir__) +APP_NAME = 'aggie-assign' def system!(*args) system(*args, exception: true) @@ -13,9 +15,9 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts "== Installing dependencies ==" - system! "gem install bundler --conservative" - system("bundle check") || system!("bundle install") + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') # puts "\n== Copying sample files ==" # unless File.exist?("config/database.yml") @@ -23,13 +25,13 @@ FileUtils.chdir APP_ROOT do # end puts "\n== Preparing database ==" - system! "bin/rails db:prepare" + system! 'bin/rails db:prepare' puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system! "bin/rails restart" + system! 'bin/rails restart' # puts "\n== Configuring puma-dev ==" # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}" diff --git a/config.ru b/config.ru index 4a3c09a..6dc8321 100644 --- a/config.ru +++ b/config.ru @@ -1,6 +1,8 @@ +# 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 Rails.application.load_server diff --git a/config/application.rb b/config/application.rb index 94d7590..8a30504 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. diff --git a/config/boot.rb b/config/boot.rb index 988a5dd..c04863f 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,6 @@ -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) +# frozen_string_literal: true -require "bundler/setup" # Set up gems listed in the Gemfile. -require "bootsnap/setup" # Speed up boot time by caching expensive operations. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/config/environment.rb b/config/environment.rb index cac5315..d5abe55 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + # Load the Rails application. -require_relative "application" +require_relative 'application' # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 4899e44..68894be 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,6 @@ -require "active_support/core_ext/integer/time" +# frozen_string_literal: true + +require 'active_support/core_ext/integer/time' Rails.application.configure do # Configure 'rails notes' to inspect Cucumber files @@ -23,12 +25,12 @@ # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? + if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store - config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } + config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -45,7 +47,7 @@ # caching is enabled. config.action_mailer.perform_caching = false - config.action_mailer.default_url_options = { host: "localhost", port: 3000 } + config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/config/environments/production.rb b/config/environments/production.rb index 4f74003..6b6104e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,4 +1,6 @@ -require "active_support/core_ext/integer/time" +# frozen_string_literal: true + +require 'active_support/core_ext/integer/time' Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -55,17 +57,17 @@ # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + config.logger = ActiveSupport::Logger.new($stdout) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # "info" includes generic and useful information about system operation, but avoids logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). If you # want to log everything, set the level to "debug". - config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info') # Use a different cache store in production. # config.cache_store = :mem_cache_store diff --git a/config/environments/test.rb b/config/environments/test.rb index 82faac1..1b90675 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,6 @@ -require "active_support/core_ext/integer/time" +# frozen_string_literal: true + +require 'active_support/core_ext/integer/time' # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that @@ -19,10 +21,10 @@ # this is usually not necessary, and can slow down your test suite. However, it's # recommended that you enable it in continuous integration systems to ensure eager # loading is working properly before deploying your code. - config.eager_load = ENV["CI"].present? + config.eager_load = ENV['CI'].present? # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" } + config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -49,7 +51,7 @@ # Unlike controllers, the mailer instance doesn't have any context about the # incoming request so you'll need to provide the :host parameter yourself. - config.action_mailer.default_url_options = { host: "www.example.com" } + config.action_mailer.default_url_options = { host: 'www.example.com' } # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/importmap.rb b/config/importmap.rb index 909dfc5..15fd627 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # Pin npm packages by running ./bin/importmap -pin "application" -pin "@hotwired/turbo-rails", to: "turbo.min.js" -pin "@hotwired/stimulus", to: "stimulus.min.js" -pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" -pin_all_from "app/javascript/controllers", under: "controllers" +pin 'application' +pin '@hotwired/turbo-rails', to: 'turbo.min.js' +pin '@hotwired/stimulus', to: 'stimulus.min.js' +pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js' +pin_all_from 'app/javascript/controllers', under: 'controllers' diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index bd5bcd2..7e6d972 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = "1.0" +Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index b3076b3..35ab3fd 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/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index c010b83..5a36c53 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. # Use this to limit dissemination of sensitive information. # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. -Rails.application.config.filter_parameters += [ - :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +Rails.application.config.filter_parameters += %i[ + passw email secret token _key crypt salt certificate otp ssn ] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 3860f65..9e049dc 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/omniauth.rb b/config/initializers/omniauth.rb index 989946a..cda2ec9 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -1,12 +1,14 @@ +# frozen_string_literal: true + Rails.application.config.middleware.use OmniAuth::Builder do # Retrieve the Google credentials from Rails credentials google_credentials = Rails.application.credentials.google # Configure the Google OAuth provider with the client_id and client_secret provider :google_oauth2, google_credentials[:client_id], google_credentials[:client_secret], { - scope: 'email, profile', # This grants access to the user's email and profile information. - prompt: 'select_account', # This allows users to choose the account they want to log in with. - image_aspect_ratio: 'square', # Ensures the profile picture is a square. - image_size: 50, # Sets the profile picture size to 50x50 pixels. - } + scope: 'email, profile', # This grants access to the user's email and profile information. + prompt: 'select_account', # This allows users to choose the account they want to log in with. + image_aspect_ratio: 'square', # Ensures the profile picture is a square. + image_size: 50 # Sets the profile picture size to 50x50 pixels. + } end diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 7db3b95..e8d0b2a 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_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 HTTP permissions policy. For further diff --git a/config/puma.rb b/config/puma.rb index 03c166f..a0cb7a8 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This configuration file will be evaluated by Puma. The top-level methods that # are invoked here are part of Puma's configuration DSL. For more information # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. @@ -20,15 +22,15 @@ # Any libraries that use a connection pool or another resource pool should # be configured to provide at least as many connections as the number of # threads. This includes Active Record's `pool` parameter in `database.yml`. -threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) +threads_count = ENV.fetch('RAILS_MAX_THREADS', 3) threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. -port ENV.fetch("PORT", 3000) +port ENV.fetch('PORT', 3000) # Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart # Specify the PID file. Defaults to tmp/pids/server.pid in development. # In other environments, only set the PID file if requested. -pidfile ENV["PIDFILE"] if ENV["PIDFILE"] +pidfile ENV['PIDFILE'] if ENV['PIDFILE'] diff --git a/config/routes.rb b/config/routes.rb index d2c7ea7..f19160b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,17 +1,19 @@ +# frozen_string_literal: true + Rails.application.routes.draw do - get "sessions/logout" - get "sessions/omniauth" - get "users/show" - get "welcome/index" + get 'sessions/logout' + get 'sessions/omniauth' + get 'users/show' + get 'welcome/index' # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. - get "up" => "rails/health#show", as: :rails_health_check + get 'up' => 'rails/health#show', as: :rails_health_check # Render dynamic PWA files from app/views/pwa/* - get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker - get "manifest" => "rails/pwa#manifest", as: :pwa_manifest + get 'service-worker' => 'rails/pwa#service_worker', as: :pwa_service_worker + get 'manifest' => 'rails/pwa#manifest', as: :pwa_manifest # Defines the root path route ("/") root 'welcome#index' diff --git a/db/migrate/20240928161950_create_users.rb b/db/migrate/20240928161950_create_users.rb index eb06889..42ec67b 100644 --- a/db/migrate/20240928161950_create_users.rb +++ b/db/migrate/20240928161950_create_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateUsers < ActiveRecord::Migration[7.2] def change create_table :users do |t| diff --git a/db/migrate/20240928163555_add_oauth_details_to_users.rb b/db/migrate/20240928163555_add_oauth_details_to_users.rb index 64f9d39..1a76e2e 100644 --- a/db/migrate/20240928163555_add_oauth_details_to_users.rb +++ b/db/migrate/20240928163555_add_oauth_details_to_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddOauthDetailsToUsers < ActiveRecord::Migration[7.2] def change add_column :users, :uid, :string diff --git a/db/schema.rb b/db/schema.rb index 3c25b06..50a0a12 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -10,15 +12,15 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_09_28_163555) do - create_table "users", force: :cascade do |t| - t.string "email" - t.string "first_name" - t.string "last_name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "uid" - t.string "provider" - t.index ["email"], name: "index_users_on_email", unique: true +ActiveRecord::Schema[7.2].define(version: 20_240_928_163_555) do + create_table 'users', force: :cascade do |t| + t.string 'email' + t.string 'first_name' + t.string 'last_name' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.string 'uid' + t.string 'provider' + t.index ['email'], name: 'index_users_on_email', unique: true end end diff --git a/db/seeds.rb b/db/seeds.rb index 4fbd6ed..0f16211 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file should ensure the existence of records required to run the application in every environment (production, # development, test). The code here should be idempotent so that it can be executed at any point in every environment. # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). diff --git a/features/step_definitions/OAuth_Authorization_steps.rb b/features/step_definitions/OAuth_Authorization_steps.rb index 1067ffb..9656351 100644 --- a/features/step_definitions/OAuth_Authorization_steps.rb +++ b/features/step_definitions/OAuth_Authorization_steps.rb @@ -1,46 +1,45 @@ -Given("I am on the welcome page") do +# frozen_string_literal: true + +Given('I am on the welcome page') do visit welcome_path end Before do - OmniAuth.config.test_mode = true - OmniAuth.config.mock_auth[:google_oauth2] = nil - end + OmniAuth.config.test_mode = true + OmniAuth.config.mock_auth[:google_oauth2] = nil +end - When("I click the button {string}") do |button_text| - click_button(button_text) - end +When('I click the button {string}') do |button_text| + click_button(button_text) +end -When("I authorize access from Google") do +When('I authorize access from Google') do mock_google_oauth_login - visit '/auth/google_oauth2/callback' + visit '/auth/google_oauth2/callback' end -Then("I should be on my profile page") do +Then('I should be on my profile page') do expect(current_path).to eq(user_path(User.first)) end -Then("I should see {string}") do |message| +Then('I should see {string}') do |message| expect(page).to have_content(message) end -When("I login with a non TAMU Google account") do +When('I login with a non TAMU Google account') do mock_google_oauth_login(non_tamu_account: true) - visit '/auth/google_oauth2/callback' + visit '/auth/google_oauth2/callback' end -Given("I am logged in as a user") do +Given('I am logged in as a user') do mock_google_oauth_login - visit '/auth/google_oauth2/callback' + visit '/auth/google_oauth2/callback' end -When("I click {string}") do |text| - click_link(text) - end - - - Then("I should be on the welcome page") do - expect(current_path).to eq(welcome_path) - end - +When('I click {string}') do |text| + click_link(text) +end +Then('I should be on the welcome page') do + expect(current_path).to eq(welcome_path) +end diff --git a/features/support/env.rb b/features/support/env.rb index f9ea253..d92c3e0 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'simplecov' SimpleCov.start 'rails' # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. @@ -30,7 +32,7 @@ begin DatabaseCleaner.strategy = :transaction rescue NameError - raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." + raise 'You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it.' end # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. @@ -54,5 +56,4 @@ Cucumber::Rails::Database.javascript_strategy = :truncation # features/support/env.rb -Dir[Rails.root.join('features/support/**/*.rb')].each { |f| require f } - +Dir[Rails.root.join('features/support/**/*.rb')].sort.each { |f| require f } diff --git a/features/support/omniauth.rb b/features/support/omniauth.rb index 78f33c2..55e6f93 100644 --- a/features/support/omniauth.rb +++ b/features/support/omniauth.rb @@ -1,17 +1,19 @@ -# Mock the OAuth authentication, since we don't want to use an actual email/password - -OmniAuth.config.test_mode = true - -OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({ - provider: 'google_oauth2', - uid: '12345', - info: { - name: 'John Doe', - email: 'johndoe@tamu.edu' - }, - credentials: { - token: 'mock_token', - refresh_token: 'mock_refresh_token', - expires_at: Time.now + 1.week - } -}) \ No newline at end of file +# frozen_string_literal: true + +# Mock the OAuth authentication, since we don't want to use an actual email/password + +OmniAuth.config.test_mode = true + +OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({ + provider: 'google_oauth2', + uid: '12345', + info: { + name: 'John Doe', + email: 'johndoe@tamu.edu' + }, + credentials: { + token: 'mock_token', + refresh_token: 'mock_refresh_token', + expires_at: Time.now + 1.week + } + }) diff --git a/features/support/omniauth_helper.rb b/features/support/omniauth_helper.rb index a17cc4e..ad83e08 100644 --- a/features/support/omniauth_helper.rb +++ b/features/support/omniauth_helper.rb @@ -1,11 +1,12 @@ +# frozen_string_literal: true + def mock_google_oauth_login(non_tamu_account: false) - OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({ - provider: 'google_oauth2', - uid: '123545', - info: { - email: non_tamu_account ? "non-tamu@gmail.com" : "user@tamu.edu", - name: 'Test User' - } - }) - end - \ No newline at end of file + OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({ + provider: 'google_oauth2', + uid: '123545', + info: { + email: non_tamu_account ? 'non-tamu@gmail.com' : 'user@tamu.edu', + name: 'Test User' + } + }) +end diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake index 0caa4d2..2874d92 100644 --- a/lib/tasks/cucumber.rake +++ b/lib/tasks/cucumber.rake @@ -1,69 +1,68 @@ +# frozen_string_literal: true + # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. # It is recommended to regenerate this file in the future when you upgrade to a # newer version of cucumber-rails. Consider adding your own code to a new file # instead of editing this one. Cucumber will automatically load all features/**/*.rb # files. +unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks + + vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first + $LOAD_PATH.unshift("#{File.dirname(vendored_cucumber_bin)}/../lib") unless vendored_cucumber_bin.nil? + + begin + require 'cucumber/rake/task' + + namespace :cucumber do + Cucumber::Rake::Task.new({ ok: 'test:prepare' }, 'Run features that should pass') do |t| + t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. + t.fork = true # You may get faster startup if you set this to false + t.profile = 'default' + end + + Cucumber::Rake::Task.new({ wip: 'test:prepare' }, 'Run features that are being worked on') do |t| + t.binary = vendored_cucumber_bin + t.fork = true # You may get faster startup if you set this to false + t.profile = 'wip' + end + + Cucumber::Rake::Task.new({ rerun: 'test:prepare' }, + 'Record failing features and run only them if any exist') do |t| + t.binary = vendored_cucumber_bin + t.fork = true # You may get faster startup if you set this to false + t.profile = 'rerun' + end + + desc 'Run all features' + task all: %i[ok wip] + + task :statsetup do + require 'rails/code_statistics' + ::STATS_DIRECTORIES << ['Cucumber features', 'features'] if File.exist?('features') + ::CodeStatistics::TEST_TYPES << 'Cucumber features' if File.exist?('features') + end + end -unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks - -vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first -$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? - -begin - require 'cucumber/rake/task' + desc 'Alias for cucumber:ok' + task cucumber: 'cucumber:ok' - namespace :cucumber do - Cucumber::Rake::Task.new({ok: 'test:prepare'}, 'Run features that should pass') do |t| - t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. - t.fork = true # You may get faster startup if you set this to false - t.profile = 'default' - end + task default: :cucumber - Cucumber::Rake::Task.new({wip: 'test:prepare'}, 'Run features that are being worked on') do |t| - t.binary = vendored_cucumber_bin - t.fork = true # You may get faster startup if you set this to false - t.profile = 'wip' + task features: :cucumber do + warn "*** The 'features' task is deprecated. See rake -T cucumber ***" end - Cucumber::Rake::Task.new({rerun: 'test:prepare'}, 'Record failing features and run only them if any exist') do |t| - t.binary = vendored_cucumber_bin - t.fork = true # You may get faster startup if you set this to false - t.profile = 'rerun' + # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon. + task 'test:prepare' do end - desc 'Run all features' - task all: [:ok, :wip] - - task :statsetup do - require 'rails/code_statistics' - ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features') - ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features') + task stats: 'cucumber:statsetup' + rescue LoadError + desc 'cucumber rake task not available (cucumber not installed)' + task :cucumber do + abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' end - - end - - desc 'Alias for cucumber:ok' - task cucumber: 'cucumber:ok' - - task default: :cucumber - - task features: :cucumber do - STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" - end - - # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon. - task 'test:prepare' do end - task stats: 'cucumber:statsetup' - - -rescue LoadError - desc 'cucumber rake task not available (cucumber not installed)' - task :cucumber do - abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' - end -end - end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 0e129f1..02980da 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -62,7 +62,6 @@ it 'sets a flash notice' do get :omniauth expect(flash[:notice]).to eq('You are logged in') - end - + end end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index d90b7b7..fc925d6 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'simplecov' SimpleCov.start 'rails' # This file is copied to spec/ when you run 'rails generate rspec:install' @@ -5,7 +7,7 @@ ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' # Prevent database truncation if the environment is production -abort("The Rails environment is running in production mode!") if Rails.env.production? +abort('The Rails environment is running in production mode!') if Rails.env.production? # Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file # that will avoid rails generators crashing because migrations haven't been run yet # return unless Rails.env.test? diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index db2f0c5..dff0981 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause @@ -45,66 +47,62 @@ # triggering implicit auto-inclusion in groups with matching metadata. config.shared_context_metadata_behavior = :apply_to_host_groups -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ + # config.disable_monkey_patching! + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed end - OmniAuth.config.test_mode = true def mock_google_oauth_login(non_tamu_account: false) OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({ - provider: 'google_oauth2', - uid: '123545', - info: { - email: non_tamu_account ? "non-tamu@gmail.com" : "user@tamu.edu", - name: 'Test User' - } - }) + provider: 'google_oauth2', + uid: '123545', + info: { + email: non_tamu_account ? 'non-tamu@gmail.com' : 'user@tamu.edu', + name: 'Test User' + } + }) end - diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index cee29fd..46f6c6b 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,5 +1,7 @@ -require "test_helper" +# frozen_string_literal: true + +require 'test_helper' class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ] + driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400] end diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb index 6340bf9..4aee9b3 100644 --- a/test/channels/application_cable/connection_test.rb +++ b/test/channels/application_cable/connection_test.rb @@ -1,4 +1,6 @@ -require "test_helper" +# frozen_string_literal: true + +require 'test_helper' module ApplicationCable class ConnectionTest < ActionCable::Connection::TestCase diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb index 15c7186..79d6149 100644 --- a/test/controllers/sessions_controller_test.rb +++ b/test/controllers/sessions_controller_test.rb @@ -1,12 +1,14 @@ -require "test_helper" +# frozen_string_literal: true + +require 'test_helper' class SessionsControllerTest < ActionDispatch::IntegrationTest - test "should get logout" do + test 'should get logout' do get sessions_logout_url assert_response :success end - test "should get omniauth" do + test 'should get omniauth' do get sessions_omniauth_url assert_response :success end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 81a594c..4344b2d 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -1,7 +1,9 @@ -require "test_helper" +# frozen_string_literal: true + +require 'test_helper' class UsersControllerTest < ActionDispatch::IntegrationTest - test "should get show" do + test 'should get show' do get users_show_url assert_response :success end diff --git a/test/controllers/welcome_controller_test.rb b/test/controllers/welcome_controller_test.rb index 76c560c..85201e4 100644 --- a/test/controllers/welcome_controller_test.rb +++ b/test/controllers/welcome_controller_test.rb @@ -1,7 +1,9 @@ -require "test_helper" +# frozen_string_literal: true + +require 'test_helper' class WelcomeControllerTest < ActionDispatch::IntegrationTest - test "should get index" do + test 'should get index' do get welcome_index_url assert_response :success end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 5c07f49..5cc44ed 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1,4 +1,6 @@ -require "test_helper" +# frozen_string_literal: true + +require 'test_helper' class UserTest < ActiveSupport::TestCase # test "the truth" do diff --git a/test/test_helper.rb b/test/test_helper.rb index 0c22470..0c92e8e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,8 @@ -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' module ActiveSupport class TestCase