diff options
author | Robert Speicher <rspeicher@gmail.com> | 2019-02-15 23:40:16 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2019-02-15 23:40:16 +0300 |
commit | 292f067146f439bdc4212705595830585d9fd77c (patch) | |
tree | 06b41ba4f955d140cbb0acd8e7d9c700be78599b /spec/policies | |
parent | 22e1c70f2b5ba2d188725719c5c7196586ad30ce (diff) | |
parent | fd7461f8546b124a7cc03e8cab703eb405d0bb98 (diff) |
Merge branch '11-8-stable-prepare-rc6' into '11-8-stable'
Prepare 11.8.0-rc6 release
See merge request gitlab-org/gitlab-ce!25279
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 |