Skip to content

Commit

Permalink
Merge pull request #1634 from FarmBot/staging
Browse files Browse the repository at this point in the history
v9.0.1 - Jolly Juniper
  • Loading branch information
RickCarlino committed Dec 19, 2019
2 parents f8575fb + d2549c0 commit 2fa3aa5
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/mutations/devices/update.rb
Expand Up @@ -12,6 +12,7 @@ class Update < Mutations::Command
time :last_saw_mq
time :last_ota
time :last_ota_checkup
boolean :needs_reset
integer :mounted_tool_id, nils: true
integer :ota_hour, nils: true
end
Expand Down
1 change: 1 addition & 0 deletions app/serializers/device_serializer.rb
Expand Up @@ -6,6 +6,7 @@ class DeviceSerializer < ApplicationSerializer
:last_saw_mq,
:mounted_tool_id,
:name,
:needs_reset,
:ota_hour,
:serial_number,
:throttled_at,
Expand Down
8 changes: 8 additions & 0 deletions db/migrate/20191219212755_add_needs_reset_to_devices.rb
@@ -0,0 +1,8 @@
class AddNeedsResetToDevices < ActiveRecord::Migration[6.0]
def change
add_column :devices,
:needs_reset,
:boolean,
default: false
end
end
86 changes: 81 additions & 5 deletions db/structure.sql
Expand Up @@ -276,7 +276,8 @@ CREATE TABLE public.devices (
mqtt_rate_limit_email_sent_at timestamp without time zone,
last_ota timestamp without time zone,
last_ota_checkup timestamp without time zone,
ota_hour integer DEFAULT 3
ota_hour integer DEFAULT 3,
needs_reset boolean DEFAULT false
);


Expand Down Expand Up @@ -663,6 +664,40 @@ CREATE SEQUENCE public.firmware_configs_id_seq
ALTER SEQUENCE public.firmware_configs_id_seq OWNED BY public.firmware_configs.id;


--
-- Name: folders; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.folders (
id bigint NOT NULL,
device_id bigint NOT NULL,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
color character varying(20) NOT NULL,
name character varying(40) NOT NULL,
parent_id integer
);


--
-- Name: folders_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.folders_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


--
-- Name: folders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.folders_id_seq OWNED BY public.folders.id;


--
-- Name: fragments; Type: TABLE; Schema: public; Owner: -
--
Expand Down Expand Up @@ -841,7 +876,8 @@ CREATE TABLE public.sequences (
kind character varying(280) DEFAULT 'sequence'::character varying,
updated_at timestamp without time zone,
created_at timestamp without time zone,
migrated_nodes boolean DEFAULT false
migrated_nodes boolean DEFAULT false,
folder_id bigint
);


