On Tue, Apr 21, 2009 at 4:02 AM, Michael Schuerig <mich...@schuerig.de> wrote: > On Monday 20 April 2009, Zach Dennis wrote: >> > I don't agress. Both classes have distinct, although related >> > purposes. RequestCondition implements the translation from request >> > parameters to #find-options. QueryScope(Builder) fits it in with >> > ActionController and adds syntactic sugar. The former is easy to >> > spec, for the latter, I've been to lazy to figure out a good way. >> >> I'm just suggesting that RequestCondition and QueryScopeBuilder are >> encapsulated behind RequestToQueryTranslator, so your controller >> doesn't have to know about both of them. Your controller doesn't >> actually care about request conditioners and query scope builders. It >> only cares that it can translate a request to a query so it can be >> used to set the scope on the model. > > That's already the case. Both of these classes are only internally used > by module QueryScope, which is the only thing a controller sees:
But you're mixing in QueryScope to the controller, it's just like if you put #query_scope inside of the controller itself. Mixins are a way to organize and re-use code, but putting code in modules does not automatically mean you are decoupling parts of your app. Your controller spec will have to take into account whatever dependencies your #query_scope method has unless you completely mock/stub it out, but that seems to work against your goal, > > class PeopleController < ApplicationController > include QueryScope > > query_scope :only => :index do > # Only allow to filter and order by the > # virtual name attribute. > # This attribute is mapped onto the real > # firstname and lastname attributes. > allow :name > condition :name => > "LOWER(firstname || ' ' || lastname) :op LOWER(?)" > order :name => "lastname :dir, firstname :dir" > end > > Michael. > > -- > Michael Schuerig > mailto:mich...@schuerig.de > http://www.schuerig.de/michael/ > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users