2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'User views an empty project', feature_category: :projects do
|
2023-04-23 21:23:45 +05:30
|
|
|
include Spec::Support::Helpers::Features::InviteMembersModalHelper
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
let_it_be(:project) { create(:project, :empty_repo) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
shared_examples 'allowing push to default branch' do
|
2021-09-30 23:02:18 +05:30
|
|
|
let(:default_branch) { project.default_branch_or_main }
|
|
|
|
|
|
|
|
it 'shows push-to-default-branch instructions' do
|
2018-05-09 12:01:36 +05:30
|
|
|
visit project_path(project)
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
expect(page).to have_content("git push -u origin #{default_branch}")
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
context 'when user is a maintainer' do
|
2018-05-09 12:01:36 +05:30
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2021-02-22 17:27:13 +05:30
|
|
|
sign_in(user)
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'allowing push to default branch'
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
it 'shows a link for inviting members and launches invite modal', :js do
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
click_button 'Invite members'
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
page.within invite_modal_selector do
|
|
|
|
expect(page).to have_content("You're inviting members to the #{project.name} project")
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
context 'when user is an admin' do
|
|
|
|
let_it_be(:user) { create(:user, :admin) }
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
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-09-30 23:02:18 +05:30
|
|
|
expect(page).not_to have_content('git push -u origin')
|
2021-02-22 17:27:13 +05:30
|
|
|
end
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
context 'when user is a developer' do
|
2018-05-09 12:01:36 +05:30
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it 'does not show push-to-master instructions nor invite members link', :aggregate_failures, :js do
|
2021-02-22 17:27:13 +05:30
|
|
|
visit project_path(project)
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
expect(page).not_to have_content('git push -u origin')
|
2021-09-04 01:27:46 +05:30
|
|
|
expect(page).not_to have_button(text: 'Invite members')
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|