Files
nairobi/spec/lib/tasks/map_location_spec.rb
Javi Martín 1a5b73a0bd Don't load tasks several times in specs
Calling `load_tasks` in several files made rails load the tasks several
times, and so they were executed several times when called.

Since the milestone migration can't be executed twice in a row (it would
fail with duplicated ID records), loading the tasks several times made
the milestone migrations task specs fail.
2018-11-30 14:15:21 +01:00

21 lines
555 B
Ruby

require 'rails_helper'
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