I tried to strip it down to the most basic elements:

LEAGUE.RB
-----
class League < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    name :string
    description :text
    rules_url :string
    timestamps
  end

  lifecycle do
    state :inactive, :default=>true
    state :active, :locked

    transition :activate, {:inactive=>:locked},
      :available_to => :all
    transition :deactivate, {[:active,:locked]=>:inactive},
      :available_to => :all
    transition :unlock, {:locked=>:active},
      :available_to => :all
    transition :lock, {:active=>:locked},
      :available_to => :all
  end

  # --- Hobo Permissions --- #

  def creatable_by?(user)
    user.administrator?
  end

  def updatable_by?(user, new)
    user.administrator?
  end

  def deletable_by?(user)
    user.administrator?
  end

  def viewable_by?(user, field)
    true
  end

end


LEAGUES.YML
-----
amateur_open:
  name: Amateur Open
  description: This is the amateur open league.
  rules_url: foo
  state: :active

PLAYERS.YML
-----
admin:
  username: admin
  email_address: [email protected]
  game_name: Commissioner
  first_name: The
  last_name: Commissioner
  dob: 1974-10-25
  administrator: true

LEAGUE_TEST.RB
-----
require File.dirname(__FILE__) + '/../test_helper'

class LeagueTest < ActiveSupport::TestCase
  fixtures :leagues, :players

  def test_admin_can_modify
    league = leagues(:amateur_open)
    admin = players(:admin)
    assert league.state == 'active'
    assert league.lifecycle.can_deactivate? admin
  end
end
-----

The final assertion fails.  No idea why.  The transition says its
available_to :all.

This is Rails 2.2.2 and Hobo 0.8.2.

sd
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to