diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d1..dfd83fa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,7 @@ class ApplicationController < ActionController::Base + around_action do |_, action| + logger.measure_error "Took too long to complete, please review your code as asynchronous task", min_duration: 3000 do + action.call + end + end end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb new file mode 100644 index 0000000..2fecb2c --- /dev/null +++ b/app/controllers/main_controller.rb @@ -0,0 +1,12 @@ +class MainController < ApplicationController + def home + end + + def about + logger.debug "some debugging info" + logger.info "efficient logging for dark theme" + logger.warn "a warning" + logger.error "an error" + sleep 3 + end +end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb deleted file mode 100644 index 5fdd389..0000000 --- a/app/controllers/welcome_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -class WelcomeController < ApplicationController - def index - # logger.measure_error "Took too long to complete", min_duration: 3000 do - # logger.debug("Debugging information to aid with problem determination") - # logger.info("Informational message such as request received\nline 2\nline3") - # logger.warn("Warn about something in the system") - # logger.error("An error occurred during processing") - # logger.fatal("Oh no something really bad happened") - - # logger.measure_info "Called external interface" do - # sleep 0.1 # Code to call external service ... - # end - - # SemanticLogger.tagged(user: "Jack", zip_code: 12345) do - # # All log entries in this block will include the above named tags - # logger.debug("Hello World") - # end - - logger.info("efficient logging for dark theme") - # raise "exception" - # end - end -end diff --git a/app/helpers/main_helper.rb b/app/helpers/main_helper.rb new file mode 100644 index 0000000..826effe --- /dev/null +++ b/app/helpers/main_helper.rb @@ -0,0 +1,2 @@ +module MainHelper +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 66edd15..546de3f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,6 +9,10 @@ <%= javascript_importmap_tags %> + <%= yield %> diff --git a/app/views/main/about.html.erb b/app/views/main/about.html.erb new file mode 100644 index 0000000..307813b --- /dev/null +++ b/app/views/main/about.html.erb @@ -0,0 +1,2 @@ +

Main#about

+

Find me in app/views/main/about.html.erb

diff --git a/app/views/main/home.html.erb b/app/views/main/home.html.erb new file mode 100644 index 0000000..50f9854 --- /dev/null +++ b/app/views/main/home.html.erb @@ -0,0 +1,2 @@ +

Main#home

+

Find me in app/views/main/home.html.erb

diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb deleted file mode 100644 index 07efe99..0000000 --- a/app/views/welcome/index.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

Welcome Aboard

- diff --git a/config/routes.rb b/config/routes.rb index a8216b4..25a7937 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ Rails.application.routes.draw do - root "welcome#index" + root "main#home" + + get "main/about" end diff --git a/test/controllers/main_controller_test.rb b/test/controllers/main_controller_test.rb new file mode 100644 index 0000000..0a327aa --- /dev/null +++ b/test/controllers/main_controller_test.rb @@ -0,0 +1,13 @@ +require "test_helper" + +class MainControllerTest < ActionDispatch::IntegrationTest + test "should get home" do + get main_home_url + assert_response :success + end + + test "should get about" do + get main_about_url + assert_response :success + end +end