~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/browser/tests/test_bugtask.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-07-19 14:33:39 UTC
  • mfrom: (13402.4.8 bug-491886)
  • Revision ID: launchpad@pqm.canonical.com-20110719143339-vrh01jmceqce2ees
[r=lifeless][bug=491886] BugTask:+editstatus will no longer OOPS when
        a user can't set a status on a new bug target.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
__metaclass__ = type
5
5
 
 
6
import transaction
 
7
 
6
8
from datetime import datetime
7
9
 
8
10
from lazr.lifecycle.event import ObjectModifiedEvent
148
150
        [activity] = view.interesting_activity
149
151
        self.assertEqual("description", activity.whatchanged)
150
152
 
 
153
    def test_error_for_changing_target_with_invalid_status(self):
 
154
        # If a user moves a bug task with a restricted status (say,
 
155
        # Triaged) to a target where they do not have permission to set
 
156
        # that status, they will be unable to complete the retargeting
 
157
        # and will instead receive an error in the UI.
 
158
        person = self.factory.makePerson()
 
159
        product = self.factory.makeProduct(
 
160
            name='product1', owner=person, official_malone=True)
 
161
        with person_logged_in(person):
 
162
            product.setBugSupervisor(person, person)
 
163
        product_2 = self.factory.makeProduct(
 
164
            name='product2', official_malone=True)
 
165
        with person_logged_in(product_2.owner):
 
166
            product_2.setBugSupervisor(product_2.owner, product_2.owner)
 
167
        bug = self.factory.makeBug(
 
168
            product=product, owner=person)
 
169
        # We need to commit here, otherwise all the sample data we
 
170
        # created gets destroyed when the transaction is rolled back.
 
171
        transaction.commit()
 
172
        with person_logged_in(person):
 
173
            form_data = {
 
174
                '%s.product' % product.name: product_2.name,
 
175
                '%s.status' % product.name: BugTaskStatus.TRIAGED.title,
 
176
                '%s.actions.save' % product.name: 'Save Changes',
 
177
                }
 
178
            view = create_initialized_view(
 
179
                bug.default_bugtask, name=u'+editstatus',
 
180
                form=form_data)
 
181
            # The bugtask's target won't have changed, since an error
 
182
            # happend. The error will be listed in the view.
 
183
            self.assertEqual(1, len(view.errors))
 
184
            self.assertEqual(product, bug.default_bugtask.target)
 
185
 
151
186
 
152
187
class TestBugTasksAndNominationsView(TestCaseWithFactory):
153
188