BigW Consortium Gitlab

issues_spec.rb 3.75 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'Issues Feed'  do
4
  describe 'GET /issues' do
5 6
    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') }
7
    let!(:group)    { create(:group) }
8
    let!(:project)  { create(:project) }
9
    let!(:issue)    { create(:issue, author: user, assignees: [assignee], project: project) }
10

11 12 13 14
    before do
      project.team << [user, :developer]
      group.add_developer(user)
    end
15

16
    context 'when authenticated' do
17
      it 'renders atom feed' do
18
        sign_in user
19
        visit project_issues_path(project, :atom)
20

21 22
        expect(response_headers['Content-Type'])
          .to have_content('application/atom+xml')
23
        expect(body).to have_selector('title', text: "#{project.name} issues")
24
        expect(body).to have_selector('author email', text: issue.author_public_email)
25 26
        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)
27
        expect(body).to have_selector('entry summary', text: issue.title)
28
      end
29 30
    end

31
    context 'when authenticated via private token' do
32
      it 'renders atom feed' do
33
        visit project_issues_path(project, :atom,
Vinnie Okada committed
34
                                            private_token: user.private_token)
35

36 37
        expect(response_headers['Content-Type'])
          .to have_content('application/atom+xml')
38
        expect(body).to have_selector('title', text: "#{project.name} issues")
39
        expect(body).to have_selector('author email', text: issue.author_public_email)
40 41
        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)
42
        expect(body).to have_selector('entry summary', text: issue.title)
43
      end
44
    end
45

46
    context 'when authenticated via RSS token' do
47
      it 'renders atom feed' do
48
        visit project_issues_path(project, :atom,
49 50
                                            rss_token: user.rss_token)

51 52
        expect(response_headers['Content-Type'])
          .to have_content('application/atom+xml')
53 54 55 56 57 58 59 60
        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

61
    it "renders atom feed with url parameters for project issues" do
62
      visit project_issues_path(project,
63
                                          :atom, rss_token: user.rss_token, state: 'opened', assignee_id: user.id)
64 65

      link = find('link[type="application/atom+xml"]')
66
      params = CGI.parse(URI.parse(link[:href]).query)
67

68
      expect(params).to include('rss_token' => [user.rss_token])
69 70 71 72 73
      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
74
      visit issues_group_path(group, :atom, rss_token: user.rss_token, state: 'opened', assignee_id: user.id)
75 76

      link = find('link[type="application/atom+xml"]')
77
      params = CGI.parse(URI.parse(link[:href]).query)
78

79
      expect(params).to include('rss_token' => [user.rss_token])
80 81 82
      expect(params).to include('state' => ['opened'])
      expect(params).to include('assignee_id' => [user.id.to_s])
    end
83 84
  end
end