Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Provide fixture feature as scalaikejdbc-play-fixture-plugin

for compatibility for scalikejdbc-play-plugin.
  • Loading branch information...
commit 248b31dbe87cacbc6611f3a2c3ab914efd367895 1 parent 00d7810
@tototoshi authored
View
32 project/Build.scala
@@ -240,6 +240,35 @@ object ScalikeJDBCProjects extends Build {
)
) dependsOn(scalikejdbc)
+ lazy val scalikejdbcPlayFixturePlugin = Project(
+ id = "play-fixture-plugin",
+ base = file("scalikejdbc-play-fixture-plugin"),
+ settings = Defaults.defaultSettings ++ Seq(
+ sbtPlugin := false,
+ organization := _organization,
+ name := "scalikejdbc-play-fixture-plugin",
+ version := _version,
+ crossScalaVersions := Seq("2.10.0"),
+ resolvers ++= _resolvers,
+ libraryDependencies ++= Seq(
+ "play" %% "play" % "2.1.0" % "provided",
+ "play" %% "play-test" % "2.1.0" % "test",
+ "com.h2database" % "h2" % "[1.3,)" % "test"
+ ),
+ testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "sequential", "true"),
+ publishTo <<= version { (v: String) => _publishTo(v) },
+ publishMavenStyle := true,
+ publishArtifact in Test := false,
+ pomIncludeRepository := { x => false },
+ pomExtra := _pomExtra,
+ scalacOptions ++= _scalacOptions
+ )
+ ).dependsOn(
+ scalikejdbcPlayPlugin
+ ).aggregate(
+ scalikejdbcPlayPlugin
+ )
+
lazy val scalikejdbcPlayPluginTestZentasks = {
val appName = "play-plugin-test-zentasks"
val appVersion = "1.0"
@@ -257,10 +286,11 @@ object ScalikeJDBCProjects extends Build {
"Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots"
)
).dependsOn(
- scalikejdbcPlayPlugin,
+ scalikejdbcPlayFixturePlugin,
scalikejdbcInterpolation
).aggregate(
scalikejdbcPlayPlugin,
+ scalikejdbcPlayFixturePlugin,
scalikejdbcInterpolation
)
}
View
1  scalikejdbc-play-fixture-plugin/build.sbt
@@ -0,0 +1 @@
+scalariformSettings
View
0  ...y-plugin/src/main/scala/scalikejdbc/Fixture.scala → ...e-plugin/src/main/scala/scalikejdbc/Fixture.scala
File renamed without changes
View
0  .../scala/scalikejdbc/FixtureNotFoundException.scala → .../scala/scalikejdbc/FixtureNotFoundException.scala
File renamed without changes
View
38 scalikejdbc-play-fixture-plugin/src/main/scala/scalikejdbc/FixturePlugin.scala
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2013 Toshiyuki Takahashi
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package scalikejdbc
+
+import play.api._
+
+/**
+ * The Play fixture plugin
+ */
+class FixturePlugin(implicit app: Application) extends Plugin
+ with FixtureSupport {
+
+ override def onStart(): Unit = {
+ if (Play.isTest || Play.isDev) {
+ loadFixtures()
+ }
+ }
+
+ override def onStop(): Unit = {
+ if (Play.isTest || Play.isDev) {
+ cleanFixtures()
+ }
+ }
+
+}
View
0  ...n/src/main/scala/scalikejdbc/FixtureSupport.scala → ...n/src/main/scala/scalikejdbc/FixtureSupport.scala
File renamed without changes
View
0  ...rc/test/resources/db/fixtures/default/project.sql → ...rc/test/resources/db/fixtures/default/project.sql
File renamed without changes
View
0  .../src/test/resources/db/fixtures/default/users.sql → .../src/test/resources/db/fixtures/default/users.sql
File renamed without changes
View
0  ...in/src/test/resources/db/fixtures/secondary/a.sql → ...in/src/test/resources/db/fixtures/secondary/a.sql
File renamed without changes
View
0  ...ugin/src/test/scala/scalikejdbc/FixtureSpec.scala → ...ugin/src/test/scala/scalikejdbc/FixtureSpec.scala
File renamed without changes
View
2  ...c/test/scala/scalikejdbc/FixtureSupportSpec.scala → ...c/test/scala/scalikejdbc/FixtureSupportSpec.scala
@@ -30,7 +30,7 @@ class FixtureSupportSpec extends Specification with BeforeAfterExample {
"db.secondary.user" -> "l",
"db.secondary.password" -> "g"
),
- additionalPlugins = Seq("scalikejdbc.PlayPlugin")
+ additionalPlugins = Seq("scalikejdbc.PlayPlugin", "scalikejdbc.FixturePlugin")
)
"FixtureSupport" should {
View
10 scalikejdbc-play-plugin/src/main/scala/scalikejdbc/PlayPlugin.scala
@@ -20,8 +20,7 @@ import play.api._
/**
* The Play plugin to use ScalikeJDBC
*/
-class PlayPlugin(implicit app: Application) extends Plugin
- with FixtureSupport {
+class PlayPlugin(implicit app: Application) extends Plugin {
import PlayPlugin._
@@ -90,16 +89,9 @@ class PlayPlugin(implicit app: Application) extends Plugin
opt("closeAllOnStop", "enabled")(playConfig).foreach { enabled => closeAllOnStop = enabled.toBoolean }
- if (Play.isTest || Play.isDev) {
- loadFixtures()
- }
}
override def onStop(): Unit = {
- if (Play.isTest || Play.isDev) {
- cleanFixtures()
- }
-
if (closeAllOnStop) {
ConnectionPool.closeAll()
registeredPoolNames.clear()
View
1  scalikejdbc-play-plugin/test/zentasks/conf/play.plugins
@@ -1,2 +1,3 @@
777:scalikejdbc.PlayPlugin
+888:scalikejdbc.FixturePlugin
Please sign in to comment.
Something went wrong with that request. Please try again.