#1693 Improvements based on CR

pull/1933/head
Kartones 10 years ago
parent c2eb230519
commit b4c64c8e6d

@ -13,12 +13,12 @@ class Admin::PagesController < ApplicationController
NEW_DATASETS_PER_PAGE = 20
MAPS_PER_PAGE = 9
USER_TAGS_LIMIT = 100
PAGE_NUMBER_PLACEHOLDER = '-666'
PAGE_NUMBER_PLACEHOLDER = 'PAGENUMBERPLACEHOLDER'
ssl_required :common_data, :public, :datasets
before_filter :login_required, :except => [:public, :datasets, :sitemap, :index]
before_filter :belongs_to_organization
before_filter :ensure_organization_correct
skip_before_filter :browser_is_html5_compliant?, only: [:public, :datasets]
skip_before_filter :ensure_user_organization_valid, only: [:public]
@ -406,7 +406,7 @@ class Admin::PagesController < ApplicationController
params[:tag]
end
def belongs_to_organization
def ensure_organization_correct
return if CartoDB.subdomainless_urls?
user_or_org_domain = CartoDB.subdomain_from_request(request)

@ -108,7 +108,11 @@ class Admin::VisualizationsController < ApplicationController
# Legacy redirect, now all public pages also with org. name
if eligible_for_redirect?(@visualization.user)
redirect_to CartoDB.url(self, 'public_table', { id: "#{params[:id]}", redirected:true }, @visualization.user) and return
redirect_to CartoDB.url(self,
'public_table',
{ id: "#{params[:id]}", redirected:true },
@visualization.user
) and return
end
@vizjson = @visualization.to_vizjson
@ -192,8 +196,14 @@ class Admin::VisualizationsController < ApplicationController
# Legacy redirect, now all public pages also with org. name
if eligible_for_redirect?(@visualization.user)
redirect to CartoDB.url(self, 'public_visualizations_public_map', {
id: "#{@visualization.user.organization.name}.#{params[:id]}", redirected:true }, @visualization.user) and return
redirect to CartoDB.url(self,
'public_visualizations_public_map',
{
id: "#{@visualization.user.organization.name}.#{params[:id]}",
redirected:true
},
@visualization.user
) and return
end
response.headers['X-Cache-Channel'] = "#{@visualization.varnish_key}:vizjson"

@ -79,19 +79,6 @@ module CartoDB
base_url
end
# NOTE: Not intended for usage outside testing (where is needed to clean state between tests)
def self.clear_internal_cache
remove_class_variable(:@@request_host) if defined?(@@request_host)
remove_class_variable(:@@hostname) if defined?(@@hostname)
remove_class_variable(:@@http_port) if defined?(@@http_port)
remove_class_variable(:@@https_port) if defined?(@@http_ports)
remove_class_variable(:@@session_domain) if defined?(@@session_domain)
remove_class_variable(:@@domain) if defined?(@@domain)
remove_class_variable(:@@subdomainless_urls) if defined?(@@subdomainless_urls)
remove_class_variable(:@@account_host) if defined?(@@account_host)
remove_class_variable(:@@account_path) if defined?(@@account_path)
end
# Note: use ||= only for fields who always have a non-nil, non-false value
# else, rely on defined? and pure assignment to allow nils and values caching the value

@ -3,6 +3,20 @@
require_relative '../../spec_helper'
require_relative '../../../spec/doubles/request'
module CartoDB
def self.clear_internal_cache
remove_class_variable(:@@request_host) if defined?(@@request_host)
remove_class_variable(:@@hostname) if defined?(@@hostname)
remove_class_variable(:@@http_port) if defined?(@@http_port)
remove_class_variable(:@@https_port) if defined?(@@http_ports)
remove_class_variable(:@@session_domain) if defined?(@@session_domain)
remove_class_variable(:@@domain) if defined?(@@domain)
remove_class_variable(:@@subdomainless_urls) if defined?(@@subdomainless_urls)
remove_class_variable(:@@account_host) if defined?(@@account_host)
remove_class_variable(:@@account_path) if defined?(@@account_path)
end
end
describe CartoDB do
after(:each) do
CartoDB.clear_internal_cache

@ -2,6 +2,20 @@
require_relative '../../../../spec_helper'
module CartoDB
def self.clear_internal_cache
remove_class_variable(:@@request_host) if defined?(@@request_host)
remove_class_variable(:@@hostname) if defined?(@@hostname)
remove_class_variable(:@@http_port) if defined?(@@http_port)
remove_class_variable(:@@https_port) if defined?(@@http_ports)
remove_class_variable(:@@session_domain) if defined?(@@session_domain)
remove_class_variable(:@@domain) if defined?(@@domain)
remove_class_variable(:@@subdomainless_urls) if defined?(@@subdomainless_urls)
remove_class_variable(:@@account_host) if defined?(@@account_host)
remove_class_variable(:@@account_path) if defined?(@@account_path)
end
end
describe Api::Json::OembedController do
after(:each) do

Loading…
Cancel
Save