Skip to content

Commit

Permalink
Merge branch 'release/0.1.17' into live
Browse files Browse the repository at this point in the history
* release/0.1.17:
  bump documentation version
  Redirect anonymous users to login page for /profile/ (fixes #39)
  use StaticLiveServerTestCase for selenium tests
  update requirements
  • Loading branch information
jandd committed Nov 13, 2014
2 parents d88ab2a + bc6657a commit bd8f933
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
4 changes: 2 additions & 2 deletions coffeestats/caffeine/tests/test_views.py
Expand Up @@ -200,9 +200,9 @@ class ProfileViewsTest(CaffeineViewTest):
"""

def test_bad_request_for_anonymous(self):
def test_redirect_for_anonymous(self):
response = self.client.get('/profile/')
self.assertEqual(response.status_code, 400)
self.assertRedirects(response, '/auth/login/?next=/profile/')

def test_notfound_for_missing_user(self):
response = self.client.get('/profile/testuser/')
Expand Down
3 changes: 2 additions & 1 deletion coffeestats/caffeine/views.py
Expand Up @@ -209,7 +209,8 @@ def get(self, request, *args, **kwargs):
return HttpResponseRedirect(reverse('public', kwargs={
'username': request.GET['u']}))
if not request.user.is_authenticated():
return HttpResponseBadRequest(_('Invalid request!'))
return HttpResponseRedirect(
"%s?next=%s" % (settings.LOGIN_URL, request.path))
return super(ProfileView, self).get(request, *args, **kwargs)

def get_context_data(self, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions coffeestats/functional_tests/base.py
@@ -1,7 +1,7 @@
import re

from django.test import LiveServerTestCase
from django.core import mail
from django.contrib.staticfiles.testing import StaticLiveServerTestCase

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
Expand All @@ -15,7 +15,7 @@
re.IGNORECASE | re.MULTILINE)


class SeleniumTest(LiveServerTestCase):
class SeleniumTest(StaticLiveServerTestCase):

@classmethod
def setUpClass(cls):
Expand Down
19 changes: 19 additions & 0 deletions coffeestats/functional_tests/test_base_pages.py
Expand Up @@ -118,3 +118,22 @@ def test_overall_elements(self):
self.assertEqual(len(box.find_elements_by_tag_name('canvas')), 1)

self.check_page_footer()


class ProfilePageTest(BaseCoffeeStatsPageTestMixin, SeleniumTest):

def test_redirect_profile_for_anonymous(self):
self.selenium.get(self.server_url + '/profile/')

self.check_page_header()

# He finds out that he was redirected to a login page
self.assertRegexpMatches(self.selenium.current_url,
r'/auth/login/\?next=/profile/$')

# there is a navigation in the page header
header = self.selenium.find_element_by_id('header')
nav = header.find_element_by_tag_name('nav')
self.assertEquals("Login\nRegister", nav.text)

self.check_page_footer()
4 changes: 2 additions & 2 deletions docs/conf.py
Expand Up @@ -57,9 +57,9 @@
# built documents.
#
# The short X.Y version.
version = '0.1.16'
version = '0.1.17'
# The full version, including alpha/beta/rc tags.
release = '0.1.16'
release = '0.1.17'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 2 additions & 3 deletions requirements/base.txt
@@ -1,12 +1,11 @@
Django==1.7
Django==1.7.1
bpython==0.13.1
django-braces==1.4.0
django-model-utils==2.2
django-registration-redux==1.1
django-absolute==0.3
logutils==0.3.3
psycopg2==2.5.4
South==1.0
passlib==1.6.2
py-bcrypt==0.4
pytz==2014.7
pytz==2014.9
4 changes: 2 additions & 2 deletions requirements/local.txt
@@ -1,7 +1,7 @@
# Local development dependencies go here
-r base.txt
coverage==3.7.1
django-debug-toolbar==1.2.1
django-debug-toolbar==1.2.2
Sphinx==1.2.3
sphinxcontrib-httpdomain==1.3.0
selenium==2.43.0
selenium==2.44.0
2 changes: 1 addition & 1 deletion requirements/test.txt
@@ -1,4 +1,4 @@
# Test dependencies go here.
-r base.txt
coverage==3.7.1
selenium==2.43.0
selenium==2.44.0

0 comments on commit bd8f933

Please sign in to comment.