comparison test/integration/.svn/text-base/issues_test.rb.svn-base @ 514:7eba09d624db live

Merge
author Chris Cannam
date Thu, 14 Jul 2011 10:50:53 +0100
parents cbce1fd3b1b7
children
comparison
equal deleted inserted replaced
512:b9aebdd7dd40 514:7eba09d624db
1 # redMine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
13 # 13 #
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 require "#{File.dirname(__FILE__)}/../test_helper" 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 class IssuesTest < ActionController::IntegrationTest 20 class IssuesTest < ActionController::IntegrationTest
21 fixtures :projects, 21 fixtures :projects,
22 :users, 22 :users,
23 :roles, 23 :roles,
63 assert_equal 1, issue.project.id 63 assert_equal 1, issue.project.id
64 assert_equal 1, issue.status.id 64 assert_equal 1, issue.status.id
65 end 65 end
66 66
67 # add then remove 2 attachments to an issue 67 # add then remove 2 attachments to an issue
68 def test_issue_attachements 68 def test_issue_attachments
69 log_user('jsmith', 'jsmith') 69 log_user('jsmith', 'jsmith')
70 set_tmp_attachments_directory 70 set_tmp_attachments_directory
71 71
72 put 'issues/1', 72 put 'issues/1',
73 :notes => 'Some notes', 73 :notes => 'Some notes',
124 124
125 assert_tag :a, :content => '2', 125 assert_tag :a, :content => '2',
126 :attributes => { :href => '/projects/ecookbook/issues?page=2' } 126 :attributes => { :href => '/projects/ecookbook/issues?page=2' }
127 127
128 end 128 end
129
130 def test_issue_with_user_custom_field
131 @field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true, :trackers => Tracker.all)
132 Role.anonymous.add_permission! :add_issues, :edit_issues
133 users = Project.find(1).users
134 tester = users.first
135
136 # Issue form
137 get '/projects/ecookbook/issues/new'
138 assert_response :success
139 assert_tag :select,
140 :attributes => {:name => "issue[custom_field_values][#{@field.id}]"},
141 :children => {:count => (users.size + 1)}, # +1 for blank value
142 :child => {
143 :tag => 'option',
144 :attributes => {:value => tester.id.to_s},
145 :content => tester.name
146 }
147
148 # Create issue
149 assert_difference 'Issue.count' do
150 post '/projects/ecookbook/issues',
151 :issue => {
152 :tracker_id => '1',
153 :priority_id => '4',
154 :subject => 'Issue with user custom field',
155 :custom_field_values => {@field.id.to_s => users.first.id.to_s}
156 }
157 end
158 issue = Issue.first(:order => 'id DESC')
159 assert_response 302
160
161 # Issue view
162 follow_redirect!
163 assert_tag :th,
164 :content => /Tester/,
165 :sibling => {
166 :tag => 'td',
167 :content => tester.name
168 }
169 assert_tag :select,
170 :attributes => {:name => "issue[custom_field_values][#{@field.id}]"},
171 :children => {:count => (users.size + 1)}, # +1 for blank value
172 :child => {
173 :tag => 'option',
174 :attributes => {:value => tester.id.to_s, :selected => 'selected'},
175 :content => tester.name
176 }
177
178 # Update issue
179 new_tester = users[1]
180 assert_difference 'Journal.count' do
181 put "/issues/#{issue.id}",
182 :notes => 'Updating custom field',
183 :issue => {
184 :custom_field_values => {@field.id.to_s => new_tester.id.to_s}
185 }
186 end
187 assert_response 302
188
189 # Issue view
190 follow_redirect!
191 assert_tag :content => 'Tester',
192 :ancestor => {:tag => 'ul', :attributes => {:class => /details/}},
193 :sibling => {
194 :content => tester.name,
195 :sibling => {
196 :content => new_tester.name
197 }
198 }
199 end
129 end 200 end