+ end
+
+ def test_show_private_account
+ user = create(:user, :data_public => false)
+
+ # Make sure that you are redirected to the login page when
+ # you are not logged in
+ get account_path
+ assert_redirected_to login_path(:referer => account_path)
+
+ # Make sure we get the page when we are logged in as the right user
+ session_for(user)
+ get account_path
+ assert_response :success
+ assert_template :show
+ assert_select "form#accountForm" do |form|
+ assert_equal "post", form.attr("method").to_s
+ assert_select "input[name='_method']", true
+ assert_equal "/account", form.attr("action").to_s
+ end
+
+ # Make sure we have a button to "go public"
+ assert_select "form.button_to[action='/user/go_public']", true
+ end
+
+ def test_destroy_allowed
+ user = create(:user)
+ session_for(user)
+
+ delete account_path
+ assert_response :redirect
+ end
+
+ def test_destroy_not_allowed
+ with_user_account_deletion_delay(24) do
+ user = create(:user)
+ create(:changeset, :user => user, :created_at => Time.now.utc)
+ session_for(user)
+
+ delete account_path
+ assert_response :bad_request
+ end