Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/build.sbt b/build.sbt
- index 8fa493a9..cde2dde3 100644
- --- a/build.sbt
- +++ b/build.sbt
- @@ -44,7 +44,9 @@ libraryDependencies ++= Seq(
- "joda-time" % "joda-time" % "2.4",
- "org.joda" % "joda-convert" % "1.6",
- "com.github.tototoshi" %% "slick-joda-mapper" % "1.2.0",
- - "org.scalaz" %% "scalaz-core" % "7.2.10"
- + "org.scalaz" %% "scalaz-core" % "7.0.6",
- + "org.scalaz" % "scalaz-concurrent_2.11" % "7.0.6",
- + "org.specs2" % "specs2-junit_2.11" % "3.6.6"
- )
- javaOptions in Test += "-Dconfig.file=conf/test.conf"
- \ No newline at end of file
- diff --git a/conf/test.conf b/conf/test.conf
- index 18a6b670..b3ce5046 100644
- --- a/conf/test.conf
- +++ b/conf/test.conf
- @@ -3,4 +3,6 @@ include "staging.conf"
- db.default.driver = com.mysql.jdbc.Driver
- db.default.url="jdbc:mysql://localhost:3307/marketmuse"
- db.default.user = marketmuse
- -db.default.password = ycombinator14
- \ No newline at end of file
- +db.default.password = ycombinator14
- +
- +smtp.mock = true
- \ No newline at end of file
- diff --git a/test/ApplicationSpec.scala b/test/ApplicationSpec.scala
- index ba256055..1aec913a 100644
- --- a/test/ApplicationSpec.scala
- +++ b/test/ApplicationSpec.scala
- @@ -5,14 +5,16 @@ import play.api.libs.json.Json
- import play.api.test._
- import play.api.test.Helpers._
- import play.api.Logger._
- +import play.api.mvc.Result
- +import scala.concurrent.Future
- import scala.sys.process._
- /**
- - * Add your spec here.
- - * You can mock out a whole application including requests, plugins etc.
- - * For more information, consult the wiki.
- - */
- + * Add your spec here.
- + * You can mock out a whole application including requests, plugins etc.
- + * For more information, consult the wiki.
- + */
- @RunWith(classOf[JUnitRunner])
- class ApplicationSpec extends Specification with BeforeAfter {
- @@ -67,7 +69,7 @@ class ApplicationSpec extends Specification with BeforeAfter {
- )).get
- status(apiSave) mustEqual OK
- - //controllers.Sites.apiSave(publicToken, id : Int)
- + //controllers.Sites.apiSave(publicToken, id : Int)
- val crawl = route(FakeRequest(GET, s"/auth/web/crawl?url=blog.hubspot.com&publicToken=$publicToken")).get
- @@ -75,12 +77,46 @@ class ApplicationSpec extends Specification with BeforeAfter {
- }
- -// "render the index page" in new WithApplication{
- -// val home = route(FakeRequest(GET, "/")).get
- -//
- -// status(home) must equalTo(OK)
- -// contentType(home) must beSome.which(_ == "text/html")
- -// contentAsString(home) must contain ("Your new application is ready.")
- -// }
- + "limit API calls per one user" in new WithApplication {
- + val register = route(FakeRequest(POST, "/auth/users/register").withJsonBody(
- + Json.obj(
- + "email" -> "test@test.com",
- + "name" -> "test_user",
- + "fullName" -> "Test User",
- + "company" -> "Test Company",
- + "password" -> "Test Password",
- + "agree" -> true
- + ))).get
- +
- + status(register) mustEqual OK
- +
- + val login = route(FakeRequest(POST, "/auth/users/login").withJsonBody(
- + Json.obj(
- + "email" -> "test@test.com",
- + "password" -> "Test Password",
- + "remember" -> true
- + ))).get
- +
- + status(login) mustEqual OK
- +
- + val publicToken = (contentAsJson(login) \ "publicToken").as[String]
- +
- + def apiRequest(): Future[Result] =
- + route(FakeRequest(POST, s"/auth/users/publicToken/$publicToken?url=test")).get
- +
- + for(_ <- 1 to 1000) {
- + status(apiRequest()) mustEqual OK
- + }
- +
- + status(apiRequest()) mustEqual TOO_MANY_REQUEST
- + }
- +
- + // "render the index page" in new WithApplication{
- + // val home = route(FakeRequest(GET, "/")).get
- + //
- + // status(home) must equalTo(OK)
- + // contentType(home) must beSome.which(_ == "text/html")
- + // contentAsString(home) must contain ("Your new application is ready.")
- + // }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement