4
4
5
5
class PasswordUnitTest < Minitest ::Test
6
6
def test_save
7
- password = Push . create ( payload : "asdf" )
7
+ password = Push . create ( kind : "text" , payload : "asdf" )
8
8
password . check_limits
9
9
assert password . save
10
10
end
11
11
12
12
def test_kind_validation
13
- password = Push . create ( payload : "asdf" )
13
+ password = Push . create ( kind : "text" , payload : "asdf" )
14
14
password . valid?
15
15
assert password . errors [ :kind ] . none?
16
16
@@ -28,19 +28,19 @@ def test_kind_validation
28
28
end
29
29
30
30
def test_expired_check
31
- password = Push . create ( payload : "asdf" )
31
+ password = Push . create ( kind : "text" , payload : "asdf" )
32
32
password . check_limits
33
33
assert_not password . expired?
34
34
35
- password = Push . create ( payload : "asdf" , created_at : 100 . weeks . ago , updated_at : 100 . weeks . ago )
35
+ password = Push . create ( kind : "text" , payload : "asdf" , created_at : 100 . weeks . ago , updated_at : 100 . weeks . ago )
36
36
assert password
37
37
38
38
password . check_limits
39
39
assert password . expired?
40
40
end
41
41
42
42
def test_defaults
43
- push = Push . create ( created_at : 3 . days . ago , updated_at : 3 . days . ago , payload : "asdf" )
43
+ push = Push . create ( kind : "text" , created_at : 3 . days . ago , updated_at : 3 . days . ago , payload : "asdf" )
44
44
45
45
assert push . expire_after_days == Settings . pw . expire_after_days_default
46
46
assert push . expire_after_views == Settings . pw . expire_after_views_default
@@ -51,7 +51,7 @@ def test_defaults
51
51
52
52
def test_days_expiration
53
53
# 3 days left
54
- push = Push . create ( created_at : 3 . days . ago , updated_at : 3 . days . ago ,
54
+ push = Push . create ( kind : "text" , created_at : 3 . days . ago , updated_at : 3 . days . ago ,
55
55
payload : "asdf" , expire_after_days : 6 )
56
56
push . check_limits
57
57
@@ -60,7 +60,7 @@ def test_days_expiration
60
60
assert_not push . expired
61
61
62
62
# already expired
63
- push = Push . create ( created_at : 3 . days . ago , updated_at : 3 . days . ago ,
63
+ push = Push . create ( kind : "text" , created_at : 3 . days . ago , updated_at : 3 . days . ago ,
64
64
payload : "asdf" , expire_after_days : 1 )
65
65
push . check_limits
66
66
@@ -69,7 +69,7 @@ def test_days_expiration
69
69
assert push . expired
70
70
71
71
# Old expired push
72
- push = Push . create ( created_at : 100 . days . ago , updated_at : 100 . days . ago ,
72
+ push = Push . create ( kind : "text" , created_at : 100 . days . ago , updated_at : 100 . days . ago ,
73
73
payload : "asdf" , expire_after_days : 1 )
74
74
push . check_limits
75
75
@@ -78,7 +78,7 @@ def test_days_expiration
78
78
assert push . expired
79
79
80
80
# Today 1 day password
81
- push = Push . create ( payload : "asdf" , expire_after_days : 1 )
81
+ push = Push . create ( kind : "text" , payload : "asdf" , expire_after_days : 1 )
82
82
push . check_limits
83
83
84
84
assert push . days_old . zero?
@@ -88,14 +88,14 @@ def test_days_expiration
88
88
89
89
def test_views_expiration
90
90
# No views
91
- push = Push . create ( payload : "asdf" , expire_after_views : 1 )
91
+ push = Push . create ( kind : "text" , payload : "asdf" , expire_after_views : 1 )
92
92
push . check_limits
93
93
94
94
assert push . views_remaining == 1
95
95
assert_not push . expired
96
96
97
97
# 1 View should expire
98
- push = Push . create ( payload : "asdf" , expire_after_views : 1 )
98
+ push = Push . create ( kind : "text" , payload : "asdf" , expire_after_views : 1 )
99
99
push . check_limits
100
100
101
101
assert push . views_remaining == 1
0 commit comments