2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-06 11:19:27 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Project member activity', :js do
|
2016-10-06 11:19:27 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public, name: 'x', namespace: user.namespace) }
|
2016-10-06 11:19:27 -04:00
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2016-10-06 11:19:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def visit_activities_and_wait_with_event(event_type)
|
2021-04-06 02:09:00 -04:00
|
|
|
Event.create!(project: project, author_id: user.id, action: event_type)
|
2017-06-29 13:06:35 -04:00
|
|
|
visit activity_project_path(project)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-10-06 11:19:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a user joins the project' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
2020-05-28 11:08:02 -04:00
|
|
|
visit_activities_and_wait_with_event(:joined)
|
2017-06-14 14:18:56 -04:00
|
|
|
end
|
2016-10-06 11:19:27 -04:00
|
|
|
|
2018-11-06 09:33:42 -05:00
|
|
|
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
|
2016-10-06 11:19:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a user leaves the project' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
2020-05-28 11:08:02 -04:00
|
|
|
visit_activities_and_wait_with_event(:left)
|
2017-06-14 14:18:56 -04:00
|
|
|
end
|
2016-10-06 11:19:27 -04:00
|
|
|
|
2018-11-06 09:33:42 -05:00
|
|
|
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
|
2016-10-06 11:19:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a users membership expires for the project' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
2020-05-28 11:08:02 -04:00
|
|
|
visit_activities_and_wait_with_event(:expired)
|
2017-06-14 14:18:56 -04:00
|
|
|
end
|
2016-10-06 11:19:27 -04:00
|
|
|
|
|
|
|
it "presents the correct message" do
|
2018-11-06 09:33:42 -05:00
|
|
|
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")
|
2016-10-06 11:19:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|