Fix failing tests

pull/247/head
Rick Carlino 2016-05-09 10:08:42 -05:00
parent 2d77f9f4f6
commit 6b977380c3
6 changed files with 5 additions and 12 deletions

View File

@ -25,7 +25,6 @@ module Api
# DELETE /api/devices/1
def destroy
# TODO: Make a service that deletes old devices when they become 'orphans'
if current_device.users.include?(current_user)
current_device.destroy
render nothing: true, status: 204

View File

@ -16,13 +16,9 @@ module Api
end
def update
# This is a mess because of some Rails security precautions that are not
# relevant to this use case:
# http://guides.rubyonrails.org/security.html#unsafe-query-generation
steps = JSON.parse(request.body.read)["steps"]
mutate Sequences::Update.run(params[:sequence],
user: current_user,
steps: steps,
steps: params[:steps],
sequence: sequence)
end

View File

@ -25,6 +25,7 @@ module FarmBot
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.action_dispatch.perform_deep_munge = false
I18n.enforce_available_locales = false
config.generators do |g|
g.template_engine :haml

View File

@ -10,9 +10,10 @@ describe Api::DevicesController do
it 'destroys a Device' do
sign_in user
old_bot = user.device
delete :destroy, id: user.device.id, fromat: :json
user.reload
expect(user.device).to be_nil
expect(user.device._id).not_to eq(old_bot._id)
expect(response.status).to eq(204)
end
end

View File

@ -10,12 +10,8 @@ describe Api::DevicesController do
it 'handles deviceless requests' do
user.update_attributes(device: nil)
sign_in user
expect(user.device).to be_falsey
get :show, {}, format: :json
expect(user.reload.device).to be_kind_of(Device)
# expect(json[:error]).to eq("add device to account")
# expect(response.status).to eq(404)
end
end
end

View File

@ -20,7 +20,7 @@ describe Api::SequencesController do
z: 3,
speed: 100,
delay: 0} }] } }
patch :update, input
patch :update, input, {format: :json}
expect(response.status).to eq(200)
sequence.reload
expect(sequence.name).to eq(input[:sequence][:name])