2021-04-12 07:02:58 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 21:27:38 -05:00
|
|
|
RSpec.describe QunitController do
|
2023-09-11 03:12:37 -05: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 15:12:08 -05:00
|
|
|
|
2023-09-11 03:12:37 -05: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 15:12:08 -05:00
|
|
|
|
2023-09-11 03:12:37 -05: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 15:12:08 -05:00
|
|
|
|
2023-09-11 03:12:37 -05: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 07:02:58 -05:00
|
|
|
end
|
|
|
|
end
|