annotate .svn/pristine/f7/f7995108bacea37dbc5acbe00e76ee4c384f6a06.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

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