← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~thumper/launchpad/recipe-owner into lp:launchpad/devel

 

Tim Penhey has proposed merging lp:~thumper/launchpad/recipe-owner into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #602386 Incorrect owner after recipe creation
  https://bugs.launchpad.net/bugs/602386

-- 
https://code.launchpad.net/~thumper/launchpad/recipe-owner/+merge/30740
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~thumper/launchpad/recipe-owner into lp:launchpad/devel.
=== modified file 'lib/lp/code/browser/sourcepackagerecipe.py'
--- lib/lp/code/browser/sourcepackagerecipe.py	2010-07-21 16:30:29 +0000
+++ lib/lp/code/browser/sourcepackagerecipe.py	2010-07-23 03:57:46 +0000
@@ -302,7 +302,7 @@
         try:
             source_package_recipe = getUtility(
                 ISourcePackageRecipeSource).new(
-                    self.user, self.user, data['name'], recipe,
+                    self.user, data['owner'], data['name'], recipe,
                     data['description'], data['distros'],
                     data['daily_build_archive'], data['build_daily'])
             Store.of(source_package_recipe).flush()

=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py	2010-07-21 21:16:54 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py	2010-07-23 03:57:46 +0000
@@ -129,6 +129,50 @@
         self.assertTextMatchesExpressionIgnoreWhitespace(
             pattern, main_text)
 
+    def test_create_new_recipe_team_owner(self):
+        # New recipes can be owned by teams that the user is a member of.
+        self.factory.makeTeam(
+            name='good-chefs', displayname='Good Chefs', members=[self.chef])
+        branch = self.makeBranch()
+        browser = self.getUserBrowser(canonical_url(branch), user=self.chef)
+        browser.getLink('Create packaging recipe').click()
+
+        # The options for the owner include the Good Chefs team.
+        options = browser.getControl('Owner').displayOptions
+        self.assertEquals(
+            ['Good Chefs (good-chefs)', 'Master Chef (chef)'],
+            sorted([str(option) for option in options]))
+
+        browser.getControl(name='field.name').value = 'daily'
+        browser.getControl('Description').value = 'Make some food!'
+        browser.getControl('Secret Squirrel').click()
+        browser.getControl('Build daily').click()
+        browser.getControl('Owner').displayValue = ['Good Chefs']
+        browser.getControl('Create Recipe').click()
+
+        pattern = """\
+            Good Chefs's daily recipe
+            .*
+
+            Description
+            Make some food!
+
+            Recipe information
+            Build schedule: Built daily
+            Owner: Good Chefs
+            Base branch: lp://dev/~chef/ratatouille/veggies
+            Debian version: 0\+\{revno\}
+            Daily build archive: Secret PPA
+            Distribution series: Secret Squirrel
+            .*
+
+            Recipe contents
+            # bzr-builder format 0.2 deb-version 0\+\{revno\}
+            lp://dev/~chef/ratatouille/veggies"""
+        main_text = extract_text(find_main_content(browser.contents))
+        self.assertTextMatchesExpressionIgnoreWhitespace(
+            pattern, main_text)
+
     def test_create_recipe_forbidden_instruction(self):
         # We don't allow the "run" instruction in our recipes.  Make sure this
         # is communicated to the user properly.

=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py	2010-07-21 14:41:26 +0000
+++ lib/lp/testing/factory.py	2010-07-23 03:57:46 +0000
@@ -534,7 +534,7 @@
 
     def makeTeam(self, owner=None, displayname=None, email=None, name=None,
                  subscription_policy=TeamSubscriptionPolicy.OPEN,
-                 visibility=None):
+                 visibility=None, members=None):
         """Create and return a new, arbitrary Team.
 
         :param owner: The person or person name to use as the team's owner.
@@ -550,6 +550,8 @@
         :param visibility: The team's visibility. If it's None, the default
             (public) will be used.
         :type visibility: `PersonVisibility`
+        :param members: People or teams to be added to the new team
+        :type members: An iterable of objects implementing IPerson
         :return: The new team
         :rtype: `ITeam`
         """
@@ -573,6 +575,10 @@
         if email is not None:
             team.setContactAddress(
                 getUtility(IEmailAddressSet).new(email, team))
+        if members is not None:
+            naked_team = removeSecurityProxy(team)
+            for member in members:
+                naked_team.addMember(member, owner)
         return team
 
     def makePoll(self, team, name, title, proposition):