When the product owner is creating a new user story, they can select this button
to create a save the current user story and go directly to creating a new one.
Signed-off-by: Darryl L. Pierce <mcpierce(a)gmail.com>
---
app/controllers/stories_controller.rb | 12 +++++++++++-
app/views/stories/_edit.html.erb | 5 ++++-
test/functional/stories_controller_test.rb | 14 ++++++++++++++
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/app/controllers/stories_controller.rb
b/app/controllers/stories_controller.rb
index 45a66d3..baa58b8 100644
--- a/app/controllers/stories_controller.rb
+++ b/app/controllers/stories_controller.rb
@@ -76,7 +76,17 @@ class StoriesController < ApplicationController
if @user_story.save
flash[:message] = "The user story was successfully created."
- format.html { redirect_to params[:url] ? params[:url] :
product_stories_path(@product) }
+
+ puts
"params['add_another']=#{params['add_another']}"
+
+ if params[:add_another]
+ format.html {
+ redirect_to params[:url] ?
+ new_product_story_path(@product, :url => params[:url]) :
+ new_product_story_path(@product) }
+ else
+ format.html { redirect_to params[:url] ? params[:url] :
product_stories_path(@product) }
+ end
else
@title = "User Story (New)"
@user_story.valid?
diff --git a/app/views/stories/_edit.html.erb b/app/views/stories/_edit.html.erb
index 078505a..7a30e1b 100644
--- a/app/views/stories/_edit.html.erb
+++ b/app/views/stories/_edit.html.erb
@@ -45,7 +45,10 @@
<tr>
<td class="buttons" colspan="2">
- <%= submit_tag "Save" %>
+ <%= submit_tag "Save", :name => :save %>
+ <% if @user_story.new_record? %>
+ <%= submit_tag "Save, Create Another", :name =>
"add_another" %>
+ <% end %>
</td>
</tr>
</table>
diff --git a/test/functional/stories_controller_test.rb
b/test/functional/stories_controller_test.rb
index 23b001f..977453d 100644
--- a/test/functional/stories_controller_test.rb
+++ b/test/functional/stories_controller_test.rb
@@ -227,6 +227,20 @@ class StoriesControllerTest < ActionController::TestCase
"User story was not saved."
end
+ # Ensures that specifying to add another the user is returned to the
+ # new action
+ def test_create_and_add_another
+ post :create,
+ {:product_id => @product.id,
+ :user_story => @new_story,
+ 'add_another' => 'yup'},
+ {:user_id => @owner.id}
+
+ assert_redirected_to new_product_story_path(@product)
+ assert UserStory.find_by_title(@new_story[:title]),
+ "User story was not saved."
+ end
+
# Ensures that anonymous users can't update stories.
def test_update_as_anonymous
put :update
--
1.5.6.5
Show replies by date