Aggiunge navigazione mobile dedicata e trasforma le principali liste operative in layout più leggibili e facili da toccare. Co-authored-by: Cursor <cursoragent@cursor.com>
100 lines
2.8 KiB
Ruby
100 lines
2.8 KiB
Ruby
require "test_helper"
|
|
|
|
class AuthenticationTest < ActionDispatch::IntegrationTest
|
|
test "requires login" do
|
|
get root_path
|
|
assert_redirected_to login_path
|
|
end
|
|
|
|
test "login and logout" do
|
|
login_as users(:admin)
|
|
assert_response :redirect
|
|
follow_redirect!
|
|
assert_response :success
|
|
|
|
delete logout_path
|
|
assert_redirected_to login_path
|
|
end
|
|
|
|
test "non admin cannot create users" do
|
|
login_as users(:marco)
|
|
follow_redirect! if response.redirect?
|
|
post users_path, params: {
|
|
user: { email: "x@example.com", first_name: "X", last_name: "Y", role: "user", password: "password123", password_confirmation: "password123" }
|
|
}
|
|
assert_response :redirect
|
|
end
|
|
|
|
test "project space is isolated by url" do
|
|
login_as users(:admin)
|
|
follow_redirect! if response.redirect?
|
|
get project_root_path(project_code: "matchlivetv")
|
|
assert_response :success
|
|
assert_match(/MatchLiveTV/, response.body)
|
|
|
|
get project_root_path(project_code: "riskmeter")
|
|
assert_response :success
|
|
assert_match(/RiskMeter/, response.body)
|
|
end
|
|
|
|
test "user cannot open disabled project" do
|
|
login_as users(:marco)
|
|
follow_redirect! if response.redirect?
|
|
get project_root_path(project_code: "riskmeter")
|
|
assert_redirected_to root_path
|
|
end
|
|
|
|
test "project pages render mobile navigation shell" do
|
|
login_as users(:admin)
|
|
follow_redirect! if response.redirect?
|
|
|
|
get project_root_path(project_code: "matchlivetv")
|
|
assert_response :success
|
|
assert_match(/mobile-bottom-nav/, response.body)
|
|
assert_match(/Altro/, response.body)
|
|
end
|
|
|
|
test "disabled user cannot login" do
|
|
admin = users(:admin)
|
|
User.create!(
|
|
email: "keeper@example.com",
|
|
first_name: "Keep",
|
|
last_name: "Admin",
|
|
role: "admin",
|
|
password: "password123",
|
|
password_confirmation: "password123"
|
|
)
|
|
assert admin.update(active: false)
|
|
|
|
post login_path, params: { email: admin.email, password: "password123" }
|
|
assert_response :unprocessable_entity
|
|
assert_match(/Email o password non validi/i, response.body)
|
|
end
|
|
|
|
test "admin can open platform settings" do
|
|
login_as users(:admin)
|
|
follow_redirect! if response.redirect?
|
|
get admin_path
|
|
assert_response :success
|
|
assert_match(/Impostazioni piattaforma/, response.body)
|
|
assert_match(/Utenti/, response.body)
|
|
end
|
|
|
|
test "non admin cannot open platform settings" do
|
|
login_as users(:marco)
|
|
follow_redirect! if response.redirect?
|
|
get admin_path
|
|
assert_redirected_to root_path
|
|
end
|
|
|
|
test "admin home has new project and settings actions" do
|
|
login_as users(:admin)
|
|
follow_redirect! if response.redirect?
|
|
get root_path
|
|
assert_response :success
|
|
assert_match(/Nuovo progetto/, response.body)
|
|
assert_match(/Impostazioni/, response.body)
|
|
assert_no_match(/Amministrazione progetti/, response.body)
|
|
end
|
|
end
|