Repository: gratipay/gratipay.com

Issue:
Fix error page
https://app.getsentry.com/gratipay/gratipay-com/group/49625026/ (was https://app.getsentry.com/gratipay/gratipay-com/group/39866655/)



Discussion:

Resolving patch:
diff --git a/configure-aspen.py b/gratipay/main.py
similarity index 99%
rename from configure-aspen.py
rename to gratipay/main.py
--- a/configure-aspen.py
+++ b/gratipay/main.py
@@ -13,9 +13,12 @@
 from gratipay.utils import cache_static, i18n, set_cookie, timer
 from gratipay.version import get_version
 
-
 import aspen
 from aspen import log_dammit
+from aspen.website import Website
+
+
+website = Website([])
 
 
 # Monkey patch aspen.Response
@@ -169,10 +172,10 @@ def filter_profile_subnav(user, participant, pages):
                       , algorithm['raise_200_for_OPTIONS']
 
                       , canonize
+                      , i18n.set_up_i18n
                       , authentication.get_auth_from_request
                       , csrf.get_csrf_token_from_request
                       , add_stuff_to_context
-                      , i18n.set_up_i18n
 
                       , algorithm['dispatch_request_to_filesystem']
 


Test patch:
diff --git a/gratipay/testing/__init__.py b/gratipay/testing/__init__.py
--- a/gratipay/testing/__init__.py
+++ b/gratipay/testing/__init__.py
@@ -12,6 +12,7 @@
 from aspen.testing.client import Client
 from gratipay.billing.exchanges import record_exchange, record_exchange_result
 from gratipay.elsewhere import UserInfo
+from gratipay.main import website
 from gratipay.models.account_elsewhere import AccountElsewhere
 from gratipay.security.user import User, SESSION
 from gratipay.testing.vcr import use_cassette
@@ -29,7 +30,7 @@ class ClientWithAuth(Client):
 
     def __init__(self, *a, **kw):
         Client.__init__(self, *a, **kw)
-        Client.website = Client.hydrate_website(self)
+        Client.website = website
 
     def build_wsgi_environ(self, *a, **kw):
         """Extend base class to support authenticating as a certain user.
diff --git a/tests/py/test_hooks.py b/tests/py/test_hooks.py
--- a/tests/py/test_hooks.py
+++ b/tests/py/test_hooks.py
@@ -28,7 +28,6 @@ def tearDown(self):
         reset = Environment(CANONICAL_SCHEME=unicode, CANONICAL_HOST=unicode, environ=self.environ)
         wireup.canonical(reset)
 
-
     def test_canonize_canonizes(self):
         response = self.client.GxT( "/"
                                   , HTTP_HOST=b'gratipay.com'
@@ -37,7 +36,6 @@ def test_canonize_canonizes(self):
         assert response.code == 302
         assert response.headers['Location'] == b'https://gratipay.com/'
 
-
     def test_session_cookie_isnt_overwritten_by_canonizer(self):
         # https://github.com/gratipay/gratipay.com/issues/940
 
@@ -57,7 +55,6 @@ def test_session_cookie_isnt_overwritten_by_canonizer(self):
         # https://gratipay.com/ if they make a request for
         # http://gratipay.com/.
 
-
     def test_session_cookie_not_set_under_API_key_auth(self):
         alice = self.make_participant('alice', claimed_time='now')
         api_key = alice.recreate_api_key()
@@ -72,7 +69,6 @@ def test_session_cookie_not_set_under_API_key_auth(self):
         assert response.code == 200
         assert SESSION not in response.headers.cookie
 
-
     def test_early_failures_dont_break_everything(self):
         old_from_wsgi = Request.from_wsgi
         def broken_from_wsgi(*a, **kw):
@@ -82,3 +78,10 @@ def broken_from_wsgi(*a, **kw):
             assert self.client.GET("/", raise_immediately=False).code == 400
         finally:
             Request.from_wsgi = old_from_wsgi
+
+
+class Tests2(Harness):
+
+    def test_error_spt_works(self):
+        r = self.client.POST('/', csrf_token=False, raise_immediately=False)
+        assert r.code == 403