diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-09-28 14:51:08 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-09-28 14:51:08 +0000 |
commit | 7e7ac5340a281ed767066af0b5f4dd45a3d7076f (patch) | |
tree | 891640b0548c0d3063daddb219006d120fa312c3 /test/unit/issue_test.rb | |
parent | 9a7fb0ad7be0ee3403f5b89eb0c16b68c991d519 (diff) | |
download | redmine-7e7ac5340a281ed767066af0b5f4dd45a3d7076f.tar.gz redmine-7e7ac5340a281ed767066af0b5f4dd45a3d7076f.zip |
Adds buit-in groups to give specific permissions to anonymous and non members users per project (#17976).
git-svn-id: http://svn.redmine.org/redmine/trunk@13417 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/issue_test.rb')
-rw-r--r-- | test/unit/issue_test.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index c4cf77c79..3454c71f5 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -219,6 +219,16 @@ class IssueTest < ActiveSupport::TestCase assert_visibility_match User.anonymous, issues end + def test_visible_scope_for_anonymous_without_view_issues_permissions_and_membership + Role.anonymous.remove_permission!(:view_issues) + Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [2]) + + issues = Issue.visible(User.anonymous).all + assert issues.any? + assert_equal [1], issues.map(&:project_id).uniq.sort + assert_visibility_match User.anonymous, issues + end + def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_default assert Role.anonymous.update_attribute(:issues_visibility, 'default') issue = Issue.generate!(:author => User.anonymous, :assigned_to => User.anonymous, :is_private => true) @@ -265,6 +275,17 @@ class IssueTest < ActiveSupport::TestCase assert_visibility_match user, issues end + def test_visible_scope_for_non_member_without_view_issues_permissions_and_membership + Role.non_member.remove_permission!(:view_issues) + Member.create!(:project_id => 1, :principal => Group.non_member, :role_ids => [2]) + user = User.find(9) + + issues = Issue.visible(user).all + assert issues.any? + assert_equal [1], issues.map(&:project_id).uniq.sort + assert_visibility_match user, issues + end + def test_visible_scope_for_member user = User.find(9) # User should see issues of projects for which user has view_issues permissions only @@ -1724,6 +1745,16 @@ class IssueTest < ActiveSupport::TestCase end end + def test_assignable_users_should_not_include_builtin_groups + Member.create!(:project_id => 1, :principal => Group.non_member, :role_ids => [1]) + Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [1]) + issue = Issue.new(:project => Project.find(1)) + + with_settings :issue_group_assignment => '1' do + assert_nil issue.assignable_users.detect {|u| u.is_a?(GroupBuiltin)} + end + end + def test_create_should_send_email_notification ActionMailer::Base.deliveries.clear issue = Issue.new(:project_id => 1, :tracker_id => 1, |