annotate .svn/pristine/f7/f7995108bacea37dbc5acbe00e76ee4c384f6a06.svn-base @ 1327:287f201c2802 redmine-2.2-integration

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