diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/presenters/issue_presenter_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/presenters/issue_presenter_spec.rb')
-rw-r--r-- | spec/presenters/issue_presenter_spec.rb | 61 |
1 files changed, 52 insertions, 9 deletions
diff --git a/spec/presenters/issue_presenter_spec.rb b/spec/presenters/issue_presenter_spec.rb index 55a6b50ffa7..e17ae218cd3 100644 --- a/spec/presenters/issue_presenter_spec.rb +++ b/spec/presenters/issue_presenter_spec.rb @@ -5,19 +5,42 @@ require 'spec_helper' RSpec.describe IssuePresenter do include Gitlab::Routing.url_helpers - let(:user) { create(:user) } - let(:group) { create(:group) } - let(:project) { create(:project, group: group) } - let(:issue) { create(:issue, project: project) } - let(:presenter) { described_class.new(issue, current_user: user) } + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } + let_it_be(:issue) { create(:issue, project: project) } + let_it_be(:task) { create(:issue, :task, project: project) } - before do + let(:presented_issue) { issue } + let(:presenter) { described_class.new(presented_issue, current_user: user) } + + before_all do group.add_developer(user) end describe '#web_url' do it 'returns correct path' do - expect(presenter.web_url).to eq("http://localhost/#{group.name}/#{project.name}/-/issues/#{issue.iid}") + expect(presenter.web_url).to eq("http://localhost/#{group.name}/#{project.name}/-/issues/#{presented_issue.iid}") + end + + context 'when issue type is task' do + let(:presented_issue) { task } + + context 'when work_items feature flag is enabled' do + it 'returns a work item url for the task' do + expect(presenter.web_url).to eq(project_work_items_url(project, work_items_path: presented_issue.id)) + end + end + + context 'when work_items feature flag is disabled' do + before do + stub_feature_flags(work_items: false) + end + + it 'returns an issue url for the task' do + expect(presenter.web_url).to eq("http://localhost/#{group.name}/#{project.name}/-/issues/#{presented_issue.iid}") + end + end end end @@ -29,7 +52,7 @@ RSpec.describe IssuePresenter do end it 'returns subscribed' do - create(:subscription, user: user, project: project, subscribable: issue, subscribed: true) + create(:subscription, user: user, project: project, subscribable: presented_issue, subscribed: true) is_expected.to be(true) end @@ -37,7 +60,27 @@ RSpec.describe IssuePresenter do describe '#issue_path' do it 'returns correct path' do - expect(presenter.issue_path).to eq("/#{group.name}/#{project.name}/-/issues/#{issue.iid}") + expect(presenter.issue_path).to eq("/#{group.name}/#{project.name}/-/issues/#{presented_issue.iid}") + end + + context 'when issue type is task' do + let(:presented_issue) { task } + + context 'when work_items feature flag is enabled' do + it 'returns a work item path for the task' do + expect(presenter.issue_path).to eq(project_work_items_path(project, work_items_path: presented_issue.id)) + end + end + + context 'when work_items feature flag is disabled' do + before do + stub_feature_flags(work_items: false) + end + + it 'returns an issue path for the task' do + expect(presenter.issue_path).to eq("/#{group.name}/#{project.name}/-/issues/#{presented_issue.iid}") + end + end end end |