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 ActiveSupport::Testing::TimeHelpers
|
2021-03-11 19:13:27 +05:30
|
|
|
include Spec::Support::Helpers::Features::MembersHelpers
|
2021-06-08 01:23:25 +05:30
|
|
|
include Spec::Support::Helpers::Features::InviteMembersModalHelper
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let_it_be(:maintainer) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project) }
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
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
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
it 'expiration date is displayed in the members list' do
|
|
|
|
visit project_project_members_path(project)
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
invite_member(new_member.name, role: 'Guest', expires_at: 5.days.from_now.to_date)
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
page.within find_member_row(new_member) do
|
|
|
|
expect(page).to have_content(/in \d days/)
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
it 'changes 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)
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
page.within find_member_row(new_member) do
|
|
|
|
fill_in 'Expiration date', with: 5.days.from_now.to_date
|
|
|
|
find_field('Expiration date').native.send_keys :enter
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
wait_for_requests
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(page).to have_content(/in \d days/)
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
2021-04-17 20:07:23 +05:30
|
|
|
end
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
it 'clears expiration date' do
|
|
|
|
project.team.add_users([new_member.id], :developer, expires_at: 5.days.from_now.to_date)
|
|
|
|
visit project_project_members_path(project)
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
page.within find_member_row(new_member) do
|
|
|
|
expect(page).to have_content(/in \d days/)
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
find('[data-testid="clear-button"]').click
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
wait_for_requests
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(page).to have_content('No expiration set')
|
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
|