dashboard_spec.rb 1.59 KB
Newer Older
randx's avatar
randx committed
1
2
require 'spec_helper'

3
describe "Dashboard Feed"  do
randx's avatar
randx committed
4
  describe "GET /" do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
5
    let!(:user) { create(:user, name: "Jonh") }
randx's avatar
randx committed
6

7
    context "projects atom feed via personal access token" do
8
      it "renders projects atom feed" do
9
10
11
        personal_access_token = create(:personal_access_token, user: user)

        visit dashboard_projects_path(:atom, private_token: personal_access_token.token)
Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
12
        expect(body).to have_selector('feed title')
13
      end
randx's avatar
randx committed
14
    end
15

16
    context "projects atom feed via feed token" do
17
      it "renders projects atom feed" do
18
        visit dashboard_projects_path(:atom, feed_token: user.feed_token)
19
20
21
22
        expect(body).to have_selector('feed title')
      end
    end

23
    context 'feed content' do
24
      let(:project) { create(:project) }
25
26
27
28
      let(:issue) { create(:issue, project: project, author: user, description: '') }
      let(:note) { create(:note, noteable: issue, author: user, note: 'Bug confirmed', project: project) }

      before do
29
        project.add_maintainer(user)
30
31
        issue_event(issue, user)
        note_event(note, user)
32
        visit dashboard_projects_path(:atom, feed_token: user.feed_token)
33
34
      end

35
      it "has issue opened event" do
36
        expect(body).to have_content("#{user.name} opened issue ##{issue.iid}")
37
38
      end

39
      it "has issue comment event" do
40
41
        expect(body)
          .to have_content("#{user.name} commented on issue ##{issue.iid}")
42
43
44
45
46
47
48
49
50
51
      end
    end
  end

  def issue_event(issue, user)
    EventCreateService.new.open_issue(issue, user)
  end

  def note_event(note, user)
    EventCreateService.new.leave_note(note, user)
randx's avatar
randx committed
52
53
  end
end