mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
DEV: apply new coding standards (#10592)
This commit is contained in:
@ -7,24 +7,24 @@ import Site from "discourse/models/site";
|
||||
import Session from "discourse/models/session";
|
||||
import { currentSettings } from "helpers/site-settings";
|
||||
|
||||
export default function(name, opts) {
|
||||
export default function (name, opts) {
|
||||
opts = opts || {};
|
||||
|
||||
if (opts.skip) {
|
||||
return;
|
||||
}
|
||||
|
||||
test(name, function(assert) {
|
||||
test(name, function (assert) {
|
||||
this.site = Site.current();
|
||||
this.session = Session.current();
|
||||
|
||||
this.registry.register("site-settings:main", currentSettings(), {
|
||||
instantiate: false
|
||||
instantiate: false,
|
||||
});
|
||||
this.registry.register("capabilities:main", EmberObject);
|
||||
this.registry.register("site:main", this.site, { instantiate: false });
|
||||
this.registry.register("session:main", this.session, {
|
||||
instantiate: false
|
||||
instantiate: false,
|
||||
});
|
||||
this.registry.injection("component", "siteSettings", "site-settings:main");
|
||||
this.registry.injection("component", "appEvents", "service:app-events");
|
||||
@ -40,7 +40,7 @@ export default function(name, opts) {
|
||||
const currentUser = User.create({ username: "eviltrout" });
|
||||
this.currentUser = currentUser;
|
||||
this.registry.register("current-user:main", this.currentUser, {
|
||||
instantiate: false
|
||||
instantiate: false,
|
||||
});
|
||||
this.registry.injection("component", "currentUser", "current-user:main");
|
||||
this.registry.register(
|
||||
|
@ -3,7 +3,7 @@ import User from "discourse/models/user";
|
||||
export function parsePostData(query) {
|
||||
const result = {};
|
||||
if (query) {
|
||||
query.split("&").forEach(function(part) {
|
||||
query.split("&").forEach(function (part) {
|
||||
const item = part.split("=");
|
||||
const firstSeg = decodeURIComponent(item[0]);
|
||||
const m = /^([^\[]+)\[(.+)\]/.exec(firstSeg);
|
||||
@ -42,7 +42,7 @@ export default new Pretender();
|
||||
|
||||
export function applyDefaultHandlers(pretender) {
|
||||
// Autoload any `*-pretender` files
|
||||
Object.keys(requirejs.entries).forEach(e => {
|
||||
Object.keys(requirejs.entries).forEach((e) => {
|
||||
let m = e.match(/^.*helpers\/([a-z-]+)\-pretender$/);
|
||||
if (m && m[1] !== "create") {
|
||||
let result = requirejs(e).default.call(pretender, helpers);
|
||||
@ -90,7 +90,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
tags: [
|
||||
{ id: "eviltrout", count: 1 },
|
||||
{ id: "planned", text: "planned", count: 7, pm_count: 0 },
|
||||
{ id: "private", text: "private", count: 0, pm_count: 7 }
|
||||
{ id: "private", text: "private", count: 0, pm_count: 7 },
|
||||
],
|
||||
extras: {
|
||||
tag_groups: [
|
||||
@ -99,28 +99,28 @@ export function applyDefaultHandlers(pretender) {
|
||||
name: "Ford Cars",
|
||||
tags: [
|
||||
{ id: "Escort", text: "Escort", count: 1, pm_count: 0 },
|
||||
{ id: "focus", text: "focus", count: 3, pm_count: 0 }
|
||||
]
|
||||
{ id: "focus", text: "focus", count: 3, pm_count: 0 },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: "Honda Cars",
|
||||
tags: [
|
||||
{ id: "civic", text: "civic", count: 4, pm_count: 0 },
|
||||
{ id: "accord", text: "accord", count: 2, pm_count: 0 }
|
||||
]
|
||||
{ id: "accord", text: "accord", count: 2, pm_count: 0 },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: "Makes",
|
||||
tags: [
|
||||
{ id: "ford", text: "ford", count: 5, pm_count: 0 },
|
||||
{ id: "honda", text: "honda", count: 6, pm_count: 0 }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{ id: "honda", text: "honda", count: 6, pm_count: 0 },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
@ -128,14 +128,14 @@ export function applyDefaultHandlers(pretender) {
|
||||
return response({ results: [{ text: "monkey", count: 1 }] });
|
||||
});
|
||||
|
||||
pretender.get(`/u/:username/emails.json`, request => {
|
||||
pretender.get(`/u/:username/emails.json`, (request) => {
|
||||
if (request.params.username === "regular2") {
|
||||
return response({
|
||||
email: "regular2@example.com",
|
||||
secondary_emails: [
|
||||
"regular2alt1@example.com",
|
||||
"regular2alt2@example.com"
|
||||
]
|
||||
"regular2alt2@example.com",
|
||||
],
|
||||
});
|
||||
}
|
||||
return response({ email: "eviltrout@example.com" });
|
||||
@ -167,18 +167,18 @@ export function applyDefaultHandlers(pretender) {
|
||||
read_restricted: false,
|
||||
parent_category_id: null,
|
||||
topic_count: 1,
|
||||
post_count: 1
|
||||
}
|
||||
]
|
||||
post_count: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
badges: [{ id: 444, count: 1 }],
|
||||
topics: [{ id: 1234, title: "cool title", slug: "cool-title" }]
|
||||
topics: [{ id: 1234, title: "cool title", slug: "cool-title" }],
|
||||
});
|
||||
});
|
||||
|
||||
pretender.get("/u/eviltrout/invited_count.json", () => {
|
||||
return response({
|
||||
counts: { pending: 1, redeemed: 0, total: 0 }
|
||||
counts: { pending: 1, redeemed: 0, total: 0 },
|
||||
});
|
||||
});
|
||||
|
||||
@ -194,7 +194,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
return response({
|
||||
pinned_in_category_count: 0,
|
||||
pinned_globally_count: 0,
|
||||
banner_count: 0
|
||||
banner_count: 0,
|
||||
});
|
||||
});
|
||||
|
||||
@ -209,34 +209,34 @@ export function applyDefaultHandlers(pretender) {
|
||||
pretender.put("/t/internationalization-localization/280/status", () => {
|
||||
return response({
|
||||
success: "OK",
|
||||
topic_status_update: null
|
||||
topic_status_update: null,
|
||||
});
|
||||
});
|
||||
|
||||
pretender.post("/clicks/track", success);
|
||||
|
||||
pretender.get("/search", request => {
|
||||
pretender.get("/search", (request) => {
|
||||
if (request.queryParams.q === "posts") {
|
||||
return response({
|
||||
posts: [
|
||||
{
|
||||
id: 1234
|
||||
}
|
||||
]
|
||||
id: 1234,
|
||||
},
|
||||
],
|
||||
});
|
||||
} else if (request.queryParams.q === "evil") {
|
||||
return response({
|
||||
posts: [
|
||||
{
|
||||
id: 1234
|
||||
}
|
||||
id: 1234,
|
||||
},
|
||||
],
|
||||
tags: [
|
||||
{
|
||||
id: 6,
|
||||
name: "eviltrout"
|
||||
}
|
||||
]
|
||||
name: "eviltrout",
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
return response({
|
||||
id: 280,
|
||||
slug: "internationalization-localization",
|
||||
url: "/t/internationalization-localization/280"
|
||||
url: "/t/internationalization-localization/280",
|
||||
});
|
||||
});
|
||||
|
||||
@ -277,7 +277,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
pretender.get("/permalink-check.json", () => {
|
||||
return response({
|
||||
found: false,
|
||||
html: "<div class='page-not-found'>not found</div>"
|
||||
html: "<div class='page-not-found'>not found</div>",
|
||||
});
|
||||
});
|
||||
|
||||
@ -293,9 +293,9 @@ export function applyDefaultHandlers(pretender) {
|
||||
id: 1,
|
||||
username: "eviltrout",
|
||||
avatar_template: "/user_avatar/default/eviltrout/{size}/1.png",
|
||||
username_lower: "eviltrout"
|
||||
}
|
||||
]
|
||||
username_lower: "eviltrout",
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
@ -311,7 +311,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
response(fixturesByUrl["/categories_and_latest.json"])
|
||||
);
|
||||
|
||||
pretender.put("/categories/:category_id", request => {
|
||||
pretender.put("/categories/:category_id", (request) => {
|
||||
const category = parsePostData(request.requestBody);
|
||||
category.id = parseInt(request.params.category_id, 10);
|
||||
|
||||
@ -322,14 +322,14 @@ export function applyDefaultHandlers(pretender) {
|
||||
return response({ category });
|
||||
});
|
||||
|
||||
pretender.get("/draft.json", request => {
|
||||
pretender.get("/draft.json", (request) => {
|
||||
if (request.queryParams.draft_key === "new_topic") {
|
||||
return response(fixturesByUrl["/draft.json"]);
|
||||
} else if (request.queryParams.draft_key.startsWith("topic_"))
|
||||
return response(
|
||||
fixturesByUrl[request.url] || {
|
||||
draft: null,
|
||||
draft_sequence: 0
|
||||
draft_sequence: 0,
|
||||
}
|
||||
);
|
||||
return response({});
|
||||
@ -337,17 +337,17 @@ export function applyDefaultHandlers(pretender) {
|
||||
|
||||
pretender.get("/drafts.json", () => response(fixturesByUrl["/drafts.json"]));
|
||||
|
||||
pretender.put("/queued_posts/:queued_post_id", function(request) {
|
||||
pretender.put("/queued_posts/:queued_post_id", function (request) {
|
||||
return response({ queued_post: { id: request.params.queued_post_id } });
|
||||
});
|
||||
|
||||
pretender.get("/queued_posts", function() {
|
||||
pretender.get("/queued_posts", function () {
|
||||
return response({
|
||||
queued_posts: [{ id: 1, raw: "queued post text", can_delete_user: true }]
|
||||
queued_posts: [{ id: 1, raw: "queued post text", can_delete_user: true }],
|
||||
});
|
||||
});
|
||||
|
||||
pretender.post("/session", function(request) {
|
||||
pretender.post("/session", function (request) {
|
||||
const data = parsePostData(request.requestBody);
|
||||
|
||||
if (data.password === "correct") {
|
||||
@ -359,7 +359,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
error: "not active",
|
||||
reason: "not_activated",
|
||||
sent_to_email: "<small>eviltrout@example.com</small>",
|
||||
current_email: "<small>current@example.com</small>"
|
||||
current_email: "<small>current@example.com</small>",
|
||||
});
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
error: "not active",
|
||||
reason: "not_activated",
|
||||
sent_to_email: "eviltrout@example.com",
|
||||
current_email: "current@example.com"
|
||||
current_email: "current@example.com",
|
||||
});
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
backup_enabled: true,
|
||||
security_key_enabled: false,
|
||||
totp_enabled: true,
|
||||
multiple_second_factor_methods: false
|
||||
multiple_second_factor_methods: false,
|
||||
});
|
||||
}
|
||||
|
||||
@ -405,7 +405,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
totp_enabled: false,
|
||||
multiple_second_factor_methods: false,
|
||||
allowed_credential_ids: ["allowed_credential_ids"],
|
||||
challenge: "challenge"
|
||||
challenge: "challenge",
|
||||
});
|
||||
}
|
||||
|
||||
@ -415,14 +415,14 @@ export function applyDefaultHandlers(pretender) {
|
||||
pretender.post("/u/action/send_activation_email", success);
|
||||
pretender.put("/u/update-activation-email", success);
|
||||
|
||||
pretender.get("/u/hp.json", function() {
|
||||
pretender.get("/u/hp.json", function () {
|
||||
return response({
|
||||
value: "32faff1b1ef1ac3",
|
||||
challenge: "61a3de0ccf086fb9604b76e884d75801"
|
||||
challenge: "61a3de0ccf086fb9604b76e884d75801",
|
||||
});
|
||||
});
|
||||
|
||||
pretender.get("/session/csrf", function() {
|
||||
pretender.get("/session/csrf", function () {
|
||||
return response({ csrf: "mgk906YLagHo2gOgM1ddYjAN4hQolBdJCqlY6jYzAYs=" });
|
||||
});
|
||||
|
||||
@ -430,7 +430,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
return response({ available: true });
|
||||
});
|
||||
|
||||
pretender.get("/u/check_username", function(request) {
|
||||
pretender.get("/u/check_username", function (request) {
|
||||
if (request.queryParams.username === "taken") {
|
||||
return response({ available: false, suggestion: "nottaken" });
|
||||
}
|
||||
@ -445,13 +445,13 @@ export function applyDefaultHandlers(pretender) {
|
||||
pretender.put("/posts/:post_id/recover", success);
|
||||
pretender.get("/posts/:post_id/expand-embed", success);
|
||||
|
||||
pretender.put("/posts/:post_id", request => {
|
||||
pretender.put("/posts/:post_id", (request) => {
|
||||
const data = parsePostData(request.requestBody);
|
||||
if (data.post.raw === "this will 409") {
|
||||
return [
|
||||
409,
|
||||
{ "Content-Type": "application/json" },
|
||||
{ errors: ["edit conflict"] }
|
||||
{ errors: ["edit conflict"] },
|
||||
];
|
||||
}
|
||||
data.post.id = request.params.post_id;
|
||||
@ -463,7 +463,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
pretender.get("/t/404.json", () => response(404, "not found"));
|
||||
pretender.get("/t/500.json", () => response(502, {}));
|
||||
|
||||
pretender.put("/t/:slug/:id", request => {
|
||||
pretender.put("/t/:slug/:id", (request) => {
|
||||
const isJSON = request.requestHeaders["Content-Type"].includes(
|
||||
"application/json"
|
||||
);
|
||||
@ -477,8 +477,8 @@ export function applyDefaultHandlers(pretender) {
|
||||
id: request.params.id,
|
||||
title: data.title,
|
||||
fancy_title: data.title,
|
||||
slug: request.params.slug
|
||||
}
|
||||
slug: request.params.slug,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@ -510,25 +510,25 @@ export function applyDefaultHandlers(pretender) {
|
||||
return response(200, fixturesByUrl["/groups/discourse/members.json"]);
|
||||
});
|
||||
|
||||
pretender.get("/t/:topic_id/posts.json", request => {
|
||||
pretender.get("/t/:topic_id/posts.json", (request) => {
|
||||
const postIds = request.queryParams.post_ids;
|
||||
const postNumber = parseInt(request.queryParams.post_number, 10);
|
||||
let posts;
|
||||
|
||||
if (postIds) {
|
||||
posts = postIds.map(p => ({
|
||||
posts = postIds.map((p) => ({
|
||||
id: parseInt(p, 10),
|
||||
post_number: parseInt(p, 10)
|
||||
post_number: parseInt(p, 10),
|
||||
}));
|
||||
} else if (postNumber && request.queryParams.asc === "true") {
|
||||
posts = [...Array(5).keys()].map(p => ({
|
||||
posts = [...Array(5).keys()].map((p) => ({
|
||||
id: p + postNumber + 1,
|
||||
post_number: p + postNumber + 1
|
||||
post_number: p + postNumber + 1,
|
||||
}));
|
||||
} else if (postNumber && request.queryParams.asc === "false") {
|
||||
posts = [...Array(5).keys()].map(p => ({
|
||||
posts = [...Array(5).keys()].map((p) => ({
|
||||
id: postNumber - p - 1,
|
||||
post_number: postNumber - p - 1
|
||||
post_number: postNumber - p - 1,
|
||||
}));
|
||||
}
|
||||
|
||||
@ -542,7 +542,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
pretender.get("/posts/:post_id/reply-ids.json", () => {
|
||||
return response(200, {
|
||||
direct_reply_ids: [45],
|
||||
all_reply_ids: [45, 100]
|
||||
all_reply_ids: [45, 100],
|
||||
});
|
||||
});
|
||||
|
||||
@ -551,7 +551,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
);
|
||||
pretender.delete("/user_badges/:badge_id", success);
|
||||
|
||||
pretender.post("/posts", function(request) {
|
||||
pretender.post("/posts", function (request) {
|
||||
const data = parsePostData(request.requestBody);
|
||||
|
||||
if (data.title === "this title triggers an error") {
|
||||
@ -564,8 +564,8 @@ export function applyDefaultHandlers(pretender) {
|
||||
action: "enqueued",
|
||||
pending_post: {
|
||||
id: 1234,
|
||||
raw: data.raw
|
||||
}
|
||||
raw: data.raw,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -574,7 +574,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
success: true,
|
||||
action: "custom",
|
||||
message: "This is a custom response",
|
||||
route_to: "/faq"
|
||||
route_to: "/faq",
|
||||
});
|
||||
}
|
||||
|
||||
@ -584,8 +584,8 @@ export function applyDefaultHandlers(pretender) {
|
||||
post: {
|
||||
id: 12345,
|
||||
topic_id: 280,
|
||||
topic_slug: "internationalization-localization"
|
||||
}
|
||||
topic_slug: "internationalization-localization",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@ -595,27 +595,27 @@ export function applyDefaultHandlers(pretender) {
|
||||
const overridden = {
|
||||
id: "site.overridden",
|
||||
value: "Overridden",
|
||||
overridden: true
|
||||
overridden: true,
|
||||
};
|
||||
|
||||
pretender.get("/admin/users/list/active.json", request => {
|
||||
pretender.get("/admin/users/list/active.json", (request) => {
|
||||
let store = [
|
||||
{
|
||||
id: 1,
|
||||
username: "eviltrout",
|
||||
email: "<small>eviltrout@example.com</small>"
|
||||
email: "<small>eviltrout@example.com</small>",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
username: "discobot",
|
||||
email: "<small>discobot_email</small>"
|
||||
}
|
||||
email: "<small>discobot_email</small>",
|
||||
},
|
||||
];
|
||||
|
||||
const showEmails = request.queryParams.show_emails;
|
||||
|
||||
if (showEmails === "false") {
|
||||
store = store.map(item => {
|
||||
store = store.map((item) => {
|
||||
delete item.email;
|
||||
return item;
|
||||
});
|
||||
@ -625,7 +625,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
const order = request.queryParams.order;
|
||||
|
||||
if (order) {
|
||||
store = store.sort(function(a, b) {
|
||||
store = store.sort(function (a, b) {
|
||||
return a[order] - b[order];
|
||||
});
|
||||
}
|
||||
@ -642,12 +642,12 @@ export function applyDefaultHandlers(pretender) {
|
||||
{
|
||||
id: 2,
|
||||
username: "sam",
|
||||
email: "<small>sam@example.com</small>"
|
||||
}
|
||||
email: "<small>sam@example.com</small>",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
pretender.get("/admin/customize/site_texts", request => {
|
||||
pretender.get("/admin/customize/site_texts", (request) => {
|
||||
if (request.queryParams.overridden) {
|
||||
return response(200, { site_texts: [overridden] });
|
||||
} else {
|
||||
@ -662,7 +662,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
response(200, { site_text: siteText })
|
||||
);
|
||||
|
||||
pretender.put("/admin/customize/site_texts/:key", request => {
|
||||
pretender.put("/admin/customize/site_texts/:key", (request) => {
|
||||
const result = parsePostData(request.requestBody);
|
||||
result.id = request.params.key;
|
||||
result.can_revert = true;
|
||||
@ -676,7 +676,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
id: 1,
|
||||
username: "eviltrout",
|
||||
email: "eviltrout@example.com",
|
||||
admin: true
|
||||
admin: true,
|
||||
});
|
||||
});
|
||||
|
||||
@ -684,7 +684,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
return response(200, {
|
||||
id: 2,
|
||||
username: "sam",
|
||||
admin: true
|
||||
admin: true,
|
||||
});
|
||||
});
|
||||
|
||||
@ -693,21 +693,21 @@ export function applyDefaultHandlers(pretender) {
|
||||
id: 3,
|
||||
username: "markvanlan",
|
||||
email: "markvanlan@example.com",
|
||||
secondary_emails: ["markvanlan1@example.com", "markvanlan2@example.com"]
|
||||
secondary_emails: ["markvanlan1@example.com", "markvanlan2@example.com"],
|
||||
});
|
||||
});
|
||||
|
||||
pretender.get("/admin/users/1234.json", () => {
|
||||
return response(200, {
|
||||
id: 1234,
|
||||
username: "regular"
|
||||
username: "regular",
|
||||
});
|
||||
});
|
||||
|
||||
pretender.get("/admin/users/1235.json", () => {
|
||||
return response(200, {
|
||||
id: 1235,
|
||||
username: "regular2"
|
||||
username: "regular2",
|
||||
});
|
||||
});
|
||||
|
||||
@ -720,7 +720,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
pretender.get("/admin/logs/staff_action_logs.json", () => {
|
||||
return response(200, {
|
||||
staff_action_logs: [],
|
||||
extras: { user_history_actions: [] }
|
||||
extras: { user_history_actions: [] },
|
||||
});
|
||||
});
|
||||
|
||||
@ -729,7 +729,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
});
|
||||
pretender.delete("/admin/logs/watched_words/:id.json", success);
|
||||
|
||||
pretender.post("/admin/logs/watched_words.json", request => {
|
||||
pretender.post("/admin/logs/watched_words.json", (request) => {
|
||||
const result = parsePostData(request.requestBody);
|
||||
result.id = new Date().getTime();
|
||||
return response(200, result);
|
||||
@ -737,7 +737,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
|
||||
pretender.get("/admin/logs/search_logs.json", () => {
|
||||
return response(200, [
|
||||
{ term: "foobar", searches: 35, click_through: 6, unique: 16 }
|
||||
{ term: "foobar", searches: 35, click_through: 6, unique: 16 },
|
||||
]);
|
||||
});
|
||||
|
||||
@ -747,8 +747,8 @@ export function applyDefaultHandlers(pretender) {
|
||||
type: "search_log_term",
|
||||
title: "Search Count",
|
||||
term: "ruby",
|
||||
data: [{ x: "2017-07-20", y: 2 }]
|
||||
}
|
||||
data: [{ x: "2017-07-20", y: 2 }],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@ -757,23 +757,23 @@ export function applyDefaultHandlers(pretender) {
|
||||
imageFilename: "somefile.png",
|
||||
imageFilesize: "10 KB",
|
||||
imageWidth: "1",
|
||||
imageHeight: "1"
|
||||
imageHeight: "1",
|
||||
});
|
||||
});
|
||||
|
||||
pretender.get("/inline-onebox", request => {
|
||||
pretender.get("/inline-onebox", (request) => {
|
||||
if (
|
||||
request.queryParams.urls.includes("http://www.example.com/has-title.html")
|
||||
) {
|
||||
return [
|
||||
200,
|
||||
{ "Content-Type": "application/html" },
|
||||
'{"inline-oneboxes":[{"url":"http://www.example.com/has-title.html","title":"This is a great title"}]}'
|
||||
'{"inline-oneboxes":[{"url":"http://www.example.com/has-title.html","title":"This is a great title"}]}',
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
pretender.get("/onebox", request => {
|
||||
pretender.get("/onebox", (request) => {
|
||||
if (
|
||||
request.queryParams.url === "http://www.example.com/has-title.html" ||
|
||||
request.queryParams.url ===
|
||||
@ -782,7 +782,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
return [
|
||||
200,
|
||||
{ "Content-Type": "application/html" },
|
||||
'<aside class="onebox"><article class="onebox-body"><h3><a href="http://www.example.com/article.html">An interesting article</a></h3></article></aside>'
|
||||
'<aside class="onebox"><article class="onebox-body"><h3><a href="http://www.example.com/article.html">An interesting article</a></h3></article></aside>',
|
||||
];
|
||||
}
|
||||
|
||||
@ -790,7 +790,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
return [
|
||||
200,
|
||||
{ "Content-Type": "application/html" },
|
||||
'<aside class="onebox"><article class="onebox-body"><p>No title</p></article></aside>'
|
||||
'<aside class="onebox"><article class="onebox-body"><p>No title</p></article></aside>',
|
||||
];
|
||||
}
|
||||
|
||||
@ -798,7 +798,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
return [
|
||||
200,
|
||||
{ "Content-Type": "application/html" },
|
||||
'<aside class="onebox"><article class="onebox-body"><h3><a href="/internal-page.html">Internal Page 4 U</a></h3></article></aside>'
|
||||
'<aside class="onebox"><article class="onebox-body"><h3><a href="/internal-page.html">Internal Page 4 U</a></h3></article></aside>',
|
||||
];
|
||||
}
|
||||
if (request.queryParams.url === "http://somegoodurl.com/") {
|
||||
@ -818,7 +818,7 @@ export function applyDefaultHandlers(pretender) {
|
||||
<div class="onebox-metadata"></div>
|
||||
<div style="clear: both"></div>
|
||||
</aside>
|
||||
`
|
||||
`,
|
||||
];
|
||||
}
|
||||
return [404, { "Content-Type": "application/html" }, ""];
|
||||
|
@ -7,10 +7,10 @@ import { buildResolver } from "discourse-common/resolver";
|
||||
import { currentSettings } from "helpers/site-settings";
|
||||
|
||||
const CatAdapter = RestAdapter.extend({
|
||||
primaryKey: "cat_id"
|
||||
primaryKey: "cat_id",
|
||||
});
|
||||
|
||||
export default function(customLookup = () => {}) {
|
||||
export default function (customLookup = () => {}) {
|
||||
const resolver = buildResolver("discourse").create();
|
||||
|
||||
return Store.create({
|
||||
@ -51,9 +51,9 @@ export default function(customLookup = () => {}) {
|
||||
const split = type.split(":");
|
||||
return resolver.customResolve({
|
||||
type: split[0],
|
||||
fullNameWithoutType: split[1]
|
||||
fullNameWithoutType: split[1],
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ export default function formatTextWithSelection(text, [start, len]) {
|
||||
text.substr(start, len),
|
||||
">",
|
||||
text.substr(start + len),
|
||||
'"'
|
||||
'"',
|
||||
].join("");
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
export default function(helpers) {
|
||||
export default function (helpers) {
|
||||
const { response } = helpers;
|
||||
const fixturesByUrl = {};
|
||||
|
||||
// Load any fixtures automatically
|
||||
Object.keys(require._eak_seen).forEach(entry => {
|
||||
Object.keys(require._eak_seen).forEach((entry) => {
|
||||
if (/^fixtures/.test(entry)) {
|
||||
const fixture = require(entry, null, null, true);
|
||||
if (fixture && fixture.default) {
|
||||
const obj = fixture.default;
|
||||
Object.keys(obj).forEach(url => {
|
||||
Object.keys(obj).forEach((url) => {
|
||||
fixturesByUrl[url] = obj[url];
|
||||
this.get(url, () => response(obj[url]));
|
||||
});
|
||||
|
@ -8,7 +8,7 @@ import { forceMobile, resetMobile } from "discourse/lib/mobile";
|
||||
import { resetPluginApi } from "discourse/lib/plugin-api";
|
||||
import {
|
||||
clearCache as clearOutletCache,
|
||||
resetExtraClasses
|
||||
resetExtraClasses,
|
||||
} from "discourse/lib/plugin-connectors";
|
||||
import { clearHTMLCache } from "discourse/helpers/custom-html";
|
||||
import { flushMap } from "discourse/models/store";
|
||||
@ -54,7 +54,7 @@ export function fakeTime(timeString, timezone = null, advanceTime = false) {
|
||||
let now = moment.tz(timeString, timezone);
|
||||
return sandbox.useFakeTimers({
|
||||
now: now.valueOf(),
|
||||
shouldAdvanceTime: advanceTime
|
||||
shouldAdvanceTime: advanceTime,
|
||||
});
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ const Plugin = $.fn.modal;
|
||||
const Modal = Plugin.Constructor;
|
||||
|
||||
function AcceptanceModal(option, _relatedTarget) {
|
||||
return this.each(function() {
|
||||
return this.each(function () {
|
||||
var $this = $(this);
|
||||
var data = $this.data("bs.modal");
|
||||
var options = $.extend(
|
||||
@ -118,7 +118,7 @@ export function controllerModule(name, args = {}) {
|
||||
args.setupController(controller);
|
||||
}
|
||||
},
|
||||
needs: args.needs
|
||||
needs: args.needs,
|
||||
});
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ export function discourseModule(name, hooks) {
|
||||
if (hooks && hooks.afterEach) {
|
||||
hooks.afterEach.call(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ export function acceptance(name, options) {
|
||||
resetMobile();
|
||||
|
||||
// For now don't do scrolling stuff in Test Mode
|
||||
HeaderComponent.reopen({ examineDockHeader: function() {} });
|
||||
HeaderComponent.reopen({ examineDockHeader: function () {} });
|
||||
|
||||
resetExtraClasses();
|
||||
if (options.mobileView) {
|
||||
@ -222,7 +222,7 @@ export function acceptance(name, options) {
|
||||
|
||||
// We do this after reset so that the willClearRender will have already fired
|
||||
resetWidgetCleanCallbacks();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -241,36 +241,36 @@ export function fixture(selector) {
|
||||
return $("#qunit-fixture");
|
||||
}
|
||||
|
||||
QUnit.assert.not = function(actual, message) {
|
||||
QUnit.assert.not = function (actual, message) {
|
||||
this.pushResult({
|
||||
result: !actual,
|
||||
actual,
|
||||
expected: !actual,
|
||||
message
|
||||
message,
|
||||
});
|
||||
};
|
||||
|
||||
QUnit.assert.blank = function(actual, message) {
|
||||
QUnit.assert.blank = function (actual, message) {
|
||||
this.pushResult({
|
||||
result: isEmpty(actual),
|
||||
actual,
|
||||
message
|
||||
message,
|
||||
});
|
||||
};
|
||||
|
||||
QUnit.assert.present = function(actual, message) {
|
||||
QUnit.assert.present = function (actual, message) {
|
||||
this.pushResult({
|
||||
result: !isEmpty(actual),
|
||||
actual,
|
||||
message
|
||||
message,
|
||||
});
|
||||
};
|
||||
|
||||
QUnit.assert.containsInstance = function(collection, klass, message) {
|
||||
QUnit.assert.containsInstance = function (collection, klass, message) {
|
||||
const result = klass.detectInstance(collection[0]);
|
||||
this.pushResult({
|
||||
result,
|
||||
message
|
||||
message,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { set } from "@ember/object";
|
||||
export default function(helpers) {
|
||||
export default function (helpers) {
|
||||
const { response } = helpers;
|
||||
|
||||
let flag = {
|
||||
@ -8,7 +8,7 @@ export default function(helpers) {
|
||||
score: 3.0,
|
||||
target_created_by_id: 1,
|
||||
cooked: "<b>cooked content</b>",
|
||||
reviewable_score_ids: [1, 2]
|
||||
reviewable_score_ids: [1, 2],
|
||||
};
|
||||
|
||||
this.get("/review", () => {
|
||||
@ -24,7 +24,7 @@ export default function(helpers) {
|
||||
created_at: "2019-01-14T19:49:53.571Z",
|
||||
username: "newbie",
|
||||
email: "newbie@example.com",
|
||||
bundled_action_ids: ["approve", "reject"]
|
||||
bundled_action_ids: ["approve", "reject"],
|
||||
},
|
||||
{
|
||||
id: 4321,
|
||||
@ -35,7 +35,7 @@ export default function(helpers) {
|
||||
target_created_by_id: 1,
|
||||
payload: {
|
||||
raw: "existing body",
|
||||
tags: ["hello", "world"]
|
||||
tags: ["hello", "world"],
|
||||
},
|
||||
version: 1,
|
||||
can_edit: true,
|
||||
@ -43,33 +43,33 @@ export default function(helpers) {
|
||||
{ id: "category_id", type: "category" },
|
||||
{ id: "payload.title", type: "text" },
|
||||
{ id: "payload.raw", type: "textarea" },
|
||||
{ id: "payload.tags", type: "tags" }
|
||||
{ id: "payload.tags", type: "tags" },
|
||||
],
|
||||
bundled_action_ids: ["approve", "reject"]
|
||||
bundled_action_ids: ["approve", "reject"],
|
||||
},
|
||||
flag
|
||||
flag,
|
||||
],
|
||||
bundled_actions: [
|
||||
{
|
||||
id: "approve",
|
||||
action_ids: ["approve"]
|
||||
action_ids: ["approve"],
|
||||
},
|
||||
{
|
||||
id: "reject",
|
||||
action_ids: ["reject"]
|
||||
}
|
||||
action_ids: ["reject"],
|
||||
},
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
id: "approve",
|
||||
label: "Approve",
|
||||
icon: "far-thumbs-up"
|
||||
icon: "far-thumbs-up",
|
||||
},
|
||||
{
|
||||
id: "reject",
|
||||
label: "Reject",
|
||||
icon: "far-thumbs-down"
|
||||
}
|
||||
icon: "far-thumbs-down",
|
||||
},
|
||||
],
|
||||
reviewable_scores: [{ id: 1 }, { id: 2 }],
|
||||
users: [{ id: 1, username: "eviltrout" }],
|
||||
@ -77,16 +77,16 @@ export default function(helpers) {
|
||||
total_rows_reviewables: 2,
|
||||
types: {
|
||||
created_by: "user",
|
||||
target_created_by: "user"
|
||||
}
|
||||
target_created_by: "user",
|
||||
},
|
||||
},
|
||||
__rest_serializer: "1"
|
||||
__rest_serializer: "1",
|
||||
});
|
||||
});
|
||||
|
||||
this.get("/review/topics", () => {
|
||||
return response(200, {
|
||||
reviewable_topics: [{ id: 1234, title: "Cool topic" }]
|
||||
reviewable_topics: [{ id: 1234, title: "Cool topic" }],
|
||||
});
|
||||
});
|
||||
|
||||
@ -96,13 +96,13 @@ export default function(helpers) {
|
||||
{
|
||||
id: 3,
|
||||
title: "Off-Topic",
|
||||
reviewable_priority: 0
|
||||
reviewable_priority: 0,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
title: "Inappropriate",
|
||||
reviewable_priority: 5
|
||||
}
|
||||
reviewable_priority: 5,
|
||||
},
|
||||
],
|
||||
reviewable_settings: {
|
||||
id: 13870,
|
||||
@ -110,10 +110,10 @@ export default function(helpers) {
|
||||
reviewable_priorities: [
|
||||
{ id: 0, name: "Low" },
|
||||
{ id: 5, name: "Medium" },
|
||||
{ id: 10, name: "High" }
|
||||
]
|
||||
{ id: 10, name: "High" },
|
||||
],
|
||||
},
|
||||
__rest_serializer: "1"
|
||||
__rest_serializer: "1",
|
||||
});
|
||||
});
|
||||
|
||||
@ -121,22 +121,22 @@ export default function(helpers) {
|
||||
|
||||
this.get("/review/:id", () => {
|
||||
return response(200, {
|
||||
reviewable: flag
|
||||
reviewable: flag,
|
||||
});
|
||||
});
|
||||
|
||||
this.put("/review/:id/perform/:actionId", request => {
|
||||
this.put("/review/:id/perform/:actionId", (request) => {
|
||||
return response(200, {
|
||||
reviewable_perform_result: {
|
||||
success: true,
|
||||
remove_reviewable_ids: [parseInt(request.params.id, 10)]
|
||||
}
|
||||
remove_reviewable_ids: [parseInt(request.params.id, 10)],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
this.put("/review/:id", request => {
|
||||
this.put("/review/:id", (request) => {
|
||||
let result = { payload: {} };
|
||||
Object.entries(JSON.parse(request.requestBody).reviewable).forEach(t => {
|
||||
Object.entries(JSON.parse(request.requestBody).reviewable).forEach((t) => {
|
||||
set(result, t[0], t[1]);
|
||||
});
|
||||
return response(200, result);
|
||||
|
@ -73,7 +73,7 @@ async function keyboardHelper(value, target, selector) {
|
||||
escape: { keyCode: 27 },
|
||||
down: { keyCode: 40 },
|
||||
up: { keyCode: 38 },
|
||||
tab: { keyCode: 9 }
|
||||
tab: { keyCode: 9 },
|
||||
};
|
||||
|
||||
await triggerEvent(
|
||||
@ -96,10 +96,7 @@ function rowHelper(row) {
|
||||
return row.attr("title");
|
||||
},
|
||||
label() {
|
||||
return row
|
||||
.find(".name")
|
||||
.text()
|
||||
.trim();
|
||||
return row.find(".name").text().trim();
|
||||
},
|
||||
value() {
|
||||
const value = row.attr("data-value");
|
||||
@ -110,7 +107,7 @@ function rowHelper(row) {
|
||||
},
|
||||
el() {
|
||||
return row;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -134,7 +131,7 @@ function headerHelper(header) {
|
||||
},
|
||||
el() {
|
||||
return header;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -151,7 +148,7 @@ function filterHelper(filter) {
|
||||
},
|
||||
el() {
|
||||
return filter;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -228,7 +225,7 @@ export default function selectKit(selector) {
|
||||
.map((_, row) => {
|
||||
return {
|
||||
name: row.getAttribute("data-name"),
|
||||
id: row.getAttribute("data-value")
|
||||
id: row.getAttribute("data-value"),
|
||||
};
|
||||
})
|
||||
.toArray();
|
||||
@ -280,15 +277,13 @@ export default function selectKit(selector) {
|
||||
|
||||
async deselectItem(value) {
|
||||
await click(
|
||||
find(selector)
|
||||
.find(".select-kit-header")
|
||||
.find(`[data-value=${value}]`)
|
||||
find(selector).find(".select-kit-header").find(`[data-value=${value}]`)
|
||||
);
|
||||
},
|
||||
|
||||
exists() {
|
||||
return exists(selector);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -303,23 +298,23 @@ export function testSelectKitModule(moduleName, options = {}) {
|
||||
|
||||
afterEach() {
|
||||
options.afterEach && options.afterEach.call(this);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export const DEFAULT_CONTENT = [
|
||||
{ id: 1, name: "foo" },
|
||||
{ id: 2, name: "bar" },
|
||||
{ id: 3, name: "baz" }
|
||||
{ id: 3, name: "baz" },
|
||||
];
|
||||
|
||||
export function setDefaultState(ctx, value, options = {}) {
|
||||
const properties = Object.assign(
|
||||
{
|
||||
value,
|
||||
onChange: v => {
|
||||
onChange: (v) => {
|
||||
ctx.set("value", v);
|
||||
}
|
||||
},
|
||||
},
|
||||
options || {}
|
||||
);
|
||||
|
@ -97,7 +97,7 @@ const ORIGINAL_SETTINGS = {
|
||||
enable_mentions: true,
|
||||
enable_personal_messages: true,
|
||||
unicode_usernames: false,
|
||||
secure_media: false
|
||||
secure_media: false,
|
||||
};
|
||||
|
||||
let siteSettings = Object.assign({}, ORIGINAL_SETTINGS);
|
||||
|
@ -13,7 +13,7 @@ PreloadStore.store("site", {
|
||||
invited_to_private_message: 7,
|
||||
invitee_accepted: 8,
|
||||
posted: 9,
|
||||
moved_post: 10
|
||||
moved_post: 10,
|
||||
},
|
||||
post_types: { regular: 1, moderator_action: 2 },
|
||||
groups: [
|
||||
@ -27,7 +27,7 @@ PreloadStore.store("site", {
|
||||
{ id: 13, name: "trust_level_3" },
|
||||
{ id: 14, name: "trust_level_4" },
|
||||
{ id: 20, name: "ubuntu" },
|
||||
{ id: 21, name: "test" }
|
||||
{ id: 21, name: "test" },
|
||||
],
|
||||
filters: ["latest", "unread", "new", "starred", "read", "posted"],
|
||||
periods: ["all", "yearly", "monthly", "weekly", "daily"],
|
||||
@ -39,7 +39,7 @@ PreloadStore.store("site", {
|
||||
"read",
|
||||
"posted",
|
||||
"categories",
|
||||
"top"
|
||||
"top",
|
||||
],
|
||||
anonymous_top_menu_items: ["latest", "categories", "top"],
|
||||
uncategorized_category_id: 17,
|
||||
@ -56,7 +56,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-extensibility/28",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
@ -70,7 +70,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-dev/1026",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
@ -84,7 +84,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-bug/2",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
@ -98,7 +98,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-hosting/2626",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
@ -112,7 +112,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-support/389",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
@ -126,7 +126,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-feature/11",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
@ -140,7 +140,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-blog/5250",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
@ -154,7 +154,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-discourse-hub/3038",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
@ -168,7 +168,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-login/2828",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
@ -182,7 +182,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-meta/24",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
@ -196,7 +196,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-howto/2629",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
@ -210,7 +210,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-marketplace/5425",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 17,
|
||||
@ -223,7 +223,7 @@ PreloadStore.store("site", {
|
||||
topic_url: null,
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
@ -237,7 +237,7 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-ux/2628",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
permission: null,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
@ -251,8 +251,8 @@ PreloadStore.store("site", {
|
||||
topic_url: "/t/category-definition-for-faq/25",
|
||||
hotness: 5.0,
|
||||
read_restricted: false,
|
||||
permission: null
|
||||
}
|
||||
permission: null,
|
||||
},
|
||||
],
|
||||
post_action_types: [
|
||||
{
|
||||
@ -263,7 +263,7 @@ PreloadStore.store("site", {
|
||||
is_flag: false,
|
||||
icon: null,
|
||||
id: 1,
|
||||
is_custom_flag: false
|
||||
is_custom_flag: false,
|
||||
},
|
||||
{
|
||||
name_key: "like",
|
||||
@ -273,7 +273,7 @@ PreloadStore.store("site", {
|
||||
is_flag: false,
|
||||
icon: "heart",
|
||||
id: 2,
|
||||
is_custom_flag: false
|
||||
is_custom_flag: false,
|
||||
},
|
||||
{
|
||||
name_key: "off_topic",
|
||||
@ -284,7 +284,7 @@ PreloadStore.store("site", {
|
||||
is_flag: true,
|
||||
icon: null,
|
||||
id: 3,
|
||||
is_custom_flag: false
|
||||
is_custom_flag: false,
|
||||
},
|
||||
{
|
||||
name_key: "inappropriate",
|
||||
@ -295,7 +295,7 @@ PreloadStore.store("site", {
|
||||
is_flag: true,
|
||||
icon: null,
|
||||
id: 4,
|
||||
is_custom_flag: false
|
||||
is_custom_flag: false,
|
||||
},
|
||||
{
|
||||
name_key: "vote",
|
||||
@ -305,7 +305,7 @@ PreloadStore.store("site", {
|
||||
is_flag: false,
|
||||
icon: null,
|
||||
id: 5,
|
||||
is_custom_flag: false
|
||||
is_custom_flag: false,
|
||||
},
|
||||
{
|
||||
name_key: "spam",
|
||||
@ -316,7 +316,7 @@ PreloadStore.store("site", {
|
||||
is_flag: true,
|
||||
icon: null,
|
||||
id: 8,
|
||||
is_custom_flag: false
|
||||
is_custom_flag: false,
|
||||
},
|
||||
{
|
||||
name_key: "notify_user",
|
||||
@ -327,7 +327,7 @@ PreloadStore.store("site", {
|
||||
is_flag: true,
|
||||
icon: null,
|
||||
id: 6,
|
||||
is_custom_flag: true
|
||||
is_custom_flag: true,
|
||||
},
|
||||
{
|
||||
name_key: "notify_moderators",
|
||||
@ -338,15 +338,15 @@ PreloadStore.store("site", {
|
||||
is_flag: true,
|
||||
icon: null,
|
||||
id: 7,
|
||||
is_custom_flag: true
|
||||
}
|
||||
is_custom_flag: true,
|
||||
},
|
||||
],
|
||||
trust_levels: [
|
||||
{ id: 0, name: "new user" },
|
||||
{ id: 1, name: "basic user" },
|
||||
{ id: 2, name: "member" },
|
||||
{ id: 3, name: "regular" },
|
||||
{ id: 4, name: "leader" }
|
||||
{ id: 4, name: "leader" },
|
||||
],
|
||||
archetypes: [{ id: "regular", name: "Regular Topic", options: [] }]
|
||||
archetypes: [{ id: "regular", name: "Regular Topic", options: [] }],
|
||||
});
|
||||
|
@ -1,77 +1,77 @@
|
||||
const _widgets = [
|
||||
{ id: 123, name: "Trout Lure" },
|
||||
{ id: 124, name: "Evil Repellant" }
|
||||
{ id: 124, name: "Evil Repellant" },
|
||||
];
|
||||
|
||||
const _moreWidgets = [
|
||||
{ id: 223, name: "Bass Lure" },
|
||||
{ id: 224, name: "Good Repellant" }
|
||||
{ id: 224, name: "Good Repellant" },
|
||||
];
|
||||
|
||||
const fruits = [
|
||||
{ id: 1, name: "apple", farmer_id: 1, color_ids: [1, 2], category_id: 4 },
|
||||
{ id: 2, name: "banana", farmer_id: 1, color_ids: [3], category_id: 3 },
|
||||
{ id: 3, name: "grape", farmer_id: 2, color_ids: [2], category_id: 5 },
|
||||
{ id: 4, name: "orange", farmer_id: null, color_ids: [2], category_id: 5 }
|
||||
{ id: 4, name: "orange", farmer_id: null, color_ids: [2], category_id: 5 },
|
||||
];
|
||||
|
||||
const farmers = [
|
||||
{ id: 1, name: "Old MacDonald" },
|
||||
{ id: 2, name: "Luke Skywalker" }
|
||||
{ id: 2, name: "Luke Skywalker" },
|
||||
];
|
||||
|
||||
const colors = [
|
||||
{ id: 1, name: "Red" },
|
||||
{ id: 2, name: "Green" },
|
||||
{ id: 3, name: "Yellow" }
|
||||
{ id: 3, name: "Yellow" },
|
||||
];
|
||||
|
||||
const cats = [
|
||||
{
|
||||
cat_id: 1,
|
||||
name: "souna"
|
||||
}
|
||||
name: "souna",
|
||||
},
|
||||
];
|
||||
|
||||
export default function(helpers) {
|
||||
export default function (helpers) {
|
||||
const { response, success, parsePostData } = helpers;
|
||||
|
||||
this.get("/cats", function() {
|
||||
this.get("/cats", function () {
|
||||
return response({
|
||||
__rest_serializer: "1",
|
||||
cats
|
||||
cats,
|
||||
});
|
||||
});
|
||||
|
||||
this.get("/fruits/:id", function(request) {
|
||||
const fruit = fruits.find(f => f.id === parseInt(request.params.id, 10));
|
||||
this.get("/fruits/:id", function (request) {
|
||||
const fruit = fruits.find((f) => f.id === parseInt(request.params.id, 10));
|
||||
return response({ __rest_serializer: "1", fruit, farmers, colors });
|
||||
});
|
||||
|
||||
this.get("/fruits", function() {
|
||||
this.get("/fruits", function () {
|
||||
return response({
|
||||
__rest_serializer: "1",
|
||||
fruits,
|
||||
farmers,
|
||||
colors,
|
||||
extras: { hello: "world" }
|
||||
extras: { hello: "world" },
|
||||
});
|
||||
});
|
||||
|
||||
this.get("/barns/:id", function() {
|
||||
this.get("/barns/:id", function () {
|
||||
return response({
|
||||
__rest_serializer: "1",
|
||||
meta: {
|
||||
types: {
|
||||
owner: "farmer"
|
||||
}
|
||||
owner: "farmer",
|
||||
},
|
||||
},
|
||||
barn: { id: 1234, owner_id: farmers[0].id },
|
||||
farmers: [farmers[0]]
|
||||
farmers: [farmers[0]],
|
||||
});
|
||||
});
|
||||
|
||||
this.get("/widgets/:widget_id", function(request) {
|
||||
this.get("/widgets/:widget_id", function (request) {
|
||||
const w = _widgets.findBy("id", parseInt(request.params.widget_id, 10));
|
||||
if (w) {
|
||||
return response({ widget: w, extras: { hello: "world" } });
|
||||
@ -80,23 +80,23 @@ export default function(helpers) {
|
||||
}
|
||||
});
|
||||
|
||||
this.post("/widgets", function(request) {
|
||||
this.post("/widgets", function (request) {
|
||||
const widget = parsePostData(request.requestBody).widget;
|
||||
widget.id = 100;
|
||||
return response(200, { widget });
|
||||
});
|
||||
|
||||
this.put("/widgets/:widget_id", function(request) {
|
||||
this.put("/widgets/:widget_id", function (request) {
|
||||
const widget = parsePostData(request.requestBody).widget;
|
||||
return response({ widget });
|
||||
});
|
||||
|
||||
this.put("/cool_things/:cool_thing_id", function(request) {
|
||||
this.put("/cool_things/:cool_thing_id", function (request) {
|
||||
const cool_thing = parsePostData(request.requestBody).cool_thing;
|
||||
return response({ cool_thing });
|
||||
});
|
||||
|
||||
this.get("/widgets", function(request) {
|
||||
this.get("/widgets", function (request) {
|
||||
let result = _widgets;
|
||||
|
||||
const qp = request.queryParams;
|
||||
@ -114,16 +114,16 @@ export default function(helpers) {
|
||||
meta: {
|
||||
total_rows_widgets: 4,
|
||||
load_more_widgets: "/load-more-widgets",
|
||||
refresh_widgets: "/widgets?refresh=true"
|
||||
}
|
||||
refresh_widgets: "/widgets?refresh=true",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
this.get("/load-more-widgets", function() {
|
||||
this.get("/load-more-widgets", function () {
|
||||
return response({
|
||||
widgets: _moreWidgets,
|
||||
total_rows_widgets: 4,
|
||||
load_more_widgets: "/load-more-widgets"
|
||||
load_more_widgets: "/load-more-widgets",
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user