Преглед изворни кода

Change the project icon when the project is mirrored from an external source

This will allow to easily find out if a project's primary location
is this pagure instance or elsewhere.

Fixes https://pagure.io/pagure/issue/4941

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Pierre-Yves Chibon пре 3 година
родитељ
комит
37b3937a39
2 измењених фајлова са 26 додато и 0 уклоњено
  1. 3 0
      pagure/templates/repo_master.html
  2. 23 0
      tests/test_pagure_flask_ui_repo_mirrored_from.py

+ 3 - 0
pagure/templates/repo_master.html

@@ -36,6 +36,9 @@
             <h3>
             {% if repo.is_fork -%}
             <i class="fa fa-code-fork text-muted"></i>
+            {% elif repo.mirrored_from -%}
+            <i class="fa fa-cloud-download text-muted" title="Mirrored from {{
+                repo.mirrored_from }}"></i>
             {%- else -%}
             <i class="fa {{projecticon()}} text-muted"></i>
             {%- endif -%}

+ 23 - 0
tests/test_pagure_flask_ui_repo_mirrored_from.py

@@ -53,6 +53,29 @@ class PagureUiRepoMirroredFromTests(tests.Modeltests):
         self.session.add(self.project)
         self.session.commit()
 
+    def test_custom_projecticon(self):
+        """ Ensure that the customized project icon is shown the main page of
+        the project.
+        """
+        output = self.app.get("/test")
+        output_text = output.get_data(as_text=True)
+        self.assertIn(
+            '<i class="fa fa-cloud-download text-muted" title="Mirrored from '
+            'https://example.com/foo/bar.git"></i>',
+            output_text,
+        )
+
+    def test_regular_projecticon(self):
+        """ Ensure that the customized project icon is shown the main page of
+        the project.
+        """
+        output = self.app.get("/test2")
+        output_text = output.get_data(as_text=True)
+        self.assertNotIn(
+            '<i class="fa fa-cloud-download text-muted" title="Mirrored from ',
+            output_text,
+        )
+
     def test_settings_shows(self):
         """ Ensure that the box to edit the mirrored from value shows up
         in the settings.