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
1=== modified file 'lib/lp/code/browser/sourcepackagerecipe.py'
2--- lib/lp/code/browser/sourcepackagerecipe.py 2010-07-21 16:30:29 +0000
3+++ lib/lp/code/browser/sourcepackagerecipe.py 2010-07-23 04:51:45 +0000
4@@ -302,7 +302,7 @@
5 try:
6 source_package_recipe = getUtility(
7 ISourcePackageRecipeSource).new(
8- self.user, self.user, data['name'], recipe,
9+ self.user, data['owner'], data['name'], recipe,
10 data['description'], data['distros'],
11 data['daily_build_archive'], data['build_daily'])
12 Store.of(source_package_recipe).flush()
13
14=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
15--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-07-21 21:16:54 +0000
16+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-07-23 04:51:45 +0000
17@@ -129,6 +129,40 @@
18 self.assertTextMatchesExpressionIgnoreWhitespace(
19 pattern, main_text)
20
21+ def test_create_new_recipe_users_teams_as_owner_options(self):
22+ # Teams that the user is in are options for the recipe owner.
23+ self.factory.makeTeam(
24+ name='good-chefs', displayname='Good Chefs', members=[self.chef])
25+ branch = self.makeBranch()
26+ browser = self.getUserBrowser(canonical_url(branch), user=self.chef)
27+ browser.getLink('Create packaging recipe').click()
28+
29+ # The options for the owner include the Good Chefs team.
30+ options = browser.getControl('Owner').displayOptions
31+ self.assertEquals(
32+ ['Good Chefs (good-chefs)', 'Master Chef (chef)'],
33+ sorted([str(option) for option in options]))
34+
35+ def test_create_new_recipe_team_owner(self):
36+ # New recipes can be owned by teams that the user is a member of.
37+ team = self.factory.makeTeam(
38+ name='good-chefs', displayname='Good Chefs', members=[self.chef])
39+ branch = self.makeBranch()
40+ browser = self.getUserBrowser(canonical_url(branch), user=self.chef)
41+ browser.getLink('Create packaging recipe').click()
42+
43+ browser.getControl(name='field.name').value = 'daily'
44+ browser.getControl('Description').value = 'Make some food!'
45+ browser.getControl('Secret Squirrel').click()
46+ browser.getControl('Build daily').click()
47+ browser.getControl('Owner').displayValue = ['Good Chefs']
48+ browser.getControl('Create Recipe').click()
49+
50+ login(ANONYMOUS)
51+ recipe = team.getRecipe(u'daily')
52+ self.assertEqual(team, recipe.owner)
53+ self.assertEqual('daily', recipe.name)
54+
55 def test_create_recipe_forbidden_instruction(self):
56 # We don't allow the "run" instruction in our recipes. Make sure this
57 # is communicated to the user properly.
58
59=== modified file 'lib/lp/testing/factory.py'
60--- lib/lp/testing/factory.py 2010-07-21 14:41:26 +0000
61+++ lib/lp/testing/factory.py 2010-07-23 04:51:45 +0000
62@@ -534,7 +534,7 @@
63
64 def makeTeam(self, owner=None, displayname=None, email=None, name=None,
65 subscription_policy=TeamSubscriptionPolicy.OPEN,
66- visibility=None):
67+ visibility=None, members=None):
68 """Create and return a new, arbitrary Team.
69
70 :param owner: The person or person name to use as the team's owner.
71@@ -550,6 +550,8 @@
72 :param visibility: The team's visibility. If it's None, the default
73 (public) will be used.
74 :type visibility: `PersonVisibility`
75+ :param members: People or teams to be added to the new team
76+ :type members: An iterable of objects implementing IPerson
77 :return: The new team
78 :rtype: `ITeam`
79 """
80@@ -573,6 +575,10 @@
81 if email is not None:
82 team.setContactAddress(
83 getUtility(IEmailAddressSet).new(email, team))
84+ if members is not None:
85+ naked_team = removeSecurityProxy(team)
86+ for member in members:
87+ naked_team.addMember(member, owner)
88 return team
89
90 def makePoll(self, team, name, title, proposition):