2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe 'events/event/_push.html.haml' do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:event) { build_stubbed(:push_event) }
|
|
|
|
|
|
|
|
context 'with a branch' do
|
|
|
|
let(:payload) { build_stubbed(:push_event_payload, event: event) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(event).to receive(:push_event_payload).and_return(payload)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'links to the branch' do
|
|
|
|
allow(event.project.repository).to receive(:branch_exists?).with(event.ref_name).and_return(true)
|
|
|
|
link = project_commits_path(event.project, event.ref_name)
|
|
|
|
|
|
|
|
render partial: 'events/event/push', locals: { event: event }
|
|
|
|
|
|
|
|
expect(rendered).to have_link(event.ref_name, href: link)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'that has been deleted' do
|
|
|
|
it 'does not link to the branch' do
|
|
|
|
render partial: 'events/event/push', locals: { event: event }
|
|
|
|
|
|
|
|
expect(rendered).not_to have_link(event.ref_name)
|
|
|
|
end
|
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
context 'ref_count is more than 1' do
|
|
|
|
let(:payload) do
|
|
|
|
build_stubbed(
|
|
|
|
:push_event_payload,
|
|
|
|
event: event,
|
|
|
|
ref_count: 4,
|
|
|
|
ref_type: :branch
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes the count in the text' do
|
|
|
|
render partial: 'events/event/push', locals: { event: event }
|
|
|
|
|
|
|
|
expect(rendered).to include('4 branches')
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a tag' do
|
|
|
|
let(:payload) { build_stubbed(:push_event_payload, event: event, ref_type: :tag, ref: 'v0.1.0') }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(event).to receive(:push_event_payload).and_return(payload)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'links to the tag' do
|
|
|
|
allow(event.project.repository).to receive(:tag_exists?).with(event.ref_name).and_return(true)
|
|
|
|
link = project_commits_path(event.project, event.ref_name)
|
|
|
|
|
|
|
|
render partial: 'events/event/push', locals: { event: event }
|
|
|
|
|
|
|
|
expect(rendered).to have_link(event.ref_name, href: link)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'that has been deleted' do
|
|
|
|
it 'does not link to the tag' do
|
|
|
|
render partial: 'events/event/push', locals: { event: event }
|
|
|
|
|
|
|
|
expect(rendered).not_to have_link(event.ref_name)
|
|
|
|
end
|
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
context 'ref_count is more than 1' do
|
|
|
|
let(:payload) do
|
|
|
|
build_stubbed(
|
|
|
|
:push_event_payload,
|
|
|
|
event: event,
|
|
|
|
ref_count: 4,
|
|
|
|
ref_type: :tag
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes the count in the text' do
|
|
|
|
render partial: 'events/event/push', locals: { event: event }
|
|
|
|
|
|
|
|
expect(rendered).to include('4 tags')
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|