diff options
author | 2011-05-18 17:19:38 +0200 | |
---|---|---|
committer | 2011-06-01 15:21:14 +0200 | |
commit | 4b874a907e16dcfb61cc82a69f9c3891bff1bfa8 (patch) | |
tree | d364ca3c0983cfd383c550792df6529443ed8bbe /site/spec/models/vote_spec.rb | |
parent | MeetBot plugin from Debian (diff) | |
download | council-webapp-4b874a907e16dcfb61cc82a69f9c3891bff1bfa8.tar.gz council-webapp-4b874a907e16dcfb61cc82a69f9c3891bff1bfa8.tar.bz2 council-webapp-4b874a907e16dcfb61cc82a69f9c3891bff1bfa8.zip |
Application provides data for IRC bot
Diffstat (limited to 'site/spec/models/vote_spec.rb')
-rw-r--r-- | site/spec/models/vote_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/site/spec/models/vote_spec.rb b/site/spec/models/vote_spec.rb new file mode 100644 index 0000000..9936829 --- /dev/null +++ b/site/spec/models/vote_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Vote do + it 'should not allow anyone to create update or destroy to anyone' do + vote = Factory(:vote) + for u in users_factory(AllRoles) do + vote.should_not be_creatable_by(u) + vote.should_not be_updatable_by(u) + vote.should_not be_destroyable_by(u) + end + end + + it 'should anyone to view' do + vote = Factory(:vote) + for u in users_factory(AllRoles) do + vote.should be_viewable_by(u) + end + end + + it 'should allow council members to vote' do + for u in users_factory(:council, :council_admin) do + Vote.new(:user => u, :voting_option => Factory(:voting_option)).should be_valid + end + end + + it 'should prevent non-council members from voting' do + for u in users_factory(:user, :admin) do + Vote.new(:user => u, :voting_option => Factory(:voting_option)).should_not be_valid + end + end + + it 'should prevent users from voting multiple times' do + v = Factory(:vote) + 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 +end |