2017-07-17 10:38:43 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
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)')
|
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'encodes the description to prevent xss issues' do
|
2018-08-23 16:53:35 -04:00
|
|
|
page.within('.issuable-details .detail-page-description') do
|
|
|
|
expect(page).to have_selector('img', count: 1)
|
|
|
|
expect(find('img')['onerror']).to be_nil
|
|
|
|
expect(find('img')['src']).to end_with('/a')
|
|
|
|
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
|