Skip to content

Commit

Permalink
Merge pull request #2570 from willkg/1167008-motidings
Browse files Browse the repository at this point in the history
[bug 1167008] Add missing motidings templates
  • Loading branch information
mythmon committed Jun 16, 2015
2 parents 7d41fdd + 9a6a7df commit dc7965e
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kitsune/motidings/templates/motidings/unsub.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1 class="title">{{ _('Are you sure you want to unsubscribe?') }}</h1>
{{ csrf() }}
<div class="submit-or-cancel">
<input type="submit" value="{{ _('Unsubscribe') }}" />
<a href="{{ url('home') }}"{# Discards l10n. Better ideas? #}>{{ _('Cancel') }}</a>
<a href="{{ url('home') }}">{{ _('Cancel') }}</a>
</div>
</form>
</article>
Expand Down
19 changes: 19 additions & 0 deletions kitsune/motidings/templates/motidings/unsubscribe_error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "base.html" %}
{% set title = _('Unsubscribe') %}
{% set crumbs = [(None, title)] %}

{% block content %}
<article class="main">
<h1>{{ _('Unsubscribe Error') }}</h1>

<p>
{% trans %}
We could not find your subscription. Either it has already been
cancelled, or there was a mistake in the unsubscribe link. Please make
sure the entire link from the email made it into the browser. If the last
part of the link wraps onto a second line in the email, try copying and
pasting the link into the browser.
{% endtrans %}
</p>
</article>
{% endblock %}
11 changes: 11 additions & 0 deletions kitsune/motidings/templates/motidings/unsubscribe_success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "base.html" %}
{% set title = _('Unsubscribe') %}
{% set crumbs = [(None, title)] %}

{% block content %}
<article class="main">
<h1>{{ _('Unsubscribed') }}</h1>

<p>{{ _('You have been unsubscribed.') }}</p>
</article>
{% endblock %}
12 changes: 12 additions & 0 deletions kitsune/motidings/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from factory import fuzzy
from factory.django import DjangoModelFactory
from tidings.models import Watch


class WatchFactory(DjangoModelFactory):
class Meta:
model = Watch

event_type = 'fooevent'
is_active = True
secret = fuzzy.FuzzyText(length=10)
42 changes: 42 additions & 0 deletions kitsune/motidings/tests/test_unsubscribe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from nose.tools import eq_

from kitsune.motidings.tests import WatchFactory
from kitsune.sumo.tests import TestCase
from kitsune.sumo.urlresolvers import reverse


class UnsubscribeTests(TestCase):
def test_view_get(self):
watch = WatchFactory()

url = reverse('tidings.unsubscribe', args=(watch.id,))
resp = self.client.get(url, follow=True)

eq_(resp.status_code, 200)
self.assertTemplateUsed('motidings/unsub.html')

def test_view_post_success(self):
watch = WatchFactory(secret='ou812')

url = reverse('tidings.unsubscribe', args=(watch.id,), locale='en-US')
resp = self.client.post(url + '?s={0}'.format(watch.secret))

eq_(resp.status_code, 200)
self.assertTemplateUsed('motidings/unsubscribe_success.html')

def test_view_post_error_wrong_doesnotexist(self):
url = reverse('tidings.unsubscribe', args=(42,), locale='en-US')
resp = self.client.post(url + '?s=applesandcinnamon')

eq_(resp.status_code, 200)
self.assertTemplateUsed('motidings/unsubscribe_error.html')

def test_view_post_error_wrong_secret(self):
watch = WatchFactory(
secret='ou812'
)
url = reverse('tidings.unsubscribe', args=(watch.id,), locale='en-US')
resp = self.client.post(url + '?s=applesandcinnamon')

eq_(resp.status_code, 200)
self.assertTemplateUsed('motidings/unsubscribe_error.html')

0 comments on commit dc7965e

Please sign in to comment.