2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2017-07-17 10:38:43 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Issue Detail', :js do
|
2017-11-06 08:46:27 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let(:issue) { create(:issue, project: project, author: user) }
|
2017-07-17 10:38:43 -04:00
|
|
|
|
|
|
|
context 'when user displays the issue' do
|
|
|
|
before do
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the issue' do
|
|
|
|
page.within('.issuable-details') do
|
|
|
|
expect(find('h2')).to have_content(issue.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-23 16:53:35 -04:00
|
|
|
context 'when issue description has xss snippet' do
|
|
|
|
before do
|
|
|
|
issue.update!(description: '![xss" onload=alert(1);//](a)')
|
2020-02-11 10:08:44 -05:00
|
|
|
|
2018-08-23 16:53:35 -04:00
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
end
|
|
|
|
|
2020-03-04 16:07:54 -05:00
|
|
|
it 'encodes the description to prevent xss issues', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/207951' do
|
2018-08-23 16:53:35 -04:00
|
|
|
page.within('.issuable-details .detail-page-description') do
|
2020-02-11 10:08:44 -05:00
|
|
|
image = find('img.js-lazy-loaded')
|
|
|
|
|
2018-08-23 16:53:35 -04:00
|
|
|
expect(page).to have_selector('img', count: 1)
|
2020-02-11 10:08:44 -05:00
|
|
|
expect(image['onerror']).to be_nil
|
|
|
|
expect(image['src']).to end_with('/a')
|
2018-08-23 16:53:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-17 10:38:43 -04:00
|
|
|
context 'when edited by a user who is later deleted' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
|
2017-12-19 12:48:29 -05:00
|
|
|
page.find('.js-issuable-edit').click
|
2017-10-20 15:26:51 -04:00
|
|
|
fill_in 'issuable-title', with: 'issue title'
|
2017-07-17 10:38:43 -04:00
|
|
|
click_button 'Save'
|
2017-11-06 08:46:27 -05:00
|
|
|
wait_for_requests
|
2017-07-17 10:38:43 -04:00
|
|
|
|
2017-10-06 16:40:41 -04:00
|
|
|
Users::DestroyService.new(user).execute(user)
|
2017-07-17 10:38:43 -04:00
|
|
|
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the issue' do
|
|
|
|
page.within('.issuable-details') do
|
|
|
|
expect(find('h2')).to have_content(issue.reload.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|