Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-06 06:08:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-06 06:08:47 +0300
commitcfbaef3f1c28cdb9b15615215b87167181cb210f (patch)
tree8713f67e889a9b6d89fd35584ec7405f5a379565 /spec
parenta97acfe57aac7d8206e99e5ffdfe9c5fb5b69544 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/profiles/notifications_controller_spec.rb1
-rw-r--r--spec/frontend/diffs/components/diff_line_gutter_content_spec.js (renamed from spec/javascripts/diffs/components/diff_line_gutter_content_spec.js)2
-rw-r--r--spec/frontend/diffs/mock_data/diff_file.js244
-rw-r--r--spec/javascripts/diffs/mock_data/diff_file.js249
-rw-r--r--spec/lib/quality/test_level_spec.rb4
-rw-r--r--spec/requests/profiles/notifications_controller_spec.rb42
6 files changed, 293 insertions, 249 deletions
diff --git a/spec/controllers/profiles/notifications_controller_spec.rb b/spec/controllers/profiles/notifications_controller_spec.rb
index ede68744ac6..ba85c781a93 100644
--- a/spec/controllers/profiles/notifications_controller_spec.rb
+++ b/spec/controllers/profiles/notifications_controller_spec.rb
@@ -24,7 +24,6 @@ describe Profiles::NotificationsController do
context 'with groups that do not have notification preferences' do
set(:group) { create(:group) }
set(:subgroup) { create(:group, parent: group) }
-
before do
group.add_developer(user)
end
diff --git a/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js b/spec/frontend/diffs/components/diff_line_gutter_content_spec.js
index 8d20be9971d..e1c03983ab5 100644
--- a/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
+++ b/spec/frontend/diffs/components/diff_line_gutter_content_spec.js
@@ -1,5 +1,5 @@
import Vue from 'vue';
-import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
+import { createComponentWithStore } from 'helpers/vue_mount_component_helper';
import DiffLineGutterContent from '~/diffs/components/diff_line_gutter_content.vue';
import { createStore } from '~/mr_notes/stores';
import discussionsMockData from '../mock_data/diff_discussions';
diff --git a/spec/frontend/diffs/mock_data/diff_file.js b/spec/frontend/diffs/mock_data/diff_file.js
new file mode 100644
index 00000000000..27428197c1c
--- /dev/null
+++ b/spec/frontend/diffs/mock_data/diff_file.js
@@ -0,0 +1,244 @@
+export default {
+ submodule: false,
+ submodule_link: null,
+ blob: {
+ id: '9e10516ca50788acf18c518a231914a21e5f16f7',
+ path: 'CHANGELOG',
+ name: 'CHANGELOG',
+ mode: '100644',
+ readable_text: true,
+ icon: 'file-text-o',
+ },
+ blob_path: 'CHANGELOG',
+ blob_name: 'CHANGELOG',
+ blob_icon: '<i aria-hidden="true" data-hidden="true" class="fa fa-file-text-o fa-fw"></i>',
+ file_hash: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a',
+ file_path: 'CHANGELOG',
+ new_file: false,
+ deleted_file: false,
+ renamed_file: false,
+ old_path: 'CHANGELOG',
+ new_path: 'CHANGELOG',
+ mode_changed: false,
+ a_mode: '100644',
+ b_mode: '100644',
+ text: true,
+ viewer: {
+ name: 'text',
+ error: null,
+ collapsed: false,
+ },
+ added_lines: 2,
+ removed_lines: 0,
+ diff_refs: {
+ base_sha: 'e63f41fe459e62e1228fcef60d7189127aeba95a',
+ start_sha: 'd9eaefe5a676b820c57ff18cf5b68316025f7962',
+ head_sha: 'c48ee0d1bf3b30453f5b32250ce03134beaa6d13',
+ },
+ content_sha: 'c48ee0d1bf3b30453f5b32250ce03134beaa6d13',
+ stored_externally: null,
+ external_storage: null,
+ old_path_html: 'CHANGELOG',
+ new_path_html: 'CHANGELOG',
+ edit_path: '/gitlab-org/gitlab-test/edit/spooky-stuff/CHANGELOG',
+ view_path: '/gitlab-org/gitlab-test/blob/spooky-stuff/CHANGELOG',
+ replaced_view_path: null,
+ collapsed: false,
+ renderIt: false,
+ too_large: false,
+ context_lines_path:
+ '/gitlab-org/gitlab-test/blob/c48ee0d1bf3b30453f5b32250ce03134beaa6d13/CHANGELOG/diff',
+ highlighted_diff_lines: [
+ {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_1',
+ type: 'new',
+ old_line: null,
+ new_line: 1,
+ discussions: [],
+ text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
+ rich_text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
+ meta_data: null,
+ },
+ {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2',
+ type: 'new',
+ old_line: null,
+ new_line: 2,
+ discussions: [],
+ text: '+<span id="LC2" class="line" lang="plaintext"></span>\n',
+ rich_text: '+<span id="LC2" class="line" lang="plaintext"></span>\n',
+ meta_data: null,
+ },
+ {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_3',
+ type: null,
+ old_line: 1,
+ new_line: 3,
+ discussions: [],
+ text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
+ rich_text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
+ meta_data: null,
+ },
+ {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_2_4',
+ type: null,
+ old_line: 2,
+ new_line: 4,
+ discussions: [],
+ text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
+ rich_text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
+ meta_data: null,
+ },
+ {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_3_5',
+ type: null,
+ old_line: 3,
+ new_line: 5,
+ discussions: [],
+ text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
+ rich_text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
+ meta_data: null,
+ },
+ {
+ line_code: null,
+ type: 'match',
+ old_line: null,
+ new_line: null,
+ discussions: [],
+ text: '',
+ rich_text: '',
+ meta_data: {
+ old_pos: 3,
+ new_pos: 5,
+ },
+ },
+ ],
+ parallel_diff_lines: [
+ {
+ left: {
+ type: 'empty-cell',
+ },
+ right: {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_1',
+ type: 'new',
+ old_line: null,
+ new_line: 1,
+ discussions: [],
+ text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
+ rich_text: '<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
+ meta_data: null,
+ },
+ },
+ {
+ left: {
+ type: 'empty-cell',
+ },
+ right: {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2',
+ type: 'new',
+ old_line: null,
+ new_line: 2,
+ discussions: [],
+ text: '+<span id="LC2" class="line" lang="plaintext"></span>\n',
+ rich_text: '<span id="LC2" class="line" lang="plaintext"></span>\n',
+ meta_data: null,
+ },
+ },
+ {
+ left: {
+ line_Code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_3',
+ type: null,
+ old_line: 1,
+ new_line: 3,
+ discussions: [],
+ text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
+ rich_text: '<span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
+ meta_data: null,
+ },
+ right: {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_3',
+ type: null,
+ old_line: 1,
+ new_line: 3,
+ discussions: [],
+ text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
+ rich_text: '<span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
+ meta_data: null,
+ },
+ },
+ {
+ left: {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_2_4',
+ type: null,
+ old_line: 2,
+ new_line: 4,
+ discussions: [],
+ text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
+ rich_text: '<span id="LC4" class="line" lang="plaintext"></span>\n',
+ meta_data: null,
+ },
+ right: {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_2_4',
+ type: null,
+ old_line: 2,
+ new_line: 4,
+ discussions: [],
+ text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
+ rich_text: '<span id="LC4" class="line" lang="plaintext"></span>\n',
+ meta_data: null,
+ },
+ },
+ {
+ left: {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_3_5',
+ type: null,
+ old_line: 3,
+ new_line: 5,
+ discussions: [],
+ text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
+ rich_text: '<span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
+ meta_data: null,
+ },
+ right: {
+ line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_3_5',
+ type: null,
+ old_line: 3,
+ new_line: 5,
+ discussions: [],
+ text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
+ rich_text: '<span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
+ meta_data: null,
+ },
+ },
+ {
+ left: {
+ line_code: null,
+ type: 'match',
+ old_line: null,
+ new_line: null,
+ discussions: [],
+ text: '',
+ rich_text: '',
+ meta_data: {
+ old_pos: 3,
+ new_pos: 5,
+ },
+ },
+ right: {
+ line_code: null,
+ type: 'match',
+ old_line: null,
+ new_line: null,
+ discussions: [],
+ text: '',
+ rich_text: '',
+ meta_data: {
+ old_pos: 3,
+ new_pos: 5,
+ },
+ },
+ },
+ ],
+ discussions: [],
+ renderingLines: false,
+};
diff --git a/spec/javascripts/diffs/mock_data/diff_file.js b/spec/javascripts/diffs/mock_data/diff_file.js
index 531686efff1..9dc365b7403 100644
--- a/spec/javascripts/diffs/mock_data/diff_file.js
+++ b/spec/javascripts/diffs/mock_data/diff_file.js
@@ -1,246 +1,5 @@
-// Copied to ee/spec/frontend/diffs/mock_data/diff_file.js
+// No new code should be added to this file. Instead, modify the
+// file this one re-exports from. For more detail about why, see:
+// https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/31349
-export default {
- submodule: false,
- submodule_link: null,
- blob: {
- id: '9e10516ca50788acf18c518a231914a21e5f16f7',
- path: 'CHANGELOG',
- name: 'CHANGELOG',
- mode: '100644',
- readable_text: true,
- icon: 'file-text-o',
- },
- blob_path: 'CHANGELOG',
- blob_name: 'CHANGELOG',
- blob_icon: '<i aria-hidden="true" data-hidden="true" class="fa fa-file-text-o fa-fw"></i>',
- file_hash: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a',
- file_path: 'CHANGELOG',
- new_file: false,
- deleted_file: false,
- renamed_file: false,
- old_path: 'CHANGELOG',
- new_path: 'CHANGELOG',
- mode_changed: false,
- a_mode: '100644',
- b_mode: '100644',
- text: true,
- viewer: {
- name: 'text',
- error: null,
- collapsed: false,
- },
- added_lines: 2,
- removed_lines: 0,
- diff_refs: {
- base_sha: 'e63f41fe459e62e1228fcef60d7189127aeba95a',
- start_sha: 'd9eaefe5a676b820c57ff18cf5b68316025f7962',
- head_sha: 'c48ee0d1bf3b30453f5b32250ce03134beaa6d13',
- },
- content_sha: 'c48ee0d1bf3b30453f5b32250ce03134beaa6d13',
- stored_externally: null,
- external_storage: null,
- old_path_html: 'CHANGELOG',
- new_path_html: 'CHANGELOG',
- edit_path: '/gitlab-org/gitlab-test/edit/spooky-stuff/CHANGELOG',
- view_path: '/gitlab-org/gitlab-test/blob/spooky-stuff/CHANGELOG',
- replaced_view_path: null,
- collapsed: false,
- renderIt: false,
- too_large: false,
- context_lines_path:
- '/gitlab-org/gitlab-test/blob/c48ee0d1bf3b30453f5b32250ce03134beaa6d13/CHANGELOG/diff',
- highlighted_diff_lines: [
- {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_1',
- type: 'new',
- old_line: null,
- new_line: 1,
- discussions: [],
- text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
- rich_text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
- meta_data: null,
- },
- {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2',
- type: 'new',
- old_line: null,
- new_line: 2,
- discussions: [],
- text: '+<span id="LC2" class="line" lang="plaintext"></span>\n',
- rich_text: '+<span id="LC2" class="line" lang="plaintext"></span>\n',
- meta_data: null,
- },
- {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_3',
- type: null,
- old_line: 1,
- new_line: 3,
- discussions: [],
- text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- rich_text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- meta_data: null,
- },
- {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_2_4',
- type: null,
- old_line: 2,
- new_line: 4,
- discussions: [],
- text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
- rich_text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
- meta_data: null,
- },
- {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_3_5',
- type: null,
- old_line: 3,
- new_line: 5,
- discussions: [],
- text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- rich_text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- meta_data: null,
- },
- {
- line_code: null,
- type: 'match',
- old_line: null,
- new_line: null,
- discussions: [],
- text: '',
- rich_text: '',
- meta_data: {
- old_pos: 3,
- new_pos: 5,
- },
- },
- ],
- parallel_diff_lines: [
- {
- left: {
- type: 'empty-cell',
- },
- right: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_1',
- type: 'new',
- old_line: null,
- new_line: 1,
- discussions: [],
- text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
- rich_text: '<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
- meta_data: null,
- },
- },
- {
- left: {
- type: 'empty-cell',
- },
- right: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2',
- type: 'new',
- old_line: null,
- new_line: 2,
- discussions: [],
- text: '+<span id="LC2" class="line" lang="plaintext"></span>\n',
- rich_text: '<span id="LC2" class="line" lang="plaintext"></span>\n',
- meta_data: null,
- },
- },
- {
- left: {
- line_Code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_3',
- type: null,
- old_line: 1,
- new_line: 3,
- discussions: [],
- text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- rich_text: '<span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- meta_data: null,
- },
- right: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_3',
- type: null,
- old_line: 1,
- new_line: 3,
- discussions: [],
- text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- rich_text: '<span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- meta_data: null,
- },
- },
- {
- left: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_2_4',
- type: null,
- old_line: 2,
- new_line: 4,
- discussions: [],
- text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
- rich_text: '<span id="LC4" class="line" lang="plaintext"></span>\n',
- meta_data: null,
- },
- right: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_2_4',
- type: null,
- old_line: 2,
- new_line: 4,
- discussions: [],
- text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
- rich_text: '<span id="LC4" class="line" lang="plaintext"></span>\n',
- meta_data: null,
- },
- },
- {
- left: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_3_5',
- type: null,
- old_line: 3,
- new_line: 5,
- discussions: [],
- text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- rich_text: '<span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- meta_data: null,
- },
- right: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_3_5',
- type: null,
- old_line: 3,
- new_line: 5,
- discussions: [],
- text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- rich_text: '<span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- meta_data: null,
- },
- },
- {
- left: {
- line_code: null,
- type: 'match',
- old_line: null,
- new_line: null,
- discussions: [],
- text: '',
- rich_text: '',
- meta_data: {
- old_pos: 3,
- new_pos: 5,
- },
- },
- right: {
- line_code: null,
- type: 'match',
- old_line: null,
- new_line: null,
- discussions: [],
- text: '',
- rich_text: '',
- meta_data: {
- old_pos: 3,
- new_pos: 5,
- },
- },
- },
- ],
- discussions: [],
- renderingLines: false,
-};
+export { default } from '../../../frontend/diffs/mock_data/diff_file';
diff --git a/spec/lib/quality/test_level_spec.rb b/spec/lib/quality/test_level_spec.rb
index 13817bdcc72..621a426a18d 100644
--- a/spec/lib/quality/test_level_spec.rb
+++ b/spec/lib/quality/test_level_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe Quality::TestLevel do
context 'when level is unit' do
it 'returns a pattern' do
expect(subject.pattern(:unit))
- .to eq("spec/{bin,config,db,dependencies,factories,finders,frontend,graphql,haml_lint,helpers,initializers,javascripts,lib,models,policies,presenters,rack_servers,routing,rubocop,serializers,services,sidekiq,tasks,uploaders,validators,views,workers,elastic_integration}{,/**/}*_spec.rb")
+ .to eq("spec/{bin,config,db,dependencies,factories,finders,frontend,graphql,haml_lint,helpers,initializers,javascripts,lib,models,policies,presenters,rack_servers,replicators,routing,rubocop,serializers,services,sidekiq,tasks,uploaders,validators,views,workers,elastic_integration}{,/**/}*_spec.rb")
end
end
@@ -82,7 +82,7 @@ RSpec.describe Quality::TestLevel do
context 'when level is unit' do
it 'returns a regexp' do
expect(subject.regexp(:unit))
- .to eq(%r{spec/(bin|config|db|dependencies|factories|finders|frontend|graphql|haml_lint|helpers|initializers|javascripts|lib|models|policies|presenters|rack_servers|routing|rubocop|serializers|services|sidekiq|tasks|uploaders|validators|views|workers|elastic_integration)})
+ .to eq(%r{spec/(bin|config|db|dependencies|factories|finders|frontend|graphql|haml_lint|helpers|initializers|javascripts|lib|models|policies|presenters|rack_servers|replicators|routing|rubocop|serializers|services|sidekiq|tasks|uploaders|validators|views|workers|elastic_integration)})
end
end
diff --git a/spec/requests/profiles/notifications_controller_spec.rb b/spec/requests/profiles/notifications_controller_spec.rb
new file mode 100644
index 00000000000..41349d6c12d
--- /dev/null
+++ b/spec/requests/profiles/notifications_controller_spec.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'view user notifications' do
+ let(:user) do
+ create(:user) do |user|
+ user.emails.create(email: 'original@example.com')
+ user.emails.create(email: 'new@example.com')
+ user.notification_email = 'original@example.com'
+ user.save!
+ end
+ end
+
+ before do
+ login_as(user)
+
+ create_list(:group, 2) do |group|
+ group.add_developer(user)
+ end
+ end
+
+ def get_profile_notifications
+ get profile_notifications_path
+ end
+
+ describe 'GET /profile/notifications' do
+ it 'avoid N+1 due to an additional groups (with no parent group)' do
+ get_profile_notifications
+
+ control = ActiveRecord::QueryRecorder.new do
+ get_profile_notifications
+ end
+
+ create_list(:group, 2) { |group| group.add_developer(user) }
+
+ expect do
+ get_profile_notifications
+ end.not_to exceed_query_limit(control)
+ end
+ end
+end