aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'site/spec/models')
-rw-r--r--site/spec/models/agenda_spec.rb5
-rw-r--r--site/spec/models/vote_spec.rb9
2 files changed, 13 insertions, 1 deletions
diff --git a/site/spec/models/agenda_spec.rb b/site/spec/models/agenda_spec.rb
index f1de822..f0dc747 100644
--- a/site/spec/models/agenda_spec.rb
+++ b/site/spec/models/agenda_spec.rb
@@ -124,7 +124,9 @@ describe Agenda do
end
u = users_factory(:council, :council, :council)
- Vote.count.should be_zero
+ Factory(:vote, :user => u.first, :voting_option => a1.voting_options.first)
+
+ Vote.count.should be_equal(1)
results_hash = {
a1.title => { u[0].irc_nick => 'Yes', u[1].irc_nick => 'Yes', u[2].irc_nick => 'Yes'},
@@ -135,6 +137,7 @@ describe Agenda do
Agenda.process_results results_hash
Vote.count.should be_equal(9)
+ Vote.council_vote_is(true).count.should be_equal(9)
u[0].votes.*.voting_option.*.description.sort.should == ['Dunno', 'Yes', 'Yes']
u[1].votes.*.voting_option.*.description.sort.should == ['Dunno', 'No', 'Yes']
diff --git a/site/spec/models/vote_spec.rb b/site/spec/models/vote_spec.rb
index aa9f2e8..f2d529e 100644
--- a/site/spec/models/vote_spec.rb
+++ b/site/spec/models/vote_spec.rb
@@ -37,4 +37,13 @@ describe Vote do
o = Factory(:voting_option, :agenda_item => v.voting_option.agenda_item, :description => 'other option')
Vote.new(:user => v.user, :voting_option => o).should_not be_valid
end
+
+ it 'should prevent users from setting council_vote to true' do
+ for u in users_factory(AllRoles - [:guest])
+ v = Factory(:vote, :user => u, :council_vote => true)
+ v.should_not be_editable_by(u)
+ v.should_not be_updatable_by(u)
+ v.should_not be_destroyable_by(u)
+ end
+ end
end