Repository: plone/cookieplone-templates

Issue:
The `.mxdev_cache` folder is not in the gitignore in a backend addon
**Describe the bug**

When creating a backend addon, the `.mxdev_cache` folder is created, but it is not listed in the `.gitignore`.

**To Reproduce**

Steps to reproduce the behavior:

1. `uvx cookieplone`
2. Select the `Backend Add-on for Plone` template.
3. Standard answer for the remaining questions.
4. `cd collective.addon`
5. `make install`

**Expected behavior**

The `.mxdev_cache` folder must be in `.gitignore`.

**Software (please complete the following information):**

- OS: Ubuntu
- Browser chrome
- Plone Version: 6.1.3
- Volto Version 18

Discussion:

Fix (patch):
diff --git a/news/307.bugfix b/news/307.bugfix
new file mode 100644
index 00000000..9594fe23
--- /dev/null
+++ b/news/307.bugfix
@@ -0,0 +1,1 @@
+Add `.mxdev_cache` to .gitignore in backend addons. @wesleybl
diff --git a/templates/add-ons/backend/{{ cookiecutter.__folder_name }}/.gitignore b/templates/add-ons/backend/{{ cookiecutter.__folder_name }}/.gitignore
index a39c756d..3bb87bf3 100644
--- a/templates/add-ons/backend/{{ cookiecutter.__folder_name }}/.gitignore
+++ b/templates/add-ons/backend/{{ cookiecutter.__folder_name }}/.gitignore
@@ -34,6 +34,7 @@ var/
 # mxdev
 .installed.txt
 .lock
+/.mxdev_cache/
 /.make-sentinels/
 /*-mxdev.txt
 /instance/


Test changes:
diff --git a/tests/templates/add-ons/backend/conftest.py b/tests/templates/add-ons/backend/conftest.py
index 8e50d2b7..6b5d0ca3 100644
--- a/tests/templates/add-ons/backend/conftest.py
+++ b/tests/templates/add-ons/backend/conftest.py
@@ -57,6 +57,11 @@
 ]
 
 
+GITIGNORE_ENTRIES = [
+    "/.mxdev_cache/",
+]
+
+
 @pytest.fixture(scope="module")
 def template_folder() -> str:
     return "add-ons/backend"
@@ -145,3 +150,5 @@ def pytest_generate_tests(metafunc):
         metafunc.parametrize("pkg_file_path", PKG_SRC_FILES)
     if "pkg_file_path_headless" in metafunc.fixturenames:
         metafunc.parametrize("pkg_file_path_headless", PKG_SRC_FEATURE_HEADLESS)
+    if "gitignore_entry" in metafunc.fixturenames:
+        metafunc.parametrize("gitignore_entry", GITIGNORE_ENTRIES)
diff --git a/tests/templates/add-ons/backend/test_backend_cutter.py b/tests/templates/add-ons/backend/test_backend_cutter.py
index 52c3ff51..847a10e2 100644
--- a/tests/templates/add-ons/backend/test_backend_cutter.py
+++ b/tests/templates/add-ons/backend/test_backend_cutter.py
@@ -97,3 +97,12 @@ def test_pkg_src_files_generated_with_two_namespaces(
     path = src_path / pkg_file_path
     assert path.exists()
     assert path.is_file()
+
+
+def test_gitignore_entries(cutter_result, gitignore_entry: str):
+    """Check if .gitignore contains required entries."""
+    gitignore_path = cutter_result.project_path / ".gitignore"
+    assert gitignore_path.exists()
+    assert gitignore_path.is_file()
+    content = gitignore_path.read_text()
+    assert gitignore_entry in content