← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rockstar/launchpad/no-recipes-on-private-branches into lp:launchpad/devel

 

Paul Hummer has proposed merging lp:~rockstar/launchpad/no-recipes-on-private-branches into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #612567 Private branches should not have a link to create recipes
  https://bugs.launchpad.net/bugs/612567


This branch fixes bug #612567 - It doesn't show the "Create recipe" link on private branches.
-- 
https://code.launchpad.net/~rockstar/launchpad/no-recipes-on-private-branches/+merge/32799
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rockstar/launchpad/no-recipes-on-private-branches into lp:launchpad/devel.
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py	2010-08-04 04:07:21 +0000
+++ lib/lp/code/browser/branch.py	2010-08-16 19:23:43 +0000
@@ -319,7 +319,10 @@
             '+upgrade', 'Upgrade this branch', icon='edit', enabled=enabled)
 
     def create_recipe(self):
-        enabled = config.build_from_branch.enabled
+        if not self.context.private and config.build_from_branch.enabled:
+            enabled = True
+        else:
+            enabled = False
         text = 'Create packaging recipe'
         return Link('+new-recipe', text, enabled=enabled, icon='add')
 
@@ -564,8 +567,8 @@
     def show_merge_links(self):
         """Return whether or not merge proposal links should be shown.
 
-        Merge proposal links should not be shown if there is only one branch in
-        a non-final state.
+        Merge proposal links should not be shown if there is only one branch
+        in a non-final state.
         """
         if not self.context.target.supports_merge_proposals:
             return False

=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py	2010-08-09 17:14:10 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py	2010-08-16 19:23:43 +0000
@@ -136,6 +136,19 @@
         self.assertTextMatchesExpressionIgnoreWhitespace(
             pattern, main_text)
 
+    def test_create_new_recipe_private_branch(self):
+        # Recipes can't be created on private branches.
+        login(self.chef.preferredemail.email)
+        branch = self.factory.makeBranch(private=True, owner=self.chef)
+        branch_url = canonical_url(branch)
+        logout()
+
+        browser = self.getUserBrowser(branch_url, user=self.chef)
+        self.assertRaises(
+            LinkNotFoundError,
+            browser.getLink,
+            'Create packaging recipe')
+
     def test_create_new_recipe_users_teams_as_owner_options(self):
         # Teams that the user is in are options for the recipe owner.
         self.factory.makeTeam(