blob: f3e02dd2bff4d0d4a549861c33dd1d86f9726bb1 (
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_equal ["You may not approve or reject drafts"], c.errors[:rating]
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_equal ["You may not approve or reject drafts"], c.errors[:rating]
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
|