From 71e31d89d12eac06449af696f83d7d13a238f9f8 Mon Sep 17 00:00:00 2001 From: Guilherme Rojas V. de Lima Date: Fri, 20 Dec 2013 11:04:31 -0200 Subject: [PATCH] Readings route --- app/controllers/readings_controller.rb | 7 +++++++ config/routes.rb | 4 +++- spec/routing/readings_routing_spec.rb | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 app/controllers/readings_controller.rb create mode 100644 spec/routing/readings_routing_spec.rb diff --git a/app/controllers/readings_controller.rb b/app/controllers/readings_controller.rb new file mode 100644 index 0000000..a13d140 --- /dev/null +++ b/app/controllers/readings_controller.rb @@ -0,0 +1,7 @@ +include OwnershipAuthentication + +class ReadingsController < ApplicationController + before_action :authenticate_user!, except: [:show] + # before_action :reading_group_owner?, except: [:show] + +end diff --git a/config/routes.rb b/config/routes.rb index ee3586c..1e3fc8c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,7 +12,9 @@ Mezuro::Application.routes.draw do get '/repositories/:id/process' => 'repositories#process_repository', as: :repository_process end - resources :reading_groups + resources :reading_groups do + resources :readings + end #resources :modules get '/modules/:id/metric_history' => 'modules#metric_history' diff --git a/spec/routing/readings_routing_spec.rb b/spec/routing/readings_routing_spec.rb new file mode 100644 index 0000000..e9e201c --- /dev/null +++ b/spec/routing/readings_routing_spec.rb @@ -0,0 +1,20 @@ +require "spec_helper" + +describe ReadingsController do + describe "routing" do + it { should route(:post, '/reading_groups/1/readings'). + to(controller: :readings, action: :create, reading_group_id: 1) } + it { should route(:get, '/reading_groups/1/readings/new'). + to(controller: :readings, action: :new, reading_group_id: 1) } + it { should route(:get, '/reading_groups/1/readings/1/edit'). + to(controller: :readings, action: :edit, reading_group_id: 1, id: 1) } + it { should route(:get, '/reading_groups/1/readings/1'). + to(controller: :readings, action: :show, reading_group_id: 1, id: 1) } + it { should route(:delete, '/reading_groups/1/readings/1'). + to(controller: :readings, action: :destroy, reading_group_id: 1, id: 1) } + it { should route(:put, '/reading_groups/1/readings/1'). + to(controller: :readings, action: :update, reading_group_id: 1, id: 1) } + it { should route(:get, '/reading_groups/1/readings'). + to(controller: :readings, action: :index, reading_group_id: 1) } + end +end -- libgit2 0.21.2