diff options
Diffstat (limited to 'spec/features/projects/members')
3 files changed, 81 insertions, 39 deletions
diff --git a/spec/features/projects/members/groups_with_access_list_spec.rb b/spec/features/projects/members/groups_with_access_list_spec.rb index 2ee6bc103e9..d59f8eb4b1d 100644 --- a/spec/features/projects/members/groups_with_access_list_spec.rb +++ b/spec/features/projects/members/groups_with_access_list_spec.rb @@ -3,20 +3,23 @@ require 'spec_helper' RSpec.describe 'Projects > Members > Groups with access list', :js do - let(:user) { create(:user) } - let(:group) { create(:group, :public) } - let(:project) { create(:project, :public) } + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group, :public) } + let_it_be(:project) { create(:project, :public) } + + let(:additional_link_attrs) { {} } + let!(:group_link) { create(:project_group_link, project: project, group: group, **additional_link_attrs) } before do - project.add_maintainer(user) - @group_link = create(:project_group_link, project: project, group: group) + travel_to Time.now.utc.beginning_of_day + project.add_maintainer(user) sign_in(user) visit project_project_members_path(project) end it 'updates group access level' do - click_button @group_link.human_access + click_button group_link.human_access page.within '.dropdown-menu' do click_link 'Guest' @@ -30,20 +33,38 @@ RSpec.describe 'Projects > Members > Groups with access list', :js do end it 'updates expiry date' do - tomorrow = Date.today + 3 + expires_at_field = "member_expires_at_#{group.id}" + fill_in expires_at_field, with: 3.days.from_now.to_date - fill_in "member_expires_at_#{group.id}", with: tomorrow.strftime("%F") - find('body').click + find_field(expires_at_field).native.send_keys :enter wait_for_requests page.within(find('li.group_member')) do - expect(page).to have_content('Expires in') + expect(page).to have_content('Expires in 3 days') + end + end + + context 'when link has expiry date set' do + let(:additional_link_attrs) { { expires_at: 3.days.from_now.to_date } } + + it 'clears expiry date' do + page.within(find('li.group_member')) do + expect(page).to have_content('Expires in 3 days') + + page.within(find('.js-edit-member-form')) do + find('.js-clear-input').click + end + + wait_for_requests + + expect(page).not_to have_content('Expires in') + end end end it 'deletes group link' do page.within(first('.group_member')) do - accept_confirm { find('.btn-remove').click } + accept_confirm { find('.btn-danger').click } end wait_for_requests diff --git a/spec/features/projects/members/list_spec.rb b/spec/features/projects/members/list_spec.rb index b32ccb0ccef..36ff461aac2 100644 --- a/spec/features/projects/members/list_spec.rb +++ b/spec/features/projects/members/list_spec.rb @@ -102,7 +102,7 @@ RSpec.describe 'Project members list' do visit_members_page expect(page).not_to have_selector("#edit_project_member_#{project_member.id}") - expect(page).not_to have_selector("#project_member_#{project_member.id} .btn-remove") + expect(page).to have_no_selector("#project_member_#{project_member.id} .btn-danger") end end diff --git a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb index 979bbd57aa3..d69c3f2652c 100644 --- a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb +++ b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb @@ -6,43 +6,64 @@ RSpec.describe 'Projects > Members > Maintainer adds member with expiration date include Select2Helper include ActiveSupport::Testing::TimeHelpers - let(:maintainer) { create(:user) } - let(:project) { create(:project) } - let!(:new_member) { create(:user) } + let_it_be(:maintainer) { create(:user) } + let_it_be(:project) { create(:project) } + let(:new_member) { create(:user) } before do + travel_to Time.now.utc.beginning_of_day + project.add_maintainer(maintainer) sign_in(maintainer) end it 'expiration date is displayed in the members list' do - travel_to Time.zone.parse('2016-08-06 08:00') do - date = 4.days.from_now - 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: date.to_s(:medium) + "\n" - click_on 'Invite' - end - - page.within "#project_member_#{new_member.project_members.first.id}" do - expect(page).to have_content('Expires in 4 days') - end + 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') end end - it 'change expiration date' do - travel_to Time.zone.parse('2016-08-06 08:00') do - date = 3.days.from_now - project.team.add_users([new_member.id], :developer, expires_at: Date.today.to_s(:medium)) - visit project_project_members_path(project) - - page.within "#project_member_#{new_member.project_members.first.id}" do - find('.js-access-expiration-date').set date.to_s(:medium) + "\n" - wait_for_requests - expect(page).to have_content('Expires in 3 days') - end + 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') end end + + def project_member_id + project.members.find_by(user_id: new_member).id + end end |