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

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

7
    context "projects atom feed via private token" do
8
      it "renders projects atom feed" do
Douwe Maan's avatar
Douwe Maan committed
9
        visit dashboard_projects_path(:atom, private_token: user.private_token)
Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
10
        expect(body).to have_selector('feed title')
11
      end
randx's avatar
randx committed
12
    end
13

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

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

      before do
        project.team << [user, :master]
        issue_event(issue, user)
        note_event(note, user)
30
        visit dashboard_projects_path(:atom, rss_token: user.rss_token)
31 32
      end

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

37
      it "has issue comment event" do
Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
38 39
        expect(body).
          to have_content("#{user.name} commented on issue ##{issue.iid}")
40 41 42 43 44 45 46 47 48 49
      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
50 51
  end
end