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>
44 lines
1.7 KiB
Ruby
44 lines
1.7 KiB
Ruby
require "test_helper"
|
|
|
|
# Who can add aircraft (Admin → Settings): adding or importing one makes you
|
|
# its Owner, who can bring in outside mechanics, so by default only
|
|
# administrators can.
|
|
class AddingAircraftTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
@user = create_user("user@example.com")
|
|
@admin = create_user("admin@example.com", admin: true)
|
|
end
|
|
|
|
test "by default only administrators add or import aircraft" do
|
|
sign_in @user
|
|
get root_path
|
|
assert_select "a[href=?]", new_aircraft_path, 0
|
|
assert_select "a[href=?]", new_aircraft_import_path, 0
|
|
assert_includes response.body, "An administrator adds aircraft"
|
|
get new_aircraft_path
|
|
assert_redirected_to root_path
|
|
post aircraft_index_path, params: { aircraft: { tail_number: "N1", tach_time: 50 } }
|
|
assert_not Aircraft.exists?(tail_number: "N1")
|
|
get new_aircraft_import_path
|
|
assert_redirected_to root_path
|
|
|
|
sign_in @admin
|
|
post aircraft_index_path, params: { aircraft: { tail_number: "N1", tach_time: 50 } }
|
|
assert_equal "owner", @admin.role_for(Aircraft.find_by!(tail_number: "N1")).key
|
|
end
|
|
|
|
test "an administrator can let everyone add aircraft" do
|
|
sign_in @admin
|
|
get edit_admin_settings_path
|
|
assert_select "select[name='settings[anyone_adds_aircraft]'] option[selected]", text: "Administrators only"
|
|
patch admin_settings_path, params: { settings: { anyone_adds_aircraft: 1 } }
|
|
assert Setting.anyone_adds_aircraft?
|
|
|
|
sign_in @user
|
|
get root_path
|
|
assert_select "a[href=?]", new_aircraft_path
|
|
post aircraft_index_path, params: { aircraft: { tail_number: "N2", tach_time: 50 } }
|
|
assert_equal "owner", @user.role_for(Aircraft.find_by!(tail_number: "N2")).key
|
|
end
|
|
end
|