+ assert_template "users/no_such_user"
+
+ get :index, :params => { :format => "html", :display_name => "Some random user", :list => "1" }, :xhr => true
+ assert_response :not_found
+ assert_template "users/no_such_user"
+ end
+
+ ##
+ # Checks the display of the friends changesets listing
+ def test_index_friends
+ private_user = create(:user, :data_public => true)
+ friend = create(:friend, :befriender => private_user)
+ create(:changeset, :user => friend.befriendee)
+
+ get :index, :params => { :friends => true }
+ assert_response :redirect
+ assert_redirected_to :controller => :users, :action => :login, :referer => friend_changesets_path
+
+ session[:user] = private_user.id
+
+ get :index, :params => { :friends => true }
+ assert_response :success
+ assert_template "history"
+
+ get :index, :params => { :friends => true, :list => "1" }, :xhr => true
+ assert_response :success
+ assert_template "index"
+
+ check_index_result(Changeset.where(:user => private_user.friend_users.identifiable))
+ end
+
+ ##
+ # Checks the display of the nearby user changesets listing
+ def test_index_nearby
+ private_user = create(:user, :data_public => false, :home_lat => 51.1, :home_lon => 1.0)
+ user = create(:user, :home_lat => 51.0, :home_lon => 1.0)
+ create(:changeset, :user => user)
+
+ get :index, :params => { :nearby => true }
+ assert_response :redirect
+ assert_redirected_to :controller => :users, :action => :login, :referer => nearby_changesets_path
+
+ session[:user] = private_user.id
+
+ get :index, :params => { :nearby => true }
+ assert_response :success
+ assert_template "history"
+
+ get :index, :params => { :nearby => true, :list => "1" }, :xhr => true
+ assert_response :success
+ assert_template "index"
+
+ check_index_result(Changeset.where(:user => user.nearby))
+ end
+
+ ##
+ # Check that we can't request later pages of the changesets index
+ def test_index_max_id
+ get :index, :params => { :format => "html", :max_id => 4 }, :xhr => true
+ assert_response :success
+ assert_template "history"
+ assert_template :layout => "xhr"
+ assert_select "h2", :text => "Changesets", :count => 1
+
+ get :index, :params => { :format => "html", :list => "1", :max_id => 4 }, :xhr => true
+ assert_response :success
+ assert_template "index"
+
+ check_index_result(Changeset.where("id <= 4"))
+ end
+
+ ##
+ # Check that a list with a next page link works
+ def test_index_more
+ create_list(:changeset, 50)
+
+ get :index, :params => { :format => "html" }
+ assert_response :success
+
+ get :index, :params => { :format => "html" }, :xhr => true
+ assert_response :success