From 0afd045cbd70764596020b616832a3e658a00204 Mon Sep 17 00:00:00 2001 From: MadeTech Dushan Date: Wed, 3 Nov 2021 12:32:38 +0000 Subject: [PATCH] lint fixes --- app/controllers/case_logs_controller.rb | 2 +- config/environments/development.rb | 2 +- config/initializers/devise.rb | 4 +-- .../20211101103235_devise_create_users.rb | 1 - db/seeds.rb | 2 +- spec/features/user_spec.rb | 36 +++++++++++-------- spec/support/devise.rb | 6 ++-- 7 files changed, 30 insertions(+), 23 deletions(-) diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index 5894fa865..8158f9e8a 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -1,7 +1,7 @@ class CaseLogsController < ApplicationController skip_before_action :verify_authenticity_token, if: :json_api_request? before_action :authenticate, if: :json_api_request? - # TODO determine if it's worth splitting out an API controller + # TODO: determine if it's worth splitting out an API controller before_action :authenticate_user!, unless: :json_api_request? def index diff --git a/config/environments/development.rb b/config/environments/development.rb index 88e951497..b6e16fe5c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -38,7 +38,7 @@ Rails.application.configure do 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/initializers/devise.rb b/config/initializers/devise.rb index 35ce3bdce..dc6872604 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -24,7 +24,7 @@ Devise.setup do |config| # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' + config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" # Configure the class responsible to send e-mails. # config.mailer = 'Devise::Mailer' @@ -36,7 +36,7 @@ Devise.setup do |config| # Load and configure the ORM. Supports :active_record (default) and # :mongoid (bson_ext recommended) by default. Other ORMs may be # available as additional gems. - require 'devise/orm/active_record' + require "devise/orm/active_record" # ==> Configuration for any authentication mechanism # Configure which keys are used when authenticating a user. The default is diff --git a/db/migrate/20211101103235_devise_create_users.rb b/db/migrate/20211101103235_devise_create_users.rb index cc0991d9b..61ae93c67 100644 --- a/db/migrate/20211101103235_devise_create_users.rb +++ b/db/migrate/20211101103235_devise_create_users.rb @@ -32,7 +32,6 @@ class DeviseCreateUsers < ActiveRecord::Migration[6.1] # t.string :unlock_token # Only if unlock strategy is :email or :both # t.datetime :locked_at - t.timestamps null: false end diff --git a/db/seeds.rb b/db/seeds.rb index a9d54b39c..cb36e5af4 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,4 +6,4 @@ # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) -User.create!(email: "test@example.com", password: "password") \ No newline at end of file +User.create!(email: "test@example.com", password: "password") diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index ff47a3bf6..95bdcd7ac 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -1,18 +1,26 @@ require "rails_helper" RSpec.describe "User Features" do - let!(:user) { FactoryBot.create(:user) } - context "A user navigating to case logs" do - it " is required to log in" do - visit("/case_logs") - expect(page).to have_current_path("/users/sign_in") - end + let!(:user) { FactoryBot.create(:user) } + context "A user navigating to case logs" do + it " is required to log in" do + visit("/case_logs") + expect(page).to have_current_path("/users/sign_in") + end + + it " is redirected to case logs after signing in" do + visit("/case_logs") + fill_in("user_email", with: "test@example.com") + fill_in("user_password", with: "pAssword1") + click_button("Log in") + expect(page).to have_current_path("/case_logs") + end + end - it " is redirected to case logs after signing in" do - visit("/case_logs") - fill_in("user_email", with: "test@example.com") - fill_in("user_password", with: "pAssword1") - click_button("Log in") - expect(page).to have_current_path("/case_logs") - end + context "A user who has forgotten their password" do + it " is redirected to the forgotten password page when they click the forgot password link" do + visit("/case_logs") + click_link("Forgot your password?") + expect(page).to have_current_path("/users/password/new") end -end \ No newline at end of file + end +end diff --git a/spec/support/devise.rb b/spec/support/devise.rb index d70d3126f..448d13799 100644 --- a/spec/support/devise.rb +++ b/spec/support/devise.rb @@ -1,9 +1,9 @@ -require_relative './controller_macros' +require_relative "./controller_macros" RSpec.configure do |config| # For Devise > 4.1.1 - config.include Devise::Test::ControllerHelpers, :type => :controller + config.include Devise::Test::ControllerHelpers, type: :controller # Use the following instead if you are on Devise <= 4.1.1 # config.include Devise::TestHelpers, :type => :controller - config.extend ControllerMacros, :type => :controller + config.extend ControllerMacros, type: :controller end