BigW Consortium Gitlab

group_links_spec.rb 2.09 KB
Newer Older
1 2
require 'spec_helper'

3
feature 'Project group links', :feature, :js do
4 5 6 7 8 9 10
  include Select2Helper

  let(:master) { create(:user) }
  let(:project) { create(:project) }
  let!(:group) { create(:group) }

  background do
11
    project.add_master(master)
12 13 14 15 16
    login_as(master)
  end

  context 'setting an expiration date for a group link' do
    before do
17
      visit namespace_project_settings_members_path(project.namespace, project)
18 19

      select2 group.id, from: '#link_group_id'
20
      fill_in 'expires_at_groups', with: (Time.current + 4.5.days).strftime('%Y-%m-%d')
21 22 23 24 25 26 27 28 29 30 31
      page.find('body').click
      click_on 'Share'
    end

    it 'shows the expiration time with a warning class' do
      page.within('.enabled-groups') do
        expect(page).to have_content('expires in 4 days')
        expect(page).to have_selector('.text-warning')
      end
    end
  end
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

  context 'nested group project' do
    let!(:nested_group) { create(:group, parent: group) }
    let!(:another_group) { create(:group) }
    let!(:project) { create(:project, namespace: nested_group) }

    background do
      group.add_master(master)
      another_group.add_master(master)
    end

    it 'does not show ancestors' do
      visit namespace_project_settings_members_path(project.namespace, project)

      click_link 'Search for a group'

      page.within '.select2-drop' do
        expect(page).to have_content(another_group.name)
        expect(page).not_to have_content(group.name)
      end
    end
  end
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

  describe 'the groups dropdown' do
    before do
      group_two = create(:group)
      group.add_owner(master)
      group_two.add_owner(master)

      visit namespace_project_settings_members_path(project.namespace, 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
74
end