diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-07-06 15:38:43 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-07-06 17:40:33 +0300 |
commit | 111ebe54712aca16f3ad0f3d859c1c036ccb9f09 (patch) | |
tree | 058564d9186c5bd291da7753cf8ee9d0c01f8c1e /spec/helpers/projects_helper_spec.rb | |
parent | 17446ff0c98e870f0500279983432e5115e060a4 (diff) |
Fork visibility level fix
Diffstat (limited to 'spec/helpers/projects_helper_spec.rb')
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 0f78725e3d9..beb9b4e438e 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -8,4 +8,48 @@ describe ProjectsHelper do expect(project_status_css_class("finished")).to eq("success") end end + + describe "can_change_visibility_level?" do + let(:project) { create(:project) } + + let(:fork_project) do + fork_project = create(:forked_project_with_submodules) + fork_project.build_forked_project_link(forked_to_project_id: fork_project.id, forked_from_project_id: project.id) + fork_project.save + + fork_project + end + + let(:user) { create(:user) } + + it "returns false if there are no approipriate permissions" do + allow(helper).to receive(:can?) { false } + + expect(helper.can_change_visibility_level?(project, user)).to be_falsey + end + + it "returns true if there are permissions and it is not fork" do + allow(helper).to receive(:can?) { true } + + expect(helper.can_change_visibility_level?(project, user)).to be_truthy + end + + context "forks" do + it "returns false if there are permissions and origin project is PRIVATE" do + allow(helper).to receive(:can?) { true } + + project.update visibility_level: Gitlab::VisibilityLevel::PRIVATE + + expect(helper.can_change_visibility_level?(fork_project, user)).to be_falsey + end + + it "returns true if there are permissions and origin project is INTERNAL" do + allow(helper).to receive(:can?) { true } + + project.update visibility_level: Gitlab::VisibilityLevel::INTERNAL + + expect(helper.can_change_visibility_level?(fork_project, user)).to be_truthy + end + end + end end |