aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-13 13:44:07 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-17 20:36:10 +0200
commit2b881b6ab25ff7b659548d1b7dc9e4b877081f14 (patch)
tree7a499403a676cf0ec2ac79882dc7654869b01520
parentImprove VotingOption model test coverage (diff)
downloadcouncil-webapp-2b881b6ab25ff7b659548d1b7dc9e4b877081f14.tar.gz
council-webapp-2b881b6ab25ff7b659548d1b7dc9e4b877081f14.tar.bz2
council-webapp-2b881b6ab25ff7b659548d1b7dc9e4b877081f14.zip
Improve Agenda model spec coverage
Fixed Agenda#current? - now it returns true for agendas in state meeting_ongoing.
-rw-r--r--site/app/models/agenda.rb2
-rw-r--r--site/spec/models/agenda_spec.rb43
2 files changed, 44 insertions, 1 deletions
diff --git a/site/app/models/agenda.rb b/site/app/models/agenda.rb
index 5be2d82..8f05e09 100644
--- a/site/app/models/agenda.rb
+++ b/site/app/models/agenda.rb
@@ -86,7 +86,7 @@ class Agenda < ActiveRecord::Base
end
def current?
- ['open', 'submissions_closed'].include?(state.to_s)
+ ['open', 'submissions_closed', 'meeting_ongoing'].include?(state.to_s)
end
def voting_array
diff --git a/site/spec/models/agenda_spec.rb b/site/spec/models/agenda_spec.rb
index 29f0bcb..b9fbd36 100644
--- a/site/spec/models/agenda_spec.rb
+++ b/site/spec/models/agenda_spec.rb
@@ -204,4 +204,47 @@ describe Agenda do
Agenda.irc_reminders.should be_empty
end
+
+ it 'should return proper possible_transitions for each state' do
+ a = Factory(:agenda)
+ u = users_factory(:council)
+ a.possible_transitions.should == [["Close this agenda.", "agenda_close_path"]]
+ a.lifecycle.close!(u)
+ a.possible_transitions.should == [["Reopen this agenda.", "agenda_reopen_path"], ["Archive this agenda.", "agenda_archive_path"]]
+ a.lifecycle.archive!(u)
+ a.possible_transitions.should == []
+ end
+
+ describe '#current?' do
+ it 'should return true if agenda is in open state' do
+ Factory(:agenda).should be_current
+ end
+
+ it 'should return true if agenda is in submissions_closed state' do
+ Factory(:agenda, :state => 'submissions_closed').should be_current
+ end
+
+ it 'should return true if agenda is in meeting_ongoing state' do
+ Factory(:agenda, :state => 'meeting_ongoing').should be_current
+ end
+
+ it 'should return true if agenda is in old state' do
+ Factory(:agenda, :state => 'old').should_not be_current
+ end
+ end
+
+ it 'should return proper voting_array' do
+ old_agenda = Factory(:agenda, :state => 'old')
+ current_agenda = Factory(:agenda)
+ i1 = Factory(:agenda_item, :agenda => old_agenda)
+ i2 = Factory(:agenda_item, :agenda => current_agenda)
+ i3 = Factory(:agenda_item, :agenda => current_agenda)
+
+ v11 = Factory(:voting_option, :agenda_item => i1)
+ v21 = Factory(:voting_option, :agenda_item => i2)
+ v22 = Factory(:voting_option, :agenda_item => i2, :description => 'other')
+
+ old_agenda.voting_array.should == [[i1.title, [v11.description]]]
+ current_agenda.voting_array.should == [[i2.title, [v21.description, v22.description]], [i3.title, []]]
+ end
end