Resetting account should reset `settings_device_name` to "FarmBot"

pull/1190/head
Rick Carlino 2019-05-11 15:34:01 -05:00
parent b794c60bb7
commit c64722af96
2 changed files with 13 additions and 8 deletions

View File

@ -19,15 +19,18 @@ module Devices
private
def run_it
Device::SINGULAR_RESOURCES.keys.map do |resource|
device.send(resource).destroy!
end
ActiveRecord::Base.transaction do
device.update_attributes!(name: "FarmBot")
Device::SINGULAR_RESOURCES.keys.map do |resource|
device.send(resource).destroy!
end
Device::PLURAL_RESOURCES.without(:token_issuances).map do |resources|
device.send(resources).destroy_all
end
Device::PLURAL_RESOURCES.without(:token_issuances).map do |resources|
device.send(resources).destroy_all
end
Alerts::Create.run!(Alert::SEED_DATA.merge(device: device))
Alerts::Create.run!(Alert::SEED_DATA.merge(device: device))
end
end
def user

View File

@ -22,6 +22,8 @@ describe Api::DevicesController do
expect(device.send(resource.pluralize).reload.count).to be > 0
end
device.update_attributes(name: "#{SecureRandom.hex(10)}")
run_jobs_now { post :reset, params: { password: password } }
resources
@ -33,7 +35,7 @@ describe Api::DevicesController do
fail(did_not_delete)
end
end
expect(device.reload.name).to eq("FarmBot")
expect(device.alerts.count).to eq(1)
expect(device.token_issuances.count).to_not be > 1
end