-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprivacy_version_test.rb
More file actions
89 lines (75 loc) · 2.23 KB
/
privacy_version_test.rb
File metadata and controls
89 lines (75 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
require "test_helper"
class PrivacyVersionTest < ActiveSupport::TestCase
test "should be valid with valid attributes" do
privacy_version = PrivacyVersion.new(
version: 2,
current_type: :current,
published_at: Date.today,
title: "Test Privacy Version",
description: "Test Description"
)
assert privacy_version.valid?
end
test "should have current_type enum" do
privacy_version = PrivacyVersion.new(
version: 2,
current_type: :current,
published_at: Date.today
)
assert privacy_version.current?
assert_not privacy_version.uncurrent?
privacy_version.current_type = :uncurrent
assert privacy_version.uncurrent?
assert_not privacy_version.current?
end
test "current_version should return latest current version" do
version = PrivacyVersion.current_version
assert_not_nil version
assert_kind_of Integer, version
end
test "current_version should return highest version number" do
PrivacyVersion.create!(
version: 10,
current_type: :current,
published_at: Date.today,
title: "Version 10",
description: "Test"
)
PrivacyVersion.create!(
version: 15,
current_type: :current,
published_at: Date.today,
title: "Version 15",
description: "Test"
)
assert_equal 15, PrivacyVersion.current_version
end
test "current_version should only return current versions" do
PrivacyVersion.create!(
version: 20,
current_type: :uncurrent,
published_at: Date.today,
title: "Uncurrent",
description: "Test"
)
PrivacyVersion.create!(
version: 5,
current_type: :current,
published_at: Date.today,
title: "Current",
description: "Test"
)
assert_equal 5, PrivacyVersion.current_version
end
test "current_version returns nil when no current version exists" do
PrivacyVersion.update_all(current_type: :uncurrent)
assert_nil PrivacyVersion.current_version
end
test "should load from fixtures" do
assert PrivacyVersion.count > 0
privacy_version = PrivacyVersion.first
assert_not_nil privacy_version
assert_not_nil privacy_version.version
assert_not_nil privacy_version.published_at
end
end