diff --git a/ckanext/harvest/templates/source/edit.html b/ckanext/harvest/templates/source/edit.html
index c5a62bc..bf34bf4 100644
--- a/ckanext/harvest/templates/source/edit.html
+++ b/ckanext/harvest/templates/source/edit.html
@@ -4,6 +4,13 @@
{% block primary_content_inner %}
- {% block form %}{{ c.form | safe }}{% endblock %}
+ {% block form %}
+ {% if c.form %}
+ {# CKAN < 2.3 #}
+ {{ c.form | safe }}
+ {% else %}
+ {{- h.snippet(form_snippet, c=c, **form_vars) -}}
+ {% endif %}
+ {% endblock %}
{% endblock %}
diff --git a/ckanext/harvest/templates/source/new.html b/ckanext/harvest/templates/source/new.html
index f98e69c..f97ed67 100644
--- a/ckanext/harvest/templates/source/new.html
+++ b/ckanext/harvest/templates/source/new.html
@@ -13,7 +13,12 @@
{% block primary_content %}
- {% block form %}{{ c.form | safe }}{% endblock %}
+ {% if c.form %}
+ {# CKAN < 2.3 #}
+ {{ c.form | safe }}
+ {% else %}
+ {{- h.snippet(form_snippet, c=c, **form_vars) -}}
+ {% endif %}
{% endblock %}
diff --git a/ckanext/harvest/tests/test_controller.py b/ckanext/harvest/tests/test_controller.py
new file mode 100644
index 0000000..86fd4b3
--- /dev/null
+++ b/ckanext/harvest/tests/test_controller.py
@@ -0,0 +1,58 @@
+from ckan.lib.helpers import url_for
+
+try:
+ from ckan.tests import helpers, factories
+except ImportError:
+ from ckan.new_tests import helpers, factories
+
+from ckanext.harvest.tests import factories as harvest_factories
+
+try:
+ from ckan.tests.helpers import assert_in
+except ImportError:
+ # for ckan 2.2
+ try:
+ from nose.tools import assert_in
+ except ImportError:
+ # Python 2.6 doesn't have it
+ def assert_in(a, b, msg=None):
+ assert a in b, msg or '%r was not in %r' % (a, b)
+
+import ckanext.harvest.model as harvest_model
+
+
+class TestController(helpers.FunctionalTestBase):
+
+ @classmethod
+ def setup_class(cls):
+ super(TestController, cls).setup_class()
+ harvest_model.setup()
+ sysadmin = factories.Sysadmin()
+ cls.extra_environ = {'REMOTE_USER': sysadmin['name'].encode('ascii')}
+
+ @classmethod
+ def teardown_class(cls):
+ super(TestController, cls).teardown_class()
+ helpers.reset_db()
+
+ def test_new_form_is_rendered(self):
+
+ url = url_for('harvest_new')
+
+ app = self._get_test_app()
+
+ response = app.get(url, extra_environ=self.extra_environ)
+
+ assert_in('