Fix tests
Some checks failed
/ Run tests (push) Failing after 55s
/ Run system tests (push) Failing after 55s
/ Build, push and deploy image (push) Has been skipped

This commit is contained in:
david 2024-09-22 22:49:53 +02:00
parent fbf6923835
commit 6e1a17281d
22 changed files with 235 additions and 13 deletions

View file

@ -28,6 +28,8 @@ class RodauthController < ApplicationController
private private
def initialize_sidebar_items def initialize_sidebar_items
return unless rodauth.logged_in?
[ [
{ label: "Profile", icon: :'person', path: profile_path, active: action_name == "profile" }, { 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" }, { label: "Passwort ändern", icon: :'lock', path: rodauth.change_password_path, active: action_name == "change_password" },

View file

@ -9,6 +9,6 @@
<% end %> <% end %>
<div class="form-group mb-3"> <div class="form-group mb-3">
<%= form.submit rodauth.logout_button, class: "btn btn-warning" %> <%= form.submit "Log out", class: "btn btn-warning" %>
</div> </div>
<% end %> <% end %>

View file

@ -7,10 +7,29 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
options: { browser: :remote, options: { browser: :remote,
url: ENV.fetch("SELENIUM_REMOTE_URL", nil) }) url: ENV.fetch("SELENIUM_REMOTE_URL", nil) })
def setup setup do
Capybara.server_host = "0.0.0.0" # bind to all interfaces 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? 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
end end

View file

@ -4,6 +4,25 @@ require "test_helper"
module Admin module Admin
class BackupsControllerTest < ActionDispatch::IntegrationTest 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 test "should show admin_backup" do
get admin_backup_url(@admin_backup) get admin_backup_url(@admin_backup)
assert_response :success assert_response :success

View file

@ -1,8 +1,27 @@
require "test_helper" require "test_helper"
class BackofficeControllerTest < ActionDispatch::IntegrationTest 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 test "should get show" do
get backoffice_show_url get backoffice_url
assert_response :success assert_response :success
end end
end end

View file

@ -3,8 +3,24 @@
require "test_helper" require "test_helper"
class ChecklistEntriesControllerTest < ActionDispatch::IntegrationTest 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 setup do
@checklist_entry = checklist_entries(:one) @checklist_entry = checklist_entries(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end end
test "should get index" do test "should get index" do

View file

@ -3,8 +3,24 @@
require "test_helper" require "test_helper"
class ChecklistsControllerTest < ActionDispatch::IntegrationTest 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 setup do
@checklist = checklists(:one) @checklist = checklists(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end end
test "should get index" do test "should get index" do

View file

@ -3,9 +3,25 @@
require "test_helper" require "test_helper"
class ChecksControllerTest < ActionDispatch::IntegrationTest 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 setup do
@principle = principles(:one) @principle = principles(:one)
@check = checks(:deletable) @check = checks(:deletable)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end end
test "should get index" do test "should get index" do

View file

@ -3,9 +3,25 @@
require "test_helper" require "test_helper"
class ElementsControllerTest < ActionDispatch::IntegrationTest 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 setup do
@element = elements(:one) @element = elements(:one)
@checklist = checklists(:one) @checklist = checklists(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end end
test "should get index" do test "should get index" do

View file

@ -3,8 +3,24 @@
require "test_helper" require "test_helper"
class LinkCategoriesControllerTest < ActionDispatch::IntegrationTest 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 setup do
@link_category = link_categories(:one) @link_category = link_categories(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end end
test "should get index" do test "should get index" do

View file

@ -3,8 +3,24 @@
require "test_helper" require "test_helper"
class LinksControllerTest < ActionDispatch::IntegrationTest 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 setup do
@link = links(:one) @link = links(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end end
test "should get index" do test "should get index" do

View file

@ -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

View file

@ -3,8 +3,24 @@
require "test_helper" require "test_helper"
class ReportsControllerTest < ActionDispatch::IntegrationTest 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 setup do
@report = reports(:one) @report = reports(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end end
test "should get index" do test "should get index" do

View file

@ -3,8 +3,24 @@
require "test_helper" require "test_helper"
class SuccessCriteriaControllerTest < ActionDispatch::IntegrationTest 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 setup do
@success_criterion = success_criteria(:one) @success_criterion = success_criteria(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end end
test "should get index" do test "should get index" do

View file

@ -4,6 +4,14 @@ require "application_system_test_case"
module Admin module Admin
class BackupsTest < ApplicationSystemTestCase class BackupsTest < ApplicationSystemTestCase
setup do
login_test
end
teardown do
logout
end
test "should create backup" do test "should create backup" do
visit admin_backup_url visit admin_backup_url

View file

@ -5,6 +5,11 @@ require "application_system_test_case"
class ChecklistsTest < ApplicationSystemTestCase class ChecklistsTest < ApplicationSystemTestCase
setup do setup do
@checklist = checklists(:one) @checklist = checklists(:one)
login_test
end
teardown do
logout
end end
test "visiting the index" do test "visiting the index" do

View file

@ -6,6 +6,11 @@ class ChecksTest < ApplicationSystemTestCase
setup do setup do
@check = checks(:one) @check = checks(:one)
@deletable_check = checks(:deletable) @deletable_check = checks(:deletable)
login_test
end
teardown do
logout
end end
test "visiting the index" do test "visiting the index" do

View file

@ -5,6 +5,11 @@ require "application_system_test_case"
class ElementsTest < ApplicationSystemTestCase class ElementsTest < ApplicationSystemTestCase
setup do setup do
@element = elements(:one) @element = elements(:one)
login_test
end
teardown do
logout
end end
test "visiting the index" do test "visiting the index" do

View file

@ -5,6 +5,11 @@ require "application_system_test_case"
class LinkCategoriesTest < ApplicationSystemTestCase class LinkCategoriesTest < ApplicationSystemTestCase
setup do setup do
@link_category = link_categories(:one) @link_category = link_categories(:one)
login_test
end
teardown do
logout
end end
test "visiting the index" do test "visiting the index" do

View file

@ -5,6 +5,11 @@ require "application_system_test_case"
class LinksTest < ApplicationSystemTestCase class LinksTest < ApplicationSystemTestCase
setup do setup do
@link = links(:one) @link = links(:one)
login_test
end
teardown do
logout
end end
test "visiting the index" do test "visiting the index" do

View file

@ -5,6 +5,11 @@ require "application_system_test_case"
class ReportsTest < ApplicationSystemTestCase class ReportsTest < ApplicationSystemTestCase
setup do setup do
@report = reports(:one) @report = reports(:one)
login_test
end
teardown do
logout
end end
test "visiting the index" do test "visiting the index" do
@ -33,7 +38,7 @@ class ReportsTest < ApplicationSystemTestCase
test "should destroy Report" do test "should destroy Report" do
visit report_url(@report) visit report_url(@report)
click_on "Prüfbericht löschen", match: :first click_on "Prüfbericht löschen", match: :first
assert_text("Report was successfully destroyed")
assert(Report.exists?(@report.id) == false) assert(Report.exists?(@report.id) == false)
end end
end end

View file

@ -3,8 +3,13 @@
require "application_system_test_case" require "application_system_test_case"
class SuccessCriteriaTest < ApplicationSystemTestCase class SuccessCriteriaTest < ApplicationSystemTestCase
teardown do
logout
end
setup do setup do
@success_criterion = success_criteria(:one) @success_criterion = success_criteria(:one)
login_test
end end
test "visiting the index" do test "visiting the index" do