summaryrefslogtreecommitdiff
path: root/spec/mailers/emails/groups_spec.rb
blob: 0184617244000e1b578fc094de692486b596912d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true

require 'spec_helper'
require 'email_spec'

RSpec.describe Emails::Groups do
  include EmailSpec::Matchers

  let(:group) { create(:group) }
  let(:user) { create(:user) }

  before do
    group.add_owner(user)
  end

  describe '#group_was_exported_email' do
    subject { Notify.group_was_exported_email(user, group) }

    it 'sends success email' do
      expect(subject).to have_subject "#{group.name} | Group was exported"
      expect(subject).to have_body_text 'The download link will expire in 24 hours.'
      expect(subject).to have_body_text "groups/#{group.path}/-/download_export"
    end
  end

  describe '#group_was_not_exported_email' do
    let(:shared) { Gitlab::ImportExport::Shared.new(group) }
    let(:error) { Gitlab::ImportExport::Error.new('Error!') }

    before do
      shared.error(error)
    end

    subject { Notify.group_was_not_exported_email(user, group, shared.errors) }

    it 'sends failure email' do
      expect(subject).to have_subject "#{group.name} | Group export error"
      expect(subject).to have_body_text "Group #{group.name} couldn't be exported."
    end
  end
end