Merge branch 'internal_use' into global_messages
commit
7cc81bee41
|
@ -2,6 +2,11 @@
|
|||
class WebAppConfig < ApplicationRecord
|
||||
belongs_to :device
|
||||
|
||||
def internal_use=(data)
|
||||
Rollbar.error("Internal data update use", { object_id: self.id })
|
||||
super(data)
|
||||
end
|
||||
|
||||
def broadcast?
|
||||
false
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddInternalUseFieldToWebAppConfigs < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :web_app_configs, :internal_use, :text, limit: 128
|
||||
end
|
||||
end
|
|
@ -353,7 +353,8 @@ CREATE TABLE public.farmware_installations (
|
|||
url character varying,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
package character varying(80)
|
||||
package character varying(80),
|
||||
package_error character varying
|
||||
);
|
||||
|
||||
|
||||
|
@ -1470,7 +1471,8 @@ CREATE TABLE public.web_app_configs (
|
|||
show_motor_plot boolean DEFAULT false,
|
||||
show_historic_points boolean DEFAULT false,
|
||||
show_sensor_readings boolean DEFAULT false,
|
||||
show_dev_menu boolean DEFAULT false
|
||||
show_dev_menu boolean DEFAULT false,
|
||||
internal_use text
|
||||
);
|
||||
|
||||
|
||||
|
@ -2816,6 +2818,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20190103213956'),
|
||||
('20190108211419'),
|
||||
('20190209133811'),
|
||||
('20190212215842');
|
||||
('20190212215842'),
|
||||
('20190307205648');
|
||||
|
||||
|
||||
|
|
|
@ -1,46 +1,45 @@
|
|||
require 'spec_helper'
|
||||
require "spec_helper"
|
||||
|
||||
describe Api::WebAppConfigsController do
|
||||
|
||||
include Devise::Test::ControllerHelpers
|
||||
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
let(:device) { user.device }
|
||||
|
||||
describe '#show' do
|
||||
it 'handles requests' do
|
||||
describe "#show" do
|
||||
it "handles requests" do
|
||||
sign_in user
|
||||
device.web_app_config.destroy! # Let's test defaults.
|
||||
get :show, format: :json
|
||||
expect(response.status).to eq(200)
|
||||
{
|
||||
:confirm_step_deletion => false,
|
||||
:disable_animations => false,
|
||||
:disable_i18n => false,
|
||||
:display_trail => false,
|
||||
:dynamic_map => false,
|
||||
:encoder_figure => false,
|
||||
:hide_webcam_widget => false,
|
||||
:legend_menu_open => false,
|
||||
:map_xl => false,
|
||||
:raw_encoders => false,
|
||||
:scaled_encoders => false,
|
||||
:show_spread => false,
|
||||
:show_farmbot => true,
|
||||
:show_plants => true,
|
||||
:show_points => true,
|
||||
:x_axis_inverted => false,
|
||||
:y_axis_inverted => false,
|
||||
:z_axis_inverted => false,
|
||||
:bot_origin_quadrant => 2,
|
||||
:zoom_level => 1,
|
||||
:success_log => 1,
|
||||
:busy_log => 1,
|
||||
:warn_log => 1,
|
||||
:error_log => 1,
|
||||
:info_log => 1,
|
||||
:fun_log => 1,
|
||||
:debug_log => 1,
|
||||
confirm_step_deletion: false,
|
||||
disable_animations: false,
|
||||
disable_i18n: false,
|
||||
display_trail: false,
|
||||
dynamic_map: false,
|
||||
encoder_figure: false,
|
||||
hide_webcam_widget: false,
|
||||
legend_menu_open: false,
|
||||
map_xl: false,
|
||||
raw_encoders: false,
|
||||
scaled_encoders: false,
|
||||
show_spread: false,
|
||||
show_farmbot: true,
|
||||
show_plants: true,
|
||||
show_points: true,
|
||||
x_axis_inverted: false,
|
||||
y_axis_inverted: false,
|
||||
z_axis_inverted: false,
|
||||
bot_origin_quadrant: 2,
|
||||
zoom_level: 1,
|
||||
success_log: 1,
|
||||
busy_log: 1,
|
||||
warn_log: 1,
|
||||
error_log: 1,
|
||||
info_log: 1,
|
||||
fun_log: 1,
|
||||
debug_log: 1,
|
||||
}.to_a.map { |key, value| expect(json[key]).to eq(value) }
|
||||
|
||||
{ created_at: String, updated_at: String }
|
||||
|
@ -48,10 +47,12 @@ describe Api::WebAppConfigsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
it 'handles update requests' do
|
||||
describe "#update" do
|
||||
it "handles update requests" do
|
||||
sign_in user
|
||||
body = { info_log: 23, bot_origin_quadrant: -1 }
|
||||
body = { info_log: 23, bot_origin_quadrant: -1, internal_use: "null" }
|
||||
calls = { object_id: user.device.web_app_config.id }
|
||||
expect(Rollbar).to receive(:error).with("Internal data update use", calls)
|
||||
body.to_a.map { |key, val| expect(device.web_app_config.send(key)).not_to eq(val) }
|
||||
put :update, body: body.to_json, params: { format: :json }
|
||||
expect(response.status).to eq(200)
|
||||
|
@ -62,7 +63,7 @@ describe Api::WebAppConfigsController do
|
|||
end
|
||||
end
|
||||
|
||||
it 'disallows mass assignment attacks against device_id' do
|
||||
it "disallows mass assignment attacks against device_id" do
|
||||
sign_in user
|
||||
body = { device_id: 99 }
|
||||
conf = device.web_app_config
|
||||
|
@ -73,8 +74,8 @@ describe Api::WebAppConfigsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#delete' do
|
||||
it 'resets everything to the defaults' do
|
||||
describe "#delete" do
|
||||
it "resets everything to the defaults" do
|
||||
sign_in user
|
||||
old_conf = device.web_app_config
|
||||
old_conf.update_attributes(zoom_level: 23)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'spec_helper'
|
||||
require "spec_helper"
|
||||
|
||||
describe DashboardController do
|
||||
include Devise::Test::ControllerHelpers
|
||||
let(:user) { FactoryBot.create(:user, confirmed_at: nil) }
|
||||
|
||||
describe 'dashboard endpoint' do
|
||||
describe "dashboard endpoint" do
|
||||
it "renders the terms of service" do
|
||||
get :tos_update
|
||||
expect(response.status).to eq(200)
|
||||
|
@ -16,24 +16,22 @@ describe DashboardController do
|
|||
end
|
||||
|
||||
it "renders the terms of service" do
|
||||
expect { get :main_app, params: {path: "nope.jpg"} }
|
||||
.to raise_error(ActionController::RoutingError)
|
||||
expect { get :main_app, params: { path: "nope.jpg" } }.to raise_error(ActionController::RoutingError)
|
||||
end
|
||||
|
||||
it "receives CSP violation reports (malformed JSON)" do
|
||||
expect(Rollbar).to receive(:info)
|
||||
.with("CSP Violation", {problem: "Crashed while parsing report"})
|
||||
.with("CSP Violation", { problem: "Crashed while parsing report" })
|
||||
post :csp_reports, body: "NOT JSON ! ! !"
|
||||
end
|
||||
|
||||
it "receives CSP violation reports (malformed JSON)" do
|
||||
expect(Rollbar).to receive(:info)
|
||||
.with("CSP Violation", {})
|
||||
post :csp_reports, body: {}.to_json, params: {format: :json}
|
||||
expect(Rollbar).to receive(:info).with("CSP Violation", {})
|
||||
post :csp_reports, body: {}.to_json, params: { format: :json }
|
||||
end
|
||||
|
||||
it 'creates a new user' do
|
||||
params = { token: user.confirmation_token }
|
||||
it "creates a new user" do
|
||||
params = { token: user.confirmation_token }
|
||||
expect(user.confirmed_at).to eq(nil)
|
||||
get :confirmation_page, params: params
|
||||
user.reload
|
||||
|
@ -42,19 +40,19 @@ describe DashboardController do
|
|||
expect(user.confirmed_at - Time.now).to be < 3
|
||||
end
|
||||
|
||||
it 'verifies email changes' do
|
||||
it "verifies email changes" do
|
||||
email = "foo@bar.com"
|
||||
user.update_attributes!(unconfirmed_email: "foo@bar.com")
|
||||
params = { token: user.confirmation_token }
|
||||
params = { token: user.confirmation_token }
|
||||
get :confirmation_page, params: params
|
||||
expect(user.reload.unconfirmed_email).to be nil
|
||||
expect(user.email).to eq email
|
||||
end
|
||||
|
||||
it 'handles self hosted image uploads' do
|
||||
name = "wow.jpg"
|
||||
params = {key: "whatever/" + name,
|
||||
file: StringIO.new(File.open("./spec/fixture.jpg").read)}
|
||||
it "handles self hosted image uploads" do
|
||||
name = "wow.jpg"
|
||||
params = { key: "whatever/" + name,
|
||||
file: StringIO.new(File.open("./spec/fixture.jpg").read) }
|
||||
post :direct_upload, params: params
|
||||
file = File.join("public", "direct_upload", "temp", name)
|
||||
expect(File.file?(file)).to be(true)
|
||||
|
|
Loading…
Reference in New Issue