Skip to content

Commit

Permalink
Added tests for the helper
Browse files Browse the repository at this point in the history
  • Loading branch information
edavis10 committed Jan 29, 2010
1 parent 9de6913 commit 0178a90
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/unit/helpers/bulk_time_entries_helper_test.rb
@@ -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

0 comments on commit 0178a90

Please sign in to comment.