diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-13 13:26:31 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-13 13:26:31 +0000 |
commit | b7dfe2ae4054aa40e15182fd3c6cb7dd39f131db (patch) | |
tree | 5ab080ca9cadeb6cd9578bf301e4e9e8810bed9e /spec/helpers | |
parent | 25cb337cf12438169f1b14bc5dace8a06a7356e3 (diff) | |
download | gitlab-ce-b7dfe2ae4054aa40e15182fd3c6cb7dd39f131db.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/issues_helper_spec.rb | 77 | ||||
-rw-r--r-- | spec/helpers/onboarding_experiment_helper_spec.rb | 8 |
2 files changed, 80 insertions, 5 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 diff --git a/spec/helpers/onboarding_experiment_helper_spec.rb b/spec/helpers/onboarding_experiment_helper_spec.rb index 5b7d9b1c2e6..cada91bff3c 100644 --- a/spec/helpers/onboarding_experiment_helper_spec.rb +++ b/spec/helpers/onboarding_experiment_helper_spec.rb @@ -4,17 +4,17 @@ require 'spec_helper' describe OnboardingExperimentHelper, type: :helper do describe '.allow_access_to_onboarding?' do - context "when we're not gitlab.com" do + context "when we're not gitlab.com or dev env" do it 'returns false' do - allow(::Gitlab).to receive(:com?).and_return(false) + allow(::Gitlab).to receive(:dev_env_or_com?).and_return(false) expect(helper.allow_access_to_onboarding?).to be(false) end end - context "when we're gitlab.com" do + context "when we're gitlab.com or dev env" do before do - allow(::Gitlab).to receive(:com?).and_return(true) + allow(::Gitlab).to receive(:dev_env_or_com?).and_return(true) end context 'and the :user_onboarding feature is not enabled' do |