changing team member feature to work without fixtures

other features are not broken and work in progress
pull/6827/head
Gregor Schmidt 14 years ago
parent 343d36bca5
commit b058755685
  1. 89
      features/step_definitions/_given_steps.rb
  2. 67
      features/step_definitions/helpers.rb
  3. 14
      features/support/setup.rb
  4. 37
      features/team_member.feature

@ -1,15 +1,19 @@
Given /^I am a product owner of the project$/ do
role = Role.find(:first, :conditions => "name='Manager'")
@user = User.find(:first, :conditions => "login='jsmith'")
role = create_role_in_project
role.permissions << :view_master_backlog
role.permissions << :create_stories
role.permissions << :update_stories
role.permissions << :view_scrum_statistics
role.save!
login_as_product_owner
login_as_user
end
Given /^I am a scrum master of the project$/ do
role = Role.find(:first, :conditions => "name='Manager'")
@user = User.find(:first, :conditions => "login='jsmith'")
role = create_role_in_project
role.permissions << :view_master_backlog
role.permissions << :view_taskboards
role.permissions << :update_sprints
@ -20,17 +24,7 @@ Given /^I am a scrum master of the project$/ do
role.permissions << :view_wiki_pages # NOTE: This is a Redmine core permission
role.permissions << :edit_wiki_pages # NOTE: This is a Redmine core permission
role.save!
login_as_scrum_master
end
Given /^I am a team member of the project$/ do
role = Role.find(:first, :conditions => "name='Manager'")
role.permissions << :view_master_backlog
role.permissions << :view_taskboards
role.permissions << :create_tasks
role.permissions << :update_tasks
role.save!
login_as_team_member
login_as_user
end
Given /^I am logged out$/ do
@ -75,9 +69,16 @@ Given /^I want to create a story$/ do
@story_params = initialize_story_params
end
Given /^I want to create a task for (.+)$/ do |story_subject|
Given /^I want to create a task for (.+)(?: in project "(.+?)")?$/ do |story_subject, *args|
args = args.compact
if args.empty?
project = @project
else
project = Project.find_by_name(args.first)
end
story = Story.find(:first, :conditions => ["subject=?", story_subject])
@task_params = initialize_task_params(story.id)
@task_params = initialize_task_params(project, story)
end
Given /^I want to create an impediment for (.+)$/ do |sprint_subject|
@ -124,11 +125,8 @@ Given /^I want to edit the story with subject (.+)$/ do |subject|
@story_params = HashWithIndifferentAccess.new(@story.attributes)
end
Given /^the (.*) project has the backlogs plugin enabled$/ do |project_id|
@project = get_project(project_id)
# Enable the backlogs plugin
@project.enabled_modules << EnabledModule.new(:name => 'backlogs')
Given /^the backlogs module is initialized in [pP]roject "(.*)"$/ do |project_name|
project = Project.find_by_name(project_name)
# Configure the story and task trackers
story_trackers = Tracker.find(:all).map{|s| "#{s.id}"}
@ -137,13 +135,14 @@ Given /^the (.*) project has the backlogs plugin enabled$/ do |project_id|
Setting["plugin_#{plugin.id}"] = {:story_trackers => story_trackers, :task_tracker => task_tracker }
# Make sure these trackers are enabled in the project
@project.update_attributes :tracker_ids => (story_trackers << task_tracker)
project.update_attributes :tracker_ids => (story_trackers << task_tracker)
end
Given /^the project has the following sprints:$/ do |table|
@project.versions.delete_all
Given /^the project "([^\"]*)" has the following sprints:$/ do |project_name, table|
project = Project.find_by_name(project_name)
table.hashes.each do |version|
version['project_id'] = @project.id
version['project_id'] = project.id
['effective_date', 'sprint_start_date'].each do |date_attr|
version[date_attr] = eval(version[date_attr]).strftime("%Y-%m-%d") if version[date_attr].match(/^(\d+)\.(year|month|week|day|hour|minute|second)(s?)\.(ago|from_now)$/)
end
@ -151,8 +150,10 @@ Given /^the project has the following sprints:$/ do |table|
end
end
Given /^the project has the following stories in the product backlog:$/ do |table|
@project.issues.delete_all
Given /^the project has the following stories in the product backlog:$/ do |project_name, table|
project = Project.find_by_name(project_name)
project.issues.delete_all
prev_id = ''
table.hashes.each do |story|
@ -168,12 +169,14 @@ Given /^the project has the following stories in the product backlog:$/ do |tabl
end
end
Given /^the project has the following stories in the following sprints:$/ do |table|
@project.issues.delete_all
Given /^the project "([^\"]*)" has the following stories in the following sprints:$/ do |project_name, table|
project = Project.find_by_name(project_name)
project.issues.delete_all
prev_id = ''
table.hashes.each do |story|
params = initialize_story_params
params = initialize_story_params(project)
params['subject'] = story['subject']
params['prev_id'] = prev_id
params['fixed_version_id'] = Sprint.find(:first, :conditions => [ "name=?", story['sprint'] ]).id
@ -186,31 +189,39 @@ Given /^the project has the following stories in the following sprints:$/ do |ta
end
end
Given /^the project has the following tasks:$/ do |table|
Given /^the project "([^\"]*)" has the following tasks:$/ do |project_name, table|
project = Project.find_by_name(project_name)
author = User.find(:first)
table.hashes.each do |task|
story = Story.find(:first, :conditions => { :subject => task['parent'] })
params = initialize_task_params(story.id)
params = initialize_task_params(project, story, author)
params['subject'] = task['subject']
# 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
Task.create_with_relationships(params, @user.id, @project.id)
Task.create_with_relationships(params, author, project.id)
end
end
Given /^the project has the following impediments:$/ do |table|
Given /^the project "([^\"]*)" has the following impediments:$/ do |project_name, table|
project = Project.find_by_name(project_name)
author = User.find(:first)
table.hashes.each do |impediment|
sprint = Sprint.find(:first, :conditions => { :name => impediment['sprint'] })
blocks = Story.find(:all, :conditions => { :subject => impediment['blocks'].split(', ') }).map{ |s| s.id }
params = initialize_impediment_params(sprint.id)
params = initialize_impediment_params(project, sprint, author)
params['subject'] = impediment['subject']
params['blocks'] = blocks.join(',')
# 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
Task.create_with_relationships(params, @user.id, @project.id)
Task.create_with_relationships(params, author.id, project.id)
end
end
@ -254,4 +265,8 @@ end
Given /^there are no stories in the project$/ do
@project.issues.delete_all
end
end
Given /^I am working in project "(.+?)"$/ do |project_name|
@project = Project.find_by_name(project_name)
end

