summaryrefslogtreecommitdiff
path: root/spec/policies
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-09-29 12:14:39 +0100
committerPhil Hughes <me@iamphill.com>2017-09-29 12:14:39 +0100
commit93aa6d04c2e81193d7833890d2281fc1df7d7129 (patch)
tree166a52d9ffdf1bbd3ef073b88626707e9a1acc16 /spec/policies
parent8585ae61e730a48fc0688417b24279c48b59dada (diff)
downloadgitlab-ce-93aa6d04c2e81193d7833890d2281fc1df7d7129.tar.gz
moved fork checks into policiesfork-btn-enabled-user-groups
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/global_policy_spec.rb23
-rw-r--r--spec/policies/namespace_policy_spec.rb20
2 files changed, 43 insertions, 0 deletions
diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb
index 983f0e52d31..5b8cf2e6ab5 100644
--- a/spec/policies/global_policy_spec.rb
+++ b/spec/policies/global_policy_spec.rb
@@ -52,6 +52,29 @@ describe GlobalPolicy do
end
end
+ describe "create fork" do
+ context "when user has not exceeded project limit" do
+ it { is_expected.to be_allowed(:create_fork) }
+ end
+
+ context "when user has exceeded project limit" do
+ let(:current_user) { create(:user, projects_limit: 0) }
+
+ it { is_expected.not_to be_allowed(:create_fork) }
+ end
+
+ context "when user is a master in a group" do
+ let(:group) { create(:group) }
+ let(:current_user) { create(:user, projects_limit: 0) }
+
+ before do
+ group.add_master(current_user)
+ end
+
+ it { is_expected.to be_allowed(:create_fork) }
+ end
+ end
+
describe 'custom attributes' do
context 'regular user' do
it { is_expected.not_to be_allowed(:read_custom_attribute) }
diff --git a/spec/policies/namespace_policy_spec.rb b/spec/policies/namespace_policy_spec.rb
new file mode 100644
index 00000000000..e52ff02e5f0
--- /dev/null
+++ b/spec/policies/namespace_policy_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe NamespacePolicy do
+ let(:current_user) { create(:user) }
+ let(:namespace) { current_user.namespace }
+
+ subject { described_class.new(current_user, namespace) }
+
+ context "create projects" do
+ context "user namespace" do
+ it { is_expected.to be_allowed(:create_projects) }
+ end
+
+ context "user who has exceeded project limit" do
+ let(:current_user) { create(:user, projects_limit: 0) }
+
+ it { is_expected.not_to be_allowed(:create_projects) }
+ end
+ end
+end