Empty instances of MapLocation won't result in a new DB record (#2220)

This commit is contained in:
Angel Perez
2018-01-08 11:46:32 -04:00
parent 6d3359dbbc
commit 665a5b57ab
7 changed files with 57 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
require 'rake'
require 'rails_helper'
Rails.application.load_tasks
describe 'rake map_locations:destroy' do
before do
create(:map_location, :proposal_map_location)
empty_location = create(:map_location, :proposal_map_location)
empty_location.attributes = { longitude: nil, latitude: nil, zoom: nil }
empty_location.save(validate: false)
end
let :run_rake_task do
Rake.application.invoke_task('map_locations:destroy')
end
it 'destroys empty locations' do
expect(MapLocation.all.size).to eq(2)
run_rake_task
expect(MapLocation.all.size).to eq(1)
end
end