Add tests for updating a story

pull/6827/head
Mark Maglana 14 years ago
parent dc43159680
commit 1fe65be927
  1. 22
      features/product_owner.feature
  2. 38
      features/step_definitions/product_owner_steps.rb

@ -49,7 +49,21 @@ Feature: Product Owner
Scenario: Create a new story
Given I am viewing the master backlog
And I want to create a new story
And I set the subject of the story to Story 5
When I create the story
Then the 1st story should be Story 5
And the 1st position should be unique
When I set the subject of the story to A Whole New Story
And I create the story
Then the 1st story should be A Whole New Story
And the 1st position should be unique
Scenario: Close and reopen a story
Given I am viewing the master backlog
When I close Story 2
Then the status of the story should be set as closed
Scenario: Update a story
Given I am viewing the master backlog
And I want to update the story with subject Story 3
When I set the subject of the story to Relaxdiego was here
And I set the tracker of the story to Bug
When I update the story
Then the story should have a subject of Relaxdiego was here
And the story should have a tracker of Bug

@ -75,7 +75,17 @@ Given /^I want to create a new story$/ do
@story_params = initialize_story_params
end
Given /^I set the (.+) of the story to (.+)$/ do |attribute, value|
Given /^I want to update the story with subject (.+)$/ do |subject|
@story = Story.find(:first, :conditions => "subject='#{subject}'")
@story.should_not be_nil
@story_params = @story.attributes
end
When /^I set the (.+) of the story to (.+)$/ do |attribute, value|
if attribute=="tracker"
attribute="tracker_id"
value = Tracker.find(:first, :conditions => "name='#{value}'").id
end
@story_params[attribute] = value
end
@ -108,6 +118,18 @@ When /^I create the story$/ do
@story_params
end
When /^I update the story$/ do
page.driver.process :post,
url_for(:controller => 'stories', :action => 'update'),
@story_params
end
When /^I close (.+)$/ do |subject|
@story = Story.find(:first, :conditions => "subject='#{subject}'")
@story.should_not be_nil
@story.update_attributes :status_id => IssueStatus.find(:first, :conditions => "name='Closed'").id
end
Then /^I should see the product backlog$/ do
page.should have_css('#product_backlog')
end
@ -129,3 +151,17 @@ end
Then /^the (\d+)(?:st|nd|rd|th) position should be unique$/ do |position|
Story.find(:all, :conditions => "position=#{position}").length.should == 1
end
Then /^the status of the story should be set as (.+)$/ do |status|
@story.reload
@story.status.name.downcase.should == status
end
Then /^the story should have a (.+) of (.+)$/ do |attribute, value|
@story.reload
if attribute=="tracker"
attribute="tracker_id"
value = Tracker.find(:first, :conditions => "name='#{value}'").id
end
@story[attribute].should == value
end
Loading…
Cancel
Save