From 3bc30c280c408f3f31c90961e0fc5809c6246137 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 8 Feb 2021 15:09:38 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../Change Documentation Location.md | 4 +-- .../merge_request_templates/Documentation.md | 2 +- .rubocop_manual_todo.yml | 1 - app/assets/stylesheets/framework/buttons.scss | 2 -- .../stylesheets/startup/startup-general.scss | 1 - app/views/layouts/_startup_css.haml | 2 +- doc/api/users.md | 2 +- spec/factories/notes.rb | 16 +++++++---- spec/models/note_spec.rb | 28 ++++++++----------- spec/support/factory_bot.rb | 13 +++++++++ 10 files changed, 39 insertions(+), 32 deletions(-) diff --git a/.gitlab/merge_request_templates/Change Documentation Location.md b/.gitlab/merge_request_templates/Change Documentation Location.md index 1197c6adc40..0c675d8d0c6 100644 --- a/.gitlab/merge_request_templates/Change Documentation Location.md +++ b/.gitlab/merge_request_templates/Change Documentation Location.md @@ -8,9 +8,7 @@ ## Related issues - - -Closes + ## Moving docs to a new location? diff --git a/.gitlab/merge_request_templates/Documentation.md b/.gitlab/merge_request_templates/Documentation.md index 34b48f6ded1..0c507277ede 100644 --- a/.gitlab/merge_request_templates/Documentation.md +++ b/.gitlab/merge_request_templates/Documentation.md @@ -11,7 +11,7 @@ ## Related issues - + ## Author's checklist (required) diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index 61d08cffddc..131b56f8132 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -25,7 +25,6 @@ FactoryBot/InlineAssociation: - 'spec/factories/go_modules.rb' - 'spec/factories/group_group_links.rb' - 'spec/factories/import_export_uploads.rb' - - 'spec/factories/notes.rb' - 'spec/factories/uploads.rb' - 'spec/factories/wiki_pages.rb' diff --git a/app/assets/stylesheets/framework/buttons.scss b/app/assets/stylesheets/framework/buttons.scss index e1cde8594fd..b51fec925cb 100644 --- a/app/assets/stylesheets/framework/buttons.scss +++ b/app/assets/stylesheets/framework/buttons.scss @@ -95,8 +95,6 @@ &:active, &.active { - box-shadow: $gl-btn-active-background; - background-color: $dark; border-color: $border-dark; color: $color; diff --git a/app/assets/stylesheets/startup/startup-general.scss b/app/assets/stylesheets/startup/startup-general.scss index 7f6e537af8f..103a3999161 100644 --- a/app/assets/stylesheets/startup/startup-general.scss +++ b/app/assets/stylesheets/startup/startup-general.scss @@ -736,7 +736,6 @@ body { white-space: nowrap; } .btn:active, .btn.active { - box-shadow: rgba(0, 0, 0, 0.16); background-color: #eaeaea; border-color: #e3e3e3; color: #303030; diff --git a/app/views/layouts/_startup_css.haml b/app/views/layouts/_startup_css.haml index 35b91c8d35e..7d3cfe28007 100644 --- a/app/views/layouts/_startup_css.haml +++ b/app/views/layouts/_startup_css.haml @@ -1,5 +1,5 @@ - startup_filename = current_path?("sessions#new") ? 'signin' : user_application_theme == 'gl-dark' ? 'dark' : 'general' -%style{ type: "text/css" } +%style = Rails.application.assets_manifest.find_sources("themes/#{user_application_theme_css_filename}.css").first.to_s.html_safe if user_application_theme_css_filename = Rails.application.assets_manifest.find_sources("startup/startup-#{startup_filename}.css").first.to_s.html_safe diff --git a/doc/api/users.md b/doc/api/users.md index a7714b72b59..92f36079ae9 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -88,7 +88,7 @@ GET /users | `order_by` | string | no | Return users ordered by `id`, `name`, `username`, `created_at`, or `updated_at` fields. Default is `id` | | `sort` | string | no | Return users sorted in `asc` or `desc` order. Default is `desc` | | `two_factor` | string | no | Filter users by Two-factor authentication. Filter values are `enabled` or `disabled`. By default it returns all users | -| `without_projects` | boolean | no | Filter users without projects. Default is `false` | +| `without_projects` | boolean | no | Filter users without projects. Default is `false`, which means that all users are returned, with and without projects. | | `admins` | boolean | no | Return only admin users. Default is `false` | ```json diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb index 4b1f3194ce5..299d08972b7 100644 --- a/spec/factories/notes.rb +++ b/spec/factories/notes.rb @@ -8,7 +8,7 @@ FactoryBot.define do factory :note do project note { generate(:title) } - author { project&.creator || create(:user) } + author { project&.creator || association(:user) } on_issue factory :note_on_commit, traits: [:on_commit] @@ -55,7 +55,7 @@ FactoryBot.define do end position do - build(:text_diff_position, + association(:text_diff_position, file: "files/ruby/popen.rb", old_line: nil, new_line: line_number, @@ -64,7 +64,7 @@ FactoryBot.define do trait :folded_position do position do - build(:text_diff_position, + association(:text_diff_position, file: "files/ruby/popen.rb", old_line: 1, new_line: 1, @@ -74,7 +74,7 @@ FactoryBot.define do factory :image_diff_note_on_merge_request do position do - build(:image_diff_position, + association(:image_diff_position, file: "files/images/any_image.png", diff_refs: diff_refs) end @@ -90,7 +90,7 @@ FactoryBot.define do end position do - build(:text_diff_position, + association(:text_diff_position, file: "files/ruby/popen.rb", old_line: nil, new_line: line_number, @@ -100,7 +100,11 @@ FactoryBot.define do end factory :diff_note_on_design, parent: :note, traits: [:on_design], class: 'DiffNote' do - position { build(:image_diff_position, file: noteable.full_path, diff_refs: noteable.diff_refs) } + position do + association(:image_diff_position, + file: noteable.full_path, + diff_refs: noteable.diff_refs) + end end trait :on_commit do diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 6e87ca6dcf7..5c14a3db54e 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -890,35 +890,31 @@ RSpec.describe Note do describe '#cache_markdown_field' do let(:html) { '

