Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding some test cases for tracking users.

  • Loading branch information...
commit e473fac6365b39e2430ba5024d7d6ba87ad9fe93 1 parent 404c0c8
@digicyc authored
View
8 src/main/scala/SGir.scala
@@ -100,14 +100,18 @@ object SGir extends PircBot {
checkIn(channel, joiner, login, hostname)
}
+ /**
+ * checkin user or add them into DB if not already.
+ * We want this to return a model.User.
+ */
def checkIn(channel: String, joiner: String, login: String, hostname: String): User = {
val user = User where (_.hostname eqs hostname) get
- if (user == None) {
+ if (user == None || user.size < 1) {
// If no user can be found then we create em.
val newUser = User.createRecord.alias(joiner)
newUser.name("")
- newUser.channel(channel)
+ //newUser.channel(channel)
newUser.hostname(hostname)
newUser.karma(0)
newUser.is_admin(false)
View
17 src/test/scala/ChannelPermTest.scala
@@ -1,3 +1,5 @@
+package antitech.sgir.test
+
/**
* Test Channel Permisions.
* channel_perm = {"#chan" -> "ops"} = Has Ops
@@ -10,16 +12,15 @@ import antitech.sgir.model.MongoConfig.initTest
import com.foursquare.rogue.Rogue._
class ChannelPermTest extends Specification {
- // Initalize the test DB
- initTest
-
- // Our Test User
- val newUser = User.createRecord.alias("TestUser")
- newUser.channel_perms("#testchan") = OPS
- newUser.save
-
"A person with ops" should {
"have it set" in {
+ initTest
+
+ // Our Test User
+ val newUser = User.createRecord.alias("TestUser")
+ newUser.channel_perms("#testchan") = OPS
+ newUser.save
+
val user =
User where (_.alias eqs "TestUser") get
user.get.channel_perms("#testchan").get mustEqual OPS
View
18 src/test/scala/UserTest.scala
@@ -0,0 +1,18 @@
+package antitech.sgir.test
+
+/**
+ * Test cases for managing our Users.
+ */
+
+import org.specs2.mutable._
+
+import antitech.sgir.model.MongoConfig.initTest
+
+class UserTest extends Specification {
+ "A user" should {
+ "be added if not" in {
+ initTest
+
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.