Browse Source

lint fixes

pull/81/head
MadeTech Dushan 3 years ago
parent
commit
f0f75dc48f
  1. 2
      Gemfile
  2. 5
      app/controllers/users/passwords_controller.rb
  3. 8
      config/environments/development.rb
  4. 1
      db/migrate/20211112105348_add_incref_field.rb
  5. 11
      lib/tasks/form_definition.rake
  6. 2
      spec/features/user_spec.rb

2
Gemfile

@ -29,7 +29,7 @@ gem "discard"
gem "activeadmin" gem "activeadmin"
# Admin charts # Admin charts
gem "chartkick" gem "chartkick"
#Json Schema # Json Schema
gem "json-schema" gem "json-schema"
gem "uk_postcode" gem "uk_postcode"
# Authentication # Authentication

5
app/controllers/users/passwords_controller.rb

@ -1,5 +1,4 @@
class Users::PasswordsController < Devise::PasswordsController class Users::PasswordsController < Devise::PasswordsController
def reset_confirmation def reset_confirmation
@email = params["email"] @email = params["email"]
render "devise/confirmations/reset" render "devise/confirmations/reset"
@ -12,9 +11,9 @@ class Users::PasswordsController < Devise::PasswordsController
respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name)) respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
end end
protected protected
def after_sending_reset_password_instructions_path_for(resource) def after_sending_reset_password_instructions_path_for(_resource)
confirmations_reset_path(email: params.dig("user", "email")) if is_navigational_format? confirmations_reset_path(email: params.dig("user", "email")) if is_navigational_format?
end end
end end

8
config/environments/development.rb

@ -44,14 +44,14 @@ Rails.application.configure do
config.action_mailer.delivery_method = :smtp config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com', address: "smtp.gmail.com",
port: 465, port: 465,
domain: 'gmail.com', domain: "gmail.com",
user_name: ENV["CORE_EMAIL_USERNAME"], user_name: ENV["CORE_EMAIL_USERNAME"],
password: ENV["CORE_EMAIL_PASSWORD"], password: ENV["CORE_EMAIL_PASSWORD"],
authentication: 'plain', authentication: "plain",
enable_starttls_auto: true, enable_starttls_auto: true,
ssl: true ssl: true,
} }
# Print deprecation notices to the Rails logger. # Print deprecation notices to the Rails logger.

1
db/migrate/20211112105348_add_incref_field.rb

@ -5,4 +5,3 @@ class AddIncrefField < ActiveRecord::Migration[6.1]
end end
end end
end end

11
lib/tasks/form_definition.rake

@ -1,6 +1,6 @@
require "json" require "json"
require "json-schema" require "json-schema"
# rubocop:disable Lint/ShadowingOuterLocalVariable
def get_all_form_paths(directories) def get_all_form_paths(directories)
form_paths = [] form_paths = []
directories.each do |directory| directories.each do |directory|
@ -13,8 +13,8 @@ end
namespace :form_definition do namespace :form_definition do
desc "Validate JSON against Generic Form Schema" desc "Validate JSON against Generic Form Schema"
task :validate do task validate: :environment do
puts "#{Rails.root}" puts Rails.root.to_s
path = "config/forms/schema/generic.json" path = "config/forms/schema/generic.json"
file = File.open(path) file = File.open(path)
@ -38,7 +38,7 @@ namespace :form_definition do
file = File.open(path) file = File.open(path)
data = JSON.parse(file.read) data = JSON.parse(file.read)
puts JSON::Validator.fully_validate(schema, data, :strict => true) puts JSON::Validator.fully_validate(schema, data, strict: true)
begin begin
JSON::Validator.validate!(schema, data) JSON::Validator.validate!(schema, data)
@ -47,4 +47,5 @@ namespace :form_definition do
end end
end end
end end
end end
# rubocop:enable Lint/ShadowingOuterLocalVariable

2
spec/features/user_spec.rb

@ -47,7 +47,7 @@ RSpec.describe "User Features" do
it " is sent a reset password email" do it " is sent a reset password email" do
visit("/users/password/new") visit("/users/password/new")
fill_in("user_email", with: "test@example.com") fill_in("user_email", with: "test@example.com")
expect{click_button("Send email")}.to change{ActionMailer::Base.deliveries.count}.by(1) expect { click_button("Send email") }.to change { ActionMailer::Base.deliveries.count }.by(1)
end end
end end
end end

Loading…
Cancel
Save