From d9251dac4c8f9e27f1e2db4b537d47d7d5a9e5be Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 14 Nov 2019 06:06:26 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../javascripts/lib/utils/tick_formats.js | 39 -------------- app/services/notes/post_process_service.rb | 2 + .../shared/_mobile_clone_panel.html.haml | 2 +- ...x-project-clone-dropdrown-button-width.yml | 5 ++ .../id-fix-any-approver-rule-for-projects.yml | 5 ++ ...3850_fix_any_approver_rule_for_projects.rb | 51 +++++++++++++++++++ doc/development/api_graphql_styleguide.md | 41 +++++++++++++++ doc/install/installation.md | 24 ++++----- locale/gitlab.pot | 12 +++++ qa/Gemfile | 7 ++- qa/Gemfile.lock | 9 +++- .../issue/check_mentions_for_xss_spec.rb | 2 +- .../lib/utils/tick_formats_spec.js | 40 --------------- spec/workers/new_note_worker_spec.rb | 19 +++---- 14 files changed, 154 insertions(+), 104 deletions(-) delete mode 100644 app/assets/javascripts/lib/utils/tick_formats.js create mode 100644 changelogs/unreleased/28258-fix-project-clone-dropdrown-button-width.yml create mode 100644 changelogs/unreleased/id-fix-any-approver-rule-for-projects.yml create mode 100644 db/post_migrate/20191008143850_fix_any_approver_rule_for_projects.rb delete mode 100644 spec/javascripts/lib/utils/tick_formats_spec.js diff --git a/app/assets/javascripts/lib/utils/tick_formats.js b/app/assets/javascripts/lib/utils/tick_formats.js deleted file mode 100644 index af3ca714400..00000000000 --- a/app/assets/javascripts/lib/utils/tick_formats.js +++ /dev/null @@ -1,39 +0,0 @@ -import { createDateTimeFormat } from '../../locale'; - -let dateTimeFormats; - -export const initDateFormats = () => { - const dayFormat = createDateTimeFormat({ month: 'short', day: 'numeric' }); - const monthFormat = createDateTimeFormat({ month: 'long' }); - const yearFormat = createDateTimeFormat({ year: 'numeric' }); - - dateTimeFormats = { - dayFormat, - monthFormat, - yearFormat, - }; -}; - -initDateFormats(); - -/** - Formats a localized date in way that it can be used for d3.js axis.tickFormat(). - - That is, it displays - - 4-digit for first of January - - full month name for first of every month - - day and abbreviated month otherwise - - see also https://github.com/d3/d3-3.x-api-reference/blob/master/SVG-Axes.md#tickFormat - */ -export const dateTickFormat = date => { - if (date.getDate() !== 1) { - return dateTimeFormats.dayFormat.format(date); - } - - if (date.getMonth() > 0) { - return dateTimeFormats.monthFormat.format(date); - } - - return dateTimeFormats.yearFormat.format(date); -}; diff --git a/app/services/notes/post_process_service.rb b/app/services/notes/post_process_service.rb index 48722cc2a79..53b3b57f4af 100644 --- a/app/services/notes/post_process_service.rb +++ b/app/services/notes/post_process_service.rb @@ -35,3 +35,5 @@ module Notes end end end + +Notes::PostProcessService.prepend_if_ee('EE::Notes::PostProcessService') diff --git a/app/views/shared/_mobile_clone_panel.html.haml b/app/views/shared/_mobile_clone_panel.html.haml index 1e6b6f7c79b..2887acf7cd7 100644 --- a/app/views/shared/_mobile_clone_panel.html.haml +++ b/app/views/shared/_mobile_clone_panel.html.haml @@ -4,7 +4,7 @@ .btn-group.mobile-git-clone.js-mobile-git-clone.btn-block = clipboard_button(button_text: default_clone_label, text: default_url_to_repo(project), hide_button_icon: true, class: "btn-primary flex-fill bold justify-content-center input-group-text clone-dropdown-btn js-clone-dropdown-label") - %button.btn.btn-primary.dropdown-toggle.js-dropdown-toggle{ type: "button", data: { toggle: "dropdown" } } + %button.btn.btn-primary.dropdown-toggle.js-dropdown-toggle.flex-grow-0.d-flex-center{ type: "button", data: { toggle: "dropdown" } } = sprite_icon("arrow-down", css_class: "dropdown-btn-icon icon") %ul.dropdown-menu.dropdown-menu-selectable.dropdown-menu-right.clone-options-dropdown{ data: { dropdown: true } } - if ssh_enabled? diff --git a/changelogs/unreleased/28258-fix-project-clone-dropdrown-button-width.yml b/changelogs/unreleased/28258-fix-project-clone-dropdrown-button-width.yml new file mode 100644 index 00000000000..d72a64de6e3 --- /dev/null +++ b/changelogs/unreleased/28258-fix-project-clone-dropdrown-button-width.yml @@ -0,0 +1,5 @@ +--- +title: Fix project clone dropdown button width +merge_request: 19551 +author: George Tsiolis +type: fixed diff --git a/changelogs/unreleased/id-fix-any-approver-rule-for-projects.yml b/changelogs/unreleased/id-fix-any-approver-rule-for-projects.yml new file mode 100644 index 00000000000..e435d4357e4 --- /dev/null +++ b/changelogs/unreleased/id-fix-any-approver-rule-for-projects.yml @@ -0,0 +1,5 @@ +--- +title: Fix any approver project rule records +merge_request: 18265 +author: +type: changed diff --git a/db/post_migrate/20191008143850_fix_any_approver_rule_for_projects.rb b/db/post_migrate/20191008143850_fix_any_approver_rule_for_projects.rb new file mode 100644 index 00000000000..c1f4b7e42ab --- /dev/null +++ b/db/post_migrate/20191008143850_fix_any_approver_rule_for_projects.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class FixAnyApproverRuleForProjects < ActiveRecord::Migration[5.2] + DOWNTIME = false + BATCH_SIZE = 1000 + + disable_ddl_transaction! + + class ApprovalProjectRule < ActiveRecord::Base + NON_EXISTENT_RULE_TYPE = 4 + ANY_APPROVER_RULE_TYPE = 3 + + include EachBatch + + self.table_name = 'approval_project_rules' + + scope :any_approver, -> { where(rule_type: ANY_APPROVER_RULE_TYPE) } + scope :non_existent_rule_type, -> { where(rule_type: NON_EXISTENT_RULE_TYPE) } + end + + def up + return unless Gitlab.ee? + + # Remove approval project rule with rule type 4 if the project has a rule with rule_type 3 + # + # Currently, there is no projects on gitlab.com which have both rules with 3 and 4 rule type + # There's a code-level validation for a rule, which doesn't allow to create rules with the same names + # + # But in order to avoid failing the update query due to uniqueness constraint + # Let's run the delete query to be sure + project_ids = FixAnyApproverRuleForProjects::ApprovalProjectRule.any_approver.select(:project_id) + FixAnyApproverRuleForProjects::ApprovalProjectRule + .non_existent_rule_type + .where(project_id: project_ids) + .delete_all + + # Set approval project rule types to 3 + # Currently there are 18_445 records to be updated + FixAnyApproverRuleForProjects::ApprovalProjectRule.non_existent_rule_type.each_batch(of: BATCH_SIZE) do |rules| + rules.update_all(rule_type: FixAnyApproverRuleForProjects::ApprovalProjectRule::ANY_APPROVER_RULE_TYPE) + end + end + + def down + # The migration doesn't leave the database in an inconsistent state + # And can be run multiple times + end +end diff --git a/doc/development/api_graphql_styleguide.md b/doc/development/api_graphql_styleguide.md index 9b3b339cc70..7161caf19ed 100644 --- a/doc/development/api_graphql_styleguide.md +++ b/doc/development/api_graphql_styleguide.md @@ -240,6 +240,47 @@ end ``` +## Descriptions + +All fields and arguments +[must have descriptions](https://gitlab.com/gitlab-org/gitlab/merge_requests/16438). + +A description of a field or argument is given using the `description:` +keyword. For example: + +```ruby +field :id, GraphQL::ID_TYPE, description: 'ID of the resource' +``` + +Descriptions of fields and arguments are viewable to users through: + +- The [GraphiQL explorer](../api/graphql/#graphiql). +- The [static GraphQL API reference](../api/graphql/#reference). + +### Description styleguide + +To ensure consistency, the following should be followed whenever adding or updating +descriptions: + +- Mention the name of the resource in the description. Example: + `'Labels of the issue'` (issue being the resource). +- Use `"{x} of the {y}"` where possible. Example: `'Title of the issue'`. + Do not start descriptions with `The`. +- Descriptions of `GraphQL::BOOLEAN_TYPE` fields should answer the question: "What does + this field do?". Example: `'Indicates project has a Git repository'`. +- Always include the word `"timestamp"` when describing an argument or + field of type `Types::TimeType`. This lets the reader know that the + format of the property will be `Time`, rather than just `Date`. +- No `.` at end of strings. + +Example: + +```ruby +field :id, GraphQL::ID_TYPE, description: 'ID of the Issue' +field :confidential, GraphQL::BOOLEAN_TYPE, description: 'Indicates the issue is confidential' +field :closed_at, Types::TimeType, description: 'Timestamp of when the issue was closed' +``` + ## Authorization Authorizations can be applied to both types and fields using the same diff --git a/doc/install/installation.md b/doc/install/installation.md index 2a26a61544a..98094ca1185 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -13,7 +13,7 @@ If you want to install on RHEL/CentOS, we recommend using the [Omnibus packages](https://about.gitlab.com/install/). This guide is long because it covers many cases and includes all commands you -need, this is [one of the few installation scripts that actually works out of the box](https://twitter.com/robinvdvleuten/status/424163226532986880). +need, this is [one of the few installation scripts that actually work out of the box](https://twitter.com/robinvdvleuten/status/424163226532986880). The following steps have been known to work. **Use caution when you deviate** from this guide. Make sure you don't violate any assumptions GitLab makes about its environment. For example, many people run into permission problems because @@ -35,7 +35,7 @@ After this termination runit will detect Sidekiq is not running and will start i Since installations from source don't use runit for process supervision, Sidekiq can't be terminated and its memory usage will grow over time. -## Select version to install +## Select a version to install Make sure you view [this installation guide](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/install/installation.md) from the branch (version) of GitLab you would like to install (e.g., `11-7-stable`). You can select the branch in the version dropdown in the top left corner of GitLab (below the menu bar). @@ -56,7 +56,7 @@ of this page: | |-- repositories ``` -- `/home/git/.ssh` - Contains OpenSSH settings. Specifically the `authorized_keys` +- `/home/git/.ssh` - Contains OpenSSH settings. Specifically, the `authorized_keys` file managed by GitLab Shell. - `/home/git/gitlab` - GitLab core software. - `/home/git/gitlab-shell` - Core add-on component of GitLab. Maintains SSH @@ -315,7 +315,7 @@ use of extensions and concurrent index removal, you need at least PostgreSQL 9.2 sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" ``` -1. Create the GitLab production database and grant all privileges on database: +1. Create the GitLab production database and grant all privileges on the database: ```sh sudo -u postgres psql -d template1 -c "CREATE DATABASE gitlabhq_production OWNER git;" @@ -397,7 +397,7 @@ sudo usermod -aG redis git ## 8. GitLab ```sh -# We'll install GitLab into home directory of the user "git" +# We'll install GitLab into the home directory of the user "git" cd /home/git ``` @@ -424,7 +424,7 @@ cd /home/git/gitlab # Copy the example GitLab config sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml -# Update GitLab config file, follow the directions at top of file +# Update GitLab config file, follow the directions at top of the file sudo -u git -H editor config/gitlab.yml # Copy the example secrets file @@ -465,7 +465,7 @@ nproc # Enable cluster mode if you expect to have a high load instance # Set the number of workers to at least the number of cores -# Ex. change amount of workers to 3 for 2GB RAM server +# Ex. change the amount of workers to 3 for 2GB RAM server sudo -u git -H editor config/unicorn.rb # Copy the example Rack attack config @@ -670,7 +670,7 @@ sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production # or you can skip the question by adding force=yes sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production force=yes -# When done you see 'Administrator account created:' +# When done, you see 'Administrator account created:' ``` NOTE: **Note:** @@ -684,7 +684,7 @@ sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PA The `secrets.yml` file stores encryption keys for sessions and secure variables. Backup `secrets.yml` someplace safe, but don't store it in the same place as your database backups. -Otherwise your secrets are exposed if one of your backups is compromised. +Otherwise, your secrets are exposed if one of your backups is compromised. ### Install Init Script @@ -835,7 +835,7 @@ initial administrator account. Enter your desired password and you'll be redirected back to the login screen. The default account's username is **root**. Provide the password you created -earlier and login. After login you can change the username if you wish. +earlier and login. After login, you can change the username if you wish. **Enjoy!** @@ -905,7 +905,7 @@ for the changes to take effect. ### Custom Redis Connection -If you'd like to connect to a Redis server on a non-standard port or on a different host, you can configure its connection string via the `config/resque.yml` file. +If you'd like to connect to a Redis server on a non-standard port or a different host, you can configure its connection string via the `config/resque.yml` file. ``` # example @@ -921,7 +921,7 @@ production: url: unix:/path/to/redis/socket ``` -Also you can use environment variables in the `config/resque.yml` file: +Also, you can use environment variables in the `config/resque.yml` file: ``` # example diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 93bde33b8f9..1ba1be9aeb1 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -15848,6 +15848,9 @@ msgstr "" msgid "Something went wrong while closing the %{issuable}. Please try again later" msgstr "" +msgid "Something went wrong while deleting the package." +msgstr "" + msgid "Something went wrong while deleting the source branch. Please try again." msgstr "" @@ -15878,6 +15881,12 @@ msgstr "" msgid "Something went wrong while fetching the environments for this merge request. Please try again." msgstr "" +msgid "Something went wrong while fetching the package." +msgstr "" + +msgid "Something went wrong while fetching the packages list." +msgstr "" + msgid "Something went wrong while fetching the projects." msgstr "" @@ -20993,6 +21002,9 @@ msgstr "" msgid "started" msgstr "" +msgid "started a discussion on %{design_link}" +msgstr "" + msgid "started on %{milestone_start_date}" msgstr "" diff --git a/qa/Gemfile b/qa/Gemfile index f04ecb13879..90a2c6e5b8b 100644 --- a/qa/Gemfile +++ b/qa/Gemfile @@ -2,7 +2,6 @@ source 'https://rubygems.org' gem 'gitlab-qa' gem 'activesupport', '5.2.3' # This should stay in sync with the root's Gemfile -gem 'pry-byebug', '~> 3.5.1', platform: :mri gem 'capybara', '~> 2.16.1' gem 'capybara-screenshot', '~> 1.0.18' gem 'rake', '~> 12.3.0' @@ -15,3 +14,9 @@ gem 'rspec_junit_formatter', '~> 0.4.1' gem 'faker', '~> 1.6', '>= 1.6.6' gem 'knapsack', '~> 1.17' gem 'parallel_tests', '~> 2.29' + +group :test do + gem 'pry-byebug', '~> 3.5.1', platform: :mri + gem "ruby-debug-ide", "~> 0.7.0" + gem "debase", "~> 0.2.4.1" +end diff --git a/qa/Gemfile.lock b/qa/Gemfile.lock index d582d77c5cd..6728c0cceee 100644 --- a/qa/Gemfile.lock +++ b/qa/Gemfile.lock @@ -29,6 +29,9 @@ GEM ffi (~> 1.0, >= 1.0.11) coderay (1.1.2) concurrent-ruby (1.1.5) + debase (0.2.4.1) + debase-ruby_core_source (>= 0.10.2) + debase-ruby_core_source (0.10.6) diff-lcs (1.3) domain_name (0.5.20170404) unf (>= 0.0.5, < 1.0.0) @@ -67,7 +70,7 @@ GEM rack (2.0.6) rack-test (0.8.2) rack (>= 1.0, < 3) - rake (12.3.0) + rake (12.3.3) rest-client (2.0.2) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) @@ -89,6 +92,8 @@ GEM rspec-support (3.7.0) rspec_junit_formatter (0.4.1) rspec-core (>= 2, < 4, != 2.12.0) + ruby-debug-ide (0.7.0) + rake (>= 0.8.1) rubyzip (1.2.2) selenium-webdriver (3.141.0) childprocess (~> 0.5) @@ -110,6 +115,7 @@ DEPENDENCIES airborne (~> 0.2.13) capybara (~> 2.16.1) capybara-screenshot (~> 1.0.18) + debase (~> 0.2.4.1) faker (~> 1.6, >= 1.6.6) gitlab-qa knapsack (~> 1.17) @@ -120,6 +126,7 @@ DEPENDENCIES rspec (~> 3.7) rspec-retry (~> 0.6.1) rspec_junit_formatter (~> 0.4.1) + ruby-debug-ide (~> 0.7.0) selenium-webdriver (~> 3.12) BUNDLED WITH diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/check_mentions_for_xss_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/check_mentions_for_xss_spec.rb index 6068b9fb04a..35cd64aa58e 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/issue/check_mentions_for_xss_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/issue/check_mentions_for_xss_spec.rb @@ -42,7 +42,7 @@ module QA Page::Project::Issue::Show.perform do |show| show.select_all_activities_filter - show.comment('cc-ing you here @eve') + show.comment("cc-ing you here @#{user.username}") expect do expect(show).to have_content("cc-ing you here") diff --git a/spec/javascripts/lib/utils/tick_formats_spec.js b/spec/javascripts/lib/utils/tick_formats_spec.js deleted file mode 100644 index 283989b4fc8..00000000000 --- a/spec/javascripts/lib/utils/tick_formats_spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import { dateTickFormat, initDateFormats } from '~/lib/utils/tick_formats'; - -import { setLanguage } from '../../helpers/locale_helper'; - -describe('tick formats', () => { - describe('dateTickFormat', () => { - beforeAll(() => { - setLanguage('de'); - initDateFormats(); - }); - - afterAll(() => { - setLanguage(null); - }); - - it('returns year for first of January', () => { - const tick = dateTickFormat(new Date('2001-01-01')); - - expect(tick).toBe('2001'); - }); - - it('returns month for first of February', () => { - const tick = dateTickFormat(new Date('2001-02-01')); - - expect(tick).toBe('Februar'); - }); - - it('returns day and month for second of February', () => { - const tick = dateTickFormat(new Date('2001-02-02')); - - expect(tick).toBe('2. Feb.'); - }); - - it('ignores time', () => { - const tick = dateTickFormat(new Date('2001-02-02 12:34:56')); - - expect(tick).toBe('2. Feb.'); - }); - }); -}); diff --git a/spec/workers/new_note_worker_spec.rb b/spec/workers/new_note_worker_spec.rb index 2966a201a62..ae62237960a 100644 --- a/spec/workers/new_note_worker_spec.rb +++ b/spec/workers/new_note_worker_spec.rb @@ -7,16 +7,17 @@ describe NewNoteWorker do let(:note) { create(:note) } it "calls NotificationService#new_note" do - expect_any_instance_of(NotificationService).to receive(:new_note).with(note) + expect_next_instance_of(NotificationService) do |service| + expect(service).to receive(:new_note).with(note) + end described_class.new.perform(note.id) end it "calls Notes::PostProcessService#execute" do - notes_post_process_service = double(Notes::PostProcessService) - allow(Notes::PostProcessService).to receive(:new).with(note) { notes_post_process_service } - - expect(notes_post_process_service).to receive(:execute) + expect_next_instance_of(Notes::PostProcessService) do |service| + expect(service).to receive(:execute) + end described_class.new.perform(note.id) end @@ -36,14 +37,14 @@ describe NewNoteWorker do expect { described_class.new.perform(unexistent_note_id) }.not_to raise_error end - it "does not call NotificationService#new_note" do - expect_any_instance_of(NotificationService).not_to receive(:new_note) + it "does not call NotificationService" do + expect(NotificationService).not_to receive(:new) described_class.new.perform(unexistent_note_id) end - it "does not call Notes::PostProcessService#execute" do - expect_any_instance_of(Notes::PostProcessService).not_to receive(:execute) + it "does not call Notes::PostProcessService" do + expect(Notes::PostProcessService).not_to receive(:new) described_class.new.perform(unexistent_note_id) end