将Rails从3.0.1升级到3.0.7后,classy_enum的TypeError

时间:2011-06-24 06:28:10

标签: ruby-on-rails-3

我刚刚将开发mac上的rails从3.0.1升级到3.0.7。 试图运行rspec(2.6.0)(带有factory_girl_rails 1.0.1)并在所有测试中出现错误,其中模型使用classy_enum(0.9.1)gem进行状态实现。 Rails本身运行没有问题,但rspec测试失败。不知道导致错误的原因。

这里确切的错误:

1) Billboard should create a new instance given valid attributes
      Failure/Error: @etype = Factory(:etype)
      TypeError:
          Cannot visit EtypeGroupActivity
   # ./spec/models/billboard_spec.rb:6:in `block (2 levels) in <top (required)>'

Etype型号代码:

class Etype < ActiveRecord::Base
  attr_accessible :code, :group, :order, :logo
  classy_enum_attr :group, :enum => :etype_group
  delegate :group_name, :to => :group

Etype_group枚举代码:

class EtypeGroup < ClassyEnum::Base
  enum_classes :event, :event_session, :activity, :venue, :venue_space
  def group_name
    ""
  end
end

class EtypeGroupEvent < EtypeGroup
  def group_name
    I18n.t('etypes.groups.event')
  end
end

更新:

billboard_spec代码是:

require 'spec_helper'

describe Billboard do
  before(:each) do
    @user = Factory(:user)
    @etype = Factory(:etype)
    @attr = { :title    => "First Keynote",
              :etype_id => @etype,
              :summary  => "This keynote will open our event" }
  end

  it "should create a new instance given valid attributes" do
    @user.billboards.create!(@attr)
  end
end

在工厂。我有:

Factory.define :etype do |etype|
  etype.code                 "keynote"
  etype.group                "activity"
  etype.order                10
end

1 个答案:

答案 0 :(得分:0)

问题已从ClassyEnum version 1.0.0

解决