2016-10-06 11:19:27 -04:00
|
|
|
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)
|
2017-02-23 18:55:01 -05:00
|
|
|
visit activity_namespace_project_path(project.namespace, project)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-10-06 11:19:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
subject { page.find(".event-title").text }
|
|
|
|
|
|
|
|
context 'when a user joins the project' do
|
|
|
|
before { visit_activities_and_wait_with_event(Event::JOINED) }
|
|
|
|
|
2017-04-07 10:35:11 -04:00
|
|
|
it { is_expected.to eq("#{user.name} joined project") }
|
2016-10-06 11:19:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a user leaves the project' do
|
|
|
|
before { visit_activities_and_wait_with_event(Event::LEFT) }
|
|
|
|
|
2017-04-07 10:35:11 -04:00
|
|
|
it { is_expected.to eq("#{user.name} left project") }
|
2016-10-06 11:19:27 -04:00
|
|
|
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
|
2017-04-07 10:35:11 -04:00
|
|
|
message = "#{user.name} removed due to membership expiration from project"
|
2016-10-06 11:19:27 -04:00
|
|
|
is_expected.to eq(message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|