Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require File.dirname(__FILE__) + '/../../test_helper' | ||
|
||
class BulkTimeEntriesHelperTest < HelperTestCase | ||
include ApplicationHelper | ||
include BulkTimeEntriesHelper | ||
include ActionController::Assertions::SelectorAssertions | ||
|
||
# Used by assert_select | ||
def html_document | ||
HTML::Document.new(@response.body) | ||
end | ||
|
||
def setup | ||
@response = ActionController::TestResponse.new | ||
super | ||
end | ||
|
||
context "#grouped_options_for_issues" do | ||
setup do | ||
@project = Project.generate! | ||
end | ||
|
||
context "with no issues" do | ||
should "return an empty option" do | ||
@response.body = grouped_options_for_issues([]) | ||
assert_select 'option', :text => '' | ||
end | ||
end | ||
|
||
context "with issues" do | ||
setup do | ||
closed = IssueStatus.generate!(:is_closed => true) | ||
@issues = [ | ||
Issue.generate_for_project!(@project, :tracker => @project.trackers.first), | ||
Issue.generate_for_project!(@project, :tracker => @project.trackers.first, :status => closed), | ||
Issue.generate_for_project!(@project, :tracker => @project.trackers.first), | ||
Issue.generate_for_project!(@project, :tracker => @project.trackers.first) | ||
] | ||
@response.body = grouped_options_for_issues(@issues) | ||
end | ||
|
||
should 'render an option tag per issue plan a blank one' do | ||
assert_select 'option', :count => 5 | ||
end | ||
|
||
should 'group the open issues with the Open Issues label' do | ||
assert_select 'optgroup[label=?]', l(:label_open_issues) do | ||
assert_select 'option', :count => 3 | ||
end | ||
end | ||
|
||
should 'group the closed issues with the Closed Issues label' do | ||
assert_select 'optgroup[label=?]', l(:label_closed_issues) do | ||
assert_select 'option', :count => 1 | ||
end | ||
end | ||
end | ||
end | ||
end |