debian-mirror-gitlab/spec/mailers/emails/issues_spec.rb

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

60 lines
1.8 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
require 'spec_helper'
require 'email_spec'
2023-05-27 22:25:52 +05:30
RSpec.describe Emails::Issues, feature_category: :team_planning do
2019-02-15 15:39:39 +05:30
include EmailSpec::Matchers
2020-04-22 19:07:51 +05:30
it 'adds email methods to Notify' do
subject.instance_methods.each do |email_method|
expect(Notify).to be_respond_to(email_method)
end
end
2019-02-15 15:39:39 +05:30
describe "#import_issues_csv_email" do
let(:user) { create(:user) }
let(:project) { create(:project) }
subject { Notify.import_issues_csv_email(user.id, project.id, @results) }
it "shows number of successful issues imported" do
@results = { success: 165, error_lines: [], parse_error: false }
expect(subject).to have_body_text "165 issues imported"
end
it "shows error when file is invalid" do
@results = { success: 0, error_lines: [], parse_error: true }
expect(subject).to have_body_text "Error parsing CSV"
end
it "shows line numbers with errors" do
@results = { success: 0, error_lines: [23, 34, 58], parse_error: false }
expect(subject).to have_body_text "23, 34, 58"
end
2019-07-07 11:18:12 +05:30
context 'with header and footer' do
let(:results) { { success: 165, error_lines: [], parse_error: false } }
subject { Notify.import_issues_csv_email(user.id, project.id, results) }
it_behaves_like 'appearance header and footer enabled'
it_behaves_like 'appearance header and footer not enabled'
end
2019-02-15 15:39:39 +05:30
end
2020-04-22 19:07:51 +05:30
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) }
2023-05-27 22:25:52 +05:30
it_behaves_like 'export csv email', 'issues'
2020-04-22 19:07:51 +05:30
end
2019-02-15 15:39:39 +05:30
end