Commit c485d2a0 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch '15013-fork-project-form-spec' into 'master'

Extract fork spec into legacy and new fork form

See merge request gitlab-org/gitlab!55461
parents ac532636 149da90b
......@@ -9,10 +9,10 @@ RSpec.describe 'Project fork' do
let(:project) { create(:project, :public, :repository) }
before do
stub_feature_flags(fork_project_form: false)
sign_in(user)
end
shared_examples 'fork button on project page' do
it 'allows user to fork project from the project page' do
visit project_path(project)
......@@ -29,29 +29,10 @@ RSpec.describe 'Project fork' do
expect(page).to have_css('a.disabled', text: 'Fork')
end
context 'with a group to fork to' do
let!(:group) { create(:group).tap { |group| group.add_owner(user) } }
it 'enables fork button on project page' do
visit project_path(project)
expect(page).not_to have_css('a.disabled', text: 'Fork')
end
it 'allows user to fork only to the group on fork page', :js do
visit new_project_fork_path(project)
to_personal_namespace = find('[data-qa-selector=fork_namespace_button].disabled')
to_group = find(".fork-groups button[data-qa-name=#{group.name}]")
expect(to_personal_namespace).not_to be_nil
expect(to_group).not_to be_disabled
end
end
end
context 'forking enabled / disabled in project settings' do
shared_examples 'create fork page' do |fork_page_text|
before do
project.project_feature.update_attribute(
:forking_access_level, forking_access_level)
......@@ -71,7 +52,7 @@ RSpec.describe 'Project fork' do
visit new_project_fork_path(project)
expect(page.status_code).to eq(200)
expect(page).to have_text(' Select a namespace to fork the project ')
expect(page).to have_text(fork_page_text)
end
end
......@@ -128,12 +109,45 @@ RSpec.describe 'Project fork' do
visit new_project_fork_path(project)
expect(page.status_code).to eq(200)
expect(page).to have_text(' Select a namespace to fork the project ')
expect(page).to have_text(fork_page_text)
end
end
end
end
it_behaves_like 'fork button on project page'
it_behaves_like 'create fork page', 'Fork project'
context 'with fork_project_form feature flag disabled' do
before do
stub_feature_flags(fork_project_form: false)
sign_in(user)
end
it_behaves_like 'fork button on project page'
context 'user has exceeded personal project limit' do
before do
user.update!(projects_limit: 0)
end
context 'with a group to fork to' do
let!(:group) { create(:group).tap { |group| group.add_owner(user) } }
it 'allows user to fork only to the group on fork page', :js do
visit new_project_fork_path(project)
to_personal_namespace = find('[data-qa-selector=fork_namespace_button].disabled')
to_group = find(".fork-groups button[data-qa-name=#{group.name}]")
expect(to_personal_namespace).not_to be_nil
expect(to_group).not_to be_disabled
end
end
end
it_behaves_like 'create fork page', ' Select a namespace to fork the project '
it 'forks the project', :sidekiq_might_not_need_inline do
visit project_path(project)
......@@ -297,4 +311,5 @@ RSpec.describe 'Project fork' do
expect(current_path).to eq(project_path(forked_project))
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment