diff options
Diffstat (limited to 'site/spec/models')
-rw-r--r-- | site/spec/models/agenda_spec.rb | 22 | ||||
-rw-r--r-- | site/spec/models/approval_spec.rb | 36 |
2 files changed, 58 insertions, 0 deletions
diff --git a/site/spec/models/agenda_spec.rb b/site/spec/models/agenda_spec.rb index 00165d1..b9e564c 100644 --- a/site/spec/models/agenda_spec.rb +++ b/site/spec/models/agenda_spec.rb @@ -23,6 +23,20 @@ describe Agenda do end end + it 'should allow everybody to view summaries after 4 council members approved it' do + agenda = Agenda.current + + for u in users_factory(:guest, :user, :admin) + agenda.should_not be_viewable_by(u, :summary) + end + + (1..4).each { |i| Factory(:approval, :agenda => agenda) } + + for u in users_factory(AllRoles) + agenda.should be_viewable_by(u, :summary) + end + end + it 'should allow only administrators and council members to edit and update' do a = Factory(:agenda) for u in users_factory(:guest, :user) @@ -310,4 +324,12 @@ describe Agenda do VotingOption.last.description.should == 'new option' end end + + it 'should remove approvals for summary, when summary changes' do + agenda = Agenda.current + Factory(:approval, :agenda => agenda) + agenda.summary = 'changed' + agenda.save! + Approval.count.should be_zero + end end diff --git a/site/spec/models/approval_spec.rb b/site/spec/models/approval_spec.rb new file mode 100644 index 0000000..4057a6d --- /dev/null +++ b/site/spec/models/approval_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe Approval do + it 'should be viewable by everybody' do + approval = Factory(:approval) + for user in users_factory(AllRoles) + approval.should be_viewable_by(user) + end + end + + it 'only council members should be able to change it - and only for themselves' do + for user in users_factory(:council, :council_admin) + approval = Factory(:approval, :user => user) + approval.should be_creatable_by(user) + approval.should be_editable_by(user) + approval.should be_updatable_by(user) + approval.should be_destroyable_by(user) + end + + approval = Factory(:approval) + for user in users_factory(:council, :council_admin) + approval.should_not be_creatable_by(user) + approval.should_not be_editable_by(user) + approval.should_not be_updatable_by(user) + approval.should_not be_destroyable_by(user) + end + + for user in users_factory(:user, :admin) + approval = Approval.new :user => user, :agenda => Agenda.current + approval.should_not be_creatable_by(user) + approval.should_not be_editable_by(user) + approval.should_not be_updatable_by(user) + approval.should_not be_destroyable_by(user) + end + end +end |