Browse code

Testy pre User model

Cinan Rakosnik authored on 17/03/2013 at 14:55:39
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,43 @@
0
+require 'test_helper'
1
+require 'ipaddr'
2
+
3
+class UserTest < ActiveSupport::TestCase
4
+
5
+	def setup
6
+
7
+	end
8
+
9
+	def teardown
10
+		User.delete_all()
11
+	end
12
+
13
+	test "create new account" do
14
+        jid = "jid@example.com"
15
+        User.create_jid(jid)
16
+
17
+        assert_not_nil User.existing_jid(jid).first
18
+    end
19
+
20
+    test "set password" do
21
+        jid = "name@example.com"
22
+        pass = "password"
23
+
24
+        user = User.create_jid(jid)
25
+        user.update_pass(jid, pass)
26
+
27
+        assert_not_nil User.where("jids.jid" => jid, "jids.pass" => pass).first
28
+    end
29
+
30
+    test "add another account" do
31
+        jid = "name@example.com"
32
+
33
+        jid2 = "name2@example.com"
34
+        pass = "pass"
35
+
36
+        user = User.create_jid(jid)
37
+
38
+        user.add_account(jid2, pass)
39
+
40
+        assert_equal 2, User.existing_jid(jid).jids.count
41
+    end
42
+end