Files
simple-aircraft-manager-rails/test/integration/admin_about_test.rb
T
rickyandClaude Opus 5.5 2b0a2f1949 Ruby 4.0.9, Rails 8.1 defaults, newest gems; admin About page
- Ruby 3.2.3 (end of life) -> 4.0.9 in the Docker image and .ruby-version
- config.load_defaults 8.1
- All gems at their newest compatible versions, including json 3.1,
  roo 4.0, rubyzip 3.7 and solid_cable 4.1
- Admin -> About: running revision and build time, uptime, Ruby/Rails/
  SQLite and key gem versions, which features are configured (never
  secret values), storage and database sizes, background job health,
  record counts. The image takes APP_REVISION and APP_BUILT_AT build args.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 08:56:14 -05:00

43 lines
1.6 KiB
Ruby

require "test_helper"
class AdminAboutTest < ActionDispatch::IntegrationTest
test "admins see versions and setup; nobody else can" do
sign_in create_user("pilot@example.com")
get admin_about_path
assert_redirected_to root_path
admin = create_user("admin@example.com", admin: true)
sign_in admin
get root_path
assert_select "a[href='#{admin_about_path}']", text: "About"
with_env("APP_REVISION" => "abc1234", "APP_BUILT_AT" => "2026-11-07T12:00:00Z", "ANTHROPIC_API_KEY" => "sk-ant-secret") do
get admin_about_path
end
assert_response :success
assert_select "[data-revision]", text: "abc1234"
body = response.body
[ RUBY_VERSION, Rails.version, SQLite3::SQLITE_VERSION, Gem.loaded_specs["turbo-rails"].version.to_s ].each { assert_includes body, _1 }
assert_includes body, "on (#{LogbookTranscriber::MODEL})"
refute_includes body, "sk-ant-secret" # configured or not; never the value
assert_select "summary", text: /All gems \(\d+\)/
end
test "storage figures count files stored once" do
info = SystemInfo.new
2.times { |i| ActiveStorage::Blob.create_and_upload!(io: StringIO.new("same bytes"), filename: "copy#{i}.txt") }
ActiveStorage::Blob.create_and_upload!(io: StringIO.new("other"), filename: "other.txt")
assert_equal({ files: 3, bytes: 25, shared_bytes: 10 }, info.storage.slice(:files, :bytes, :shared_bytes))
end
private
def with_env(vars)
saved = vars.keys.to_h { [ _1, ENV[_1] ] }
vars.each { ENV[_1] = _2 }
yield
ensure
saved.each { ENV[_1] = _2 }
end
end