Scaffold exercise collection routes

This commit is contained in:
Maximilian Grundke
2017-09-27 16:08:56 +02:00
parent af67208fd3
commit 44a3cabe98
6 changed files with 45 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,3 @@
class ExerciseCollectionPolicy < AdminOnlyPolicy
end

View File

@ -0,0 +1 @@
h1 = 'ExerciseCollections#index'

View File

@ -0,0 +1 @@
h1 = 'ExerciseCollection#show'

View File

@ -74,6 +74,8 @@ Rails.application.routes.draw do
end
end
resources :exercise_collections
resources :proxy_exercises do
member do
post :clone

View File

@ -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