-
Create a new check
+ <%= t(".#{@check.kind}.title") %>
<%= render "form", check: @check %>
diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb
index 02f3c53..fccb7eb 100644
--- a/app/views/shared/_navbar.html.erb
+++ b/app/views/shared/_navbar.html.erb
@@ -8,10 +8,13 @@
<% if user_signed_in? %>
-
- <%= link_to("My checks", checks_path, class: "nav-link") %>
+ <%= link_to(t(".my_checks"), checks_path, class: "nav-link") %>
-
- <%= link_to("Add a check", new_check_path, class: "nav-link") %>
+ <%= link_to(t(".new_domain_check"), new_check_path(kind: :domain), class: "nav-link") %>
+
+ -
+ <%= link_to(t(".new_ssl_check"), new_check_path(kind: :ssl), class: "nav-link") %>
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9a34ad9..5bde33f 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -53,6 +53,9 @@ en:
en: English
fr: French
navbar:
+ my_checks: "My checks"
+ new_domain_check: "New domain check"
+ new_ssl_check: "New SSL check"
sign_up: "Sign up"
sign_in: "Sign in"
sign_out: "Sign out"
@@ -60,11 +63,30 @@ en:
checks:
index:
+ title: List of your checks
no_check_yet_html: |
You have not set up a check yet.
Please add a
domain
or a
ssl !
+
+ new:
+ title: New check
+ domain:
+ title: New domain check
+ ssl:
+ title: New SSL check
+
+ create:
+ saved: "Your check has been saved."
+ invalid: "Please check the form."
+
form:
+ generic:
+ domain: Domain
+ domain:
+ domain: Domain name
+ ssl:
+ domain: Hostname
notifications_hint: |
Receive notifications to warn you when our system detects that the
expiration date is coming. The time is set in number of days.
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index ed5926f..2477a7f 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -2,8 +2,15 @@ fr:
activerecord:
attributes:
check:
+ domain: "Domaine"
+ comment: "Commentaire"
+ vendor: "Fournisseur"
+ kind: Type
domain_created_at: "Date de création"
domain_updated_at: "Date de modification"
+ notification:
+ interval: Délai
+ recipient: Destinataire
user:
tos_accepted: "Conditions d'utilisation"
notifications_enabled: "Notifications activées"
@@ -11,6 +18,11 @@ fr:
models:
check:
past: "ne peut être dans le futur"
+ helpers:
+ submit:
+ check:
+ create: "Créer"
+ update: "Valider"
time:
am: am
@@ -61,6 +73,9 @@ fr:
en: Anglais
fr: Français
navbar:
+ my_checks: "Mes vérifications"
+ new_domain_check: "Nouveau nom de domaine"
+ new_ssl_check: "Nouveau certificat SSL"
sign_up: "Enregistrement"
sign_in: "Connexion"
sign_out: "Déconnexion"
@@ -68,11 +83,30 @@ fr:
checks:
index:
+ title: "Liste de vos vérifications"
no_check_yet_html: |
Vous n'avez pas encore créé de vérification.
Vous pouvez en ajouter pour un
domaine
ou un
SSL !
+
+ new:
+ title: Nouvelle vérification
+ domain:
+ title: Nouvelle vérification d'un nom de domaine
+ ssl:
+ title: Nouvelle vérification d'un certificat SSL
+
+ create:
+ saved: La vérification est enregistrée.
+ invalid: Veuillez vérifier le formulaire.
+
form:
+ generic:
+ domain: Domaine
+ domain:
+ domain: Nom de domaine
+ ssl:
+ domain: Nom d'hôte
notifications_hint: |
Recevez des notifications pour vous avertir lorsque notre système détecte
- que la date d'expiration approche. Le délais est indiqué ennombre de jours.
+ que la date d'expiration approche. Le délai est indiqué ennombre de jours.
diff --git a/test/controllers/checks_controller_test.rb b/test/controllers/checks_controller_test.rb
index 77435b7..98035cf 100644
--- a/test/controllers/checks_controller_test.rb
+++ b/test/controllers/checks_controller_test.rb
@@ -1,7 +1,34 @@
require "test_helper"
class ChecksControllerTest < ActionDispatch::IntegrationTest
- # test "the truth" do
- # assert true
- # end
+ setup do
+ @user = create(:user)
+ login_as(@user)
+ end
+
+ test "no logged users are redirected to signin form" do
+ logout
+ get new_check_path
+ assert_redirected_to new_user_session_path
+ end
+
+ test "new without kind does not trigger an error" do
+ get new_check_path
+ assert_response :success
+ end
+
+ test "new with kind domain does not trigger an error" do
+ get new_check_path(kind: :domain)
+ assert_response :success
+ end
+
+ test "new with kind ssl does not trigger an error" do
+ get new_check_path(kind: :ssl)
+ assert_response :success
+ end
+
+ test "new with an invalid kind returns an error" do
+ get new_check_path(kind: :invalid)
+ assert_response :not_found
+ end
end
diff --git a/test/system/checks_test.rb b/test/system/checks_test.rb
index 1fefa51..e7be944 100644
--- a/test/system/checks_test.rb
+++ b/test/system/checks_test.rb
@@ -8,29 +8,28 @@ class ChecksTest < ApplicationSystemTestCase
@check = create(:check, :with_notifications, user: @user)
end
- test "create a check and a notification" do
+ test "create a check and a notification without kind" do
visit new_check_path
- domain = "domain-test.fr"
- fill_in("check[domain]", with: domain)
choose "domain"
- recipient = "recipient@example.org"
- fill_in("check[notifications_attributes][0][recipient]", with: recipient)
- fill_in("check[notifications_attributes][0][interval]", with: 30)
+ fill_and_valid_new_check
+ end
- click_button
+ test "create a predefined domain check" do
+ visit new_check_path(kind: :domain)
- assert_equal checks_path, page.current_path
+ refute page.has_css? "domain[kind]"
- assert page.has_css?(".alert-success")
- assert page.has_content?(domain)
+ fill_and_valid_new_check
+ end
- notification = Notification.last
- assert_equal recipient, notification.recipient
- assert_equal 30, notification.interval
- assert notification.email?
- assert notification.pending?
+ test "create a predefined ssl check" do
+ visit new_check_path(kind: :ssl)
+
+ refute page.has_css? "domain[kind]"
+
+ fill_and_valid_new_check
end
test "remove a notification" do
@@ -83,4 +82,32 @@ class ChecksTest < ApplicationSystemTestCase
assert notification.email?
assert notification.pending?
end
+
+ private
+
+ # rubocop:disable Metrics/AbcSize
+ # rubocop:disable Metrics/MethodLength
+ def fill_and_valid_new_check
+ domain = "domain-test.fr"
+ fill_in("check[domain]", with: domain)
+
+ recipient = "recipient@example.org"
+ fill_in("check[notifications_attributes][0][recipient]", with: recipient)
+ fill_in("check[notifications_attributes][0][interval]", with: 30)
+
+ click_button
+
+ assert_equal checks_path, page.current_path
+
+ assert page.has_css?(".alert-success")
+ assert page.has_content?(domain)
+
+ notification = Notification.last
+ assert_equal recipient, notification.recipient
+ assert_equal 30, notification.interval
+ assert notification.email?
+ assert notification.pending?
+ end
+ # rubocop:enable Metrics/AbcSize
+ # rubocop:enable Metrics/MethodLength
end