aboutsummaryrefslogtreecommitdiff
path: root/site/spec
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-29 21:05:59 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-07-06 16:49:50 +0200
commit18d211a14161638795cc0641646e0d454f97959c (patch)
treee2749d8abd282c45e6a9f12a9ba454395b6baa81 /site/spec
parentAllow all users to vote (diff)
downloadcouncil-webapp-18d211a14161638795cc0641646e0d454f97959c.tar.gz
council-webapp-18d211a14161638795cc0641646e0d454f97959c.tar.bz2
council-webapp-18d211a14161638795cc0641646e0d454f97959c.zip
Distinguish votes made during council voting and community voice
* Add council_vote to Vote model. * Users can create votes only with council_vote = false inside application. * Votes created from data from council meeting have council_vote = true. * Update council member vote after meeting if [s]he made one using web app.
Diffstat (limited to 'site/spec')
-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