debian-mirror-gitlab/spec/features/user_can_display_performance_bar_spec.rb

103 lines
2.5 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
2020-06-23 00:09:42 +05:30
RSpec.describe 'User can display performance bar', :js do
2018-03-17 18:26:18 +05:30
shared_examples 'performance bar cannot be displayed' do
2017-09-10 17:25:29 +05:30
it 'does not show the performance bar by default' do
2018-05-09 12:01:36 +05:30
expect(page).not_to have_css('#js-peek')
2017-09-10 17:25:29 +05:30
end
context 'when user press `pb`' do
before do
find('body').native.send_keys('pb')
end
it 'does not show the performance bar by default' do
2018-05-09 12:01:36 +05:30
expect(page).not_to have_css('#js-peek')
2017-09-10 17:25:29 +05:30
end
end
end
2018-03-17 18:26:18 +05:30
shared_examples 'performance bar can be displayed' do
2017-09-10 17:25:29 +05:30
it 'does not show the performance bar by default' do
2018-05-09 12:01:36 +05:30
expect(page).not_to have_css('#js-peek')
2017-09-10 17:25:29 +05:30
end
context 'when user press `pb`' do
before do
find('body').native.send_keys('pb')
end
it 'shows the performance bar' do
2018-05-09 12:01:36 +05:30
expect(page).to have_css('#js-peek')
2017-09-10 17:25:29 +05:30
end
end
end
2018-03-17 18:26:18 +05:30
shared_examples 'performance bar is enabled by default in development' do
before do
2019-12-04 20:38:33 +05:30
stub_rails_env('development')
2018-03-17 18:26:18 +05:30
end
it 'shows the performance bar by default' do
refresh # Because we're stubbing Rails.env after the 1st visit to root_path
2018-05-09 12:01:36 +05:30
expect(page).to have_css('#js-peek')
2018-03-17 18:26:18 +05:30
end
end
2017-09-10 17:25:29 +05:30
let(:group) { create(:group) }
context 'when user is logged-out' do
before do
visit root_path
end
context 'when the performance_bar feature is disabled' do
before do
stub_application_setting(performance_bar_allowed_group_id: nil)
end
2018-03-17 18:26:18 +05:30
it_behaves_like 'performance bar cannot be displayed'
2017-09-10 17:25:29 +05:30
end
context 'when the performance_bar feature is enabled' do
before do
stub_application_setting(performance_bar_allowed_group_id: group.id)
end
2018-03-17 18:26:18 +05:30
it_behaves_like 'performance bar cannot be displayed'
2017-09-10 17:25:29 +05:30
end
end
context 'when user is logged-in' do
before do
user = create(:user)
sign_in(user)
group.add_guest(user)
visit root_path
end
context 'when the performance_bar feature is disabled' do
before do
stub_application_setting(performance_bar_allowed_group_id: nil)
end
2018-03-17 18:26:18 +05:30
it_behaves_like 'performance bar cannot be displayed'
it_behaves_like 'performance bar is enabled by default in development'
2017-09-10 17:25:29 +05:30
end
context 'when the performance_bar feature is enabled' do
before do
stub_application_setting(performance_bar_allowed_group_id: group.id)
end
2018-03-17 18:26:18 +05:30
it_behaves_like 'performance bar is enabled by default in development'
it_behaves_like 'performance bar can be displayed'
2017-09-10 17:25:29 +05:30
end
end
end