@ -2,65 +2,46 @@ def get_project(identifier)
Project.find(:first, :conditions => "identifier='#{identifier}'")
end
def initialize_story_params
@story = HashWithIndifferentAccess.new(Story.new.attributes)
@story['project_id'] = @project.id
@story['tracker_id'] = Story.trackers.first
@story['author_id'] = @user.id
@story
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
story['author_id'] = user.id
story
end
def initialize_task_params(story_id)
params = HashWithIndifferentAccess.new(Task.new.attributes)
params['project_id'] = @project.id
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
params['author_id'] = user.id
params['parent_issue_id'] = story.id
params['status_id'] = IssueStatus.find(:first).id
params
end
def initialize_impediment_params(sprint_id)
def initialize_impediment_params(project, sprint, user = User.find(:first))
params = HashWithIndifferentAccess.new(Task.new.attributes)
params['project_id'] = @project.id
params['project_id'] = project.id
params['tracker_id'] = Task.tracker
params['author_id'] = @user.id
params['fixed_version_id'] = sprint_id
params['author_id'] = user.id
params['fixed_version_id'] = sprint.id
params['status_id'] = IssueStatus.find(:first).id
params
end
def login_as_product_owner
visit url_for(:controller => 'account', :action=>'login')
fill_in 'username', :with => 'jsmith'
fill_in 'password', :with => 'jsmith'
click_button 'Login »'
@user = User.find(:first, :conditions => "login='jsmith'")
end
def create_role_in_project
role = Role.find(:first, :conditions => "name='Manager'")
def login_as_scrum_master
visit url_for(:controller => 'account', :action=>'login')
fill_in 'username', :with => 'jsmith'
fill_in 'password', :with => 'jsmith'
click_button 'Login »'
@user = User.find(:first, :conditions => "login='jsmith'")
end
@user.memberships.destroy_all
def login_as_team_member
visit url_for(:controller => 'account', :action=>'login')
fill_in 'username', :with => 'jsmith'
fill_in 'password', :with => 'jsmith'
click_button 'Login »'
@user = User.find(:first, :conditions => "login='jsmith'")
end
membership = @user.memberships.create(:project_id => @project)
require 'ruby-debug'; debugger
membership.member_roles << MemberRole.new(:role => role)
membership.save!
def login_as_admin
visit url_for(:controller => 'account', :action=>'login')
fill_in 'username', :with => 'admin'
fill_in 'password', :with => 'admin'
click_button 'Login »'
@user = User.find(:first, :conditions => "login='admin'")
end
role
end
def task_position(task)
p1 = task.story.tasks.select{|t| t.id == task.id}[0].rank

