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-09-13 16:26:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-13 16:26:31 +0300
commitb7dfe2ae4054aa40e15182fd3c6cb7dd39f131db (patch)
tree5ab080ca9cadeb6cd9578bf301e4e9e8810bed9e /spec/helpers/issues_helper_spec.rb
parent25cb337cf12438169f1b14bc5dace8a06a7356e3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers/issues_helper_spec.rb')
-rw-r--r--spec/helpers/issues_helper_spec.rb77
1 files changed, 76 insertions, 1 deletions
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index 039143eb8d7..d15b5a4ab58 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -142,7 +142,7 @@ describe IssuesHelper do
expect(link_to_discussions_to_resolve(merge_request, nil)).to include(expected_path)
end
- it "containst the reference to the merge request" do
+ it "contains the reference to the merge request" do
expect(link_to_discussions_to_resolve(merge_request, nil)).to include(merge_request.to_reference)
end
end
@@ -185,4 +185,79 @@ describe IssuesHelper do
expect(helper.show_new_issue_link?(project)).to be_truthy
end
end
+
+ describe '#issue_closed_link' do
+ let(:new_issue) { create(:issue, project: project) }
+ let(:guest) { create(:user) }
+
+ before do
+ allow(helper).to receive(:can?) do |*args|
+ Ability.allowed?(*args)
+ end
+ end
+
+ shared_examples 'successfully displays link to issue and with css class' do |action|
+ it 'returns link' do
+ link = "<a class=\"#{css_class}\" href=\"/#{new_issue.project.full_path}/issues/#{new_issue.iid}\">(#{action})</a>"
+
+ expect(helper.issue_closed_link(issue, user, css_class: css_class)).to match(link)
+ end
+ end
+
+ shared_examples 'does not display link' do
+ it 'returns nil' do
+ expect(helper.issue_closed_link(issue, user)).to be_nil
+ end
+ end
+
+ context 'with linked issue' do
+ context 'with moved issue' do
+ before do
+ issue.update(moved_to: new_issue)
+ end
+
+ context 'when user has permission to see new issue' do
+ let(:user) { project.owner }
+ let(:css_class) { 'text-white text-underline' }
+
+ it_behaves_like 'successfully displays link to issue and with css class', 'moved'
+ end
+
+ context 'when user has no permission to see new issue' do
+ let(:user) { guest }
+
+ it_behaves_like 'does not display link'
+ end
+ end
+
+ context 'with duplicated issue' do
+ before do
+ issue.update(duplicated_to: new_issue)
+ end
+
+ context 'when user has permission to see new issue' do
+ let(:user) { project.owner }
+ let(:css_class) { 'text-white text-underline' }
+
+ it_behaves_like 'successfully displays link to issue and with css class', 'duplicated'
+ end
+
+ context 'when user has no permission to see new issue' do
+ let(:user) { guest }
+
+ it_behaves_like 'does not display link'
+ end
+ end
+ end
+
+ context 'without linked issue' do
+ let(:user) { project.owner }
+
+ before do
+ issue.update(moved_to: nil, duplicated_to: nil)
+ end
+
+ it_behaves_like 'does not display link'
+ end
+ end
end