summaryrefslogtreecommitdiff
path: root/spec/policies
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-11-29 17:30:14 -0200
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-11-30 16:02:25 -0200
commit42c332689deb2fcbb3eb71d5134d583f4518b65f (patch)
treedd492df8cd2683ec9a08a8abfe0381b5a368912f /spec/policies
parentd6b9b21e6db3c32e0f272ab96486876fa8b54d1b (diff)
downloadgitlab-ce-42c332689deb2fcbb3eb71d5134d583f4518b65f.tar.gz
Improve ProjectPolicy spec to check permissions when wiki is disabled
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/project_policy_spec.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb
index 96249a7d8c3..b49e4f3a8bc 100644
--- a/spec/policies/project_policy_spec.rb
+++ b/spec/policies/project_policy_spec.rb
@@ -23,7 +23,7 @@ describe ProjectPolicy, models: true do
:download_code, :fork_project, :create_project_snippet, :update_issue,
:admin_issue, :admin_label, :admin_list, :read_commit_status, :read_build,
:read_container_image, :read_pipeline, :read_environment, :read_deployment,
- :read_merge_request
+ :read_merge_request, :download_wiki_code
]
end
@@ -56,7 +56,8 @@ describe ProjectPolicy, models: true do
let(:public_permissions) do
[
:download_code, :fork_project, :read_commit_status, :read_pipeline,
- :read_container_image, :build_download_code, :build_read_container_image
+ :read_container_image, :build_download_code, :build_read_container_image,
+ :download_wiki_code
]
end
@@ -87,6 +88,15 @@ describe ProjectPolicy, models: true do
expect(Ability.allowed?(user, :read_issue, project)).to be_falsy
end
+ it 'does not include the wiki permissions when the feature is disabled' do
+ project.project_feature.update_attribute(:wiki_access_level, ProjectFeature::DISABLED)
+ wiki_permissions = [:read_wiki, :create_wiki, :update_wiki, :admin_wiki, :download_wiki_code]
+
+ permissions = described_class.abilities(owner, project).to_set
+
+ expect(permissions).not_to include(*wiki_permissions)
+ end
+
context 'abilities for non-public projects' do
let(:project) { create(:empty_project, namespace: owner.namespace) }