diff options
author | Sean McGivern <sean@gitlab.com> | 2016-10-28 15:11:32 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-10-28 15:11:32 +0100 |
commit | af6cf695c43d0b5f189de05069a475fcea73e374 (patch) | |
tree | 142208fedcf30f481014b64c0607535feb96a677 /spec/policies | |
parent | db9979bcad17e46ef2b151b018c5f7769d33ca77 (diff) | |
download | gitlab-ce-af6cf695c43d0b5f189de05069a475fcea73e374.tar.gz |
Add specs for a user from a group link23872-members-of-group-that-has-project-access-getting-404-on-accessing-a-project-issue
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/issues_policy_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/policies/issues_policy_spec.rb b/spec/policies/issues_policy_spec.rb index 0dfd2772e42..2b7b6cad654 100644 --- a/spec/policies/issues_policy_spec.rb +++ b/spec/policies/issues_policy_spec.rb @@ -5,6 +5,8 @@ describe IssuePolicy, models: true do let(:author) { create(:user) } let(:assignee) { create(:user) } let(:reporter) { create(:user) } + let(:group) { create(:group, :public) } + let(:reporter_from_group_link) { create(:user) } def permissions(user, issue) IssuePolicy.abilities(user, issue).to_set @@ -21,6 +23,10 @@ describe IssuePolicy, models: true do project.team << [author, :guest] project.team << [assignee, :guest] project.team << [reporter, :reporter] + + group.add_reporter(reporter_from_group_link) + + create(:project_group_link, group: group, project: project) end it 'does not allow non-members to read issues' do @@ -41,6 +47,11 @@ describe IssuePolicy, models: true do expect(permissions(reporter, issue_no_assignee)).to include(:read_issue, :update_issue, :admin_issue) end + it 'allows reporters from group links to read, update, and admin issues' do + expect(permissions(reporter_from_group_link, issue)).to include(:read_issue, :update_issue, :admin_issue) + expect(permissions(reporter_from_group_link, issue_no_assignee)).to include(:read_issue, :update_issue, :admin_issue) + end + it 'allows issue authors to read and update their issues' do expect(permissions(author, issue)).to include(:read_issue, :update_issue) expect(permissions(author, issue)).not_to include(:admin_issue) @@ -76,6 +87,11 @@ describe IssuePolicy, models: true do expect(permissions(reporter, confidential_issue_no_assignee)).to include(:read_issue, :update_issue, :admin_issue) end + it 'allows reporters from group links to read, update, and admin confidential issues' do + expect(permissions(reporter_from_group_link, confidential_issue)).to include(:read_issue, :update_issue, :admin_issue) + expect(permissions(reporter_from_group_link, confidential_issue_no_assignee)).to include(:read_issue, :update_issue, :admin_issue) + end + it 'allows issue authors to read and update their confidential issues' do expect(permissions(author, confidential_issue)).to include(:read_issue, :update_issue) expect(permissions(author, confidential_issue)).not_to include(:admin_issue) @@ -100,6 +116,10 @@ describe IssuePolicy, models: true do before do project.team << [guest, :guest] project.team << [reporter, :reporter] + + group.add_reporter(reporter_from_group_link) + + create(:project_group_link, group: group, project: project) end it 'allows guests to read issues' do @@ -115,6 +135,11 @@ describe IssuePolicy, models: true do expect(permissions(reporter, issue_no_assignee)).to include(:read_issue, :update_issue, :admin_issue) end + it 'allows reporters from group links to read, update, and admin issues' do + expect(permissions(reporter_from_group_link, issue)).to include(:read_issue, :update_issue, :admin_issue) + expect(permissions(reporter_from_group_link, issue_no_assignee)).to include(:read_issue, :update_issue, :admin_issue) + end + it 'allows issue authors to read and update their issues' do expect(permissions(author, issue)).to include(:read_issue, :update_issue) expect(permissions(author, issue)).not_to include(:admin_issue) @@ -145,6 +170,11 @@ describe IssuePolicy, models: true do expect(permissions(reporter, confidential_issue_no_assignee)).to include(:read_issue, :update_issue, :admin_issue) end + it 'allows reporter from group links to read, update, and admin confidential issues' do + expect(permissions(reporter_from_group_link, confidential_issue)).to include(:read_issue, :update_issue, :admin_issue) + expect(permissions(reporter_from_group_link, confidential_issue_no_assignee)).to include(:read_issue, :update_issue, :admin_issue) + end + it 'allows issue authors to read and update their confidential issues' do expect(permissions(author, confidential_issue)).to include(:read_issue, :update_issue) expect(permissions(author, confidential_issue)).not_to include(:admin_issue) |