2020-10-07 08:48:38 -04:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
|
RSpec.describe "SiteSetting.styleguide_admin_only" do
|
2020-10-07 08:48:38 -04:00
|
|
|
|
before { SiteSetting.styleguide_enabled = true }
|
|
|
|
|
|
2022-07-27 12:14:14 -04:00
|
|
|
|
context "when styleguide is admin only" do
|
2020-10-07 08:48:38 -04:00
|
|
|
|
before { SiteSetting.styleguide_admin_only = true }
|
|
|
|
|
|
2022-07-27 12:14:14 -04:00
|
|
|
|
context "when user is admin" do
|
2020-10-07 08:48:38 -04:00
|
|
|
|
before { sign_in(Fabricate(:admin)) }
|
|
|
|
|
|
|
|
|
|
it "shows the styleguide" do
|
|
|
|
|
get "/styleguide"
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2022-07-27 12:14:14 -04:00
|
|
|
|
context "when user is not admin" do
|
2020-10-07 08:48:38 -04:00
|
|
|
|
before { sign_in(Fabricate(:user)) }
|
|
|
|
|
|
|
|
|
|
it "doesn’t allow access" do
|
|
|
|
|
get "/styleguide"
|
|
|
|
|
expect(response.status).to eq(403)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
|
RSpec.describe "SiteSetting.styleguide_enabled" do
|
2020-10-07 08:48:38 -04:00
|
|
|
|
before { sign_in(Fabricate(:admin)) }
|
|
|
|
|
|
2022-07-27 12:14:14 -04:00
|
|
|
|
context "when style is enabled" do
|
2020-10-07 08:48:38 -04:00
|
|
|
|
before { SiteSetting.styleguide_enabled = true }
|
|
|
|
|
|
|
|
|
|
it "shows the styleguide" do
|
|
|
|
|
get "/styleguide"
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2022-07-27 12:14:14 -04:00
|
|
|
|
context "when styleguide is disabled" do
|
2020-10-07 08:48:38 -04:00
|
|
|
|
before { SiteSetting.styleguide_enabled = false }
|
|
|
|
|
|
|
|
|
|
it "returns a page not found" do
|
|
|
|
|
get "/styleguide"
|
|
|
|
|
expect(response.status).to eq(404)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|