mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 13:03:44 +08:00
b3238bfc34
Now forums can enroll their sites to be showcased in the Discourse [Discover](https://discourse.org/discover) directory. Once they enable the site setting `include_in_discourse_discover` to enroll their forum the `CallDiscourseHub` job will ping the `api.discourse.org/api/discover/enroll` endpoint. Then the Discourse Hub will fetch the basic details from the forum and add it to the review queue. If the site is approved then the forum details will be displayed in the `/discover` page.
58 lines
1.7 KiB
Ruby
58 lines
1.7 KiB
Ruby
# 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")
|
|
DiscourseUpdates.stubs(:critical_updates_available?).returns(false)
|
|
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
|