From 965cb76f1da1d4c8c6d11a3e40bd14a85ed6653b Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Sat, 4 May 2024 01:53:57 +0200 Subject: [PATCH] Generate Units::Defaults controller bin/rails g controller Units/Defaults index --- app/controllers/units/defaults_controller.rb | 8 ++++++++ app/helpers/units/defaults_helper.rb | 2 ++ app/views/units/defaults/index.html.erb | 2 ++ config/routes.rb | 4 ++++ test/controllers/units/defaults_controller_test.rb | 8 ++++++++ 5 files changed, 24 insertions(+) create mode 100644 app/controllers/units/defaults_controller.rb create mode 100644 app/helpers/units/defaults_helper.rb create mode 100644 app/views/units/defaults/index.html.erb create mode 100644 test/controllers/units/defaults_controller_test.rb diff --git a/app/controllers/units/defaults_controller.rb b/app/controllers/units/defaults_controller.rb new file mode 100644 index 0000000..990d7de --- /dev/null +++ b/app/controllers/units/defaults_controller.rb @@ -0,0 +1,8 @@ +class Units::DefaultsController < ApplicationController + before_action except: :index do + raise AccessForbidden unless current_user.at_least(:admin) + end + + def index + end +end diff --git a/app/helpers/units/defaults_helper.rb b/app/helpers/units/defaults_helper.rb new file mode 100644 index 0000000..9721ef5 --- /dev/null +++ b/app/helpers/units/defaults_helper.rb @@ -0,0 +1,2 @@ +module Units::DefaultsHelper +end diff --git a/app/views/units/defaults/index.html.erb b/app/views/units/defaults/index.html.erb new file mode 100644 index 0000000..34466c7 --- /dev/null +++ b/app/views/units/defaults/index.html.erb @@ -0,0 +1,2 @@ +

Units::Defaults#index

+

Find me in app/views/units/defaults/index.html.erb

diff --git a/config/routes.rb b/config/routes.rb index c977e9b..1f30d79 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,6 +8,10 @@ Rails.application.routes.draw do end end + namespace :units do + get 'defaults/index' + end + resources :users, only: [:index, :show, :update] do member do get :disguise diff --git a/test/controllers/units/defaults_controller_test.rb b/test/controllers/units/defaults_controller_test.rb new file mode 100644 index 0000000..b01dfe2 --- /dev/null +++ b/test/controllers/units/defaults_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class Units::DefaultsControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get units_defaults_index_url + assert_response :success + end +end