FIX: Remove `:term` from `admin/search_logs/term/:term` route.
Search log terms is a string that can contain characters like `/` which messes with the route.
This commit is contained in:
parent
c836d67cac
commit
8c2fa99f78
|
@ -11,10 +11,11 @@ export default Discourse.Route.extend({
|
|||
model(params) {
|
||||
this._params = params;
|
||||
|
||||
return ajax(`/admin/logs/search_logs/term/${params.term}.json`, {
|
||||
return ajax(`/admin/logs/search_logs/term.json`, {
|
||||
data: {
|
||||
period: params.period,
|
||||
search_type: params.searchType
|
||||
search_type: params.searchType,
|
||||
term: params.term
|
||||
}
|
||||
}).then(json => {
|
||||
// Add zero values for missing dates
|
||||
|
|
|
@ -179,7 +179,7 @@ Discourse::Application.routes.draw do
|
|||
end
|
||||
post "watched_words/upload" => "watched_words#upload"
|
||||
resources :search_logs, only: [:index]
|
||||
get 'search_logs/term/:term' => 'search_logs#term'
|
||||
get 'search_logs/term/' => 'search_logs#term'
|
||||
end
|
||||
|
||||
get "/logs" => "staff_action_logs#index"
|
||||
|
|
|
@ -39,19 +39,29 @@ RSpec.describe Admin::SearchLogsController do
|
|||
|
||||
context "#term" do
|
||||
it "raises an error if you aren't logged in" do
|
||||
get '/admin/logs/search_logs/term/ruby.json'
|
||||
get '/admin/logs/search_logs/term.json', params: {
|
||||
term: "ruby"
|
||||
}
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it "raises an error if you aren't an admin" do
|
||||
sign_in(user)
|
||||
get '/admin/logs/search_logs/term/ruby.json'
|
||||
|
||||
get '/admin/logs/search_logs/term.json', params: {
|
||||
term: "ruby"
|
||||
}
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it "should work if you are an admin" do
|
||||
sign_in(admin)
|
||||
get '/admin/logs/search_logs/term/ruby.json'
|
||||
|
||||
get '/admin/logs/search_logs/term.json', params: {
|
||||
term: "ruby"
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
|
|
|
@ -577,11 +577,12 @@ export default function() {
|
|||
]);
|
||||
});
|
||||
|
||||
this.get("/admin/logs/search_logs/term/ruby.json", () => {
|
||||
this.get("/admin/logs/search_logs/term.json", () => {
|
||||
return response(200, {
|
||||
term: {
|
||||
type: "search_log_term",
|
||||
title: "Search Count",
|
||||
term: "ruby",
|
||||
data: [{ x: "2017-07-20", y: 2 }]
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue