mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
Tests: dummy names instead of a real one
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6e871e9ebb
commit
d5d06d4169
6 files changed
+11
-11
No files matched your search
@@ -2,7 +2,7 @@ require "test_helper"
|
||||
|
||||
class AirTrailExportFlowTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@pilot = create_user("ricky@example.com")
|
||||
@pilot = create_user("jane@example.com")
|
||||
@a = create_aircraft(pilot: @pilot, owner: create_user, tail_number: "N12345")
|
||||
@a.flight_logs.create!(date: Date.current, departure_location: "KOQU", destination_location: "KBID", tach_time: 0.5)
|
||||
sign_in @pilot
|
||||
@@ -13,10 +13,10 @@ class AirTrailExportFlowTest < ActionDispatch::IntegrationTest
|
||||
assert_select "a[href='#{new_aircraft_air_trail_export_path(@a)}']", text: "Export for AirTrail"
|
||||
get new_aircraft_air_trail_export_path(@a)
|
||||
assert_response :success
|
||||
assert_select "input[name='username'][value='ricky']"
|
||||
assert_select "input[name='username'][value='jane']"
|
||||
assert_select "form[data-turbo='false']"
|
||||
|
||||
post aircraft_air_trail_export_path(@a), params: { username: "ricky", aircraft_type: "C150", scope: "all" }
|
||||
post aircraft_air_trail_export_path(@a), params: { username: "jane", aircraft_type: "C150", scope: "all" }
|
||||
assert_response :success
|
||||
assert_equal "application/json", response.media_type
|
||||
assert_match(/attachment; filename="n12345-airtrail-.*\.json"/, response.headers["Content-Disposition"])
|
||||
|
||||
@@ -20,7 +20,7 @@ class AirTrailSyncFlowTest < ActionDispatch::IntegrationTest
|
||||
connect
|
||||
assert_redirected_to air_trail_connection_path
|
||||
follow_redirect!
|
||||
assert_match "Connected to AirTrail as ricky", response.body
|
||||
assert_match "Connected to AirTrail as jane", response.body
|
||||
assert_equal "https://airtrail.test", @user.air_trail_connection.base_url
|
||||
|
||||
perform_enqueued_jobs do
|
||||
|
||||
@@ -4,7 +4,7 @@ class SetupTest < ActionDispatch::IntegrationTest
|
||||
test "first run creates admin, then setup is closed" do
|
||||
get root_path
|
||||
assert_redirected_to new_setup_path
|
||||
post setup_path, params: { user: { name: "Ricky", email_address: "a@b.com", password: "test-password-123", password_confirmation: "test-password-123" } }
|
||||
post setup_path, params: { user: { name: "Jane", email_address: "a@b.com", password: "test-password-123", password_confirmation: "test-password-123" } }
|
||||
assert_redirected_to root_path
|
||||
assert User.last.admin?
|
||||
get new_setup_path
|
||||
|
||||
@@ -11,13 +11,13 @@ class AirTrailExportTest < ActiveSupport::TestCase
|
||||
tach_time: tach, hobbs_time: hobbs, user: user, notes: notes)
|
||||
end
|
||||
|
||||
def export(**opts) = AirTrailExport.new(@a, username: "ricky", **opts)
|
||||
def export(**opts) = AirTrailExport.new(@a, username: "jane", **opts)
|
||||
|
||||
test "builds AirTrail's import format" do
|
||||
fly Date.new(2026, 10, 24), "KLHV", "44N", tach: 1.9, hobbs: 2.0, notes: "Fall colors"
|
||||
data = JSON.parse(export(aircraft_type: "c150").to_json)
|
||||
|
||||
assert_equal [ { "id" => "sam-pilot", "username" => "ricky", "displayName" => "ricky" } ], data["users"]
|
||||
assert_equal [ { "id" => "sam-pilot", "username" => "jane", "displayName" => "jane" } ], data["users"]
|
||||
f = data["flights"].first
|
||||
assert_equal "2026-10-24", f["date"]
|
||||
assert_equal "day", f["datePrecision"]
|
||||
@@ -83,6 +83,6 @@ class AirTrailExportTest < ActiveSupport::TestCase
|
||||
assert_not AirTrailExport.new(@a, username: "ri").valid?
|
||||
assert_not AirTrailExport.new(@a, username: "jane pilot").valid?
|
||||
assert_not export(aircraft_type: "CESSNA").valid?
|
||||
assert_not AirTrailExport.new(create_aircraft, username: "ricky").valid? # no flights
|
||||
assert_not AirTrailExport.new(create_aircraft, username: "jane").valid? # no flights
|
||||
end
|
||||
end
|
||||
@@ -30,11 +30,11 @@ class AirTrailSyncerTest < ActiveSupport::TestCase
|
||||
body = @fake.flights.fetch(sync.remote_id)
|
||||
assert_equal [ "2026-10-24", 101, 102, 7, 2160, "N12345" ],
|
||||
body.values_at("date", "fromId", "toId", "aircraftId", "duration", "aircraftReg")
|
||||
assert_equal [ { "userId" => "u-ricky", "guestName" => nil, "seat" => "pilot", "seatNumber" => nil,
|
||||
assert_equal [ { "userId" => "u-jane", "guestName" => nil, "seat" => "pilot", "seatNumber" => nil,
|
||||
"seatClass" => nil, "flightReason" => nil, "customFields" => {} } ], body["passengers"]
|
||||
assert_equal "gpx", body.dig("track", "sourceFormat")
|
||||
assert_equal [ -71.412028, 41.597139, 5.2 ], body.dig("track", "coordinates", 0)
|
||||
assert_equal "ricky", @connection.reload.remote_username
|
||||
assert_equal "jane", @connection.reload.remote_username
|
||||
end
|
||||
|
||||
test "unchanged flights aren't re-sent; changed ones are replaced; deleted-in-AirTrail ones recreated" do
|
||||
|
||||
@@ -44,7 +44,7 @@ class FakeAirTrail
|
||||
query = URI.decode_www_form(req.uri.query.to_s).to_h
|
||||
case [ req.method, path ]
|
||||
in [ :get, "/api/v1/me" ]
|
||||
json(200, data: { id: "u-ricky", username: "ricky", displayName: "Ricky", role: nil, isOwner: true,
|
||||
json(200, data: { id: "u-jane", username: "jane", displayName: "Jane", role: nil, isOwner: true,
|
||||
permissions: [], credential: { kind: "apiKey", scopes: @scopes } })
|
||||
in [ :get, "/api/v1/airports" ]
|
||||
code = query["query"].to_s.upcase
|
||||
|
||||
Reference in new issue
Block a user