docbrown/spec/requests/async_info_spec.rb
Michael Kohl 6dfabd578f
Rename SiteConfig to Settings::General (#13573)
* Rename SiteConfig

* More renaming

* Update spec

* Update mandatory settings mapping

* More renaming

* e2e test fixes

* You have a rename, and you have a rename

* Spec fix

* More changes

* Temporarily disable specs

* After-merge update

* Undo rename for migration

* undo rename of DUS

* Fix DUS

* Fix merge problem

* Remove redundant DUS

* Fix specs

* Remove unused code

* Change wrong class name

* More cleanup

* Re-add missing values to constant

* Fix constant

* Fix spec

* Remove obsolete fields

* Add accidentally removed field

* Update spec

* Move methods from Settings::General to ForemInstance

* Remove unneeded model

* Change mentions of 'site config'
2021-05-21 14:45:37 +02:00

40 lines
1.2 KiB
Ruby

require "rails_helper"
RSpec.describe "AsyncInfo", type: :request do
let(:controller_instance) { AsyncInfoController.new }
before do
allow(AsyncInfoController).to receive(:new).and_return(controller_instance)
end
describe "GET /async_info/base_data" do
context "when not logged-in" do
it "returns json without user" do
get "/async_info/base_data"
expect(response.parsed_body.keys).to match_array(%w[broadcast param token])
end
it "renders normal response even if the Forem instance is private" do
allow(Settings::UserExperience).to receive(:public).and_return(false)
get "/async_info/base_data"
expect(response.parsed_body.keys).to match_array(%w[broadcast param token])
end
end
context "when logged in" do
it "returns token and user" do
sign_in create(:user)
get "/async_info/base_data"
expect(response.parsed_body.keys).to match_array(%w[broadcast param token user])
end
end
end
describe "GET /async_info/shell_version" do
it "returns shell_version" do
get "/async_info/shell_version"
expect(response.body).to include("version")
end
end
end