~launchpad-pqm/launchpad/devel

12510.5.9 by Aaron Bentley
Fix lint.
1
Changing bug assignment
2
=======================
5093.2.6 by Tom Berger
pagetests
3
3554.1.21 by Brad Bollenbach
fix assign to nobody on bugtask edit form
4
A bug is unassigned by choosing the "Assigned to" -> "Nobody" option.
5
5093.2.8 by Tom Berger
post-review changes
6
    >>> admin_browser.open("http://launchpad.dev/firefox/+bug/1")
3554.1.21 by Brad Bollenbach
fix assign to nobody on bugtask edit form
7
8
Bug 1 is currently assigned to someone.
9
5093.2.8 by Tom Berger
post-review changes
10
    >>> assignee_control = admin_browser.getControl(
3691.206.3 by Bjorn Tillenius
field -> new prefix in tests.
11
    ...     name="firefox.assignee.option", index=0)
12
    >>> assignee_control.value == ["firefox.assignee.assigned_to"]
3554.1.21 by Brad Bollenbach
fix assign to nobody on bugtask edit form
13
    True
14
15
But we can change it to be assigned to nobody.
16
3691.206.3 by Bjorn Tillenius
field -> new prefix in tests.
17
    >>> assignee_control.value = ["firefox.assignee.assign_to_nobody"]
3554.1.21 by Brad Bollenbach
fix assign to nobody on bugtask edit form
18
5093.2.8 by Tom Berger
post-review changes
19
    >>> admin_browser.getControl("Save Changes", index=0).click()
3554.1.21 by Brad Bollenbach
fix assign to nobody on bugtask edit form
20
12510.5.9 by Aaron Bentley
Fix lint.
21
    >>> admin_browser.getControl(
22
    ...     name="firefox.assignee.option", index=0).value
3691.206.3 by Bjorn Tillenius
field -> new prefix in tests.
23
    ['firefox.assignee.assign_to_nobody']
5093.2.6 by Tom Berger
pagetests
24
5093.2.8 by Tom Berger
post-review changes
25
12510.5.9 by Aaron Bentley
Fix lint.
26
Bug assignment to non-contributors
27
==================================
5093.2.6 by Tom Berger
pagetests
28
29
When attempting to assign a bug to a user who isn't an established bug
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
30
contributor (they have no bugs currently assigned to them) the user is
5282.1.3 by Tom Berger
post-review changes from barry.
31
warned immediately after the assignment, so that they can change their
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
32
choice if it was mistaken.
5093.2.6 by Tom Berger
pagetests
33
5093.2.8 by Tom Berger
post-review changes
34
    >>> admin_browser.open("http://launchpad.dev/firefox/+bug/1")
35
    >>> assignee_control = admin_browser.getControl(
5093.2.6 by Tom Berger
pagetests
36
    ...     name="firefox.assignee.option", index=0)
37
    >>> assignee_control.value = ["firefox.assignee.assign_to"]
5093.2.8 by Tom Berger
post-review changes
38
    >>> assign_to_control = admin_browser.getControl(
5093.2.6 by Tom Berger
pagetests
39
    ...     name="firefox.assignee", index=0)
40
    >>> assign_to_control.value = "cprov"
5093.2.8 by Tom Berger
post-review changes
41
    >>> admin_browser.getControl("Save Changes", index=0).click()
42
    >>> print extract_text(
5282.1.2 by Tom Berger
some review suggestions from BjornT and barry.
43
    ...     first_tag_by_class(admin_browser.contents, 'warning message'))
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
44
    Celso Providelo
5282.1.2 by Tom Berger
some review suggestions from BjornT and barry.
45
    did not previously have any assigned bugs in
46
    Mozilla Firefox.
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
47
    If this bug was assigned by mistake,
5282.1.2 by Tom Berger
some review suggestions from BjornT and barry.
48
    you may change the assignment.
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
49
50
If the new assignee does have bugs assigned, but not in the relevant pillar,
51
the user will be warned too.
52
53
    >>> admin_browser.open("http://bugs.launchpad.dev/jokosher/+bug/11")
54
    >>> assignee_control = admin_browser.getControl(
55
    ...     name="jokosher.assignee.option", index=0)
56
    >>> assignee_control.value = ["jokosher.assignee.assign_to"]
5093.2.8 by Tom Berger
post-review changes
57
    >>> assign_to_control = admin_browser.getControl(
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
58
    ...     name="jokosher.assignee", index=0)
59
    >>> assign_to_control.value = "cprov"
5093.2.8 by Tom Berger
post-review changes
60
    >>> admin_browser.getControl("Save Changes", index=0).click()
61
    >>> print extract_text(
5282.1.2 by Tom Berger
some review suggestions from BjornT and barry.
62
    ...     first_tag_by_class(admin_browser.contents, 'warning message'))
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
63
    Celso Providelo
64
    did not previously have any assigned bugs in
65
    Jokosher Audio Editor.
66
    If this bug was assigned by mistake,
5282.1.2 by Tom Berger
some review suggestions from BjornT and barry.
67
    you may change the assignment.
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
68
69
When assigning a bug to oneself, though, the warning message is suppreseed.
70
5282.1.3 by Tom Berger
post-review changes from barry.
71
    >>> from zope.component import getUtility
11692.6.2 by Curtis Hovey
Use deglober to fixing simple glob imports in doctests.
72
    >>> from lp.registry.interfaces.person import IPersonSet
