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