Added a new members page, controller method and functional tests.
Signed-off-by: Darryl L. Pierce <mcpierce(a)gmail.com>
---
app/controllers/sprints_controller.rb | 10 +++-
app/views/sprints/members.html.erb | 33 ++++++++++++
test/functional/sprints_controller_test.rb | 76 +++++++++++++++++++--------
3 files changed, 93 insertions(+), 26 deletions(-)
create mode 100644 app/views/sprints/members.html.erb
diff --git a/app/controllers/sprints_controller.rb
b/app/controllers/sprints_controller.rb
index 3535a5e..6abf784 100644
--- a/app/controllers/sprints_controller.rb
+++ b/app/controllers/sprints_controller.rb
@@ -17,7 +17,7 @@
# +SprintsController+ handles performing CRUD operations on instances of
# +Sprint+.
class SprintsController < ApplicationController
- before_filter :authenticated, :except => [:index, :show]
+ before_filter :authenticated, :except => [:index, :show, :members]
before_filter :load_product
before_filter :load_sprint, :except => [:index, :new, :create]
before_filter :get_status, :only => [:status]
@@ -230,6 +230,10 @@ class SprintsController < ApplicationController
end
end
+ # GET /product/1/sprint/1/members
+ def members
+ end
+
private
def load_product
@@ -240,7 +244,7 @@ class SprintsController < ApplicationController
flash[:error] = "Missing or invalid product."
respond_to do |format|
- format.html { redirect_to products_path }
+ format.html { redirect_to error_path }
end
end
end
@@ -252,7 +256,7 @@ class SprintsController < ApplicationController
flash[:error] = "Missing or invalid sprint."
respond_to do |format|
- format.html { redirect_to product_sprints_path(@product) }
+ format.html { redirect_to error_path }
end
end
end
diff --git a/app/views/sprints/members.html.erb b/app/views/sprints/members.html.erb
new file mode 100644
index 0000000..b1198de
--- /dev/null
+++ b/app/views/sprints/members.html.erb
@@ -0,0 +1,33 @@
+<div id="content">
+ <table class="main-list">
+ <caption><%= "Members For \"#{(a)sprint.title}\""
%></caption>
+ <thead>
+ <tr>
+ <th scope="col">#</th>
+ <th scope="col" class="name">Member</th>
+ <th scope="col">Task Hours</th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @sprint.members.each do |member| %>
+ <tr class="<%= cycle('odd', 'even') %>">
+ <td><%= member.id %></td>
+ <td class="name">
+ <% if member.avatar_url %>
+ <div class="small-icon"><%= image_tag member.avatar_url
%></div>
+ <% end %>
+ <%= link_to member.display_name, user_path(member) %>
+ </td>
+ <td>0</td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+</div>
+
+<% render :layout => 'home/sidebar', :locals => {:title =>
'Member Options'} do %>
+
+ <%= link_to "View sprint",
+ product_sprint_path(@product, @sprint), :class => "command" %>
+
+<% end %>
diff --git a/test/functional/sprints_controller_test.rb
b/test/functional/sprints_controller_test.rb
index 7536418..a092751 100644
--- a/test/functional/sprints_controller_test.rb
+++ b/test/functional/sprints_controller_test.rb
@@ -68,7 +68,7 @@ class SprintsControllerTest < ActionController::TestCase
def test_index_with_invalid_product
get :index
- assert_redirected_to products_path
+ assert_redirected_to error_path
end
# Ensures that a list of all sprints is viewable.
@@ -85,21 +85,21 @@ class SprintsControllerTest < ActionController::TestCase
def test_show_with_invalid_product
get :show
- assert_redirected_to products_path
+ assert_redirected_to error_path
end
# Ensures that a valid sprint id is required.
def test_show_with_invalid_sprint_id
get :show, {:product_id => @product.id}
- assert_redirected_to product_sprints_path(@product)
+ assert_redirected_to error_path
end
# Ensures that the sprint must be a part of the product.
def test_show_with_sprint_product_mismatch
get :show, {:product_id => @other_product.id, :id => @active_sprint.id}
- assert_redirected_to product_sprints_path(@other_product)
+ assert_redirected_to error_path
end
# Ensures that showing a sprint works as expected.
@@ -125,7 +125,7 @@ class SprintsControllerTest < ActionController::TestCase
def test_new_with_invalid_product
get :new, {}, {:user_id => @owner.id}
- assert_redirected_to products_path
+ assert_redirected_to error_path
end
# Ensures that only the owner can create a new sprint.
@@ -157,14 +157,14 @@ class SprintsControllerTest < ActionController::TestCase
def test_edit_with_invalid_product
get :edit, {}, {:user_id => @owner.id}
- assert_redirected_to products_path
+ assert_redirected_to error_path
end
# Ensures that a valid user sprint id is required.
def test_edit_with_invalid_sprint
get :edit, {:product_id => @product.id}, {:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@product)
+ assert_redirected_to error_path
end
# Ensures that the sprint has to belong to the product.
@@ -174,7 +174,7 @@ class SprintsControllerTest < ActionController::TestCase
:id => @active_sprint.id},
{:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@other_product)
+ assert_redirected_to error_path
end
# Ensures that editing a sprint works as expected.
@@ -205,7 +205,7 @@ class SprintsControllerTest < ActionController::TestCase
def test_create_with_invalid_product
post :create, {}, {:user_id => @owner.id}
- assert_redirected_to products_path
+ assert_redirected_to error_path
end
# Ensures that only the owner can create a sprint.
@@ -273,14 +273,14 @@ class SprintsControllerTest < ActionController::TestCase
def test_update_with_invalid_product
put :update, {}, {:user_id => @owner.id}
- assert_redirected_to products_path
+ assert_redirected_to error_path
end
# Ensures that a valid sprint id must be provided.
def test_update_with_invalid_sprint
put :update, {:product_id => @product.id}, {:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@product)
+ assert_redirected_to error_path
end
# Ensures that the sprint and product must be matched.
@@ -289,7 +289,7 @@ class SprintsControllerTest < ActionController::TestCase
{:product_id => @other_product.id, :id => @active_sprint.id},
{:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@other_product)
+ assert_redirected_to error_path
end
# Ensures that only the product owner can update a sprint.
@@ -357,14 +357,14 @@ class SprintsControllerTest < ActionController::TestCase
def test_delete_with_invalid_product
delete :destroy, {}, {:user_id => @owner.id}
- assert_redirected_to products_path
+ assert_redirected_to error_path
end
# Ensures that a sprint is required.
def test_delete_with_invalid_sprint
delete :destroy, {:product_id => @product.id}, {:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@product)
+ assert_redirected_to error_path
end
# Ensures that the sprint must be a part of the product.
@@ -373,7 +373,7 @@ class SprintsControllerTest < ActionController::TestCase
{:product_id => @other_product.id, :id => @active_sprint.id},
{:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@other_product)
+ assert_redirected_to error_path
end
# Ensures that only the owner can delete a sprint.
@@ -411,14 +411,14 @@ class SprintsControllerTest < ActionController::TestCase
def test_plan_with_invalid_product
get :plan, {}, {:user_id => @owner.id}
- assert_redirected_to products_path
+ assert_redirected_to error_path
end
# Ensures that a valid sprint is required.
def test_plan_with_invalid_sprint
get :plan, {:product_id => @product.id}, {:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@product)
+ assert_redirected_to error_path
end
# Ensures that the sprint belongs to the product.
@@ -427,7 +427,7 @@ class SprintsControllerTest < ActionController::TestCase
{:product_id => @other_product.id, :sprint => @active_sprint.id},
{:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@other_product)
+ assert_redirected_to error_path
end
# Ensures that you can only populate a pending sprint.
@@ -471,14 +471,14 @@ class SprintsControllerTest < ActionController::TestCase
def test_populate_with_invalid_product
post :populate, {}, {:user_id => @owner.id}
- assert_redirected_to products_path
+ assert_redirected_to error_path
end
# Ensures that a valid sprint is required.
def test_populate_with_invalid_sprint
post :populate, {:product_id => @product.id}, {:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@product)
+ assert_redirected_to error_path
end
# Ensures that the sprint belongs to the product.
@@ -487,7 +487,7 @@ class SprintsControllerTest < ActionController::TestCase
{:product_id => @other_product.id, :sprint => @active_sprint.id},
{:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@other_product)
+ assert_redirected_to error_path
end
# Ensures that you can only populate a pending sprint.
@@ -534,14 +534,14 @@ class SprintsControllerTest < ActionController::TestCase
def test_status_with_invalid_product
put :status, {}, {:user_id => @owner.id}
- assert_redirected_to products_url
+ assert_redirected_to error_path
end
# Ensures that a valid sprint is required.
def test_status_with_invalid_sprint
put :status, {:product_id => @product.id}, {:user_id => @owner.id}
- assert_redirected_to product_sprints_path(@product)
+ assert_redirected_to error_path
end
# Ensures that non-product owners can't alter a sprint's status.
@@ -589,4 +589,34 @@ class SprintsControllerTest < ActionController::TestCase
end
end
end
+
+ # Ensures that a valid product is required.
+ def test_members_with_invalid_product
+ get :members
+
+ assert_redirected_to error_path
+ end
+
+ # Ensures that a valid sprint is required.
+ def test_members_with_invalid_sprint
+ get :members, {:product_id => @product.id}
+
+ assert_redirected_to error_path
+ end
+
+ # Ensures that the product and sprint match.
+ def test_members_with_product_sprint_mismatch
+ get :members, {:product_id => @other_product.id, :id => @active_sprint.id}
+
+ assert_redirected_to error_path
+ end
+
+ # Ensures that the sprint members are viewable.
+ def test_members
+ get :members, {:product_id => @product.id, :id => @active_sprint.id}
+
+ assert_response :success
+ assert assigns['sprint'], "Failed to load a sprint."
+ assert_equal @active_sprint.id, assigns['sprint'].id, "Failed to load
the correct sprint."
+ end
end
--
1.6.0.6