summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-09-07 20:41:33 +0000
committerFatih Acet <acetfatih@gmail.com>2016-09-07 20:41:33 +0000
commit5dab043f2d5907958985482ef562420db0ddea5f (patch)
tree3401690ba06ac332f183d15e7d109828fb109225 /spec
parent13a91b560e74b457eab20fe2c48e0af5afcf41b3 (diff)
parentdfa286c1818eea9f05d3a76f99b6b2dd7b66e1d7 (diff)
downloadgitlab-ce-5dab043f2d5907958985482ef562420db0ddea5f.tar.gz
Merge branch 'issue_21821' into 'master'
Fix project settings field fixes #21821 See merge request !6185
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/projects_helper_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 284b58d8d5c..70032e7df94 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -174,4 +174,48 @@ describe ProjectsHelper do
end
end
end
+
+ describe "#project_feature_access_select" do
+ let(:project) { create(:empty_project, :public) }
+ let(:user) { create(:user) }
+
+ context "when project is internal or public" do
+ it "shows all options" do
+ helper.instance_variable_set(:@project, project)
+ result = helper.project_feature_access_select(:issues_access_level)
+ expect(result).to include("Disabled")
+ expect(result).to include("Only team members")
+ expect(result).to include("Everyone with access")
+ end
+ end
+
+ context "when project is private" do
+ before { project.update_attributes(visibility_level: Gitlab::VisibilityLevel::PRIVATE) }
+
+ it "shows only allowed options" do
+ helper.instance_variable_set(:@project, project)
+ result = helper.project_feature_access_select(:issues_access_level)
+ expect(result).to include("Disabled")
+ expect(result).to include("Only team members")
+ expect(result).not_to include("Everyone with access")
+ end
+ end
+
+ context "when project moves from public to private" do
+ before do
+ project.project_feature.update_attributes(issues_access_level: ProjectFeature::ENABLED)
+ project.update_attributes(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
+ end
+
+ it "shows the highest allowed level selected" do
+ helper.instance_variable_set(:@project, project)
+ result = helper.project_feature_access_select(:issues_access_level)
+
+ expect(result).to include("Disabled")
+ expect(result).to include("Only team members")
+ expect(result).not_to include("Everyone with access")
+ expect(result).to have_selector('option[selected]', text: "Only team members")
+ end
+ end
+ end
end