From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QXxfl-0002Nw-4g for garchives@archives.gentoo.org; Sat, 18 Jun 2011 15:42:57 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 43D1C1C03C; Sat, 18 Jun 2011 15:42:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 05A931C03C for ; Sat, 18 Jun 2011 15:42:34 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7D7B11B403A for ; Sat, 18 Jun 2011 15:42:34 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 5FAD280048 for ; Sat, 18 Jun 2011 15:42:33 +0000 (UTC) From: "Petteri Räty" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" Message-ID: <2b881b6ab25ff7b659548d1b7dc9e4b877081f14.betelgeuse@gentoo> Subject: [gentoo-commits] proj/council-webapp:master commit in: site/app/models/, site/spec/models/ X-VCS-Repository: proj/council-webapp X-VCS-Files: site/app/models/agenda.rb site/spec/models/agenda_spec.rb X-VCS-Directories: site/app/models/ site/spec/models/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 2b881b6ab25ff7b659548d1b7dc9e4b877081f14 Date: Sat, 18 Jun 2011 15:42:33 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: f9b70a65b55f96016dbeb15ccb2458ab commit: 2b881b6ab25ff7b659548d1b7dc9e4b877081f14 Author: Joachim Filip Ignacy Bartosik gmail com= > AuthorDate: Mon Jun 13 11:44:07 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Fri Jun 17 18:36:10 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/council-webap= p.git;a=3Dcommit;h=3D2b881b6a Improve Agenda model spec coverage Fixed Agenda#current? - now it returns true for agendas in state meeting_= ongoing. --- site/app/models/agenda.rb | 2 +- site/spec/models/agenda_spec.rb | 43 +++++++++++++++++++++++++++++++++= ++++++ 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 =20 def current? - ['open', 'submissions_closed'].include?(state.to_s) + ['open', 'submissions_closed', 'meeting_ongoing'].include?(state.to_= s) end =20 def voting_array diff --git a/site/spec/models/agenda_spec.rb b/site/spec/models/agenda_sp= ec.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 =20 Agenda.irc_reminders.should be_empty end + + it 'should return proper possible_transitions for each state' do + a =3D Factory(:agenda) + u =3D users_factory(:council) + a.possible_transitions.should =3D=3D [["Close this agenda.", "agenda= _close_path"]] + a.lifecycle.close!(u) + a.possible_transitions.should =3D=3D [["Reopen this agenda.", "agend= a_reopen_path"], ["Archive this agenda.", "agenda_archive_path"]] + a.lifecycle.archive!(u) + a.possible_transitions.should =3D=3D [] + 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 =3D> 'submissions_closed').should be_curre= nt + end + + it 'should return true if agenda is in meeting_ongoing state' do + Factory(:agenda, :state =3D> 'meeting_ongoing').should be_current + end + + it 'should return true if agenda is in old state' do + Factory(:agenda, :state =3D> 'old').should_not be_current + end + end + + it 'should return proper voting_array' do + old_agenda =3D Factory(:agenda, :state =3D> 'old') + current_agenda =3D Factory(:agenda) + i1 =3D Factory(:agenda_item, :agenda =3D> old_agenda) + i2 =3D Factory(:agenda_item, :agenda =3D> current_agenda) + i3 =3D Factory(:agenda_item, :agenda =3D> current_agenda) + + v11 =3D Factory(:voting_option, :agenda_item =3D> i1) + v21 =3D Factory(:voting_option, :agenda_item =3D> i2) + v22 =3D Factory(:voting_option, :agenda_item =3D> i2, :description =3D= > 'other') + + old_agenda.voting_array.should =3D=3D [[i1.title, [v11.description]]= ] + current_agenda.voting_array.should =3D=3D [[i2.title, [v21.descripti= on, v22.description]], [i3.title, []]] + end end