@@ -34,7 +34,8 class UserTest < ActiveSupport::TestCase | |||
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | def test_sorted_scope_should_sort_user_by_display_name |
|
37 |
assert_equal User.all.map(&:name).map(&:downcase).sort, |
|
|
37 | assert_equal User.all.map(&:name).map(&:downcase).sort, | |
|
38 | User.sorted.all.map(&:name).map(&:downcase) | |
|
38 | 39 | end |
|
39 | 40 | |
|
40 | 41 | def test_generate |
@@ -138,7 +139,8 class UserTest < ActiveSupport::TestCase | |||
|
138 | 139 | u.login = 'newuser' |
|
139 | 140 | u.password, u.password_confirmation = "password", "password" |
|
140 | 141 | assert u.save |
|
141 |
u = User.new(:firstname => "Similar", :lastname => "User", |
|
|
142 | u = User.new(:firstname => "Similar", :lastname => "User", | |
|
143 | :mail => "similaruser@somenet.foo") | |
|
142 | 144 | u.login = 'NewUser' |
|
143 | 145 | u.password, u.password_confirmation = "password", "password" |
|
144 | 146 | assert !u.save |
@@ -207,7 +209,8 class UserTest < ActiveSupport::TestCase | |||
|
207 | 209 | |
|
208 | 210 | def test_destroy_should_update_comments |
|
209 | 211 | comment = Comment.create!( |
|
210 |
:commented => News.create!(:project_id => 1, |
|
|
212 | :commented => News.create!(:project_id => 1, | |
|
213 | :author_id => 1, :title => 'foo', :description => 'foo'), | |
|
211 | 214 | :author => User.find(2), |
|
212 | 215 | :comments => 'foo' |
|
213 | 216 | ) |
@@ -218,7 +221,8 class UserTest < ActiveSupport::TestCase | |||
|
218 | 221 | end |
|
219 | 222 | |
|
220 | 223 | def test_destroy_should_update_issues |
|
221 |
issue = Issue.create!(:project_id => 1, :author_id => 2, |
|
|
224 | issue = Issue.create!(:project_id => 1, :author_id => 2, | |
|
225 | :tracker_id => 1, :subject => 'foo') | |
|
222 | 226 | |
|
223 | 227 | User.find(2).destroy |
|
224 | 228 | assert_nil User.find_by_id(2) |
@@ -226,7 +230,8 class UserTest < ActiveSupport::TestCase | |||
|
226 | 230 | end |
|
227 | 231 | |
|
228 | 232 | def test_destroy_should_unassign_issues |
|
229 |
issue = Issue.create!(:project_id => 1, :author_id => 1, |
|
|
233 | issue = Issue.create!(:project_id => 1, :author_id => 1, | |
|
234 | :tracker_id => 1, :subject => 'foo', :assigned_to_id => 2) | |
|
230 | 235 | |
|
231 | 236 | User.find(2).destroy |
|
232 | 237 | assert_nil User.find_by_id(2) |
@@ -234,7 +239,8 class UserTest < ActiveSupport::TestCase | |||
|
234 | 239 | end |
|
235 | 240 | |
|
236 | 241 | def test_destroy_should_update_journals |
|
237 |
issue = Issue.create!(:project_id => 1, :author_id => 2, |
|
|
242 | issue = Issue.create!(:project_id => 1, :author_id => 2, | |
|
243 | :tracker_id => 1, :subject => 'foo') | |
|
238 | 244 | issue.init_journal(User.find(2), "update") |
|
239 | 245 | issue.save! |
|
240 | 246 | |
@@ -244,7 +250,8 class UserTest < ActiveSupport::TestCase | |||
|
244 | 250 | end |
|
245 | 251 | |
|
246 | 252 | def test_destroy_should_update_journal_details_old_value |
|
247 |
issue = Issue.create!(:project_id => 1, :author_id => 1, |
|
|
253 | issue = Issue.create!(:project_id => 1, :author_id => 1, | |
|
254 | :tracker_id => 1, :subject => 'foo', :assigned_to_id => 2) | |
|
248 | 255 | issue.init_journal(User.find(1), "update") |
|
249 | 256 | issue.assigned_to_id = nil |
|
250 | 257 | assert_difference 'JournalDetail.count' do |
@@ -259,7 +266,8 class UserTest < ActiveSupport::TestCase | |||
|
259 | 266 | end |
|
260 | 267 | |
|
261 | 268 | def test_destroy_should_update_journal_details_value |
|
262 |
issue = Issue.create!(:project_id => 1, :author_id => 1, |
|
|
269 | issue = Issue.create!(:project_id => 1, :author_id => 1, | |
|
270 | :tracker_id => 1, :subject => 'foo') | |
|
263 | 271 | issue.init_journal(User.find(1), "update") |
|
264 | 272 | issue.assigned_to_id = 2 |
|
265 | 273 | assert_difference 'JournalDetail.count' do |
@@ -275,16 +283,16 class UserTest < ActiveSupport::TestCase | |||
|
275 | 283 | |
|
276 | 284 | def test_destroy_should_update_messages |
|
277 | 285 | board = Board.create!(:project_id => 1, :name => 'Board', :description => 'Board') |
|
278 |
message = Message.create!(:board_id => board.id, :author_id => 2, |
|
|
279 | ||
|
286 | message = Message.create!(:board_id => board.id, :author_id => 2, | |
|
287 | :subject => 'foo', :content => 'foo') | |
|
280 | 288 | User.find(2).destroy |
|
281 | 289 | assert_nil User.find_by_id(2) |
|
282 | 290 | assert_equal User.anonymous, message.reload.author |
|
283 | 291 | end |
|
284 | 292 | |
|
285 | 293 | def test_destroy_should_update_news |
|
286 |
news = News.create!(:project_id => 1, :author_id => 2, |
|
|
287 | ||
|
294 | news = News.create!(:project_id => 1, :author_id => 2, | |
|
295 | :title => 'foo', :description => 'foo') | |
|
288 | 296 | User.find(2).destroy |
|
289 | 297 | assert_nil User.find_by_id(2) |
|
290 | 298 | assert_equal User.anonymous, news.reload.author |
@@ -313,7 +321,8 class UserTest < ActiveSupport::TestCase | |||
|
313 | 321 | end |
|
314 | 322 | |
|
315 | 323 | def test_destroy_should_update_time_entries |
|
316 |
entry = TimeEntry.new(:hours => '2', :spent_on => Date.today, |
|
|
324 | entry = TimeEntry.new(:hours => '2', :spent_on => Date.today, | |
|
325 | :activity => TimeEntryActivity.create!(:name => 'foo')) | |
|
317 | 326 | entry.project_id = 1 |
|
318 | 327 | entry.user_id = 2 |
|
319 | 328 | entry.save! |
@@ -332,7 +341,8 class UserTest < ActiveSupport::TestCase | |||
|
332 | 341 | end |
|
333 | 342 | |
|
334 | 343 | def test_destroy_should_delete_watchers |
|
335 |
issue = Issue.create!(:project_id => 1, :author_id => 1, |
|
|
344 | issue = Issue.create!(:project_id => 1, :author_id => 1, | |
|
345 | :tracker_id => 1, :subject => 'foo') | |
|
336 | 346 | watcher = Watcher.create!(:user_id => 2, :watchable => issue) |
|
337 | 347 | |
|
338 | 348 | User.find(2).destroy |
@@ -344,7 +354,9 class UserTest < ActiveSupport::TestCase | |||
|
344 | 354 | wiki_content = WikiContent.create!( |
|
345 | 355 | :text => 'foo', |
|
346 | 356 | :author_id => 2, |
|
347 | :page => WikiPage.create!(:title => 'Foo', :wiki => Wiki.create!(:project_id => 3, :start_page => 'Start')) | |
|
357 | :page => WikiPage.create!(:title => 'Foo', | |
|
358 | :wiki => Wiki.create!(:project_id => 3, | |
|
359 | :start_page => 'Start')) | |
|
348 | 360 | ) |
|
349 | 361 | wiki_content.text = 'bar' |
|
350 | 362 | assert_difference 'WikiContent::Version.count' do |
@@ -418,7 +430,8 class UserTest < ActiveSupport::TestCase | |||
|
418 | 430 | |
|
419 | 431 | def test_validate_password_length |
|
420 | 432 | with_settings :password_min_length => '100' do |
|
421 |
user = User.new(:firstname => "new100", |
|
|
433 | user = User.new(:firstname => "new100", | |
|
434 | :lastname => "user100", :mail => "newuser100@somenet.foo") | |
|
422 | 435 | user.login = "newuser100" |
|
423 | 436 | user.password, user.password_confirmation = "password100", "password100" |
|
424 | 437 | assert !user.save |
@@ -473,25 +486,29 class UserTest < ActiveSupport::TestCase | |||
|
473 | 486 | |
|
474 | 487 | def test_fields_for_order_statement_should_return_fields_according_user_format_setting |
|
475 | 488 | with_settings :user_format => 'lastname_coma_firstname' do |
|
476 |
assert_equal ['users.lastname', 'users.firstname', 'users.id'], |
|
|
489 | assert_equal ['users.lastname', 'users.firstname', 'users.id'], | |
|
490 | User.fields_for_order_statement | |
|
477 | 491 | end |
|
478 | 492 | end |
|
479 | 493 | |
|
480 | 494 | def test_fields_for_order_statement_width_table_name_should_prepend_table_name |
|
481 | 495 | with_settings :user_format => 'lastname_firstname' do |
|
482 |
assert_equal ['authors.lastname', 'authors.firstname', 'authors.id'], |
|
|
496 | assert_equal ['authors.lastname', 'authors.firstname', 'authors.id'], | |
|
497 | User.fields_for_order_statement('authors') | |
|
483 | 498 | end |
|
484 | 499 | end |
|
485 | 500 | |
|
486 | 501 | def test_fields_for_order_statement_with_blank_format_should_return_default |
|
487 | 502 | with_settings :user_format => '' do |
|
488 |
assert_equal ['users.firstname', 'users.lastname', 'users.id'], |
|
|
503 | assert_equal ['users.firstname', 'users.lastname', 'users.id'], | |
|
504 | User.fields_for_order_statement | |
|
489 | 505 | end |
|
490 | 506 | end |
|
491 | 507 | |
|
492 | 508 | def test_fields_for_order_statement_with_invalid_format_should_return_default |
|
493 | 509 | with_settings :user_format => 'foo' do |
|
494 |
assert_equal ['users.firstname', 'users.lastname', 'users.id'], |
|
|
510 | assert_equal ['users.firstname', 'users.lastname', 'users.id'], | |
|
511 | User.fields_for_order_statement | |
|
495 | 512 | end |
|
496 | 513 | end |
|
497 | 514 |
General Comments 0
You need to be logged in to leave comments.
Login now