Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-17 18:08:15 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-17 18:08:15 +0300
commitc2b98d3dbd47ab92c79c702276fe9130d9a28036 (patch)
treebf4071f551fdc12c22b23b2bb66483064e7b9ea9 /spec/policies
parentbadb9c1deacbea601b02f88811b7e123589d9251 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/blob_policy_spec.rb31
-rw-r--r--spec/policies/wiki_page_policy_spec.rb31
2 files changed, 62 insertions, 0 deletions
diff --git a/spec/policies/blob_policy_spec.rb b/spec/policies/blob_policy_spec.rb
new file mode 100644
index 00000000000..20c8a55f437
--- /dev/null
+++ b/spec/policies/blob_policy_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe BlobPolicy do
+ include_context 'ProjectPolicyTable context'
+ include ProjectHelpers
+ using RSpec::Parameterized::TableSyntax
+
+ let(:project) { create(:project, :repository, project_level) }
+ let(:user) { create_user_from_membership(project, membership) }
+ let(:blob) { project.repository.blob_at(SeedRepo::FirstCommit::ID, 'README.md') }
+
+ subject(:policy) { described_class.new(user, blob) }
+
+ where(:project_level, :feature_access_level, :membership, :expected_count) do
+ permission_table_for_guest_feature_access_and_non_private_project_only
+ end
+
+ with_them do
+ it "grants permission" do
+ update_feature_access_level(project, feature_access_level)
+
+ if expected_count == 1
+ expect(policy).to be_allowed(:read_blob)
+ else
+ expect(policy).to be_disallowed(:read_blob)
+ end
+ end
+ end
+end
diff --git a/spec/policies/wiki_page_policy_spec.rb b/spec/policies/wiki_page_policy_spec.rb
new file mode 100644
index 00000000000..e550ccf6d65
--- /dev/null
+++ b/spec/policies/wiki_page_policy_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe WikiPagePolicy do
+ include_context 'ProjectPolicyTable context'
+ include ProjectHelpers
+ using RSpec::Parameterized::TableSyntax
+
+ let(:project) { create(:project, :wiki_repo, project_level) }
+ let(:user) { create_user_from_membership(project, membership) }
+ let(:wiki_page) { create(:wiki_page, wiki: project.wiki) }
+
+ subject(:policy) { described_class.new(user, wiki_page) }
+
+ where(:project_level, :feature_access_level, :membership, :expected_count) do
+ permission_table_for_guest_feature_access
+ end
+
+ with_them do
+ it "grants permission" do
+ update_feature_access_level(project, feature_access_level)
+
+ if expected_count == 1
+ expect(policy).to be_allowed(:read_wiki_page)
+ else
+ expect(policy).to be_disallowed(:read_wiki_page)
+ end
+ end
+ end
+end