Expand Down Expand Up @@ -1370,7 +1406,7 @@ CREATE VIEW public.resource_update_steps AS
edge_nodes.kind,
edge_nodes.value
FROM public.edge_nodes
WHERE (((edge_nodes.kind)::text = 'resource_type'::text) AND ((edge_nodes.value)::text = ANY ((ARRAY['"GenericPointer"'::character varying, '"ToolSlot"'::character varying, '"Plant"'::character varying])::text[])))
WHERE (((edge_nodes.kind)::text = 'resource_type'::text) AND ((edge_nodes.value)::text = ANY (ARRAY[('"GenericPointer"'::character varying)::text, ('"ToolSlot"'::character varying)::text, ('"Plant"'::character varying)::text])))
), resource_id AS (
SELECT edge_nodes.primary_node_id,
edge_nodes.kind,
Expand Down Expand Up @@ -1649,7 +1685,8 @@ CREATE TABLE public.users (
agreed_to_terms_at timestamp without time zone,
confirmation_sent_at timestamp without time zone,
unconfirmed_email character varying,
inactivity_warning_sent_at timestamp without time zone
inactivity_warning_sent_at timestamp without time zone,
inactivity_warning_count integer
);


Expand Down Expand Up @@ -1887,6 +1924,13 @@ ALTER TABLE ONLY public.fbos_configs ALTER COLUMN id SET DEFAULT nextval('public
ALTER TABLE ONLY public.firmware_configs ALTER COLUMN id SET DEFAULT nextval('public.firmware_configs_id_seq'::regclass);


--
-- Name: folders id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.folders ALTER COLUMN id SET DEFAULT nextval('public.folders_id_seq'::regclass);


--
-- Name: fragments id; Type: DEFAULT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -2203,6 +2247,14 @@ ALTER TABLE ONLY public.firmware_configs
ADD CONSTRAINT firmware_configs_pkey PRIMARY KEY (id);


--
-- Name: folders folders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.folders
ADD CONSTRAINT folders_pkey PRIMARY KEY (id);


--
-- Name: fragments fragments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -2575,6 +2627,13 @@ CREATE INDEX index_fbos_configs_on_device_id ON public.fbos_configs USING btree
CREATE INDEX index_firmware_configs_on_device_id ON public.firmware_configs USING btree (device_id);


--
-- Name: index_folders_on_device_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_folders_on_device_id ON public.folders USING btree (device_id);


--
-- Name: index_fragments_on_device_id; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -2904,6 +2963,13 @@ CREATE INDEX index_sequences_on_created_at ON public.sequences USING btree (crea
CREATE INDEX index_sequences_on_device_id ON public.sequences USING btree (device_id);


--
-- Name: index_sequences_on_folder_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_sequences_on_folder_id ON public.sequences USING btree (folder_id);


--
-- Name: index_standard_pairs_on_arg_name_id; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -3026,6 +3092,14 @@ ALTER TABLE ONLY public.pin_bindings
ADD CONSTRAINT fk_rails_1f1c3b6979 FOREIGN KEY (device_id) REFERENCES public.devices(id);


--
-- Name: folders fk_rails_58e285f76e; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.folders
ADD CONSTRAINT fk_rails_58e285f76e FOREIGN KEY (parent_id) REFERENCES public.folders(id);


--
-- Name: sensors fk_rails_92e56bf2fb; Type: FK CONSTRAINT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -3368,6 +3442,8 @@ INSERT INTO "schema_migrations" (version) VALUES
('20190930202839'),
('20191002125625'),
('20191107170431'),
('20191119204916');
('20191119204916'),
('20191203163621'),
('20191219212755');


12 changes: 8 additions & 4 deletions spec/controllers/dashboard_spec.rb
Expand Up @@ -10,13 +10,17 @@
expect(response.status).to eq(200)
end

it "renders the terms of service" do
it "renders the front page" do
get :front_page
expect(response.status).to eq(200)
# first entry in api_docs.md
SmarfDoc.note("Documentation generated for the " +
"[FarmBot Web App](https://github.com/FarmBot/Farmbot-Web-App).")
end

it "renders the terms of service" do
expect { get :main_app, params: { path: "nope.jpg" } }.to raise_error(ActionController::RoutingError)
it "returns error on invalid path" do
expect { get :main_app, params: { path: "nope.jpg" } }
.to raise_error(ActionController::RoutingError)
end

it "receives CSP violation reports (malformed JSON)" do
Expand All @@ -26,7 +30,7 @@
expect(json).to eq(problem: "Crashed while parsing report")
end

it "receives CSP violation reports (malformed JSON)" do
it "receives CSP violation reports (JSON)" do
post :csp_reports, body: {}.to_json, params: { format: :json }
expect(json).to eq({})
end
Expand Down
3 changes: 2 additions & 1 deletion spec/mutations/devices/update_spec.rb
Expand Up @@ -7,10 +7,11 @@

it 'updates an existing device' do
previous_name = device.name
p = { last_saw_mq: Time.now.utc, name: "Farmbot" }
p = { last_saw_mq: Time.now.utc, name: "Farmbot", needs_reset: true }
Devices::Update.run!({device: device}, p)
device.reload
expect(device.name).to eq(p[:name])
expect(device.needs_reset).to eq(p[:needs_reset])
expect(device.last_saw_mq.hour).to eq(p[:last_saw_mq].hour)
expect(device.last_saw_mq.min).to eq(p[:last_saw_mq].min)
end
Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -83,7 +83,9 @@ def clear!
config.order = "random"
if ENV["DOCS"]
config.after(:each, type: :controller) do
SmarfDoc.run!(NiceResponse.new(request), response)
if request.path.length > 0 || response.body.length > 0
SmarfDoc.run!(NiceResponse.new(request), response)
end
end

config.after(:suite) do
Expand Down

0 comments on commit 2fa3aa5

Please sign in to comment.