Skip to content

Message#from_yaml results in invalid parts when body is not present #1038

Closed
@angelcarballo

Description

@angelcarballo

Found this behaviour while testing serialization and deserialization of messages via YAML.

The following spec fails (at least on master and 2.6.4)

context 'when body is not present' do
  it 'should encode after deserializing' do
    message = Mail::Message.new(
      to: '[email protected]',
      cc: '[email protected]',
      bcc: '[email protected]',
      subject: 'subject'
    )
    serialized = message.to_yaml
    deserialized = Mail::Message.from_yaml(serialized)
    expect{ deserialized.encoded }.not_to raise_error
  end
end

The #from_yaml method sets @body directly, which after YAML serialization will contain an Array on parts instead of a PartList instance.

Is this a bug, or it's the expected behaviour (making the body mandatory) ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions