From 31385ca15630391f4c05c017df52b0f1af87be3f Mon Sep 17 00:00:00 2001 From: Gregor Schmidt Date: Wed, 4 Apr 2012 13:28:01 +0200 Subject: [PATCH] Fixing cukes * making sure, that project id and author are set properly * setting status separately so no workflow restrictions apply --- .../edit_story_tracker_and_status.feature | 9 ++--- features/step_definitions/_given_steps.rb | 8 ++++- features/step_definitions/helpers.rb | 34 +++++++++++++++---- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/features/edit_story_tracker_and_status.feature b/features/edit_story_tracker_and_status.feature index 33958c359b..1cf087bd00 100644 --- a/features/edit_story_tracker_and_status.feature +++ b/features/edit_story_tracker_and_status.feature @@ -40,10 +40,11 @@ Feature: Edit story tracker and status | Closed | true | false | | Rejected | true | false | And the project has the following stories in the following sprints: - | subject | sprint | tracker | status | story_points | - | Story A | Sprint 001 | Bug | New | 10 | - | Story B | Sprint 001 | Story | New | 20 | - | Story C | Sprint 001 | Bug | Resolved | 20 | + | subject | sprint | tracker | story_points | + | Story A | Sprint 001 | Bug | 10 | + | Story B | Sprint 001 | Story | 20 | + | Story C | Sprint 001 | Bug | 20 | + And the status of "Story C" is "Resolved" And the Tracker "Story" has for the Role "manager" the following workflows: | old_status | new_status | | New | Rejected | diff --git a/features/step_definitions/_given_steps.rb b/features/step_definitions/_given_steps.rb index 9bcf4bd1f7..099c3fd824 100644 --- a/features/step_definitions/_given_steps.rb +++ b/features/step_definitions/_given_steps.rb @@ -158,7 +158,7 @@ Given /^the [pP]roject(?: "([^\"]*)")? has the following stories in the followin # NOTE: We're bypassing the controller here because we're just # setting up the database for the actual tests. The actual tests, # however, should NOT bypass the controller - s = Story.create_and_position params, :project => project + s = Story.create_and_position(params, :project => params[:project], :author => params['author']) prev_id = s.id end end @@ -308,3 +308,9 @@ Given /^the [tT]racker(?: "([^\"]*)")? has for the Role "(.+?)" the following wo end tracker.save! end + +Given /^the status of "([^"]*)" is "([^"]*)"$/ do |issue_subject, status_name| + s = Issue.find_by_subject(issue_subject) + s.status = IssueStatus.find_by_name(status_name) + s.save! +end diff --git a/features/step_definitions/helpers.rb b/features/step_definitions/helpers.rb index 1e25c5355d..7f791cba62 100644 --- a/features/step_definitions/helpers.rb +++ b/features/step_definitions/helpers.rb @@ -1,38 +1,58 @@ def initialize_story_params(project, user = User.find(:first)) story = HashWithIndifferentAccess.new(Story.new.attributes) - story['project_id'] = project.id story['tracker_id'] = Story.trackers.first + + # unsafe attributes that will not be used directly but added for your + # convenience + story['project_id'] = project.id story['author_id'] = user.id + story['project'] = project + story['author'] = user story end def initialize_task_params(project, story, user = User.find(:first)) params = HashWithIndifferentAccess.new - params['project_id'] = project.id params['tracker_id'] = Task.tracker - params['author_id'] = user.id params['parent_issue_id'] = story.id if story params['status_id'] = IssueStatus.find(:first).id + + # unsafe attributes that will not be used directly but added for your + # convenience + params['project_id'] = project.id + params['author_id'] = user.id + params['project'] = project + params['author'] = user params end def initialize_issue_params(project, tracker = Tracker.find(:first), parent = nil, user = User.find(:first)) params = HashWithIndifferentAccess.new - params['project_id'] = project.id params['tracker_id'] = tracker.id - params['author_id'] = user.id params['parent_issue_id'] = parent.id if parent params['status_id'] = IssueStatus.find(:first).id + + # unsafe attributes that will not be used directly but added for your + # convenience + params['project_id'] = project.id + params['author_id'] = user.id + params['project'] = project + params['author'] = user params end def initialize_impediment_params(project, sprint, user = User.find(:first)) params = HashWithIndifferentAccess.new(Task.new.attributes) - params['project_id'] = project.id params['tracker_id'] = Task.tracker - params['author_id'] = user.id params['fixed_version_id'] = sprint.id params['status_id'] = IssueStatus.find(:first).id + + # unsafe attributes that will not be used directly but added for your + # convenience + params['project_id'] = project.id + params['author_id'] = user.id + params['project'] = project + params['author'] = user params end