diff --git a/django/views/generic/dates.py b/django/views/generic/dates.py
index 5f5f959..f8a35ca 100644
a
|
b
|
def _get_next_prev_month(generic_view, naive_result, is_previous, use_first_day)
|
584 | 584 | result = result.replace(day=1) |
585 | 585 | |
586 | 586 | # Check against future dates. |
587 | | if result and (allow_future or result < datetime.date.today()): |
| 587 | if result and (allow_future or result <= datetime.date.today()): |
588 | 588 | return result |
589 | 589 | else: |
590 | 590 | return None |
diff --git a/tests/regressiontests/generic_views/dates.py b/tests/regressiontests/generic_views/dates.py
index 652f66b..f7168ca 100644
a
|
b
|
class DayArchiveViewTests(TestCase):
|
337 | 337 | res = self.client.get('/dates/books/%s/' % urlbit) |
338 | 338 | self.assertEqual(res.status_code, 404) |
339 | 339 | |
| 340 | # specific case for the day before current day (==yesterday) |
| 341 | today = datetime.date.today() |
| 342 | yesterday = today - datetime.timedelta(days=1) |
| 343 | urlbit2 = yesterday.strftime("%Y/%b/%d").lower() |
| 344 | b2 = Book.objects.create(name="Djangonauts: psychoanalisys of the insane", |
| 345 | pages=512, pubdate=yesterday) |
| 346 | b3 = Book.objects.create(name="Djangonauts: psychoanalisys of the insane", |
| 347 | pages=1024, pubdate=today) |
| 348 | res = self.client.get('/dates/books/%s/' % urlbit2) |
| 349 | self.assertEqual(res.context['next_day'], datetime.date.today()) |
| 350 | # remove those crazy books so that the tests below don't fail |
| 351 | b2.delete() |
| 352 | b3.delete() |
| 353 | |
340 | 354 | # allow_future = True, valid future month |
341 | 355 | res = self.client.get('/dates/books/%s/allow_future/' % urlbit) |
342 | 356 | self.assertEqual(res.status_code, 200) |
diff --git a/tests/regressiontests/views/tests/generic/date_based.py b/tests/regressiontests/views/tests/generic/date_based.py
index 96555e5..6b9a83a 100644
a
|
b
|
class MonthArchiveTest(TestCase):
|
130 | 130 | self.assertEqual(response.status_code, 200) |
131 | 131 | self.assertEqual(response.context['next_month'], None) |
132 | 132 | self.assertEqual(response.context['previous_month'], prev_month) |
133 | | |
| 133 | |
134 | 134 | def test_archive_month_date_list(self): |
135 | 135 | author = Author(name="John Smith") |
136 | 136 | author.save() |
… |
… |
class DayArchiveTests(TestCase):
|
169 | 169 | response = self.client.get('/date_based/archive_day/2004/1/21/') |
170 | 170 | self.assertEqual(response.status_code, 200) |
171 | 171 | self.assertEqual(response.context['object_list'][0], article) |
| 172 | |
| 173 | def test_yesterday_and_today(self): |
| 174 | """ |
| 175 | Ensure it works for the next day == today (#17192) |
| 176 | """ |
| 177 | author = Author.objects.create(name="John Smith") |
| 178 | today = date.today() |
| 179 | yesterday = today - timedelta(days=1) |
| 180 | article1 = Article.objects.create(title="example", author=author, |
| 181 | date_created=yesterday) |
| 182 | article2 = Article.objects.create(title="example", author=author, |
| 183 | date_created=today) |
| 184 | urlbit = yesterday.strftime("%Y/%m/%d").lower() |
| 185 | response = self.client.get('/date_based/archive_day/%s/' % urlbit) |
| 186 | self.assertEqual(response.context['next_day'], today) |