blob: 2b6005c7a560830f8b38d41a927d21022de10267 (
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
|
require 'spec_helper'
describe VotingOption do
it 'should allow only council members to create' do
v = Factory(:voting_option)
for u in users_factory(:guest, :user, :admin)
v.should_not be_creatable_by(u)
end
for u in users_factory(:council, :council_admin)
v.should be_creatable_by(u)
end
end
it 'should allow only council members to update and destroy if it belongs to open agenda' do
v = Factory(:voting_option)
for u in users_factory(:guest, :user, :admin)
v.should_not be_updatable_by(u)
v.should_not be_destroyable_by(u)
end
for u in users_factory(:council, :council_admin)
v.should be_updatable_by(u)
v.should be_destroyable_by(u)
end
end
it 'should allow no one to update and destroy if it belongs to closed or archived agenda' do
a1 = Factory(:agenda, :state => 'closed')
i1 = Factory(:agenda_item, :agenda => a1)
v1 = Factory(:voting_option, :agenda_item => i1)
a2 = Factory(:agenda, :state => 'old')
i2 = Factory(:agenda_item, :agenda => a2)
v2 = Factory(:voting_option, :agenda_item => i2)
for u in users_factory(AllRoles)
v1.should_not be_updatable_by(u)
v1.should_not be_destroyable_by(u)
v2.should_not be_updatable_by(u)
v2.should_not be_destroyable_by(u)
end
end
it 'should allow everyone to view' do
v = Factory(:voting_option)
for u in users_factory(AllRoles)
v.should be_viewable_by(u)
end
end
end
|