Commit 359c113f authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'chore/disable-admin-mode-in-requests-views' into 'master'

Disable auto admin mode on requests and views specs

See merge request gitlab-org/gitlab!48700
parents 1a4ceaaf 457e1881
---
title: Disable auto admin mode on requests and views specs
merge_request: 48700
author: Diego Louzán
type: other
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'view audit events' do RSpec.describe 'view audit events' do
include AdminModeHelper
describe 'GET /audit_events' do describe 'GET /audit_events' do
let_it_be(:admin) { create(:admin) } let_it_be(:admin) { create(:admin) }
let_it_be(:audit_event) { create(:user_audit_event) } let_it_be(:audit_event) { create(:user_audit_event) }
...@@ -13,6 +15,11 @@ RSpec.describe 'view audit events' do ...@@ -13,6 +15,11 @@ RSpec.describe 'view audit events' do
login_as(admin) login_as(admin)
end end
context 'when admin mode is enabled' do
before do
enable_admin_mode!(admin)
end
it 'returns 200 response' do it 'returns 200 response' do
send_request send_request
...@@ -31,6 +38,15 @@ RSpec.describe 'view audit events' do ...@@ -31,6 +38,15 @@ RSpec.describe 'view audit events' do
send_request send_request
end.not_to exceed_all_query_limit(control) end.not_to exceed_all_query_limit(control)
end end
end
context 'when admin mode is disabled' do
it 'redirects to admin mode enable' do
send_request
expect(response).to redirect_to(new_admin_session_path)
end
end
def send_request def send_request
get admin_audit_logs_path get admin_audit_logs_path
......
...@@ -4,6 +4,7 @@ require 'spec_helper' ...@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Admin::AbuseReportsController, '(JavaScript fixtures)', type: :controller do RSpec.describe Admin::AbuseReportsController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
include AdminModeHelper
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let!(:abuse_report) { create(:abuse_report) } let!(:abuse_report) { create(:abuse_report) }
...@@ -18,6 +19,7 @@ RSpec.describe Admin::AbuseReportsController, '(JavaScript fixtures)', type: :co ...@@ -18,6 +19,7 @@ RSpec.describe Admin::AbuseReportsController, '(JavaScript fixtures)', type: :co
before do before do
sign_in(admin) sign_in(admin)
enable_admin_mode!(admin)
end end
it 'abuse_reports/abuse_reports_list.html' do it 'abuse_reports/abuse_reports_list.html' do
......
...@@ -5,12 +5,14 @@ require 'spec_helper' ...@@ -5,12 +5,14 @@ require 'spec_helper'
RSpec.describe Admin::UsersController, '(JavaScript fixtures)', type: :controller do RSpec.describe Admin::UsersController, '(JavaScript fixtures)', type: :controller do
include StubENV include StubENV
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
include AdminModeHelper
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
before do before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(admin) sign_in(admin)
enable_admin_mode!(admin)
end end
render_views render_views
......
...@@ -5,6 +5,7 @@ require 'spec_helper' ...@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe Admin::ApplicationSettingsController, '(JavaScript fixtures)', type: :controller do RSpec.describe Admin::ApplicationSettingsController, '(JavaScript fixtures)', type: :controller do
include StubENV include StubENV
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
include AdminModeHelper
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
...@@ -13,6 +14,7 @@ RSpec.describe Admin::ApplicationSettingsController, '(JavaScript fixtures)', ty ...@@ -13,6 +14,7 @@ RSpec.describe Admin::ApplicationSettingsController, '(JavaScript fixtures)', ty
before do before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(admin) sign_in(admin)
enable_admin_mode!(admin)
end end
render_views render_views
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Projects::AutocompleteSourcesController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::AutocompleteSourcesController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let_it_be(:admin) { create(:admin) } let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, name: 'frontend-fixtures') } let_it_be(:group) { create(:group, name: 'frontend-fixtures') }
let_it_be(:project) { create(:project, namespace: group, path: 'autocomplete-sources-project') } let_it_be(:project) { create(:project, namespace: group, path: 'autocomplete-sources-project') }
let_it_be(:issue) { create(:issue, project: project) } let_it_be(:issue) { create(:issue, project: project) }
...@@ -15,7 +15,8 @@ RSpec.describe Projects::AutocompleteSourcesController, '(JavaScript fixtures)', ...@@ -15,7 +15,8 @@ RSpec.describe Projects::AutocompleteSourcesController, '(JavaScript fixtures)',
end end
before do before do
sign_in(admin) group.add_owner(user)
sign_in(user)
end end
it 'autocomplete_sources/labels.json' do it 'autocomplete_sources/labels.json' do
......
...@@ -5,9 +5,9 @@ require 'spec_helper' ...@@ -5,9 +5,9 @@ require 'spec_helper'
RSpec.describe Projects::BlobController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::BlobController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') } let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
let(:user) { project.owner }
render_views render_views
...@@ -16,7 +16,7 @@ RSpec.describe Projects::BlobController, '(JavaScript fixtures)', type: :control ...@@ -16,7 +16,7 @@ RSpec.describe Projects::BlobController, '(JavaScript fixtures)', type: :control
end end
before do before do
sign_in(admin) sign_in(user)
allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon') allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
end end
......
...@@ -5,9 +5,9 @@ require 'spec_helper' ...@@ -5,9 +5,9 @@ require 'spec_helper'
RSpec.describe 'Branches (JavaScript fixtures)' do RSpec.describe 'Branches (JavaScript fixtures)' do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let_it_be(:admin) { create(:admin) }
let_it_be(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let_it_be(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let_it_be(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') } let_it_be(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
let_it_be(:user) { project.owner }
before(:all) do before(:all) do
clean_frontend_fixtures('branches/') clean_frontend_fixtures('branches/')
...@@ -22,7 +22,7 @@ RSpec.describe 'Branches (JavaScript fixtures)' do ...@@ -22,7 +22,7 @@ RSpec.describe 'Branches (JavaScript fixtures)' do
render_views render_views
before do before do
sign_in(admin) sign_in(user)
end end
it 'branches/new_branch.html' do it 'branches/new_branch.html' do
...@@ -44,7 +44,7 @@ RSpec.describe 'Branches (JavaScript fixtures)' do ...@@ -44,7 +44,7 @@ RSpec.describe 'Branches (JavaScript fixtures)' do
# - "master": default, protected # - "master": default, protected
# - "markdown": non-default, protected # - "markdown": non-default, protected
# - "many_files": non-default, not protected # - "many_files": non-default, not protected
get api("/projects/#{project.id}/repository/branches?search=ma", admin) get api("/projects/#{project.id}/repository/branches?search=ma", user)
expect(response).to be_successful expect(response).to be_successful
end end
......
...@@ -5,10 +5,10 @@ require 'spec_helper' ...@@ -5,10 +5,10 @@ require 'spec_helper'
RSpec.describe Projects::ClustersController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::ClustersController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace) } let(:project) { create(:project, :repository, namespace: namespace) }
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) } let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:user) { project.owner }
render_views render_views
...@@ -17,7 +17,7 @@ RSpec.describe Projects::ClustersController, '(JavaScript fixtures)', type: :con ...@@ -17,7 +17,7 @@ RSpec.describe Projects::ClustersController, '(JavaScript fixtures)', type: :con
end end
before do before do
sign_in(admin) sign_in(user)
end end
after do after do
......
...@@ -6,14 +6,12 @@ RSpec.describe 'Commit (JavaScript fixtures)' do ...@@ -6,14 +6,12 @@ RSpec.describe 'Commit (JavaScript fixtures)' do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) } let_it_be(:user) { project.owner }
let_it_be(:commit) { project.commit("master") } let_it_be(:commit) { project.commit("master") }
before(:all) do before(:all) do
clean_frontend_fixtures('commit/') clean_frontend_fixtures('commit/')
clean_frontend_fixtures('api/commits/') clean_frontend_fixtures('api/commits/')
project.add_maintainer(user)
end end
before do before do
......
...@@ -4,6 +4,7 @@ require 'spec_helper' ...@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
include AdminModeHelper
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
...@@ -17,7 +18,10 @@ RSpec.describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :c ...@@ -17,7 +18,10 @@ RSpec.describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :c
end end
before do before do
# Using an admin for these fixtures because they are used for verifying a frontend
# component that would normally get its data from `Admin::DeployKeysController`
sign_in(admin) sign_in(admin)
enable_admin_mode!(admin)
end end
after do after do
......
...@@ -6,8 +6,8 @@ RSpec.describe 'Freeze Periods (JavaScript fixtures)' do ...@@ -6,8 +6,8 @@ RSpec.describe 'Freeze Periods (JavaScript fixtures)' do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
include TimeZoneHelper include TimeZoneHelper
let_it_be(:admin) { create(:admin) }
let_it_be(:project) { create(:project, :repository, path: 'freeze-periods-project') } let_it_be(:project) { create(:project, :repository, path: 'freeze-periods-project') }
let_it_be(:user) { project.owner }
before(:all) do before(:all) do
clean_frontend_fixtures('api/freeze-periods/') clean_frontend_fixtures('api/freeze-periods/')
...@@ -34,7 +34,7 @@ RSpec.describe 'Freeze Periods (JavaScript fixtures)' do ...@@ -34,7 +34,7 @@ RSpec.describe 'Freeze Periods (JavaScript fixtures)' do
create(:ci_freeze_period, project: project, freeze_start: '0 12 * * 1-5', freeze_end: '0 1 5 * *', cron_timezone: 'Etc/UTC') create(:ci_freeze_period, project: project, freeze_start: '0 12 * * 1-5', freeze_end: '0 1 5 * *', cron_timezone: 'Etc/UTC')
create(:ci_freeze_period, project: project, freeze_start: '0 12 * * 1-5', freeze_end: '0 16 * * 6', cron_timezone: 'Europe/Berlin') create(:ci_freeze_period, project: project, freeze_start: '0 12 * * 1-5', freeze_end: '0 16 * * 6', cron_timezone: 'Europe/Berlin')
get api("/projects/#{project.id}/freeze_periods", admin) get api("/projects/#{project.id}/freeze_periods", user)
expect(response).to be_successful expect(response).to be_successful
end end
......
...@@ -5,20 +5,20 @@ require 'spec_helper' ...@@ -5,20 +5,20 @@ require 'spec_helper'
RSpec.describe 'Groups (JavaScript fixtures)', type: :controller do RSpec.describe 'Groups (JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) } let(:user) { create(:user) }
let(:group) { create(:group, name: 'frontend-fixtures-group', runners_token: 'runnerstoken:intabulasreferre')} let(:group) { create(:group, name: 'frontend-fixtures-group', runners_token: 'runnerstoken:intabulasreferre')}
render_views
before(:all) do before(:all) do
clean_frontend_fixtures('groups/') clean_frontend_fixtures('groups/')
end end
before do before do
group.add_maintainer(admin) group.add_owner(user)
sign_in(admin) sign_in(user)
end end
render_views
describe GroupsController, '(JavaScript fixtures)', type: :controller do describe GroupsController, '(JavaScript fixtures)', type: :controller do
it 'groups/edit.html' do it 'groups/edit.html' do
get :edit, params: { id: group } get :edit, params: { id: group }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin, feed_token: 'feedtoken:coldfeed') } let(:user) { create(:user, feed_token: 'feedtoken:coldfeed') }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project_empty_repo, namespace: namespace, path: 'issues-project') } let(:project) { create(:project_empty_repo, namespace: namespace, path: 'issues-project') }
...@@ -16,7 +16,8 @@ RSpec.describe Projects::IssuesController, '(JavaScript fixtures)', type: :contr ...@@ -16,7 +16,8 @@ RSpec.describe Projects::IssuesController, '(JavaScript fixtures)', type: :contr
end end
before do before do
sign_in(admin) project.add_maintainer(user)
sign_in(user)
end end
after do after do
......
...@@ -5,9 +5,9 @@ require 'spec_helper' ...@@ -5,9 +5,9 @@ require 'spec_helper'
RSpec.describe Projects::JobsController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::JobsController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'builds-project') } let(:project) { create(:project, :repository, namespace: namespace, path: 'builds-project') }
let(:user) { project.owner }
let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id) } let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id) }
let!(:build_with_artifacts) { create(:ci_build, :success, :artifacts, :trace_artifact, pipeline: pipeline, stage: 'test', artifacts_expire_at: Time.now + 18.months) } let!(:build_with_artifacts) { create(:ci_build, :success, :artifacts, :trace_artifact, pipeline: pipeline, stage: 'test', artifacts_expire_at: Time.now + 18.months) }
let!(:failed_build) { create(:ci_build, :failed, pipeline: pipeline, stage: 'build') } let!(:failed_build) { create(:ci_build, :failed, pipeline: pipeline, stage: 'build') }
...@@ -26,7 +26,7 @@ RSpec.describe Projects::JobsController, '(JavaScript fixtures)', type: :control ...@@ -26,7 +26,7 @@ RSpec.describe Projects::JobsController, '(JavaScript fixtures)', type: :control
end end
before do before do
sign_in(admin) sign_in(user)
end end
after do after do
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe 'Labels (JavaScript fixtures)' do RSpec.describe 'Labels (JavaScript fixtures)' do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) } let(:user) { create(:user) }
let(:group) { create(:group, name: 'frontend-fixtures-group' )} let(:group) { create(:group, name: 'frontend-fixtures-group' )}
let(:project) { create(:project_empty_repo, namespace: group, path: 'labels-project') } let(:project) { create(:project_empty_repo, namespace: group, path: 'labels-project') }
...@@ -29,8 +29,6 @@ RSpec.describe 'Labels (JavaScript fixtures)' do ...@@ -29,8 +29,6 @@ RSpec.describe 'Labels (JavaScript fixtures)' do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
include ApiHelpers include ApiHelpers
let(:user) { create(:user) }
before do before do
group.add_owner(user) group.add_owner(user)
end end
...@@ -46,7 +44,8 @@ RSpec.describe 'Labels (JavaScript fixtures)' do ...@@ -46,7 +44,8 @@ RSpec.describe 'Labels (JavaScript fixtures)' do
render_views render_views
before do before do
sign_in(admin) group.add_owner(user)
sign_in(user)
end end
it 'labels/project_labels.json' do it 'labels/project_labels.json' do
......
...@@ -5,9 +5,9 @@ require 'spec_helper' ...@@ -5,9 +5,9 @@ require 'spec_helper'
RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') } let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') }
let(:user) { project.owner }
# rubocop: disable Layout/TrailingWhitespace # rubocop: disable Layout/TrailingWhitespace
let(:description) do let(:description) do
...@@ -55,7 +55,7 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: ...@@ -55,7 +55,7 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type:
end end
before do before do
sign_in(admin) sign_in(user)
allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo']) allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo'])
end end
...@@ -64,7 +64,7 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: ...@@ -64,7 +64,7 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type:
end end
it 'merge_requests/merge_request_of_current_user.html' do it 'merge_requests/merge_request_of_current_user.html' do
merge_request.update(author: admin) merge_request.update(author: user)
render_merge_request(merge_request) render_merge_request(merge_request)
end end
...@@ -76,19 +76,19 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: ...@@ -76,19 +76,19 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type:
end end
it 'merge_requests/diff_comment.html' do it 'merge_requests/diff_comment.html' do
create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) create(:diff_note_on_merge_request, project: project, author: user, position: position, noteable: merge_request)
create(:note_on_merge_request, author: admin, project: project, noteable: merge_request) create(:note_on_merge_request, author: user, project: project, noteable: merge_request)
render_merge_request(merge_request) render_merge_request(merge_request)
end end
it 'merge_requests/diff_discussion.json' do it 'merge_requests/diff_discussion.json' do
create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) create(:diff_note_on_merge_request, project: project, author: user, position: position, noteable: merge_request)
render_discussions_json(merge_request) render_discussions_json(merge_request)
end end
it 'merge_requests/resolved_diff_discussion.json' do it 'merge_requests/resolved_diff_discussion.json' do
note = create(:discussion_note_on_merge_request, :resolved, project: project, author: admin, position: position, noteable: merge_request) note = create(:discussion_note_on_merge_request, :resolved, project: project, author: user, position: position, noteable: merge_request)
create(:system_note, project: project, author: admin, noteable: merge_request, discussion_id: note.discussion.id) create(:system_note, project: project, author: user, noteable: merge_request, discussion_id: note.discussion.id)
render_discussions_json(merge_request) render_discussions_json(merge_request)
end end
...@@ -111,7 +111,7 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: ...@@ -111,7 +111,7 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type:
context 'with mentions' do context 'with mentions' do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:description) { "@#{group.full_path} @all @#{admin.username}" } let(:description) { "@#{group.full_path} @all @#{user.username}" }
it 'merge_requests/merge_request_with_mentions.html' do it 'merge_requests/merge_request_with_mentions.html' do
render_merge_request(merge_request) render_merge_request(merge_request)
......
...@@ -5,9 +5,9 @@ require 'spec_helper' ...@@ -5,9 +5,9 @@ require 'spec_helper'
RSpec.describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') } let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') }
let(:user) { project.owner }
let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') } let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') }
let(:path) { "files/ruby/popen.rb" } let(:path) { "files/ruby/popen.rb" }
let(:position) do let(:position) do
...@@ -25,7 +25,7 @@ RSpec.describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)' ...@@ -25,7 +25,7 @@ RSpec.describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)'
end end
before do before do
sign_in(admin) sign_in(user)
end end
after do after do
......
...@@ -5,11 +5,11 @@ require 'spec_helper' ...@@ -5,11 +5,11 @@ require 'spec_helper'
RSpec.describe Projects::PipelineSchedulesController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::PipelineSchedulesController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :public, :repository) } let(:project) { create(:project, :public, :repository) }
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: admin) } let(:user) { project.owner }
let!(:pipeline_schedule_populated) { create(:ci_pipeline_schedule, project: project, owner: admin) } let!(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: user) }
let!(:pipeline_schedule_populated) { create(:ci_pipeline_schedule, project: project, owner: user) }
let!(:pipeline_schedule_variable1) { create(:ci_pipeline_schedule_variable, key: 'foo', value: 'foovalue', pipeline_schedule: pipeline_schedule_populated) } let!(:pipeline_schedule_variable1) { create(:ci_pipeline_schedule_variable, key: 'foo', value: 'foovalue', pipeline_schedule: pipeline_schedule_populated) }
let!(:pipeline_schedule_variable2) { create(:ci_pipeline_schedule_variable, key: 'bar', value: 'barvalue', pipeline_schedule: pipeline_schedule_populated) } let!(:pipeline_schedule_variable2) { create(:ci_pipeline_schedule_variable, key: 'bar', value: 'barvalue', pipeline_schedule: pipeline_schedule_populated) }
...@@ -20,7 +20,7 @@ RSpec.describe Projects::PipelineSchedulesController, '(JavaScript fixtures)', t ...@@ -20,7 +20,7 @@ RSpec.describe Projects::PipelineSchedulesController, '(JavaScript fixtures)', t
end end
before do before do
sign_in(admin) sign_in(user)
end end
it 'pipeline_schedules/edit.html' do it 'pipeline_schedules/edit.html' do
......
...@@ -5,7 +5,6 @@ require 'spec_helper' ...@@ -5,7 +5,6 @@ require 'spec_helper'
RSpec.describe Projects::PipelinesController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::PipelinesController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'pipelines-project') } let(:project) { create(:project, :repository, namespace: namespace, path: 'pipelines-project') }
let(:commit) { create(:commit, project: project) } let(:commit) { create(:commit, project: project) }
...@@ -22,7 +21,7 @@ RSpec.describe Projects::PipelinesController, '(JavaScript fixtures)', type: :co ...@@ -22,7 +21,7 @@ RSpec.describe Projects::PipelinesController, '(JavaScript fixtures)', type: :co
end end
before do before do
sign_in(admin) sign_in(user)
end end
it 'pipelines/pipelines.json' do it 'pipelines/pipelines.json' do
......
...@@ -7,11 +7,11 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do ...@@ -7,11 +7,11 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do
runners_token = 'runnerstoken:intabulasreferre' runners_token = 'runnerstoken:intabulasreferre'
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, namespace: namespace, path: 'builds-project', runners_token: runners_token) } let(:project) { create(:project, namespace: namespace, path: 'builds-project', runners_token: runners_token) }
let(:project_with_repo) { create(:project, :repository, description: 'Code and stuff') } let(:project_with_repo) { create(:project, :repository, description: 'Code and stuff') }
let(:project_variable_populated) { create(:project, namespace: namespace, path: 'builds-project2', runners_token: runners_token) } let(:project_variable_populated) { create(:project, namespace: namespace, path: 'builds-project2', runners_token: runners_token) }
let(:user) { project.owner }
render_views render_views
...@@ -20,8 +20,8 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do ...@@ -20,8 +20,8 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do
end end
before do before do
project.add_maintainer(admin) project_with_repo.add_maintainer(user)
sign_in(admin) sign_in(user)
allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon') allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
end end
......
...@@ -5,10 +5,10 @@ require 'spec_helper' ...@@ -5,10 +5,10 @@ require 'spec_helper'
RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project_empty_repo, namespace: namespace, path: 'services-project') } let(:project) { create(:project_empty_repo, namespace: namespace, path: 'services-project') }
let!(:service) { create(:prometheus_service, project: project) } let!(:service) { create(:prometheus_service, project: project) }
let(:user) { project.owner }
render_views render_views
...@@ -17,7 +17,7 @@ RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :con ...@@ -17,7 +17,7 @@ RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :con
end end
before do before do
sign_in(admin) sign_in(user)
end end
after do after do
......
...@@ -7,7 +7,7 @@ RSpec.describe SearchController, '(JavaScript fixtures)', type: :controller do ...@@ -7,7 +7,7 @@ RSpec.describe SearchController, '(JavaScript fixtures)', type: :controller do
render_views render_views
let_it_be(:user) { create(:admin) } let_it_be(:user) { create(:user) }
before(:all) do before(:all) do
clean_frontend_fixtures('search/') clean_frontend_fixtures('search/')
...@@ -66,6 +66,10 @@ RSpec.describe SearchController, '(JavaScript fixtures)', type: :controller do ...@@ -66,6 +66,10 @@ RSpec.describe SearchController, '(JavaScript fixtures)', type: :controller do
offset: 0) offset: 0)
end end
before do
project.add_developer(user)
end
it 'search/blob_search_result.html' do it 'search/blob_search_result.html' do
allow_next_instance_of(SearchServicePresenter) do |search_service| allow_next_instance_of(SearchServicePresenter) do |search_service|
allow(search_service).to receive(:search_objects).and_return(blobs) allow(search_service).to receive(:search_objects).and_return(blobs)
......
...@@ -5,10 +5,10 @@ require 'spec_helper' ...@@ -5,10 +5,10 @@ require 'spec_helper'
RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :controller do RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project_empty_repo, namespace: namespace, path: 'services-project') } let(:project) { create(:project_empty_repo, namespace: namespace, path: 'services-project') }
let!(:service) { create(:custom_issue_tracker_service, project: project) } let!(:service) { create(:custom_issue_tracker_service, project: project) }
let(:user) { project.owner }
render_views render_views
...@@ -17,7 +17,7 @@ RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :con ...@@ -17,7 +17,7 @@ RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :con
end end
before do before do
sign_in(admin) sign_in(user)
end end
after do after do
......
...@@ -5,10 +5,10 @@ require 'spec_helper' ...@@ -5,10 +5,10 @@ require 'spec_helper'
RSpec.describe SnippetsController, '(JavaScript fixtures)', type: :controller do RSpec.describe SnippetsController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') } let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
let(:snippet) { create(:personal_snippet, :public, title: 'snippet.md', content: '# snippet', file_name: 'snippet.md', author: admin) } let(:user) { project.owner }
let(:snippet) { create(:personal_snippet, :public, title: 'snippet.md', content: '# snippet', file_name: 'snippet.md', author: user) }
render_views render_views
...@@ -17,7 +17,7 @@ RSpec.describe SnippetsController, '(JavaScript fixtures)', type: :controller do ...@@ -17,7 +17,7 @@ RSpec.describe SnippetsController, '(JavaScript fixtures)', type: :controller do
end end
before do before do
sign_in(admin) sign_in(user)
allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo']) allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo'])
end end
...@@ -26,7 +26,7 @@ RSpec.describe SnippetsController, '(JavaScript fixtures)', type: :controller do ...@@ -26,7 +26,7 @@ RSpec.describe SnippetsController, '(JavaScript fixtures)', type: :controller do
end end
it 'snippets/show.html' do it 'snippets/show.html' do
create(:discussion_note_on_project_snippet, noteable: snippet, project: project, author: admin, note: '- [ ] Task List Item') create(:discussion_note_on_project_snippet, noteable: snippet, project: project, author: user, note: '- [ ] Task List Item')
get(:show, params: { id: snippet.to_param }) get(:show, params: { id: snippet.to_param })
......
...@@ -5,8 +5,8 @@ require 'spec_helper' ...@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe 'Tags (JavaScript fixtures)' do RSpec.describe 'Tags (JavaScript fixtures)' do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let_it_be(:admin) { create(:admin) }
let_it_be(:project) { create(:project, :repository, path: 'tags-project') } let_it_be(:project) { create(:project, :repository, path: 'tags-project') }
let_it_be(:user) { project.owner }
before(:all) do before(:all) do
clean_frontend_fixtures('api/tags/') clean_frontend_fixtures('api/tags/')
...@@ -20,7 +20,7 @@ RSpec.describe 'Tags (JavaScript fixtures)' do ...@@ -20,7 +20,7 @@ RSpec.describe 'Tags (JavaScript fixtures)' do
include ApiHelpers include ApiHelpers
it 'api/tags/tags.json' do it 'api/tags/tags.json' do
get api("/projects/#{project.id}/repository/tags", admin) get api("/projects/#{project.id}/repository/tags", user)
expect(response).to be_successful expect(response).to be_successful
end end
......
...@@ -5,13 +5,13 @@ require 'spec_helper' ...@@ -5,13 +5,13 @@ require 'spec_helper'
RSpec.describe 'Todos (JavaScript fixtures)' do RSpec.describe 'Todos (JavaScript fixtures)' do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project_empty_repo, namespace: namespace, path: 'todos-project') } let(:project) { create(:project_empty_repo, namespace: namespace, path: 'todos-project') }
let(:user) { project.owner }
let(:issue_1) { create(:issue, title: 'issue_1', project: project) } let(:issue_1) { create(:issue, title: 'issue_1', project: project) }
let!(:todo_1) { create(:todo, user: admin, project: project, target: issue_1, created_at: 5.hours.ago) } let!(:todo_1) { create(:todo, user: user, project: project, target: issue_1, created_at: 5.hours.ago) }
let(:issue_2) { create(:issue, title: 'issue_2', project: project) } let(:issue_2) { create(:issue, title: 'issue_2', project: project) }
let!(:todo_2) { create(:todo, :done, user: admin, project: project, target: issue_2, created_at: 50.hours.ago) } let!(:todo_2) { create(:todo, :done, user: user, project: project, target: issue_2, created_at: 50.hours.ago) }
before(:all) do before(:all) do
clean_frontend_fixtures('todos/') clean_frontend_fixtures('todos/')
...@@ -25,7 +25,7 @@ RSpec.describe 'Todos (JavaScript fixtures)' do ...@@ -25,7 +25,7 @@ RSpec.describe 'Todos (JavaScript fixtures)' do
render_views render_views
before do before do
sign_in(admin) sign_in(user)
end end
it 'todos/todos.html' do it 'todos/todos.html' do
...@@ -39,7 +39,7 @@ RSpec.describe 'Todos (JavaScript fixtures)' do ...@@ -39,7 +39,7 @@ RSpec.describe 'Todos (JavaScript fixtures)' do
render_views render_views
before do before do
sign_in(admin) sign_in(user)
end end
it 'todos/todos.json' do it 'todos/todos.json' do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe NavHelper, :do_not_mock_admin_mode do RSpec.describe NavHelper do
describe '#header_links' do describe '#header_links' do
include_context 'custom session' include_context 'custom session'
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe API::APIGuard::AdminModeMiddleware, :do_not_mock_admin_mode, :request_store do RSpec.describe API::APIGuard::AdminModeMiddleware, :request_store do
let(:user) { create(:admin) } let(:user) { create(:admin) }
it 'is loaded' do it 'is loaded' do
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
# Based on spec/requests/api/groups_spec.rb # Based on spec/requests/api/groups_spec.rb
# Should follow closely in order to ensure all situations are covered # Should follow closely in order to ensure all situations are covered
RSpec.describe 'getting group information', :do_not_mock_admin_mode do RSpec.describe 'getting group information' do
include GraphqlHelpers include GraphqlHelpers
include UploadHelpers include UploadHelpers
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Mark snippet as spam', :do_not_mock_admin_mode do RSpec.describe 'Mark snippet as spam' do
include GraphqlHelpers include GraphqlHelpers
let_it_be(:admin) { create(:admin) } let_it_be(:admin) { create(:admin) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe API::Users, :do_not_mock_admin_mode do RSpec.describe API::Users do
let_it_be(:admin) { create(:admin) } let_it_be(:admin) { create(:admin) }
let_it_be(:user, reload: true) { create(:user, username: 'user.with.dot') } let_it_be(:user, reload: true) { create(:user, username: 'user.with.dot') }
let_it_be(:key) { create(:key, user: user) } let_it_be(:key) { create(:key, user: user) }
......
...@@ -795,6 +795,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -795,6 +795,7 @@ RSpec.describe 'Git HTTP requests' do
context 'administrator' do context 'administrator' do
let(:user) { create(:admin) } let(:user) { create(:admin) }
context 'when admin mode is enabled', :enable_admin_mode do
it_behaves_like 'can download code only' it_behaves_like 'can download code only'
it 'downloads from other project get status 403' do it 'downloads from other project get status 403' do
...@@ -804,6 +805,17 @@ RSpec.describe 'Git HTTP requests' do ...@@ -804,6 +805,17 @@ RSpec.describe 'Git HTTP requests' do
end end
end end
context 'when admin mode is disabled' do
it_behaves_like 'can download code only'
it 'downloads from other project get status 404' do
clone_get "#{other_project.full_path}.git", user: 'gitlab-ci-token', password: build.token
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
context 'regular user' do context 'regular user' do
let(:user) { create(:user) } let(:user) { create(:user) }
......
...@@ -195,7 +195,7 @@ RSpec.describe 'Git LFS API and storage' do ...@@ -195,7 +195,7 @@ RSpec.describe 'Git LFS API and storage' do
end end
end end
context 'administrator' do context 'administrator', :enable_admin_mode do
let(:user) { create(:admin) } let(:user) { create(:admin) }
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) } let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
...@@ -453,7 +453,7 @@ RSpec.describe 'Git LFS API and storage' do ...@@ -453,7 +453,7 @@ RSpec.describe 'Git LFS API and storage' do
end end
end end
context 'administrator' do context 'administrator', :enable_admin_mode do
let(:user) { create(:admin) } let(:user) { create(:admin) }
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) } let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
......
...@@ -12,7 +12,7 @@ RSpec.describe 'Self-Monitoring project requests' do ...@@ -12,7 +12,7 @@ RSpec.describe 'Self-Monitoring project requests' do
it_behaves_like 'not accessible to non-admin users' it_behaves_like 'not accessible to non-admin users'
context 'with admin user' do context 'with admin user', :enable_admin_mode do
before do before do
login_as(admin) login_as(admin)
end end
...@@ -36,7 +36,7 @@ RSpec.describe 'Self-Monitoring project requests' do ...@@ -36,7 +36,7 @@ RSpec.describe 'Self-Monitoring project requests' do
it_behaves_like 'not accessible to non-admin users' it_behaves_like 'not accessible to non-admin users'
context 'with admin user' do context 'with admin user', :enable_admin_mode do
before do before do
login_as(admin) login_as(admin)
end end
...@@ -116,7 +116,7 @@ RSpec.describe 'Self-Monitoring project requests' do ...@@ -116,7 +116,7 @@ RSpec.describe 'Self-Monitoring project requests' do
it_behaves_like 'not accessible to non-admin users' it_behaves_like 'not accessible to non-admin users'
context 'with admin user' do context 'with admin user', :enable_admin_mode do
before do before do
login_as(admin) login_as(admin)
end end
...@@ -140,7 +140,7 @@ RSpec.describe 'Self-Monitoring project requests' do ...@@ -140,7 +140,7 @@ RSpec.describe 'Self-Monitoring project requests' do
it_behaves_like 'not accessible to non-admin users' it_behaves_like 'not accessible to non-admin users'
context 'with admin user' do context 'with admin user', :enable_admin_mode do
before do before do
login_as(admin) login_as(admin)
end end
......
...@@ -286,19 +286,13 @@ RSpec.configure do |config| ...@@ -286,19 +286,13 @@ RSpec.configure do |config|
./ee/spec/elastic_integration ./ee/spec/elastic_integration
./ee/spec/finders ./ee/spec/finders
./ee/spec/lib ./ee/spec/lib
./ee/spec/requests/admin
./ee/spec/serializers ./ee/spec/serializers
./ee/spec/support/shared_examples/finders/geo ./ee/spec/support/shared_examples/finders/geo
./ee/spec/support/shared_examples/graphql/geo ./ee/spec/support/shared_examples/graphql/geo
./spec/finders ./spec/finders
./spec/frontend
./spec/helpers
./spec/lib ./spec/lib
./spec/requests
./spec/serializers ./spec/serializers
./spec/support/shared_examples/requests
./spec/support/shared_examples/lib/gitlab ./spec/support/shared_examples/lib/gitlab
./spec/views
./spec/workers ./spec/workers
) )
......
...@@ -20,6 +20,18 @@ RSpec.shared_examples 'not accessible to non-admin users' do ...@@ -20,6 +20,18 @@ RSpec.shared_examples 'not accessible to non-admin users' do
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
context 'with authenticated admin user without admin mode' do
before do
login_as(create(:admin))
end
it 'redirects to enable admin mode' do
subject
expect(response).to redirect_to(new_admin_session_path)
end
end
end end
# Requires subject and worker_class and status_api to be defined # Requires subject and worker_class and status_api to be defined
......
...@@ -16,6 +16,7 @@ RSpec.describe "projects/artifacts/_artifact.html.haml" do ...@@ -16,6 +16,7 @@ RSpec.describe "projects/artifacts/_artifact.html.haml" do
context 'with admin' do context 'with admin' do
let(:user) { build(:admin) } let(:user) { build(:admin) }
context 'when admin mode is enabled', :enable_admin_mode do
it 'has a delete button' do it 'has a delete button' do
render_partial render_partial
...@@ -23,6 +24,16 @@ RSpec.describe "projects/artifacts/_artifact.html.haml" do ...@@ -23,6 +24,16 @@ RSpec.describe "projects/artifacts/_artifact.html.haml" do
end end
end end
context 'when admin mode is disabled' do
it 'has no delete button' do
project.add_reporter(user)
render_partial
expect(rendered).not_to have_link('Delete artifacts')
end
end
end
context 'with owner' do context 'with owner' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { build(:project, namespace: user.namespace) } let(:project) { build(:project, namespace: user.namespace) }
......
...@@ -54,12 +54,23 @@ RSpec.describe 'search/_results' do ...@@ -54,12 +54,23 @@ RSpec.describe 'search/_results' do
let(:scope) { search_scope } let(:scope) { search_scope }
let(:search_objects) { Gitlab::ProjectSearchResults.new(user, '*', project: project).objects(scope) } let(:search_objects) { Gitlab::ProjectSearchResults.new(user, '*', project: project).objects(scope) }
context 'when admin mode is enabled', :enable_admin_mode do
it 'renders the click text event tracking attributes' do it 'renders the click text event tracking attributes' do
render render
expect(rendered).to have_selector('[data-track-event=click_text]') expect(rendered).to have_selector('[data-track-event=click_text]')
expect(rendered).to have_selector('[data-track-property=search_result]') expect(rendered).to have_selector('[data-track-property=search_result]')
end end
end
context 'when admin mode is disabled' do
it 'does not render the click text event tracking attributes' do
render
expect(rendered).not_to have_selector('[data-track-event=click_text]')
expect(rendered).not_to have_selector('[data-track-property=search_result]')
end
end
it 'does render the sidebar' do it 'does render the sidebar' do
render render
...@@ -74,12 +85,23 @@ RSpec.describe 'search/_results' do ...@@ -74,12 +85,23 @@ RSpec.describe 'search/_results' do
let(:scope) { search_scope } let(:scope) { search_scope }
let(:search_objects) { Gitlab::ProjectSearchResults.new(user, '*', project: project).objects(scope) } let(:search_objects) { Gitlab::ProjectSearchResults.new(user, '*', project: project).objects(scope) }
context 'when admin mode is enabled', :enable_admin_mode do
it 'renders the click text event tracking attributes' do it 'renders the click text event tracking attributes' do
render render
expect(rendered).to have_selector('[data-track-event=click_text]') expect(rendered).to have_selector('[data-track-event=click_text]')
expect(rendered).to have_selector('[data-track-property=search_result]') expect(rendered).to have_selector('[data-track-property=search_result]')
end end
end
context 'when admin mode is disabled' do
it 'does not render the click text event tracking attributes' do
render
expect(rendered).not_to have_selector('[data-track-event=click_text]')
expect(rendered).not_to have_selector('[data-track-property=search_result]')
end
end
it 'does not render the sidebar' do it 'does not render the sidebar' do
render render
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment