annotate .svn/pristine/ef/ef080ba0770e3cd764457ef43f3d15cbc219ecf1.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents e248c7af89ec
children
rev   line source
Chris@1494 1 # Redmine - project management software
Chris@1494 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1494 3 #
Chris@1494 4 # This program is free software; you can redistribute it and/or
Chris@1494 5 # modify it under the terms of the GNU General Public License
Chris@1494 6 # as published by the Free Software Foundation; either version 2
Chris@1494 7 # of the License, or (at your option) any later version.
Chris@1494 8 #
Chris@1494 9 # This program is distributed in the hope that it will be useful,
Chris@1494 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1494 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1494 12 # GNU General Public License for more details.
Chris@1494 13 #
Chris@1494 14 # You should have received a copy of the GNU General Public License
Chris@1494 15 # along with this program; if not, write to the Free Software
Chris@1494 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1494 17
Chris@1494 18 require File.expand_path('../../../test_helper', __FILE__)
Chris@1494 19
Chris@1494 20 class IssuesHelperTest < ActionView::TestCase
Chris@1494 21 include ApplicationHelper
Chris@1494 22 include Redmine::I18n
Chris@1494 23 include IssuesHelper
Chris@1494 24 include CustomFieldsHelper
Chris@1494 25 include ERB::Util
Chris@1494 26
Chris@1494 27 fixtures :projects, :trackers, :issue_statuses, :issues,
Chris@1494 28 :enumerations, :users, :issue_categories,
Chris@1494 29 :projects_trackers,
Chris@1494 30 :roles,
Chris@1494 31 :member_roles,
Chris@1494 32 :members,
Chris@1494 33 :enabled_modules,
Chris@1494 34 :custom_fields,
Chris@1494 35 :attachments,
Chris@1494 36 :versions
Chris@1494 37
Chris@1494 38 def setup
Chris@1494 39 super
Chris@1494 40 set_language_if_valid('en')
Chris@1494 41 User.current = nil
Chris@1494 42 end
Chris@1494 43
Chris@1494 44 def test_issue_heading
Chris@1494 45 assert_equal "Bug #1", issue_heading(Issue.find(1))
Chris@1494 46 end
Chris@1494 47
Chris@1494 48 def test_issues_destroy_confirmation_message_with_one_root_issue
Chris@1494 49 assert_equal l(:text_issues_destroy_confirmation),
Chris@1494 50 issues_destroy_confirmation_message(Issue.find(1))
Chris@1494 51 end
Chris@1494 52
Chris@1494 53 def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues
Chris@1494 54 assert_equal l(:text_issues_destroy_confirmation),
Chris@1494 55 issues_destroy_confirmation_message(Issue.find([1, 2]))
Chris@1494 56 end
Chris@1494 57
Chris@1494 58 def test_issues_destroy_confirmation_message_with_one_parent_issue
Chris@1494 59 Issue.find(2).update_attribute :parent_issue_id, 1
Chris@1494 60 assert_equal l(:text_issues_destroy_confirmation) + "\n" +
Chris@1494 61 l(:text_issues_destroy_descendants_confirmation, :count => 1),
Chris@1494 62 issues_destroy_confirmation_message(Issue.find(1))
Chris@1494 63 end
Chris@1494 64
Chris@1494 65 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
Chris@1494 66 Issue.find(2).update_attribute :parent_issue_id, 1
Chris@1494 67 assert_equal l(:text_issues_destroy_confirmation),
Chris@1494 68 issues_destroy_confirmation_message(Issue.find([1, 2]))
Chris@1494 69 end
Chris@1494 70
Chris@1494 71 test 'show_detail with no_html should show a changing attribute' do
Chris@1494 72 detail = JournalDetail.new(:property => 'attr', :old_value => '40',
Chris@1494 73 :value => '100', :prop_key => 'done_ratio')
Chris@1494 74 assert_equal "% Done changed from 40 to 100", show_detail(detail, true)
Chris@1494 75 end
Chris@1494 76
Chris@1494 77 test 'show_detail with no_html should show a new attribute' do
Chris@1494 78 detail = JournalDetail.new(:property => 'attr', :old_value => nil,
Chris@1494 79 :value => '100', :prop_key => 'done_ratio')
Chris@1494 80 assert_equal "% Done set to 100", show_detail(detail, true)
Chris@1494 81 end
Chris@1494 82
Chris@1494 83 test 'show_detail with no_html should show a deleted attribute' do
Chris@1494 84 detail = JournalDetail.new(:property => 'attr', :old_value => '50',
Chris@1494 85 :value => nil, :prop_key => 'done_ratio')
Chris@1494 86 assert_equal "% Done deleted (50)", show_detail(detail, true)
Chris@1494 87 end
Chris@1494 88
Chris@1494 89 test 'show_detail with html should show a changing attribute with HTML highlights' do
Chris@1494 90 detail = JournalDetail.new(:property => 'attr', :old_value => '40',
Chris@1494 91 :value => '100', :prop_key => 'done_ratio')
Chris@1494 92 html = show_detail(detail, false)
Chris@1494 93 assert_include '<strong>% Done</strong>', html
Chris@1494 94 assert_include '<i>40</i>', html
Chris@1494 95 assert_include '<i>100</i>', html
Chris@1494 96 end
Chris@1494 97
Chris@1494 98 test 'show_detail with html should show a new attribute with HTML highlights' do
Chris@1494 99 detail = JournalDetail.new(:property => 'attr', :old_value => nil,
Chris@1494 100 :value => '100', :prop_key => 'done_ratio')
Chris@1494 101 html = show_detail(detail, false)
Chris@1494 102 assert_include '<strong>% Done</strong>', html
Chris@1494 103 assert_include '<i>100</i>', html
Chris@1494 104 end
Chris@1494 105
Chris@1494 106 test 'show_detail with html should show a deleted attribute with HTML highlights' do
Chris@1494 107 detail = JournalDetail.new(:property => 'attr', :old_value => '50',
Chris@1494 108 :value => nil, :prop_key => 'done_ratio')
Chris@1494 109 html = show_detail(detail, false)
Chris@1494 110 assert_include '<strong>% Done</strong>', html
Chris@1494 111 assert_include '<del><i>50</i></del>', html
Chris@1494 112 end
Chris@1494 113
Chris@1494 114 test 'show_detail with a start_date attribute should format the dates' do
Chris@1494 115 detail = JournalDetail.new(
Chris@1494 116 :property => 'attr',
Chris@1494 117 :old_value => '2010-01-01',
Chris@1494 118 :value => '2010-01-31',
Chris@1494 119 :prop_key => 'start_date'
Chris@1494 120 )
Chris@1494 121 with_settings :date_format => '%m/%d/%Y' do
Chris@1494 122 assert_match "01/31/2010", show_detail(detail, true)
Chris@1494 123 assert_match "01/01/2010", show_detail(detail, true)
Chris@1494 124 end
Chris@1494 125 end
Chris@1494 126
Chris@1494 127 test 'show_detail with a due_date attribute should format the dates' do
Chris@1494 128 detail = JournalDetail.new(
Chris@1494 129 :property => 'attr',
Chris@1494 130 :old_value => '2010-01-01',
Chris@1494 131 :value => '2010-01-31',
Chris@1494 132 :prop_key => 'due_date'
Chris@1494 133 )
Chris@1494 134 with_settings :date_format => '%m/%d/%Y' do
Chris@1494 135 assert_match "01/31/2010", show_detail(detail, true)
Chris@1494 136 assert_match "01/01/2010", show_detail(detail, true)
Chris@1494 137 end
Chris@1494 138 end
Chris@1494 139
Chris@1494 140 test 'show_detail should show old and new values with a project attribute' do
Chris@1494 141 detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id',
Chris@1494 142 :old_value => 1, :value => 2)
Chris@1494 143 assert_match 'eCookbook', show_detail(detail, true)
Chris@1494 144 assert_match 'OnlineStore', show_detail(detail, true)
Chris@1494 145 end
Chris@1494 146
Chris@1494 147 test 'show_detail should show old and new values with a issue status attribute' do
Chris@1494 148 detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id',
Chris@1494 149 :old_value => 1, :value => 2)
Chris@1494 150 assert_match 'New', show_detail(detail, true)
Chris@1494 151 assert_match 'Assigned', show_detail(detail, true)
Chris@1494 152 end
Chris@1494 153
Chris@1494 154 test 'show_detail should show old and new values with a tracker attribute' do
Chris@1494 155 detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id',
Chris@1494 156 :old_value => 1, :value => 2)
Chris@1494 157 assert_match 'Bug', show_detail(detail, true)
Chris@1494 158 assert_match 'Feature request', show_detail(detail, true)
Chris@1494 159 end
Chris@1494 160
Chris@1494 161 test 'show_detail should show old and new values with a assigned to attribute' do
Chris@1494 162 detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id',
Chris@1494 163 :old_value => 1, :value => 2)
Chris@1494 164 assert_match 'Redmine Admin', show_detail(detail, true)
Chris@1494 165 assert_match 'John Smith', show_detail(detail, true)
Chris@1494 166 end
Chris@1494 167
Chris@1494 168 test 'show_detail should show old and new values with a priority attribute' do
Chris@1494 169 detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id',
Chris@1494 170 :old_value => 4, :value => 5)
Chris@1494 171 assert_match 'Low', show_detail(detail, true)
Chris@1494 172 assert_match 'Normal', show_detail(detail, true)
Chris@1494 173 end
Chris@1494 174
Chris@1494 175 test 'show_detail should show old and new values with a category attribute' do
Chris@1494 176 detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id',
Chris@1494 177 :old_value => 1, :value => 2)
Chris@1494 178 assert_match 'Printing', show_detail(detail, true)
Chris@1494 179 assert_match 'Recipes', show_detail(detail, true)
Chris@1494 180 end
Chris@1494 181
Chris@1494 182 test 'show_detail should show old and new values with a fixed version attribute' do
Chris@1494 183 detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id',
Chris@1494 184 :old_value => 1, :value => 2)
Chris@1494 185 assert_match '0.1', show_detail(detail, true)
Chris@1494 186 assert_match '1.0', show_detail(detail, true)
Chris@1494 187 end
Chris@1494 188
Chris@1494 189 test 'show_detail should show old and new values with a estimated hours attribute' do
Chris@1494 190 detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours',
Chris@1494 191 :old_value => '5', :value => '6.3')
Chris@1494 192 assert_match '5.00', show_detail(detail, true)
Chris@1494 193 assert_match '6.30', show_detail(detail, true)
Chris@1494 194 end
Chris@1494 195
Chris@1494 196 test 'show_detail should show old and new values with a custom field' do
Chris@1494 197 detail = JournalDetail.new(:property => 'cf', :prop_key => '1',
Chris@1494 198 :old_value => 'MySQL', :value => 'PostgreSQL')
Chris@1494 199 assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true)
Chris@1494 200 end
Chris@1494 201
Chris@1494 202 test 'show_detail should show added file' do
Chris@1494 203 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1',
Chris@1494 204 :old_value => nil, :value => 'error281.txt')
Chris@1494 205 assert_match 'error281.txt', show_detail(detail, true)
Chris@1494 206 end
Chris@1494 207
Chris@1494 208 test 'show_detail should show removed file' do
Chris@1494 209 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1',
Chris@1494 210 :old_value => 'error281.txt', :value => nil)
Chris@1494 211 assert_match 'error281.txt', show_detail(detail, true)
Chris@1494 212 end
Chris@1494 213
Chris@1494 214 def test_show_detail_relation_added
Chris@1494 215 detail = JournalDetail.new(:property => 'relation',
Chris@1494 216 :prop_key => 'label_precedes',
Chris@1494 217 :value => 1)
Chris@1494 218 assert_equal "Precedes Bug #1: Can't print recipes added", show_detail(detail, true)
Chris@1494 219 assert_match %r{<strong>Precedes</strong> <i><a href="/issues/1" class=".+">Bug #1</a>: Can&#x27;t print recipes</i> added},
Chris@1494 220 show_detail(detail, false)
Chris@1494 221 end
Chris@1494 222
Chris@1494 223 def test_show_detail_relation_added_with_inexistant_issue
Chris@1494 224 inexistant_issue_number = 9999
Chris@1494 225 assert_nil Issue.find_by_id(inexistant_issue_number)
Chris@1494 226 detail = JournalDetail.new(:property => 'relation',
Chris@1494 227 :prop_key => 'label_precedes',
Chris@1494 228 :value => inexistant_issue_number)
Chris@1494 229 assert_equal "Precedes Issue ##{inexistant_issue_number} added", show_detail(detail, true)
Chris@1494 230 assert_equal "<strong>Precedes</strong> <i>Issue ##{inexistant_issue_number}</i> added", show_detail(detail, false)
Chris@1494 231 end
Chris@1494 232
Chris@1494 233 def test_show_detail_relation_added_should_not_disclose_issue_that_is_not_visible
Chris@1494 234 issue = Issue.generate!(:is_private => true)
Chris@1494 235 detail = JournalDetail.new(:property => 'relation',
Chris@1494 236 :prop_key => 'label_precedes',
Chris@1494 237 :value => issue.id)
Chris@1494 238
Chris@1494 239 assert_equal "Precedes Issue ##{issue.id} added", show_detail(detail, true)
Chris@1494 240 assert_equal "<strong>Precedes</strong> <i>Issue ##{issue.id}</i> added", show_detail(detail, false)
Chris@1494 241 end
Chris@1494 242
Chris@1494 243 def test_show_detail_relation_deleted
Chris@1494 244 detail = JournalDetail.new(:property => 'relation',
Chris@1494 245 :prop_key => 'label_precedes',
Chris@1494 246 :old_value => 1)
Chris@1494 247 assert_equal "Precedes deleted (Bug #1: Can't print recipes)", show_detail(detail, true)
Chris@1494 248 assert_match %r{<strong>Precedes</strong> deleted \(<i><a href="/issues/1" class=".+">Bug #1</a>: Can&#x27;t print recipes</i>\)},
Chris@1494 249 show_detail(detail, false)
Chris@1494 250 end
Chris@1494 251
Chris@1494 252 def test_show_detail_relation_deleted_with_inexistant_issue
Chris@1494 253 inexistant_issue_number = 9999
Chris@1494 254 assert_nil Issue.find_by_id(inexistant_issue_number)
Chris@1494 255 detail = JournalDetail.new(:property => 'relation',
Chris@1494 256 :prop_key => 'label_precedes',
Chris@1494 257 :old_value => inexistant_issue_number)
Chris@1494 258 assert_equal "Precedes deleted (Issue #9999)", show_detail(detail, true)
Chris@1494 259 assert_equal "<strong>Precedes</strong> deleted (<i>Issue #9999</i>)", show_detail(detail, false)
Chris@1494 260 end
Chris@1494 261
Chris@1494 262 def test_show_detail_relation_deleted_should_not_disclose_issue_that_is_not_visible
Chris@1494 263 issue = Issue.generate!(:is_private => true)
Chris@1494 264 detail = JournalDetail.new(:property => 'relation',
Chris@1494 265 :prop_key => 'label_precedes',
Chris@1494 266 :old_value => issue.id)
Chris@1494 267
Chris@1494 268 assert_equal "Precedes deleted (Issue ##{issue.id})", show_detail(detail, true)
Chris@1494 269 assert_equal "<strong>Precedes</strong> deleted (<i>Issue ##{issue.id}</i>)", show_detail(detail, false)
Chris@1494 270 end
Chris@1494 271 end