Merge lp:~diegosarmentero/ubuntu-sso-client/fix-double-navigation into lp:ubuntu-sso-client

Proposed by Diego Sarmentero
Status: Merged
Approved by: Natalia Bidart
Approved revision: 821
Merged at revision: 820
Proposed branch: lp:~diegosarmentero/ubuntu-sso-client/fix-double-navigation
Merge into: lp:ubuntu-sso-client
Diff against target: 69 lines (+25/-4)
2 files modified
ubuntu_sso/qt/controllers.py (+7/-3)
ubuntu_sso/qt/tests/test_controllers.py (+18/-1)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-sso-client/fix-double-navigation
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+83973@code.launchpad.net

Commit message

Fix double back navigation in SSO reset code page (LP: #862403).

Description of the change

Fix double back navigation in SSO reset code page (LP: #862403).

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1 nice!

review: Approve
819. By Diego Sarmentero

Adding one more test

820. By Diego Sarmentero

back navigation fixed

821. By Diego Sarmentero

Adding improves to tests.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/qt/controllers.py'
2--- ubuntu_sso/qt/controllers.py 2011-11-11 20:34:57 +0000
3+++ ubuntu_sso/qt/controllers.py 2011-12-01 12:19:27 +0000
4@@ -828,8 +828,12 @@
5 email = unicode(self.view.wizard().forgotten.ui.email_line_edit.text())
6 self.view.wizard().current_user.ui.email_edit.setText(email)
7 self.view.wizard().overlay.hide()
8- self.view.wizard().back()
9- self.view.wizard().back()
10+ current_user_id = self.view.wizard().current_user_page_id
11+ visited_pages = self.view.wizard().visitedPages()
12+ for index in reversed(visited_pages):
13+ if index == current_user_id:
14+ break
15+ self.view.wizard().back()
16
17 def on_password_change_error(self, app_name, error):
18 """Let the user know that there was an error."""
19@@ -844,7 +848,7 @@
20 email = unicode(self.view.wizard().forgotten.ui.email_line_edit.text())
21 code = unicode(self.view.ui.reset_code_line_edit.text())
22 password = unicode(self.view.ui.password_line_edit.text())
23- logger.info('Settig new password for %s and email %s with code %s',
24+ logger.info('Setting new password for %r and email %r with code %r',
25 app_name, email, code)
26 self.backend.set_new_password(app_name, email, code, password)
27
28
29=== modified file 'ubuntu_sso/qt/tests/test_controllers.py'
30--- ubuntu_sso/qt/tests/test_controllers.py 2011-11-11 20:34:57 +0000
31+++ ubuntu_sso/qt/tests/test_controllers.py 2011-12-01 12:19:27 +0000
32@@ -669,6 +669,7 @@
33 self.count_back = 0
34 self.hide_value = False
35 self.text_value = 'mail@mail.com'
36+ self.current_user_page_id = 4
37
38 def wizard(self):
39 """Fake wizard function for view."""
40@@ -690,6 +691,10 @@
41 def setText(self, text):
42 """Fake setText for QLineEdit."""
43 self.text_value = text
44+
45+ def visitedPages(self):
46+ """Return an int list of fake visited pages."""
47+ return [1, 4, 6, 8]
48 # pylint: enable=C0103
49
50
51@@ -2094,5 +2099,17 @@
52 """Test that on_password_changed execute the proper operation."""
53 self.controller.on_password_changed('app_name', '')
54 self.assertTrue(self.controller.view.hide_value)
55- self.assertEqual(self.controller.view.count_back, 2)
56+ times_visited = 2
57+ self.assertEqual(self.controller.view.count_back, times_visited)
58+ self.assertEqual(self.controller.view.text_value, 'mail@mail.com')
59+
60+ def test_on_password_changed_not_visited(self):
61+ """Test that on_password_changed execute the proper operation."""
62+ current_user_page_id = 20
63+ self.patch(self.controller.view, "current_user_page_id",
64+ current_user_page_id)
65+ self.controller.on_password_changed('app_name', '')
66+ self.assertTrue(self.controller.view.hide_value)
67+ times_visited = 4
68+ self.assertEqual(self.controller.view.count_back, times_visited)
69 self.assertEqual(self.controller.view.text_value, 'mail@mail.com')

Subscribers

People subscribed via source and target branches