Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Map route issues #90

Merged
merged 4 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion assets/javascripts/discourse/components/map-component.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ export default MountWidget.extend({
this.scheduleSetup();
},

@observes("category", "geoLocation", "geoLocations.[]", "userList.[]")
@observes(
"topicList",
"category",
"geoLocation",
"geoLocations.[]",
"userList.[]"
)
refreshMap() {
this.queueRerender();
this.scheduleSetup();
Expand Down
3 changes: 2 additions & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-locations
# about: Tools for handling locations in Discourse
# version: 6.3.6
# version: 6.3.7
# authors: Angus McLeod, Robert Barrow
# contact_emails: development@pavilion.tech
# url: https://github.com/angusmcleod/discourse-locations
Expand Down Expand Up @@ -164,6 +164,7 @@ class Engine < ::Rails::Engine
get 'u/user-map' => 'users#index'
get 'users/user-map' => 'users#index'
get "c/*category_slug_path_with_id/l/map" => "list#category_default"
get "/map" => "list#latest"
end

load File.expand_path('../serializers/geo_location.rb', __FILE__)
Expand Down
56 changes: 56 additions & 0 deletions test/javascripts/acceptance/map-to-do.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import mapFixtures from "../fixtures/map-fixtures";
import altSiteFixtures from "../fixtures/alt-site-fixtures";
import { cloneJSON } from "discourse-common/lib/object";

// TODO This currently won't work because qunit does not currently see the L global variable for Leaflet. Rename file once resolved.

acceptance("Topic Map - Show Correct Population", function (needs) {
needs.user();
needs.settings({
location_enabled: true,
});
needs.site(cloneJSON(altSiteFixtures["site.json"]));
needs.pretender((server, helper) => {
const categoryMapResponse = cloneJSON(mapFixtures["/category_map.json"]);
server.get("/c/general/announcements/24/l/map.json", () =>
helper.response(categoryMapResponse)
);
const mapResponse = cloneJSON(mapFixtures["/map.json"]);
server.get("/map.json", () => helper.response(mapResponse));
});

test("Category map includes the right topics", async function (assert) {
await visit("c/general/announcements/24/l/map");

assert.ok(
exists(
'img.leaflet-marker-icon[title="Coolest thing you have seen today"]'
),
"Announcement Topic Location exists"
);

assert.false(
exists('img.leaflet-marker-icon[title="The Room Appreciation Topic"]'),
"Software and Operating Systems Topic Location does not exist"
);
});

test("General map shows topics from all Categories", async function (assert) {
await visit("/map");

assert.ok(
exists(
'img.leaflet-marker-icon[title="Coolest thing you have seen today"]'
),
"Announcement Topic Location exists"
);

assert.ok(
exists('img.leaflet-marker-icon[title="The Room Appreciation Topic"]'),
"Software and Operating Systems Topic Location does exist"
);
});
});