diff --git a/app/controllers/rodauth_controller.rb b/app/controllers/rodauth_controller.rb
index b477d29..9703c74 100644
--- a/app/controllers/rodauth_controller.rb
+++ b/app/controllers/rodauth_controller.rb
@@ -28,6 +28,8 @@ class RodauthController < ApplicationController
private
def initialize_sidebar_items
+ return unless rodauth.logged_in?
+
[
{ label: "Profile", icon: :'person', path: profile_path, active: action_name == "profile" },
{ label: "Passwort ändern", icon: :'lock', path: rodauth.change_password_path, active: action_name == "change_password" },
diff --git a/app/views/rodauth/logout.html.erb b/app/views/rodauth/logout.html.erb
index e0d1b6c..2372d41 100644
--- a/app/views/rodauth/logout.html.erb
+++ b/app/views/rodauth/logout.html.erb
@@ -9,6 +9,6 @@
<% end %>
- <%= form.submit rodauth.logout_button, class: "btn btn-warning" %>
+ <%= form.submit "Log out", class: "btn btn-warning" %>
<% end %>
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
index bc7bf46..7988bd9 100644
--- a/test/application_system_test_case.rb
+++ b/test/application_system_test_case.rb
@@ -7,10 +7,29 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
options: { browser: :remote,
url: ENV.fetch("SELENIUM_REMOTE_URL", nil) })
- def setup
+ setup do
Capybara.server_host = "0.0.0.0" # bind to all interfaces
Capybara.app_host = "http://#{IPSocket.getaddress(Socket.gethostname)}" if ENV["SELENIUM_REMOTE_URL"].present?
+ end
- super
+ def app_host
+ "http://#{IPSocket.getaddress(Socket.gethostname)}"
+ end
+
+ def login(email, password)
+ visit "/login"
+ fill_in "Login", with: email
+ fill_in "Password", with: password
+ click_button "Login"
+ end
+
+ def logout
+ visit "/logout"
+ click_on "Log out"
+ end
+
+ def login_test
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
end
end
diff --git a/test/controllers/admin/backups_controller_test.rb b/test/controllers/admin/backups_controller_test.rb
index 3cca198..9ae75bc 100644
--- a/test/controllers/admin/backups_controller_test.rb
+++ b/test/controllers/admin/backups_controller_test.rb
@@ -4,6 +4,25 @@ require "test_helper"
module Admin
class BackupsControllerTest < ActionDispatch::IntegrationTest
+ def login(email, password)
+ post "/login", params: { email: email, password: password }
+ assert_redirected_to "/"
+ end
+
+ def logout
+ post "/logout"
+ assert_redirected_to "/"
+ end
+
+ teardown do
+ logout
+ end
+
+ setup do
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
+ end
+
test "should show admin_backup" do
get admin_backup_url(@admin_backup)
assert_response :success
diff --git a/test/controllers/backoffice_controller_test.rb b/test/controllers/backoffice_controller_test.rb
index 7c09854..8e1f237 100644
--- a/test/controllers/backoffice_controller_test.rb
+++ b/test/controllers/backoffice_controller_test.rb
@@ -1,8 +1,27 @@
require "test_helper"
class BackofficeControllerTest < ActionDispatch::IntegrationTest
+ def login(email, password)
+ post "/login", params: { email: email, password: password }
+ assert_redirected_to "/"
+ end
+
+ def logout
+ post "/logout"
+ assert_redirected_to "/"
+ end
+
+ teardown do
+ logout
+ end
+
+ setup do
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
+ end
+
test "should get show" do
- get backoffice_show_url
+ get backoffice_url
assert_response :success
end
end
diff --git a/test/controllers/checklist_entries_controller_test.rb b/test/controllers/checklist_entries_controller_test.rb
index fc21961..adba726 100644
--- a/test/controllers/checklist_entries_controller_test.rb
+++ b/test/controllers/checklist_entries_controller_test.rb
@@ -3,8 +3,24 @@
require "test_helper"
class ChecklistEntriesControllerTest < ActionDispatch::IntegrationTest
+ def login(email, password)
+ post "/login", params: { email: email, password: password }
+ assert_redirected_to "/"
+ end
+
+ def logout
+ post "/logout"
+ assert_redirected_to "/"
+ end
+
+ teardown do
+ logout
+ end
+
setup do
@checklist_entry = checklist_entries(:one)
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
end
test "should get index" do
diff --git a/test/controllers/checklists_controller_test.rb b/test/controllers/checklists_controller_test.rb
index 6fdaf63..83d8ad7 100644
--- a/test/controllers/checklists_controller_test.rb
+++ b/test/controllers/checklists_controller_test.rb
@@ -3,8 +3,24 @@
require "test_helper"
class ChecklistsControllerTest < ActionDispatch::IntegrationTest
+ def login(email, password)
+ post "/login", params: { email: email, password: password }
+ assert_redirected_to "/"
+ end
+
+ def logout
+ post "/logout"
+ assert_redirected_to "/"
+ end
+
+ teardown do
+ logout
+ end
+
setup do
@checklist = checklists(:one)
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
end
test "should get index" do
diff --git a/test/controllers/checks_controller_test.rb b/test/controllers/checks_controller_test.rb
index 1a65af3..ebcd0c9 100644
--- a/test/controllers/checks_controller_test.rb
+++ b/test/controllers/checks_controller_test.rb
@@ -3,9 +3,25 @@
require "test_helper"
class ChecksControllerTest < ActionDispatch::IntegrationTest
+ def login(email, password)
+ post "/login", params: { email: email, password: password }
+ assert_redirected_to "/"
+ end
+
+ def logout
+ post "/logout"
+ assert_redirected_to "/"
+ end
+
+ teardown do
+ logout
+ end
+
setup do
@principle = principles(:one)
@check = checks(:deletable)
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
end
test "should get index" do
diff --git a/test/controllers/elements_controller_test.rb b/test/controllers/elements_controller_test.rb
index f31c589..fb2f8e9 100644
--- a/test/controllers/elements_controller_test.rb
+++ b/test/controllers/elements_controller_test.rb
@@ -3,9 +3,25 @@
require "test_helper"
class ElementsControllerTest < ActionDispatch::IntegrationTest
+ def login(email, password)
+ post "/login", params: { email: email, password: password }
+ assert_redirected_to "/"
+ end
+
+ def logout
+ post "/logout"
+ assert_redirected_to "/"
+ end
+
+ teardown do
+ logout
+ end
+
setup do
@element = elements(:one)
@checklist = checklists(:one)
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
end
test "should get index" do
diff --git a/test/controllers/link_categories_controller_test.rb b/test/controllers/link_categories_controller_test.rb
index 5dc7ab1..144ee98 100644
--- a/test/controllers/link_categories_controller_test.rb
+++ b/test/controllers/link_categories_controller_test.rb
@@ -3,8 +3,24 @@
require "test_helper"
class LinkCategoriesControllerTest < ActionDispatch::IntegrationTest
+ def login(email, password)
+ post "/login", params: { email: email, password: password }
+ assert_redirected_to "/"
+ end
+
+ def logout
+ post "/logout"
+ assert_redirected_to "/"
+ end
+
+ teardown do
+ logout
+ end
+
setup do
@link_category = link_categories(:one)
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
end
test "should get index" do
diff --git a/test/controllers/links_controller_test.rb b/test/controllers/links_controller_test.rb
index a2ebc27..7e7bdc1 100644
--- a/test/controllers/links_controller_test.rb
+++ b/test/controllers/links_controller_test.rb
@@ -3,8 +3,24 @@
require "test_helper"
class LinksControllerTest < ActionDispatch::IntegrationTest
+ def login(email, password)
+ post "/login", params: { email: email, password: password }
+ assert_redirected_to "/"
+ end
+
+ def logout
+ post "/logout"
+ assert_redirected_to "/"
+ end
+
+ teardown do
+ logout
+ end
+
setup do
@link = links(:one)
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
end
test "should get index" do
diff --git a/test/controllers/public_controller_test.rb b/test/controllers/public_controller_test.rb
deleted file mode 100644
index 4118a7f..0000000
--- a/test/controllers/public_controller_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "test_helper"
-
-class PublicControllerTest < ActionDispatch::IntegrationTest
- test "should get root" do
- get public_root_url
- assert_response :success
- end
-end
diff --git a/test/controllers/reports_controller_test.rb b/test/controllers/reports_controller_test.rb
index b2e5c8d..00f9984 100644
--- a/test/controllers/reports_controller_test.rb
+++ b/test/controllers/reports_controller_test.rb
@@ -3,8 +3,24 @@
require "test_helper"
class ReportsControllerTest < ActionDispatch::IntegrationTest
+ def login(email, password)
+ post "/login", params: { email: email, password: password }
+ assert_redirected_to "/"
+ end
+
+ def logout
+ post "/logout"
+ assert_redirected_to "/"
+ end
+
+ teardown do
+ logout
+ end
+
setup do
@report = reports(:one)
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
end
test "should get index" do
diff --git a/test/controllers/success_criteria_controller_test.rb b/test/controllers/success_criteria_controller_test.rb
index 78d7954..b62c55c 100644
--- a/test/controllers/success_criteria_controller_test.rb
+++ b/test/controllers/success_criteria_controller_test.rb
@@ -3,8 +3,24 @@
require "test_helper"
class SuccessCriteriaControllerTest < ActionDispatch::IntegrationTest
+ def login(email, password)
+ post "/login", params: { email: email, password: password }
+ assert_redirected_to "/"
+ end
+
+ def logout
+ post "/logout"
+ assert_redirected_to "/"
+ end
+
+ teardown do
+ logout
+ end
+
setup do
@success_criterion = success_criteria(:one)
+ Account.create(email: "test@example.com", password: "password")
+ login("test@example.com", "password")
end
test "should get index" do
diff --git a/test/system/admin/backups_test.rb b/test/system/admin/backups_test.rb
index 269b39b..44df54a 100644
--- a/test/system/admin/backups_test.rb
+++ b/test/system/admin/backups_test.rb
@@ -4,6 +4,14 @@ require "application_system_test_case"
module Admin
class BackupsTest < ApplicationSystemTestCase
+ setup do
+ login_test
+ end
+
+ teardown do
+ logout
+ end
+
test "should create backup" do
visit admin_backup_url
diff --git a/test/system/checklists_test.rb b/test/system/checklists_test.rb
index a1b4af6..bdb8d81 100644
--- a/test/system/checklists_test.rb
+++ b/test/system/checklists_test.rb
@@ -5,6 +5,11 @@ require "application_system_test_case"
class ChecklistsTest < ApplicationSystemTestCase
setup do
@checklist = checklists(:one)
+ login_test
+ end
+
+ teardown do
+ logout
end
test "visiting the index" do
diff --git a/test/system/checks_test.rb b/test/system/checks_test.rb
index 4420c91..840e81e 100644
--- a/test/system/checks_test.rb
+++ b/test/system/checks_test.rb
@@ -6,6 +6,11 @@ class ChecksTest < ApplicationSystemTestCase
setup do
@check = checks(:one)
@deletable_check = checks(:deletable)
+ login_test
+ end
+
+ teardown do
+ logout
end
test "visiting the index" do
diff --git a/test/system/elements_test.rb b/test/system/elements_test.rb
index 72fc129..6e7a99f 100644
--- a/test/system/elements_test.rb
+++ b/test/system/elements_test.rb
@@ -5,6 +5,11 @@ require "application_system_test_case"
class ElementsTest < ApplicationSystemTestCase
setup do
@element = elements(:one)
+ login_test
+ end
+
+ teardown do
+ logout
end
test "visiting the index" do
diff --git a/test/system/link_categories_test.rb b/test/system/link_categories_test.rb
index e0321c7..fddeb29 100644
--- a/test/system/link_categories_test.rb
+++ b/test/system/link_categories_test.rb
@@ -5,6 +5,11 @@ require "application_system_test_case"
class LinkCategoriesTest < ApplicationSystemTestCase
setup do
@link_category = link_categories(:one)
+ login_test
+ end
+
+ teardown do
+ logout
end
test "visiting the index" do
diff --git a/test/system/links_test.rb b/test/system/links_test.rb
index 5802167..777ca28 100644
--- a/test/system/links_test.rb
+++ b/test/system/links_test.rb
@@ -5,6 +5,11 @@ require "application_system_test_case"
class LinksTest < ApplicationSystemTestCase
setup do
@link = links(:one)
+ login_test
+ end
+
+ teardown do
+ logout
end
test "visiting the index" do
diff --git a/test/system/reports_test.rb b/test/system/reports_test.rb
index c8936e3..7c70110 100644
--- a/test/system/reports_test.rb
+++ b/test/system/reports_test.rb
@@ -5,6 +5,11 @@ require "application_system_test_case"
class ReportsTest < ApplicationSystemTestCase
setup do
@report = reports(:one)
+ login_test
+ end
+
+ teardown do
+ logout
end
test "visiting the index" do
@@ -33,7 +38,7 @@ class ReportsTest < ApplicationSystemTestCase
test "should destroy Report" do
visit report_url(@report)
click_on "Prüfbericht löschen", match: :first
-
+ assert_text("Report was successfully destroyed")
assert(Report.exists?(@report.id) == false)
end
end
diff --git a/test/system/success_criteria_test.rb b/test/system/success_criteria_test.rb
index 6cb3e5f..6529f72 100644
--- a/test/system/success_criteria_test.rb
+++ b/test/system/success_criteria_test.rb
@@ -3,8 +3,13 @@
require "application_system_test_case"
class SuccessCriteriaTest < ApplicationSystemTestCase
+ teardown do
+ logout
+ end
+
setup do
@success_criterion = success_criteria(:one)
+ login_test
end
test "visiting the index" do