docbrown/spec/requests/async_info_spec.rb
Julianna Tetreault 4a9f442354
Creator Onboarding: Creator Setup View (#14728)
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Yhëhtozr <conlang2012@outlook.com>
Co-authored-by: yheuhtozr <84892012+yheuhtozr@users.noreply.github.com>
Co-authored-by: Nick Taylor <nick@dev.to>
2021-11-01 15:50:08 -04:00

33 lines
1 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 creator creator_onboarding param token user])
end
end
end
end