some html

'} + before do + allow(Banzai::Renderer).to receive(:cacheless_render_field).and_call_original + end + context 'note for a project snippet' do let(:snippet) { create(:project_snippet) } - let(:note) { build(:note_on_project_snippet, project: snippet.project, noteable: snippet) } + let(:note) { create(:note_on_project_snippet, project: snippet.project, noteable: snippet) } - before do + it 'skips project check' do expect(Banzai::Renderer).to receive(:cacheless_render_field) - .with(note, :note, { skip_project_check: false }).and_return(html) + .with(note, :note, { skip_project_check: false }) - note.save - end - - it 'creates a note' do - expect(note.note_html).to eq(html) + note.update!(note: html) end end context 'note for a personal snippet' do let(:snippet) { create(:personal_snippet) } - let(:note) { build(:note_on_personal_snippet, noteable: snippet) } + let(:note) { create(:note_on_personal_snippet, noteable: snippet) } - before do + it 'does not skip project check' do expect(Banzai::Renderer).to receive(:cacheless_render_field) - .with(note, :note, { skip_project_check: true }).and_return(html) + .with(note, :note, { skip_project_check: true }) - note.save - end - - it 'creates a note' do - expect(note.note_html).to eq(html) + note.update!(note: html) end end end diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb index c9d372993b5..5761e05d541 100644 --- a/spec/support/factory_bot.rb +++ b/spec/support/factory_bot.rb @@ -3,3 +3,16 @@ FactoryBot::SyntaxRunner.class_eval do include RSpec::Mocks::ExampleMethods end + +# Patching FactoryBot to allow stubbing non AR models +# See https://github.com/thoughtbot/factory_bot/pull/1466 +module Gitlab + module FactoryBotStubPatch + def has_settable_id?(result_instance) + result_instance.class.respond_to?(:primary_key) && + result_instance.class.primary_key + end + end +end + +FactoryBot::Strategy::Stub.prepend(Gitlab::FactoryBotStubPatch)