14600.1.2 by Curtis Hovey
Updated callsites to import from lp.testing, where the code has been for years.
73
    >>> from lp.testing import login, logout
5282.1.3 by Tom Berger
post-review changes from barry.
74
75
    >>> login('no-priv@canonical.com')
76
    >>> no_priv = getUtility(IPersonSet).getByName('no-priv')
77
    >>> no_priv.isBugContributor(user=no_priv)
78
    False
79
80
    >>> logout()
81
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
82
    >>> user_browser.open("http://bugs.launchpad.dev/jokosher/+bug/11")
83
    >>> assignee_control = user_browser.getControl(
84
    ...     name="jokosher.assignee.option", index=0)
10788.5.2 by Abel Deuring
ordinary users can (un)assign a bug task only to hemselves and their teams
85
    >>> assignee_control.value = ["jokosher.assignee.assign_to_me"]
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
86
    >>> user_browser.getControl("Save Changes", index=0).click()
87
    >>> print user_browser.url
88
    http://bugs.launchpad.dev/jokosher/+bug/11
89
    >>> print first_tag_by_class(
5282.1.2 by Tom Berger
some review suggestions from BjornT and barry.
90
    ...     user_browser.contents, 'warning message')
5282.1.1 by Tom Berger
don't ask for confirmation, just display a notification.
91
    None
10788.5.2 by Abel Deuring
ordinary users can (un)assign a bug task only to hemselves and their teams
92
93
12510.5.9 by Aaron Bentley
Fix lint.
94
Bug task assignment by regular users
95
====================================
10788.5.2 by Abel Deuring
ordinary users can (un)assign a bug task only to hemselves and their teams
96
11435.6.14 by Deryck Hodge
Fix the conditions required for a page test.
97
Regular users can only set themselves and their teams as assignees if
98
there is a bug supervisor established for a project.
99
100
To demonstrate, let's first set a bug supervisor for the jokosher
101
project used in these tests.
102
103
    >>> login('foo.bar@canonical.com')
104
    >>> from lp.registry.interfaces.product import IProductSet
105
    >>> jokosher = getUtility(IProductSet).getByName('jokosher')
106
    >>> foobar = getUtility(IPersonSet).getByName('name16')
107
    >>> jokosher.setBugSupervisor(foobar, foobar)
108
10788.5.2 by Abel Deuring
ordinary users can (un)assign a bug task only to hemselves and their teams
109
To avoid any confusion, the option to assign somebody else is only
110
shown if the user has sufficient privileges to assign anybody or if
111
the user is a member of at least one team. no-priv is no a member of
112
any team and hence does no see the option to asign somebody else.
113
114
    >>> no_priv.teams_participated_in.count()
115
    0
14449.5.2 by Curtis Hovey
Merge interaction fixes from private team branch.
116
117
    >>> logout()
10788.5.2 by Abel Deuring
ordinary users can (un)assign a bug task only to hemselves and their teams
118
    >>> user_browser.open("http://bugs.launchpad.dev/jokosher/+bug/11")
119
    >>> assignee_control = user_browser.getControl(
120
    ...     name="jokosher.assignee.option", index=0)
121
    >>> assignee_control.value = ["jokosher.assignee.assign_to"]
122
    Traceback (most recent call last):
123
    ...
124
    ItemNotFoundError: insufficient items with name
125
    'jokosher.assignee.assign_to'
126
    >>> user_browser.getControl(name="jokosher.assignee", index=0)
127
    Traceback (most recent call last):
128
    ...
129
    LookupError: name 'jokosher.assignee'
130
131
Once no_priv is a member of a team, the option is shown.
132
133
    >>> login('no-priv@canonical.com')
134
    >>> no_privs_team_name = factory.makeTeam(owner=no_priv).name
135
    >>> logout()
136
    >>> user_browser.open("http://bugs.launchpad.dev/jokosher/+bug/11")
137
    >>> assignee_control = user_browser.getControl(
138
    ...     name="jokosher.assignee.option", index=0)
139
    >>> assignee_control.value = ["jokosher.assignee.assign_to"]
140
    >>> assign_to_control = user_browser.getControl(
141
    ...     name="jokosher.assignee", index=0)
142
    >>> assign_to_control.value = no_privs_team_name
143
    >>> user_browser.getControl("Save Changes", index=0).click()
144
    >>> print_errors(user_browser.contents)
145
12510.5.5 by Aaron Bentley
Fix typo
146
But if he tries to set other persons or teams, he gets an error message.
10788.5.2 by Abel Deuring
ordinary users can (un)assign a bug task only to hemselves and their teams
147
148
    >>> user_browser.open("http://bugs.launchpad.dev/jokosher/+bug/11")
149
    >>> assignee_control = user_browser.getControl(
150
    ...     name="jokosher.assignee.option", index=0)
151
    >>> assignee_control.value = ["jokosher.assignee.assign_to"]
152
    >>> assign_to_control = user_browser.getControl(
153
    ...     name="jokosher.assignee", index=0)
154
    >>> assign_to_control.value = "name12"
155
    >>> user_browser.getControl("Save Changes", index=0).click()
156
    >>> print_errors(user_browser.contents)
157
    There is 1 error in the data you entered. Please fix it and try again.
158
    (Find…)
159
    Constraint not satisfied