diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-03-08 16:47:47 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-03-08 16:47:47 +0000 |
commit | 1a73f8fa0f46cd7a1c1ef1f548f22214e06c51da (patch) | |
tree | 17ca622120ba3bbe7b37c88bb58fa482a8734e04 /test/unit/helpers | |
parent | fe066e793d061c6c982a6998b683b6336434a5b3 (diff) | |
download | redmine-1a73f8fa0f46cd7a1c1ef1f548f22214e06c51da.tar.gz redmine-1a73f8fa0f46cd7a1c1ef1f548f22214e06c51da.zip |
Added unit tests for IssuesHelper#show_detail
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3552 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/helpers')
-rw-r--r-- | test/unit/helpers/issues_helper_test.rb | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/test/unit/helpers/issues_helper_test.rb b/test/unit/helpers/issues_helper_test.rb new file mode 100644 index 000000000..5e405a8c9 --- /dev/null +++ b/test/unit/helpers/issues_helper_test.rb @@ -0,0 +1,159 @@ +# Redmine - project management software +# Copyright (C) 2006-2010 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require File.dirname(__FILE__) + '/../../test_helper' + +class IssuesHelperTest < HelperTestCase + include ApplicationHelper + include IssuesHelper + + include ActionController::Assertions::SelectorAssertions + fixtures :all + + # Used by assert_select + def html_document + HTML::Document.new(@response.body) + end + + def setup + super + set_language_if_valid('en') + User.current = nil + @response = ActionController::TestResponse.new + end + + def controller + @controller ||= IssuesController.new + end + + def request + @request ||= ActionController::TestRequest.new + end + + context "IssuesHelper#show_detail" do + context "with no_html" do + should 'show a changing attribute' do + @detail = JournalDetail.generate!(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') + assert_equal "% Done changed from 40 to 100", show_detail(@detail, true) + end + + should 'show a new attribute' do + @detail = JournalDetail.generate!(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') + assert_equal "% Done set to 100", show_detail(@detail, true) + end + + should 'show a deleted attribute' do + @detail = JournalDetail.generate!(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') + assert_equal "% Done deleted (50)", show_detail(@detail, true) + end + end + + context "with html" do + should 'show a changing attribute with HTML highlights' do + @detail = JournalDetail.generate!(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') + @response.body = show_detail(@detail, false) + + assert_select 'strong', :text => '% Done' + assert_select 'i', :text => '40' + assert_select 'i', :text => '100' + end + + should 'show a new attribute with HTML highlights' do + @detail = JournalDetail.generate!(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') + @response.body = show_detail(@detail, false) + + assert_select 'strong', :text => '% Done' + assert_select 'i', :text => '100' + end + + should 'show a deleted attribute with HTML highlights' do + @detail = JournalDetail.generate!(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') + @response.body = show_detail(@detail, false) + + assert_select 'strong', :text => '% Done' + assert_select 'strike' do + assert_select 'i', :text => '50' + end + end + end + + context "with a start_date attribute" do + should "format the current date" do + @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date') + assert_match "01/31/2010", show_detail(@detail, true) + end + + should "format the old date" do + @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date') + assert_match "01/01/2010", show_detail(@detail, true) + end + end + + context "with a due_date attribute" do + should "format the current date" do + @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date') + assert_match "01/31/2010", show_detail(@detail, true) + end + + should "format the old date" do + @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date') + assert_match "01/01/2010", show_detail(@detail, true) + end + end + + context "with a project attribute" do + should_show_the_old_and_new_values_for('project_id', Project) + end + + context "with a issue status attribute" do + should_show_the_old_and_new_values_for('status_id', IssueStatus) + end + + context "with a tracker attribute" do + should_show_the_old_and_new_values_for('tracker_id', Tracker) + end + + context "with a assigned to attribute" do + should_show_the_old_and_new_values_for('assigned_to_id', User) + end + + context "with a priority attribute" do + should_show_the_old_and_new_values_for('priority_id', IssuePriority) do + @old_value = IssuePriority.generate!(:type => 'IssuePriority') + @new_value = IssuePriority.generate!(:type => 'IssuePriority') + end + end + + context "with a category attribute" do + should_show_the_old_and_new_values_for('category_id', IssueCategory) + end + + context "with a fixed version attribute" do + should_show_the_old_and_new_values_for('fixed_version_id', Version) + end + + context "with a estimated hours attribute" do + should "format the time into two decimal places" + should "format the old time into two decimal places" + end + + should "test custom fields" + should "test attachments" + + end + +end |