Commit 8912169a415b5ccf36e13e5312735cb4e9ea4e96

Authored by Rafael Manzo
1 parent 841edc19

User projects list

app/views/layouts/application.html.erb
... ... @@ -80,6 +80,7 @@
80 80 <% if user_signed_in? %>
81 81 <li class="nav-header">User info</li>
82 82 <li>Hello, <strong><%= current_user.name %></strong></li>
  83 + <li><%= link_to 'My projects', user_projects_path(current_user.id) %></li>
83 84 <% end %>
84 85 <% if content_for?(:sidebar) %>
85 86 <%= yield :sidebar %>
... ...
app/views/projects/index.html.erb
... ... @@ -4,27 +4,4 @@
4 4  
5 5 <p><% if user_signed_in? %><%= link_to 'New Project', new_project_path, class: 'btn btn-primary' %><% end %></p>
6 6  
7   -<table class="table table-hover">
8   - <thead>
9   - <tr>
10   - <th>Name</th>
11   - <th>Description</th>
12   - <th colspan="2"></th>
13   - </tr>
14   - </thead>
15   -
16   - <tbody>
17   - <% @projects.each do |project| %>
18   - <tr>
19   - <td><%= project.name %></td>
20   - <td><%= project.description %></td>
21   - <td><%= link_to 'Show', project_path(project.id), class: 'btn btn-info' %></td>
22   - <td>
23   - <% if project_owner? project.id %>
24   - <%= link_to 'Edit', edit_project_path(project.id), class: 'btn btn-info' %>
25   - <% end %>
26   - </td>
27   - </tr>
28   - <% end %>
29   - </tbody>
30   -</table>
  7 +<%= render partial: 'shared/project_list', locals: {projects: @projects} %>
... ...
app/views/shared/_project_list.html.erb 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +<table class="table table-hover">
  2 + <thead>
  3 + <tr>
  4 + <th>Name</th>
  5 + <th>Description</th>
  6 + <th colspan="2"></th>
  7 + </tr>
  8 + </thead>
  9 +
  10 + <tbody>
  11 + <% projects.each do |project| %>
  12 + <tr>
  13 + <td><%= project.name %></td>
  14 + <td><%= project.description %></td>
  15 + <td><%= link_to 'Show', project_path(project.id), class: 'btn btn-info' %></td>
  16 + <td>
  17 + <% if project_owner? project.id %>
  18 + <%= link_to 'Edit', edit_project_path(project.id), class: 'btn btn-info' %>
  19 + <% end %>
  20 + </td>
  21 + </tr>
  22 + <% end %>
  23 + </tbody>
  24 +</table>
0 25 \ No newline at end of file
... ...
app/views/users/projects.html.erb
... ... @@ -0,0 +1,5 @@
  1 +<div class="page-header">
  2 + <h1><%= @user.name %> Projects</h1>
  3 +</div>
  4 +
  5 +<%= render partial: 'shared/project_list', locals: {projects: @user.projects} %>
0 6 \ No newline at end of file
... ...
features/homepage.feature
... ... @@ -17,4 +17,5 @@ Feature: Homepage
17 17 Then I should see "Edit"
18 18 And I should see "Logout"
19 19 And I should see "Latest projects"
20   - And I should see "Project"
21 20 \ No newline at end of file
  21 + And I should see "Project"
  22 + And I should see "My projects"
22 23 \ No newline at end of file
... ...
features/step_definitions/user_steps.rb 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +When(/^I click the (.+) link$/) do |text|
  2 + click_link text
  3 +end
  4 +
  5 +When(/^I press the (.+) button$/) do |text|
  6 + click_button text
  7 +end
  8 +
  9 +When(/^I fill the (.+) field with "(.+)"$/) do |field, text|
  10 + fill_in field, :with => text
  11 +end
  12 +
  13 +Then(/^my name should have changed to (.+)$/) do |text|
  14 + @user.reload
  15 + @user.name.should eq(text)
  16 +end
  17 +
  18 +Then(/^I should be in the User Projects page$/) do
  19 + page.should have_content("#{@user.name} Projects")
  20 +end
0 21 \ No newline at end of file
... ...
features/step_definitions/user_update_steps.rb
... ... @@ -1,16 +0,0 @@
1   -When(/^I click the (.+) link$/) do |text|
2   - click_link text
3   -end
4   -
5   -When(/^I press the (.+) button$/) do |text|
6   - click_button text
7   -end
8   -
9   -When(/^I fill the (.+) field with "(.+)"$/) do |field, text|
10   - fill_in field, :with => text
11   -end
12   -
13   -Then(/^my name should have changed to (.+)$/) do |text|
14   - @user.reload
15   - @user.name.should eq(text)
16   -end
17 0 \ No newline at end of file
features/user_update.feature
... ... @@ -1,15 +0,0 @@
1   -Feature: User update
2   - In Order to be able to update my name
3   - As a regular user
4   - I want to have an edit page
5   -
6   - Scenario: with current password
7   - Given I am a regular user
8   - And I am signed in
9   - And I am at the homepage
10   - When I click the Edit link
11   - And I fill the Name field with "Rafael Manzo"
12   - And I fill the Current password field with "password"
13   - And I press the Update button
14   - Then I should see "You updated your account successfully"
15   - And my name should have changed to Rafael Manzo
16 0 \ No newline at end of file
features/users/user_projects.feature 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +Feature: User projects list
  2 + In Order to be able to easily find my projects
  3 + As a regular user
  4 + I want to have a page with a list of my projects
  5 +
  6 + @kalibro_restart
  7 + Scenario: with current password
  8 + Given I am a regular user
  9 + And I own a sample project
  10 + And I am signed in
  11 + And I am at the homepage
  12 + When I click the My projects link
  13 + Then I should be in the User Projects page
  14 + And the sample project should be there
0 15 \ No newline at end of file
... ...
features/users/user_update.feature 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +Feature: User update
  2 + In Order to be able to update my name
  3 + As a regular user
  4 + I want to have an edit page
  5 +
  6 + Scenario: with current password
  7 + Given I am a regular user
  8 + And I am signed in
  9 + And I am at the homepage
  10 + When I click the Edit link
  11 + And I fill the Name field with "Rafael Manzo"
  12 + And I fill the Current password field with "password"
  13 + And I press the Update button
  14 + Then I should see "You updated your account successfully"
  15 + And my name should have changed to Rafael Manzo
0 16 \ No newline at end of file
... ...