blob: 995ebb19bad614b765255c50deea0bc9364e7014 (
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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
require 'spec_helper'
describe Proxy do
it 'should require agenda to be set' do
p = Proxy.new
p.should_not be_valid
p.errors.keys.include?(:agenda).should be_true
p.errors[:agenda].include?("can't be blank").should be_true
p.agenda = Agenda.current || Factory(:agenda)
p.valid?
p.errors.keys.include?(:agenda).should be_false
end
it 'should require council member to be set and to be council member' do
p = Proxy.new
p.should_not be_valid
p.errors.keys.include?(:council_member).should be_true
p.errors[:council_member].include?("can't be blank").should be_true
p.council_member = Factory(:user)
p.should_not be_valid
p.errors.keys.include?(:council_member).should be_true
p.errors[:council_member].include?('must be council member').should be_true
p.council_member = users_factory(:council)
p.valid?
p.errors.keys.include?(:council_member).should be_false
end
it 'should require proxy to be set and not to be council member' do
p = Proxy.new
p.should_not be_valid
p.errors.keys.include?(:proxy).should be_true
p.errors[:proxy].include?("can't be blank").should be_true
p.proxy = users_factory(:council)
p.should_not be_valid
p.errors.keys.include?(:proxy).should be_true
p.errors[:proxy].include?('must not be council member').should be_true
p.proxy = Factory(:user)
p.valid?
p.errors.keys.include?(:proxy).should be_false
end
it 'should allow only council members to create for their selfs' do
for u in users_factory(:user, :admin)
p = Proxy.new :council_member => u
p.should_not be_creatable_by(u)
end
p = Proxy.new :council_member => users_factory(:council_admin)
for u in users_factory(:council, :council_admin)
p.should_not be_creatable_by(u)
end
for u in users_factory(:council, :council_admin)
p = Proxy.new :council_member => u
p.should be_creatable_by(u)
end
end
it 'should allow no one to update or edit' do
p = Factory(:proxy)
for u in users_factory(:all_roles) + [p.council_member, p.proxy]
p.should_not be_editable_by(u)
p.should_not be_updatable_by(u)
end
end
it 'should allow everyone to view' do
p = Factory(:proxy)
for u in users_factory(:all_roles) + [p.council_member, p.proxy]
p.should be_viewable_by(u)
end
end
it 'should allow council members to destroy their own proxies for current meeting' do
a = Factory(:agenda)
p = Factory(:proxy, :agenda => a)
p.should be_destroyable_by(p.council_member)
end
it 'should not allow council members to destroy their own proxies for old meetings' do
a = Factory(:agenda, :state => 'old')
p = Factory(:proxy, :agenda => a)
p.should_not be_destroyable_by(p.council_member)
end
it 'should not allow users to destoy someone else proxy' do
a = Factory(:agenda)
p = Factory(:proxy, :agenda => a)
for u in users_factory(:all_roles)
p.should_not be_destroyable_by(u)
end
end
it 'should remember nick of council member and proxy from time it was created' do
c = users_factory(:council)
u = users_factory(:user)
p = Factory(:proxy, :council_member => c, :proxy => u)
c_nick = c.irc_nick
u_nick = u.irc_nick
u.irc_nick = 'diffrent nick'
c.irc_nick = 'other nick'
u.save!
c.save!
p.reload
p.council_member_nick.should == c_nick
p.proxy_nick.should == u_nick
end
end
|