group_links_spec.rb 1.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
require 'spec_helper'

feature 'Projects > Members > Anonymous user sees members', feature: true, js: true do
  include WaitForAjax

  let(:user) { create(:user) }
  let(:group) { create(:group, :public) }
  let(:project) { create(:empty_project, :public) }

  background do
    project.team << [user, :master]
    @group_link = create(:project_group_link, project: project, group: group)

    login_as(user)
    visit namespace_project_project_members_path(project.namespace, project)
  end

  it 'updates group access level' do
    select 'Guest', from: "member_access_level_#{group.id}"
    wait_for_ajax

    visit namespace_project_project_members_path(project.namespace, project)

    expect(page).to have_select("member_access_level_#{group.id}", selected: 'Guest')
  end

  it 'updates expiry date' do
    tomorrow = Date.today + 3

    fill_in "member_expires_at_#{group.id}", with: tomorrow.strftime("%F")
    wait_for_ajax

33
    page.within(find('li.group_member')) do
Phil Hughes's avatar
Phil Hughes committed
34
      expect(page).to have_content('Expires in')
35 36
    end
  end
Phil Hughes's avatar
Phil Hughes committed
37 38 39 40 41 42 43 44 45

  it 'deletes group link' do
    page.within(first('.group_member')) do
      find('.btn-remove').click
    end
    wait_for_ajax

    expect(page).not_to have_selector('.group_member')
  end
Phil Hughes's avatar
Phil Hughes committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

  context 'search' do
    it 'finds no results' do
      page.within '.member-search-form' do
        fill_in 'search', with: 'testing 123'
        find('.member-search-btn').click
      end

      expect(page).not_to have_selector('.group_member')
    end

    it 'finds results' do
      page.within '.member-search-form' do
        fill_in 'search', with: group.name
        find('.member-search-btn').click
      end

      expect(page).to have_selector('.group_member', count: 1)
    end
  end
66
end