cartodb/spec/lib/tasks/fix_unique_overlays_spec.rb

29 lines
1007 B
Ruby
Raw Normal View History

2020-06-15 10:58:47 +08:00
require 'spec_helper_min'
require 'rake'
require_relative '../../../app/models/visualization/member'
require_relative '../../../app/models/visualization/overlays'
describe 'cartodb:fix_unique_overlays' do
before(:each) do
Rake.application.rake_require "tasks/fix_unique_overlays"
Rake::Task.define_task(:environment)
member = Visualization::Member.new
@visualization = member
end
it 'deletes duplicate overlays of unique type' do
Visualization::Overlays.new(@visualization).create_default_overlays
dup_overlay = Carto::Overlay.new(visualization_id: @visualization.id, type: 'logo')
dup_overlay.save(validate: false)
dup_overlay = Carto::Overlay.new(visualization_id: @visualization.id, type: 'logo')
dup_overlay.save(validate: false)
@visualization.overlays.select { |o| o.type == 'logo' }.count.should eq 3
Rake.application['cartodb:fix_unique_overlays'].invoke
@visualization.overlays.select { |o| o.type == 'logo' }.count.should eq 1
end
end