gitlab-org--gitlab-foss/spec/features/projects/fork_spec.rb
Phil Hughes 8585ae61e7
Fix fork button being disabled for users who can fork to group
Previously the fork button was disabled for all users if they have
exceeded their project limit. This fixes that by changing the check
to see if the user can fork to a group instead of their own namespace.

This behaviour is already possible by visiting the new fork page
directly, so this just fixes the button being disabled.

Closes #38462
2017-09-29 10:51:26 +01:00

57 lines
1.3 KiB
Ruby

require 'spec_helper'
describe 'Project fork' do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
before do
sign_in user
end
it 'allows user to fork project' do
visit project_path(project)
expect(page).not_to have_css('a.disabled', text: 'Fork')
end
it 'disables fork button when user has exceeded project limit' do
user.projects_limit = 0
user.save!
visit project_path(project)
expect(page).to have_css('a.disabled', text: 'Fork')
end
context 'master in group' do
before do
group = create(:group)
group.add_master(user)
end
it 'allows user to fork project to group or to user namespace' do
visit project_path(project)
expect(page).not_to have_css('a.disabled', text: 'Fork')
click_link 'Fork'
expect(page).to have_css('.fork-thumbnail', count: 2)
expect(page).not_to have_css('.fork-thumbnail.disabled')
end
it 'allows user to fork project to group and not user when exceeded project limit' do
user.projects_limit = 0
user.save!
visit project_path(project)
expect(page).not_to have_css('a.disabled', text: 'Fork')
click_link 'Fork'
expect(page).to have_css('.fork-thumbnail', count: 2)
expect(page).to have_css('.fork-thumbnail.disabled')
end
end
end