Rename house ad routes so ad blockers don't detect them
adplugin, house_ads, house_ad_settings become pluginad, house_creatives, and house_settings.
This commit is contained in:
parent
edc549b269
commit
8d4df6df91
|
@ -2,7 +2,7 @@ export default {
|
|||
resource: "admin.adminPlugins",
|
||||
path: "/plugins",
|
||||
map() {
|
||||
this.route("houseAds", { path: "/adplugin/house_ads" }, function() {
|
||||
this.route("houseAds", { path: "/pluginad/house_creatives" }, function() {
|
||||
this.route("index", { path: "/" });
|
||||
this.route("show", { path: "/:ad_id" });
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ export default Ember.Component.extend({
|
|||
});
|
||||
|
||||
ajax(
|
||||
`/admin/plugins/adplugin/house_ad_settings/${this.get("name")}.json`,
|
||||
`/admin/plugins/pluginad/house_settings/${this.get("name")}.json`,
|
||||
{
|
||||
type: "PUT",
|
||||
data: { value: this.get("adValue") }
|
||||
|
|
|
@ -34,8 +34,8 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||
|
||||
ajax(
|
||||
newRecord
|
||||
? `/admin/plugins/adplugin/house_ads`
|
||||
: `/admin/plugins/adplugin/house_ads/${buffered.get("id")}`,
|
||||
? `/admin/plugins/pluginad/house_creatives`
|
||||
: `/admin/plugins/pluginad/house_creatives/${buffered.get("id")}`,
|
||||
{
|
||||
type: newRecord ? "POST" : "PUT",
|
||||
data
|
||||
|
@ -80,7 +80,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||
return;
|
||||
}
|
||||
|
||||
ajax(`/admin/plugins/adplugin/house_ads/${model.get("id")}`, {
|
||||
ajax(`/admin/plugins/pluginad/house_creatives/${model.get("id")}`, {
|
||||
type: "DELETE"
|
||||
})
|
||||
.then(() => {
|
||||
|
|
|
@ -4,7 +4,7 @@ export default Discourse.Route.extend({
|
|||
settings: null,
|
||||
|
||||
model() {
|
||||
return ajax("/admin/plugins/adplugin/house_ads.json").then(data => {
|
||||
return ajax("/admin/plugins/pluginad/house_creatives.json").then(data => {
|
||||
this.set("settings", Ember.Object.create(data.settings));
|
||||
return data.house_ads.map(ad => Ember.Object.create(ad));
|
||||
});
|
||||
|
|
|
@ -71,12 +71,12 @@ after_initialize do
|
|||
|
||||
AdPlugin::Engine.routes.draw do
|
||||
root to: 'house_ads#index'
|
||||
resources :house_ads, only: [:index, :show, :create, :update, :destroy]
|
||||
resources :house_ad_settings, only: [:update]
|
||||
resources :house_creatives, only: [:index, :show, :create, :update, :destroy], controller: 'house_ads'
|
||||
resources :house_settings, only: [:update], controller: 'house_ad_settings'
|
||||
end
|
||||
|
||||
Discourse::Application.routes.append do
|
||||
get '/ads.txt' => "adstxt#index"
|
||||
mount ::AdPlugin::Engine, at: '/admin/plugins/adplugin', constraints: AdminConstraint.new
|
||||
mount ::AdPlugin::Engine, at: '/admin/plugins/pluginad', constraints: AdminConstraint.new
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,13 +13,13 @@ describe AdPlugin::HouseAdSettingsController do
|
|||
let(:valid_params) { { value: 'Banner' } }
|
||||
|
||||
it "error if not logged in" do
|
||||
put '/admin/plugins/adplugin/house_ad_settings/topic_list_top.json', params: valid_params
|
||||
put '/admin/plugins/pluginad/house_settings/topic_list_top.json', params: valid_params
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it "error if not staff" do
|
||||
sign_in(Fabricate(:user))
|
||||
put '/admin/plugins/adplugin/house_ad_settings/topic_list_top.json', params: valid_params
|
||||
put '/admin/plugins/pluginad/house_settings/topic_list_top.json', params: valid_params
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
|
@ -29,18 +29,18 @@ describe AdPlugin::HouseAdSettingsController do
|
|||
end
|
||||
|
||||
it "changes the setting" do
|
||||
put '/admin/plugins/adplugin/house_ad_settings/topic_list_top.json', params: valid_params
|
||||
put '/admin/plugins/pluginad/house_settings/topic_list_top.json', params: valid_params
|
||||
expect(response.status).to eq(200)
|
||||
expect(AdPlugin::HouseAdSetting.all[:topic_list_top]).to eq(valid_params[:value])
|
||||
end
|
||||
|
||||
it "errors on invalid setting name" do
|
||||
put '/admin/plugins/adplugin/house_ad_settings/nope-nope.json', params: valid_params
|
||||
put '/admin/plugins/pluginad/house_settings/nope-nope.json', params: valid_params
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it "errors on invalid setting value" do
|
||||
put '/admin/plugins/adplugin/house_ad_settings/topic_list_top.json', params: valid_params.merge(value: "Banner|<script>")
|
||||
put '/admin/plugins/pluginad/house_settings/topic_list_top.json', params: valid_params.merge(value: "Banner|<script>")
|
||||
expect(response.status).to eq(400)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue