+ assert_template "user/no_such_user"
+ end
+
+ ##
+ # Checks the display of the friends changesets listing
+ def test_list_friends
+ private_user = create(:user, :data_public => true)
+ friend = create(:friend, :befriender => private_user)
+ create(:changeset, :user => friend.befriendee)
+
+ get :list, :params => { :friends => true }
+ assert_response :redirect
+ assert_redirected_to :controller => :user, :action => :login, :referer => friend_changesets_path
+
+ session[:user] = private_user.id
+
+ get :list, :params => { :friends => true }
+ assert_response :success
+ assert_template "history"
+
+ get :list, :params => { :friends => true, :list => "1" }, :xhr => true
+ assert_response :success
+ assert_template "list"
+
+ check_list_result(Changeset.where(:user => private_user.friend_users.identifiable))
+ end
+
+ ##
+ # Checks the display of the nearby user changesets listing
+ def test_list_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 :list, :params => { :nearby => true }
+ assert_response :redirect
+ assert_redirected_to :controller => :user, :action => :login, :referer => nearby_changesets_path
+
+ session[:user] = private_user.id
+
+ get :list, :params => { :nearby => true }
+ assert_response :success
+ assert_template "history"
+
+ get :list, :params => { :nearby => true, :list => "1" }, :xhr => true
+ assert_response :success
+ assert_template "list"
+
+ check_list_result(Changeset.where(:user => user.nearby))
+ end
+
+ ##
+ # Check that we can't request later pages of the changesets list
+ def test_list_max_id
+ get :list, :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 :list, :params => { :format => "html", :list => "1", :max_id => 4 }, :xhr => true
+ assert_response :success
+ assert_template "list"
+
+ check_list_result(Changeset.where("id <= 4"))
+ end
+
+ ##
+ # Check that a list with a next page link works
+ def test_list_more
+ create_list(:changeset, 50)
+
+ get :list, :params => { :format => "html" }
+ assert_response :success
+
+ get :list, :params => { :format => "html" }, :xhr => true
+ assert_response :success