-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #391 from dmitry-sinina/1.7.10
1.7.10
- Loading branch information
Showing
4 changed files
with
119 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe YetiMail do | ||
describe '.email_message' do | ||
subject do | ||
YetiMail.email_message(log_id) | ||
end | ||
|
||
before do | ||
System::SmtpConnection.create!( | ||
name: 'test', | ||
host: 'smtp.example.com', | ||
port: 25, | ||
from_address: 'sender@example.com', | ||
global: true | ||
) | ||
end | ||
let(:log_id) { log.id } | ||
let!(:log) do | ||
Log::EmailLog.create!( | ||
contact_id: contact.id, | ||
smtp_connection_id: contact.smtp_connection.id, | ||
mail_to: contact.email, | ||
mail_from: 'rspec@example.com', | ||
subject: 'test', | ||
attachment_id: [attachment.id], | ||
msg: '<h1>Hello</h1>' | ||
) | ||
end | ||
let(:attachment) do | ||
Notification::Attachment.create!(filename: 'test.txt', data: 'some data') | ||
end | ||
let(:contact) do | ||
Billing::Contact.create!(email: 'test@example.com') | ||
end | ||
|
||
|
||
it 'renders the headers and body' do | ||
expect(subject.subject).to eq('test') | ||
expect(subject.to).to eq([log.mail_to]) | ||
expect(subject.from).to eq([log.mail_from]) | ||
expect(subject.body.encoded).to include(log.msg) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Api::Rest::System::JobsController do | ||
describe 'PUT /api/rest/system/jobs/:type/run' do | ||
subject do | ||
put "/api/rest/system/jobs/#{job_type}/run" | ||
end | ||
|
||
context 'when type is EventProcessor' do | ||
let(:job_type) { 'EventProcessor' } | ||
|
||
include_examples :responds_with_status, 204 | ||
|
||
context 'with events' do | ||
before do | ||
Event.reload_translations | ||
|
||
allow_any_instance_of(YetisNode::JsonRpcTransport).to receive(:rpc_send). | ||
with('request.router.translations.reload', []).and_return(nil) | ||
end | ||
|
||
it 'expects to delete success events' do | ||
expect { subject }.to change { Event.count }.from(Node.count).to(0) | ||
end | ||
|
||
include_examples :responds_with_status, 204 | ||
|
||
context 'when one event failed' do | ||
before do | ||
expect_any_instance_of(Jobs::EventProcessor).to receive(:process_event). | ||
exactly(Node.count).times.and_raise(StandardError.new('some error')) | ||
end | ||
|
||
it 'expects to not delete events' do | ||
expect { subject }.to_not change { Event.count } | ||
end | ||
|
||
include_examples :responds_with_status, 204 | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
end |