debian-mirror-gitlab/spec/views/projects/issues/show.html.haml_spec.rb

153 lines
4.5 KiB
Ruby
Raw Normal View History

2019-03-02 22:35:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe 'projects/issues/show' do
2020-05-24 23:13:21 +05:30
include_context 'project show action'
2019-03-02 22:35:43 +05:30
context 'when the issue is closed' do
before do
allow(issue).to receive(:closed?).and_return(true)
2019-07-07 11:18:12 +05:30
allow(view).to receive(:current_user).and_return(user)
2019-03-02 22:35:43 +05:30
end
2019-07-07 11:18:12 +05:30
context 'when the issue was moved' do
let(:new_issue) { create(:issue, project: project, author: user) }
2019-03-02 22:35:43 +05:30
2019-07-07 11:18:12 +05:30
before do
issue.moved_to = new_issue
end
context 'when user can see the moved issue' do
before do
project.add_developer(user)
end
2020-07-28 23:09:34 +05:30
it 'shows "Closed (moved)" if an issue has been moved and closed' do
2019-07-07 11:18:12 +05:30
render
expect(rendered).to have_selector('.status-box-issue-closed:not(.hidden)', text: 'Closed (moved)')
end
2019-12-04 20:38:33 +05:30
it 'shows "Closed (moved)" if an issue has been moved and discussion is locked' do
allow(issue).to receive(:discussion_locked).and_return(true)
render
expect(rendered).to have_selector('.status-box-issue-closed:not(.hidden)', text: 'Closed (moved)')
end
2019-07-07 11:18:12 +05:30
it 'links "moved" to the new issue the original issue was moved to' do
render
expect(rendered).to have_selector("a[href=\"#{issue_path(new_issue)}\"]", text: 'moved')
end
2020-07-28 23:09:34 +05:30
it 'does not show "closed (moved)" if an issue has been moved and reopened (not closed)' do
allow(issue).to receive(:closed?).and_return(false)
render
expect(rendered).not_to have_selector('.status-box-issue-closed:not(.hidden)', text: 'Closed (moved)')
end
2019-07-07 11:18:12 +05:30
end
context 'when user cannot see moved issue' do
it 'does not show moved issue link' do
render
2019-03-02 22:35:43 +05:30
2019-07-07 11:18:12 +05:30
expect(rendered).not_to have_selector("a[href=\"#{issue_path(new_issue)}\"]", text: 'moved')
end
end
2019-03-02 22:35:43 +05:30
end
2019-12-04 20:38:33 +05:30
context 'when the issue was duplicated' do
let(:new_issue) { create(:issue, project: project, author: user) }
before do
issue.duplicated_to = new_issue
end
context 'when user can see the duplicated issue' do
before do
project.add_developer(user)
end
it 'shows "Closed (duplicated)" if an issue has been duplicated' do
render
expect(rendered).to have_selector('.status-box-issue-closed:not(.hidden)', text: 'Closed (duplicated)')
end
it 'links "duplicated" to the new issue the original issue was duplicated to' do
render
expect(rendered).to have_selector("a[href=\"#{issue_path(new_issue)}\"]", text: 'duplicated')
end
end
context 'when user cannot see duplicated issue' do
it 'does not show duplicated issue link' do
render
expect(rendered).not_to have_selector("a[href=\"#{issue_path(new_issue)}\"]", text: 'duplicated')
end
end
end
it 'shows "Closed" if an issue has not been moved or duplicated' do
render
expect(rendered).to have_selector('.status-box-issue-closed:not(.hidden)', text: 'Closed')
end
it 'shows "Closed" if discussion is locked' do
allow(issue).to receive(:discussion_locked).and_return(true)
2019-03-02 22:35:43 +05:30
render
expect(rendered).to have_selector('.status-box-issue-closed:not(.hidden)', text: 'Closed')
end
end
context 'when the issue is open' do
before do
allow(issue).to receive(:closed?).and_return(false)
2019-12-04 20:38:33 +05:30
allow(issue).to receive(:discussion_locked).and_return(false)
2019-03-02 22:35:43 +05:30
end
it 'shows "Open" if an issue has been moved' do
render
expect(rendered).to have_selector('.status-box-open:not(.hidden)', text: 'Open')
end
2019-12-04 20:38:33 +05:30
it 'shows "Open" if discussion is locked' do
allow(issue).to receive(:discussion_locked).and_return(true)
render
expect(rendered).to have_selector('.status-box-open:not(.hidden)', text: 'Open')
end
2019-03-02 22:35:43 +05:30
end
2020-03-13 15:44:24 +05:30
context 'when the issue is related to a sentry error' do
it 'renders a stack trace' do
sentry_issue = double(:sentry_issue, sentry_issue_identifier: '1066622')
allow(issue).to receive(:sentry_issue).and_return(sentry_issue)
render
expect(rendered).to have_selector(
"#js-sentry-error-stack-trace"\
"[data-issue-stack-trace-path="\
"\"/#{project.full_path}/-/error_tracking/1066622/stack_trace.json\"]"
)
end
end
context 'when the issue is not related to a sentry error' do
it 'does not render a stack trace' do
render
expect(rendered).not_to have_selector('#js-sentry-error-stack-trace')
end
end
2019-03-02 22:35:43 +05:30
end