2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Projects > Members > Maintainer adds member with expiration date', :js do
|
2016-09-13 17:45:13 +05:30
|
|
|
include Select2Helper
|
|
|
|
include ActiveSupport::Testing::TimeHelpers
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let_it_be(:maintainer) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let(:new_member) { create(:user) }
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
2021-01-03 14:25:43 +05:30
|
|
|
travel_to Time.now.utc.beginning_of_day
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(maintainer)
|
|
|
|
sign_in(maintainer)
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'expiration date is displayed in the members list' do
|
2021-01-03 14:25:43 +05:30
|
|
|
visit project_project_members_path(project)
|
|
|
|
|
|
|
|
page.within '.invite-users-form' do
|
|
|
|
select2(new_member.id, from: '#user_ids', multiple: true)
|
|
|
|
|
|
|
|
fill_in 'expires_at', with: 3.days.from_now.to_date
|
|
|
|
find_field('expires_at').native.send_keys :enter
|
|
|
|
|
|
|
|
click_on 'Invite'
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within "#project_member_#{project_member_id}" do
|
|
|
|
expect(page).to have_content('Expires in 3 days')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'changes expiration date' do
|
|
|
|
project.team.add_users([new_member.id], :developer, expires_at: Date.today.to_date)
|
|
|
|
visit project_project_members_path(project)
|
|
|
|
|
|
|
|
page.within "#project_member_#{project_member_id}" do
|
|
|
|
fill_in 'Expiration date', with: 3.days.from_now.to_date
|
|
|
|
find_field('Expiration date').native.send_keys :enter
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content('Expires in 3 days')
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'clears expiration date' do
|
|
|
|
project.team.add_users([new_member.id], :developer, expires_at: 3.days.from_now.to_date)
|
|
|
|
visit project_project_members_path(project)
|
|
|
|
|
|
|
|
page.within "#project_member_#{project_member_id}" do
|
|
|
|
expect(page).to have_content('Expires in 3 days')
|
|
|
|
|
|
|
|
find('.js-clear-input').click
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_content('Expires in')
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
def project_member_id
|
|
|
|
project.members.find_by(user_id: new_member).id
|
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|