Skip to content

Commit

Permalink
Set default plant_status on weed types to "active"
Browse files Browse the repository at this point in the history
  • Loading branch information
RickCarlino committed May 12, 2020
1 parent 3dc7bfb commit 4af481c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/celery_script_settings_bag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def self.exists?(id)
ONLY_ONE_COORD = "Move Absolute does not accept a group of locations " \
"as input. Please change your selection to a single" \
" location."
PLANT_STAGES = %w(planned planted harvested sprouted removed)
PLANT_STAGES = %w(planned planted harvested sprouted active removed)
SCOPE_DECLARATIONS = [:variable_declaration, :parameter_declaration]
MISC_ENUM_ERR = '"%s" is not valid. Allowed values: %s'
MAX_WAIT_MS = 1000 * 60 * 3 # Three Minutes
Expand Down
1 change: 1 addition & 0 deletions app/mutations/points/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def validate
end

def execute
inputs[:plant_stage] ||= "active" if pointer_type == "Weed"
klass_.create!(inputs)
end

Expand Down
20 changes: 15 additions & 5 deletions spec/controllers/api/points/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
expect(json[:y]).to eq(payload[:y])
expect(json[:z]).to eq(payload[:z])
end
it "creates a weed" do
sign_in user
p = { x: 23, y: 45, pointer_type: "Weed" }
post :create, body: p.to_json, params: { format: :json }
expect(response.status).to eq(200)
weed = Weed.last
expect(weed.x).to eq(p[:x])
expect(weed.y).to eq(p[:y])
expect(weed.plant_stage).to eq("active")
end

it "creates a plant" do
sign_in user
Expand Down Expand Up @@ -158,11 +168,11 @@
it "disallows bad `tool_id`s" do
sign_in user
payload = { pointer_type: "ToolSlot",
name: "foo",
x: 0,
y: 0,
z: 0,
tool_id: (Tool.count + 100) }
name: "foo",
x: 0,
y: 0,
z: 0,
tool_id: (Tool.count + 100) }
old_tool_count = ToolSlot.count
post :create, body: payload.to_json, params: { format: :json }
expect(response.status).to eq(422)
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/api/webcam_feeds/create_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'spec_helper'
require "spec_helper"

describe Api::WebcamFeedsController do
let(:user) { FactoryBot.create(:user) }
include Devise::Test::ControllerHelpers

it 'creates a webcam feed' do
it "creates a webcam feed" do
sign_in user
input = { name: "name1", url: "url1" }
b4 = WebcamFeed.count
Expand Down

0 comments on commit 4af481c

Please sign in to comment.