BigW Consortium Gitlab

users_spec.rb 1.39 KB
Newer Older
1 2 3 4 5 6
require 'spec_helper'

describe "User Feed", feature: true  do
  describe "GET /" do
    let!(:user) { create(:user) }

7
    context 'user atom feed via private token' do
8 9
      it "should render user atom feed" do
        visit user_path(user, :atom, private_token: user.private_token)
10
        expect(body).to have_selector('feed title')
11 12 13 14 15
      end
    end

    context 'feed content' do
      let(:project) { create(:project) }
16 17 18 19 20 21 22 23
      let(:issue) do
        create(:issue, project: project,
               author: user, description: '')
      end
      let(:note) do
        create(:note, noteable: issue, author: user,
               note: 'Bug confirmed', project: project)
      end
24 25 26 27 28 29 30 31

      before do
        project.team << [user, :master]
        issue_event(issue, user)
        note_event(note, user)
        visit user_path(user, :atom, private_token: user.private_token)
      end

32
      it 'should have issue opened event' do
33
        expect(body).to have_content("#{safe_name} opened issue ##{issue.iid}")
34 35
      end

36
      it 'should have issue comment event' do
37 38
        expect(body).
          to have_content("#{safe_name} commented on issue ##{issue.iid}")
39 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)
  end
50 51 52 53

  def safe_name
    html_escape(user.name)
  end
54
end