From add5442f4dcf2e81cec5a626a56e11d0e4d24b26 Mon Sep 17 00:00:00 2001 From: timibello Date: Sun, 23 May 2021 10:31:44 -0500 Subject: [PATCH 1/9] generated error controller --- app/assets/stylesheets/errors.scss | 3 +++ app/controllers/errors_controller.rb | 7 +++++++ app/helpers/errors_helper.rb | 2 ++ .../errors/internal_server_error.html.erb | 2 ++ app/views/errors/not_found.html.erb | 2 ++ config/routes.rb | 2 ++ spec/helpers/errors_helper_spec.rb | 15 +++++++++++++++ spec/requests/errors_spec.rb | 18 ++++++++++++++++++ .../internal_server_error.html.erb_spec.rb | 5 +++++ spec/views/errors/not_found.html.erb_spec.rb | 5 +++++ 10 files changed, 61 insertions(+) create mode 100644 app/assets/stylesheets/errors.scss create mode 100644 app/controllers/errors_controller.rb create mode 100644 app/helpers/errors_helper.rb create mode 100644 app/views/errors/internal_server_error.html.erb create mode 100644 app/views/errors/not_found.html.erb create mode 100644 spec/helpers/errors_helper_spec.rb create mode 100644 spec/requests/errors_spec.rb create mode 100644 spec/views/errors/internal_server_error.html.erb_spec.rb create mode 100644 spec/views/errors/not_found.html.erb_spec.rb diff --git a/app/assets/stylesheets/errors.scss b/app/assets/stylesheets/errors.scss new file mode 100644 index 0000000..f7f5241 --- /dev/null +++ b/app/assets/stylesheets/errors.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the errors controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: https://sass-lang.com/ diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb new file mode 100644 index 0000000..0ca5908 --- /dev/null +++ b/app/controllers/errors_controller.rb @@ -0,0 +1,7 @@ +class ErrorsController < ApplicationController + def not_found + end + + def internal_server_error + end +end diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rb new file mode 100644 index 0000000..8e3b415 --- /dev/null +++ b/app/helpers/errors_helper.rb @@ -0,0 +1,2 @@ +module ErrorsHelper +end diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb new file mode 100644 index 0000000..6025472 --- /dev/null +++ b/app/views/errors/internal_server_error.html.erb @@ -0,0 +1,2 @@ +

Errors#internal_server_error

+

Find me in app/views/errors/internal_server_error.html.erb

diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb new file mode 100644 index 0000000..7f18c80 --- /dev/null +++ b/app/views/errors/not_found.html.erb @@ -0,0 +1,2 @@ +

Errors#not_found

+

Find me in app/views/errors/not_found.html.erb

diff --git a/config/routes.rb b/config/routes.rb index b98f440..56549c8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Rails.application.routes.draw do + get 'errors/not_found' + get 'errors/internal_server_error' # match '/404', to: 'application#render_not_found', via: :all root 'users#index' diff --git a/spec/helpers/errors_helper_spec.rb b/spec/helpers/errors_helper_spec.rb new file mode 100644 index 0000000..e359203 --- /dev/null +++ b/spec/helpers/errors_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ErrorsHelper. For example: +# +# describe ErrorsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe ErrorsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/errors_spec.rb b/spec/requests/errors_spec.rb new file mode 100644 index 0000000..436204d --- /dev/null +++ b/spec/requests/errors_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "Errors", type: :request do + describe "GET /not_found" do + it "returns http success" do + get "/errors/not_found" + expect(response).to have_http_status(:success) + end + end + + describe "GET /internal_server_error" do + it "returns http success" do + get "/errors/internal_server_error" + expect(response).to have_http_status(:success) + end + end + +end diff --git a/spec/views/errors/internal_server_error.html.erb_spec.rb b/spec/views/errors/internal_server_error.html.erb_spec.rb new file mode 100644 index 0000000..2ae6ed2 --- /dev/null +++ b/spec/views/errors/internal_server_error.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "errors/internal_server_error.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/errors/not_found.html.erb_spec.rb b/spec/views/errors/not_found.html.erb_spec.rb new file mode 100644 index 0000000..4e0eed4 --- /dev/null +++ b/spec/views/errors/not_found.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "errors/not_found.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end From 3044d49c0a502bbb45ec6cb0c00d3fa4e9b7d47e Mon Sep 17 00:00:00 2001 From: timibello Date: Sun, 23 May 2021 10:36:43 -0500 Subject: [PATCH 2/9] rendered app response --- app/controllers/errors_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 0ca5908..4388fcc 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -1,7 +1,10 @@ class ErrorsController < ApplicationController def not_found + render status: 404 end + def internal_server_error + render status: 500 end end From 805b52d8a8692a2eeef6908c681f2fac5395b54b Mon Sep 17 00:00:00 2001 From: timibello Date: Sun, 23 May 2021 10:41:36 -0500 Subject: [PATCH 3/9] added appropriate routing --- config/routes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 56549c8..581b2c0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,8 @@ Rails.application.routes.draw do get 'errors/not_found' get 'errors/internal_server_error' + match "/404", to: "errors#not_found", via: :all + match "/500", to: "errors#internal_server_error", via: :all # match '/404', to: 'application#render_not_found', via: :all root 'users#index' From 42664e727735ed25e14e7a5c4310804ba9876870 Mon Sep 17 00:00:00 2001 From: timibello Date: Sun, 23 May 2021 10:48:37 -0500 Subject: [PATCH 4/9] adjusted configuration --- config/application.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 75e0d2a..bac4b6b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -10,7 +10,8 @@ module Shiftwork2 class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 6.0 - + config.exceptions_app = self.routes + # Set official app timezone config.time_zone = "UTC" From 401bea67ac40e218b11496a13ecad078e85d451d Mon Sep 17 00:00:00 2001 From: timibello Date: Sun, 23 May 2021 10:51:40 -0500 Subject: [PATCH 5/9] config to test locally --- config/environments/development.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 66df51f..428c0e7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -10,7 +10,7 @@ config.eager_load = false # Show full error reports. - config.consider_all_requests_local = true + config.consider_all_requests_local = false # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. From ae6a68374f7161f0977fc93eec7c518f4f73ef46 Mon Sep 17 00:00:00 2001 From: timibello Date: Sun, 23 May 2021 10:53:52 -0500 Subject: [PATCH 6/9] deleted public html 404 and 500 error pages --- public/404.html | 67 ------------------------------------------------- public/500.html | 66 ------------------------------------------------ 2 files changed, 133 deletions(-) delete mode 100644 public/404.html delete mode 100644 public/500.html diff --git a/public/404.html b/public/404.html deleted file mode 100644 index 2be3af2..0000000 --- a/public/404.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The page you were looking for doesn't exist (404) - - - - - - -
-
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/public/500.html b/public/500.html deleted file mode 100644 index 78a030a..0000000 --- a/public/500.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - We're sorry, but something went wrong (500) - - - - - - -
-
-

