CDB-1915 Both fixed the problem, and added a check so visualization doesn't allows to be set to private if user has no private maps enabled

pull/370/head
Kartones 11 years ago
parent be6b592266
commit 03e2c48456

1
.gitignore vendored

@ -1,3 +1,4 @@
.rvmrc
.DS_Store
.bundle
dump.rdb

@ -1 +0,0 @@
rvm use --create 1.9.2@cartodb > /dev/null

@ -269,6 +269,10 @@ module CartoDB
tokens.first
end #get_auth_token
def supports_private_maps?
!@user_data.nil? && @user_data.respond_to?(:actions) && @user_data.actions.respond_to?(:private_maps)
end # supports_private_maps?
private
attr_reader :repository, :name_checker, :validator
@ -281,6 +285,10 @@ module CartoDB
remove_password()
end
if (privacy_changed && @privacy == PRIVACY_PRIVATE && !supports_private_maps?)
raise CartoDB::InvalidMember
end
invalidate_varnish_cache if name_changed || privacy_changed || description_changed
set_timestamps

@ -307,10 +307,7 @@
self.create_vis_dialog.appendToBody().open();
} else {
// Set visualization to private if need it
if (private_vis) {
self.vis.set('privacy', 'PRIVATE');
}
self.vis.set('privacy', private_vis);
// Add new layer
self.map.addCartodbLayerFromTable(tableName, userName, {

@ -174,6 +174,9 @@ describe Table do
end
it 'propagates privacy changes to the associated visualization' do
# Need to at least have this decorated in the user data or checks before becoming private will raise an error
CartoDB::Visualization::Member.any_instance.stubs(:supports_private_maps?).returns(true)
table = create_table(user_id: @user.id)
table.should be_private
table.table_visualization.should be_private
@ -201,6 +204,9 @@ describe Table do
it 'propagates changes to affected visualizations
if privacy set to PRIVATE' do
# Need to at least have this decorated in the user data or checks before becoming private will raise an error
CartoDB::Visualization::Member.any_instance.stubs(:supports_private_maps?).returns(true)
table = create_table(user_id: @user.id)
table.should be_private
table.table_visualization.should be_private
@ -220,6 +226,9 @@ describe Table do
end
it 'receives privacy changes from the associated visualization' do
# Need to at least have this decorated in the user data or checks before becoming private will raise an error
CartoDB::Visualization::Member.any_instance.stubs(:supports_private_maps?).returns(true)
table = create_table(user_id: @user.id)
table.should be_private
table.table_visualization.should be_private

@ -84,6 +84,9 @@ describe Visualization::Member do
end
it 'invalidates vizjson cache in varnish if privacy changed' do
# Need to at least have this decorated in the user data or checks before becoming private will raise an error
CartoDB::Visualization::Member.any_instance.stubs(:supports_private_maps?).returns(true)
member = Visualization::Member.new(random_attributes)
member.store

Loading…
Cancel
Save