2020-05-24 23:13:21 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Groups > Members > Owner adds member with expiration date', :js do
|
2020-05-24 23:13:21 +05:30
|
|
|
include Select2Helper
|
|
|
|
include ActiveSupport::Testing::TimeHelpers
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let_it_be(:user1) { create(:user, name: 'John Doe') }
|
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let(:new_member) { create(:user, name: 'Mary Jane') }
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
before do
|
2020-11-24 15:15:51 +05:30
|
|
|
stub_feature_flags(vue_group_members_list: false)
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
travel_to Time.now.utc.beginning_of_day
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
group.add_owner(user1)
|
|
|
|
sign_in(user1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'expiration date is displayed in the members list' do
|
2021-01-03 14:25:43 +05:30
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
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 "#group_member_#{group_member_id}" do
|
|
|
|
expect(page).to have_content('Expires in 3 days')
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'changes expiration date' do
|
|
|
|
group.add_developer(new_member)
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
page.within "#group_member_#{group_member_id}" do
|
|
|
|
fill_in 'Expiration date', with: 3.days.from_now.to_date
|
|
|
|
find_field('Expiration date').native.send_keys :enter
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
wait_for_requests
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
expect(page).to have_content('Expires in 3 days')
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'clears expiration date' do
|
|
|
|
create(:group_member, :developer, user: new_member, group: group, expires_at: 3.days.from_now.to_date)
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
page.within "#group_member_#{group_member_id}" do
|
|
|
|
expect(page).to have_content('Expires in 3 days')
|
|
|
|
|
|
|
|
find('.js-clear-input').click
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
wait_for_requests
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
expect(page).not_to have_content('Expires in')
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
def group_member_id
|
2020-05-24 23:13:21 +05:30
|
|
|
group.members.find_by(user_id: new_member).id
|
|
|
|
end
|
|
|
|
end
|