We're sorry, but something went wrong.

-
-

If you are the application owner check the logs for more information.

-
- - From 8f39cc288b72d39bd4762d7aa0369f4a7e098e94 Mon Sep 17 00:00:00 2001 From: timibello Date: Sun, 23 May 2021 10:58:12 -0500 Subject: [PATCH 7/9] added default styling to 500 page --- .../errors/internal_server_error.html.erb | 68 ++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb index 6025472..9a444d3 100644 --- a/app/views/errors/internal_server_error.html.erb +++ b/app/views/errors/internal_server_error.html.erb @@ -1,2 +1,66 @@ -

Errors#internal_server_error

-

Find me in app/views/errors/internal_server_error.html.erb

+ + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + \ No newline at end of file From 6999cf02efc80ac58df41e8611a6f22da8c44e44 Mon Sep 17 00:00:00 2001 From: timibello Date: Sun, 23 May 2021 11:09:10 -0500 Subject: [PATCH 8/9] added simple style to 404 page --- app/views/errors/not_found.html.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb index 7f18c80..9de0abd 100644 --- a/app/views/errors/not_found.html.erb +++ b/app/views/errors/not_found.html.erb @@ -1,2 +1,5 @@ -

Errors#not_found

-

Find me in app/views/errors/not_found.html.erb

+
+

Oops! Page Not Found

+

Sorry but the page you are looking for does not exist.

+

<%= link_to "Go Back Home", root_path, class: "btn btn-info pl-5 pr-5" %>

+
From b4d038d8aef455dd893b1890bab6e34019254db7 Mon Sep 17 00:00:00 2001 From: timibello Date: Sun, 23 May 2021 14:04:45 -0500 Subject: [PATCH 9/9] added styles,tags,divs to error pages --- app/assets/stylesheets/errors.scss | 23 +++++ .../errors/internal_server_error.html.erb | 92 ++++++------------- 2 files changed, 50 insertions(+), 65 deletions(-) diff --git a/app/assets/stylesheets/errors.scss b/app/assets/stylesheets/errors.scss index f7f5241..151c161 100644 --- a/app/assets/stylesheets/errors.scss +++ b/app/assets/stylesheets/errors.scss @@ -1,3 +1,26 @@ // Place all the styles related to the errors controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: https://sass-lang.com/ +body { + background: #f5f5f5; + font-family: 'Noto Sans', sans-serif; + margin: 0; + color: #4c5667; + overflow-x: hidden !important; + padding-top: 40px; + padding-bottom: 40px; +} + +.message-box h1 { + color: #252932; + font-size: 80px; + font-weight: 700; + margin-left: 18px; + line-height: 80px; + text-shadow: rgba(61, 61, 61, 0.3) 1px 1px, rgba(61, 61, 61, 0.2) 2px 2px, rgba(61, 61, 61, 0.3) 3px 3px; + padding-top: 25px; +} + +.message { + font-size: 18px; +} \ No newline at end of file diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb index 9a444d3..22e2f72 100644 --- a/app/views/errors/internal_server_error.html.erb +++ b/app/views/errors/internal_server_error.html.erb @@ -1,66 +1,28 @@ - - - - We're sorry, but something went wrong (500) - - - - - - -
-
-

We're sorry, but something went wrong.

+
+
+
+ + + + + + + + +
-

If you are the application owner check the logs for more information.

-
- - \ No newline at end of file + +
+ +
+
+