From 6a14c3542c5e2387b29f10e18988d6451e56ef22 Mon Sep 17 00:00:00 2001 From: namrataukirde Date: Mon, 26 Aug 2019 21:26:03 +0530 Subject: [PATCH 1/8] fix online-button --- app/templates/item/edit.hbs | 2 +- app/templates/offer/ios_notification.hbs | 2 +- app/templates/offer/submit.hbs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/templates/item/edit.hbs b/app/templates/item/edit.hbs index 0bcac69b..30d67869 100644 --- a/app/templates/item/edit.hbs +++ b/app/templates/item/edit.hbs @@ -21,7 +21,7 @@
- {{#online-button classNames="add_item_link button expand" disabledOverride=disabled disabled=isOfferReviewed offer=model.offer}}{{t "items.add_item.save"}}{{/online-button}} + {{#online-button classNames="add_item_link button expand" tagName="button" disabledOverride=disabled disabled=isOfferReviewed offer=model.offer}}{{t "items.add_item.save"}}{{/online-button}}
diff --git a/app/templates/offer/ios_notification.hbs b/app/templates/offer/ios_notification.hbs index 6ab50c9c..a40ee5ba 100644 --- a/app/templates/offer/ios_notification.hbs +++ b/app/templates/offer/ios_notification.hbs @@ -26,7 +26,7 @@ {{#link-to "offer.submit" classNames="button expand secondary"}}{{t "offer.notifications.no"}}{{/link-to}}
- {{#online-button action="sendPushNotification" classNames="button expand"}}{{t "offer.notifications.notify"}}{{/online-button}} + {{#online-button action="sendPushNotification" tagName="button" classNames="button expand"}}{{t "offer.notifications.notify"}}{{/online-button}}
diff --git a/app/templates/offer/submit.hbs b/app/templates/offer/submit.hbs index 87ac63c2..7809a263 100644 --- a/app/templates/offer/submit.hbs +++ b/app/templates/offer/submit.hbs @@ -23,7 +23,7 @@
- {{#online-button action="submitOffer" actionArgs=false classNames="button expand secondary"}}{{t "no"}}{{/online-button}} + {{#online-button action="submitOffer" tagName="button" actionArgs=false classNames="button expand secondary"}}{{t "no"}}{{/online-button}}
{{#online-button action="submitOffer" actionArgs=true classNames="button expand"}}{{t "yes"}}{{/online-button}} From 47c0796b26b03822151b2da1fe61b90f75d681e4 Mon Sep 17 00:00:00 2001 From: namrataukirde Date: Wed, 28 Aug 2019 15:31:50 +0530 Subject: [PATCH 2/8] fix nokogiri vulnerability --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a692010a..d5584408 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -148,7 +148,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2019.0331) mini_magick (4.9.5) - mini_portile2 (2.3.0) + mini_portile2 (2.4.0) minitest (5.11.3) molinillo (0.6.6) multi_json (1.13.1) @@ -161,8 +161,8 @@ GEM net-ssh (>= 2.6.5) net-ssh (5.0.2) netrc (0.11.0) - nokogiri (1.8.5) - mini_portile2 (~> 2.3.0) + nokogiri (1.10.4) + mini_portile2 (~> 2.4.0) os (1.0.1) plist (3.5.0) public_suffix (2.0.5) From 683ff1f926849b0f67afbf8fd446474195530840 Mon Sep 17 00:00:00 2001 From: Abhinav Garg Date: Thu, 5 Sep 2019 18:01:31 +0530 Subject: [PATCH 3/8] upgrade to latest shared --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index d924738b..f8bc7eed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10339,7 +10339,7 @@ sha@~2.0.1: "shared-goodcity@git://github.com/crossroads/shared.goodcity.git#master": version "0.0.0" - resolved "git://github.com/crossroads/shared.goodcity.git#28c2bb73b4513810b831199fc9f539e9a22145a2" + resolved "git://github.com/crossroads/shared.goodcity.git#7f12addb009406f15261293d3735c1d955313cb8" dependencies: cryptiles "^4.1.2" ember-cli-babel "^5.1.6" From d47230b88a41ccadb0c8cdec84a9986556ecbac0 Mon Sep 17 00:00:00 2001 From: Abhinav Garg Date: Tue, 10 Sep 2019 11:17:51 +0530 Subject: [PATCH 4/8] fix offers index route because we are not doing preload --- app/routes/offers/index.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/routes/offers/index.js b/app/routes/offers/index.js index 6c7cdc6e..8ab6d3bd 100644 --- a/app/routes/offers/index.js +++ b/app/routes/offers/index.js @@ -1,22 +1,23 @@ -import AuthorizeRoute from './../authorize'; +import AuthorizeRoute from "./../authorize"; export default AuthorizeRoute.extend({ - model() { - return this.store.peekAll('offer'); + return this.store.findAll("offer"); }, redirect(my_offers) { var route = this; - switch(my_offers.get('length')) { - case 0 : route.transitionTo('offers.new'); break; - case 1 : - if(my_offers.get('firstObject.state') === 'draft') { - var firstOffer = my_offers.get('firstObject'); - if(firstOffer.get('itemCount') === 0) { - route.transitionTo('offer', firstOffer); + switch (my_offers.get("length")) { + case 0: + route.transitionTo("offers.new"); + break; + case 1: + if (my_offers.get("firstObject.state") === "draft") { + var firstOffer = my_offers.get("firstObject"); + if (firstOffer.get("itemCount") === 0) { + route.transitionTo("offer", firstOffer); } else { - route.transitionTo('offer.offer_details', firstOffer); + route.transitionTo("offer.offer_details", firstOffer); } } } @@ -24,11 +25,10 @@ export default AuthorizeRoute.extend({ renderTemplate() { this.render(); // default template - this.render('appMenuList', { - into: 'offers/index', - outlet: 'appMenuList', - controller: 'application' + this.render("appMenuList", { + into: "offers/index", + outlet: "appMenuList", + controller: "application" }); } - }); From 458d62a568670ab4f80e336f6b19242ab189793c Mon Sep 17 00:00:00 2001 From: Abhinav Garg Date: Tue, 10 Sep 2019 11:56:46 +0530 Subject: [PATCH 5/8] fix failing tests --- app/templates/offer/submit.hbs | 2 +- tests/acceptance/create-offer-test.js | 61 +++++++++++++++++---------- tests/acceptance/login-test.js | 61 +++++++++++++++------------ tests/acceptance/offer-test.js | 49 ++++++++++++--------- 4 files changed, 103 insertions(+), 70 deletions(-) diff --git a/app/templates/offer/submit.hbs b/app/templates/offer/submit.hbs index 7809a263..eefe1253 100644 --- a/app/templates/offer/submit.hbs +++ b/app/templates/offer/submit.hbs @@ -26,7 +26,7 @@ {{#online-button action="submitOffer" tagName="button" actionArgs=false classNames="button expand secondary"}}{{t "no"}}{{/online-button}}
- {{#online-button action="submitOffer" actionArgs=true classNames="button expand"}}{{t "yes"}}{{/online-button}} + {{#online-button action="submitOffer" actionArgs=true classNames="button expand submit"}}{{t "yes"}}{{/online-button}}
diff --git a/tests/acceptance/create-offer-test.js b/tests/acceptance/create-offer-test.js index 51ff59ab..01dd373c 100644 --- a/tests/acceptance/create-offer-test.js +++ b/tests/acceptance/create-offer-test.js @@ -1,22 +1,23 @@ -import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import { make } from 'ember-data-factory-guy'; -import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper'; -import { module, test } from 'qunit'; +import Ember from "ember"; +import startApp from "../helpers/start-app"; +import { make } from "ember-data-factory-guy"; +import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; +import { module, test } from "qunit"; // import { mockFindAll } from 'ember-data-factory-guy'; - var App, container; -module('Create New Offer', { +module("Create New Offer", { beforeEach: function() { App = startApp({}, 2); container = App.__container__; TestHelper.setup(); }, afterEach: function() { - Em.run(function() { TestHelper.teardown(); }); - Ember.run(App, 'destroy'); + Em.run(function() { + TestHelper.teardown(); + }); + Ember.run(App, "destroy"); } }); @@ -29,13 +30,19 @@ test("should create new offer", function(assert) { andThen(function() { // test: created new offer and redirected to its show page. - assert.equal(currentURL(), '/offers/2'); + assert.equal(currentURL(), "/offers/3"); //test: item count zero - assert.equal($.trim(find('.tab-bar-section .title').text()), "Offer items (0)"); + assert.equal( + $.trim(find(".tab-bar-section .title").text()), + "Offer items (0)" + ); //test: no items message - assert.equal($.trim($('.no-items').text()), "You don't have any items in this offer yet. Please add your first item!"); + assert.equal( + $.trim($(".no-items").text()), + "You don't have any items in this offer yet. Please add your first item!" + ); }); }); @@ -43,29 +50,39 @@ test("should redirect to previous empty offer", function(assert) { assert.expect(4); var currentUserId = JSON.parse(window.localStorage.currentUserId); - var user = make("user", {id:currentUserId}); - make("offer_with_items", {id:1, createdBy:user}); // check offer with items is not returned - make("offer",{"id":5, createdBy:user}); - - container.lookup("service:messageBox").custom = (message, btn1Text, btn1Callback) => { + var user = make("user", { id: currentUserId }); + make("offer_with_items", { id: 1, createdBy: user }); // check offer with items is not returned + make("offer", { id: 5, createdBy: user }); + + container.lookup("service:messageBox").custom = ( + message, + btn1Text, + btn1Callback + ) => { btn1Callback(); }; visit("/offers"); andThen(function() { - assert.equal(currentURL(), '/offers'); + assert.equal(currentURL(), "/offers"); click("a:contains('Make a New Donation')"); - andThen(function(){ - assert.equal(currentURL(), '/offers/5'); + andThen(function() { + assert.equal(currentURL(), "/offers/5"); //test: item count zero - assert.equal($.trim(find('.tab-bar-section .title').text()), "Offer items (0)"); + assert.equal( + $.trim(find(".tab-bar-section .title").text()), + "Offer items (0)" + ); //test: no items message - assert.equal($.trim(find('.no-items').text()), "You don't have any items in this offer yet. Please add your first item!"); + assert.equal( + $.trim(find(".no-items").text()), + "You don't have any items in this offer yet. Please add your first item!" + ); }); }); }); diff --git a/tests/acceptance/login-test.js b/tests/acceptance/login-test.js index 117e02b3..0ba0c8d9 100644 --- a/tests/acceptance/login-test.js +++ b/tests/acceptance/login-test.js @@ -1,45 +1,48 @@ -import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import FactoryGuy from 'ember-data-factory-guy'; -import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper'; -import '../factories/user_profile'; -import { module, test } from 'qunit'; +import Ember from "ember"; +import startApp from "../helpers/start-app"; +import FactoryGuy from "ember-data-factory-guy"; +import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; +import "../factories/user_profile"; +import { module, test } from "qunit"; var App, hk_user, non_hk_user; -module('Acceptance: Login', { +module("Acceptance: Login", { beforeEach: function() { App = startApp(); TestHelper.setup(); - hk_user = FactoryGuy.make('with_hk_mobile'); - non_hk_user = FactoryGuy.make('with_non_hk_mobile'); + hk_user = FactoryGuy.make("with_hk_mobile"); + non_hk_user = FactoryGuy.make("with_non_hk_mobile"); App.__container__.lookup("controller:subscriptions").pusher = { - get: function() { return {}; }, + get: function() { + return {}; + }, wire: function() {} }; }, afterEach: function() { - Ember.run(function () { TestHelper.teardown(); }); - Ember.run(App, 'destroy'); + Ember.run(function() { + TestHelper.teardown(); + }); + Ember.run(App, "destroy"); } }); test("User able to enter mobile number and get the sms code", function(assert) { assert.expect(1); - visit("/login"); andThen(function() { var ele_logout = $("a:contains('Logout')"); - if(ele_logout.length > 0){ + if (ele_logout.length > 0) { click(ele_logout[0]); } }); andThen(function() { - fillIn('#mobile', hk_user.get("mobile")); - triggerEvent('#mobile', 'blur'); + fillIn("#mobile", hk_user.get("mobile")); + triggerEvent("#mobile", "blur"); click("#getsmscode"); }); @@ -55,24 +58,24 @@ test("User is able to enter sms code and confirm and redirected to offers", func visit("/authenticate"); andThen(function() { var ele_logout = $("a:contains('Logout')"); - if(ele_logout.length > 0){ + if (ele_logout.length > 0) { click(ele_logout[0]); } }); andThen(function() { - visit('/authenticate'); - fillIn('#pin', "1234"); - triggerEvent('#pin', 'blur'); + visit("/authenticate"); + fillIn("#pin", "1234"); + triggerEvent("#pin", "blur"); }); andThen(function() { - assert.equal(find('#pin').val().length, 4); + assert.equal(find("#pin").val().length, 4); window.localStorage.authToken = authToken; click("#submit_pin"); }); - andThen(function(){ + andThen(function() { assert.equal(currentURL(), "/offers"); }); }); @@ -90,25 +93,27 @@ test("Logout clears authToken", function(assert) { test("User is able to resend the sms code", function(assert) { assert.expect(1); - $.mockjax({url:"/api/v1/auth/send_pi*",responseText:{ - "otp_auth_key" : "/JqONEgEjrZefDV3ZIQsNA==" - }}); + $.mockjax({ + url: "/api/v1/auth/send_pi*", + responseText: { + otp_auth_key: "/JqONEgEjrZefDV3ZIQsNA==" + } + }); visit("/authenticate"); andThen(function() { var ele_logout = $("a:contains('Logout')"); - if(ele_logout.length > 0){ + if (ele_logout.length > 0) { click(ele_logout[0]); } }); andThen(function() { - visit('/authenticate'); + visit("/authenticate"); click("#resend-pin"); }); andThen(function() { assert.equal(window.localStorage.otpAuthKey, '"/JqONEgEjrZefDV3ZIQsNA=="'); }); - }); diff --git a/tests/acceptance/offer-test.js b/tests/acceptance/offer-test.js index 1f68275b..fa918eaa 100644 --- a/tests/acceptance/offer-test.js +++ b/tests/acceptance/offer-test.js @@ -1,42 +1,44 @@ -import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import FactoryGuy from 'ember-data-factory-guy'; -import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper'; +import Ember from "ember"; +import startApp from "../helpers/start-app"; +import FactoryGuy from "ember-data-factory-guy"; +import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; var App, store, offer, item1, item2, image; -module('Display Offer', { +module("Display Offer", { beforeEach: function() { App = startApp(); TestHelper.setup(); store = FactoryGuy.store; offer = FactoryGuy.make("offer"); - item1 = FactoryGuy.make("item", {offer:offer,state:"submitted"}); - item2 = FactoryGuy.make("item", {offer:offer,state:"submitted"}); - image = FactoryGuy.make("image", {item:item1,favourite:true}); + item1 = FactoryGuy.make("item", { offer: offer, state: "submitted" }); + item2 = FactoryGuy.make("item", { offer: offer, state: "submitted" }); + image = FactoryGuy.make("image", { item: item1, favourite: true }); }, afterEach: function() { - Em.run(function() { TestHelper.teardown(); }); - Ember.run(App, 'destroy'); + Em.run(function() { + TestHelper.teardown(); + }); + Ember.run(App, "destroy"); } }); test("Display offer details", function() { - visit('/offers/' + offer.id + "/offer_details"); + visit("/offers/" + offer.id + "/offer_details"); andThen(function() { // offer show page equal(currentURL(), "/offers/" + offer.id + "/offer_details"); - equal($.trim(find('.tab-bar-section .title').text()), "Offer Details"); + equal($.trim(find(".tab-bar-section .title").text()), "Offer Details"); // add-item & remove-item buttons and confirm offer link // equal(find("a:contains('Add Item')").length, 1); equal(find("a[href='/offers/" + offer.id + "/confirm']").length, 1); // list of all items - equal(find('.item-content li img.cl-item-image').length, 2); + equal(find(".item-content li img.cl-item-image").length, 2); // favourite image for 'item2': default image equal(find('img[src="assets/images/default_item.jpg"]').length, 1); @@ -46,12 +48,17 @@ test("Display offer details", function() { }); }); -test("Confirm and Submit Offer", function(){ +test("Confirm and Submit Offer", function() { visit("/offers/" + offer.id + "/offer_details"); - click("a[href='/offers/"+ offer.id +"/confirm']"); + click("a[href='/offers/" + offer.id + "/confirm']"); andThen(function() { - equal($('h1.title').text().toLowerCase(), "confirm"); + equal( + $("h1.title") + .text() + .toLowerCase(), + "confirm" + ); equal(currentURL(), "/offers/" + offer.id + "/confirm"); // confirm offer page has submit link @@ -60,11 +67,15 @@ test("Confirm and Submit Offer", function(){ click("a:contains('Next')"); andThen(function() { - equal($('h1.title').text().toLowerCase(), "sale of goods"); + equal( + $("h1.title") + .text() + .toLowerCase(), + "sale of goods" + ); equal(currentURL(), "/offers/" + offer.id + "/submit"); - - click("button:contains('Yes')"); + click(".button.submit"); andThen(function() { equal(currentURL(), "/offers/" + offer.id + "/offer_details"); From aa258d2c74195ec6b7e2b223a62366e5372380e9 Mon Sep 17 00:00:00 2001 From: Abhinav Garg Date: Tue, 10 Sep 2019 12:34:54 +0530 Subject: [PATCH 6/8] add check for peekAll --- app/routes/offers/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/routes/offers/index.js b/app/routes/offers/index.js index 8ab6d3bd..802178a7 100644 --- a/app/routes/offers/index.js +++ b/app/routes/offers/index.js @@ -2,6 +2,10 @@ import AuthorizeRoute from "./../authorize"; export default AuthorizeRoute.extend({ model() { + let cachedRecords = this.store.peekAll("offer"); + if (cachedRecords.get("length")) { + return Ember.RSVP.resolve(cachedRecords); + } return this.store.findAll("offer"); }, From 06b76e8a0ddcd5a837afd50b5ae0666bf11e0207 Mon Sep 17 00:00:00 2001 From: Abhinav Garg Date: Tue, 10 Sep 2019 12:45:19 +0530 Subject: [PATCH 7/8] remove ember rsvp --- app/routes/offers/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes/offers/index.js b/app/routes/offers/index.js index 802178a7..96d1be96 100644 --- a/app/routes/offers/index.js +++ b/app/routes/offers/index.js @@ -4,7 +4,7 @@ export default AuthorizeRoute.extend({ model() { let cachedRecords = this.store.peekAll("offer"); if (cachedRecords.get("length")) { - return Ember.RSVP.resolve(cachedRecords); + return cachedRecords; } return this.store.findAll("offer"); }, From e88f95257d3e52f63b602d601495138eb27a9e3e Mon Sep 17 00:00:00 2001 From: Abul Asar <37627094+abulsayyad123@users.noreply.github.com> Date: Thu, 12 Sep 2019 15:35:15 +0530 Subject: [PATCH 8/8] update app version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9104616f..94515534 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "goodcity", - "version": "0.16.9", + "version": "0.17.0", "description": "Small description for goodcity goes here", "license": "MIT", "author": "",