diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-01 12:07:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-01 12:07:33 +0300 |
commit | f5eabcfa0e39e8212eb333d9e824294d14f530d5 (patch) | |
tree | 1a365d06c584e61b50ac3850b4058fd7826173c8 /spec/views | |
parent | 0537e77587de43e2b3c5cbd8610641b3003a9840 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/groups/_home_panel.html.haml_spec.rb | 26 | ||||
-rw-r--r-- | spec/views/projects/_home_panel.html.haml_spec.rb | 32 |
2 files changed, 58 insertions, 0 deletions
diff --git a/spec/views/groups/_home_panel.html.haml_spec.rb b/spec/views/groups/_home_panel.html.haml_spec.rb index b8168b20450..e76862cdaea 100644 --- a/spec/views/groups/_home_panel.html.haml_spec.rb +++ b/spec/views/groups/_home_panel.html.haml_spec.rb @@ -14,4 +14,30 @@ RSpec.describe 'groups/_home_panel' do expect(rendered).to have_content("Group ID: #{group.id}") end + + context 'admin area link' do + it 'renders admin area link for admin' do + allow(view).to receive(:current_user).and_return(create(:admin)) + + render + + expect(rendered).to have_link(href: admin_group_path(group)) + end + + it 'does not render admin area link for non-admin' do + allow(view).to receive(:current_user).and_return(create(:user)) + + render + + expect(rendered).not_to have_link(href: admin_group_path(group)) + end + + it 'does not render admin area link for anonymous' do + allow(view).to receive(:current_user).and_return(nil) + + render + + expect(rendered).not_to have_link(href: admin_group_path(group)) + end + end end diff --git a/spec/views/projects/_home_panel.html.haml_spec.rb b/spec/views/projects/_home_panel.html.haml_spec.rb index d329c57af00..78131937d3c 100644 --- a/spec/views/projects/_home_panel.html.haml_spec.rb +++ b/spec/views/projects/_home_panel.html.haml_spec.rb @@ -5,6 +5,38 @@ require 'spec_helper' RSpec.describe 'projects/_home_panel' do include ProjectForksHelper + context 'admin area link' do + let(:project) { create(:project) } + + before do + assign(:project, project) + end + + it 'renders admin area link for admin' do + allow(view).to receive(:current_user).and_return(create(:admin)) + + render + + expect(rendered).to have_link(href: admin_project_path(project)) + end + + it 'does not render admin area link for non-admin' do + allow(view).to receive(:current_user).and_return(create(:user)) + + render + + expect(rendered).not_to have_link(href: admin_project_path(project)) + end + + it 'does not render admin area link for anonymous' do + allow(view).to receive(:current_user).and_return(nil) + + render + + expect(rendered).not_to have_link(href: admin_project_path(project)) + end + end + context 'notifications' do let(:project) { create(:project) } |