2021-04-12 08:02:58 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe QunitController do
|
2023-09-11 04:12:37 -04:00
|
|
|
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
|
2021-04-28 16:12:08 -04:00
|
|
|
|
2023-09-11 04:12:37 -04:00
|
|
|
it "hides page for regular users in production" do
|
|
|
|
production_sign_in(Fabricate(:user))
|
|
|
|
get "/theme-qunit"
|
|
|
|
expect(response.status).to eq(404)
|
|
|
|
end
|
2021-04-28 16:12:08 -04:00
|
|
|
|
2023-09-11 04:12:37 -04:00
|
|
|
it "hides page for anon in production" do
|
|
|
|
production_sign_in(nil)
|
|
|
|
get "/theme-qunit"
|
|
|
|
expect(response.status).to eq(404)
|
|
|
|
end
|
2021-04-28 16:12:08 -04:00
|
|
|
|
2023-09-11 04:12:37 -04:00
|
|
|
it "shows page for admin in production" do
|
|
|
|
production_sign_in(Fabricate(:admin))
|
|
|
|
get "/theme-qunit"
|
|
|
|
expect(response.status).to eq(200)
|
2021-04-12 08:02:58 -04:00
|
|
|
end
|
|
|
|
end
|