diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-09-13 20:21:33 +0300 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-09-13 20:21:33 +0300 |
commit | 4c0beb6c024b25ff24c7c2ea966bacab0ee860d5 (patch) | |
tree | f3e61556a1cc9132f439d222dca9d6366eb8a6ca /spec/features/projects/members | |
parent | 2d58626a33bc0d4e78eaf0c25965d18a6239fa3b (diff) | |
parent | 33010da28b0f2e00e96cc4bf6c439363905a81d5 (diff) |
Merge branch 'master' into sh-headless-chrome-support
Diffstat (limited to 'spec/features/projects/members')
-rw-r--r-- | spec/features/projects/members/groups_with_access_list_spec.rb (renamed from spec/features/projects/members/group_links_spec.rb) | 14 | ||||
-rw-r--r-- | spec/features/projects/members/share_with_group_spec.rb | 191 |
2 files changed, 198 insertions, 7 deletions
diff --git a/spec/features/projects/members/group_links_spec.rb b/spec/features/projects/members/groups_with_access_list_spec.rb index 1c348b987d4..9950272af08 100644 --- a/spec/features/projects/members/group_links_spec.rb +++ b/spec/features/projects/members/groups_with_access_list_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Projects > Members > Anonymous user sees members', js: true do +feature 'Projects > Members > Groups with access list', js: true do let(:user) { create(:user) } let(:group) { create(:group, :public) } let(:project) { create(:project, :public) } @@ -13,7 +13,7 @@ feature 'Projects > Members > Anonymous user sees members', js: true do visit project_settings_members_path(project) end - it 'updates group access level' do + scenario 'updates group access level' do click_button @group_link.human_access page.within '.dropdown-menu' do @@ -27,7 +27,7 @@ feature 'Projects > Members > Anonymous user sees members', js: true do expect(first('.group_member')).to have_content('Guest') end - it 'updates expiry date' do + scenario 'updates expiry date' do tomorrow = Date.today + 3 fill_in "member_expires_at_#{group.id}", with: tomorrow.strftime("%F") @@ -38,7 +38,7 @@ feature 'Projects > Members > Anonymous user sees members', js: true do end end - it 'deletes group link' do + scenario 'deletes group link' do page.within(first('.group_member')) do find('.btn-remove').click end @@ -47,8 +47,8 @@ feature 'Projects > Members > Anonymous user sees members', js: true do expect(page).not_to have_selector('.group_member') end - context 'search' do - it 'finds no results' do + context 'search in existing members (yes, this filters the groups list as well)' do + scenario 'finds no results' do page.within '.member-search-form' do fill_in 'search', with: 'testing 123' find('.member-search-btn').click @@ -57,7 +57,7 @@ feature 'Projects > Members > Anonymous user sees members', js: true do expect(page).not_to have_selector('.group_member') end - it 'finds results' do + scenario 'finds results' do page.within '.member-search-form' do fill_in 'search', with: group.name find('.member-search-btn').click diff --git a/spec/features/projects/members/share_with_group_spec.rb b/spec/features/projects/members/share_with_group_spec.rb new file mode 100644 index 00000000000..3b368f8e25d --- /dev/null +++ b/spec/features/projects/members/share_with_group_spec.rb @@ -0,0 +1,191 @@ +require 'spec_helper' + +feature 'Project > Members > Share with Group', :js do + include Select2Helper + include ActionView::Helpers::DateHelper + + let(:master) { create(:user) } + + describe 'Share with group lock' do + shared_examples 'the project can be shared with groups' do + scenario 'the "Share with group" tab exists' do + visit project_settings_members_path(project) + expect(page).to have_selector('#share-with-group-tab') + end + end + + shared_examples 'the project cannot be shared with groups' do + scenario 'the "Share with group" tab does not exist' do + visit project_settings_members_path(project) + expect(page).to have_selector('#add-member-tab') + expect(page).not_to have_selector('#share-with-group-tab') + end + end + + context 'for a project in a root group' do + let!(:group_to_share_with) { create(:group) } + let(:project) { create(:project, namespace: create(:group)) } + + background do + project.add_master(master) + sign_in(master) + end + + context 'when the group has "Share with group lock" disabled' do + it_behaves_like 'the project can be shared with groups' + + scenario 'the project can be shared with another group' do + visit project_settings_members_path(project) + + click_on 'share-with-group-tab' + + select2 group_to_share_with.id, from: '#link_group_id' + page.find('body').click + find('.btn-create').trigger('click') + + page.within('.project-members-groups') do + expect(page).to have_content(group_to_share_with.name) + end + end + end + + context 'when the group has "Share with group lock" enabled' do + before do + project.namespace.update_column(:share_with_group_lock, true) + end + + it_behaves_like 'the project cannot be shared with groups' + end + end + + context 'for a project in a subgroup', :nested_groups do + let!(:group_to_share_with) { create(:group) } + let(:root_group) { create(:group) } + let(:subgroup) { create(:group, parent: root_group) } + let(:project) { create(:project, namespace: subgroup) } + + background do + project.add_master(master) + sign_in(master) + end + + context 'when the root_group has "Share with group lock" disabled' do + context 'when the subgroup has "Share with group lock" disabled' do + it_behaves_like 'the project can be shared with groups' + end + + context 'when the subgroup has "Share with group lock" enabled' do + before do + subgroup.update_column(:share_with_group_lock, true) + end + + it_behaves_like 'the project cannot be shared with groups' + end + end + + context 'when the root_group has "Share with group lock" enabled' do + before do + root_group.update_column(:share_with_group_lock, true) + end + + context 'when the subgroup has "Share with group lock" disabled (parent overridden)' do + it_behaves_like 'the project can be shared with groups' + end + + context 'when the subgroup has "Share with group lock" enabled' do + before do + subgroup.update_column(:share_with_group_lock, true) + end + + it_behaves_like 'the project cannot be shared with groups' + end + end + end + end + + describe 'setting an expiration date for a group link' do + let(:project) { create(:project) } + let!(:group) { create(:group) } + + around do |example| + Timecop.freeze { example.run } + end + + before do + project.add_master(master) + sign_in(master) + + visit project_settings_members_path(project) + + click_on 'share-with-group-tab' + + select2 group.id, from: '#link_group_id' + + fill_in 'expires_at_groups', with: (Time.now + 4.5.days).strftime('%Y-%m-%d') + page.find('body').click + find('.btn-create').trigger('click') + end + + scenario 'the group link shows the expiration time with a warning class' do + page.within('.project-members-groups') do + # Using distance_of_time_in_words_to_now because it is not the same as + # subtraction, and this way avoids time zone issues as well + expires_in_text = distance_of_time_in_words_to_now(project.project_group_links.first.expires_at) + expect(page).to have_content(expires_in_text) + expect(page).to have_selector('.text-warning') + end + end + end + + describe 'the groups dropdown' do + context 'with multiple groups to choose from' do + let(:project) { create(:project) } + + background do + project.add_master(master) + sign_in(master) + + create(:group).add_owner(master) + create(:group).add_owner(master) + + visit project_settings_members_path(project) + execute_script 'GroupsSelect.PER_PAGE = 1;' + open_select2 '#link_group_id' + end + + it 'should infinitely scroll' do + expect(find('.select2-drop .select2-results')).to have_selector('.select2-result', count: 1) + + scroll_select2_to_bottom('.select2-drop .select2-results:visible') + + expect(find('.select2-drop .select2-results')).to have_selector('.select2-result', count: 2) + end + end + + context 'for a project in a nested group' do + let(:group) { create(:group) } + let!(:nested_group) { create(:group, parent: group) } + let!(:group_to_share_with) { create(:group) } + let!(:project) { create(:project, namespace: nested_group) } + + background do + project.add_master(master) + sign_in(master) + group.add_master(master) + group_to_share_with.add_master(master) + end + + scenario 'the groups dropdown does not show ancestors', :nested_groups do + visit project_settings_members_path(project) + + click_on 'share-with-group-tab' + click_link 'Search for a group' + + page.within '.select2-drop' do + expect(page).to have_content(group_to_share_with.name) + expect(page).not_to have_content(group.name) + end + end + end + end +end |