##// END OF EJS Templates
Fixed: escaped link in conflict resolution form (#11341)....
Jean-Philippe Lang -
r9742:5981aee06de0
parent child
Show More
@@ -1,26 +1,26
1 1 <div class="conflict">
2 2 <%= l(:notice_issue_update_conflict) %>
3 3 <% if @conflict_journals.present? %>
4 4 <div class="conflict-details">
5 5 <% @conflict_journals.sort_by(&:id).each do |journal| %>
6 6 <p><%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %></p>
7 7 <% if journal.details.any? %>
8 8 <ul class="details">
9 9 <% details_to_strings(journal.details).each do |string| %>
10 10 <li><%= string %></li>
11 11 <% end %>
12 12 </ul>
13 13 <% end %>
14 14 <%= textilizable(journal, :notes) unless journal.notes.blank? %>
15 15 <% end %>
16 16 </div>
17 17 <% end %>
18 18 </div>
19 19 <p>
20 20 <label><%= radio_button_tag 'conflict_resolution', 'overwrite' %> <%= l(:text_issue_conflict_resolution_overwrite) %></label><br />
21 21 <% if @notes.present? %>
22 22 <label><%= radio_button_tag 'conflict_resolution', 'add_notes' %> <%= l(:text_issue_conflict_resolution_add_notes) %></label><br />
23 23 <% end %>
24 <label><%= radio_button_tag 'conflict_resolution', 'cancel' %> <%= l(:text_issue_conflict_resolution_cancel, :link => link_to_issue(@issue, :subject => false)) %></label>
24 <label><%= radio_button_tag 'conflict_resolution', 'cancel' %> <%= l(:text_issue_conflict_resolution_cancel, :link => link_to_issue(@issue, :subject => false)).html_safe %></label>
25 25 </p>
26 26 <p><%= submit_tag l(:button_submit) %></p>
@@ -1,232 +1,236
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19 require 'issues_controller'
20 20
21 21 class IssuesControllerTransactionTest < ActionController::TestCase
22 22 fixtures :projects,
23 23 :users,
24 24 :roles,
25 25 :members,
26 26 :member_roles,
27 27 :issues,
28 28 :issue_statuses,
29 29 :versions,
30 30 :trackers,
31 31 :projects_trackers,
32 32 :issue_categories,
33 33 :enabled_modules,
34 34 :enumerations,
35 35 :attachments,
36 36 :workflows,
37 37 :custom_fields,
38 38 :custom_values,
39 39 :custom_fields_projects,
40 40 :custom_fields_trackers,
41 41 :time_entries,
42 42 :journals,
43 43 :journal_details,
44 44 :queries
45 45
46 46 self.use_transactional_fixtures = false
47 47
48 48 def setup
49 49 @controller = IssuesController.new
50 50 @request = ActionController::TestRequest.new
51 51 @response = ActionController::TestResponse.new
52 52 User.current = nil
53 53 end
54 54
55 55 def test_update_stale_issue_should_not_update_the_issue
56 56 issue = Issue.find(2)
57 57 @request.session[:user_id] = 2
58 58
59 59 assert_no_difference 'Journal.count' do
60 60 assert_no_difference 'TimeEntry.count' do
61 61 put :update,
62 62 :id => issue.id,
63 63 :issue => {
64 64 :fixed_version_id => 4,
65 65 :lock_version => (issue.lock_version - 1)
66 66 },
67 67 :notes => 'My notes',
68 68 :time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id }
69 69 end
70 70 end
71 71
72 72 assert_response :success
73 73 assert_template 'edit'
74 assert_tag 'div', :attributes => {:class => 'conflict'}
75 assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'overwrite'}
76 assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'add_notes'}
77 assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'cancel'}
74
75 assert_select 'div.conflict'
76 assert_select 'input[name=?][value=?]', 'conflict_resolution', 'overwrite'
77 assert_select 'input[name=?][value=?]', 'conflict_resolution', 'add_notes'
78 assert_select 'label' do
79 assert_select 'input[name=?][value=?]', 'conflict_resolution', 'cancel'
80 assert_select 'a[href=/issues/2]'
81 end
78 82 end
79 83
80 84 def test_update_stale_issue_should_save_attachments
81 85 set_tmp_attachments_directory
82 86 issue = Issue.find(2)
83 87 @request.session[:user_id] = 2
84 88
85 89 assert_no_difference 'Journal.count' do
86 90 assert_no_difference 'TimeEntry.count' do
87 91 assert_difference 'Attachment.count' do
88 92 put :update,
89 93 :id => issue.id,
90 94 :issue => {
91 95 :fixed_version_id => 4,
92 96 :lock_version => (issue.lock_version - 1)
93 97 },
94 98 :notes => 'My notes',
95 99 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}},
96 100 :time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id }
97 101 end
98 102 end
99 103 end
100 104
101 105 assert_response :success
102 106 assert_template 'edit'
103 107 attachment = Attachment.first(:order => 'id DESC')
104 108 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
105 109 assert_tag 'span', :content => /testfile.txt/
106 110 end
107 111
108 112 def test_update_stale_issue_without_notes_should_not_show_add_notes_option
109 113 issue = Issue.find(2)
110 114 @request.session[:user_id] = 2
111 115
112 116 put :update, :id => issue.id,
113 117 :issue => {
114 118 :fixed_version_id => 4,
115 119 :lock_version => (issue.lock_version - 1)
116 120 },
117 121 :notes => ''
118 122
119 123 assert_tag 'div', :attributes => {:class => 'conflict'}
120 124 assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'overwrite'}
121 125 assert_no_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'add_notes'}
122 126 assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'cancel'}
123 127
124 128 end
125 129
126 130 def test_update_stale_issue_should_show_conflicting_journals
127 131 @request.session[:user_id] = 2
128 132
129 133 put :update, :id => 1,
130 134 :issue => {
131 135 :fixed_version_id => 4,
132 136 :lock_version => 2
133 137 },
134 138 :notes => '',
135 139 :last_journal_id => 1
136 140
137 141 assert_not_nil assigns(:conflict_journals)
138 142 assert_equal 1, assigns(:conflict_journals).size
139 143 assert_equal 2, assigns(:conflict_journals).first.id
140 144 assert_tag 'div', :attributes => {:class => 'conflict'},
141 145 :descendant => {:content => /Some notes with Redmine links/}
142 146 end
143 147
144 148 def test_update_stale_issue_without_previous_journal_should_show_all_journals
145 149 @request.session[:user_id] = 2
146 150
147 151 put :update, :id => 1,
148 152 :issue => {
149 153 :fixed_version_id => 4,
150 154 :lock_version => 2
151 155 },
152 156 :notes => '',
153 157 :last_journal_id => ''
154 158
155 159 assert_not_nil assigns(:conflict_journals)
156 160 assert_equal 2, assigns(:conflict_journals).size
157 161 assert_tag 'div', :attributes => {:class => 'conflict'},
158 162 :descendant => {:content => /Some notes with Redmine links/}
159 163 assert_tag 'div', :attributes => {:class => 'conflict'},
160 164 :descendant => {:content => /Journal notes/}
161 165 end
162 166
163 167 def test_update_stale_issue_with_overwrite_conflict_resolution_should_update
164 168 @request.session[:user_id] = 2
165 169
166 170 assert_difference 'Journal.count' do
167 171 put :update, :id => 1,
168 172 :issue => {
169 173 :fixed_version_id => 4,
170 174 :lock_version => 2
171 175 },
172 176 :notes => 'overwrite_conflict_resolution',
173 177 :conflict_resolution => 'overwrite'
174 178 end
175 179
176 180 assert_response 302
177 181 issue = Issue.find(1)
178 182 assert_equal 4, issue.fixed_version_id
179 183 journal = Journal.first(:order => 'id DESC')
180 184 assert_equal 'overwrite_conflict_resolution', journal.notes
181 185 assert journal.details.any?
182 186 end
183 187
184 188 def test_update_stale_issue_with_add_notes_conflict_resolution_should_update
185 189 @request.session[:user_id] = 2
186 190
187 191 assert_difference 'Journal.count' do
188 192 put :update, :id => 1,
189 193 :issue => {
190 194 :fixed_version_id => 4,
191 195 :lock_version => 2
192 196 },
193 197 :notes => 'add_notes_conflict_resolution',
194 198 :conflict_resolution => 'add_notes'
195 199 end
196 200
197 201 assert_response 302
198 202 issue = Issue.find(1)
199 203 assert_nil issue.fixed_version_id
200 204 journal = Journal.first(:order => 'id DESC')
201 205 assert_equal 'add_notes_conflict_resolution', journal.notes
202 206 assert journal.details.empty?
203 207 end
204 208
205 209 def test_update_stale_issue_with_cancel_conflict_resolution_should_redirect_without_updating
206 210 @request.session[:user_id] = 2
207 211
208 212 assert_no_difference 'Journal.count' do
209 213 put :update, :id => 1,
210 214 :issue => {
211 215 :fixed_version_id => 4,
212 216 :lock_version => 2
213 217 },
214 218 :notes => 'add_notes_conflict_resolution',
215 219 :conflict_resolution => 'cancel'
216 220 end
217 221
218 222 assert_redirected_to '/issues/1'
219 223 issue = Issue.find(1)
220 224 assert_nil issue.fixed_version_id
221 225 end
222 226
223 227 def test_index_should_rescue_invalid_sql_query
224 228 Query.any_instance.stubs(:statement).returns("INVALID STATEMENT")
225 229
226 230 get :index
227 231 assert_response 500
228 232 assert_tag 'p', :content => /An error occurred/
229 233 assert_nil session[:query]
230 234 assert_nil session[:issues_index_sort]
231 235 end
232 236 end
General Comments 0
You need to be logged in to leave comments. Login now