debian-mirror-gitlab/spec/features/issues/issue_detail_spec.rb

61 lines
1.6 KiB
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
require 'rails_helper'
2018-11-08 19:23:39 +05:30
describe 'Issue Detail', :js do
2018-03-17 18:26:18 +05:30
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project, author: user) }
2017-09-10 17:25:29 +05:30
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-11-08 19:23:39 +05:30
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-05-18 00:54:41 +05:30
it 'encodes the description to prevent xss issues' do
2018-11-08 19:23:39 +05:30
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-09-10 17:25:29 +05:30
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
2018-03-17 18:26:18 +05:30
page.find('.js-issuable-edit').click
fill_in 'issuable-title', with: 'issue title'
2017-09-10 17:25:29 +05:30
click_button 'Save'
2018-03-17 18:26:18 +05:30
wait_for_requests
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
Users::DestroyService.new(user).execute(user)
2017-09-10 17:25:29 +05:30
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