Testing OutgoingMessagePrototype Creation and Validation in Postal
This test suite validates the OutgoingMessagePrototype model functionality in the Postal server application, focusing on message creation and validation. The tests ensure proper handling of outgoing email messages with their associated attributes and server relationships.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
postalserver/postal
spec/models/outgoing_message_prototype_spec.rb
# frozen_string_literal: true
require "rails_helper"
describe OutgoingMessagePrototype do
let(:server) { create(:server) }
it "should create a new message" do
domain = create(:domain, owner: server)
prototype = OutgoingMessagePrototype.new(server, "127.0.0.1", "TestSuite", {
from: "test@#{domain.name}",
to: "[email protected]",
subject: "Test Message",
plain_body: "A plain body!"
})
expect(prototype.valid?).to be true
message = prototype.create_message("[email protected]")
expect(message).to be_a Hash
expect(message[:id]).to be_a Integer
expect(message[:token]).to be_a String
end
end