Skip to content

Commit

Permalink
Agenda.current creates new agenda if needed
Browse files Browse the repository at this point in the history
Removed agenda initializer as it is no longer needed.
  • Loading branch information
jbartosik committed Jul 5, 2011
1 parent 0467daa commit 1300715
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion site/app/models/agenda.rb
Expand Up @@ -48,7 +48,9 @@ def view_permitted?(field)
end

def self.current
Agenda.state_is_not(:old).first
result = Agenda.state_is_not(:old).first
result = Agenda.create! unless result
result
end

def self.transitions_available(user)
Expand Down
12 changes: 0 additions & 12 deletions site/config/initializers/agenda.rb

This file was deleted.

12 changes: 12 additions & 0 deletions site/spec/models/agenda_spec.rb
Expand Up @@ -233,6 +233,18 @@ def test_migration(object, migration, prohibited, allowed, final_state)
end
end

describe '#current?' do
it 'should create new agenda if needed' do
Agenda.count.should be_zero
agenda = Agenda.current
agenda2 = Agenda.current
agenda.should be_a(Agenda)
agenda2.should be_a(Agenda)
Agenda.count.should be_equal(1)
agenda.id.should be_equal(agenda2.id)
end
end

it 'should return proper voting_array' do
old_agenda = Factory(:agenda, :state => 'old')
current_agenda = Factory(:agenda)
Expand Down

0 comments on commit 1300715

Please sign in to comment.