2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe 'projects/commits/_commit.html.haml' do
|
2022-08-13 15:12:31 +05:30
|
|
|
let(:template) { 'projects/commits/commit' }
|
2019-07-07 11:18:12 +05:30
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:commit) { project.repository.commit(ref) }
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
before do
|
|
|
|
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
context 'with different committer' do
|
|
|
|
let(:ref) { 'master' }
|
|
|
|
let(:committer) { create(:user) }
|
|
|
|
|
|
|
|
it 'renders committed by user' do
|
|
|
|
allow(commit).to receive(:different_committer?).and_return(true)
|
|
|
|
allow(commit).to receive(:committer).and_return(committer)
|
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
render partial: template, formats: :html, locals: {
|
2021-11-18 22:05:49 +05:30
|
|
|
project: project,
|
|
|
|
ref: ref,
|
|
|
|
commit: commit
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(rendered).to have_text("#{committer.name} committed")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
context 'with a signed commit' do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:ref) { GpgHelpers::SIGNED_COMMIT_SHA }
|
|
|
|
|
|
|
|
it 'does not display a loading spinner for GPG status' do
|
2022-05-07 20:08:51 +05:30
|
|
|
render partial: template, formats: :html, locals: {
|
2017-09-10 17:25:29 +05:30
|
|
|
project: project,
|
|
|
|
ref: ref,
|
|
|
|
commit: commit
|
|
|
|
}
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
within '.signature-badge' do
|
2021-02-22 17:27:13 +05:30
|
|
|
expect(page).not_to have_css('.gl-spinner')
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
context 'with ci status' do
|
|
|
|
let(:ref) { 'master' }
|
2022-09-01 20:07:04 +05:30
|
|
|
|
|
|
|
let_it_be(:user) { create(:user) }
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
allow(view).to receive(:current_user).and_return(user)
|
|
|
|
|
|
|
|
create(
|
|
|
|
:ci_empty_pipeline,
|
|
|
|
ref: 'master',
|
|
|
|
sha: commit.id,
|
|
|
|
status: 'success',
|
|
|
|
project: project
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipelines are disabled' do
|
|
|
|
before do
|
|
|
|
allow(project).to receive(:builds_enabled?).and_return(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not display a ci status icon' do
|
2022-05-07 20:08:51 +05:30
|
|
|
render partial: template, formats: :html, locals: {
|
2019-07-07 11:18:12 +05:30
|
|
|
project: project,
|
|
|
|
ref: ref,
|
|
|
|
commit: commit
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(rendered).not_to have_css('.ci-status-link')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipelines are enabled' do
|
2022-09-01 20:07:04 +05:30
|
|
|
context 'when user has access' do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays a ci status icon' do
|
|
|
|
render partial: template, formats: :html, locals: {
|
|
|
|
project: project,
|
|
|
|
ref: ref,
|
|
|
|
commit: commit
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(rendered).to have_css('.ci-status-link')
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2022-09-01 20:07:04 +05:30
|
|
|
context 'when user does not have access' do
|
|
|
|
it 'does not display a ci status icon' do
|
|
|
|
render partial: template, formats: :html, locals: {
|
|
|
|
project: project,
|
|
|
|
ref: ref,
|
|
|
|
commit: commit
|
|
|
|
}
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2022-09-01 20:07:04 +05:30
|
|
|
expect(rendered).not_to have_css('.ci-status-link')
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|