Skip to content

Commit 4faf790

Browse files
committed
Merge branch 'development'
2 parents fe148ff + a3aeb9a commit 4faf790

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.tmp/**
55

66
.env
7-
test-harness/.engine/**
7+
.engine
88
test-harness/coldbox/**
99
test-harness/docbox/**
1010
test-harness/testbox/**

box.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"ColdBox Mail Services",
3-
"version":"2.6.1",
3+
"version":"2.6.2",
44
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbmailservices/@build.version@/[email protected]@.zip",
55
"author":"Ortus Solutions.com <[email protected]",
66
"slug":"cbmailservices",

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
----
99

10+
11+
## [v2.6.2] => 2022-DEC-20
12+
13+
### Fixed
14+
15+
* If the incoming `layout` arugment for the `setView()` method in the mail is empty, it should ignore it.
16+
17+
----
18+
1019
## [v2.6.1] => 2022-NOV-21
1120

1221
### Changed

models/Mail.cfc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,20 @@ component accessors="true" {
195195
);
196196
}
197197

198+
/**
199+
* Run email validation and throw an InvalidMailException if required params are missing.
200+
*/
201+
Mail function validateOrFail(){
202+
if ( NOT this.validate() ){
203+
throw(
204+
type : "InvalidMailException",
205+
message: "One or more required fields are missing.",
206+
detail : "Please check the basic mail fields of To, From, Subject and Body as they are empty. To: #variables.config.to#, From: #variables.config.from#, Subject Len = #variables.config.subject.length()#, Body Len = #variables.config.body.length()#."
207+
);
208+
}
209+
return this;
210+
}
211+
198212
/**
199213
* Validate that the basic fields of from, to, subject, and body are set for sending mail
200214
*/
@@ -442,7 +456,7 @@ component accessors="true" {
442456
variables.config.type = "html";
443457

444458
// Do we have a layout?
445-
if ( !isNull( arguments.layout ) ) {
459+
if ( !isNull( arguments.layout ) && len( arguments.layout ) ) {
446460
variables.config.body = variables.wirebox
447461
.getInstance( "Renderer@coldbox" )
448462
.layout(

test-harness/tests/specs/MailTest.cfc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,29 @@
6161
expect( mail.validate() ).toBeTrue();
6262
} );
6363

64+
it( "validateOrFail will throw for invalid mail", function() {
65+
66+
expect(function() {
67+
mail.configure(
68+
69+
70+
// OMIT subject... "Oops! DID I DO THAT???"
71+
)
72+
.validateOrFail()
73+
}).toThrow( "InvalidMailException" );
74+
});
75+
76+
it( "validateOrFail won't throw for valid emails", function() {
77+
expect( function() {
78+
mail.configure(
79+
subject = "Hello",
80+
81+
82+
body = "Hello"
83+
).validateOrFail();
84+
}).notToThrow( "InvalidMailException" );
85+
});
86+
6487
it( "can set html types", function(){
6588
mail.configure(
6689
subject = "Hello",

0 commit comments

Comments
 (0)