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