##// END OF EJS Templates
Merged r9390 from trunk....
Merged r9390 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9400 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r8957:bcd8c643844f
r9266:8fefb7c05bb9
Show More
issues_helper_test.rb
171 lines | 6.5 KiB | text/x-ruby | RubyLexer
/ test / unit / helpers / issues_helper_test.rb
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 # Redmine - project management software
Jean-Philippe Lang
Adds a helper for issue heading (#7647)....
r5327 # Copyright (C) 2006-2011 Jean-Philippe Lang
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 #
# 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.
Toshi MARUYAMA
remove trailing white-spaces from unit issues helper test....
r5684 #
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 # 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.
Toshi MARUYAMA
remove trailing white-spaces from unit issues helper test....
r5684 #
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 # 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.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../../test_helper', __FILE__)
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Jean-Philippe Lang
Makes tests inherit from ActionView::TestCase....
r8157 class IssuesHelperTest < ActionView::TestCase
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 include ApplicationHelper
include IssuesHelper
Toshi MARUYAMA
test: include ERB::Util at test/unit/helpers/issues_helper_test.rb...
r8193 include ERB::Util
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
Rails3: replace "all" fixtures at test/unit/helpers/issues_helper_test.rb...
r7372 fixtures :projects, :trackers, :issue_statuses, :issues,
:enumerations, :users, :issue_categories,
:projects_trackers,
:roles,
:member_roles,
:members,
:enabled_modules,
:workflows
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
def setup
super
set_language_if_valid('en')
User.current = nil
end
Toshi MARUYAMA
remove trailing white-spaces from unit issues helper test....
r5684
Jean-Philippe Lang
Adds a helper for issue heading (#7647)....
r5327 def test_issue_heading
assert_equal "Bug #1", issue_heading(Issue.find(1))
end
Toshi MARUYAMA
remove trailing white-spaces from unit issues helper test....
r5684
Jean-Philippe Lang
Warn about subtasks before deleting a parent issue (#6562)....
r5375 def test_issues_destroy_confirmation_message_with_one_root_issue
assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1))
end
Toshi MARUYAMA
remove trailing white-spaces from unit issues helper test....
r5684
Jean-Philippe Lang
Warn about subtasks before deleting a parent issue (#6562)....
r5375 def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues
assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
end
Toshi MARUYAMA
remove trailing white-spaces from unit issues helper test....
r5684
Jean-Philippe Lang
Warn about subtasks before deleting a parent issue (#6562)....
r5375 def test_issues_destroy_confirmation_message_with_one_parent_issue
Issue.find(2).update_attribute :parent_issue_id, 1
assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1),
issues_destroy_confirmation_message(Issue.find(1))
end
Toshi MARUYAMA
remove trailing white-spaces from unit issues helper test....
r5684
Jean-Philippe Lang
Warn about subtasks before deleting a parent issue (#6562)....
r5375 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
Issue.find(2).update_attribute :parent_issue_id, 1
assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
context "IssuesHelper#show_detail" do
context "with no_html" do
should 'show a changing attribute' do
Jean-Philippe Lang
No need to save the record....
r8957 @detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 assert_equal "% Done changed from 40 to 100", show_detail(@detail, true)
end
should 'show a new attribute' do
Jean-Philippe Lang
No need to save the record....
r8957 @detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 assert_equal "% Done set to 100", show_detail(@detail, true)
end
should 'show a deleted attribute' do
Jean-Philippe Lang
No need to save the record....
r8957 @detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 assert_equal "% Done deleted (50)", show_detail(@detail, true)
end
end
context "with html" do
should 'show a changing attribute with HTML highlights' do
Jean-Philippe Lang
No need to save the record....
r8957 @detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
Jean-Philippe Lang
Makes tests inherit from ActionView::TestCase....
r8157 html = show_detail(@detail, false)
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Jean-Philippe Lang
Makes tests inherit from ActionView::TestCase....
r8157 assert_include '<strong>% Done</strong>', html
assert_include '<i>40</i>', html
assert_include '<i>100</i>', html
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 end
should 'show a new attribute with HTML highlights' do
Jean-Philippe Lang
No need to save the record....
r8957 @detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
Jean-Philippe Lang
Makes tests inherit from ActionView::TestCase....
r8157 html = show_detail(@detail, false)
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Jean-Philippe Lang
Makes tests inherit from ActionView::TestCase....
r8157 assert_include '<strong>% Done</strong>', html
assert_include '<i>100</i>', html
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 end
should 'show a deleted attribute with HTML highlights' do
Jean-Philippe Lang
No need to save the record....
r8957 @detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
Jean-Philippe Lang
Makes tests inherit from ActionView::TestCase....
r8157 html = show_detail(@detail, false)
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Jean-Philippe Lang
Makes tests inherit from ActionView::TestCase....
r8157 assert_include '<strong>% Done</strong>', html
assert_include '<strike><i>50</i></strike>', html
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 end
end
context "with a start_date attribute" do
should "format the current date" do
Jean-Philippe Lang
No need to save the record....
r8957 @detail = JournalDetail.new(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date')
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 assert_match "01/31/2010", show_detail(@detail, true)
end
should "format the old date" do
Jean-Philippe Lang
No need to save the record....
r8957 @detail = JournalDetail.new(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date')
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 assert_match "01/01/2010", show_detail(@detail, true)
end
end
context "with a due_date attribute" do
should "format the current date" do
Jean-Philippe Lang
No need to save the record....
r8957 @detail = JournalDetail.new(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date')
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 assert_match "01/31/2010", show_detail(@detail, true)
end
should "format the old date" do
Jean-Philippe Lang
No need to save the record....
r8957 @detail = JournalDetail.new(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date')
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 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