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