2012-08-03 16:49:54 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
describe 'Issues Feed' do
|
2015-02-12 18:53:23 +00:00
|
|
|
describe 'GET /issues' do
|
2017-02-16 23:41:34 +00:00
|
|
|
let!(:user) { create(:user, email: 'private1@example.com', public_email: 'public1@example.com') }
|
|
|
|
let!(:assignee) { create(:user, email: 'private2@example.com', public_email: 'public2@example.com') }
|
2016-11-03 10:29:37 +00:00
|
|
|
let!(:group) { create(:group) }
|
2017-08-02 19:55:11 +00:00
|
|
|
let!(:project) { create(:project) }
|
2017-05-04 12:11:15 +00:00
|
|
|
let!(:issue) { create(:issue, author: user, assignees: [assignee], project: project) }
|
2012-09-12 12:01:50 +00:00
|
|
|
|
2016-11-03 10:29:37 +00:00
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_developer(user)
|
2016-11-03 10:29:37 +00:00
|
|
|
group.add_developer(user)
|
|
|
|
end
|
2012-09-12 12:01:50 +00:00
|
|
|
|
2015-02-12 18:53:23 +00:00
|
|
|
context 'when authenticated' do
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'renders atom feed' do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in user
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_issues_path(project, :atom)
|
2012-09-12 12:01:50 +00:00
|
|
|
|
2017-06-21 13:48:12 +00:00
|
|
|
expect(response_headers['Content-Type'])
|
|
|
|
.to have_content('application/atom+xml')
|
2015-02-12 18:53:23 +00:00
|
|
|
expect(body).to have_selector('title', text: "#{project.name} issues")
|
2017-02-16 23:41:34 +00:00
|
|
|
expect(body).to have_selector('author email', text: issue.author_public_email)
|
2017-05-05 13:57:27 +00:00
|
|
|
expect(body).to have_selector('assignees assignee email', text: issue.assignees.first.public_email)
|
|
|
|
expect(body).to have_selector('assignee email', text: issue.assignees.first.public_email)
|
2015-02-12 18:53:23 +00:00
|
|
|
expect(body).to have_selector('entry summary', text: issue.title)
|
2012-09-12 12:01:50 +00:00
|
|
|
end
|
2012-08-03 16:49:54 +00:00
|
|
|
end
|
|
|
|
|
2017-10-12 09:01:12 +00:00
|
|
|
context 'when authenticated via personal access token' do
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'renders atom feed' do
|
2017-10-12 09:01:12 +00:00
|
|
|
personal_access_token = create(:personal_access_token, user: user)
|
|
|
|
|
2017-06-29 17:06:35 +00:00
|
|
|
visit project_issues_path(project, :atom,
|
2017-10-12 09:01:12 +00:00
|
|
|
private_token: personal_access_token.token)
|
2012-08-03 16:49:54 +00:00
|
|
|
|
2017-06-21 13:48:12 +00:00
|
|
|
expect(response_headers['Content-Type'])
|
|
|
|
.to have_content('application/atom+xml')
|
2015-02-12 18:53:23 +00:00
|
|
|
expect(body).to have_selector('title', text: "#{project.name} issues")
|
2017-02-16 23:41:34 +00:00
|
|
|
expect(body).to have_selector('author email', text: issue.author_public_email)
|
2017-05-05 13:57:27 +00:00
|
|
|
expect(body).to have_selector('assignees assignee email', text: issue.assignees.first.public_email)
|
|
|
|
expect(body).to have_selector('assignee email', text: issue.assignees.first.public_email)
|
2015-02-12 18:53:23 +00:00
|
|
|
expect(body).to have_selector('entry summary', text: issue.title)
|
2012-09-12 12:01:50 +00:00
|
|
|
end
|
2012-08-03 16:49:54 +00:00
|
|
|
end
|
2016-11-03 10:29:37 +00:00
|
|
|
|
2018-05-31 14:01:04 +00:00
|
|
|
context 'when authenticated via feed token' do
|
2017-05-23 13:59:33 +00:00
|
|
|
it 'renders atom feed' do
|
2017-06-29 17:06:35 +00:00
|
|
|
visit project_issues_path(project, :atom,
|
2018-05-31 14:01:04 +00:00
|
|
|
feed_token: user.feed_token)
|
2017-05-23 13:59:33 +00:00
|
|
|
|
2017-06-21 13:48:12 +00:00
|
|
|
expect(response_headers['Content-Type'])
|
|
|
|
.to have_content('application/atom+xml')
|
2017-05-23 13:59:33 +00:00
|
|
|
expect(body).to have_selector('title', text: "#{project.name} issues")
|
|
|
|
expect(body).to have_selector('author email', text: issue.author_public_email)
|
|
|
|
expect(body).to have_selector('assignees assignee email', text: issue.assignees.first.public_email)
|
|
|
|
expect(body).to have_selector('assignee email', text: issue.assignees.first.public_email)
|
|
|
|
expect(body).to have_selector('entry summary', text: issue.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-03 10:29:37 +00:00
|
|
|
it "renders atom feed with url parameters for project issues" do
|
2018-05-31 14:01:04 +00:00
|
|
|
visit project_issues_path(project, :atom, feed_token: user.feed_token, state: 'opened', assignee_id: user.id)
|
2016-11-03 10:29:37 +00:00
|
|
|
|
|
|
|
link = find('link[type="application/atom+xml"]')
|
2017-02-22 00:51:36 +00:00
|
|
|
params = CGI.parse(URI.parse(link[:href]).query)
|
2016-11-03 10:29:37 +00:00
|
|
|
|
2018-05-31 14:01:04 +00:00
|
|
|
expect(params).to include('feed_token' => [user.feed_token])
|
2016-11-03 10:29:37 +00:00
|
|
|
expect(params).to include('state' => ['opened'])
|
|
|
|
expect(params).to include('assignee_id' => [user.id.to_s])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "renders atom feed with url parameters for group issues" do
|
2018-05-31 14:01:04 +00:00
|
|
|
visit issues_group_path(group, :atom, feed_token: user.feed_token, state: 'opened', assignee_id: user.id)
|
2016-11-03 10:29:37 +00:00
|
|
|
|
|
|
|
link = find('link[type="application/atom+xml"]')
|
2017-02-22 00:51:36 +00:00
|
|
|
params = CGI.parse(URI.parse(link[:href]).query)
|
2016-11-03 10:29:37 +00:00
|
|
|
|
2018-05-31 14:01:04 +00:00
|
|
|
expect(params).to include('feed_token' => [user.feed_token])
|
2016-11-03 10:29:37 +00:00
|
|
|
expect(params).to include('state' => ['opened'])
|
|
|
|
expect(params).to include('assignee_id' => [user.id.to_s])
|
|
|
|
end
|
2012-08-03 16:49:54 +00:00
|
|
|
end
|
|
|
|
end
|