2019-10-17 14:08:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
require 'email_spec'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Emails::Releases do
|
2019-10-17 14:08:05 -04:00
|
|
|
include EmailSpec::Matchers
|
|
|
|
include_context 'gitlab email notification'
|
|
|
|
|
|
|
|
describe '#new_release_email' do
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project) }
|
2021-04-08 23:09:05 -04:00
|
|
|
|
2019-10-17 14:08:05 -04:00
|
|
|
let(:release) { create(:release, project: project) }
|
|
|
|
|
|
|
|
subject { Notify.new_release_email(user.id, release) }
|
|
|
|
|
|
|
|
it_behaves_like 'an email sent from GitLab'
|
|
|
|
|
|
|
|
context 'when the release has a name' do
|
|
|
|
it 'shows the correct subject' do
|
2019-11-12 16:06:30 -05:00
|
|
|
release.name = 'beta-1'
|
2019-10-17 14:08:05 -04:00
|
|
|
expected_subject = "#{release.project.name} | New release: #{release.name} - #{release.tag}"
|
|
|
|
is_expected.to have_subject(expected_subject)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the release does not have a name' do
|
|
|
|
it 'shows the correct subject' do
|
|
|
|
release.name = nil
|
|
|
|
expected_subject = "#{release.project.name} | New release: #{release.tag}"
|
|
|
|
|
|
|
|
is_expected.to have_subject(expected_subject)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains a message with the new release tag' do
|
|
|
|
message = "A new Release #{release.tag} for #{release.project.name} was published."
|
|
|
|
is_expected.to have_body_text(message)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the release assets' do
|
|
|
|
is_expected.to have_body_text('Assets:')
|
|
|
|
release.sources do |source|
|
|
|
|
is_expected.to have_body_text("Download #{source.format}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the release notes' do
|
|
|
|
is_expected.to have_body_text('Release notes:')
|
|
|
|
is_expected.to have_body_text(release.description)
|
|
|
|
end
|
2020-12-16 13:10:10 -05:00
|
|
|
|
|
|
|
context 'release notes with attachment' do
|
|
|
|
let(:upload_path) { '/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg' }
|
|
|
|
let(:release) { create(:release, project: project, description: "Attachment: [Test file](#{upload_path})") }
|
|
|
|
|
|
|
|
it 'renders absolute links' do
|
2021-06-22 20:07:53 -04:00
|
|
|
is_expected.to have_body_text(%Q(<a href="#{project.web_url}#{upload_path}" data-canonical-src="#{upload_path}" data-link="true" class="gfm">Test file</a>))
|
2020-12-16 13:10:10 -05:00
|
|
|
end
|
|
|
|
end
|
2019-10-17 14:08:05 -04:00
|
|
|
end
|
|
|
|
end
|