annotate .svn/pristine/ce/ce3436e583ff12a4824d53281463f89ddea0a5e7.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 cbb26bc654de
children
rev   line source
Chris@909 1 # Redmine - project management software
Chris@909 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@909 3 #
Chris@909 4 # This program is free software; you can redistribute it and/or
Chris@909 5 # modify it under the terms of the GNU General Public License
Chris@909 6 # as published by the Free Software Foundation; either version 2
Chris@909 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@909 9 # This program is distributed in the hope that it will be useful,
Chris@909 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@909 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@909 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@909 14 # You should have received a copy of the GNU General Public License
Chris@909 15 # along with this program; if not, write to the Free Software
Chris@909 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@909 17
Chris@909 18 require File.expand_path('../../../test_helper', __FILE__)
Chris@909 19
Chris@909 20 class IssuesHelperTest < HelperTestCase
Chris@909 21 include ApplicationHelper
Chris@909 22 include IssuesHelper
Chris@909 23
Chris@909 24 include ActionController::Assertions::SelectorAssertions
Chris@909 25 fixtures :projects, :trackers, :issue_statuses, :issues,
Chris@909 26 :enumerations, :users, :issue_categories,
Chris@909 27 :projects_trackers,
Chris@909 28 :roles,
Chris@909 29 :member_roles,
Chris@909 30 :members,
Chris@909 31 :enabled_modules,
Chris@909 32 :workflows
Chris@909 33
Chris@909 34 # Used by assert_select
Chris@909 35 def html_document
Chris@909 36 HTML::Document.new(@response.body)
Chris@909 37 end
Chris@909 38
Chris@909 39 def setup
Chris@909 40 super
Chris@909 41 set_language_if_valid('en')
Chris@909 42 User.current = nil
Chris@909 43 @response = ActionController::TestResponse.new
Chris@909 44 end
Chris@909 45
Chris@909 46 def controller
Chris@909 47 @controller ||= IssuesController.new
Chris@909 48 end
Chris@909 49
Chris@909 50 def request
Chris@909 51 @request ||= ActionController::TestRequest.new
Chris@909 52 end
Chris@909 53
Chris@909 54 def test_issue_heading
Chris@909 55 assert_equal "Bug #1", issue_heading(Issue.find(1))
Chris@909 56 end
Chris@909 57
Chris@909 58 def test_issues_destroy_confirmation_message_with_one_root_issue
Chris@909 59 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1))
Chris@909 60 end
Chris@909 61
Chris@909 62 def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues
Chris@909 63 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
Chris@909 64 end
Chris@909 65
Chris@909 66 def test_issues_destroy_confirmation_message_with_one_parent_issue
Chris@909 67 Issue.find(2).update_attribute :parent_issue_id, 1
Chris@909 68 assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1),
Chris@909 69 issues_destroy_confirmation_message(Issue.find(1))
Chris@909 70 end
Chris@909 71
Chris@909 72 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
Chris@909 73 Issue.find(2).update_attribute :parent_issue_id, 1
Chris@909 74 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
Chris@909 75 end
Chris@909 76
Chris@909 77 context "IssuesHelper#show_detail" do
Chris@909 78 context "with no_html" do
Chris@909 79 should 'show a changing attribute' do
Chris@909 80 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
Chris@909 81 assert_equal "% Done changed from 40 to 100", show_detail(@detail, true)
Chris@909 82 end
Chris@909 83
Chris@909 84 should 'show a new attribute' do
Chris@909 85 @detail = JournalDetail.generate!(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
Chris@909 86 assert_equal "% Done set to 100", show_detail(@detail, true)
Chris@909 87 end
Chris@909 88
Chris@909 89 should 'show a deleted attribute' do
Chris@909 90 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
Chris@909 91 assert_equal "% Done deleted (50)", show_detail(@detail, true)
Chris@909 92 end
Chris@909 93 end
Chris@909 94
Chris@909 95 context "with html" do
Chris@909 96 should 'show a changing attribute with HTML highlights' do
Chris@909 97 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
Chris@909 98 @response.body = show_detail(@detail, false)
Chris@909 99
Chris@909 100 assert_select 'strong', :text => '% Done'
Chris@909 101 assert_select 'i', :text => '40'
Chris@909 102 assert_select 'i', :text => '100'
Chris@909 103 end
Chris@909 104
Chris@909 105 should 'show a new attribute with HTML highlights' do
Chris@909 106 @detail = JournalDetail.generate!(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
Chris@909 107 @response.body = show_detail(@detail, false)
Chris@909 108
Chris@909 109 assert_select 'strong', :text => '% Done'
Chris@909 110 assert_select 'i', :text => '100'
Chris@909 111 end
Chris@909 112
Chris@909 113 should 'show a deleted attribute with HTML highlights' do
Chris@909 114 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
Chris@909 115 @response.body = show_detail(@detail, false)
Chris@909 116
Chris@909 117 assert_select 'strong', :text => '% Done'
Chris@909 118 assert_select 'strike' do
Chris@909 119 assert_select 'i', :text => '50'
Chris@909 120 end
Chris@909 121 end
Chris@909 122 end
Chris@909 123
Chris@909 124 context "with a start_date attribute" do
Chris@909 125 should "format the current date" do
Chris@909 126 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date')
Chris@909 127 assert_match "01/31/2010", show_detail(@detail, true)
Chris@909 128 end
Chris@909 129
Chris@909 130 should "format the old date" do
Chris@909 131 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date')
Chris@909 132 assert_match "01/01/2010", show_detail(@detail, true)
Chris@909 133 end
Chris@909 134 end
Chris@909 135
Chris@909 136 context "with a due_date attribute" do
Chris@909 137 should "format the current date" do
Chris@909 138 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date')
Chris@909 139 assert_match "01/31/2010", show_detail(@detail, true)
Chris@909 140 end
Chris@909 141
Chris@909 142 should "format the old date" do
Chris@909 143 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date')
Chris@909 144 assert_match "01/01/2010", show_detail(@detail, true)
Chris@909 145 end
Chris@909 146 end
Chris@909 147
Chris@909 148 context "with a project attribute" do
Chris@909 149 should_show_the_old_and_new_values_for('project_id', Project)
Chris@909 150 end
Chris@909 151
Chris@909 152 context "with a issue status attribute" do
Chris@909 153 should_show_the_old_and_new_values_for('status_id', IssueStatus)
Chris@909 154 end
Chris@909 155
Chris@909 156 context "with a tracker attribute" do
Chris@909 157 should_show_the_old_and_new_values_for('tracker_id', Tracker)
Chris@909 158 end
Chris@909 159
Chris@909 160 context "with a assigned to attribute" do
Chris@909 161 should_show_the_old_and_new_values_for('assigned_to_id', User)
Chris@909 162 end
Chris@909 163
Chris@909 164 context "with a priority attribute" do
Chris@909 165 should_show_the_old_and_new_values_for('priority_id', IssuePriority) do
Chris@909 166 @old_value = IssuePriority.generate!(:type => 'IssuePriority')
Chris@909 167 @new_value = IssuePriority.generate!(:type => 'IssuePriority')
Chris@909 168 end
Chris@909 169 end
Chris@909 170
Chris@909 171 context "with a category attribute" do
Chris@909 172 should_show_the_old_and_new_values_for('category_id', IssueCategory)
Chris@909 173 end
Chris@909 174
Chris@909 175 context "with a fixed version attribute" do
Chris@909 176 should_show_the_old_and_new_values_for('fixed_version_id', Version)
Chris@909 177 end
Chris@909 178
Chris@909 179 context "with a estimated hours attribute" do
Chris@909 180 should "format the time into two decimal places"
Chris@909 181 should "format the old time into two decimal places"
Chris@909 182 end
Chris@909 183
Chris@909 184 should "test custom fields"
Chris@909 185 should "test attachments"
Chris@909 186
Chris@909 187 end
Chris@909 188
Chris@909 189 end