Move tasks folder back into lib
parent
c46f0602a9
commit
6e07a23cfd
|
@ -0,0 +1,31 @@
|
||||||
|
module Api
|
||||||
|
class ToolBaysController < Api::AbstractController
|
||||||
|
def show
|
||||||
|
render json: tool_bay
|
||||||
|
end
|
||||||
|
|
||||||
|
def index
|
||||||
|
render json: tool_bays
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
mutate ToolBays::Update.run(tool_bay_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def tool_bay
|
||||||
|
@tool_bay ||= tool_bays.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def tool_bay_params
|
||||||
|
{ device: current_device,
|
||||||
|
tool_bay: tool_bay,
|
||||||
|
name: params[:name] }
|
||||||
|
end
|
||||||
|
|
||||||
|
def tool_bays
|
||||||
|
@tool_bays ||= current_device.tool_bays
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,21 +1,23 @@
|
||||||
class Api::ToolsController < ApplicationController
|
module Api
|
||||||
def create
|
class ToolsController < Api::AbstractController
|
||||||
raise "Not implemented yet"
|
def create
|
||||||
|
raise "Not implemented yet"
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
raise "Not implemented yet"
|
||||||
|
end
|
||||||
|
|
||||||
|
def index
|
||||||
|
raise "Not implemented yet"
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
raise "Not implemented yet"
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
raise "Not implemented yet"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
def show
|
|
||||||
raise "Not implemented yet"
|
|
||||||
end
|
|
||||||
|
|
||||||
def index
|
|
||||||
raise "Not implemented yet"
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
raise "Not implemented yet"
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
raise "Not implemented yet"
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -5,10 +5,11 @@ class DashboardController < ApplicationController
|
||||||
# support HTML5 push state routing.
|
# support HTML5 push state routing.
|
||||||
# If anyone knows a better way to support push state routing, please let me
|
# If anyone knows a better way to support push state routing, please let me
|
||||||
# know.
|
# know.
|
||||||
THE_FRONTEND_APP = File.read("public/app/index.html") # Cache in memory.
|
THE_FRONTEND_APP = File.read("public/app/index.html").html_safe # Cache in memory.
|
||||||
ACME_SECRET = ENV["ACME_SECRET"]
|
ACME_SECRET = ENV["ACME_SECRET"]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
render html: THE_FRONTEND_APP.html_safe, layout: false
|
render html: THE_FRONTEND_APP, layout: false
|
||||||
end
|
end
|
||||||
|
|
||||||
# This endpoint gets hit by Certbot / Let's Encrypt when its time to verify
|
# This endpoint gets hit by Certbot / Let's Encrypt when its time to verify
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
module ToolBays
|
||||||
|
class Update < Mutations::Command
|
||||||
|
required do
|
||||||
|
model :device, class: Device
|
||||||
|
model :tool_bay, class: ToolBay
|
||||||
|
end
|
||||||
|
|
||||||
|
optional do
|
||||||
|
string :name
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute
|
||||||
|
tool_bay.update_attributes!(update_params) && tool_bay
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def update_params
|
||||||
|
inputs.except(:device, :tool_bay)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -13,7 +13,9 @@ FarmBot::Application.routes.draw do
|
||||||
resources :schedules, only: [:create, :update, :destroy, :index]
|
resources :schedules, only: [:create, :update, :destroy, :index]
|
||||||
resources :peripherals, only: [:create, :destroy, :index]
|
resources :peripherals, only: [:create, :destroy, :index]
|
||||||
resources :corpuses, only: [:index, :show]
|
resources :corpuses, only: [:index, :show]
|
||||||
# resources :tools, only: [:create, :show, :index, :destroy, :update]
|
resources :tool_bays, only: [:show, :index, :update]
|
||||||
|
# resources :tool_slots, only: [:create, :show, :index, :destroy, :update]
|
||||||
|
# resources :tools, only: [:create, :show, :index, :destroy, :update]
|
||||||
end
|
end
|
||||||
|
|
||||||
devise_for :users
|
devise_for :users
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require_relative '../key_gen'
|
require_relative '../../app/lib/key_gen'
|
||||||
|
|
||||||
namespace :keys do
|
namespace :keys do
|
||||||
desc "Reset RSA keys used for signing / verifying tokens."
|
desc "Reset RSA keys used for signing / verifying tokens."
|
|
@ -0,0 +1,18 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Api::ToolBaysController do
|
||||||
|
include Devise::Test::ControllerHelpers
|
||||||
|
describe '#update' do
|
||||||
|
let(:user) { FactoryGirl.create(:user) }
|
||||||
|
let(:tool_bay) { FactoryGirl.create(:tool_bay, device: user.device) }
|
||||||
|
it 'updates a tool bay' do
|
||||||
|
sign_in user
|
||||||
|
payload = { name: "Fooo", id: tool_bay.id }
|
||||||
|
patch :update, params: payload
|
||||||
|
expect(tool_bay.name).not_to eq(payload[:name])
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
expect(tool_bay.name).to eq(payload[:name])
|
||||||
|
expect(json[:name]).to eq(payload[:name])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue