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