From 0ec315c52a731ff149977b9231a15770fa3bd742 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 13 Sep 2012 16:22:17 +0100 Subject: Paginate the timeline to allow it to render in a reasonable amount of time. In order to avoid sorting large numbers of objects in order to get the right order of combined events across the two model types, get the overall order first from the database and then populate the slice we're interested in. --- spec/controllers/admin_general_controller_spec.rb | 45 +++++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'spec/controllers/admin_general_controller_spec.rb') diff --git a/spec/controllers/admin_general_controller_spec.rb b/spec/controllers/admin_general_controller_spec.rb index 820d1e7f3..dc1eb0d97 100644 --- a/spec/controllers/admin_general_controller_spec.rb +++ b/spec/controllers/admin_general_controller_spec.rb @@ -1,18 +1,39 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -describe AdminGeneralController, "when viewing front page of admin interface" do - integrate_views - before { basic_auth_login @request } - - it "should render the front page" do - get :index, :suppress_redirect => 1 - response.should render_template('index') - end +describe AdminGeneralController do + + describe "when viewing front page of admin interface" do + + integrate_views + before { basic_auth_login @request } + + it "should render the front page" do + get :index, :suppress_redirect => 1 + response.should render_template('index') + end + + it "should redirect to include trailing slash" do + get :index + response.should redirect_to(:controller => 'admin_general', + :action => 'index') + end - it "should redirect to include trailing slash" do - get :index - response.should redirect_to(:controller => 'admin_general', - :action => 'index') end + describe 'when viewing the timeline' do + + it 'should assign an array of events in order of descending date to the view' do + get :timeline, :all => 1 + previous_event = nil + previous_event_at = nil + assigns[:events].each do |event, event_at| + if previous_event + (event_at <= previous_event_at).should be_true + end + previous_event = event + previous_event_at = event_at + end + end + + end end -- cgit v1.2.3