2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-18 06:44:12 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe 'User views an empty project' do
|
2021-06-07 11:09:56 -04:00
|
|
|
let_it_be(:project) { create(:project, :empty_repo) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
2018-04-18 06:44:12 -04:00
|
|
|
|
|
|
|
shared_examples 'allowing push to default branch' do
|
2021-07-12 08:09:39 -04:00
|
|
|
let(:default_branch) { project.default_branch_or_main }
|
|
|
|
|
|
|
|
it 'shows push-to-default-branch instructions' do
|
2018-04-18 06:44:12 -04:00
|
|
|
visit project_path(project)
|
|
|
|
|
2021-07-12 08:09:39 -04:00
|
|
|
expect(page).to have_content("git push -u origin #{default_branch}")
|
2018-04-18 06:44:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-07 11:09:56 -04:00
|
|
|
context 'when user is a maintainer' do
|
2018-04-18 06:44:12 -04:00
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2020-11-23 10:09:37 -05:00
|
|
|
sign_in(user)
|
2018-04-18 06:44:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'allowing push to default branch'
|
2021-06-07 11:09:56 -04:00
|
|
|
|
|
|
|
it 'shows a link for inviting members and launches invite modal', :js do
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
click_button 'Invite members'
|
|
|
|
|
|
|
|
expect(page).to have_content("You're inviting members to the")
|
|
|
|
end
|
2018-04-18 06:44:12 -04:00
|
|
|
end
|
|
|
|
|
2021-06-07 11:09:56 -04:00
|
|
|
context 'when user is an admin' do
|
|
|
|
let_it_be(:user) { create(:user, :admin) }
|
2018-04-18 06:44:12 -04:00
|
|
|
|
2020-11-23 10:09:37 -05:00
|
|
|
context 'when admin mode is enabled' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
gitlab_enable_admin_mode_sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'allowing push to default branch'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when admin mode is disabled' do
|
|
|
|
it 'does not show push-to-master instructions' do
|
|
|
|
visit project_path(project)
|
|
|
|
|
2021-07-12 08:09:39 -04:00
|
|
|
expect(page).not_to have_content('git push -u origin')
|
2020-11-23 10:09:37 -05:00
|
|
|
end
|
|
|
|
end
|
2018-04-18 06:44:12 -04:00
|
|
|
end
|
|
|
|
|
2021-06-07 11:09:56 -04:00
|
|
|
context 'when user is a developer' do
|
2018-04-18 06:44:12 -04:00
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2021-06-07 11:09:56 -04:00
|
|
|
it 'does not show push-to-master instructions nor invite members link', :aggregate_failures, :js do
|
2020-11-23 10:09:37 -05:00
|
|
|
visit project_path(project)
|
|
|
|
|
2021-07-12 08:09:39 -04:00
|
|
|
expect(page).not_to have_content('git push -u origin')
|
2021-06-07 11:09:56 -04:00
|
|
|
expect(page).not_to have_button(text: 'Invite members')
|
2018-04-18 06:44:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|