summaryrefslogtreecommitdiff
path: root/spec/features/dashboard/project_member_activity_index_spec.rb
blob: 8e7a0b2a6113f674727deb1fb636edeca84a19d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true

require 'spec_helper'

describe 'Project member activity', :js do
  let(:user)            { create(:user) }
  let(:project)         { create(:project, :public, name: 'x', namespace: user.namespace) }

  before do
    project.add_maintainer(user)
  end

  def visit_activities_and_wait_with_event(event_type)
    Event.create(project: project, author_id: user.id, action: event_type)
    visit activity_project_path(project)
    wait_for_requests
  end

  context 'when a user joins the project' do
    before do
      visit_activities_and_wait_with_event(Event::JOINED)
    end

    it "presents the correct message" do
      expect(page.find('.event-user-info').text).to eq("#{user.name} #{user.to_reference}")
      expect(page.find('.event-title').text).to eq("joined project")
    end
  end

  context 'when a user leaves the project' do
    before do
      visit_activities_and_wait_with_event(Event::LEFT)
    end

    it "presents the correct message" do
      expect(page.find('.event-user-info').text).to eq("#{user.name} #{user.to_reference}")
      expect(page.find('.event-title').text).to eq("left project")
    end
  end

  context 'when a users membership expires for the project' do
    before do
      visit_activities_and_wait_with_event(Event::EXPIRED)
    end

    it "presents the correct message" do
      expect(page.find('.event-user-info').text).to eq("#{user.name} #{user.to_reference}")
      expect(page.find('.event-title').text).to eq("removed due to membership expiration from project")
    end
  end
end