Commit 841edc19c6497dfcc1d03d33ff8b48a5737669eb

Authored by Rafael Manzo
1 parent 6dca9da8

UserController created to list user's projects

app/controllers/users_controller.rb 0 → 100644
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
  1 +class UsersController < ApplicationController
  2 + # GET /users/1/projects
  3 + def projects
  4 + @user = User.find(params[:user_id].to_i)
  5 + end
  6 +end
app/views/users/projects.html.erb 0 → 100644
config/routes.rb
1 Mezuro::Application.routes.draw do 1 Mezuro::Application.routes.draw do
2 #resources :repositories 2 #resources :repositories
3 3
4 - devise_for :users  
5 -  
6 - root "home#index"  
7 - #resources :projects 4 + devise_for :users
  5 + get 'users/:user_id/projects' => 'users#projects', as: :user_projects
8 6
9 resources :projects do 7 resources :projects do
10 resources :repositories, except: [:update, :index] 8 resources :repositories, except: [:update, :index]
11 get '/repositories/:id/modules/:module_result_id' => 'repositories#show', as: :repository_module 9 get '/repositories/:id/modules/:module_result_id' => 'repositories#show', as: :repository_module
12 put '/repositories/:id' => 'repositories#update', as: :repository_update 10 put '/repositories/:id' => 'repositories#update', as: :repository_update
13 end 11 end
  12 +
  13 + root "home#index"
14 # The priority is based upon order of creation: first created -> highest priority. 14 # The priority is based upon order of creation: first created -> highest priority.
15 # See how all your routes lay out with "rake routes". 15 # See how all your routes lay out with "rake routes".
16 16
spec/controllers/users_controller_spec.rb 0 → 100644
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
  1 +require 'spec_helper'
  2 +
  3 +describe UsersController do
  4 + describe 'projects' do
  5 + let(:user) { FactoryGirl.build(:user) }
  6 +
  7 + before :each do
  8 + User.expects(:find).with(user.id).returns(user)
  9 +
  10 + get :projects, user_id: user.id
  11 + end
  12 +
  13 + it { should render_template(:projects) }
  14 + end
  15 +end
spec/factories/users.rb
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 FactoryGirl.define do 3 FactoryGirl.define do
4 factory :user do 4 factory :user do
  5 + id 1
5 name "Diego Martinez" 6 name "Diego Martinez"
6 email "diego@email.com" 7 email "diego@email.com"
7 password "password" 8 password "password"
spec/routing/user_routing_spec.rb 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +require "spec_helper"
  2 +
  3 +describe UsersController do
  4 + describe "routing" do
  5 + it { should route(:get, '/users/1/projects').
  6 + to(controller: :users, action: :projects, user_id: 1) }
  7 + end
  8 +end
0 \ No newline at end of file 9 \ No newline at end of file