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.
21 lines
555 B
Ruby
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
|