0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-11 02:59:07 +08:00
discourse/spec/requests/admin/versions_controller_spec.rb
David Taylor 325eb4280d
UX: Remove update priority handling in version checks (#42165)
Previously, api.dicourse.org would track whether an update is 'critical'
or not, and then change the color/design of the 'update available'
indicator in the dashboard. These flags have not always been set
reliably, and the extra complexity is not worth maintaining. If an admin
wants to find out what's included in an update, we now have a clear
changelog linked from the dashboard.
2026-08-10 13:48:39 +01:00

56 lines
1.6 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe Admin::VersionsController do
fab!(:admin)
fab!(:moderator)
fab!(:user)
before do
Jobs::CallDiscourseHub.any_instance.stubs(:execute).returns(true)
DiscourseUpdates.stubs(:updated_at).returns(2.hours.ago)
DiscourseUpdates.stubs(:latest_version).returns("1.2.33")
end
describe "#show" do
shared_examples "version info accessible" do
it "should return the currently available version" do
get "/admin/version_check.json"
expect(response.status).to eq(200)
json = response.parsed_body
expect(json["latest_version"]).to eq("1.2.33")
end
it "should return the installed version" do
get "/admin/version_check.json"
json = response.parsed_body
expect(response.status).to eq(200)
expect(json["installed_version"]).to eq(Discourse::VERSION::STRING)
end
end
context "when logged in as admin" do
before { sign_in(admin) }
include_examples "version info accessible"
end
context "when logged in as a moderator" do
before { sign_in(moderator) }
include_examples "version info accessible"
end
context "when logged in as a non-staff user" do
before { sign_in(user) }
it "denies access with a 404 response" do
get "/admin/version_check.json"
expect(response.status).to eq(404)
expect(response.parsed_body["errors"]).to include(I18n.t("not_found"))
expect(response.parsed_body["latest_version"]).to be_nil
expect(response.parsed_body["installed_version"]).to be_nil
end
end
end
end