mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
- Admin → Settings → Who can add aircraft: administrators only (the default) or everyone. Adding an aircraft or importing a .sam.zip makes you its Owner, so this decides who can become one. - A signing invitation from an Owner of the aircraft (or an administrator) lets the outside mechanic create an account for the invited address again, with a password or by signing in with SSO; checked when it's used. Others' signing invitations still need an existing account, and say so. - Docs: who makes accounts, the new setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.3 KiB
Ruby
33 lines
1.3 KiB
Ruby
require "test_helper"
|
|
|
|
class SetupTest < ActionDispatch::IntegrationTest
|
|
test "first run creates admin with the code from the server log, then setup is closed" do
|
|
get root_path
|
|
assert_redirected_to new_setup_path
|
|
get new_setup_path
|
|
assert_select "input[name=setup_code]"
|
|
admin = { name: "Jane", email_address: "a@b.com", password: "test-password-123", password_confirmation: "test-password-123" }
|
|
|
|
post setup_path, params: { user: admin, setup_code: "AAAA-AAAA" }
|
|
assert_response :unprocessable_entity
|
|
assert_not User.exists?
|
|
|
|
post setup_path, params: { user: admin, setup_code: SetupCode.current.downcase.delete("-") } # forgiving about case and the dash
|
|
assert_redirected_to root_path
|
|
assert_not SetupCode.file.exist?, "the code is used up"
|
|
assert User.last.admin?
|
|
get new_setup_path
|
|
assert_redirected_to root_path
|
|
end
|
|
|
|
test "create aircraft makes creator the owner" do
|
|
Setting.update_integers("anyone_adds_aircraft" => 1) # anyone may add aircraft here
|
|
user = create_user
|
|
sign_in user
|
|
post aircraft_index_path, params: { aircraft: { tail_number: "N1", tach_time: 50 } }
|
|
a = Aircraft.find_by!(tail_number: "N1")
|
|
assert_redirected_to aircraft_path(a)
|
|
assert_equal "owner", user.role_for(a).key
|
|
end
|
|
end
|