From b5d3c957c1e700ba90cd53b4f325934938864a9f Mon Sep 17 00:00:00 2001 From: Juliette Cougnoux Date: Wed, 25 Jul 2018 11:57:07 +0200 Subject: [PATCH] Adding round robin checkbox in ssl checks form and in checks table. --- app/controllers/checks_controller.rb | 5 +++-- app/models/check.rb | 2 +- app/views/checks/_form.html.erb | 6 +++++- db/migrate/20180724075445_add_roundrobin_to_checks.rb | 7 +++++++ db/schema.rb | 1 + test/factories/checks.rb | 2 +- test/models/check_test.rb | 2 +- 7 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20180724075445_add_roundrobin_to_checks.rb diff --git a/app/controllers/checks_controller.rb b/app/controllers/checks_controller.rb index 0029c81..da16fe8 100644 --- a/app/controllers/checks_controller.rb +++ b/app/controllers/checks_controller.rb @@ -81,8 +81,9 @@ class ChecksController < ApplicationController end def check_params(*others) - params.require(:check).permit(:domain, :domain_created_at, :comment, :vendor, *others, - notifications_attributes: [:id, :channel, :recipient, :interval]) + params.require(:check) + .permit(:domain, :domain_created_at, :comment, :vendor, :round_robin, *others, + notifications_attributes: [:id, :channel, :recipient, :interval]) end def build_empty_notification diff --git a/app/models/check.rb b/app/models/check.rb index 5aa1b2e..446c8b6 100644 --- a/app/models/check.rb +++ b/app/models/check.rb @@ -1,6 +1,5 @@ # Copyright (C) 2018 Colin Darie , 2018 Jeremy Lecour , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) - # == Schema Information # # Table name: checks @@ -16,6 +15,7 @@ # kind :integer not null # last_run_at :datetime # last_success_at :datetime +# round_robin :boolean default(TRUE) # vendor :string(255) # created_at :datetime not null # updated_at :datetime not null diff --git a/app/views/checks/_form.html.erb b/app/views/checks/_form.html.erb index cffce68..4f8b586 100644 --- a/app/views/checks/_form.html.erb +++ b/app/views/checks/_form.html.erb @@ -12,7 +12,11 @@ <%= f.input :comment %> <%= f.input :vendor %> - + + <% if check.ssl? %> + <%= f.input :round_robin %> + <% end %> + <% if check.persisted? %> <%= f.input :active %> <% end %> diff --git a/db/migrate/20180724075445_add_roundrobin_to_checks.rb b/db/migrate/20180724075445_add_roundrobin_to_checks.rb new file mode 100644 index 0000000..025e0bb --- /dev/null +++ b/db/migrate/20180724075445_add_roundrobin_to_checks.rb @@ -0,0 +1,7 @@ +# Copyright (C) 2018 Juliette Cougnoux , 2018 Evolix +# License: GNU AGPL-3+ (see full text in LICENSE file) +class AddRoundrobinToChecks < ActiveRecord::Migration[5.2] + def change + add_column :checks, :round_robin, :boolean, default: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 024d864..71fba1b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -38,6 +38,7 @@ ActiveRecord::Schema.define(version: 2018_08_01_072038) do t.boolean "active", default: true, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.boolean "round_robin", default: true t.integer "consecutive_failures", default: 0, null: false t.index ["user_id"], name: "index_checks_on_user_id" end diff --git a/test/factories/checks.rb b/test/factories/checks.rb index a0a7ff3..af5ca25 100644 --- a/test/factories/checks.rb +++ b/test/factories/checks.rb @@ -1,6 +1,5 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) - # == Schema Information # # Table name: checks @@ -16,6 +15,7 @@ # kind :integer not null # last_run_at :datetime # last_success_at :datetime +# round_robin :boolean default(TRUE) # vendor :string(255) # created_at :datetime not null # updated_at :datetime not null diff --git a/test/models/check_test.rb b/test/models/check_test.rb index f2074cb..f5240c9 100644 --- a/test/models/check_test.rb +++ b/test/models/check_test.rb @@ -1,6 +1,5 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) - # == Schema Information # # Table name: checks @@ -16,6 +15,7 @@ # kind :integer not null # last_run_at :datetime # last_success_at :datetime +# round_robin :boolean default(TRUE) # vendor :string(255) # created_at :datetime not null # updated_at :datetime not null