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