Every WarpEngine API response now carries `WarpEngine-Version`, so a client can branch on the engine's age without a round trip to ask. Set in a before_action rather than after: `rescue_from` never reaches an after_action, and a client needs the version most when something came back wrong. The name lives in `WarpEngine::VERSION_HEADER`. The host's own endpoints — the store registry — do not carry it, because they are not the engine. A software has one pipeline, and the newest assignment now wins. Two pipelines pointing at the same software was not an error the database caught; it was a link that silently did nothing, with the software still showing whichever row came first. Assigning a software another pipeline holds therefore moves it, the admin says which pipeline it was taken from, and `Pipeline#software_taken_from` carries that for anything else that cares. Deliberately a callback and not a unique index: rows here are soft-deleted, and a unique index counts deleted rows, so a pipeline removed last year would block its software from ever being linked again. The engine is 0.4.0. The site's /stores page and its screenshot follow the client's new name, and the shot is a fresh one showing the greyed-out titles the client now lists. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
31 lines
1.0 KiB
Ruby
31 lines
1.0 KiB
Ruby
require "rails_helper"
|
|
|
|
# Every response the engine serves carries the version that served it, so a client can
|
|
# branch on the engine's age without asking a separate endpoint for it.
|
|
RSpec.describe "the WarpEngine-Version header", type: :request do
|
|
it "is on a normal response" do
|
|
create(:software)
|
|
|
|
get "/api/software"
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
expect(response.headers["WarpEngine-Version"]).to eq(WarpEngine::VERSION)
|
|
end
|
|
|
|
# The one a client needs most: something came back wrong, and it wants to know whether
|
|
# the engine on the other end is old enough to explain it. `rescue_from` never reaches
|
|
# an after_action, which is why the header is set before the action runs.
|
|
it "is on an error response" do
|
|
get "/api/image/999999"
|
|
|
|
expect(response).to have_http_status(:not_found)
|
|
expect(response.headers["WarpEngine-Version"]).to eq(WarpEngine::VERSION)
|
|
end
|
|
|
|
it "is on a served file" do
|
|
get "/file/nothing-here.zip"
|
|
|
|
expect(response.headers["WarpEngine-Version"]).to eq(WarpEngine::VERSION)
|
|
end
|
|
end
|