blob: 6e0de8b37783b5fdbe324a350d748f18fb277044 (
plain)
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
|
require 'test_helper'
class CommentTest < ActiveSupport::TestCase
fixtures :all
test "padawans should not be able to make approvals" do
c = Comment.new
c.glsa_id = 1
c.user = users(:test_padawan)
c.text = "test"
c.rating = "approval"
c.save
assert c.errors.any?
assert_includes c.errors[:rating], "You may not approve or reject drafts"
end
test "padawans should not be able to make rejections" do
c = Comment.new
c.glsa_id = 1
c.user = users(:test_padawan)
c.text = "test"
c.rating = "rejection"
c.save
assert c.errors.any?
assert_includes c.errors[:rating], "You may not approve or reject drafts"
end
test "advisory owners should not be able to approve their own drafts" do
c = Comment.new
c.user_id = 1
c.text = "test"
c.rating = "approval"
c.glsa_id = 2
c.save
assert c.errors.any?
assert_equal ["The owner of a draft cannot make approvals or rejections"], c.errors[:rating]
end
test "users should not be able to approve a draft twice" do
# second comment loaded from fixtures
c = Comment.new
c.user_id = 7
c.text = "test"
c.rating = "approval"
c.glsa_id = 2
c.save
assert c.errors.any?
assert_equal ["You have already approved or rejected this draft"], c.errors[:rating]
end
end
|