@ -1,7 +1,7 @@
#Seed the DB
Before do
Fixtures.reset_cache
fixtures_folder = File.join(RAILS_ROOT, 'test', 'fixtures')
fixtures = Dir[File.join(fixtures_folder, '*.yml')].map {|f| File.basename(f, '.yml') }
Fixtures.create_fixtures(fixtures_folder, fixtures)
end
# #Seed the DB
# Before do
# Fixtures.reset_cache
# fixtures_folder = File.join(RAILS_ROOT, 'test', 'fixtures')
# fixtures = Dir[File.join(fixtures_folder, '*.yml')].map {|f| File.basename(f, '.yml') }
# Fixtures.create_fixtures(fixtures_folder, fixtures)
# end

@ -4,28 +4,45 @@ Feature: Team Member
So that I can update everyone on the status of the project
Background:
Given the ecookbook project has the backlogs plugin enabled
And I am a team member of the project
And the project has the following sprints:
Given there is 1 project with:
| name | ecookbook |
And the project "ecookbook" uses the following modules:
| backlogs |
And the backlogs module is initialized in project "ecookbook"
And there is 1 user with:
| login | jsmith |
And there is a role "member"
And the role "member" may have the following rights:
| view_master_backlog |
| view_taskboards |
| create_tasks |
| update_tasks |
| view_issues |
| edit_issues |
| manage_subtasks |
And the user "jsmith" is a "member" in the Project "ecookbook"
And the project "ecookbook" has the following sprints:
| name | sprint_start_date | effective_date |
| Sprint 001 | 2010-01-01 | 2010-01-31 |
| Sprint 002 | 2010-02-01 | 2010-02-28 |
| Sprint 003 | 2010-03-01 | 2010-03-31 |
| Sprint 004 | 2010-03-01 | 2010-03-31 |
And the project has the following stories in the following sprints:
And the project "ecookbook" has the following stories in the following sprints:
| position | subject | sprint |
| 1 | Story 1 | Sprint 001 |
| 2 | Story 2 | Sprint 001 |
| 3 | Story 3 | Sprint 001 |
| 4 | Story 4 | Sprint 002 |
And the project has the following tasks:
And the project "ecookbook" has the following tasks:
| subject | parent |
| Task 1 | Story 1 |
And the project has the following impediments:
And the project "ecookbook" has the following impediments:
| subject | sprint | blocks |
| Impediment 1 | Sprint 001 | Story 1 |
| Impediment 2 | Sprint 001 | Story 2 |
| Impediment 2 | Sprint 001 | Story 2 |
And I am logged in as "jsmith"
And I am working in project "ecookbook"
Scenario: Create a task for a story
Given I am viewing the taskboard for Sprint 001
And I want to create a task for Story 1
@ -78,12 +95,12 @@ Feature: Team Member
Then the request should complete successfully
And the server should return 2 updated impediments
Scenario: Fetch zero updated impediments
Scenario: Fetch zero updated impediments
Given I am viewing the taskboard for Sprint 001
When the browser fetches impediments updated since 1 week from now
Then the request should complete successfully
And the server should return 0 updated impediments
Scenario: Copy estimate to remaining
Given I am viewing the taskboard for Sprint 001
And I want to create a task for Story 1

Loading…
Cancel
Save