Commit 149da90b authored by Samantha Ming's avatar Samantha Ming Committed by Mark Lapierre

Split fork spec into FF enable or disable

Part of issue: https://gitlab.com/gitlab-org/gitlab/-/issues/15013
parent 2dc5ffc1
......@@ -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