debian-mirror-gitlab/spec/lib/gitlab/hook_data/release_builder_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.5 KiB
Ruby
Raw Normal View History

2021-01-29 00:20:46 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::HookData::ReleaseBuilder do
let_it_be(:project) { create(:project, :public, :repository) }
2021-04-29 21:17:54 +05:30
2021-01-29 00:20:46 +05:30
let(:release) { create(:release, project: project) }
let(:builder) { described_class.new(release) }
describe '#build' do
let(:data) { builder.build('create') }
it 'includes safe attribute' do
%w[
2022-11-25 23:54:43 +05:30
id
created_at
description
name
released_at
tag
2021-01-29 00:20:46 +05:30
].each do |key|
expect(data).to include(key)
end
end
it 'includes additional attrs' do
expect(data[:object_kind]).to eq('release')
expect(data[:project]).to eq(builder.release.project.hook_attrs.with_indifferent_access)
expect(data[:action]).to eq('create')
expect(data).to include(:assets)
expect(data).to include(:commit)
end
context 'when the Release has an image in the description' do
let(:release_with_description) do
create(:release, project: project, description: 'test![Release_Image](/uploads/abc/Release_Image.png)')
end
let(:builder) { described_class.new(release_with_description) }
it 'sets the image to use an absolute URL' do
expected_path = "#{release_with_description.project.path_with_namespace}/uploads/abc/Release_Image.png"
expect(data[:description])
.to eq("test![Release_Image](#{Settings.gitlab.url}/#{expected_path})")
end
end
end
end