Merge lp:~thumper/launchpad/recipe-owner into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: 11226
Proposed branch: lp:~thumper/launchpad/recipe-owner
Merge into: lp:launchpad
Diff against target: 90 lines (+42/-2)
3 files modified
lib/lp/code/browser/sourcepackagerecipe.py (+1/-1)
lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+34/-0)
lib/lp/testing/factory.py (+7/-1)
To merge this branch: bzr merge lp:~thumper/launchpad/recipe-owner
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+30740@code.launchpad.net

Commit message

Use the specified owner of the recipe when creating the recipe in the view.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 04:51:45 +0000
@@ -302,7 +302,7 @@
302 try:302 try:
303 source_package_recipe = getUtility(303 source_package_recipe = getUtility(
304 ISourcePackageRecipeSource).new(304 ISourcePackageRecipeSource).new(
305 self.user, self.user, data['name'], recipe,305 self.user, data['owner'], data['name'], recipe,
306 data['description'], data['distros'],306 data['description'], data['distros'],
307 data['daily_build_archive'], data['build_daily'])307 data['daily_build_archive'], data['build_daily'])
308 Store.of(source_package_recipe).flush()308 Store.of(source_package_recipe).flush()
309309
=== 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 04:51:45 +0000
@@ -129,6 +129,40 @@
129 self.assertTextMatchesExpressionIgnoreWhitespace(129 self.assertTextMatchesExpressionIgnoreWhitespace(
130 pattern, main_text)130 pattern, main_text)
131131
132 def test_create_new_recipe_users_teams_as_owner_options(self):
133 # Teams that the user is in are options for the recipe owner.
134 self.factory.makeTeam(
135 name='good-chefs', displayname='Good Chefs', members=[self.chef])
136 branch = self.makeBranch()
137 browser = self.getUserBrowser(canonical_url(branch), user=self.chef)
138 browser.getLink('Create packaging recipe').click()
139
140 # The options for the owner include the Good Chefs team.
141 options = browser.getControl('Owner').displayOptions
142 self.assertEquals(
143 ['Good Chefs (good-chefs)', 'Master Chef (chef)'],
144 sorted([str(option) for option in options]))
145
146 def test_create_new_recipe_team_owner(self):
147 # New recipes can be owned by teams that the user is a member of.
148 team = self.factory.makeTeam(
149 name='good-chefs', displayname='Good Chefs', members=[self.chef])
150 branch = self.makeBranch()
151 browser = self.getUserBrowser(canonical_url(branch), user=self.chef)
152 browser.getLink('Create packaging recipe').click()
153
154 browser.getControl(name='field.name').value = 'daily'
155 browser.getControl('Description').value = 'Make some food!'
156 browser.getControl('Secret Squirrel').click()
157 browser.getControl('Build daily').click()
158 browser.getControl('Owner').displayValue = ['Good Chefs']
159 browser.getControl('Create Recipe').click()
160
161 login(ANONYMOUS)
162 recipe = team.getRecipe(u'daily')
163 self.assertEqual(team, recipe.owner)
164 self.assertEqual('daily', recipe.name)
165
132 def test_create_recipe_forbidden_instruction(self):166 def test_create_recipe_forbidden_instruction(self):
133 # We don't allow the "run" instruction in our recipes. Make sure this167 # We don't allow the "run" instruction in our recipes. Make sure this
134 # is communicated to the user properly.168 # is communicated to the user properly.
135169
=== 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 04:51:45 +0000
@@ -534,7 +534,7 @@
534534
535 def makeTeam(self, owner=None, displayname=None, email=None, name=None,535 def makeTeam(self, owner=None, displayname=None, email=None, name=None,
536 subscription_policy=TeamSubscriptionPolicy.OPEN,536 subscription_policy=TeamSubscriptionPolicy.OPEN,
537 visibility=None):537 visibility=None, members=None):
538 """Create and return a new, arbitrary Team.538 """Create and return a new, arbitrary Team.
539539
540 :param owner: The person or person name to use as the team's owner.540 :param owner: The person or person name to use as the team's owner.
@@ -550,6 +550,8 @@
550 :param visibility: The team's visibility. If it's None, the default550 :param visibility: The team's visibility. If it's None, the default
551 (public) will be used.551 (public) will be used.
552 :type visibility: `PersonVisibility`552 :type visibility: `PersonVisibility`
553 :param members: People or teams to be added to the new team
554 :type members: An iterable of objects implementing IPerson
553 :return: The new team555 :return: The new team
554 :rtype: `ITeam`556 :rtype: `ITeam`
555 """557 """
@@ -573,6 +575,10 @@
573 if email is not None:575 if email is not None:
574 team.setContactAddress(576 team.setContactAddress(
575 getUtility(IEmailAddressSet).new(email, team))577 getUtility(IEmailAddressSet).new(email, team))
578 if members is not None:
579 naked_team = removeSecurityProxy(team)
580 for member in members:
581 naked_team.addMember(member, owner)
576 return team582 return team
577583
578 def makePoll(self, team, name, title, proposition):584 def makePoll(self, team, name, title, proposition):