Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
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 "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
|
||||
Reference in New Issue
Block a user