开发者

Why can my functional test not see my methods created using define_method?

I have this in my application_controller.rb:

Group.all.each do |g|
  define_method( "is_#{ g.name }?".to_sym ) do
    unless @current_user.in_group?( g.name )
      flash[:notice] = "You must be in the #{ g.name.titleize } group to access that page"
      redirect_to '/'
      return false
    end
  end
end

It u开发者_运维百科ses entries in my groups table to create methods on the fly.

My problem is my functional tests can't see those methods:

  1) Error:
test_has_an_index(Sc::QuestionsControllerTest):
NoMethodError: undefined method `is_admin?' for #<Sc::QuestionsController:0x000000067749c0>

What do I need to do so my functional tests can see my dynamically created methods?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