mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-06 10:30:31 +08:00
This is already used for more than just themes, and we plan to extend its usage even further
35 lines
1.1 KiB
Ruby
35 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe QunitController do
|
|
def production_sign_in(user)
|
|
# We need to call sign_in before stubbing the method because SessionController#become
|
|
# checks for the current env when the file is loaded.
|
|
# We need to make sure become is called once before stubbing, or the method
|
|
# wont'be available for future tests if this one runs first.
|
|
sign_in(user) if user
|
|
Rails.env.stubs(:production?).returns(true)
|
|
end
|
|
|
|
# rubocop:disable RSpec/BeforeAfterAll
|
|
before(:all) { AssetProcessor.build_production_asset_processor }
|
|
|
|
after(:all) { File.delete(AssetProcessor::PROCESSOR_PATH) }
|
|
|
|
it "hides page for regular users in production" do
|
|
production_sign_in(Fabricate(:user))
|
|
get "/theme-qunit"
|
|
expect(response.status).to eq(404)
|
|
end
|
|
|
|
it "hides page for anon in production" do
|
|
production_sign_in(nil)
|
|
get "/theme-qunit"
|
|
expect(response.status).to eq(404)
|
|
end
|
|
|
|
it "shows page for admin in production" do
|
|
production_sign_in(Fabricate(:admin))
|
|
get "/theme-qunit"
|
|
expect(response.status).to eq(200)
|
|
end
|
|
end
|