diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /spec/mailers | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) | |
download | gitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/mailers')
-rw-r--r-- | spec/mailers/emails/issues_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/mailers/emails/issues_spec.rb b/spec/mailers/emails/issues_spec.rb index 5b5bd6f4308..dfd974aa5f3 100644 --- a/spec/mailers/emails/issues_spec.rb +++ b/spec/mailers/emails/issues_spec.rb @@ -6,6 +6,12 @@ require 'email_spec' describe Emails::Issues do include EmailSpec::Matchers + it 'adds email methods to Notify' do + subject.instance_methods.each do |email_method| + expect(Notify).to be_respond_to(email_method) + end + end + describe "#import_issues_csv_email" do let(:user) { create(:user) } let(:project) { create(:project) } @@ -39,4 +45,47 @@ describe Emails::Issues do it_behaves_like 'appearance header and footer not enabled' end end + + describe '#issues_csv_email' do + let(:user) { create(:user) } + let(:empty_project) { create(:project, path: 'myproject') } + let(:export_status) { { truncated: false, rows_expected: 3, rows_written: 3 } } + let(:attachment) { subject.attachments.first } + + subject { Notify.issues_csv_email(user, empty_project, "dummy content", export_status) } + + include_context 'gitlab email notification' + + it 'attachment has csv mime type' do + expect(attachment.mime_type).to eq 'text/csv' + end + + it 'generates a useful filename' do + expect(attachment.filename).to include(Date.today.year.to_s) + expect(attachment.filename).to include('issues') + expect(attachment.filename).to include('myproject') + expect(attachment.filename).to end_with('.csv') + end + + it 'mentions number of issues and project name' do + expect(subject).to have_content '3' + expect(subject).to have_content empty_project.name + end + + it "doesn't need to mention truncation by default" do + expect(subject).not_to have_content 'truncated' + end + + context 'when truncated' do + let(:export_status) { { truncated: true, rows_expected: 12, rows_written: 10 } } + + it 'mentions that the csv has been truncated' do + expect(subject).to have_content 'truncated' + end + + it 'mentions the number of issues written and expected' do + expect(subject).to have_content '10 of 12 issues' + end + end + end end |