##// END OF EJS Templates
The descendant count in the issues delete confirmation message is wrong if issues share some descendants....
The descendant count in the issues delete confirmation message is wrong if issues share some descendants. git-svn-id: http://svn.redmine.org/redmine/trunk@13818 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r13436:bfdd9f7c295d
r13436:bfdd9f7c295d
Show More
issues_helper_test.rb
285 lines | 12.4 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
Toshi MARUYAMA
update copyright year (#15977)...
r12461 # Copyright (C) 2006-2014 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
Jean-Philippe Lang
Include Redmine::I18n in helpers tests....
r11645 include Redmine::I18n
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 include IssuesHelper
Jean-Philippe Lang
Additional tests for IssuesHelper#show_detail....
r9332 include CustomFieldsHelper
Toshi MARUYAMA
test: include ERB::Util at test/unit/helpers/issues_helper_test.rb...
r8193 include ERB::Util
Toshi MARUYAMA
make IssuesHelperTest passes when config.threadsafe! is enabled (#12097)...
r12152 include Rails.application.routes.url_helpers
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,
Jean-Philippe Lang
Additional tests for IssuesHelper#show_detail....
r9332 :custom_fields,
Jean-Philippe Lang
html5 compliance....
r9927 :attachments,
:versions
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
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 assert_equal l(:text_issues_destroy_confirmation),
issues_destroy_confirmation_message(Issue.find(1))
Jean-Philippe Lang
Warn about subtasks before deleting a parent issue (#6562)....
r5375 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
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 assert_equal l(:text_issues_destroy_confirmation),
issues_destroy_confirmation_message(Issue.find([1, 2]))
Jean-Philippe Lang
Warn about subtasks before deleting a parent issue (#6562)....
r5375 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
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 assert_equal l(:text_issues_destroy_confirmation) + "\n" +
l(:text_issues_destroy_descendants_confirmation, :count => 1),
issues_destroy_confirmation_message(Issue.find(1))
Jean-Philippe Lang
Warn about subtasks before deleting a parent issue (#6562)....
r5375 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
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 assert_equal l(:text_issues_destroy_confirmation),
issues_destroy_confirmation_message(Issue.find([1, 2]))
Jean-Philippe Lang
Warn about subtasks before deleting a parent issue (#6562)....
r5375 end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Jean-Philippe Lang
The descendant count in the issues delete confirmation message is wrong if issues share some descendants....
r13436 def test_issues_destroy_confirmation_message_with_issues_that_share_descendants
root = Issue.generate!
child = Issue.generate!(:parent_issue_id => root.id)
Issue.generate!(:parent_issue_id => child.id)
assert_equal l(:text_issues_destroy_confirmation) + "\n" +
l(:text_issues_destroy_descendants_confirmation, :count => 1),
issues_destroy_confirmation_message([root.reload, child.reload])
end
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail with no_html should show a changing attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :old_value => '40',
:value => '100', :prop_key => 'done_ratio')
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_equal "% Done changed from 40 to 100", show_detail(detail, true)
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail with no_html should show a new attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :old_value => nil,
:value => '100', :prop_key => 'done_ratio')
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_equal "% Done set to 100", show_detail(detail, true)
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail with no_html should show a deleted attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :old_value => '50',
:value => nil, :prop_key => 'done_ratio')
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_equal "% Done deleted (50)", show_detail(detail, true)
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail with html should show a changing attribute with HTML highlights' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :old_value => '40',
:value => '100', :prop_key => 'done_ratio')
Jean-Philippe Lang
Removing shoulda context....
r11089 html = show_detail(detail, false)
assert_include '<strong>% Done</strong>', html
assert_include '<i>40</i>', html
assert_include '<i>100</i>', html
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail with html should show a new attribute with HTML highlights' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :old_value => nil,
:value => '100', :prop_key => 'done_ratio')
Jean-Philippe Lang
Removing shoulda context....
r11089 html = show_detail(detail, false)
assert_include '<strong>% Done</strong>', html
assert_include '<i>100</i>', html
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail with html should show a deleted attribute with HTML highlights' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :old_value => '50',
:value => nil, :prop_key => 'done_ratio')
Jean-Philippe Lang
Removing shoulda context....
r11089 html = show_detail(detail, false)
assert_include '<strong>% Done</strong>', html
assert_include '<del><i>50</i></del>', html
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail with a start_date attribute should format the dates' do
Jean-Philippe Lang
Removing shoulda context....
r11089 detail = JournalDetail.new(
:property => 'attr',
:old_value => '2010-01-01',
:value => '2010-01-31',
:prop_key => 'start_date'
)
with_settings :date_format => '%m/%d/%Y' do
assert_match "01/31/2010", show_detail(detail, true)
assert_match "01/01/2010", show_detail(detail, true)
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 end
Jean-Philippe Lang
Removing shoulda context....
r11089 end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail with a due_date attribute should format the dates' do
Jean-Philippe Lang
Removing shoulda context....
r11089 detail = JournalDetail.new(
:property => 'attr',
:old_value => '2010-01-01',
:value => '2010-01-31',
:prop_key => 'due_date'
)
with_settings :date_format => '%m/%d/%Y' do
assert_match "01/31/2010", show_detail(detail, true)
assert_match "01/01/2010", show_detail(detail, true)
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 end
Jean-Philippe Lang
Removing shoulda context....
r11089 end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show old and new values with a project attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id',
:old_value => 1, :value => 2)
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_match 'eCookbook', show_detail(detail, true)
assert_match 'OnlineStore', show_detail(detail, true)
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show old and new values with a issue status attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id',
:old_value => 1, :value => 2)
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_match 'New', show_detail(detail, true)
assert_match 'Assigned', show_detail(detail, true)
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show old and new values with a tracker attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id',
:old_value => 1, :value => 2)
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_match 'Bug', show_detail(detail, true)
assert_match 'Feature request', show_detail(detail, true)
end
Jean-Philippe Lang
Additional tests for IssuesHelper#show_detail....
r9332
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show old and new values with a assigned to attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id',
:old_value => 1, :value => 2)
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_match 'Redmine Admin', show_detail(detail, true)
assert_match 'John Smith', show_detail(detail, true)
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show old and new values with a priority attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id',
:old_value => 4, :value => 5)
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_match 'Low', show_detail(detail, true)
assert_match 'Normal', show_detail(detail, true)
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show old and new values with a category attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id',
:old_value => 1, :value => 2)
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_match 'Printing', show_detail(detail, true)
assert_match 'Recipes', show_detail(detail, true)
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show old and new values with a fixed version attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id',
:old_value => 1, :value => 2)
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_match '0.1', show_detail(detail, true)
assert_match '1.0', show_detail(detail, true)
end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show old and new values with a estimated hours attribute' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours',
:old_value => '5', :value => '6.3')
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_match '5.00', show_detail(detail, true)
assert_match '6.30', show_detail(detail, true)
end
Jean-Philippe Lang
Additional tests for IssuesHelper#show_detail....
r9332
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show old and new values with a custom field' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'cf', :prop_key => '1',
:old_value => 'MySQL', :value => 'PostgreSQL')
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true)
end
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show added file' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1',
:old_value => nil, :value => 'error281.txt')
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_match 'error281.txt', show_detail(detail, true)
end
Toshi MARUYAMA
remove redundant 'IssuesHelper#' from issues_helper_test context...
r11484 test 'show_detail should show removed file' do
Toshi MARUYAMA
code layout clean up issues_helper_test.rb...
r11483 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1',
:old_value => 'error281.txt', :value => nil)
Jean-Philippe Lang
Removing shoulda context....
r11089 assert_match 'error281.txt', show_detail(detail, true)
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 end
Toshi MARUYAMA
add journal after creating/deleting issue relation (#1005)...
r11655
Jean-Philippe Lang
Splits tests (#1005)....
r11711 def test_show_detail_relation_added
Toshi MARUYAMA
add journal after creating/deleting issue relation (#1005)...
r11655 detail = JournalDetail.new(:property => 'relation',
Jean-Philippe Lang
Store relation type instead of i18n key in journals (#15704)....
r12141 :prop_key => 'precedes',
Toshi MARUYAMA
add journal after creating/deleting issue relation (#1005)...
r11655 :value => 1)
Jean-Philippe Lang
Removed that quote in a fixture subject....
r13393 assert_equal "Precedes Bug #1: Cannot print recipes added", show_detail(detail, true)
Toshi MARUYAMA
Rails4: replace hard-coded html with class at IssuesHelperTest...
r12597 str = link_to("Bug #1", "/issues/1", :class => Issue.find(1).css_classes)
Jean-Philippe Lang
Removed that quote in a fixture subject....
r13393 assert_equal "<strong>Precedes</strong> <i>#{str}: Cannot print recipes</i> added",
Toshi MARUYAMA
Rails4: replace hard-coded html with class at IssuesHelperTest...
r12597 show_detail(detail, false)
Jean-Philippe Lang
Splits tests (#1005)....
r11711 end
def test_show_detail_relation_added_with_inexistant_issue
inexistant_issue_number = 9999
assert_nil Issue.find_by_id(inexistant_issue_number)
Toshi MARUYAMA
add journal after creating/deleting issue relation (#1005)...
r11655 detail = JournalDetail.new(:property => 'relation',
Jean-Philippe Lang
Store relation type instead of i18n key in journals (#15704)....
r12141 :prop_key => 'precedes',
Jean-Philippe Lang
Splits tests (#1005)....
r11711 :value => inexistant_issue_number)
assert_equal "Precedes Issue ##{inexistant_issue_number} added", show_detail(detail, true)
assert_equal "<strong>Precedes</strong> <i>Issue ##{inexistant_issue_number}</i> added", show_detail(detail, false)
Toshi MARUYAMA
add journal after creating/deleting issue relation (#1005)...
r11655 end
Jean-Philippe Lang
Fixed that journal details about issue relations may disclose issues that are not visible (#1005)....
r11709 def test_show_detail_relation_added_should_not_disclose_issue_that_is_not_visible
issue = Issue.generate!(:is_private => true)
detail = JournalDetail.new(:property => 'relation',
Jean-Philippe Lang
Store relation type instead of i18n key in journals (#15704)....
r12141 :prop_key => 'precedes',
Jean-Philippe Lang
Fixed that journal details about issue relations may disclose issues that are not visible (#1005)....
r11709 :value => issue.id)
Jean-Philippe Lang
Prepends issue numbers with a number sign (#1005)....
r11710 assert_equal "Precedes Issue ##{issue.id} added", show_detail(detail, true)
assert_equal "<strong>Precedes</strong> <i>Issue ##{issue.id}</i> added", show_detail(detail, false)
Jean-Philippe Lang
Fixed that journal details about issue relations may disclose issues that are not visible (#1005)....
r11709 end
Jean-Philippe Lang
Splits tests (#1005)....
r11711 def test_show_detail_relation_deleted
Toshi MARUYAMA
add journal after creating/deleting issue relation (#1005)...
r11655 detail = JournalDetail.new(:property => 'relation',
Jean-Philippe Lang
Store relation type instead of i18n key in journals (#15704)....
r12141 :prop_key => 'precedes',
Toshi MARUYAMA
add journal after creating/deleting issue relation (#1005)...
r11655 :old_value => 1)
Jean-Philippe Lang
Removed that quote in a fixture subject....
r13393 assert_equal "Precedes deleted (Bug #1: Cannot print recipes)", show_detail(detail, true)
Toshi MARUYAMA
Rails4: replace hard-coded html with class at IssuesHelperTest...
r12597 str = link_to("Bug #1",
"/issues/1",
:class => Issue.find(1).css_classes)
Jean-Philippe Lang
Removed that quote in a fixture subject....
r13393 assert_equal "<strong>Precedes</strong> deleted (<i>#{str}: Cannot print recipes</i>)",
Toshi MARUYAMA
add journal after creating/deleting issue relation (#1005)...
r11655 show_detail(detail, false)
Jean-Philippe Lang
Splits tests (#1005)....
r11711 end
def test_show_detail_relation_deleted_with_inexistant_issue
inexistant_issue_number = 9999
assert_nil Issue.find_by_id(inexistant_issue_number)
Toshi MARUYAMA
add journal after creating/deleting issue relation (#1005)...
r11655 detail = JournalDetail.new(:property => 'relation',
Jean-Philippe Lang
Store relation type instead of i18n key in journals (#15704)....
r12141 :prop_key => 'precedes',
Jean-Philippe Lang
Splits tests (#1005)....
r11711 :old_value => inexistant_issue_number)
Jean-Philippe Lang
Prepends issue numbers with a number sign (#1005)....
r11710 assert_equal "Precedes deleted (Issue #9999)", show_detail(detail, true)
assert_equal "<strong>Precedes</strong> deleted (<i>Issue #9999</i>)", show_detail(detail, false)
Toshi MARUYAMA
add journal after creating/deleting issue relation (#1005)...
r11655 end
Jean-Philippe Lang
Fixed that journal details about issue relations may disclose issues that are not visible (#1005)....
r11709
def test_show_detail_relation_deleted_should_not_disclose_issue_that_is_not_visible
issue = Issue.generate!(:is_private => true)
detail = JournalDetail.new(:property => 'relation',
Jean-Philippe Lang
Store relation type instead of i18n key in journals (#15704)....
r12141 :prop_key => 'precedes',
Jean-Philippe Lang
Fixed that journal details about issue relations may disclose issues that are not visible (#1005)....
r11709 :old_value => issue.id)
Jean-Philippe Lang
Prepends issue numbers with a number sign (#1005)....
r11710 assert_equal "Precedes deleted (Issue ##{issue.id})", show_detail(detail, true)
assert_equal "<strong>Precedes</strong> deleted (<i>Issue ##{issue.id}</i>)", show_detail(detail, false)
Jean-Philippe Lang
Fixed that journal details about issue relations may disclose issues that are not visible (#1005)....
r11709 end
Eric Davis
Added unit tests for IssuesHelper#show_detail...
r3438 end