aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-05-25 17:33:25 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-05-25 17:33:25 +0100
commitc0e528b0826877dbd132e533c406dd0d5d09bb6e (patch)
treeb361c7ec5d1a28f09a63e609db079725f0e3e6b4
parentd447a019cfe5d1e523b98c7bd4b488d445615a3f (diff)
more useful explanatory comments
Diffstat (limited to '')
-rw-r--r--ctrack/users/tests/test_views.py2
-rw-r--r--ctrack/users/views.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py
index ca2d0c2..f8e7e78 100644
--- a/ctrack/users/tests/test_views.py
+++ b/ctrack/users/tests/test_views.py
@@ -67,7 +67,9 @@ def test_profile_view_contains_organisation_information(person):
# Django Advanced Testing Topics
request.user = user
+ # We pass 'username' rather than 'slug' here because we are setting 'slug_url_kwarg' in our CBV.
response = UserDetailView.as_view()(request, username=user.username)
+
assert response.status_code == 200
assert response.context_data["user"].username == "testy"
assert response.context_data["user"].is_stakeholder() is True
diff --git a/ctrack/users/views.py b/ctrack/users/views.py
index fcc0e84..ed29ea1 100644
--- a/ctrack/users/views.py
+++ b/ctrack/users/views.py
@@ -16,6 +16,8 @@ class UserDetailView(LoginRequiredMixin, DetailView):
# citizen to be used in a URL
slug_field = "username"
+ # the name of the URLConf keyword argument that contains the slug. By default, slug_url_kwarg is 'slug'.
+ # we have to pass 'username' as the argument when testing UserDetailView because of this.
slug_url_kwarg = "username"