BigW Consortium Gitlab

dashboard_spec.rb 1.32 KB
Newer Older
randx committed
1 2
require 'spec_helper'

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

7 8
    context "projects atom feed via private token" do
      it "should render projects atom feed" do
Douwe Maan committed
9
        visit dashboard_projects_path(:atom, private_token: user.private_token)
10
        expect(body).to have_selector('feed title')
11
      end
randx committed
12
    end
13 14 15 16 17 18 19 20 21 22

    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)
Douwe Maan committed
23
        visit dashboard_projects_path(:atom, private_token: user.private_token)
24 25 26
      end

      it "should have issue opened event" do
27
        expect(body).to have_content("#{user.name} opened issue ##{issue.iid}")
28 29 30
      end

      it "should have issue comment event" do
31 32
        expect(body).
          to have_content("#{user.name} commented on issue ##{issue.iid}")
33 34 35 36 37 38 39 40 41 42
      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 committed
43 44
  end
end