diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2170643..fff7c10 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -80,6 +80,7 @@ <% if user_signed_in? %>
  • Hello, <%= current_user.name %>
  • +
  • <%= link_to 'My projects', user_projects_path(current_user.id) %>
  • <% end %> <% if content_for?(:sidebar) %> <%= yield :sidebar %> diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 5684a86..bf27127 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -4,27 +4,4 @@

    <% if user_signed_in? %><%= link_to 'New Project', new_project_path, class: 'btn btn-primary' %><% end %>

    - - - - - - - - - - - <% @projects.each do |project| %> - - - - - - - <% end %> - -
    NameDescription
    <%= project.name %><%= project.description %><%= link_to 'Show', project_path(project.id), class: 'btn btn-info' %> - <% if project_owner? project.id %> - <%= link_to 'Edit', edit_project_path(project.id), class: 'btn btn-info' %> - <% end %> -
    +<%= render partial: 'shared/project_list', locals: {projects: @projects} %> diff --git a/app/views/shared/_project_list.html.erb b/app/views/shared/_project_list.html.erb new file mode 100644 index 0000000..c7808df --- /dev/null +++ b/app/views/shared/_project_list.html.erb @@ -0,0 +1,24 @@ + + + + + + + + + + + <% projects.each do |project| %> + + + + + + + <% end %> + +
    NameDescription
    <%= project.name %><%= project.description %><%= link_to 'Show', project_path(project.id), class: 'btn btn-info' %> + <% if project_owner? project.id %> + <%= link_to 'Edit', edit_project_path(project.id), class: 'btn btn-info' %> + <% end %> +
    \ No newline at end of file diff --git a/app/views/users/projects.html.erb b/app/views/users/projects.html.erb index e69de29..594fa52 100644 --- a/app/views/users/projects.html.erb +++ b/app/views/users/projects.html.erb @@ -0,0 +1,5 @@ + + +<%= render partial: 'shared/project_list', locals: {projects: @user.projects} %> \ No newline at end of file diff --git a/features/homepage.feature b/features/homepage.feature index 3241ebb..76eba09 100644 --- a/features/homepage.feature +++ b/features/homepage.feature @@ -17,4 +17,5 @@ Feature: Homepage Then I should see "Edit" And I should see "Logout" And I should see "Latest projects" - And I should see "Project" \ No newline at end of file + And I should see "Project" + And I should see "My projects" \ No newline at end of file diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb new file mode 100644 index 0000000..8d6c79b --- /dev/null +++ b/features/step_definitions/user_steps.rb @@ -0,0 +1,20 @@ +When(/^I click the (.+) link$/) do |text| + click_link text +end + +When(/^I press the (.+) button$/) do |text| + click_button text +end + +When(/^I fill the (.+) field with "(.+)"$/) do |field, text| + fill_in field, :with => text +end + +Then(/^my name should have changed to (.+)$/) do |text| + @user.reload + @user.name.should eq(text) +end + +Then(/^I should be in the User Projects page$/) do + page.should have_content("#{@user.name} Projects") +end \ No newline at end of file diff --git a/features/step_definitions/user_update_steps.rb b/features/step_definitions/user_update_steps.rb deleted file mode 100644 index 608bcf5..0000000 --- a/features/step_definitions/user_update_steps.rb +++ /dev/null @@ -1,16 +0,0 @@ -When(/^I click the (.+) link$/) do |text| - click_link text -end - -When(/^I press the (.+) button$/) do |text| - click_button text -end - -When(/^I fill the (.+) field with "(.+)"$/) do |field, text| - fill_in field, :with => text -end - -Then(/^my name should have changed to (.+)$/) do |text| - @user.reload - @user.name.should eq(text) -end \ No newline at end of file diff --git a/features/user_update.feature b/features/user_update.feature deleted file mode 100644 index 3889f7d..0000000 --- a/features/user_update.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: User update - In Order to be able to update my name - As a regular user - I want to have an edit page - - Scenario: with current password - Given I am a regular user - And I am signed in - And I am at the homepage - When I click the Edit link - And I fill the Name field with "Rafael Manzo" - And I fill the Current password field with "password" - And I press the Update button - Then I should see "You updated your account successfully" - And my name should have changed to Rafael Manzo \ No newline at end of file diff --git a/features/users/user_projects.feature b/features/users/user_projects.feature new file mode 100644 index 0000000..da76ff6 --- /dev/null +++ b/features/users/user_projects.feature @@ -0,0 +1,14 @@ +Feature: User projects list + In Order to be able to easily find my projects + As a regular user + I want to have a page with a list of my projects + + @kalibro_restart + Scenario: with current password + Given I am a regular user + And I own a sample project + And I am signed in + And I am at the homepage + When I click the My projects link + Then I should be in the User Projects page + And the sample project should be there \ No newline at end of file diff --git a/features/users/user_update.feature b/features/users/user_update.feature new file mode 100644 index 0000000..3889f7d --- /dev/null +++ b/features/users/user_update.feature @@ -0,0 +1,15 @@ +Feature: User update + In Order to be able to update my name + As a regular user + I want to have an edit page + + Scenario: with current password + Given I am a regular user + And I am signed in + And I am at the homepage + When I click the Edit link + And I fill the Name field with "Rafael Manzo" + And I fill the Current password field with "password" + And I press the Update button + Then I should see "You updated your account successfully" + And my name should have changed to Rafael Manzo \ No newline at end of file -- libgit2 0.21.2