BigW Consortium Gitlab

user_transfers_a_project_spec.rb 1.14 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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
require 'spec_helper'

feature 'User transfers a project', :js do
  let(:user) { create(:user) }
  let(:project) { create(:project, :repository, namespace: user.namespace) }

  before do
    sign_in user
  end

  def transfer_project(project, group)
    visit edit_project_path(project)

    page.within('.js-project-transfer-form') do
      page.find('.select2-container').click
    end

    page.find("div[role='option']", text: group.full_name).click

    click_button('Transfer project')

    fill_in 'confirm_name_input', with: project.name

    click_button 'Confirm'

    wait_for_requests
  end

  it 'allows transferring a project to a subgroup of a namespace' do
    group = create(:group)
    group.add_owner(user)

    transfer_project(project, group)

    expect(project.reload.namespace).to eq(group)
  end

  context 'when nested groups are available', :nested_groups do
    it 'allows transferring a project to a subgroup' do
      parent = create(:group)
      parent.add_owner(user)
      subgroup = create(:group, parent: parent)

      transfer_project(project, subgroup)

      expect(project.reload.namespace).to eq(subgroup)
    end
  end
end