From 44a3cabe988df187755a69da3e285b4a6c85be12 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Wed, 27 Sep 2017 16:08:56 +0200 Subject: [PATCH] Scaffold exercise collection routes --- .../exercise_collections_controller.rb | 24 +++++++++++++++++++ app/policies/exercise_collection_policy.rb | 3 +++ .../exercise_collections/index.html.slim | 1 + app/views/exercise_collections/show.html.slim | 1 + config/routes.rb | 2 ++ .../exercise_collections_controller_test.rb | 14 +++++++++++ 6 files changed, 45 insertions(+) create mode 100644 app/controllers/exercise_collections_controller.rb create mode 100644 app/policies/exercise_collection_policy.rb create mode 100644 app/views/exercise_collections/index.html.slim create mode 100644 app/views/exercise_collections/show.html.slim create mode 100644 test/controllers/exercise_collections_controller_test.rb diff --git a/app/controllers/exercise_collections_controller.rb b/app/controllers/exercise_collections_controller.rb new file mode 100644 index 00000000..359ed7b8 --- /dev/null +++ b/app/controllers/exercise_collections_controller.rb @@ -0,0 +1,24 @@ +class ExerciseCollectionsController < ApplicationController + + before_action :set_exercise_collection, only: [:show] + + def index + @exercise_collections = ExerciseCollection.all + authorize! + end + + def show + end + + + private + + def set_exercise_collection + @exercise_collection = ExerciseCollection.find(params[:id]) + authorize! + end + + def authorize! + authorize(@exercise_collection || @exercise_collections) + end +end diff --git a/app/policies/exercise_collection_policy.rb b/app/policies/exercise_collection_policy.rb new file mode 100644 index 00000000..ff150290 --- /dev/null +++ b/app/policies/exercise_collection_policy.rb @@ -0,0 +1,3 @@ +class ExerciseCollectionPolicy < AdminOnlyPolicy + +end diff --git a/app/views/exercise_collections/index.html.slim b/app/views/exercise_collections/index.html.slim new file mode 100644 index 00000000..03f4829c --- /dev/null +++ b/app/views/exercise_collections/index.html.slim @@ -0,0 +1 @@ +h1 = 'ExerciseCollections#index' diff --git a/app/views/exercise_collections/show.html.slim b/app/views/exercise_collections/show.html.slim new file mode 100644 index 00000000..6ed2b5f7 --- /dev/null +++ b/app/views/exercise_collections/show.html.slim @@ -0,0 +1 @@ +h1 = 'ExerciseCollection#show' diff --git a/config/routes.rb b/config/routes.rb index eb243464..7f254f1d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,6 +74,8 @@ Rails.application.routes.draw do end end + resources :exercise_collections + resources :proxy_exercises do member do post :clone diff --git a/test/controllers/exercise_collections_controller_test.rb b/test/controllers/exercise_collections_controller_test.rb new file mode 100644 index 00000000..699c9271 --- /dev/null +++ b/test/controllers/exercise_collections_controller_test.rb @@ -0,0 +1,14 @@ +require 'test_helper' + +class ExerciseCollectionsControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + + test "should get show" do + get :show + assert_response :success + end + +end