Skip to content

Commit

Permalink
Merge pull request #88 from sbleon/iteration_stories
Browse files Browse the repository at this point in the history
This fixes issue #67. It incorporates @amair's original fix, plus the improvement suggested by @tienle, with tests. Iterations now contain the correct stories!
  • Loading branch information
jasonnoble committed Sep 4, 2013
2 parents e9ed2c7 + 7298947 commit b8b67c9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
10 changes: 5 additions & 5 deletions lib/pivotal-tracker/iteration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def all(project, options={})
params = PivotalTracker.encode_options(options)
parse(Client.connection["/projects/#{project.id}/iterations#{params}"].get)
end

def current(project)
array = parse(Client.connection["projects/#{project.id}/iterations/current"].get)
array.first if array
Expand All @@ -22,19 +22,19 @@ def backlog(project, options={})
params = PivotalTracker.encode_options(options)
parse(Client.connection["/projects/#{project.id}/iterations/backlog#{params}"].get)
end

def current_backlog(project, options={})
params = PivotalTracker.encode_options(options)
parse(Client.connection["/projects/#{project.id}/iterations/current_backlog#{params}"].get)
end
end
end

element :id, Integer
element :number, Integer
element :start, DateTime
element :finish, DateTime
element :team_strength, Float
has_many :stories, Story
has_many :stories, Story, :xpath => './/stories'

end
end
1 change: 0 additions & 1 deletion pivotal-tracker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ Gem::Specification.new do |s|
"spec/pivotal-tracker/project_spec.rb",
"spec/pivotal-tracker/story_spec.rb",
"spec/pivotal-tracker/task_spec.rb",
"spec/spec.opts",
"spec/spec_helper.rb",
"spec/support/stale_fish_fixtures.rb"
]
Expand Down
37 changes: 33 additions & 4 deletions spec/pivotal-tracker/iteration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
@iterations.first.should be_a(PivotalTracker::Iteration)
end
end

describe ".current_backlog" do
before do
@iterations = PivotalTracker::Iteration.current_backlog(@project)
Expand All @@ -59,18 +59,47 @@
@iterations.first.should be_a(PivotalTracker::Iteration)
end
end

describe ".team_strength" do
before do
@iteration = PivotalTracker::Iteration.current(@project)
end

it "should return a Float" do
@iteration.should respond_to(:team_strength)
@iteration.team_strength.should be_a(Float)
end
end


describe ".stories" do
context "for the current iteration" do
before do
@iteration = PivotalTracker::Iteration.current(@project)
end

it "should include one story" do
@iteration.stories.should be_a(Array)
@iteration.stories.length.should eq(1)
@iteration.stories.first.description.should eq("Generic description")
@iteration.stories.first.estimate.should eq (2)
end
end

context "with multiple iterations" do
before do
@iteration1 = PivotalTracker::Iteration.current(@project)
@iteration2 = PivotalTracker::Iteration.backlog(@project).first
end

it "should include the correct stories in each iteration" do
@iteration1.stories.count.should eq(1)
@iteration1.stories.first.name.should eq('Tasks Test')
@iteration2.stories.count.should eq(1)
@iteration2.stories.first.name.should eq('This is for comments')
end
end
end


end

1 change: 0 additions & 1 deletion spec/spec.opts

This file was deleted.

4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def is_stale?


RSpec.configure do |config|
# Allow focus on a specific test if specified
config.filter_run :focus => true
config.run_all_when_everything_filtered = true

# Give StaleFish temporary file which is ignored by git
org_stale_fish_config = File.join(File.dirname(__FILE__), 'fixtures', 'stale_fish.yml')
tmp_stale_fish_config = File.join(File.dirname(__FILE__), 'fixtures', 'stale_fish-tmp.yml')
Expand Down

0 comments on commit b8b67c9

Please sign in to comment.