Merge lp:~diegosarmentero/pay-ui/payment-methods into lp:pay-ui

Proposed by Diego Sarmentero
Status: Merged
Approved by: dobey
Approved revision: 22
Merged at revision: 19
Proposed branch: lp:~diegosarmentero/pay-ui/payment-methods
Merge into: lp:pay-ui
Prerequisite: lp:~diegosarmentero/pay-ui/recent-login-flow
Diff against target: 110 lines (+21/-5)
5 files modified
app/ui/CheckoutPage.qml (+2/-0)
backend/modules/payui/network.cpp (+2/-1)
backend/tests/mock_click_server.py (+3/-3)
backend/tests/test_network.cpp (+13/-0)
manifest.json (+1/-1)
To merge this branch: bzr merge lp:~diegosarmentero/pay-ui/payment-methods
Reviewer Review Type Date Requested Status
dobey (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+229236@code.launchpad.net

Commit message

- Update combo as requested by design
- Detect preferred payment method with backend (not only from choices)

To post a comment you must log in.
22. By Diego Sarmentero

adding test for preferred backend

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/ui/CheckoutPage.qml'
2--- app/ui/CheckoutPage.qml 2014-07-29 11:32:13 +0000
3+++ app/ui/CheckoutPage.qml 2014-08-01 14:23:26 +0000
4@@ -152,7 +152,9 @@
5 top: accountView.bottom
6 margins: units.gu(2)
7 }
8+ expanded: true
9 delegate: OptionSelectorDelegate {
10+ selected: modelData.preferred
11 Item {
12 anchors.fill: parent
13 Column {
14
15=== modified file 'backend/modules/payui/network.cpp'
16--- backend/modules/payui/network.cpp 2014-08-01 14:23:26 +0000
17+++ backend/modules/payui/network.cpp 2014-08-01 14:23:26 +0000
18@@ -134,13 +134,14 @@
19 QJsonObject object = array.at(i).toObject();
20 QString description = object.value("description").toString();
21 QString backend = object.value("id").toString();
22+ bool preferredBackend = object.value("preferred").toBool();
23 QJsonArray choices = object.value("choices").toArray();
24 for (int j = 0; j < choices.size(); j++) {
25 QJsonObject choice = choices.at(j).toObject();
26 QString name = choice.value("description").toString();
27 QString paymentId = choice.value("id").toString();
28 bool requiresInteracion = choice.value("requires_interaction").toBool();
29- bool preferred = choice.value("preferred").toBool();
30+ bool preferred = choice.value("preferred").toBool() && preferredBackend;
31 PayInfo* pay = new PayInfo();
32 pay->setPayData(name, description, paymentId, backend, requiresInteracion, preferred);
33 listPays.append(qVariantFromValue((QObject*)pay));
34
35=== modified file 'backend/tests/mock_click_server.py'
36--- backend/tests/mock_click_server.py 2014-07-29 12:29:10 +0000
37+++ backend/tests/mock_click_server.py 2014-08-01 14:23:26 +0000
38@@ -31,7 +31,7 @@
39 ],
40 "id": 532,
41 "requires_interaction": False,
42- "preferred": True,
43+ "preferred": False,
44 "description": "PayPal Preapproved Payment (exp. 2014-04-12)"
45 }
46 ]
47@@ -47,7 +47,7 @@
48 ],
49 "id": 1767,
50 "requires_interaction": False,
51- "preferred": True,
52+ "preferred": False,
53 "description": "**** **** **** 1111 (Visa, exp. 02/2015)"
54 },
55 {
56@@ -56,7 +56,7 @@
57 ],
58 "id": 1726,
59 "requires_interaction": False,
60- "preferred": False,
61+ "preferred": True,
62 "description": "**** **** **** 1111 (Visa, exp. 03/2015)"
63 }
64 ]
65
66=== modified file 'backend/tests/test_network.cpp'
67--- backend/tests/test_network.cpp 2014-07-29 17:47:11 +0000
68+++ backend/tests/test_network.cpp 2014-08-01 14:23:26 +0000
69@@ -29,8 +29,11 @@
70 #include <QTest>
71 #include <QTimer>
72 #include <QSignalSpy>
73+#include <QVariant>
74+#include <QVariantList>
75
76 #include <modules/payui/network.h>
77+#include <modules/payui/pay_info.h>
78
79 using namespace UbuntuPurchase;
80
81@@ -101,6 +104,16 @@
82 QTRY_COMPARE(spy.count(), 1);
83 QList<QVariant> arguments = spy.takeFirst();
84 QVERIFY(arguments.at(0).toList().count() == 3);
85+ QVariantList listPays = arguments.at(0).toList();
86+ for (int i = 0; i < listPays.count(); i++) {
87+ QVariant var = listPays.at(i);
88+ PayInfo* info = var.value<PayInfo*>();
89+ if (i == 2) {
90+ QVERIFY(info->preferred() == true);
91+ } else {
92+ QVERIFY(info->preferred() == false);
93+ }
94+ }
95 }
96
97 void TestNetwork::testNetworkGetPaymentTypesFail()
98
99=== modified file 'manifest.json'
100--- manifest.json 2014-08-01 14:23:26 +0000
101+++ manifest.json 2014-08-01 14:23:26 +0000
102@@ -11,6 +11,6 @@
103 "desktop": "payui.desktop"
104 }
105 },
106- "version": "0.3.7",
107+ "version": "0.3.8",
108 "maintainer": "Sarmentero Diego <diego.sarmentero@canonical.com>"
109 }
110\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: