Commit 841edc19c6497dfcc1d03d33ff8b48a5737669eb
1 parent
6dca9da8
Exists in
colab
and in
4 other branches
UserController created to list user's projects
Showing
6 changed files
with
34 additions
and
4 deletions
Show diff stats
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 |
@@ -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
@@ -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 |