Skip to content

Commit

Permalink
Merge branch '7_add_git_block' into zmaster
Browse files Browse the repository at this point in the history
  • Loading branch information
zdennis committed Apr 1, 2012
2 parents e218a2c + 0c7fc08 commit ba819c0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
34 changes: 34 additions & 0 deletions features/block.feature
Expand Up @@ -48,6 +48,40 @@ Feature: git block
We need more information
"""

Scenario: Blocking a specific card with a message argument
Given I have configured the Git repos for Pivotal
When I run `git-block CURRENT_CARD -m "We need more information"`
Then the output should contain "Story CURRENT_CARD has been blocked."
When the current card is refreshed
Then the card CURRENT_CARD should have the "blocked" label
And the card CURRENT_CARD should have the comment by "PIVOTAL_USER":
"""
We need more information
"""

Scenario: Blocking a specific card and being prompted for a message
Given I have configured the Git repos for Pivotal
When I run `git-block CURRENT_CARD` interactively
When I type "We need more information"
Then the output should contain "Story CURRENT_CARD has been blocked."
When the current card is refreshed
Then the card CURRENT_CARD should have the "blocked" label
And the card CURRENT_CARD should have the comment by "PIVOTAL_USER":
"""
We need more information
"""

Scenario: Blocking a card that is already blocked
Given I have configured the Git repos for Pivotal
And the card is labeled "blocked"
When I run `git-block CURRENT_CARD -m "We need more information"`
Then the output should contain "Story CURRENT_CARD is already blocked."
When the current card is refreshed
Then the card CURRENT_CARD should not have the comment:
"""
We need more information
"""

Scenario: Trying to block when not on a topic branch and not supplying a card id
Given I have configured the Git repos for Pivotal
And I am on the "foo" branch
Expand Down
7 changes: 6 additions & 1 deletion features/step_definitions/steps.rb
Expand Up @@ -40,7 +40,7 @@
comment_on_story :author => author, :text => text
end

Given /^the (#{STORY_TYPE}) is labeled "([^"]+)"$/ do |type, labels|
Given /^the (#{STORY_TYPE}|card) is labeled "([^"]+)"$/ do |type, labels|
update_test_story :labels => labels
end

Expand Down Expand Up @@ -96,6 +96,11 @@
end
end

Then /^the card CURRENT_CARD should not have the comment:$/ do |str|
current_card.notes.all.detect{ |n| n.text.include?(str) }.should be_nil
end


Then /^I should be on the "([^"]*)" branch$/ do |branch|
current_branch.should == branch
end
Expand Down
5 changes: 5 additions & 0 deletions lib/commands/block.rb
Expand Up @@ -17,6 +17,11 @@ def run!
return 1
end

if story.labels.to_s.include?(BlockedLabel)
put "Story #{story_id} is already blocked."
return 0
end

message = options[:message].to_s

if message.empty?
Expand Down

0 comments on commit ba819c0

Please sign in to comment.