rubycas / rubycas-client

Ruby client for Yale's Central Authentication Service protocol -- an open source enterprise single sign on system for web applications.
http://code.google.com/p/rubycas-client/
Other
332 stars 217 forks source link

Use of class level configuration, singleton pattern makes testing difficult #47

Closed CloCkWeRX closed 12 years ago

CloCkWeRX commented 12 years ago

The way the code is put together implies There Will Only Ever Be One Filter.

This is particularly annoying to test, as:

Having looked at the origins of this, I under it's from the depths of 2006 or earlier, but it could do with a bit of love to remove the singleton nature and configuration pattern in favour of something more DI flavoured.

ie:

    class YourController
      before_filter :configurize, :restrict
      
      def configurize
        client = CASClient.new()
        @filter = RubyCAS::Filter.new(client, config.rubycas)
      end

      def restrict
        @filter.filter(self)
      end
    end
CloCkWeRX commented 12 years ago

aw, nuts. This was meant to go on rubycas-client-rails