Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Performance improvement #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
}

version "2.0.2"
version "2.0.2-3.2.x"
group "org.grails.plugins"

apply plugin: 'idea'
Expand Down Expand Up @@ -43,8 +43,7 @@ dependencies {
provided "org.grails:grails-plugin-services"
provided "org.grails:grails-plugin-domain-class"

testCompile "org.grails:grails-gorm-testing-support"
testCompile "net.bytebuddy:byte-buddy:1.7.9"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:hibernate5"
testCompile "com.h2database:h2:1.4.196"

Expand All @@ -60,6 +59,8 @@ task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}

// enable if you wish to package this plugin as a standalone application
bootRepackage.enabled = false
grailsPublish {
userOrg = 'kefirsf'
license {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
grailsVersion=3.3.2
gormVersion=6.1.8.RELEASE
grailsVersion=3.2.11
gormVersion=6.0.12.RELEASE
gradleWrapperVersion=3.5.1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class AsynchronousMailService {
savedMessage = asynchronousMailPersistenceService.save(message, true, true)
}
} else {
savedMessage = asynchronousMailPersistenceService.save(message, true, true)
savedMessage = asynchronousMailPersistenceService.save(message
, asynchronousMailConfigService.useFlushOnSave
, true)
}

if (!savedMessage) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package grails.plugin.asyncmail

import grails.test.mixin.integration.Integration
import grails.testing.mixin.integration.Integration
import grails.transaction.Rollback
import spock.lang.Specification

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package grails.plugin.asyncmail

import grails.testing.mixin.integration.Integration
import grails.test.mixin.integration.Integration
import spock.lang.Specification

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package grails.plugin.asyncmail

import grails.testing.mixin.integration.Integration
import grails.test.mixin.integration.Integration
import grails.transaction.Rollback
import org.springframework.beans.factory.annotation.Autowired
import spock.lang.Specification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package grails.plugin.asyncmail
import grails.config.Config
import grails.core.support.GrailsConfigurationAware
import grails.plugin.asyncmail.enums.MessageStatus
import grails.testing.mixin.integration.Integration
import grails.test.mixin.integration.Integration
import grails.transaction.Rollback
import org.springframework.transaction.TransactionDefinition
import spock.lang.Specification
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package grails.plugin.asyncmail

import grails.testing.mixin.integration.Integration
import grails.test.mixin.integration.Integration
import grails.transaction.Rollback
import org.springframework.beans.factory.annotation.Autowired
import spock.lang.Specification
Expand Down
Original file line number Diff line number Diff line change
@@ -1,63 +1,61 @@
package grails.plugin.asyncmail

import grails.testing.gorm.DomainUnitTest
import grails.test.mixin.TestFor
import spock.lang.Specification

import static grails.plugin.asyncmail.AsynchronousMailAttachment.DEFAULT_MIME_TYPE

/**
* @author Vitalii Samolovskikh aka Kefir, Puneet Behl
*/
class AsynchronousMailAttachmentSpec extends Specification implements DomainUnitTest<AsynchronousMailAttachment> {


@TestFor(AsynchronousMailAttachment)
class AsynchronousMailAttachmentSpec extends Specification {
void "testing default constructor"() {
when:
AsynchronousMailAttachment attachment = new AsynchronousMailAttachment()
AsynchronousMailAttachment attachment = new AsynchronousMailAttachment()

then:
!attachment.attachmentName
attachment.mimeType == DEFAULT_MIME_TYPE
!attachment.content
!attachment.inline
!attachment.attachmentName
attachment.mimeType == DEFAULT_MIME_TYPE
!attachment.content
!attachment.inline
}

void "testing constraints"() {
setup:
AsynchronousMailAttachment attachment
AsynchronousMailAttachment attachment

when: 'constraints on default attachment'
attachment = new AsynchronousMailAttachment()
attachment = new AsynchronousMailAttachment()

then: 'should fail validation'
!attachment.validate()
attachment.errors.getFieldError('attachmentName').code == 'nullable'
attachment.errors.getFieldError('content').code == 'nullable'
attachment.errors.getFieldError('message').code == 'nullable'
!attachment.validate()
attachment.errors.getFieldError('attachmentName').code == 'nullable'
attachment.errors.getFieldError('content').code == 'nullable'
attachment.errors.getFieldError('message').code == 'nullable'

when: 'attachmentName is empty'
attachment = new AsynchronousMailAttachment(attachmentName: '')
attachment = new AsynchronousMailAttachment(attachmentName: '')

then: 'should fail validation with nullable error on attachmentName'
!attachment.validate()
attachment.errors.getFieldError('attachmentName').code == 'nullable'
!attachment.validate()
attachment.errors.getFieldError('attachmentName').code == 'nullable'

when: 'mimeType is null'
attachment = new AsynchronousMailAttachment(mimeType: null)
attachment = new AsynchronousMailAttachment(mimeType: null)

then: 'should fail validation on mimeType'
!attachment.validate()
attachment.errors.getFieldError('mimeType').code == 'nullable'
!attachment.validate()
attachment.errors.getFieldError('mimeType').code == 'nullable'

when: 'a valid attachment'
attachment = new AsynchronousMailAttachment(
attachmentName:'name',
content:'Grails'.getBytes(),
message: new AsynchronousMailMessage()
)
attachment = new AsynchronousMailAttachment(
attachmentName: 'name',
content: 'Grails'.getBytes(),
message: new AsynchronousMailMessage()
)

then: 'should pass all validations'
attachment.validate()

attachment.validate()
}
}
Loading