diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-18 06:07:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-18 06:07:23 +0300 |
commit | 962afb3da11a72c7fca322378886b2c0be9f3385 (patch) | |
tree | 541e08c4d329ab62cfbadde45b0f15d2171e004e /spec/views | |
parent | 8a560d56661f56804ddf6596f928e7d25db37443 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/projects/_files.html.haml_spec.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/views/projects/_files.html.haml_spec.rb b/spec/views/projects/_files.html.haml_spec.rb new file mode 100644 index 00000000000..618a0948739 --- /dev/null +++ b/spec/views/projects/_files.html.haml_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'projects/_files', feature_category: :projects do + let_it_be(:template) { 'projects/files' } + let_it_be(:namespace) { build_stubbed(:namespace) } + let_it_be(:user) { build_stubbed(:user, namespace: namespace) } + let_it_be(:project) { build_stubbed(:project, namespace: namespace) } + + before do + assign(:project, project) + assign(:path, '/job_path') + assign(:ref, 'main') + # used by project_new_blob_path + assign(:id, '1') + + allow(project).to receive(:statistics_buttons).and_return([]) + end + + context 'when the user disabled project shortcut buttons' do + before do + allow(view).to receive(:current_user).and_return(user) + allow(user).to receive(:project_shortcut_buttons).and_return(false) + end + + it 'does not render buttons' do + render(template, is_project_overview: true) + + expect(rendered).not_to have_selector('.js-show-on-project-root') + end + end + + context 'when the user has project shortcut buttons enabled' do + before do + allow(view).to receive(:current_user).and_return(user) + allow(user).to receive(:project_shortcut_buttons).and_return(true) + end + + it 'renders buttons' do + render(template, is_project_overview: true) + + expect(rendered).to have_selector('.js-show-on-project-root') + end + end + + context 'when rendered in the project overview page and there is no current user' do + it 'renders buttons' do + render(template, is_project_overview: true) + + expect(rendered).to have_selector('.js-show-on-project-root') + end + end + + context 'when rendered in a page other than project overview' do + it 'does not render buttons' do + render(template, is_project_overview: false) + + expect(rendered).not_to have_selector('.js-show-on-project-root') + end + end +end |