Merge lp:~dobey/unity-scope-click/no-refundable-if-no-price into lp:unity-scope-click/touch-15-04

Proposed by dobey
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 329
Merged at revision: 329
Proposed branch: lp:~dobey/unity-scope-click/no-refundable-if-no-price
Merge into: lp:unity-scope-click/touch-15-04
Diff against target: 107 lines (+19/-15)
4 files modified
libclickscope/click/package.h (+2/-2)
libclickscope/click/preview.cpp (+9/-8)
libclickscope/click/preview.h (+2/-1)
libclickscope/tests/test_preview.cpp (+6/-4)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/no-refundable-if-no-price
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Paweł Stołowski (community) Approve
Review via email: mp+267045@code.launchpad.net

Commit message

Don't check refundability if price in details is 0 (or unspecified).
Initialize the price and rating to 0.0f in package details.

To post a comment you must log in.
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Looks good, +1

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

Only initialize rating in the package object, not details.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libclickscope/click/package.h'
--- libclickscope/click/package.h 2015-01-20 03:40:54 +0000
+++ libclickscope/click/package.h 2015-08-05 16:16:30 +0000
@@ -98,12 +98,12 @@
9898
99 std::string name; // formerly app_id99 std::string name; // formerly app_id
100 std::string title;100 std::string title;
101 double price;101 double price = 0.0f;
102 std::string icon_url;102 std::string icon_url;
103 std::string url;103 std::string url;
104 std::string version;104 std::string version;
105 std::string publisher;105 std::string publisher;
106 double rating;106 double rating = 0.0f;
107 void matches (std::string query, std::function<bool> callback);107 void matches (std::string query, std::function<bool> callback);
108 std::string content;108 std::string content;
109 std::map<std::string, double> prices;109 std::map<std::string, double> prices;
110110
=== modified file 'libclickscope/click/preview.cpp'
--- libclickscope/click/preview.cpp 2015-07-07 02:48:20 +0000
+++ libclickscope/click/preview.cpp 2015-08-05 16:16:30 +0000
@@ -796,7 +796,7 @@
796 getApplicationUri(manifest, [this, reply, manifest, app_name, &review, userid](const std::string& uri) {796 getApplicationUri(manifest, [this, reply, manifest, app_name, &review, userid](const std::string& uri) {
797 populateDetails([this, reply, uri, manifest, app_name](const PackageDetails &details){797 populateDetails([this, reply, uri, manifest, app_name](const PackageDetails &details){
798 store_department(details);798 store_department(details);
799 pushPackagePreviewWidgets(reply, details, createButtons(uri, manifest));799 pushPackagePreviewWidgets(reply, details, createButtons(uri, manifest, details));
800 },800 },
801 [this, reply, &review, manifest, userid](const ReviewList& reviewlist,801 [this, reply, &review, manifest, userid](const ReviewList& reviewlist,
802 click::Reviews::Error error) {802 click::Reviews::Error error) {
@@ -836,7 +836,8 @@
836}836}
837837
838scopes::PreviewWidgetList InstalledPreview::createButtons(const std::string& uri,838scopes::PreviewWidgetList InstalledPreview::createButtons(const std::string& uri,
839 const Manifest& manifest)839 const Manifest& manifest,
840 const PackageDetails& details)
840{841{
841 scopes::PreviewWidgetList widgets;842 scopes::PreviewWidgetList widgets;
842 scopes::PreviewWidget buttons("buttons", "actions");843 scopes::PreviewWidget buttons("buttons", "actions");
@@ -861,16 +862,16 @@
861 }862 }
862 if (manifest.removable)863 if (manifest.removable)
863 {864 {
864 if (!isRefundable()) {865 if (details.package.price > 0.00f && isRefundable()) {
866 builder.add_tuple({
867 {"id", scopes::Variant(click::Preview::Actions::CANCEL_PURCHASE_INSTALLED)},
868 {"label", scopes::Variant(_("Cancel Purchase"))}
869 });
870 } else {
865 builder.add_tuple({871 builder.add_tuple({
866 {"id", scopes::Variant(click::Preview::Actions::UNINSTALL_CLICK)},872 {"id", scopes::Variant(click::Preview::Actions::UNINSTALL_CLICK)},
867 {"label", scopes::Variant(_("Uninstall"))}873 {"label", scopes::Variant(_("Uninstall"))}
868 });874 });
869 } else {
870 builder.add_tuple({
871 {"id", scopes::Variant(click::Preview::Actions::CANCEL_PURCHASE_INSTALLED)},
872 {"label", scopes::Variant(_("Cancel Purchase"))}
873 });
874 }875 }
875 }876 }
876 if (!uri.empty() || manifest.removable) {877 if (!uri.empty() || manifest.removable) {
877878
=== modified file 'libclickscope/click/preview.h'
--- libclickscope/click/preview.h 2015-07-07 02:48:20 +0000
+++ libclickscope/click/preview.h 2015-08-05 16:16:30 +0000
@@ -225,7 +225,8 @@
225 void getApplicationUri(const Manifest& manifest, std::function<void(const std::string&)> callback);225 void getApplicationUri(const Manifest& manifest, std::function<void(const std::string&)> callback);
226 std::string get_consumer_key();226 std::string get_consumer_key();
227 scopes::PreviewWidgetList createButtons(const std::string& uri,227 scopes::PreviewWidgetList createButtons(const std::string& uri,
228 const click::Manifest& manifest);228 const click::Manifest& manifest,
229 const PackageDetails& details);
229private:230private:
230 scopes::ActionMetadata metadata;231 scopes::ActionMetadata metadata;
231};232};
232233
=== modified file 'libclickscope/tests/test_preview.cpp'
--- libclickscope/tests/test_preview.cpp 2015-07-07 02:48:20 +0000
+++ libclickscope/tests/test_preview.cpp 2015-08-05 16:16:30 +0000
@@ -493,18 +493,20 @@
493 .WillOnce(Return(true));493 .WillOnce(Return(true));
494 click::Manifest manifest;494 click::Manifest manifest;
495 manifest.removable = true;495 manifest.removable = true;
496 auto widgets = preview.createButtons("fake uri", manifest);496 click::PackageDetails details;
497 details.package.price = 0.99f;
498 auto widgets = preview.createButtons("fake uri", manifest, details);
497 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);499 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);
498 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "cancel_purchase_installed");500 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "cancel_purchase_installed");
499}501}
500502
501TEST_F(InstalledPreviewTest, testIsRefundableButtonNotShown) {503TEST_F(InstalledPreviewTest, testIsRefundableButtonNotShown) {
502 FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);504 FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);
503 EXPECT_CALL(preview, isRefundable()).Times(1)505 EXPECT_CALL(preview, isRefundable()).Times(0);
504 .WillOnce(Return(false));
505 click::Manifest manifest;506 click::Manifest manifest;
506 manifest.removable = true;507 manifest.removable = true;
507 auto widgets = preview.createButtons("fake uri", manifest);508 click::PackageDetails details;
509 auto widgets = preview.createButtons("fake uri", manifest, details);
508 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);510 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);
509 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "uninstall_click");511 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "uninstall_click");
510}512}

Subscribers

People subscribed via source and target branches

to all changes: