Mercurial > hg > soundsoftware-site
comparison test/unit/.svn/text-base/user_test.rb.svn-base @ 25:9fd6221709a6 luisf
* Merge cannam branch
| author | Chris Cannam |
|---|---|
| date | Fri, 24 Sep 2010 15:51:28 +0100 |
| parents | 40f7cfd4df19 |
| children | 94944d00e43c |
comparison
equal
deleted
inserted
replaced
| 24:39511236fe36 | 25:9fd6221709a6 |
|---|---|
| 353 assert !user.change_password_allowed?, "User allowed to change password, though auth source does not" | 353 assert !user.change_password_allowed?, "User allowed to change password, though auth source does not" |
| 354 end | 354 end |
| 355 | 355 |
| 356 end | 356 end |
| 357 | 357 |
| 358 context "#allowed_to?" do | |
| 359 context "with a unique project" do | |
| 360 should "return false if project is archived" do | |
| 361 project = Project.find(1) | |
| 362 Project.any_instance.stubs(:status).returns(Project::STATUS_ARCHIVED) | |
| 363 assert ! @admin.allowed_to?(:view_issues, Project.find(1)) | |
| 364 end | |
| 365 | |
| 366 should "return false if related module is disabled" do | |
| 367 project = Project.find(1) | |
| 368 project.enabled_module_names = ["issue_tracking"] | |
| 369 assert @admin.allowed_to?(:add_issues, project) | |
| 370 assert ! @admin.allowed_to?(:view_wiki_pages, project) | |
| 371 end | |
| 372 | |
| 373 should "authorize nearly everything for admin users" do | |
| 374 project = Project.find(1) | |
| 375 assert ! @admin.member_of?(project) | |
| 376 %w(edit_issues delete_issues manage_news manage_documents manage_wiki).each do |p| | |
| 377 assert @admin.allowed_to?(p.to_sym, project) | |
| 378 end | |
| 379 end | |
| 380 | |
| 381 should "authorize normal users depending on their roles" do | |
| 382 project = Project.find(1) | |
| 383 assert @jsmith.allowed_to?(:delete_messages, project) #Manager | |
| 384 assert ! @dlopper.allowed_to?(:delete_messages, project) #Developper | |
| 385 end | |
| 386 end | |
| 387 | |
| 388 context "with options[:global]" do | |
| 389 should "authorize if user has at least one role that has this permission" do | |
| 390 @dlopper2 = User.find(5) #only Developper on a project, not Manager anywhere | |
| 391 @anonymous = User.find(6) | |
| 392 assert @jsmith.allowed_to?(:delete_issue_watchers, nil, :global => true) | |
| 393 assert ! @dlopper2.allowed_to?(:delete_issue_watchers, nil, :global => true) | |
| 394 assert @dlopper2.allowed_to?(:add_issues, nil, :global => true) | |
| 395 assert ! @anonymous.allowed_to?(:add_issues, nil, :global => true) | |
| 396 assert @anonymous.allowed_to?(:view_issues, nil, :global => true) | |
| 397 end | |
| 398 end | |
| 399 end | |
| 400 | |
| 358 if Object.const_defined?(:OpenID) | 401 if Object.const_defined?(:OpenID) |
| 359 | 402 |
| 360 def test_setting_identity_url | 403 def test_setting_identity_url |
| 361 normalized_open_id_url = 'http://example.com/' | 404 normalized_open_id_url = 'http://example.com/' |
| 362 u = User.new( :identity_url => 'http://example.com/' ) | 405 u = User.new( :identity_url => 'http://example.com/' ) |
