Skip to content

Commit ffbc2c8

Browse files
author
Robert Clark
committed
Add basic model and controller tests for current application functionality
1 parent 777d4cd commit ffbc2c8

File tree

17 files changed

+155
-19
lines changed

17 files changed

+155
-19
lines changed

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ AllCops:
1111
- 'vendor/**/*'
1212
Layout/LineLength:
1313
Max: 120
14+
Metrics/BlockLength:
15+
Exclude:
16+
- spec/**/*
17+
Metrics/MethodLength:
18+
Exclude:
19+
- spec/**/*

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ group :development do
5353
gem 'listen', '>= 3.0.5', '< 3.2'
5454
gem 'web-console', '>= 3.3.0'
5555
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
56+
gem 'letter_opener'
5657
gem 'spring'
5758
gem 'spring-watcher-listen', '~> 2.0.0'
5859
end

Gemfile.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ GEM
123123
jbuilder (2.10.0)
124124
activesupport (>= 5.0.0)
125125
jwt (2.2.1)
126+
launchy (2.5.0)
127+
addressable (~> 2.7)
128+
letter_opener (1.7.0)
129+
launchy (~> 2.2)
126130
listen (3.1.5)
127131
rb-fsevent (~> 0.9, >= 0.9.4)
128132
rb-inotify (~> 0.9, >= 0.9.7)
@@ -319,6 +323,7 @@ DEPENDENCIES
319323
gitlab_omniauth-ldap (~> 2.1.1)
320324
haml-rails (~> 2.0)
321325
jbuilder (~> 2.7)
326+
letter_opener
322327
listen (>= 3.0.5, < 3.2)
323328
omniauth (~> 1.8)
324329
omniauth-github

Procfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
web: bundle exec rails s
1+
web: bundle exec rails s -p 3000
22
webpacker: ./bin/webpack-dev-server

app/controllers/users/registrations_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# frozen_string_literal: true
22

3-
class Users
3+
module Users
44
# This controller exists so that we can block user registration if local user
55
# login is disabled.
66
class RegistrationsController < Devise::RegistrationsController
77
def create
88
if Settings.local_login.enabled
99
super
1010
else
11-
redirect :back, alert: 'New user registration is not currently enabled.'
11+
redirect_back(fallback_location: new_user_session_path, alert: I18n.t('devise.registrations.disabled'))
1212
end
1313
end
1414
end

app/helpers/application_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# frozen_string_literal: true
22

3-
# This allows us access to the _path variables inside the application
4-
include Rails.application.routes.url_helpers
5-
63
# This module handles items that we use across multiple controllers
74
# and views throughout the application
85
module ApplicationHelper
6+
# This allows us access to the _path variables inside the application
7+
include Rails.application.routes.url_helpers
8+
99
# Build the links shown to users in the navigation bar
1010
def base_navigation
1111
[

app/views/devise/sessions/new.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
%b-card-text
1818
= render 'devise/sessions/ldap'
1919
- if Settings.local_login.enabled
20-
%b-tab{:active => params[:active_tab].eql?('local') ? true : false, :title => "Login"}
20+
%b-tab{:active => params[:active_tab].eql?('local') ? true : false, :title => "Local Login"}
2121
%b-card-text
2222
= render 'devise/sessions/local'
2323
%b-tab{:active => params[:active_tab].eql?('registration') ? true : false, :title => "Register"}

config/environments/development.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
# Raises error for missing translations.
5151
# config.action_view.raise_on_missing_translations = true
5252

53+
# Use the letter opener gem for email delivery in development
54+
config.action_mailer.delivery_method = :letter_opener
55+
config.action_mailer.perform_deliveries = true
56+
57+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
58+
5359
# Use an evented file watcher to asynchronously detect changes in source code,
5460
# routes, locales, etc. This feature depends on the listen gem.
5561
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

config/environments/test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
# ActionMailer::Base.deliveries array.
4343
config.action_mailer.delivery_method = :test
4444

45+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
46+
4547
# Print deprecation notices to the stderr.
4648
config.active_support.deprecation = :stderr
4749

config/locales/devise.en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ en:
4545
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
4646
updated: "Your account has been updated successfully."
4747
updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
48+
disabled: "New user registration is not currently enabled."
4849
sessions:
4950
signed_in: "Signed in successfully."
5051
signed_out: "Signed out successfully."

0 commit comments

Comments
 (0)