On Aug 15, 2008, at 6:46 AM, Matt Wynne <[EMAIL PROTECTED]> wrote:
On 15 Aug 2008, at 12:25, David Chelimsky wrote:
Hey Matt - welcome!
The paginate() method lives on the model class, so there's nothing
stopping you from wrapping those calls in methods on the model,
slinging around the params object.
# CityController
def get_cities
City.paginate_all(params)
end
# City
def self.paginate_all(params)
self.paginate(:all, get_find_params(params).merge!(:page =>
params[:page]))
end
etc
Aha. Cool, thanks.
For my next question: how do I go about driving out change to the
model, spec-first?
I'm thinking I would call (in my spec)
City.should_receive(:paginate).with(:conditions => "name like
'%#{test_params[:name}%'" .... )
City.paginate_all(test_params)
Thereby covering the code in get_find_params()
Is that the right approach?
That's probably how I would do it. Might also consider wrapping the
params in a separate object that manages the extraction.
David
cheers,
Matt
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users