Commit 679cee79 authored by Matt Wright's avatar Matt Wright
Browse files

Add default/global context processor. Fixes #306

parent 3d7b97ac
......@@ -350,6 +350,9 @@ class _SecurityState(object):
rv.update(fn())
return rv
def context_processor(self, fn):
self._add_ctx_processor(None, fn)
def forgot_password_context_processor(self, fn):
self._add_ctx_processor('forgot_password', fn)
......
......@@ -24,11 +24,16 @@ from utils import authenticate
send_confirmation_template='custom_security/send_confirmation.html',
register_user_template='custom_security/register_user.html')
def test_context_processors(client, app):
@app.security.context_processor
def default_ctx_processor():
return {'global': 'global'}
@app.security.forgot_password_context_processor
def forgot_password():
return {'foo': 'bar'}
response = client.get('/reset')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.login_context_processor
......@@ -36,6 +41,7 @@ def test_context_processors(client, app):
return {'foo': 'bar'}
response = client.get('/login')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.register_context_processor
......@@ -43,6 +49,7 @@ def test_context_processors(client, app):
return {'foo': 'bar'}
response = client.get('/register')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.reset_password_context_processor
......@@ -50,6 +57,7 @@ def test_context_processors(client, app):
return {'foo': 'bar'}
response = client.get('/reset')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.change_password_context_processor
......@@ -58,6 +66,7 @@ def test_context_processors(client, app):
authenticate(client)
response = client.get('/change')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.send_confirmation_context_processor
......@@ -65,6 +74,7 @@ def test_context_processors(client, app):
return {'foo': 'bar'}
response = client.get('/confirm')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.mail_context_processor
......@@ -75,6 +85,7 @@ def test_context_processors(client, app):
client.post('/reset', data=dict(email='matt@lp.com'))
email = outbox[0]
assert b'global' in email.html
assert 'bar' in email.html
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment