summaryrefslogtreecommitdiff
path: root/spec/helpers/issues_helper_spec.rb
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-04-10 19:49:26 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2018-04-11 10:51:43 +0200
commitc39e3f22ce12a302e294deb3523414e4a684b6fb (patch)
tree2a0e8d4bb5c2b81ef6c8bb82758f05c52b8642fc /spec/helpers/issues_helper_spec.rb
parent04c7d0d55500e6f118bd17153f3af11e83fce826 (diff)
downloadgitlab-ce-c39e3f22ce12a302e294deb3523414e4a684b6fb.tar.gz
Show `New Issue` link for projects
When a user is not logged in, we want to show the `New Issue` link so he gets directed to the login flow first. When a project is archived, we never want to show the link.
Diffstat (limited to 'spec/helpers/issues_helper_spec.rb')
-rw-r--r--spec/helpers/issues_helper_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index 95da9a6f3d4..8bb2e234e9a 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -163,4 +163,26 @@ describe IssuesHelper do
end
end
end
+
+ describe '#show_new_issue_link?' do
+ before do
+ allow(helper).to receive(:current_user)
+ end
+
+ it 'is false when no project there is no project' do
+ expect(helper.show_new_issue_link?(nil)).to be_falsey
+ end
+
+ it 'is true when there is a project and no logged in user' do
+ expect(helper.show_new_issue_link?(build(:project))).to be_truthy
+ end
+
+ it 'is true when the current user does not have access to the project' do
+ project = build(:project)
+ allow(helper).to receive(:current_user).and_return(project.owner)
+
+ expect(helper).to receive(:can?).with(project.owner, :create_issue, project).and_return(true)
+ expect(helper.show_new_issue_link?(project)).to be_truthy
+ end
+ end
end