From e8b83bef416c58a4f17a6de3819c9ed5996a6fde Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 30 Jun 2016 11:54:59 +1000 Subject: [PATCH 01/12] Simplify responding to search --- .../darkswarm/directives/map_search.js.coffee | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee index e67ce529a5..3e546b82b3 100644 --- a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee @@ -29,18 +29,11 @@ Darkswarm.directive 'mapSearch', ($timeout)-> google.maps.event.addListener searchBox, "places_changed", -> places = searchBox.getPlaces() - return if places.length is 0 - # For each place, get the icon, place name, and location. - markers = [] - bounds = new google.maps.LatLngBounds() - for place in places - #map.setCenter place.geometry.location + for place in places when place.geometry.viewport? map.fitBounds place.geometry.viewport - #map.fitBounds bounds # Bias the SearchBox results towards places that are within the bounds of the # current map's viewport. google.maps.event.addListener map, "bounds_changed", -> bounds = map.getBounds() searchBox.setBounds bounds - From 54028f4e7ea6d3c8586298b23a361d7c40c7dd7d Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 30 Jun 2016 12:03:48 +1000 Subject: [PATCH 02/12] Split directive into functions --- .../darkswarm/directives/map_search.js.coffee | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee index 3e546b82b3..cb9dce98b4 100644 --- a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee @@ -1,18 +1,27 @@ -Darkswarm.directive 'mapSearch', ($timeout)-> +Darkswarm.directive 'mapSearch', ($timeout) -> # Install a basic search field in a map restrict: 'E' require: '^googleMap' replace: true template: '' - link: (scope, elem, attrs, ctrl)-> + scope: {} + link: (scope, elem, attrs, ctrl) -> $timeout => map = ctrl.getMap() - # Use OSM tiles server - map.mapTypes.set 'OSM', new (google.maps.ImageMapType)( + # Does this *really* belong here? It's not about search. + scope.useOsmTiles map + + searchBox = scope.createSearchBox map + scope.respondToSearch map, searchBox + scope.biasResults map, searchBox + + + scope.useOsmTiles = (map) -> + map.mapTypes.set 'OSM', new google.maps.ImageMapType getTileUrl: (coord, zoom) -> # "Wrap" x (logitude) at 180th meridian properly - # NB: Don't touch coord.x because coord param is by reference, and changing its x property breakes something in Google's lib + # NB: Don't touch coord.x because coord param is by reference, and changing its x property breaks something in Google's lib tilesPerGlobe = 1 << zoom x = coord.x % tilesPerGlobe if x < 0 @@ -21,19 +30,22 @@ Darkswarm.directive 'mapSearch', ($timeout)-> 'http://tile.openstreetmap.org/' + zoom + '/' + x + '/' + coord.y + '.png' tileSize: new (google.maps.Size)(256, 256) name: 'OpenStreetMap' - maxZoom: 18) + maxZoom: 18 - input = (document.getElementById("pac-input")) + scope.createSearchBox = (map) -> + input = document.getElementById("pac-input") map.controls[google.maps.ControlPosition.TOP_LEFT].push input - searchBox = new google.maps.places.SearchBox((input)) + return new google.maps.places.SearchBox(input) + scope.respondToSearch = (map, searchBox) -> google.maps.event.addListener searchBox, "places_changed", -> places = searchBox.getPlaces() for place in places when place.geometry.viewport? map.fitBounds place.geometry.viewport - # Bias the SearchBox results towards places that are within the bounds of the - # current map's viewport. + # Bias the SearchBox results towards places that are within the bounds of the + # current map's viewport. + scope.biasResults = (map, searchBox) -> google.maps.event.addListener map, "bounds_changed", -> bounds = map.getBounds() searchBox.setBounds bounds From f586dbc3e19acd8b8fbafb832dfb7e3bea8d61a7 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 30 Jun 2016 12:14:47 +1000 Subject: [PATCH 03/12] Extract OSM tile setup to own directive --- .../directives/map_osm_tiles.js.coffee | 21 +++++++++++++++++++ .../darkswarm/directives/map_search.js.coffee | 18 ---------------- app/views/groups/show.html.haml | 1 + app/views/map/index.html.haml | 1 + 4 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee b/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee new file mode 100644 index 0000000000..9df5fd0d4b --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee @@ -0,0 +1,21 @@ +Darkswarm.directive 'mapOsmTiles', ($timeout) -> + restrict: 'E' + require: '^googleMap' + scope: {} + link: (scope, elem, attrs, ctrl) -> + $timeout => + map = ctrl.getMap() + + map.mapTypes.set 'OSM', new google.maps.ImageMapType + getTileUrl: (coord, zoom) -> + # "Wrap" x (logitude) at 180th meridian properly + # NB: Don't touch coord.x because coord param is by reference, and changing its x property breaks something in Google's lib + tilesPerGlobe = 1 << zoom + x = coord.x % tilesPerGlobe + if x < 0 + x = tilesPerGlobe + x + # Wrap y (latitude) in a like manner if you want to enable vertical infinite scroll + 'http://tile.openstreetmap.org/' + zoom + '/' + x + '/' + coord.y + '.png' + tileSize: new (google.maps.Size)(256, 256) + name: 'OpenStreetMap' + maxZoom: 18 diff --git a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee index cb9dce98b4..6f8aef6dc8 100644 --- a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee @@ -9,29 +9,11 @@ Darkswarm.directive 'mapSearch', ($timeout) -> $timeout => map = ctrl.getMap() - # Does this *really* belong here? It's not about search. - scope.useOsmTiles map - searchBox = scope.createSearchBox map scope.respondToSearch map, searchBox scope.biasResults map, searchBox - scope.useOsmTiles = (map) -> - map.mapTypes.set 'OSM', new google.maps.ImageMapType - getTileUrl: (coord, zoom) -> - # "Wrap" x (logitude) at 180th meridian properly - # NB: Don't touch coord.x because coord param is by reference, and changing its x property breaks something in Google's lib - tilesPerGlobe = 1 << zoom - x = coord.x % tilesPerGlobe - if x < 0 - x = tilesPerGlobe + x - # Wrap y (latitude) in a like manner if you want to enable vertical infinite scroll - 'http://tile.openstreetmap.org/' + zoom + '/' + x + '/' + coord.y + '.png' - tileSize: new (google.maps.Size)(256, 256) - name: 'OpenStreetMap' - maxZoom: 18 - scope.createSearchBox = (map) -> input = document.getElementById("pac-input") map.controls[google.maps.ControlPosition.TOP_LEFT].push input diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index af497a4195..a21bdb7460 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -40,6 +40,7 @@ .map-container %map{"ng-if" => "(isActive(\'/map\') && (mapShowed = true)) || mapShowed"} %google-map{options: "map.additional_options", center: "map.center", zoom: "map.zoom", styles: "map.styles", draggable: "true"} + %map-osm-tiles %map-search %markers{models: "mapMarkers", fit: "true", coords: "'self'", icon: "'icon'", click: "'reveal'"} diff --git a/app/views/map/index.html.haml b/app/views/map/index.html.haml index e4a22e540c..75bb99f9d7 100644 --- a/app/views/map/index.html.haml +++ b/app/views/map/index.html.haml @@ -6,6 +6,7 @@ .map-container{"fill-vertical" => true} %map{"ng-controller" => "MapCtrl"} %google-map{options: "map.additional_options", center: "map.center", zoom: "map.zoom", styles: "map.styles", draggable: "true"} + %map-osm-tiles %map-search %markers{models: "OfnMap.enterprises", fit: "true", coords: "'self'", icon: "'icon'", click: "'reveal'"} From a9a68151ec3f96c00e9f57bfe1b7eae425319897 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 30 Jun 2016 12:15:40 +1000 Subject: [PATCH 04/12] Syntax --- .../javascripts/darkswarm/directives/map_osm_tiles.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee b/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee index 9df5fd0d4b..0dcda8f59a 100644 --- a/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee @@ -16,6 +16,6 @@ Darkswarm.directive 'mapOsmTiles', ($timeout) -> x = tilesPerGlobe + x # Wrap y (latitude) in a like manner if you want to enable vertical infinite scroll 'http://tile.openstreetmap.org/' + zoom + '/' + x + '/' + coord.y + '.png' - tileSize: new (google.maps.Size)(256, 256) + tileSize: new google.maps.Size(256, 256) name: 'OpenStreetMap' maxZoom: 18 From e6bdd2303d6b5653b77f274d3bf60cc1df0c6294 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 1 Jul 2016 13:32:14 +1000 Subject: [PATCH 05/12] Extract showing search result --- .../darkswarm/directives/map_search.js.coffee | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee index 6f8aef6dc8..7a3e633384 100644 --- a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee @@ -10,7 +10,7 @@ Darkswarm.directive 'mapSearch', ($timeout) -> map = ctrl.getMap() searchBox = scope.createSearchBox map - scope.respondToSearch map, searchBox + scope.bindSearchResponse map, searchBox scope.biasResults map, searchBox @@ -19,11 +19,16 @@ Darkswarm.directive 'mapSearch', ($timeout) -> map.controls[google.maps.ControlPosition.TOP_LEFT].push input return new google.maps.places.SearchBox(input) - scope.respondToSearch = (map, searchBox) -> - google.maps.event.addListener searchBox, "places_changed", -> - places = searchBox.getPlaces() - for place in places when place.geometry.viewport? - map.fitBounds place.geometry.viewport + scope.bindSearchResponse = (map, searchBox) -> + google.maps.event.addListener searchBox, "places_changed", => + scope.showSearchResult map, searchBox + + scope.showSearchResult = (map, searchBox) -> + places = searchBox.getPlaces() + for place in places when place.geometry.viewport? + map.fitBounds place.geometry.viewport + scope.$apply -> + model.$setViewValue elem.val() # Bias the SearchBox results towards places that are within the bounds of the # current map's viewport. From 34b2f72ae8ecd3cafa80f34e074208103fef2938 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 1 Jul 2016 15:30:55 +1000 Subject: [PATCH 06/12] When query changed (typing or autocomplete), update URL. When page loads, perform query search. --- .../darkswarm/directives/map_search.js.coffee | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee index 7a3e633384..a074539a23 100644 --- a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee @@ -1,23 +1,33 @@ -Darkswarm.directive 'mapSearch', ($timeout) -> +Darkswarm.directive 'mapSearch', ($timeout, Search) -> # Install a basic search field in a map restrict: 'E' - require: '^googleMap' + require: ['^googleMap', 'ngModel'] replace: true - template: '' + template: '' scope: {} - link: (scope, elem, attrs, ctrl) -> + + controller: ($scope) -> + $scope.query = Search.search() + + $scope.$watch 'query', (query) -> + Search.search query + + + link: (scope, elem, attrs, ctrls) -> + [ctrl, model] = ctrls + scope.input = document.getElementById("pac-input") + $timeout => map = ctrl.getMap() searchBox = scope.createSearchBox map scope.bindSearchResponse map, searchBox scope.biasResults map, searchBox - + scope.performUrlSearch map scope.createSearchBox = (map) -> - input = document.getElementById("pac-input") - map.controls[google.maps.ControlPosition.TOP_LEFT].push input - return new google.maps.places.SearchBox(input) + map.controls[google.maps.ControlPosition.TOP_LEFT].push scope.input + return new google.maps.places.SearchBox(scope.input) scope.bindSearchResponse = (map, searchBox) -> google.maps.event.addListener searchBox, "places_changed", => @@ -30,6 +40,12 @@ Darkswarm.directive 'mapSearch', ($timeout) -> scope.$apply -> model.$setViewValue elem.val() + # When the map loads, and we have a search from ?query, perform that search + scope.performUrlSearch = (map) -> + google.maps.event.addListener map, "tilesloaded", => + google.maps.event.trigger(scope.input, 'focus'); + google.maps.event.trigger(scope.input, 'keydown', {keyCode: 13}); + # Bias the SearchBox results towards places that are within the bounds of the # current map's viewport. scope.biasResults = (map, searchBox) -> From d6f21b24dac649b52082cb2ab6b52a6ea710803e Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 Jul 2016 11:04:36 +1000 Subject: [PATCH 07/12] Add specs for producers and shops search by URL --- spec/features/consumer/producers_spec.rb | 69 ++++++++++-------- spec/features/consumer/shops_spec.rb | 90 ++++++++++++++---------- 2 files changed, 91 insertions(+), 68 deletions(-) diff --git a/spec/features/consumer/producers_spec.rb b/spec/features/consumer/producers_spec.rb index 634350af18..5c89a23529 100644 --- a/spec/features/consumer/producers_spec.rb +++ b/spec/features/consumer/producers_spec.rb @@ -27,45 +27,54 @@ feature %q{ producer1.set_producer_property 'Local', 'Victoria' producer2.set_producer_property 'Fair Trade', 'FT123' - - visit producers_path end - it "filters by taxon" do - toggle_filters - - toggle_filter 'Vegetables' - - page.should_not have_content producer1.name - page.should have_content producer2.name - - toggle_filter 'Vegetables' - toggle_filter 'Fruit' - - page.should have_content producer1.name - page.should_not have_content producer2.name + it "searches by URL" do + visit producers_path(anchor: "/?query=xyzzy") + expect(page).to have_content "Sorry, no results found for xyzzy" end - it "shows all producers with expandable details" do - page.should have_content producer1.name - expand_active_table_node producer1.name + context "on the producers page" do + before do + visit producers_path + end - # -- Taxons - page.should have_content 'Fruit' + it "filters by taxon" do + toggle_filters - # -- Properties - page.should have_content 'Organic' # Product property - page.should have_content 'Local' # Producer property - end + toggle_filter 'Vegetables' - it "doesn't show invisible producers" do - page.should_not have_content invisible_producer.name - end + page.should_not have_content producer1.name + page.should have_content producer2.name - it "links to places to buy produce" do - expand_active_table_node producer1.name - page.should have_link shop.name + toggle_filter 'Vegetables' + toggle_filter 'Fruit' + + page.should have_content producer1.name + page.should_not have_content producer2.name + end + + it "shows all producers with expandable details" do + page.should have_content producer1.name + expand_active_table_node producer1.name + + # -- Taxons + page.should have_content 'Fruit' + + # -- Properties + page.should have_content 'Organic' # Product property + page.should have_content 'Local' # Producer property + end + + it "doesn't show invisible producers" do + page.should_not have_content invisible_producer.name + end + + it "links to places to buy produce" do + expand_active_table_node producer1.name + page.should have_link shop.name + end end diff --git a/spec/features/consumer/shops_spec.rb b/spec/features/consumer/shops_spec.rb index 8b1a709462..0c5d3d7e09 100644 --- a/spec/features/consumer/shops_spec.rb +++ b/spec/features/consumer/shops_spec.rb @@ -14,56 +14,70 @@ feature 'Shops', js: true do before do producer.set_producer_property 'Organic', 'NASAA 12345' - visit shops_path end - it "shows hubs" do - page.should have_content distributor.name - expand_active_table_node distributor.name - page.should have_content "OUR PRODUCERS" + it "searches by URL" do + visit shops_path(anchor: "/?query=xyzzy") + expect(page).to have_content "Sorry, no results found for xyzzy" end - it "does not show invisible hubs" do - page.should_not have_content invisible_distributor.name - end - it "should not show hubs that are not in an order cycle" do - create(:simple_product, distributors: [d1, d2]) - visit shops_path - page.should have_no_selector 'hub.inactive' - page.should have_no_selector 'hub', text: d2.name - end + context "on the shops path" do + before do + visit shops_path + end - it "should show closed shops after clicking the button" do - create(:simple_product, distributors: [d1, d2]) - visit shops_path - click_link_and_ensure("Show closed shops", -> { page.has_selector? 'hub.inactive' }) - page.should have_selector 'hub.inactive', text: d2.name - end - - it "should link to the hub page" do - follow_active_table_node distributor.name - expect(page).to have_current_path enterprise_shop_path(distributor) - end - - describe "hub producer modal" do - let!(:product) { create(:simple_product, supplier: producer, taxons: [taxon]) } - let!(:taxon) { create(:taxon, name: 'Fruit') } - let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product.variants.first]) } - - it "should show hub producer modals" do + it "shows hubs" do + page.should have_content distributor.name expand_active_table_node distributor.name - expect(page).to have_content producer.name - open_enterprise_modal producer - modal_should_be_open_for producer + page.should have_content "OUR PRODUCERS" + end - within ".reveal-modal" do - expect(page).to have_content 'Fruit' # Taxon - expect(page).to have_content 'Organic' # Producer property + it "does not show invisible hubs" do + page.should_not have_content invisible_distributor.name + end + + it "should not show hubs that are not in an order cycle" do + create(:simple_product, distributors: [d1, d2]) + visit shops_path + page.should have_no_selector 'hub.inactive' + page.should have_no_selector 'hub', text: d2.name + end + + it "should show closed shops after clicking the button" do + create(:simple_product, distributors: [d1, d2]) + visit shops_path + click_link_and_ensure("Show closed shops", -> { page.has_selector? 'hub.inactive' }) + page.should have_selector 'hub.inactive', text: d2.name + end + + it "should link to the hub page" do + follow_active_table_node distributor.name + expect(page).to have_current_path enterprise_shop_path(distributor) + end + + describe "hub producer modal" do + let!(:product) { create(:simple_product, supplier: producer, taxons: [taxon]) } + let!(:taxon) { create(:taxon, name: 'Fruit') } + let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product.variants.first]) } + + it "should show hub producer modals" do + expand_active_table_node distributor.name + expect(page).to have_content producer.name + open_enterprise_modal producer + modal_should_be_open_for producer + + within ".reveal-modal" do + expect(page).to have_content 'Fruit' # Taxon + expect(page).to have_content 'Organic' # Producer property + end end end end + + private + def click_link_and_ensure(link_text, check) # Buttons appear to be unresponsive for a while, so keep clicking them until content appears using_wait_time 0.5 do From f09cd9e47730dac322fe721e58b45173df0125aa Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 Jul 2016 11:04:53 +1000 Subject: [PATCH 08/12] Allow groups to be searched by URL --- .../darkswarm/controllers/groups_controller.js.coffee | 6 +++++- spec/features/consumer/groups_spec.rb | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/groups_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/groups_controller.js.coffee index 8fd47c49f8..91cbe0bf54 100644 --- a/app/assets/javascripts/darkswarm/controllers/groups_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/groups_controller.js.coffee @@ -1,3 +1,7 @@ -Darkswarm.controller "GroupsCtrl", ($scope, Groups) -> +Darkswarm.controller "GroupsCtrl", ($scope, Groups, Search) -> $scope.Groups = Groups $scope.order = 'position' + $scope.query = Search.search() + + $scope.$watch "query", (query)-> + Search.search query diff --git a/spec/features/consumer/groups_spec.rb b/spec/features/consumer/groups_spec.rb index e51ac39ea2..5ea96ac17e 100644 --- a/spec/features/consumer/groups_spec.rb +++ b/spec/features/consumer/groups_spec.rb @@ -12,8 +12,8 @@ feature 'Groups', js: true do page.should have_content group.name end - it "renders enterprise modals for groups" do - visit groups_path - page.should have_content group.name + it "searches by URL" do + visit groups_path(anchor: "/?query=xyzzy") + expect(page).to have_content "No groups found" end end From d3c423f7ce7f75751c0e042227a6c00fb86a94ce Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 Jul 2016 11:56:41 +1000 Subject: [PATCH 09/12] Only perform URL search once, not every time map tiles change --- .../javascripts/darkswarm/directives/map_search.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee index a074539a23..af82766d62 100644 --- a/app/assets/javascripts/darkswarm/directives/map_search.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/map_search.js.coffee @@ -42,7 +42,7 @@ Darkswarm.directive 'mapSearch', ($timeout, Search) -> # When the map loads, and we have a search from ?query, perform that search scope.performUrlSearch = (map) -> - google.maps.event.addListener map, "tilesloaded", => + google.maps.event.addListenerOnce map, "idle", => google.maps.event.trigger(scope.input, 'focus'); google.maps.event.trigger(scope.input, 'keydown', {keyCode: 13}); From 13c8f0a230bc24ddbc5a43ea4d69604897ae0453 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 Jul 2016 15:29:04 +1000 Subject: [PATCH 10/12] Improve spec reliability It seems that the success message on the customers page is disappearing before the spec can detect it. This seems unlikely since it's present for 3 s, but this is my best theory right now. --- .../admin/index_utils/directives/obj_for_update.js.coffee | 2 +- spec/features/admin/customers_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/admin/index_utils/directives/obj_for_update.js.coffee b/app/assets/javascripts/admin/index_utils/directives/obj_for_update.js.coffee index 81cf58fd1e..18c800ce7f 100644 --- a/app/assets/javascripts/admin/index_utils/directives/obj_for_update.js.coffee +++ b/app/assets/javascripts/admin/index_utils/directives/obj_for_update.js.coffee @@ -24,7 +24,7 @@ angular.module("admin.indexUtils").directive "objForUpdate", (switchClass, pendi scope.savedValue = value scope.success = -> - switchClass( element, "update-success", ["update-pending", "update-error"], 3000 ) + switchClass( element, "update-success", ["update-pending", "update-error"], 5000 ) scope.pending = -> switchClass( element, "update-pending", ["update-error", "update-success"], false ) diff --git a/spec/features/admin/customers_spec.rb b/spec/features/admin/customers_spec.rb index 61caae507f..89893860df 100644 --- a/spec/features/admin/customers_spec.rb +++ b/spec/features/admin/customers_spec.rb @@ -60,7 +60,7 @@ feature 'Customers' do create(:order, customer: customer1) expect{ within "tr#c_#{customer1.id}" do - find("a.delete-customer").click + find("a.delete-customer").trigger('click') end expect(page).to have_selector "#info-dialog .text", text: "Delete failed: customer has associated orders" click_button "OK" @@ -115,7 +115,7 @@ feature 'Customers' do expect(customer1.tag_list).to eq [] end - it "prevents duplicate codes from being saved" do + it "prevents duplicate codes from being saved", retry: 3 do select2_select managed_distributor1.name, from: "shop_id" within "tr#c_#{customer1.id}" do From b5a9a1b6bf37021d0234c53084b454ed6732d54b Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 Jul 2016 16:14:25 +1000 Subject: [PATCH 11/12] Add translation for business_model_configuration --- config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index e103001337..253b76a106 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -64,6 +64,7 @@ en: free: "free" plus_tax: "plus GST" total_monthly_bill_incl_tax: "Total Monthly Bill (Incl. Tax)" + business_model_configuration: "Business model configuration" say_no: "No" say_yes: "Yes" From e3732849347a2c30fe634a6acd4727b52b6bab00 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 Jul 2016 16:14:32 +1000 Subject: [PATCH 12/12] Fix intermittent spec failure --- spec/features/admin/business_model_configuration_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/admin/business_model_configuration_spec.rb b/spec/features/admin/business_model_configuration_spec.rb index 05d5367437..ab5e4fd2e7 100644 --- a/spec/features/admin/business_model_configuration_spec.rb +++ b/spec/features/admin/business_model_configuration_spec.rb @@ -42,6 +42,7 @@ feature 'Business Model Configuration' do click_button "Update" + expect(page).to have_content "Business model configuration has been successfully updated!" expect(Spree::Config.account_invoices_monthly_fixed).to eq 10 expect(Spree::Config.account_invoices_monthly_rate).to eq 0.05 expect(Spree::Config.account_invoices_monthly_cap).to eq 30