2021-02-22 17:27:13 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'projects/empty' do
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { ProjectPresenter.new(create(:project, :empty_repo), current_user: user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(view).to receive(:experiment_enabled?).and_return(true)
|
|
|
|
allow(view).to receive(:current_user).and_return(user)
|
|
|
|
assign(:project, project)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user can push code on the project' do
|
|
|
|
before do
|
|
|
|
allow(view).to receive(:can?).with(user, :push_code, project).and_return(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays "git clone" instructions' do
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_content("git clone")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user can not push code on the project' do
|
|
|
|
before do
|
|
|
|
allow(view).to receive(:can?).with(user, :push_code, project).and_return(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not display "git clone" instructions' do
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).not_to have_content("git clone")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
context 'project is archived' do
|
|
|
|
let(:project) { ProjectPresenter.new(create(:project, :empty_repo, :archived), current_user: user) }
|
|
|
|
|
|
|
|
it 'shows archived notice' do
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_content('Archived project!')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
context 'with invite button on empty projects' do
|
2021-02-22 17:27:13 +05:30
|
|
|
let(:can_import_members) { true }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(view).to receive(:can_import_members?).and_return(can_import_members)
|
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it 'shows invite members info', :aggregate_failures do
|
|
|
|
render
|
2021-02-22 17:27:13 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
expect(rendered).to have_selector('[data-track-event=render]')
|
|
|
|
expect(rendered).to have_selector('[data-track-label=invite_members_empty_project]')
|
|
|
|
expect(rendered).to have_content('Invite your team')
|
|
|
|
expect(rendered).to have_content('Add members to this project and start collaborating with your team.')
|
|
|
|
expect(rendered).to have_selector('.js-invite-members-trigger')
|
|
|
|
expect(rendered).to have_selector('.js-invite-members-modal')
|
|
|
|
expect(rendered).to have_selector('[data-label=invite_members_empty_project]')
|
|
|
|
expect(rendered).to have_selector('[data-event=click_button]')
|
2021-09-30 23:02:18 +05:30
|
|
|
expect(rendered).to have_selector('[data-trigger-source=project-empty-page]')
|
2021-02-22 17:27:13 +05:30
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
context 'when user does not have permissions to invite members' do
|
|
|
|
let(:can_import_members) { false }
|
2021-02-22 17:27:13 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it 'does not show invite member info', :aggregate_failures do
|
|
|
|
render
|
2021-02-22 17:27:13 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
expect(rendered).not_to have_content('Invite your team')
|
|
|
|
expect(rendered).not_to have_selector('.js-invite-members-trigger')
|
|
|
|
expect(rendered).not_to have_selector('.js-invite-members-modal')
|
2021-02-22 17:27:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|