diff --git a/app/services/metrics/dashboard/grafana_metric_embed_service.rb b/app/services/metrics/dashboard/grafana_metric_embed_service.rb index f302a786ba8fa402879fc30bb00ffb7c371fbcf5..60591e9a6f351f3113fbcdbc1c2153d359355c05 100644 --- a/app/services/metrics/dashboard/grafana_metric_embed_service.rb +++ b/app/services/metrics/dashboard/grafana_metric_embed_service.rb @@ -44,6 +44,9 @@ module Metrics # Inherits the primary logic from the parent class and # maintains the service's API while including ReactiveCache def calculate_reactive_cache(*) + # This is called with explicit parentheses to prevent + # the params passed to #calculate_reactive_cache from + # being passed to #get_dashboard (which accepts none) ::Metrics::Dashboard::BaseService .instance_method(:get_dashboard) .bind(self) diff --git a/db/migrate/20191014025629_rename_design_management_version_user_to_author.rb b/db/migrate/20191014025629_rename_design_management_version_user_to_author.rb new file mode 100644 index 0000000000000000000000000000000000000000..2359cc2e826872aeba8d9ffd382260ff0ad10af8 --- /dev/null +++ b/db/migrate/20191014025629_rename_design_management_version_user_to_author.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RenameDesignManagementVersionUserToAuthor < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + rename_column_concurrently :design_management_versions, :user_id, :author_id + end + + def down + undo_rename_column_concurrently :design_management_versions, :user_id, :author_id + end +end diff --git a/db/migrate/20191014030730_add_author_index_to_design_management_versions.rb b/db/migrate/20191014030730_add_author_index_to_design_management_versions.rb new file mode 100644 index 0000000000000000000000000000000000000000..30e076f1fe6f9738ed72bc46093e81802dcbbb71 --- /dev/null +++ b/db/migrate/20191014030730_add_author_index_to_design_management_versions.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddAuthorIndexToDesignManagementVersions < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :design_management_versions, :author_id, where: 'author_id IS NOT NULL' + end + + def down + remove_concurrent_index :design_management_versions, :author_id + end +end diff --git a/db/post_migrate/20191014030134_cleanup_design_management_version_user_to_author_rename.rb b/db/post_migrate/20191014030134_cleanup_design_management_version_user_to_author_rename.rb new file mode 100644 index 0000000000000000000000000000000000000000..e7132cbeeb714cab937f9ed4e0ed5eb7ae03a8cb --- /dev/null +++ b/db/post_migrate/20191014030134_cleanup_design_management_version_user_to_author_rename.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class CleanupDesignManagementVersionUserToAuthorRename < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + cleanup_concurrent_column_rename :design_management_versions, :user_id, :author_id + end + + def down + undo_cleanup_concurrent_column_rename :design_management_versions, :user_id, :author_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 109f9e8e038110c9de446e16a60896c767c60ddb..290c669e467f5d6ea4e3adf41d6540a718fed7ec 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1301,11 +1301,11 @@ ActiveRecord::Schema.define(version: 2019_10_16_220135) do create_table "design_management_versions", force: :cascade do |t| t.binary "sha", null: false t.bigint "issue_id" - t.integer "user_id" t.datetime_with_timezone "created_at" + t.integer "author_id" + t.index ["author_id"], name: "index_design_management_versions_on_author_id", where: "(author_id IS NOT NULL)" t.index ["issue_id"], name: "index_design_management_versions_on_issue_id" t.index ["sha", "issue_id"], name: "index_design_management_versions_on_sha_and_issue_id", unique: true - t.index ["user_id"], name: "index_design_management_versions_on_user_id", where: "(user_id IS NOT NULL)" end create_table "draft_notes", force: :cascade do |t| @@ -4135,7 +4135,7 @@ ActiveRecord::Schema.define(version: 2019_10_16_220135) do add_foreign_key "design_management_designs_versions", "design_management_designs", column: "design_id", name: "fk_03c671965c", on_delete: :cascade add_foreign_key "design_management_designs_versions", "design_management_versions", column: "version_id", name: "fk_f4d25ba00c", on_delete: :cascade add_foreign_key "design_management_versions", "issues", on_delete: :cascade - add_foreign_key "design_management_versions", "users", name: "fk_ee16b939e5", on_delete: :nullify + add_foreign_key "design_management_versions", "users", column: "author_id", name: "fk_c1440b4896", on_delete: :nullify add_foreign_key "draft_notes", "merge_requests", on_delete: :cascade add_foreign_key "draft_notes", "users", column: "author_id", on_delete: :cascade add_foreign_key "elasticsearch_indexed_namespaces", "namespaces", on_delete: :cascade diff --git a/lib/gitlab/data_builder/push.rb b/lib/gitlab/data_builder/push.rb index a83b03f540c9e4f314b090ea2cfeed38bb2c2b71..65cfd47e1e858cc766bedb4fbda23844c9ddc44c 100644 --- a/lib/gitlab/data_builder/push.rb +++ b/lib/gitlab/data_builder/push.rb @@ -19,12 +19,25 @@ module Gitlab user_email: "john@example.com", user_avatar: "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80", project_id: 15, + project: { + id: 15, + name: "gitlab", + description: "", + web_url: "http://test.example.com/gitlab/gitlab", + avatar_url: "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80", + git_ssh_url: "git@test.example.com:gitlab/gitlab.git", + git_http_url: "http://test.example.com/gitlab/gitlab.git", + namespace: "gitlab", + visibility_level: 0, + path_with_namespace: "gitlab/gitlab", + default_branch: "master" + }, commits: [ { id: "c5feabde2d8cd023215af4d2ceeb7a64839fc428", message: "Add simple search to projects in public area", timestamp: "2013-05-13T18:18:08+00:00", - url: "https://test.example.com/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428", + url: "https://test.example.com/gitlab/gitlab/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428", author: { name: "Test User", email: "test@example.com" @@ -45,7 +58,20 @@ module Gitlab # user_name: String, # user_username: String, # user_email: String - # project_id: String, + # project_id: Fixnum, + # project: { + # id: Fixnum, + # name: String, + # description: String, + # web_url: String, + # avatar_url: String, + # git_ssh_url: String, + # git_http_url: String, + # namespace: String, + # visibility_level: Fixnum, + # path_with_namespace: String, + # default_branch: String + # } # repository: { # name: String, # url: String, diff --git a/scripts/lint-doc.sh b/scripts/lint-doc.sh index d097c2aee91ba8e15d9cb1d89aea3518861940fd..7f5d6130fe4d42129bb3ee00a4bb9f375763dede 100755 --- a/scripts/lint-doc.sh +++ b/scripts/lint-doc.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash cd "$(dirname "$0")/.." +echo "=> Linting documents at path $(pwd) as $(whoami)..." # Use long options (e.g. --header instead of -H) for curl examples in documentation. echo '=> Checking for cURL short options...' @@ -25,7 +26,7 @@ fi # Make sure no files in doc/ are executable EXEC_PERM_COUNT=$(find doc/ -type f -perm 755 | wc -l) -echo '=> Checking for executable permissions...' +echo "=> Checking $(pwd)/doc for executable permissions..." if [ "${EXEC_PERM_COUNT}" -ne 0 ] then echo '✖ ERROR: Executable permissions should not be used in documentation! Use `chmod 644` to the files in question:' >&2 diff --git a/spec/lib/gitlab/data_builder/push_spec.rb b/spec/lib/gitlab/data_builder/push_spec.rb index 58509b6946380cbfda41a085a2c65c02e5aa5820..cbc03fc38ebcc2751e6cc6a6e1729ac2330a252e 100644 --- a/spec/lib/gitlab/data_builder/push_spec.rb +++ b/spec/lib/gitlab/data_builder/push_spec.rb @@ -57,6 +57,32 @@ describe Gitlab::DataBuilder::Push do include_examples 'deprecated repository hook data' end + describe '.sample_data' do + let(:data) { described_class.sample_data } + + it { expect(data).to be_a(Hash) } + it { expect(data[:before]).to eq('95790bf891e76fee5e1747ab589903a6a1f80f22') } + it { expect(data[:after]).to eq('da1560886d4f094c3e6c9ef40349f7d38b5d27d7') } + it { expect(data[:ref]).to eq('refs/heads/master') } + it { expect(data[:project_id]).to eq(15) } + it { expect(data[:commits].size).to eq(1) } + it { expect(data[:total_commits_count]).to eq(1) } + it 'contains project data' do + expect(data[:project]).to be_a(Hash) + expect(data[:project][:id]).to eq(15) + expect(data[:project][:name]).to eq('gitlab') + expect(data[:project][:description]).to eq('') + expect(data[:project][:web_url]).to eq('http://test.example.com/gitlab/gitlab') + expect(data[:project][:avatar_url]).to eq('https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80') + expect(data[:project][:git_http_url]).to eq('http://test.example.com/gitlab/gitlab.git') + expect(data[:project][:git_ssh_url]).to eq('git@test.example.com:gitlab/gitlab.git') + expect(data[:project][:namespace]).to eq('gitlab') + expect(data[:project][:visibility_level]).to eq(0) + expect(data[:project][:path_with_namespace]).to eq('gitlab/gitlab') + expect(data[:project][:default_branch]).to eq('master') + end + end + describe '.build' do let(:data) do described_class.build( diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index 8ae571a69efbad956d09d31627cac2fac0925f24..5b2a0043492a9a807a979748a0954ecaecbc1077 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -752,4 +752,4 @@ DesignManagement::Version: - created_at - sha - issue_id -- user_id +- author_id