BigW Consortium Gitlab

project_member_activity_index_spec.rb 1.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
require 'spec_helper'

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

  before do
    project.team << [user, :master]
  end

  def visit_activities_and_wait_with_event(event_type)
    Event.create(project: project, author_id: user.id, action: event_type)
13
    visit activity_namespace_project_path(project.namespace, project)
14 15 16 17 18 19 20 21
    wait_for_ajax
  end

  subject { page.find(".event-title").text }

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

22
    it { is_expected.to eq("#{user.name} joined project") }
23 24 25 26 27
  end

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

28
    it { is_expected.to eq("#{user.name} left project") }
29 30 31 32 33 34
  end

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

    it "presents the correct message" do
35
      message = "#{user.name} removed due to membership expiration from project"
36 37 38 39
      is_expected.to eq(message)
    end
  end
end