Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grails 3.3.9 upgrade #12

Merged
merged 6 commits into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
attempting to add tests for domain objects
  • Loading branch information
mcroteau committed Dec 16, 2018
commit df600699b38e55bc0a4946fb2abe945702e9b352
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}
}

version "1.0.1"
version "0.1"
group "greenfield"

apply plugin:"eclipse"
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,16 @@ import greenfield.AccountController

class AccountControllerSpec extends Specification implements ControllerUnitTest<AccountController> {


void setup() {
println "here... setting up..."
def controller = (AccountController)mockController(AccountController)
}

void "test GET request"() {
when:
def controller = (AccountController)mockController(AccountController)
controller.index()

then:
response.text == 'Success'
}

void "test POST request"() {
when:
def controller = (AccountController)mockController(AccountController)
request.method = 'POST'
controller.customer_profile()
true == true

then:
response.status == METHOD_NOT_ALLOWED.value()
true == true
}
}
23 changes: 23 additions & 0 deletions src/test/groovy/greenfield/domain/AccountSpec.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package greenfield.domain

import spock.lang.Specification
import grails.testing.gorm.DomainUnitTest
import grails.testing.gorm.DataTest

import org.greenfield.Account

class AccountSpec extends Specification implements DataTest {

void setupSpec(){
mockDomain Account
}

void "test basic persistence mocking"() {
setup:
def account = new Account(name: 'Robert Fripp', username: "robert", password: "robert", email: "[email protected]").save(flush:true)

expect:
Account.count() == 1
}

}