diff options
author | Stan Hu <stanhu@gmail.com> | 2019-02-14 13:19:59 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-02-14 13:41:43 -0800 |
commit | b2da8042b4d11db246a26b63eebc78a3c0660b08 (patch) | |
tree | 69feead682ebd9c7ab55c569bab523f67bd03679 /spec/policies | |
parent | c470a77937c79169f3ba78a31c249bd71b5c6070 (diff) | |
download | gitlab-ce-b2da8042b4d11db246a26b63eebc78a3c0660b08.tar.gz |
Fix 403 errors when adding an assignee list in project boards
Due to a bug in `BoardPolicy`, users were getting back a 403 error when
trying to assign users to an assignee list and seeing "Something went
wrong while fetching assignees list". For some reason, the declarative
policy runtime was ignoring the ternary condition.
To work around the issue, we make the project board an explicit
condition check.
Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/9727
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/board_policy_spec.rb | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/policies/board_policy_spec.rb b/spec/policies/board_policy_spec.rb new file mode 100644 index 00000000000..4b76d65ef69 --- /dev/null +++ b/spec/policies/board_policy_spec.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe BoardPolicy do + let(:user) { create(:user) } + let(:project) { create(:project, :private) } + let(:group) { create(:group, :private) } + let(:group_board) { create(:board, group: group) } + let(:project_board) { create(:board, project: project) } + + let(:board_permissions) do + [ + :read_parent, + :read_milestone, + :read_issue + ] + end + + def expect_allowed(*permissions) + permissions.each { |p| is_expected.to be_allowed(p) } + end + + def expect_disallowed(*permissions) + permissions.each { |p| is_expected.not_to be_allowed(p) } + end + + context 'group board' do + subject { described_class.new(user, group_board) } + + context 'user has access' do + before do + group.add_developer(user) + end + + it do + expect_allowed(*board_permissions) + end + end + + context 'user does not have access' do + it do + expect_disallowed(*board_permissions) + end + end + end + + context 'project board' do + subject { described_class.new(user, project_board) } + + context 'user has access' do + before do + project.add_developer(user) + end + + it do + expect_allowed(*board_permissions) + end + end + + context 'user does not have access' do + it do + expect_disallowed(*board_permissions) + end + end + end +end |