diff options
1153 files changed, 18309 insertions, 9613 deletions
diff --git a/.gitignore b/.gitignore index 89da29fd790..e529e33530a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ eslint-report.html /.yarn-cache /.byebug_history /Vagrantfile +/app/assets/javascripts/locale/**/app.js /backups/* /config/aws.yml /config/database.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f0c266485b6..790d9a1f72a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -193,6 +193,7 @@ setup-test-env: script: - node --version - yarn install --pure-lockfile --cache-folder .yarn-cache + - bundle exec rake gettext:po_to_json - bundle exec rake gitlab:assets:compile - bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init' artifacts: @@ -433,6 +434,7 @@ gitlab:assets:compile: NO_COMPRESSION: "true" script: - yarn install --pure-lockfile --production --cache-folder .yarn-cache + - bundle exec rake gettext:po_to_json - bundle exec rake gitlab:assets:compile artifacts: name: webpack-report @@ -450,6 +452,7 @@ karma: BABEL_ENV: "coverage" CHROME_LOG_FILE: "chrome_debug.log" script: + - bundle exec rake gettext:po_to_json - bundle exec rake karma coverage: '/^Statements *: (\d+\.\d+%)/' artifacts: @@ -461,6 +464,7 @@ karma: - coverage-javascript/ codeclimate: + <<: *except-docs before_script: [] image: docker:latest stage: test @@ -472,6 +476,7 @@ codeclimate: script: - docker pull codeclimate/codeclimate - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f json > codeclimate.json + - sed -i.bak 's/\({"body":"\)[^"]*\("}\)/\1\2/g' codeclimate.json artifacts: paths: [codeclimate.json] @@ -546,3 +551,9 @@ cache gems: only: - master@gitlab-org/gitlab-ce - master@gitlab-org/gitlab-ee + +gitlab_git_test: + variables: + SETUP_DB: "false" + script: + - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes diff --git a/.gitlab/issue_templates/Bug.md b/.gitlab/issue_templates/Bug.md index 9d53a48409a..aec734870d6 100644 --- a/.gitlab/issue_templates/Bug.md +++ b/.gitlab/issue_templates/Bug.md @@ -1,11 +1,18 @@ Please read this! Before opening a new issue, make sure to search for keywords in the issues -filtered by the "regression" or "bug" label: +filtered by the "regression" or "bug" label. + +For the Community Edition issue tracker: - https://gitlab.com/gitlab-org/gitlab-ce/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab-ce/issues?label_name%5B%5D=bug +For the Enterprise Edition issue tracker: + +- https://gitlab.com/gitlab-org/gitlab-ee/issues?label_name%5B%5D=regression +- https://gitlab.com/gitlab-org/gitlab-ee/issues?label_name%5B%5D=bug + and verify the issue you're about to submit isn't a duplicate. Please remove this notice if you're confident your issue isn't a duplicate. diff --git a/.gitlab/issue_templates/Feature Proposal.md b/.gitlab/issue_templates/Feature Proposal.md index d96c9ad59e0..1278061a410 100644 --- a/.gitlab/issue_templates/Feature Proposal.md +++ b/.gitlab/issue_templates/Feature Proposal.md @@ -3,8 +3,14 @@ Please read this! Before opening a new issue, make sure to search for keywords in the issues filtered by the "feature proposal" label: +For the Community Edition issue tracker: + - https://gitlab.com/gitlab-org/gitlab-ce/issues?label_name%5B%5D=feature+proposal +For the Enterprise Edition issue tracker: + +- https://gitlab.com/gitlab-org/gitlab-ee/issues?label_name%5B%5D=feature+proposal + and verify the issue you're about to submit isn't a duplicate. Please remove this notice if you're confident your issue isn't a duplicate. @@ -21,12 +27,24 @@ Please remove this notice if you're confident your issue isn't a duplicate. ### Documentation blurb -(Write the start of the documentation of this feature here, include: +#### Overview + +What is it? +Why should someone use this feature? +What is the underlying (business) problem? +How do you use this feature? + +#### Use cases + +Who is this for? Provide one or more use cases. + +### Feature checklist -1. Why should someone use it; what's the underlying problem. -2. What is the solution. -3. How does someone use this +Make sure these are completed before closing the issue, +with a link to the relevant commit. -During implementation, this can then be copied and used as a starter for the documentation.) +- [ ] [Feature assurance](https://about.gitlab.com/handbook/product/#feature-assurance) +- [ ] Documentation +- [ ] Added to [features.yml](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/features.yml) -/label ~"feature proposal" +/label ~"feature proposal"
\ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index 4537e710dd4..32ec60f540b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -164,6 +164,11 @@ Style/DefWithParentheses: Style/Documentation: Enabled: false +# Multi-line method chaining should be done with leading dots. +Style/DotPosition: + Enabled: true + EnforcedStyle: leading + # This cop checks for uses of double negation (!!) to convert something # to a boolean value. As this is both cryptic and usually redundant, it # should be avoided. diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e2d9c37479d..5ab4692dd60 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -88,13 +88,6 @@ Security/YAMLLoad: Style/BarePercentLiterals: Enabled: false -# Offense count: 1403 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: leading, trailing -Style/DotPosition: - Enabled: false - # Offense count: 5 # Cop supports --auto-correct. Style/EachWithObject: diff --git a/CHANGELOG.md b/CHANGELOG.md index f43858a00a5..f372cbf91e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,238 @@ documentation](doc/development/changelog.md) for instructions on adding your own entry. +## 9.3.2 (2017-06-27) + +- API: Fix optional arugments for POST :id/variables. !12474 +- Bump premailer-rails gem to 1.9.7 and its dependencies to prevent network retrieval of assets. + +## 9.3.1 (2017-06-26) + +- Fix reversed breadcrumb order for nested groups. !12322 +- Fix 500 when failing to create private group. !12394 +- Fix linking to line number on side-by-side diff creating empty discussion box. +- Don't match tilde and exclamation mark as part of requirements.txt package name. +- Perform project housekeeping after importing projects. +- Fixed ctrl+enter not submit issue edit form. + +## 9.3.0 (2017-06-22) + +- Refactored gitlab:app:check into SystemCheck liberary and improve some checks. !9173 +- Add an ability to cancel attaching file and redesign attaching files UI. !9431 (blackst0ne) +- Add Aliyun OSS as the backup storage provider. !9721 (Yuanfei Zhu) +- Add suport for find_local_branches GRPC from Gitaly. !10059 +- Allow manual bypass of auto_sign_in_with_provider with a new param. !10187 (Maxime Besson) +- Redirect to user's keys index instead of user's index after a key is deleted in the admin. !10227 (Cyril Jouve) +- Changed Blame to Annotate in the UI to promote blameless culture. !10378 (Ilya Vassilevsky) +- Implement ability to update deploy keys. !10383 (Alexander Randa) +- Allow numeric values in gitlab-ci.yml. !10607 (blackst0ne) +- Add a feature test for Unicode trace. !10736 (dosuken123) +- Notes: Warning message should go away once resolved. !10823 (Jacopo Beschi @jacopo-beschi) +- Project authorizations are calculated much faster when using PostgreSQL, and nested groups support for MySQL has been removed +. !10885 +- Fix long urls in the title of commit. !10938 (Alexander Randa) +- Update gem sidekiq-cron from 0.4.4 to 0.6.0 and rufus-scheduler from 3.1.10 to 3.4.0. !10976 (dosuken123) +- Use relative paths for group/project/user avatars. !11001 (blackst0ne) +- Enable cancelling non-HEAD pending pipelines by default for all projects. !11023 +- Implement web hook logging. !11027 (Alexander Randa) +- Add indices for auto_canceled_by_id for ci_pipelines and ci_builds on PostgreSQL. !11034 +- Add post-deploy migration to clean up projects in `pending_delete` state. !11044 +- Limit User's trackable attributes, like `current_sign_in_at`, to update at most once/hour. !11053 +- Disallow multiple selections for Milestone dropdown. !11084 +- Link to commit author user page from pipelines. !11100 +- Fix the last coverage in trace log should be extracted. !11128 (dosuken123) +- Remove redirect for old issue url containing id instead of iid. !11135 (blackst0ne) +- Backported new SystemHook event: `repository_update`. !11140 +- Keep input data after creating a tag that already exists. !11155 +- Fix support for external CI services. !11176 +- Translate backend for Project & Repository pages. !11183 +- Fix LaTeX formatting for AsciiDoc wiki. !11212 +- Add foreign key for pipeline schedule owner. !11233 +- Print Go version in rake gitlab:env:info. !11241 +- Include the blob content when printing a blob page. !11247 +- Sync email address from specified omniauth provider. !11268 (Robin Bobbitt) +- Disable reference prefixes in notes for Snippets. !11278 +- Rename build_events to job_events. !11287 +- Add API support for pipeline schedule. !11307 (dosuken123) +- Use route.cache_key for project list cache key. !11325 +- Make environment table realtime. !11333 +- Cache npm modules between pipelines with yarn to speed up setup-test-env. !11343 +- Allow GitLab instance to start when InfluxDB hostname cannot be resolved. !11356 +- Add ConvDev Index page to admin area. !11377 +- Fix Git-over-HTTP error statuses and improve error messages. !11398 +- Renamed users 'Audit Log'' to 'Authentication Log'. !11400 +- Style people in issuable search bar. !11402 +- Change /builds in the URL to /-/jobs. Backward URLs were also added. !11407 +- Update password field label while editing service settings. !11431 +- Add an optional performance bar to view performance metrics for the current page. !11439 +- Update task_list to version 2.0.0. !11525 (Jared Deckard <jared.deckard@gmail.com>) +- Avoid resource intensive login checks if password is not provided. !11537 (Horatiu Eugen Vlad) +- Allow numeric pages domain. !11550 +- Exclude manual actions when checking if pipeline can be canceled. !11562 +- Add server uptime to System Info page in admin dashboard. !11590 (Justin Boltz) +- Simplify testing and saving service integrations. !11599 +- Fixed handling of the `can_push` attribute in the v3 deploy_keys api. !11607 (Richard Clamp) +- Improve user experience around slash commands in instant comments. !11612 +- Show current user immediately in issuable filters. !11630 +- Add extra context-sensitive functionality for the top right menu button. !11632 +- Reorder Issue action buttons in order of usability. !11642 +- Expose atom links with an RSS token instead of using the private token. !11647 (Alexis Reigel) +- Respect merge, instead of push, permissions for protected actions. !11648 +- Job details page update real time. !11651 +- Improve performance of ProjectFinder used in /projects API endpoint. !11666 +- Remove redundant data-turbolink attributes from links. !11672 (blackst0ne) +- Minimum postgresql version is now 9.2. !11677 +- Add protected variables which would only be passed to protected branches or protected tags. !11688 +- Introduce optimistic locking support via optional parameter last_commit_sha on File Update API. !11694 (electroma) +- Add $CI_ENVIRONMENT_URL to predefined variables for pipelines. !11695 +- Simplify project repository settings page. !11698 +- Fix pipeline_schedules pages throwing error 500. !11706 (dosuken123) +- Add performance deltas between app deployments on Merge Request widget. !11730 +- Add feature toggles and API endpoints for admins. !11747 +- Replace 'starred_projects.feature' spinach test with an rspec analog. !11752 (blackst0ne) +- Introduce an Events API. !11755 +- Display Shared Runner status in Admin Dashboard. !11783 (Ivan Chernov) +- Persist pipeline stages in the database. !11790 +- Revert the feature that would include the current user's username in the HTTP clone URL. !11792 +- Enable Gitaly by default in installations from source. !11796 +- Use zopfli compression for frontend assets. !11798 +- Add tag_list param to project api. !11799 (Ivan Chernov) +- Add changelog for improved Registry description. !11816 +- Automatically adjust project settings to match changes in project visibility. !11831 +- Add slugify project path to CI enviroment variables. !11838 (Ivan Chernov) +- Add all pipeline sources as special keywords to 'only' and 'except'. !11844 (Filip Krakowski) +- Allow pulling of container images using personal access tokens. !11845 +- Expose import_status in Projects API. !11851 (Robin Bobbitt) +- Allow admins to delete users from the admin users page. !11852 +- Allow users to be hard-deleted from the API. !11853 +- Fix hard-deleting users when they have authored issues. !11855 +- Fix missing optional path parameter in "Create project for user" API. !11868 +- Allow users to be hard-deleted from the admin panel. !11874 +- Add a Rake task to aid in rotating otp_key_base. !11881 +- Fix submodule link to then project under subgroup. !11906 +- Fix binary encoding error on MR diffs. !11929 +- Limit non-administrators to adding 100 members at a time to groups and projects. !11940 +- add bulgarian translation of cycle analytics page to I18N. !11958 (Lyubomir Vasilev) +- Make backup task to continue on corrupt repositories. !11962 +- Fix incorrect ETag cache key when relative instance URL is used. !11964 +- Reinstate is_admin flag in users api when authenticated user is an admin. !12211 (rickettm) +- Fix edit button for deploy keys available from other projects. !12301 (Alexander Randa) +- Fix passing CI_ENVIRONMENT_NAME and CI_ENVIRONMENT_SLUG for CI_ENVIRONMENT_URL. !12344 +- Disable environment list refresh due to bug https://gitlab.com/gitlab-org/gitlab-ee/issues/2677. !12347 +- Standardize timeline note margins across different viewport sizes. !12364 +- Fix Ordered Task List Items. !31483 (Jared Deckard <jared.deckard@gmail.com>) +- Upgrade dependency to Go 1.8.3. !31943 +- Add prometheus metrics on pipeline creation. +- Fix etag route not being a match for environments. +- Sort folder for environments. +- Support descriptions for snippets. +- Hide clone panel and file list when user is only a guest. (James Clark) +- Don’t create comment on JIRA if it already exists for the entity. +- Update Dashboard Groups UI with better support for subgroups. +- Confirm Project forking behaviour via the API. +- Add prometheus based metrics collection to gitlab webapp. +- Fix: Wiki is not searchable with Guest permissions. +- Center all empty states. +- Remove 'New issue' button when issues search returns no results. +- Add API URL to JIRA settings. +- animate adding issue to boards. +- Update session cookie key name to be unique to instance in development. +- Single click on filter to open filtered search dropdown. +- Makes header information of pipeline show page realtine. +- Creates a mediator for pipeline details vue in order to mount several vue apps with the same data. +- Scope issue/merge request recent searches to project. +- Increase individual diff collapse limit to 100 KB, and render limit to 200 KB. +- Fix Pipelines table empty state - only render empty state if we receive 0 pipelines. +- Make New environment empty state btn lowercase. +- Removes duplicate environment variable in documentation. +- Change links in issuable meta to black. +- Fix border-bottom for project activity tab. +- Adds new icon for CI skipped status. +- Create equal padding for emoji. +- Use briefcase icon for company in profile page. +- Remove overflow from comment form for confidential issues and vertically aligns confidential issue icon. +- Keep trailing newline when resolving conflicts by picking sides. +- Fix /unsubscribe slash command creating extra todos when you were already mentioned in an issue. +- Fix math rendering on blob pages. +- Allow group reporters to manage group labels. +- Use pre-wrap for commit messages to keep lists indented. +- Count badges depend on translucent color to better adjust to different background colors and permission badges now feature a pill shaped design similar to labels. +- Allow reporters to promote project labels to group labels. +- Enabled keyboard shortcuts on artifacts pages. +- Perform filtered search when state tab is changed. +- Remove duplication for sharing projects with groups in project settings. +- Change order of commits ahead and behind on divergence graph for branch list view. +- Creates CI Header component for Pipelines and Jobs details pages. +- Invalidate cache for issue and MR counters more granularly. +- disable blocked manual actions. +- Load tree readme asynchronously. +- Display extra info about files on .gitlab-ci.yml, .gitlab/route-map.yml and LICENSE blob pages. +- Fix replying to a commit discussion displayed in the context of an MR. +- Consistently use monospace font for commit SHAs and branch and tag names. +- Consistently display last push event widget. +- Don't copy empty elements that were not selected on purpose as GFM. +- Copy as GFM even when parts of other elements are selected. +- Autolink package names in Gemfile. +- Resolve N+1 query issue with discussions. +- Don't match email addresses or foo@bar as user references. +- Fix title of discussion jump button at top of page. +- Don't return nil for missing objects from parser cache. +- Make .gitmodules parsing more resilient to syntax errors. +- Add username parameter to gravatar URL. +- Autolink package names in more dependency files. +- Return nil when looking up config for unknown LDAP provider. +- Add system note with link to diff comparison when MR discussion becomes outdated. +- Don't wrap pasted code when it's already inside code tags. +- Revert 'New file from interface on existing branch'. +- Show last commit for current tree on tree page. +- Add documentation about adding foreign keys. +- add username field to push webhook. (David Turner) +- Rename CI/CD Pipelines to Pipelines in the project settings. +- Make environment tables responsive. +- Expand/collapse backlog & closed lists in issue boards. +- Fix GitHub importer performance on branch existence check. +- Fix counter cache for acts as taggable. +- Github - Fix token interpolation when cloning wiki repository. +- Fix token interpolation when setting the Github remote. +- Fix N+1 queries for non-members in comment threads. +- Fix terminals support for Kubernetes Service. +- Fix: A diff comment on a change at last line of a file shows as two comments in discussion. +- Instrument MergeRequestDiff#load_commits. +- Introduce source to Pipeline entity. +- Fixed create new label form in issue form not working for sub-group projects. +- Fixed style on unsubscribe page. (Gustav Ernberg) +- Enables inline editing for an issues title & description. +- Ask for an example project for bug reports. +- Add summary lines for collapsed details in the bug report template. +- Prevent commits from upstream repositories to be re-processed by forks. +- Avoid repeated queries for pipeline builds on merge requests. +- Preloads head pipeline for merge request collection. +- Handle head pipeline when creating merge requests. +- Migrate artifacts to a new path. +- Rescue OpenSSL::SSL::SSLError in JiraService & IssueTrackerService. +- Repository browser: handle in-repository submodule urls. (David Turner) +- Prevent project transfers if a new group is not selected. +- Allow 'no one' as an option for allowed to merge on a procted branch. +- Reduce time spent waiting for certain Sidekiq jobs to complete. +- Refactor ProjectsFinder#init_collection to produce more efficient queries for retrieving projects. +- Remove unused code and uses underscore. +- Restricts search projects dropdown to group projects when group is selected. +- Properly handle container registry redirects to fix metadata stored on a S3 backend. +- Fix LFS timeouts when trying to save large files. +- Set artifact working directory to be in the destination store to prevent unnecessary I/O. +- Strip trailing whitespaces in submodule URLs. +- Make sure reCAPTCHA configuration is loaded when spam checks are initiated. +- Fix up arrow not editing last discussion comment. +- Added application readiness endpoints to the monitoring health check admin view. +- Use wait_for_requests for both ajax and Vue requests. +- Cleanup ci_variables schema and table. +- Remove foreigh key on ci_trigger_schedules only if it exists. +- Allow translation of Pipeline Schedules. + +## 9.2.7 (2017-06-21) + +- Reinstate is_admin flag in users api when authenticated user is an admin. !12211 (rickettm) + ## 9.2.6 (2017-06-16) - Fix the last coverage in trace log should be extracted. !11128 (dosuken123) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8b6c87ae518..89e505709a3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,6 +49,8 @@ _This notice should stay as the first item in the CONTRIBUTING.MD file._ Thank you for your interest in contributing to GitLab. This guide details how to contribute to GitLab in a way that is efficient for everyone. +Looking for something to work on? Look for the label [Accepting Merge Requests](#i-want-to-contribute). + GitLab comes into two flavors, GitLab Community Edition (CE) our free and open source edition, and GitLab Enterprise Edition (EE) which is our commercial edition. Throughout this guide you will see references to CE and EE for diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index bc859cbd6d9..54d1a4f2a4a 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -0.11.2 +0.13.0 diff --git a/GITLAB_SHELL_VERSION b/GITLAB_SHELL_VERSION index ab0fa336dd0..c20c645d7e4 100644 --- a/GITLAB_SHELL_VERSION +++ b/GITLAB_SHELL_VERSION @@ -1 +1 @@ -5.0.5 +5.0.6 diff --git a/GITLAB_WORKHORSE_VERSION b/GITLAB_WORKHORSE_VERSION index 3e3c2f1e5ed..ccbccc3dc62 100644 --- a/GITLAB_WORKHORSE_VERSION +++ b/GITLAB_WORKHORSE_VERSION @@ -1 +1 @@ -2.1.1 +2.2.0 @@ -2,7 +2,7 @@ source 'https://rubygems.org' gem 'rails', '4.2.8' gem 'rails-deprecated_sanitizer', '~> 1.0.3' -gem 'bootsnap', '~> 1.0.0' +gem 'bootsnap', '~> 1.1' # Responders respond_to and respond_with gem 'responders', '~> 2.0' @@ -123,6 +123,7 @@ gem 'asciidoctor', '~> 1.5.2' gem 'asciidoctor-plantuml', '0.0.7' gem 'rouge', '~> 2.0' gem 'truncato', '~> 0.7.8' +gem 'bootstrap_form', '~> 2.7.0' # See https://groups.google.com/forum/#!topic/ruby-security-ann/aSbgDiwb24s # and https://groups.google.com/forum/#!topic/ruby-security-ann/Dy7YiKb_pMM @@ -256,10 +257,11 @@ gem 'base32', '~> 0.3.0' # Sentry integration gem 'sentry-raven', '~> 2.4.0' -gem 'premailer-rails', '~> 1.9.0' +gem 'premailer-rails', '~> 1.9.7' # I18n gem 'ruby_parser', '~> 3.8', require: false +gem 'rails-i18n', '~> 4.0.9' gem 'gettext_i18n_rails', '~> 1.8.0' gem 'gettext_i18n_rails_js', '~> 1.2.0' gem 'gettext', '~> 3.2.2', require: false, group: :development @@ -353,7 +355,7 @@ group :test do gem 'shoulda-matchers', '~> 2.8.0', require: false gem 'email_spec', '~> 1.6.0' gem 'json-schema', '~> 2.6.2' - gem 'webmock', '~> 1.24.0' + gem 'webmock', '~> 2.3.2' gem 'test_after_commit', '~> 1.1' gem 'sham_rack', '~> 1.3.6' gem 'timecop', '~> 0.8.0' @@ -383,7 +385,7 @@ gem 'vmstat', '~> 2.3.0' gem 'sys-filesystem', '~> 1.1.6' # Gitaly GRPC client -gem 'gitaly', '~> 0.8.0' +gem 'gitaly', '~> 0.9.0' gem 'toml-rb', '~> 0.3.15', require: false diff --git a/Gemfile.lock b/Gemfile.lock index e38f8b92c8c..f4ddd30da1b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,11 +83,12 @@ GEM bindata (2.3.5) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bootsnap (1.0.0) + bootsnap (1.1.1) msgpack (~> 1.0) bootstrap-sass (3.3.6) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) + bootstrap_form (2.7.0) brakeman (3.6.1) browser (2.2.0) builder (3.2.3) @@ -138,7 +139,7 @@ GEM crack (0.4.3) safe_yaml (~> 1.0.0) creole (0.5.0) - css_parser (1.4.1) + css_parser (1.5.0) addressable d3_rails (3.5.11) railties (>= 3.1.0) @@ -277,7 +278,7 @@ GEM po_to_json (>= 1.0.0) rails (>= 3.2.0) gherkin-ruby (0.3.2) - gitaly (0.8.0) + gitaly (0.9.0) google-protobuf (~> 3.1) grpc (~> 1.0) github-linguist (4.7.6) @@ -353,7 +354,7 @@ GEM grape-entity (0.6.0) activesupport multi_json (>= 1.3.2) - grpc (1.2.5) + grpc (1.4.0) google-protobuf (~> 3.1) googleauth (~> 0.5.1) haml (4.0.7) @@ -367,7 +368,7 @@ GEM temple (~> 0.7.6) thor tilt - hashdiff (0.3.2) + hashdiff (0.3.4) hashie (3.5.5) hashie-forbidden_attributes (0.1.1) hashie (>= 3.0) @@ -462,7 +463,7 @@ GEM mimemagic (0.3.0) mini_portile2 (2.1.0) minitest (5.7.0) - mmap2 (2.2.6) + mmap2 (2.2.7) mousetrap-rails (1.4.6) msgpack (1.1.0) multi_json (1.12.1) @@ -591,10 +592,11 @@ GEM websocket-driver (>= 0.2.0) posix-spawn (0.3.11) powerpack (0.1.1) - premailer (1.8.6) - css_parser (>= 1.3.6) + premailer (1.10.4) + addressable + css_parser (>= 1.4.10) htmlentities (>= 4.0.0) - premailer-rails (1.9.2) + premailer-rails (1.9.7) actionmailer (>= 3, < 6) premailer (~> 1.7, >= 1.7.9) prometheus-client-mmap (0.7.0.beta5) @@ -646,6 +648,9 @@ GEM rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) + rails-i18n (4.0.9) + i18n (~> 0.7) + railties (~> 4.0) railties (4.2.8) actionpack (= 4.2.8) activesupport (= 4.2.8) @@ -886,7 +891,7 @@ GEM vmstat (2.3.0) warden (1.2.6) rack (>= 1.0) - webmock (1.24.6) + webmock (2.3.2) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff @@ -925,8 +930,9 @@ DEPENDENCIES benchmark-ips (~> 2.3.0) better_errors (~> 2.1.0) binding_of_caller (~> 0.7.2) - bootsnap (~> 1.0.0) + bootsnap (~> 1.1) bootstrap-sass (~> 3.3.0) + bootstrap_form (~> 2.7.0) brakeman (~> 3.6.0) browser (~> 2.2) bullet (~> 5.5.0) @@ -974,7 +980,7 @@ DEPENDENCIES gettext (~> 3.2.2) gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails_js (~> 1.2.0) - gitaly (~> 0.8.0) + gitaly (~> 0.9.0) github-linguist (~> 4.7.0) gitlab-flowdock-git-hook (~> 1.0.1) gitlab-markup (~> 1.5.1) @@ -1044,7 +1050,7 @@ DEPENDENCIES peek-sidekiq (~> 1.0.3) pg (~> 0.18.2) poltergeist (~> 1.9.0) - premailer-rails (~> 1.9.0) + premailer-rails (~> 1.9.7) prometheus-client-mmap (~> 0.7.0.beta5) pry-byebug (~> 3.4.1) pry-rails (~> 0.3.4) @@ -1054,6 +1060,7 @@ DEPENDENCIES rack-proxy (~> 0.6.0) rails (= 4.2.8) rails-deprecated_sanitizer (~> 1.0.3) + rails-i18n (~> 4.0.9) rainbow (~> 2.2) rblineprof (~> 0.3.6) rdoc (~> 4.2) @@ -1115,7 +1122,7 @@ DEPENDENCIES version_sorter (~> 2.1.0) virtus (~> 1.0.1) vmstat (~> 2.3.0) - webmock (~> 1.24.0) + webmock (~> 2.3.2) webpack-rails (~> 0.9.10) wikicloth (= 0.8.1) diff --git a/app/assets/images/new_nav.png b/app/assets/images/new_nav.png Binary files differnew file mode 100644 index 00000000000..8879d26d341 --- /dev/null +++ b/app/assets/images/new_nav.png diff --git a/app/assets/images/old_nav.png b/app/assets/images/old_nav.png Binary files differnew file mode 100644 index 00000000000..23fae7aa19e --- /dev/null +++ b/app/assets/images/old_nav.png diff --git a/app/assets/javascripts/awards_handler.js b/app/assets/javascripts/awards_handler.js index adb45b0606d..c34d80f0601 100644 --- a/app/assets/javascripts/awards_handler.js +++ b/app/assets/javascripts/awards_handler.js @@ -1,11 +1,8 @@ +/* eslint-disable class-methods-use-this */ /* global Flash */ import Cookies from 'js-cookie'; - -import emojiMap from 'emojis/digests.json'; -import emojiAliases from 'emojis/aliases.json'; -import { glEmojiTag } from './behaviors/gl_emoji'; -import isEmojiNameValid from './behaviors/gl_emoji/is_emoji_name_valid'; +import * as Emoji from './emoji'; const animationEndEventString = 'animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd'; const transitionEndEventString = 'transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'; @@ -16,8 +13,6 @@ const requestAnimationFrame = window.requestAnimationFrame || const FROM_SENTENCE_REGEX = /(?:, and | and |, )/; // For separating lists produced by ruby's Array#toSentence -let categoryMap = null; - const categoryLabelMap = { activity: 'Activity', people: 'People', @@ -29,26 +24,6 @@ const categoryLabelMap = { flags: 'Flags', }; -function buildCategoryMap() { - return Object.keys(emojiMap).reduce((currentCategoryMap, emojiNameKey) => { - const emojiInfo = emojiMap[emojiNameKey]; - if (currentCategoryMap[emojiInfo.category]) { - currentCategoryMap[emojiInfo.category].push(emojiNameKey); - } - - return currentCategoryMap; - }, { - activity: [], - people: [], - nature: [], - food: [], - travel: [], - objects: [], - symbols: [], - flags: [], - }); -} - function renderCategory(name, emojiList, opts = {}) { return ` <h5 class="emoji-menu-title"> @@ -58,7 +33,7 @@ function renderCategory(name, emojiList, opts = {}) { ${emojiList.map(emojiName => ` <li class="emoji-menu-list-item"> <button class="emoji-menu-btn text-center js-emoji-btn" type="button"> - ${glEmojiTag(emojiName, { + ${Emoji.glEmojiTag(emojiName, { sprite: true, })} </button> @@ -68,147 +43,143 @@ function renderCategory(name, emojiList, opts = {}) { `; } -function AwardsHandler() { - this.eventListeners = []; - this.aliases = emojiAliases; - // If the user shows intent let's pre-build the menu - this.registerEventListener('one', $(document), 'mouseenter focus', '.js-add-award', 'mouseenter focus', () => { - const $menu = $('.emoji-menu'); - if ($menu.length === 0) { - requestAnimationFrame(() => { - this.createEmojiMenu(); - }); - } - // Prebuild the categoryMap - categoryMap = categoryMap || buildCategoryMap(); - }); - this.registerEventListener('on', $(document), 'click', '.js-add-award', (e) => { - e.stopPropagation(); - e.preventDefault(); - this.showEmojiMenu($(e.currentTarget)); - }); - - this.registerEventListener('on', $('html'), 'click', (e) => { - const $target = $(e.target); - if (!$target.closest('.emoji-menu-content').length) { - $('.js-awards-block.current').removeClass('current'); - } - if (!$target.closest('.emoji-menu').length) { - if ($('.emoji-menu').is(':visible')) { - $('.js-add-award.is-active').removeClass('is-active'); - $('.emoji-menu').removeClass('is-visible'); +export default class AwardsHandler { + constructor() { + this.eventListeners = []; + // If the user shows intent let's pre-build the menu + this.registerEventListener('one', $(document), 'mouseenter focus', '.js-add-award', 'mouseenter focus', () => { + const $menu = $('.emoji-menu'); + if ($menu.length === 0) { + requestAnimationFrame(() => { + this.createEmojiMenu(); + }); } - } - }); - this.registerEventListener('on', $(document), 'click', '.js-emoji-btn', (e) => { - e.preventDefault(); - const $target = $(e.currentTarget); - const $glEmojiElement = $target.find('gl-emoji'); - const $spriteIconElement = $target.find('.icon'); - const emoji = ($glEmojiElement.length ? $glEmojiElement : $spriteIconElement).data('name'); - - $target.closest('.js-awards-block').addClass('current'); - this.addAward(this.getVotesBlock(), this.getAwardUrl(), emoji); - }); -} + }); + this.registerEventListener('on', $(document), 'click', '.js-add-award', (e) => { + e.stopPropagation(); + e.preventDefault(); + this.showEmojiMenu($(e.currentTarget)); + }); -AwardsHandler.prototype.registerEventListener = function registerEventListener(method = 'on', element, ...args) { - element[method].call(element, ...args); - this.eventListeners.push({ - element, - args, - }); -}; + this.registerEventListener('on', $('html'), 'click', (e) => { + const $target = $(e.target); + if (!$target.closest('.emoji-menu-content').length) { + $('.js-awards-block.current').removeClass('current'); + } + if (!$target.closest('.emoji-menu').length) { + if ($('.emoji-menu').is(':visible')) { + $('.js-add-award.is-active').removeClass('is-active'); + $('.emoji-menu').removeClass('is-visible'); + } + } + }); + this.registerEventListener('on', $(document), 'click', '.js-emoji-btn', (e) => { + e.preventDefault(); + const $target = $(e.currentTarget); + const $glEmojiElement = $target.find('gl-emoji'); + const $spriteIconElement = $target.find('.icon'); + const emoji = ($glEmojiElement.length ? $glEmojiElement : $spriteIconElement).data('name'); + + $target.closest('.js-awards-block').addClass('current'); + this.addAward(this.getVotesBlock(), this.getAwardUrl(), emoji); + }); + } -AwardsHandler.prototype.showEmojiMenu = function showEmojiMenu($addBtn) { - if ($addBtn.hasClass('js-note-emoji')) { - $addBtn.closest('.note').find('.js-awards-block').addClass('current'); - } else { - $addBtn.closest('.js-awards-block').addClass('current'); - } - - const $menu = $('.emoji-menu'); - const $thumbsBtn = $menu.find('[data-name="thumbsup"], [data-name="thumbsdown"]').parent(); - const $userAuthored = this.isUserAuthored($addBtn); - if ($menu.length) { - if ($menu.is('.is-visible')) { - $addBtn.removeClass('is-active'); - $menu.removeClass('is-visible'); - $('.js-emoji-menu-search').blur(); - } else { - $addBtn.addClass('is-active'); - this.positionMenu($menu, $addBtn); - $menu.addClass('is-visible'); - $('.js-emoji-menu-search').focus(); - } - } else { - $addBtn.addClass('is-loading is-active'); - this.createEmojiMenu(() => { - const $createdMenu = $('.emoji-menu'); - $addBtn.removeClass('is-loading'); - this.positionMenu($createdMenu, $addBtn); - return setTimeout(() => { - $createdMenu.addClass('is-visible'); - $('.js-emoji-menu-search').focus(); - }, 200); + registerEventListener(method = 'on', element, ...args) { + element[method].call(element, ...args); + this.eventListeners.push({ + element, + args, }); } - $thumbsBtn.toggleClass('disabled', $userAuthored); -}; + showEmojiMenu($addBtn) { + if ($addBtn.hasClass('js-note-emoji')) { + $addBtn.closest('.note').find('.js-awards-block').addClass('current'); + } else { + $addBtn.closest('.js-awards-block').addClass('current'); + } -// Create the emoji menu with the first category of emojis. -// Then render the remaining categories of emojis one by one to avoid jank. -AwardsHandler.prototype.createEmojiMenu = function createEmojiMenu(callback) { - if (this.isCreatingEmojiMenu) { - return; - } - this.isCreatingEmojiMenu = true; - - // Render the first category - categoryMap = categoryMap || buildCategoryMap(); - const categoryNameKey = Object.keys(categoryMap)[0]; - const emojisInCategory = categoryMap[categoryNameKey]; - const firstCategory = renderCategory(categoryLabelMap[categoryNameKey], emojisInCategory); - - // Render the frequently used - const frequentlyUsedEmojis = this.getFrequentlyUsedEmojis(); - let frequentlyUsedCatgegory = ''; - if (frequentlyUsedEmojis.length > 0) { - frequentlyUsedCatgegory = renderCategory('Frequently used', frequentlyUsedEmojis, { - menuListClass: 'frequent-emojis', - }); + const $menu = $('.emoji-menu'); + const $thumbsBtn = $menu.find('[data-name="thumbsup"], [data-name="thumbsdown"]').parent(); + const $userAuthored = this.isUserAuthored($addBtn); + if ($menu.length) { + if ($menu.is('.is-visible')) { + $addBtn.removeClass('is-active'); + $menu.removeClass('is-visible'); + $('.js-emoji-menu-search').blur(); + } else { + $addBtn.addClass('is-active'); + this.positionMenu($menu, $addBtn); + $menu.addClass('is-visible'); + $('.js-emoji-menu-search').focus(); + } + } else { + $addBtn.addClass('is-loading is-active'); + this.createEmojiMenu(() => { + const $createdMenu = $('.emoji-menu'); + $addBtn.removeClass('is-loading'); + this.positionMenu($createdMenu, $addBtn); + return setTimeout(() => { + $createdMenu.addClass('is-visible'); + $('.js-emoji-menu-search').focus(); + }, 200); + }); + } + + $thumbsBtn.toggleClass('disabled', $userAuthored); } - const emojiMenuMarkup = ` - <div class="emoji-menu"> - <input type="text" name="emoji-menu-search" value="" class="js-emoji-menu-search emoji-search search-input form-control" placeholder="Search emoji" /> + // Create the emoji menu with the first category of emojis. + // Then render the remaining categories of emojis one by one to avoid jank. + createEmojiMenu(callback) { + if (this.isCreatingEmojiMenu) { + return; + } + this.isCreatingEmojiMenu = true; + + // Render the first category + const categoryMap = Emoji.getEmojiCategoryMap(); + const categoryNameKey = Object.keys(categoryMap)[0]; + const emojisInCategory = categoryMap[categoryNameKey]; + const firstCategory = renderCategory(categoryLabelMap[categoryNameKey], emojisInCategory); + + // Render the frequently used + const frequentlyUsedEmojis = this.getFrequentlyUsedEmojis(); + let frequentlyUsedCatgegory = ''; + if (frequentlyUsedEmojis.length > 0) { + frequentlyUsedCatgegory = renderCategory('Frequently used', frequentlyUsedEmojis, { + menuListClass: 'frequent-emojis', + }); + } + + const emojiMenuMarkup = ` + <div class="emoji-menu"> + <input type="text" name="emoji-menu-search" value="" class="js-emoji-menu-search emoji-search search-input form-control" placeholder="Search emoji" /> - <div class="emoji-menu-content"> - ${frequentlyUsedCatgegory} - ${firstCategory} + <div class="emoji-menu-content"> + ${frequentlyUsedCatgegory} + ${firstCategory} + </div> </div> - </div> - `; + `; - document.body.insertAdjacentHTML('beforeend', emojiMenuMarkup); + document.body.insertAdjacentHTML('beforeend', emojiMenuMarkup); - this.addRemainingEmojiMenuCategories(); - this.setupSearch(); - if (callback) { - callback(); + this.addRemainingEmojiMenuCategories(); + this.setupSearch(); + if (callback) { + callback(); + } } -}; -AwardsHandler - .prototype - .addRemainingEmojiMenuCategories = function addRemainingEmojiMenuCategories() { + addRemainingEmojiMenuCategories() { if (this.isAddingRemainingEmojiMenuCategories) { return; } this.isAddingRemainingEmojiMenuCategories = true; - categoryMap = categoryMap || buildCategoryMap(); + const categoryMap = Emoji.getEmojiCategoryMap(); // Avoid the jank and render the remaining categories separately // This will take more time, but makes UI more responsive @@ -243,179 +214,167 @@ AwardsHandler emojiContentElement.insertAdjacentHTML('beforeend', '<p>We encountered an error while adding the remaining categories</p>'); throw new Error(`Error occurred in addRemainingEmojiMenuCategories: ${err.message}`); }); - }; - -AwardsHandler.prototype.positionMenu = function positionMenu($menu, $addBtn) { - const position = $addBtn.data('position'); - // The menu could potentially be off-screen or in a hidden overflow element - // So we position the element absolute in the body - const css = { - top: `${$addBtn.offset().top + $addBtn.outerHeight()}px`, - }; - if (position === 'right') { - css.left = `${($addBtn.offset().left - $menu.outerWidth()) + 20}px`; - $menu.addClass('is-aligned-right'); - } else { - css.left = `${$addBtn.offset().left}px`; - $menu.removeClass('is-aligned-right'); - } - return $menu.css(css); -}; - -AwardsHandler.prototype.addAward = function addAward( - votesBlock, - awardUrl, - emoji, - checkMutuality, - callback, -) { - const normalizedEmoji = this.normalizeEmojiName(emoji); - const $emojiButton = this.findEmojiIcon(votesBlock, normalizedEmoji).parent(); - this.postEmoji($emojiButton, awardUrl, normalizedEmoji, () => { - this.addAwardToEmojiBar(votesBlock, normalizedEmoji, checkMutuality); - return typeof callback === 'function' ? callback() : undefined; - }); - $('.emoji-menu').removeClass('is-visible'); - $('.js-add-award.is-active').removeClass('is-active'); -}; + } -AwardsHandler.prototype.addAwardToEmojiBar = function addAwardToEmojiBar( - votesBlock, - emoji, - checkForMutuality, -) { - if (checkForMutuality || checkForMutuality === null) { - this.checkMutuality(votesBlock, emoji); - } - this.addEmojiToFrequentlyUsedList(emoji); - const normalizedEmoji = this.normalizeEmojiName(emoji); - const $emojiButton = this.findEmojiIcon(votesBlock, normalizedEmoji).parent(); - if ($emojiButton.length > 0) { - if (this.isActive($emojiButton)) { - this.decrementCounter($emojiButton, normalizedEmoji); + positionMenu($menu, $addBtn) { + const position = $addBtn.data('position'); + // The menu could potentially be off-screen or in a hidden overflow element + // So we position the element absolute in the body + const css = { + top: `${$addBtn.offset().top + $addBtn.outerHeight()}px`, + }; + if (position === 'right') { + css.left = `${($addBtn.offset().left - $menu.outerWidth()) + 20}px`; + $menu.addClass('is-aligned-right'); } else { - const counter = $emojiButton.find('.js-counter'); - counter.text(parseInt(counter.text(), 10) + 1); - $emojiButton.addClass('active'); - this.addYouToUserList(votesBlock, normalizedEmoji); - this.animateEmoji($emojiButton); + css.left = `${$addBtn.offset().left}px`; + $menu.removeClass('is-aligned-right'); } - } else { - votesBlock.removeClass('hidden'); - this.createEmoji(votesBlock, normalizedEmoji); + return $menu.css(css); } -}; -AwardsHandler.prototype.getVotesBlock = function getVotesBlock() { - const currentBlock = $('.js-awards-block.current'); - let resultantVotesBlock = currentBlock; - if (currentBlock.length === 0) { - resultantVotesBlock = $('.js-awards-block').eq(0); + addAward(votesBlock, awardUrl, emoji, checkMutuality, callback) { + const normalizedEmoji = Emoji.normalizeEmojiName(emoji); + const $emojiButton = this.findEmojiIcon(votesBlock, normalizedEmoji).parent(); + this.postEmoji($emojiButton, awardUrl, normalizedEmoji, () => { + this.addAwardToEmojiBar(votesBlock, normalizedEmoji, checkMutuality); + return typeof callback === 'function' ? callback() : undefined; + }); + $('.emoji-menu').removeClass('is-visible'); + $('.js-add-award.is-active').removeClass('is-active'); } - return resultantVotesBlock; -}; + addAwardToEmojiBar(votesBlock, emoji, checkForMutuality) { + if (checkForMutuality || checkForMutuality === null) { + this.checkMutuality(votesBlock, emoji); + } + this.addEmojiToFrequentlyUsedList(emoji); + const normalizedEmoji = Emoji.normalizeEmojiName(emoji); + const $emojiButton = this.findEmojiIcon(votesBlock, normalizedEmoji).parent(); + if ($emojiButton.length > 0) { + if (this.isActive($emojiButton)) { + this.decrementCounter($emojiButton, normalizedEmoji); + } else { + const counter = $emojiButton.find('.js-counter'); + counter.text(parseInt(counter.text(), 10) + 1); + $emojiButton.addClass('active'); + this.addYouToUserList(votesBlock, normalizedEmoji); + this.animateEmoji($emojiButton); + } + } else { + votesBlock.removeClass('hidden'); + this.createEmoji(votesBlock, normalizedEmoji); + } + } -AwardsHandler.prototype.getAwardUrl = function getAwardUrl() { - return this.getVotesBlock().data('award-url'); -}; + getVotesBlock() { + const currentBlock = $('.js-awards-block.current'); + let resultantVotesBlock = currentBlock; + if (currentBlock.length === 0) { + resultantVotesBlock = $('.js-awards-block').eq(0); + } + + return resultantVotesBlock; + } + + getAwardUrl() { + return this.getVotesBlock().data('award-url'); + } -AwardsHandler.prototype.checkMutuality = function checkMutuality(votesBlock, emoji) { - const awardUrl = this.getAwardUrl(); - if (emoji === 'thumbsup' || emoji === 'thumbsdown') { - const mutualVote = emoji === 'thumbsup' ? 'thumbsdown' : 'thumbsup'; - const $emojiButton = votesBlock.find(`[data-name="${mutualVote}"]`).parent(); - const isAlreadyVoted = $emojiButton.hasClass('active'); - if (isAlreadyVoted) { - this.addAward(votesBlock, awardUrl, mutualVote, false); + checkMutuality(votesBlock, emoji) { + const awardUrl = this.getAwardUrl(); + if (emoji === 'thumbsup' || emoji === 'thumbsdown') { + const mutualVote = emoji === 'thumbsup' ? 'thumbsdown' : 'thumbsup'; + const $emojiButton = votesBlock.find(`[data-name="${mutualVote}"]`).parent(); + const isAlreadyVoted = $emojiButton.hasClass('active'); + if (isAlreadyVoted) { + this.addAward(votesBlock, awardUrl, mutualVote, false); + } } } -}; -AwardsHandler.prototype.isActive = function isActive($emojiButton) { - return $emojiButton.hasClass('active'); -}; + isActive($emojiButton) { + return $emojiButton.hasClass('active'); + } -AwardsHandler.prototype.isUserAuthored = function isUserAuthored($button) { - return $button.hasClass('js-user-authored'); -}; + isUserAuthored($button) { + return $button.hasClass('js-user-authored'); + } -AwardsHandler.prototype.decrementCounter = function decrementCounter($emojiButton, emoji) { - const counter = $('.js-counter', $emojiButton); - const counterNumber = parseInt(counter.text(), 10); - if (counterNumber > 1) { - counter.text(counterNumber - 1); - this.removeYouFromUserList($emojiButton); - } else if (emoji === 'thumbsup' || emoji === 'thumbsdown') { - $emojiButton.tooltip('destroy'); - counter.text('0'); - this.removeYouFromUserList($emojiButton); - if ($emojiButton.parents('.note').length) { + decrementCounter($emojiButton, emoji) { + const counter = $('.js-counter', $emojiButton); + const counterNumber = parseInt(counter.text(), 10); + if (counterNumber > 1) { + counter.text(counterNumber - 1); + this.removeYouFromUserList($emojiButton); + } else if (emoji === 'thumbsup' || emoji === 'thumbsdown') { + $emojiButton.tooltip('destroy'); + counter.text('0'); + this.removeYouFromUserList($emojiButton); + if ($emojiButton.parents('.note').length) { + this.removeEmoji($emojiButton); + } + } else { this.removeEmoji($emojiButton); } - } else { - this.removeEmoji($emojiButton); + return $emojiButton.removeClass('active'); } - return $emojiButton.removeClass('active'); -}; -AwardsHandler.prototype.removeEmoji = function removeEmoji($emojiButton) { - $emojiButton.tooltip('destroy'); - $emojiButton.remove(); - const $votesBlock = this.getVotesBlock(); - if ($votesBlock.find('.js-emoji-btn').length === 0) { - $votesBlock.addClass('hidden'); + removeEmoji($emojiButton) { + $emojiButton.tooltip('destroy'); + $emojiButton.remove(); + const $votesBlock = this.getVotesBlock(); + if ($votesBlock.find('.js-emoji-btn').length === 0) { + $votesBlock.addClass('hidden'); + } } -}; - -AwardsHandler.prototype.getAwardTooltip = function getAwardTooltip($awardBlock) { - return $awardBlock.attr('data-original-title') || $awardBlock.attr('data-title') || ''; -}; -AwardsHandler.prototype.toSentence = function toSentence(list) { - let sentence; - if (list.length <= 2) { - sentence = list.join(' and '); - } else { - sentence = `${list.slice(0, -1).join(', ')}, and ${list[list.length - 1]}`; + getAwardTooltip($awardBlock) { + return $awardBlock.attr('data-original-title') || $awardBlock.attr('data-title') || ''; } - return sentence; -}; + toSentence(list) { + let sentence; + if (list.length <= 2) { + sentence = list.join(' and '); + } else { + sentence = `${list.slice(0, -1).join(', ')}, and ${list[list.length - 1]}`; + } -AwardsHandler.prototype.removeYouFromUserList = function removeYouFromUserList($emojiButton) { - const awardBlock = $emojiButton; - const originalTitle = this.getAwardTooltip(awardBlock); - const authors = originalTitle.split(FROM_SENTENCE_REGEX); - authors.splice(authors.indexOf('You'), 1); - return awardBlock - .closest('.js-emoji-btn') - .removeData('title') - .removeAttr('data-title') - .removeAttr('data-original-title') - .attr('title', this.toSentence(authors)) - .tooltip('fixTitle'); -}; + return sentence; + } -AwardsHandler.prototype.addYouToUserList = function addYouToUserList(votesBlock, emoji) { - const awardBlock = this.findEmojiIcon(votesBlock, emoji).parent(); - const origTitle = this.getAwardTooltip(awardBlock); - let users = []; - if (origTitle) { - users = origTitle.trim().split(FROM_SENTENCE_REGEX); - } - users.unshift('You'); - return awardBlock - .attr('title', this.toSentence(users)) - .tooltip('fixTitle'); -}; + removeYouFromUserList($emojiButton) { + const awardBlock = $emojiButton; + const originalTitle = this.getAwardTooltip(awardBlock); + const authors = originalTitle.split(FROM_SENTENCE_REGEX); + authors.splice(authors.indexOf('You'), 1); + return awardBlock + .closest('.js-emoji-btn') + .removeData('title') + .removeAttr('data-title') + .removeAttr('data-original-title') + .attr('title', this.toSentence(authors)) + .tooltip('fixTitle'); + } + + addYouToUserList(votesBlock, emoji) { + const awardBlock = this.findEmojiIcon(votesBlock, emoji).parent(); + const origTitle = this.getAwardTooltip(awardBlock); + let users = []; + if (origTitle) { + users = origTitle.trim().split(FROM_SENTENCE_REGEX); + } + users.unshift('You'); + return awardBlock + .attr('title', this.toSentence(users)) + .tooltip('fixTitle'); + } -AwardsHandler - .prototype - .createAwardButtonForVotesBlock = function createAwardButtonForVotesBlock(votesBlock, emojiName) { + createAwardButtonForVotesBlock(votesBlock, emojiName) { const buttonHtml = ` <button class="btn award-control js-emoji-btn has-tooltip active" title="You" data-placement="bottom"> - ${glEmojiTag(emojiName)} + ${Emoji.glEmojiTag(emojiName)} <span class="award-control-text js-counter">1</span> </button> `; @@ -424,144 +383,127 @@ AwardsHandler this.animateEmoji($emojiButton); $('.award-control').tooltip(); votesBlock.removeClass('current'); - }; - -AwardsHandler.prototype.animateEmoji = function animateEmoji($emoji) { - const className = 'pulse animated once short'; - $emoji.addClass(className); + } - this.registerEventListener('on', $emoji, animationEndEventString, (e) => { - $(e.currentTarget).removeClass(className); - }); -}; + animateEmoji($emoji) { + const className = 'pulse animated once short'; + $emoji.addClass(className); -AwardsHandler.prototype.createEmoji = function createEmoji(votesBlock, emoji) { - if ($('.emoji-menu').length) { - this.createAwardButtonForVotesBlock(votesBlock, emoji); + this.registerEventListener('on', $emoji, animationEndEventString, (e) => { + $(e.currentTarget).removeClass(className); + }); } - this.createEmojiMenu(() => { - this.createAwardButtonForVotesBlock(votesBlock, emoji); - }); -}; -AwardsHandler.prototype.postEmoji = function postEmoji($emojiButton, awardUrl, emoji, callback) { - if (this.isUserAuthored($emojiButton)) { - this.userAuthored($emojiButton); - } else { - $.post(awardUrl, { - name: emoji, - }, (data) => { - if (data.ok) { - callback(); - } - }).fail(() => new Flash('Something went wrong on our end.')); + createEmoji(votesBlock, emoji) { + if ($('.emoji-menu').length) { + this.createAwardButtonForVotesBlock(votesBlock, emoji); + } + this.createEmojiMenu(() => { + this.createAwardButtonForVotesBlock(votesBlock, emoji); + }); } -}; -AwardsHandler.prototype.findEmojiIcon = function findEmojiIcon(votesBlock, emoji) { - return votesBlock.find(`.js-emoji-btn [data-name="${emoji}"]`); -}; + postEmoji($emojiButton, awardUrl, emoji, callback) { + if (this.isUserAuthored($emojiButton)) { + this.userAuthored($emojiButton); + } else { + $.post(awardUrl, { + name: emoji, + }, (data) => { + if (data.ok) { + callback(); + } + }).fail(() => new Flash('Something went wrong on our end.')); + } + } -AwardsHandler.prototype.userAuthored = function userAuthored($emojiButton) { - const oldTitle = this.getAwardTooltip($emojiButton); - const newTitle = 'You cannot vote on your own issue, MR and note'; - gl.utils.updateTooltipTitle($emojiButton, newTitle).tooltip('show'); - // Restore tooltip back to award list - return setTimeout(() => { - $emojiButton.tooltip('hide'); - gl.utils.updateTooltipTitle($emojiButton, oldTitle); - }, 2800); -}; + findEmojiIcon(votesBlock, emoji) { + return votesBlock.find(`.js-emoji-btn [data-name="${emoji}"]`); + } -AwardsHandler.prototype.scrollToAwards = function scrollToAwards() { - const options = { - scrollTop: $('.awards').offset().top - 110, - }; - return $('body, html').animate(options, 200); -}; + userAuthored($emojiButton) { + const oldTitle = this.getAwardTooltip($emojiButton); + const newTitle = 'You cannot vote on your own issue, MR and note'; + gl.utils.updateTooltipTitle($emojiButton, newTitle).tooltip('show'); + // Restore tooltip back to award list + return setTimeout(() => { + $emojiButton.tooltip('hide'); + gl.utils.updateTooltipTitle($emojiButton, oldTitle); + }, 2800); + } -AwardsHandler.prototype.normalizeEmojiName = function normalizeEmojiName(emoji) { - return Object.prototype.hasOwnProperty.call(this.aliases, emoji) ? this.aliases[emoji] : emoji; -}; + scrollToAwards() { + const options = { + scrollTop: $('.awards').offset().top - 110, + }; + return $('body, html').animate(options, 200); + } -AwardsHandler - .prototype - .addEmojiToFrequentlyUsedList = function addEmojiToFrequentlyUsedList(emoji) { - if (isEmojiNameValid(emoji)) { + addEmojiToFrequentlyUsedList(emoji) { + if (Emoji.isEmojiNameValid(emoji)) { this.frequentlyUsedEmojis = _.uniq(this.getFrequentlyUsedEmojis().concat(emoji)); Cookies.set('frequently_used_emojis', this.frequentlyUsedEmojis.join(','), { expires: 365 }); } - }; - -AwardsHandler.prototype.getFrequentlyUsedEmojis = function getFrequentlyUsedEmojis() { - return this.frequentlyUsedEmojis || (() => { - const frequentlyUsedEmojis = _.uniq((Cookies.get('frequently_used_emojis') || '').split(',')); - this.frequentlyUsedEmojis = frequentlyUsedEmojis.filter( - inputName => isEmojiNameValid(inputName), - ); + } - return this.frequentlyUsedEmojis; - })(); -}; + getFrequentlyUsedEmojis() { + return this.frequentlyUsedEmojis || (() => { + const frequentlyUsedEmojis = _.uniq((Cookies.get('frequently_used_emojis') || '').split(',')); + this.frequentlyUsedEmojis = frequentlyUsedEmojis.filter( + inputName => Emoji.isEmojiNameValid(inputName), + ); -AwardsHandler.prototype.setupSearch = function setupSearch() { - const $search = $('.js-emoji-menu-search'); + return this.frequentlyUsedEmojis; + })(); + } - this.registerEventListener('on', $search, 'input', (e) => { - const term = $(e.target).val().trim(); - this.searchEmojis(term); - }); + setupSearch() { + const $search = $('.js-emoji-menu-search'); - const $menu = $('.emoji-menu'); - this.registerEventListener('on', $menu, transitionEndEventString, (e) => { - if (e.target === e.currentTarget) { - // Clear the search - this.searchEmojis(''); - } - }); -}; + this.registerEventListener('on', $search, 'input', (e) => { + const term = $(e.target).val().trim(); + this.searchEmojis(term); + }); -AwardsHandler.prototype.searchEmojis = function searchEmojis(term) { - const $search = $('.js-emoji-menu-search'); - $search.val(term); - - // Clean previous search results - $('ul.emoji-menu-search, h5.emoji-search-title').remove(); - if (term.length > 0) { - // Generate a search result block - const h5 = $('<h5 class="emoji-search-title"/>').text('Search results'); - const foundEmojis = this.findMatchingEmojiElements(term).show(); - const ul = $('<ul>').addClass('emoji-menu-list emoji-menu-search').append(foundEmojis); - $('.emoji-menu-content ul, .emoji-menu-content h5').hide(); - $('.emoji-menu-content').append(h5).append(ul); - } else { - $('.emoji-menu-content').children().show(); + const $menu = $('.emoji-menu'); + this.registerEventListener('on', $menu, transitionEndEventString, (e) => { + if (e.target === e.currentTarget) { + // Clear the search + this.searchEmojis(''); + } + }); } -}; -AwardsHandler.prototype.findMatchingEmojiElements = function findMatchingEmojiElements(term) { - const safeTerm = term.toLowerCase(); - - const namesMatchingAlias = []; - Object.keys(emojiAliases).forEach((alias) => { - if (alias.indexOf(safeTerm) >= 0) { - namesMatchingAlias.push(emojiAliases[alias]); + searchEmojis(term) { + const $search = $('.js-emoji-menu-search'); + $search.val(term); + + // Clean previous search results + $('ul.emoji-menu-search, h5.emoji-search-title').remove(); + if (term.length > 0) { + // Generate a search result block + const h5 = $('<h5 class="emoji-search-title"/>').text('Search results'); + const foundEmojis = this.findMatchingEmojiElements(term).show(); + const ul = $('<ul>').addClass('emoji-menu-list emoji-menu-search').append(foundEmojis); + $('.emoji-menu-content ul, .emoji-menu-content h5').hide(); + $('.emoji-menu-content').append(h5).append(ul); + } else { + $('.emoji-menu-content').children().show(); } - }); - const $matchingElements = namesMatchingAlias.concat(safeTerm) - .reduce( - ($result, searchTerm) => - $result.add($(`.emoji-menu-list:not(.frequent-emojis) [data-name*="${searchTerm}"]`)), - $([]), - ); - return $matchingElements.closest('li').clone(); -}; + } -AwardsHandler.prototype.destroy = function destroy() { - this.eventListeners.forEach((entry) => { - entry.element.off.call(entry.element, ...entry.args); - }); - $('.emoji-menu').remove(); -}; + findMatchingEmojiElements(query) { + const emojiMatches = Emoji.filterEmojiNamesByAlias(query); + const $emojiElements = $('.emoji-menu-list:not(.frequent-emojis) [data-name]'); + const $matchingElements = $emojiElements + .filter((i, elm) => emojiMatches.indexOf(elm.dataset.name) >= 0); + return $matchingElements.closest('li').clone(); + } -export default AwardsHandler; + destroy() { + this.eventListeners.forEach((entry) => { + entry.element.off.call(entry.element, ...entry.args); + }); + $('.emoji-menu').remove(); + } +} diff --git a/app/assets/javascripts/behaviors/gl_emoji.js b/app/assets/javascripts/behaviors/gl_emoji.js index 36ce4fddb72..8156e491a42 100644 --- a/app/assets/javascripts/behaviors/gl_emoji.js +++ b/app/assets/javascripts/behaviors/gl_emoji.js @@ -1,75 +1,10 @@ import installCustomElements from 'document-register-element'; -import emojiMap from 'emojis/digests.json'; -import emojiAliases from 'emojis/aliases.json'; -import { getUnicodeSupportMap } from './gl_emoji/unicode_support_map'; -import { isEmojiUnicodeSupported } from './gl_emoji/is_emoji_unicode_supported'; +import { emojiImageTag, emojiFallbackImageSrc } from '../emoji'; +import isEmojiUnicodeSupported from '../emoji/support'; installCustomElements(window); -const generatedUnicodeSupportMap = getUnicodeSupportMap(); - -function emojiImageTag(name, src) { - return `<img class="emoji" title=":${name}:" alt=":${name}:" src="${src}" width="20" height="20" align="absmiddle" />`; -} - -function assembleFallbackImageSrc(inputName) { - let name = Object.prototype.hasOwnProperty.call(emojiAliases, inputName) ? - emojiAliases[inputName] : inputName; - let emojiInfo = emojiMap[name]; - // Fallback to question mark for unknown emojis - if (!emojiInfo) { - name = 'grey_question'; - emojiInfo = emojiMap[name]; - } - const fallbackImageSrc = `${gon.asset_host || ''}${gon.relative_url_root || ''}/assets/emoji/${name}-${emojiInfo.digest}.png`; - - return fallbackImageSrc; -} -const glEmojiTagDefaults = { - sprite: false, - forceFallback: false, -}; -function glEmojiTag(inputName, options) { - const opts = Object.assign({}, glEmojiTagDefaults, options); - let name = Object.prototype.hasOwnProperty.call(emojiAliases, inputName) ? - emojiAliases[inputName] : inputName; - let emojiInfo = emojiMap[name]; - // Fallback to question mark for unknown emojis - if (!emojiInfo) { - name = 'grey_question'; - emojiInfo = emojiMap[name]; - } - - const fallbackImageSrc = assembleFallbackImageSrc(name); - const fallbackSpriteClass = `emoji-${name}`; - - const classList = []; - if (opts.forceFallback && opts.sprite) { - classList.push('emoji-icon'); - classList.push(fallbackSpriteClass); - } - const classAttribute = classList.length > 0 ? `class="${classList.join(' ')}"` : ''; - const fallbackSpriteAttribute = opts.sprite ? `data-fallback-sprite-class="${fallbackSpriteClass}"` : ''; - let contents = emojiInfo.moji; - if (opts.forceFallback && !opts.sprite) { - contents = emojiImageTag(name, fallbackImageSrc); - } - - return ` - <gl-emoji - ${classAttribute} - data-name="${name}" - data-fallback-src="${fallbackImageSrc}" - ${fallbackSpriteAttribute} - data-unicode-version="${emojiInfo.unicodeVersion}" - title="${emojiInfo.description}" - > - ${contents} - </gl-emoji> - `; -} - -function installGlEmojiElement() { +export default function installGlEmojiElement() { const GlEmojiElementProto = Object.create(HTMLElement.prototype); GlEmojiElementProto.createdCallback = function createdCallback() { const emojiUnicode = this.textContent.trim(); @@ -90,7 +25,7 @@ function installGlEmojiElement() { if ( emojiUnicode && isEmojiUnicode && - !isEmojiUnicodeSupported(generatedUnicodeSupportMap, emojiUnicode, unicodeVersion) + !isEmojiUnicodeSupported(emojiUnicode, unicodeVersion) ) { // CSS sprite fallback takes precedence over image fallback if (hasCssSpriteFalback) { @@ -100,7 +35,7 @@ function installGlEmojiElement() { } else if (hasImageFallback) { this.innerHTML = emojiImageTag(name, fallbackSrc); } else { - const src = assembleFallbackImageSrc(name); + const src = emojiFallbackImageSrc(name); this.innerHTML = emojiImageTag(name, src); } } @@ -110,9 +45,3 @@ function installGlEmojiElement() { prototype: GlEmojiElementProto, }); } - -export { - installGlEmojiElement, - glEmojiTag, - emojiImageTag, -}; diff --git a/app/assets/javascripts/behaviors/gl_emoji/is_emoji_name_valid.js b/app/assets/javascripts/behaviors/gl_emoji/is_emoji_name_valid.js deleted file mode 100644 index be4aeb32c46..00000000000 --- a/app/assets/javascripts/behaviors/gl_emoji/is_emoji_name_valid.js +++ /dev/null @@ -1,11 +0,0 @@ -import emojiMap from 'emojis/digests.json'; -import emojiAliases from 'emojis/aliases.json'; - -function isEmojiNameValid(inputName) { - const name = Object.prototype.hasOwnProperty.call(emojiAliases, inputName) ? - emojiAliases[inputName] : inputName; - - return name && emojiMap[name]; -} - -export default isEmojiNameValid; diff --git a/app/assets/javascripts/behaviors/index.js b/app/assets/javascripts/behaviors/index.js index 5b931e6cfa6..44b2c974b9e 100644 --- a/app/assets/javascripts/behaviors/index.js +++ b/app/assets/javascripts/behaviors/index.js @@ -1,7 +1,7 @@ import './autosize'; import './bind_in_out'; import './details_behavior'; -import { installGlEmojiElement } from './gl_emoji'; +import installGlEmojiElement from './gl_emoji'; import './quick_submit'; import './requires_input'; import './toggler_behavior'; diff --git a/app/assets/javascripts/behaviors/quick_submit.js b/app/assets/javascripts/behaviors/quick_submit.js index 1f9e0448084..bc693616460 100644 --- a/app/assets/javascripts/behaviors/quick_submit.js +++ b/app/assets/javascripts/behaviors/quick_submit.js @@ -40,7 +40,7 @@ $(document).on('keydown.quick_submit', '.js-quick-submit', (e) => { e.preventDefault(); const $form = $(e.target).closest('form'); - const $submitButton = $form.find('input[type=submit], button[type=submit]'); + const $submitButton = $form.find('input[type=submit], button[type=submit]').first(); if (!$submitButton.attr('disabled')) { $submitButton.trigger('click', [e]); diff --git a/app/assets/javascripts/boards/components/board_new_issue.js b/app/assets/javascripts/boards/components/board_new_issue.js index b1c47b09c35..4af8b0c7713 100644 --- a/app/assets/javascripts/boards/components/board_new_issue.js +++ b/app/assets/javascripts/boards/components/board_new_issue.js @@ -17,7 +17,7 @@ export default { methods: { submit(e) { e.preventDefault(); - if (this.title.trim() === '') return; + if (this.title.trim() === '') return Promise.resolve(); this.error = false; @@ -29,7 +29,10 @@ export default { assignees: [], }); - this.list.newIssue(issue) + eventHub.$emit(`scroll-board-list-${this.list.id}`); + this.cancel(); + + return this.list.newIssue(issue) .then(() => { // Need this because our jQuery very kindly disables buttons on ALL form submissions $(this.$refs.submitButton).enable(); @@ -47,9 +50,6 @@ export default { // Show error message this.error = true; }); - - eventHub.$emit(`scroll-board-list-${this.list.id}`); - this.cancel(); }, cancel() { this.title = ''; diff --git a/app/assets/javascripts/boards/models/list.js b/app/assets/javascripts/boards/models/list.js index 548de1a4c52..b4b09b3876e 100644 --- a/app/assets/javascripts/boards/models/list.js +++ b/app/assets/javascripts/boards/models/list.js @@ -112,8 +112,7 @@ class List { .then((resp) => { const data = resp.json(); issue.id = data.iid; - }) - .then(() => { + if (this.issuesSize > 1) { const moveBeforeIid = this.issues[1].id; gl.boardService.moveIssue(issue.id, null, null, null, moveBeforeIid); diff --git a/app/assets/javascripts/commit/pipelines/pipelines_bundle.js b/app/assets/javascripts/commit/pipelines/pipelines_bundle.js index 86d99dd87da..2c38440a2af 100644 --- a/app/assets/javascripts/commit/pipelines/pipelines_bundle.js +++ b/app/assets/javascripts/commit/pipelines/pipelines_bundle.js @@ -1,29 +1,30 @@ -/* eslint-disable no-param-reassign */ - import Vue from 'vue'; -import VueResource from 'vue-resource'; -import CommitPipelinesTable from './pipelines_table'; - -Vue.use(VueResource); +import commitPipelinesTable from './pipelines_table.vue'; /** - * Commits View > Pipelines Tab > Pipelines Table. - * - * Renders Pipelines table in pipelines tab in the commits show view. + * Used in: + * - Commit details View > Pipelines Tab > Pipelines Table. + * - Merge Request details View > Pipelines Tab > Pipelines Table. + * - New Merge Request View > Pipelines Tab > Pipelines Table. */ -// export for use in merge_request_tabs.js (TODO: remove this hack) +const CommitPipelinesTable = Vue.extend(commitPipelinesTable); + +// export for use in merge_request_tabs.js (TODO: remove this hack when we understand how to load +// vue.js in merge_request_tabs.js) window.gl = window.gl || {}; window.gl.CommitPipelinesTable = CommitPipelinesTable; -$(() => { - gl.commits = gl.commits || {}; - gl.commits.pipelines = gl.commits.pipelines || {}; - +document.addEventListener('DOMContentLoaded', () => { const pipelineTableViewEl = document.querySelector('#commit-pipeline-table-view'); if (pipelineTableViewEl && pipelineTableViewEl.dataset.disableInitialization === undefined) { - gl.commits.pipelines.PipelinesTableBundle = new CommitPipelinesTable().$mount(); - pipelineTableViewEl.appendChild(gl.commits.pipelines.PipelinesTableBundle.$el); + const table = new CommitPipelinesTable({ + propsData: { + endpoint: pipelineTableViewEl.dataset.endpoint, + helpPagePath: pipelineTableViewEl.dataset.helpPagePath, + }, + }).$mount(); + pipelineTableViewEl.appendChild(table.$el); } }); diff --git a/app/assets/javascripts/commit/pipelines/pipelines_table.js b/app/assets/javascripts/commit/pipelines/pipelines_table.js deleted file mode 100644 index 70ba83ce5b9..00000000000 --- a/app/assets/javascripts/commit/pipelines/pipelines_table.js +++ /dev/null @@ -1,191 +0,0 @@ -import Vue from 'vue'; -import Visibility from 'visibilityjs'; -import pipelinesTableComponent from '../../vue_shared/components/pipelines_table.vue'; -import PipelinesService from '../../pipelines/services/pipelines_service'; -import PipelineStore from '../../pipelines/stores/pipelines_store'; -import eventHub from '../../pipelines/event_hub'; -import emptyState from '../../pipelines/components/empty_state.vue'; -import errorState from '../../pipelines/components/error_state.vue'; -import loadingIcon from '../../vue_shared/components/loading_icon.vue'; -import '../../lib/utils/common_utils'; -import '../../vue_shared/vue_resource_interceptor'; -import Poll from '../../lib/utils/poll'; - -/** - * - * Uses `pipelines-table-component` to render Pipelines table with an API call. - * Endpoint is provided in HTML and passed as `endpoint`. - * We need a store to store the received environemnts. - * We need a service to communicate with the server. - * - */ - -export default Vue.component('pipelines-table', { - - components: { - pipelinesTableComponent, - errorState, - emptyState, - loadingIcon, - }, - - /** - * Accesses the DOM to provide the needed data. - * Returns the necessary props to render `pipelines-table-component` component. - * - * @return {Object} - */ - data() { - const store = new PipelineStore(); - - return { - endpoint: null, - helpPagePath: null, - store, - state: store.state, - isLoading: false, - hasError: false, - isMakingRequest: false, - updateGraphDropdown: false, - hasMadeRequest: false, - }; - }, - - computed: { - shouldRenderErrorState() { - return this.hasError && !this.isLoading; - }, - - /** - * Empty state is only rendered if after the first request we receive no pipelines. - * - * @return {Boolean} - */ - shouldRenderEmptyState() { - return !this.state.pipelines.length && - !this.isLoading && - this.hasMadeRequest && - !this.hasError; - }, - - shouldRenderTable() { - return !this.isLoading && - this.state.pipelines.length > 0 && - !this.hasError; - }, - }, - - /** - * When the component is about to be mounted, tell the service to fetch the data - * - * A request to fetch the pipelines will be made. - * In case of a successfull response we will store the data in the provided - * store, in case of a failed response we need to warn the user. - * - */ - beforeMount() { - const element = document.querySelector('#commit-pipeline-table-view'); - - this.endpoint = element.dataset.endpoint; - this.helpPagePath = element.dataset.helpPagePath; - this.service = new PipelinesService(this.endpoint); - - this.poll = new Poll({ - resource: this.service, - method: 'getPipelines', - successCallback: this.successCallback, - errorCallback: this.errorCallback, - notificationCallback: this.setIsMakingRequest, - }); - - if (!Visibility.hidden()) { - this.isLoading = true; - this.poll.makeRequest(); - } else { - // If tab is not visible we need to make the first request so we don't show the empty - // state without knowing if there are any pipelines - this.fetchPipelines(); - } - - Visibility.change(() => { - if (!Visibility.hidden()) { - this.poll.restart(); - } else { - this.poll.stop(); - } - }); - - eventHub.$on('refreshPipelines', this.fetchPipelines); - }, - - beforeDestroy() { - eventHub.$off('refreshPipelines'); - }, - - destroyed() { - this.poll.stop(); - }, - - methods: { - fetchPipelines() { - this.isLoading = true; - - return this.service.getPipelines() - .then(response => this.successCallback(response)) - .catch(() => this.errorCallback()); - }, - - successCallback(resp) { - const response = resp.json(); - - this.hasMadeRequest = true; - - // depending of the endpoint the response can either bring a `pipelines` key or not. - const pipelines = response.pipelines || response; - this.store.storePipelines(pipelines); - this.isLoading = false; - this.updateGraphDropdown = true; - }, - - errorCallback() { - this.hasError = true; - this.isLoading = false; - this.updateGraphDropdown = false; - }, - - setIsMakingRequest(isMakingRequest) { - this.isMakingRequest = isMakingRequest; - - if (isMakingRequest) { - this.updateGraphDropdown = false; - } - }, - }, - - template: ` - <div class="content-list pipelines"> - - <loading-icon - label="Loading pipelines" - size="3" - v-if="isLoading" - /> - - <empty-state - v-if="shouldRenderEmptyState" - :help-page-path="helpPagePath" /> - - <error-state v-if="shouldRenderErrorState" /> - - <div - class="table-holder" - v-if="shouldRenderTable"> - <pipelines-table-component - :pipelines="state.pipelines" - :service="service" - :update-graph-dropdown="updateGraphDropdown" - /> - </div> - </div> - `, -}); diff --git a/app/assets/javascripts/commit/pipelines/pipelines_table.vue b/app/assets/javascripts/commit/pipelines/pipelines_table.vue new file mode 100644 index 00000000000..3c77f14d533 --- /dev/null +++ b/app/assets/javascripts/commit/pipelines/pipelines_table.vue @@ -0,0 +1,90 @@ +<script> + import PipelinesService from '../../pipelines/services/pipelines_service'; + import PipelineStore from '../../pipelines/stores/pipelines_store'; + import pipelinesMixin from '../../pipelines/mixins/pipelines'; + + export default { + props: { + endpoint: { + type: String, + required: true, + }, + helpPagePath: { + type: String, + required: true, + }, + }, + mixins: [ + pipelinesMixin, + ], + + data() { + const store = new PipelineStore(); + + return { + store, + state: store.state, + }; + }, + + computed: { + /** + * Empty state is only rendered if after the first request we receive no pipelines. + * + * @return {Boolean} + */ + shouldRenderEmptyState() { + return !this.state.pipelines.length && + !this.isLoading && + this.hasMadeRequest && + !this.hasError; + }, + + shouldRenderTable() { + return !this.isLoading && + this.state.pipelines.length > 0 && + !this.hasError; + }, + }, + created() { + this.service = new PipelinesService(this.endpoint); + }, + methods: { + successCallback(resp) { + const response = resp.json(); + + // depending of the endpoint the response can either bring a `pipelines` key or not. + const pipelines = response.pipelines || response; + this.setCommonData(pipelines); + }, + }, + }; +</script> +<template> + <div class="content-list pipelines"> + + <loading-icon + label="Loading pipelines" + size="3" + v-if="isLoading" + /> + + <empty-state + v-if="shouldRenderEmptyState" + :help-page-path="helpPagePath" + /> + + <error-state + v-if="shouldRenderErrorState" + /> + + <div + class="table-holder" + v-if="shouldRenderTable"> + <pipelines-table-component + :pipelines="state.pipelines" + :update-graph-dropdown="updateGraphDropdown" + /> + </div> + </div> +</template> diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 88b4b567fa9..31a86090242 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -55,6 +55,7 @@ import RefSelectDropdown from './ref_select_dropdown'; import GfmAutoComplete from './gfm_auto_complete'; import ShortcutsBlob from './shortcuts_blob'; import initSettingsPanels from './settings_panels'; +import initExperimentalFlags from './experimental_flags'; (function() { var Dispatcher; @@ -120,6 +121,9 @@ import initSettingsPanels from './settings_panels'; } switch (page) { + case 'profiles:preferences:show': + initExperimentalFlags(); + break; case 'sessions:new': new UsernameValidator(); new ActiveTabMemoizer(); diff --git a/app/assets/javascripts/emoji/index.js b/app/assets/javascripts/emoji/index.js new file mode 100644 index 00000000000..cac35d6eed5 --- /dev/null +++ b/app/assets/javascripts/emoji/index.js @@ -0,0 +1,99 @@ +import emojiMap from 'emojis/digests.json'; +import emojiAliases from 'emojis/aliases.json'; + +export const validEmojiNames = [...Object.keys(emojiMap), ...Object.keys(emojiAliases)]; + +export function normalizeEmojiName(name) { + return Object.prototype.hasOwnProperty.call(emojiAliases, name) ? emojiAliases[name] : name; +} + +export function isEmojiNameValid(name) { + return validEmojiNames.indexOf(name) >= 0; +} + +export function filterEmojiNames(filter) { + const match = filter.toLowerCase(); + return validEmojiNames.filter(name => name.indexOf(match) >= 0); +} + +export function filterEmojiNamesByAlias(filter) { + return _.uniq(filterEmojiNames(filter).map(name => normalizeEmojiName(name))); +} + +let emojiCategoryMap; +export function getEmojiCategoryMap() { + if (!emojiCategoryMap) { + emojiCategoryMap = { + activity: [], + people: [], + nature: [], + food: [], + travel: [], + objects: [], + symbols: [], + flags: [], + }; + Object.keys(emojiMap).forEach((name) => { + const emoji = emojiMap[name]; + if (emojiCategoryMap[emoji.category]) { + emojiCategoryMap[emoji.category].push(name); + } + }); + } + return emojiCategoryMap; +} + +export function getEmojiInfo(query) { + let name = normalizeEmojiName(query); + let emojiInfo = emojiMap[name]; + + // Fallback to question mark for unknown emojis + if (!emojiInfo) { + name = 'grey_question'; + emojiInfo = emojiMap[name]; + } + + return { ...emojiInfo, name }; +} + +export function emojiFallbackImageSrc(inputName) { + const { name, digest } = getEmojiInfo(inputName); + return `${gon.asset_host || ''}${gon.relative_url_root || ''}/assets/emoji/${name}-${digest}.png`; +} + +export function emojiImageTag(name, src) { + return `<img class="emoji" title=":${name}:" alt=":${name}:" src="${src}" width="20" height="20" align="absmiddle" />`; +} + +export function glEmojiTag(inputName, options) { + const opts = { sprite: false, forceFallback: false, ...options }; + const { name, ...emojiInfo } = getEmojiInfo(inputName); + + const fallbackImageSrc = emojiFallbackImageSrc(name); + const fallbackSpriteClass = `emoji-${name}`; + + const classList = []; + if (opts.forceFallback && opts.sprite) { + classList.push('emoji-icon'); + classList.push(fallbackSpriteClass); + } + const classAttribute = classList.length > 0 ? `class="${classList.join(' ')}"` : ''; + const fallbackSpriteAttribute = opts.sprite ? `data-fallback-sprite-class="${fallbackSpriteClass}"` : ''; + let contents = emojiInfo.moji; + if (opts.forceFallback && !opts.sprite) { + contents = emojiImageTag(name, fallbackImageSrc); + } + + return ` + <gl-emoji + ${classAttribute} + data-name="${name}" + data-fallback-src="${fallbackImageSrc}" + ${fallbackSpriteAttribute} + data-unicode-version="${emojiInfo.unicodeVersion}" + title="${emojiInfo.description}" + > + ${contents} + </gl-emoji> + `; +} diff --git a/app/assets/javascripts/emoji/support/index.js b/app/assets/javascripts/emoji/support/index.js new file mode 100644 index 00000000000..1f7852dd487 --- /dev/null +++ b/app/assets/javascripts/emoji/support/index.js @@ -0,0 +1,10 @@ +import isEmojiUnicodeSupported from './is_emoji_unicode_supported'; +import getUnicodeSupportMap from './unicode_support_map'; + +// cache browser support map between calls +let browserUnicodeSupportMap; + +export default function isEmojiUnicodeSupportedByBrowser(emojiUnicode, unicodeVersion) { + browserUnicodeSupportMap = browserUnicodeSupportMap || getUnicodeSupportMap(); + return isEmojiUnicodeSupported(browserUnicodeSupportMap, emojiUnicode, unicodeVersion); +} diff --git a/app/assets/javascripts/behaviors/gl_emoji/is_emoji_unicode_supported.js b/app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js index 4f8884d05ac..3fd23efa9f8 100644 --- a/app/assets/javascripts/behaviors/gl_emoji/is_emoji_unicode_supported.js +++ b/app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js @@ -111,7 +111,7 @@ function isEmojiUnicodeSupported(unicodeSupportMap = {}, emojiUnicode, unicodeVe } export { - isEmojiUnicodeSupported, + isEmojiUnicodeSupported as default, isFlagEmoji, isKeycapEmoji, isSkinToneComboEmoji, diff --git a/app/assets/javascripts/behaviors/gl_emoji/unicode_support_map.js b/app/assets/javascripts/emoji/support/unicode_support_map.js index 257df55e54f..755381c2f95 100644 --- a/app/assets/javascripts/behaviors/gl_emoji/unicode_support_map.js +++ b/app/assets/javascripts/emoji/support/unicode_support_map.js @@ -140,7 +140,7 @@ function generateUnicodeSupportMap(testMap) { return resultMap; } -function getUnicodeSupportMap() { +export default function getUnicodeSupportMap() { let unicodeSupportMap; let userAgentFromCache; @@ -165,8 +165,3 @@ function getUnicodeSupportMap() { return unicodeSupportMap; } - -export { - getUnicodeSupportMap, - generateUnicodeSupportMap, -}; diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index a2448520a5f..e7495677e7c 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -2,6 +2,7 @@ import playIconSvg from 'icons/_icon_play.svg'; import eventHub from '../event_hub'; import loadingIcon from '../../vue_shared/components/loading_icon.vue'; +import tooltip from '../../vue_shared/directives/tooltip'; export default { props: { @@ -12,6 +13,10 @@ export default { }, }, + directives: { + tooltip, + }, + components: { loadingIcon, }, @@ -33,8 +38,6 @@ export default { onClickAction(endpoint) { this.isLoading = true; - $(this.$refs.tooltip).tooltip('destroy'); - eventHub.$emit('postAction', endpoint); }, @@ -53,11 +56,11 @@ export default { class="btn-group" role="group"> <button + v-tooltip type="button" - class="dropdown btn btn-default dropdown-new js-dropdown-play-icon-container has-tooltip" + class="dropdown btn btn-default dropdown-new js-dropdown-play-icon-container" data-container="body" data-toggle="dropdown" - ref="tooltip" :title="title" :aria-label="title" :disabled="isLoading"> diff --git a/app/assets/javascripts/environments/components/environment_external_url.vue b/app/assets/javascripts/environments/components/environment_external_url.vue index eaeec2bc53c..6b749814ea4 100644 --- a/app/assets/javascripts/environments/components/environment_external_url.vue +++ b/app/assets/javascripts/environments/components/environment_external_url.vue @@ -1,4 +1,6 @@ <script> +import tooltip from '../../vue_shared/directives/tooltip'; + /** * Renders the external url link in environments table. */ @@ -10,6 +12,10 @@ export default { }, }, + directives: { + tooltip, + }, + computed: { title() { return 'Open'; @@ -19,7 +25,8 @@ export default { </script> <template> <a - class="btn external-url has-tooltip" + v-tooltip + class="btn external-url" data-container="body" target="_blank" rel="noopener noreferrer nofollow" diff --git a/app/assets/javascripts/environments/components/environment_item.vue b/app/assets/javascripts/environments/components/environment_item.vue index 809c147bf25..b25113e0fc6 100644 --- a/app/assets/javascripts/environments/components/environment_item.vue +++ b/app/assets/javascripts/environments/components/environment_item.vue @@ -403,6 +403,14 @@ export default { return ''; }, + displayEnvironmentActions() { + return this.hasManualActions || + this.externalURL || + this.monitoringUrl || + this.hasStopAction || + this.canRetry; + }, + /** * Constructs folder URL based on the current location and the folder id. * @@ -535,9 +543,12 @@ export default { </span> </div> - <div class="table-section section-30 table-button-footer" role="gridcell"> + <div + v-if="!model.isFolder && displayEnvironmentActions" + class="table-section section-30 table-button-footer" + role="gridcell"> + <div - v-if="!model.isFolder" class="btn-group table-action-buttons" role="group"> diff --git a/app/assets/javascripts/environments/components/environment_monitoring.vue b/app/assets/javascripts/environments/components/environment_monitoring.vue index 07cf92281a0..1655561cdd3 100644 --- a/app/assets/javascripts/environments/components/environment_monitoring.vue +++ b/app/assets/javascripts/environments/components/environment_monitoring.vue @@ -2,6 +2,8 @@ /** * Renders the Monitoring (Metrics) link in environments table. */ +import tooltip from '../../vue_shared/directives/tooltip'; + export default { props: { monitoringUrl: { @@ -10,6 +12,10 @@ export default { }, }, + directives: { + tooltip, + }, + computed: { title() { return 'Monitoring'; @@ -19,7 +25,8 @@ export default { </script> <template> <a - class="btn monitoring-url has-tooltip hidden-xs hidden-sm" + v-tooltip + class="btn monitoring-url hidden-xs hidden-sm" data-container="body" rel="noopener noreferrer nofollow" :href="monitoringUrl" diff --git a/app/assets/javascripts/environments/components/environment_stop.vue b/app/assets/javascripts/environments/components/environment_stop.vue index 091c543860b..85f11d2071b 100644 --- a/app/assets/javascripts/environments/components/environment_stop.vue +++ b/app/assets/javascripts/environments/components/environment_stop.vue @@ -5,6 +5,7 @@ */ import eventHub from '../event_hub'; import loadingIcon from '../../vue_shared/components/loading_icon.vue'; +import tooltip from '../../vue_shared/directives/tooltip'; export default { props: { @@ -14,6 +15,10 @@ export default { }, }, + directives: { + tooltip, + }, + data() { return { isLoading: false, @@ -46,8 +51,9 @@ export default { </script> <template> <button + v-tooltip type="button" - class="btn stop-env-link has-tooltip hidden-xs hidden-sm" + class="btn stop-env-link hidden-xs hidden-sm" data-container="body" @click="onClick" :disabled="isLoading" diff --git a/app/assets/javascripts/environments/components/environment_terminal_button.vue b/app/assets/javascripts/environments/components/environment_terminal_button.vue index 1ca65a79951..2037bf618e3 100644 --- a/app/assets/javascripts/environments/components/environment_terminal_button.vue +++ b/app/assets/javascripts/environments/components/environment_terminal_button.vue @@ -4,6 +4,7 @@ * Used in environments table. */ import terminalIconSvg from 'icons/_icon_terminal.svg'; +import tooltip from '../../vue_shared/directives/tooltip'; export default { props: { @@ -14,6 +15,10 @@ export default { }, }, + directives: { + tooltip, + }, + data() { return { terminalIconSvg, @@ -29,7 +34,8 @@ export default { </script> <template> <a - class="btn terminal-button has-tooltip hidden-xs hidden-sm" + v-tooltip + class="btn terminal-button hidden-xs hidden-sm" data-container="body" :title="title" :aria-label="title" diff --git a/app/assets/javascripts/experimental_flags.js b/app/assets/javascripts/experimental_flags.js new file mode 100644 index 00000000000..dbd3843cef7 --- /dev/null +++ b/app/assets/javascripts/experimental_flags.js @@ -0,0 +1,11 @@ +import Cookies from 'js-cookie'; + +export default () => { + $('.js-experiment-feature-toggle').on('change', (e) => { + const el = e.target; + + Cookies.set(el.name, el.value, { + expires: 365 * 10, + }); + }); +}; diff --git a/app/assets/javascripts/filtered_search/filtered_search_manager.js b/app/assets/javascripts/filtered_search/filtered_search_manager.js index 8f547bd8f1f..1425769d2de 100644 --- a/app/assets/javascripts/filtered_search/filtered_search_manager.js +++ b/app/assets/javascripts/filtered_search/filtered_search_manager.js @@ -40,6 +40,10 @@ class FilteredSearchManager { return []; }) .then((searches) => { + if (!searches) { + return; + } + // Put any searches that may have come in before // we fetched the saved searches ahead of the already saved ones const resultantSearches = this.recentSearchesStore.setRecentSearches( @@ -487,6 +491,7 @@ class FilteredSearchManager { } searchState(e) { + e.preventDefault(); const target = e.currentTarget; // remove focus outline after click target.blur(); diff --git a/app/assets/javascripts/gfm_auto_complete.js b/app/assets/javascripts/gfm_auto_complete.js index 105762cb1ba..f99bac7da1a 100644 --- a/app/assets/javascripts/gfm_auto_complete.js +++ b/app/assets/javascripts/gfm_auto_complete.js @@ -1,8 +1,6 @@ -import emojiMap from 'emojis/digests.json'; -import emojiAliases from 'emojis/aliases.json'; -import { glEmojiTag } from '~/behaviors/gl_emoji'; -import glRegexp from '~/lib/utils/regexp'; -import AjaxCache from '~/lib/utils/ajax_cache'; +import { validEmojiNames, glEmojiTag } from './emoji'; +import glRegexp from './lib/utils/regexp'; +import AjaxCache from './lib/utils/ajax_cache'; function sanitize(str) { return str.replace(/<(?:.|\n)*?>/gm, ''); @@ -375,7 +373,7 @@ class GfmAutoComplete { if (this.cachedData[at]) { this.loadData($input, at, this.cachedData[at]); } else if (GfmAutoComplete.atTypeMap[at] === 'emojis') { - this.loadData($input, at, Object.keys(emojiMap).concat(Object.keys(emojiAliases))); + this.loadData($input, at, validEmojiNames); } else { AjaxCache.retrieve(this.dataSources[GfmAutoComplete.atTypeMap[at]], true) .then((data) => { diff --git a/app/assets/javascripts/groups/stores/groups_store.js b/app/assets/javascripts/groups/stores/groups_store.js index f6dc4290fd5..6eab6083e8f 100644 --- a/app/assets/javascripts/groups/stores/groups_store.js +++ b/app/assets/javascripts/groups/stores/groups_store.js @@ -47,8 +47,8 @@ export default class GroupsStore { // Map groups to an object groups.map((group) => { - mappedGroups[group.id] = group; - mappedGroups[group.id].subGroups = {}; + mappedGroups[`id${group.id}`] = group; + mappedGroups[`id${group.id}`].subGroups = {}; return group; }); @@ -56,26 +56,27 @@ export default class GroupsStore { const currentGroup = mappedGroups[key]; if (currentGroup.parentId) { // If the group is not at the root level, add it to its parent array of subGroups. - const findParentGroup = mappedGroups[currentGroup.parentId]; + const findParentGroup = mappedGroups[`id${currentGroup.parentId}`]; if (findParentGroup) { - mappedGroups[currentGroup.parentId].subGroups[currentGroup.id] = currentGroup; - mappedGroups[currentGroup.parentId].isOpen = true; // Expand group if it has subgroups + mappedGroups[`id${currentGroup.parentId}`].subGroups[`id${currentGroup.id}`] = currentGroup; + mappedGroups[`id${currentGroup.parentId}`].isOpen = true; // Expand group if it has subgroups } else if (parentGroup && parentGroup.id === currentGroup.parentId) { - tree[currentGroup.id] = currentGroup; + tree[`id${currentGroup.id}`] = currentGroup; } else { - // Means the groups hast no direct parent. - // Save for later processing, we will add them to its corresponding base group + // No parent found. We save it for later processing orphans.push(currentGroup); + + // Add to tree to preserve original order + tree[`id${currentGroup.id}`] = currentGroup; } } else { - // If the group is at the root level, add it to first level elements array. - tree[currentGroup.id] = currentGroup; + // If the group is at the top level, add it to first level elements array. + tree[`id${currentGroup.id}`] = currentGroup; } return key; }); - // Hopefully this array will be empty for most cases if (orphans.length) { orphans.map((orphan) => { let found = false; @@ -83,11 +84,23 @@ export default class GroupsStore { Object.keys(tree).map((key) => { const group = tree[key]; - if (currentOrphan.fullPath.lastIndexOf(group.fullPath) === 0) { + + if ( + group && + currentOrphan.fullPath.lastIndexOf(group.fullPath) === 0 && + // Make sure the currently selected orphan is not the same as the group + // we are checking here otherwise it will end up in an infinite loop + currentOrphan.id !== group.id + ) { group.subGroups[currentOrphan.id] = currentOrphan; group.isOpen = true; currentOrphan.isOrphan = true; found = true; + + // Delete if group was put at the top level. If not the group will be displayed twice. + if (tree[`id${currentOrphan.id}`]) { + delete tree[`id${currentOrphan.id}`]; + } } return key; @@ -95,7 +108,8 @@ export default class GroupsStore { if (!found) { currentOrphan.isOrphan = true; - tree[currentOrphan.id] = currentOrphan; + + tree[`id${currentOrphan.id}`] = currentOrphan; } return orphan; @@ -140,7 +154,7 @@ export default class GroupsStore { // eslint-disable-next-line class-methods-use-this removeGroup(group, collection) { - Vue.delete(collection, group.id); + Vue.delete(collection, `id${group.id}`); } // eslint-disable-next-line class-methods-use-this diff --git a/app/assets/javascripts/issuable_bulk_update_sidebar.js b/app/assets/javascripts/issuable_bulk_update_sidebar.js index 84bd2e092e6..a8856120c5e 100644 --- a/app/assets/javascripts/issuable_bulk_update_sidebar.js +++ b/app/assets/javascripts/issuable_bulk_update_sidebar.js @@ -22,6 +22,7 @@ export default class IssuableBulkUpdateSidebar { initDomElements() { this.$page = $('.page-with-sidebar'); this.$sidebar = $('.right-sidebar'); + this.$sidebarInnerContainer = this.$sidebar.find('.issuable-sidebar'); this.$bulkEditCancelBtn = $('.js-bulk-update-menu-hide'); this.$bulkEditSubmitBtn = $('.update-selected-issues'); this.$bulkUpdateEnableBtn = $('.js-bulk-update-toggle'); @@ -113,6 +114,7 @@ export default class IssuableBulkUpdateSidebar { toggleSidebarDisplay(show) { this.$page.toggleClass(SIDEBAR_EXPANDED_CLASS, show); this.$page.toggleClass(SIDEBAR_COLLAPSED_CLASS, !show); + this.$sidebarInnerContainer.toggleClass(HIDDEN_CLASS, !show); this.$sidebar.toggleClass(SIDEBAR_EXPANDED_CLASS, show); this.$sidebar.toggleClass(SIDEBAR_COLLAPSED_CLASS, !show); } diff --git a/app/assets/javascripts/issue_show/components/app.vue b/app/assets/javascripts/issue_show/components/app.vue index e14414d3f68..3d5fb7f441c 100644 --- a/app/assets/javascripts/issue_show/components/app.vue +++ b/app/assets/javascripts/issue_show/components/app.vue @@ -51,6 +51,11 @@ export default { required: false, default: '', }, + initialTaskStatus: { + type: String, + required: false, + default: '', + }, updatedAt: { type: String, required: false, @@ -105,6 +110,7 @@ export default { updatedAt: this.updatedAt, updatedByName: this.updatedByName, updatedByPath: this.updatedByPath, + taskStatus: this.initialTaskStatus, }); return { @@ -198,13 +204,7 @@ export default { method: 'getData', successCallback: (res) => { const data = res.json(); - const shouldUpdate = this.store.stateShouldUpdate(data); - this.store.updateState(data); - - if (this.showForm && (shouldUpdate.title || shouldUpdate.description)) { - this.store.formState.lockedWarningVisible = true; - } }, errorCallback(err) { throw new Error(err); diff --git a/app/assets/javascripts/issue_show/components/description.vue b/app/assets/javascripts/issue_show/components/description.vue index bb95ff0101b..43db66c8e08 100644 --- a/app/assets/javascripts/issue_show/components/description.vue +++ b/app/assets/javascripts/issue_show/components/description.vue @@ -37,18 +37,7 @@ }); }, taskStatus() { - const taskRegexMatches = this.taskStatus.match(/(\d+) of (\d+)/); - const $issuableHeader = $('.issuable-meta'); - const $tasks = $('#task_status', $issuableHeader); - const $tasksShort = $('#task_status_short', $issuableHeader); - - if (taskRegexMatches) { - $tasks.text(this.taskStatus); - $tasksShort.text(`${taskRegexMatches[1]}/${taskRegexMatches[2]} task${taskRegexMatches[2] > 1 ? 's' : ''}`); - } else { - $tasks.text(''); - $tasksShort.text(''); - } + this.updateTaskStatusText(); }, }, methods: { @@ -64,9 +53,24 @@ }); } }, + updateTaskStatusText() { + const taskRegexMatches = this.taskStatus.match(/(\d+) of ((?!0)\d+)/); + const $issuableHeader = $('.issuable-meta'); + const $tasks = $('#task_status', $issuableHeader); + const $tasksShort = $('#task_status_short', $issuableHeader); + + if (taskRegexMatches) { + $tasks.text(this.taskStatus); + $tasksShort.text(`${taskRegexMatches[1]}/${taskRegexMatches[2]} task${taskRegexMatches[2] > 1 ? 's' : ''}`); + } else { + $tasks.text(''); + $tasksShort.text(''); + } + }, }, mounted() { this.renderGFM(); + this.updateTaskStatusText(); }, }; </script> diff --git a/app/assets/javascripts/issue_show/components/fields/description.vue b/app/assets/javascripts/issue_show/components/fields/description.vue index 54650d2f184..27b1b814f9a 100644 --- a/app/assets/javascripts/issue_show/components/fields/description.vue +++ b/app/assets/javascripts/issue_show/components/fields/description.vue @@ -47,7 +47,8 @@ ref="textarea" slot="textarea" placeholder="Write a comment or drag your files here..." - @keydown.meta.enter="updateIssuable"> + @keydown.meta.enter="updateIssuable" + @keydown.ctrl.enter="updateIssuable"> </textarea> </markdown-field> </div> diff --git a/app/assets/javascripts/issue_show/components/fields/project_move.vue b/app/assets/javascripts/issue_show/components/fields/project_move.vue index f811fb0de24..7bf2be8b28a 100644 --- a/app/assets/javascripts/issue_show/components/fields/project_move.vue +++ b/app/assets/javascripts/issue_show/components/fields/project_move.vue @@ -1,10 +1,10 @@ <script> - import tooltipMixin from '../../../vue_shared/mixins/tooltip'; + import tooltip from '../../../vue_shared/directives/tooltip'; export default { - mixins: [ - tooltipMixin, - ], + directives: { + tooltip, + }, props: { formState: { type: Object, @@ -71,9 +71,9 @@ data-placeholder="Move to a different project" /> </div> <span + v-tooltip data-placement="auto top" - title="Moving an issue will copy the discussion to a different project and close it here. All participants will be notified of the new location." - ref="tooltip"> + title="Moving an issue will copy the discussion to a different project and close it here. All participants will be notified of the new location."> <i class="fa fa-question-circle" aria-hidden="true"> diff --git a/app/assets/javascripts/issue_show/components/fields/title.vue b/app/assets/javascripts/issue_show/components/fields/title.vue index 6556bf117e2..83af8e1e245 100644 --- a/app/assets/javascripts/issue_show/components/fields/title.vue +++ b/app/assets/javascripts/issue_show/components/fields/title.vue @@ -26,6 +26,7 @@ placeholder="Issue title" aria-label="Issue title" v-model="formState.title" - @keydown.meta.enter="updateIssuable" /> + @keydown.meta.enter="updateIssuable" + @keydown.ctrl.enter="updateIssuable" /> </fieldset> </template> diff --git a/app/assets/javascripts/issue_show/index.js b/app/assets/javascripts/issue_show/index.js index 14b2a1e18e9..ad8cb6465e2 100644 --- a/app/assets/javascripts/issue_show/index.js +++ b/app/assets/javascripts/issue_show/index.js @@ -45,6 +45,7 @@ document.addEventListener('DOMContentLoaded', () => { updatedAt: this.updatedAt, updatedByName: this.updatedByName, updatedByPath: this.updatedByPath, + initialTaskStatus: this.initialTaskStatus, }, }); }, diff --git a/app/assets/javascripts/issue_show/stores/index.js b/app/assets/javascripts/issue_show/stores/index.js index 27c2d349f52..0c8bd6f1cc3 100644 --- a/app/assets/javascripts/issue_show/stores/index.js +++ b/app/assets/javascripts/issue_show/stores/index.js @@ -1,23 +1,6 @@ export default class Store { - constructor({ - titleHtml, - titleText, - descriptionHtml, - descriptionText, - updatedAt, - updatedByName, - updatedByPath, - }) { - this.state = { - titleHtml, - titleText, - descriptionHtml, - descriptionText, - taskStatus: '', - updatedAt, - updatedByName, - updatedByPath, - }; + constructor(initialState) { + this.state = initialState; this.formState = { title: '', confidential: false, @@ -29,6 +12,10 @@ export default class Store { } updateState(data) { + if (this.stateShouldUpdate(data)) { + this.formState.lockedWarningVisible = true; + } + this.state.titleHtml = data.title; this.state.titleText = data.title_text; this.state.descriptionHtml = data.description; @@ -40,10 +27,8 @@ export default class Store { } stateShouldUpdate(data) { - return { - title: this.state.titleText !== data.title_text, - description: this.state.descriptionText !== data.description_text, - }; + return this.state.titleText !== data.title_text || + this.state.descriptionText !== data.description_text; } setFormState(state) { diff --git a/app/assets/javascripts/label_manager.js b/app/assets/javascripts/label_manager.js index 38b2eb9ff14..d8814802d9e 100644 --- a/app/assets/javascripts/label_manager.js +++ b/app/assets/javascripts/label_manager.js @@ -21,6 +21,7 @@ } bindEvents() { + this.prioritizedLabels.find('.btn-action').on('mousedown', this, this.onButtonActionClick); return this.togglePriorityButton.on('click', this, this.onTogglePriorityClick); } @@ -36,6 +37,11 @@ _this.toggleEmptyState($label, $btn, action); } + onButtonActionClick(e) { + e.stopPropagation(); + $(e.currentTarget).tooltip('hide'); + } + toggleEmptyState($label, $btn, action) { this.emptyState.classList.toggle('hidden', !!this.prioritizedLabels[0].querySelector(':scope > li')); } diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 2aca86189fd..122ec138c59 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -86,18 +86,25 @@ // This is required to handle non-unicode characters in hash hash = decodeURIComponent(hash); + var fixedTabs = document.querySelector('.js-tabs-affix'); + var fixedNav = document.querySelector('.navbar-gitlab'); + + var adjustment = 0; + if (fixedNav) adjustment -= fixedNav.offsetHeight; + // scroll to user-generated markdown anchor if we cannot find a match if (document.getElementById(hash) === null) { var target = document.getElementById('user-content-' + hash); if (target && target.scrollIntoView) { target.scrollIntoView(true); + window.scrollBy(0, adjustment); } } else { // only adjust for fixedTabs when not targeting user-generated content - var fixedTabs = document.querySelector('.js-tabs-affix'); if (fixedTabs) { - window.scrollBy(0, -fixedTabs.offsetHeight); + adjustment -= fixedTabs.offsetHeight; } + window.scrollBy(0, adjustment); } }; diff --git a/app/assets/javascripts/lib/utils/text_utility.js b/app/assets/javascripts/lib/utils/text_utility.js index 601d01e1be1..021f936a4fa 100644 --- a/app/assets/javascripts/lib/utils/text_utility.js +++ b/app/assets/javascripts/lib/utils/text_utility.js @@ -94,8 +94,8 @@ gl.text.insertText = function(textArea, text, tag, blockTag, selected, wrap) { startChar = !wrap && !currentLineEmpty && textArea.selectionStart > 0 ? '\n' : ''; - if (selectedSplit.length > 1 && (!wrap || (blockTag != null))) { - if (blockTag != null) { + if (selectedSplit.length > 1 && (!wrap || (blockTag != null && blockTag !== ''))) { + if (blockTag != null && blockTag !== '') { insertText = this.blockTagText(text, textArea, blockTag, selected); } else { insertText = selectedSplit.map(function(val) { diff --git a/app/assets/javascripts/locale/bg/app.js b/app/assets/javascripts/locale/bg/app.js deleted file mode 100644 index ba56c0bea25..00000000000 --- a/app/assets/javascripts/locale/bg/app.js +++ /dev/null @@ -1 +0,0 @@ -var locales = locales || {}; locales['bg'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","POT-Creation-Date":"2017-05-04 19:24-0500","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","PO-Revision-Date":"2017-06-05 09:40-0400","Last-Translator":"Lyubomir Vasilev <lyubomirv@abv.bg>","Language-Team":"Bulgarian","Language":"bg","X-Generator":"Zanata 3.9.6","Plural-Forms":"nplurals=2; plural=(n != 1)","lang":"bg","domain":"app","plural_forms":"nplurals=2; plural=(n != 1)"},"ByAuthor|by":["от"],"Commit":["Подаване","Подавания"],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":["Анализът на циклите дава общ поглед върху това колко време е нужно на една идея да се превърне в завършена функционалност в проекта."],"CycleAnalyticsStage|Code":["Програмиране"],"CycleAnalyticsStage|Issue":["Проблем"],"CycleAnalyticsStage|Plan":["Планиране"],"CycleAnalyticsStage|Production":["Издаване"],"CycleAnalyticsStage|Review":["Преглед и одобрение"],"CycleAnalyticsStage|Staging":["Подготовка за издаване"],"CycleAnalyticsStage|Test":["Тестване"],"Deploy":["Внедряване","Внедрявания"],"FirstPushedBy|First":["Първо"],"FirstPushedBy|pushed by":["изпращане на промени от"],"From issue creation until deploy to production":["От създаването на проблема до внедряването в крайната версия"],"From merge request merge until deploy to production":["От прилагането на заявката за сливане до внедряването в крайната версия"],"Introducing Cycle Analytics":["Представяме Ви анализът на циклите"],"Last %d day":["Последния %d ден","Последните %d дни"],"Limited to showing %d event at most":["Ограничено до показване на последното %d събитие","Ограничено до показване на последните %d събития"],"Median":["Медиана"],"New Issue":["Нов проблем","Нови проблема"],"Not available":["Не е налично"],"Not enough data":["Няма достатъчно данни"],"OpenedNDaysAgo|Opened":["Отворен"],"Pipeline Health":["Състояние"],"ProjectLifecycle|Stage":["Етап"],"Read more":["Прочетете повече"],"Related Commits":["Свързани подавания"],"Related Deployed Jobs":["Свързани задачи за внедряване"],"Related Issues":["Свързани проблеми"],"Related Jobs":["Свързани задачи"],"Related Merge Requests":["Свързани заявки за сливане"],"Related Merged Requests":["Свързани приложени заявки за сливане"],"Showing %d event":["Показване на %d събитие","Показване на %d събития"],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":["Етапът на програмиране показва времето от първото подаване до създаването на заявката за сливане. Данните ще бъдат добавени тук автоматично след като бъде създадена първата заявка за сливане."],"The collection of events added to the data gathered for that stage.":["Съвкупността от събития добавени към данните събрани за този етап."],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":["Етапът на проблемите показва колко е времето от създаването на проблем до определянето на целеви етап на проекта за него, или до добавянето му в списък на дъската за проблеми. Започнете да добавяте проблеми, за да видите данните за този етап."],"The phase of the development lifecycle.":["Етапът от цикъла на разработка"],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":["Етапът на планиране показва колко е времето от преходната стъпка до изпращането на първото подаване. Това време ще бъде добавено автоматично след като изпратите първото си подаване."],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":["Етапът на издаване показва общото време, което е нужно от създаването на проблем до внедряването на кода в крайната версия."],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":["Етапът на преглед и одобрение показва времето от създаването на заявката за сливане до прилагането ѝ. Данните ще бъдат добавени автоматично след като приложите първата си заявка за сливане."],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":["Етапът на подготовка за издаване показва времето между прилагането на заявката за сливане и внедряването на кода в средата на работещата крайна версия. Данните ще бъдат добавени автоматично след като направите първото си внедряване в крайната версия."],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":["Етапът на тестване показва времето, което е нужно на „Gitlab CI“ да изпълни всички задачи за свързаната заявка за сливане. Данните ще бъдат добавени автоматично след като приключи изпълнените на първата Ви такава задача."],"The time taken by each data entry gathered by that stage.":["Времето, което отнема всеки запис от данни за съответния етап."],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":["Стойността, която се намира в средата на последователността от наблюдавани данни. Например: медианата на 3, 5 и 9 е 5, а медианата на 3, 5, 7 и 8 е (5+7)/2 = 6."],"Time before an issue gets scheduled":["Време преди един проблем да бъде планиран за работа"],"Time before an issue starts implementation":["Време преди работата по проблем да започне"],"Time between merge request creation and merge/close":["Време между създаване на заявка за сливане и прилагането/отхвърлянето ѝ"],"Time until first merge request":["Време преди първата заявка за сливане"],"Time|hr":["час","часа"],"Time|min":["мин","мин"],"Time|s":["сек"],"Total Time":["Общо време"],"Total test time for all commits/merges":["Общо време за тестване на всички подавания/сливания"],"Want to see the data? Please ask an administrator for access.":["Искате ли да видите данните? Помолете администратор за достъп."],"We don't have enough data to show this stage.":["Няма достатъчно данни за този етап."],"You need permission.":["Нуждаете се от разрешение."],"day":["ден","дни"]}}};
\ No newline at end of file diff --git a/app/assets/javascripts/locale/de/app.js b/app/assets/javascripts/locale/de/app.js deleted file mode 100644 index e7d2b174405..00000000000 --- a/app/assets/javascripts/locale/de/app.js +++ /dev/null @@ -1 +0,0 @@ -var locales = locales || {}; locales['de'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-05-09 13:44+0200","Language-Team":"German","Language":"de","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Plural-Forms":"nplurals=2; plural=n != 1;","Last-Translator":"","X-Generator":"Poedit 2.0.1","lang":"de","domain":"app","plural_forms":"nplurals=2; plural=n != 1;"},"Are you sure you want to delete this pipeline schedule?":[""],"ByAuthor|by":["Von"],"Cancel":[""],"Commit":["Commit","Commits"],"Cron Timezone":[""],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":["Cycle Analytics liefern einen Überblick darüber, wie viel Zeit in Ihrem Projekt von einer Idee bis zum Produktivdeployment vergeht."],"CycleAnalyticsStage|Code":["Code"],"CycleAnalyticsStage|Issue":["Issue"],"CycleAnalyticsStage|Plan":["Planung"],"CycleAnalyticsStage|Production":["Produktiv"],"CycleAnalyticsStage|Review":["Review"],"CycleAnalyticsStage|Staging":["Staging"],"CycleAnalyticsStage|Test":["Test"],"Delete":[""],"Deploy":["Deployment","Deployments"],"Description":[""],"Edit":[""],"Edit Pipeline Schedule %{id}":[""],"Failed to change the owner":[""],"Failed to remove the pipeline schedule":[""],"Filter":[""],"FirstPushedBy|First":["Erster"],"FirstPushedBy|pushed by":["gepusht von"],"From issue creation until deploy to production":["Vom Anlegen des Issues bis zum Produktivdeployment"],"From merge request merge until deploy to production":["Vom Merge Request bis zum Produktivdeployment"],"Interval Pattern":[""],"Introducing Cycle Analytics":["Was sind Cycle Analytics?"],"Last %d day":["Letzter %d Tag","Letzten %d Tage"],"Last Pipeline":[""],"Limited to showing %d event at most":["Eingeschränkt auf maximal %d Ereignis","Eingeschränkt auf maximal %d Ereignisse"],"Median":["Median"],"New Issue":["Neues Issue","Neue Issues"],"New Pipeline Schedule":[""],"No schedules":[""],"Not available":["Nicht verfügbar"],"Not enough data":["Nicht genügend Daten"],"OpenedNDaysAgo|Opened":["Erstellt"],"Owner":[""],"Pipeline Health":["Pipeline Kennzahlen"],"Pipeline Schedule":[""],"Pipeline Schedules":[""],"PipelineSchedules|Activated":[""],"PipelineSchedules|Active":[""],"PipelineSchedules|All":[""],"PipelineSchedules|Inactive":[""],"PipelineSchedules|Next Run":[""],"PipelineSchedules|None":[""],"PipelineSchedules|Provide a short description for this pipeline":[""],"PipelineSchedules|Take ownership":[""],"PipelineSchedules|Target":[""],"ProjectLifecycle|Stage":["Phase"],"Read more":["Mehr"],"Related Commits":["Zugehörige Commits"],"Related Deployed Jobs":["Zugehörige Deploymentjobs"],"Related Issues":["Zugehörige Issues"],"Related Jobs":["Zugehörige Jobs"],"Related Merge Requests":["Zugehörige Merge Requests"],"Related Merged Requests":["Zugehörige abgeschlossene Merge Requests"],"Save pipeline schedule":[""],"Schedule a new pipeline":[""],"Select a timezone":[""],"Select target branch":[""],"Showing %d event":["Zeige %d Ereignis","Zeige %d Ereignisse"],"Target Branch":[""],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":["Die Code-Phase stellt die Zeit vom ersten Commit bis zum Erstellen eines Merge Requests dar. Sobald Sie Ihren ersten Merge Request anlegen, werden dessen Daten automatisch ergänzt."],"The collection of events added to the data gathered for that stage.":["Ereignisse, die für diese Phase ausgewertet wurden."],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":["Die Issue-Phase stellt die Zeit vom Anlegen eines Issues bis zum Zuweisen eines Meilensteins oder Hinzufügen zum Issue Board dar. Erstellen Sie einen Issue, damit dessen Daten hier erscheinen."],"The phase of the development lifecycle.":["Die Phase im Entwicklungsprozess."],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":["Die Planungsphase stellt die Zeit von der vorherigen Phase bis zum Pushen des ersten Commits dar. Sobald Sie den ersten Commit pushen, werden dessen Daten hier erscheinen."],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":["Die Produktiv-Phase stellt die Gesamtzeit vom Anlegen eines Issues bis zum Deployment auf dem Produktivsystem dar. Sobald Sie den vollständigen Entwicklungszyklus von einer Idee bis zum Produktivdeployment durchlaufen haben, erscheinen die zugehörigen Daten hier."],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":["Die Review-Phase stellt die Zeit vom Anlegen eines Merge Requests bis zum Mergen dar. Sobald Sie Ihren ersten Merge Request abschließen, werden dessen Daten hier automatisch angezeigt."],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":["Die Staging-Phase stellt die Zeit zwischen Mergen eines Merge Requests und dem Produktivdeployment dar. Sobald Sie das erste Produktivdeployment durchgeführt haben, werden dessen Daten hier automatisch angezeigt."],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":["Die Test-Phase stellt die Zeit dar, die GitLab CI benötigt um die Pipelines von Merge Requests abzuarbeiten. Sobald die erste Pipeline abgeschlossen ist, werden deren Daten hier automatisch angezeigt."],"The time taken by each data entry gathered by that stage.":["Zeit die für das jeweilige Ereignis in der Phase ermittelt wurde."],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":["Der mittlere aller erfassten Werte. Zum Beispiel ist für 3, 5, 9 der Median 5. Bei 3, 5, 7, 8 ist der Median (5+7)/2 = 6."],"Time before an issue gets scheduled":["Zeit bis ein Issue geplant wird"],"Time before an issue starts implementation":["Zeit bis die Implementierung für ein Issue beginnt"],"Time between merge request creation and merge/close":["Zeit zwischen Anlegen und Mergen/Schließen eines Merge Requests"],"Time until first merge request":["Zeit bis zum ersten Merge Request"],"Time|hr":["h","h"],"Time|min":["min","min"],"Time|s":["s"],"Total Time":["Gesamtzeit"],"Total test time for all commits/merges":["Gesamte Testlaufzeit für alle Commits/Merges"],"Want to see the data? Please ask an administrator for access.":["Um diese Daten einsehen zu können, wenden Sie sich bitte an Ihren Administrator."],"We don't have enough data to show this stage.":["Es liegen nicht genügend Daten vor, um diese Phase anzuzeigen."],"You need permission.":["Sie benötigen Zugriffsrechte."],"day":["Tag","Tage"]}}};
\ No newline at end of file diff --git a/app/assets/javascripts/locale/en/app.js b/app/assets/javascripts/locale/en/app.js deleted file mode 100644 index d634af959e5..00000000000 --- a/app/assets/javascripts/locale/en/app.js +++ /dev/null @@ -1 +0,0 @@ -var locales = locales || {}; locales['en'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-04-12 22:36-0500","Last-Translator":"FULL NAME <EMAIL@ADDRESS>","Language-Team":"English","Language":"en","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Plural-Forms":"nplurals=2; plural=n != 1;","lang":"en","domain":"app","plural_forms":"nplurals=2; plural=n != 1;"},"%{commit_author_link} committed %{commit_timeago}":[""],"About auto deploy":[""],"Active":[""],"Activity":[""],"Add Changelog":[""],"Add Contribution guide":[""],"Add License":[""],"Add an SSH key to your profile to pull or push via SSH.":[""],"Add new directory":[""],"Archived project! Repository is read-only":[""],"Are you sure you want to delete this pipeline schedule?":[""],"Attach a file by drag & drop or %{upload_link}":[""],"Branch":["",""],"Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, choose a GitLab CI Yaml template and commit your changes. %{link_to_autodeploy_doc}":[""],"Branches":[""],"Browse files":[""],"ByAuthor|by":[""],"CI configuration":[""],"Cancel":[""],"ChangeTypeActionLabel|Pick into branch":[""],"ChangeTypeActionLabel|Revert in branch":[""],"ChangeTypeAction|Cherry-pick":[""],"Changelog":[""],"Charts":[""],"Cherry-pick this commit":[""],"Cherry-pick this merge request":[""],"CiStatusLabel|canceled":[""],"CiStatusLabel|created":[""],"CiStatusLabel|failed":[""],"CiStatusLabel|manual action":[""],"CiStatusLabel|passed":[""],"CiStatusLabel|passed with warnings":[""],"CiStatusLabel|pending":[""],"CiStatusLabel|skipped":[""],"CiStatusLabel|waiting for manual action":[""],"CiStatusText|blocked":[""],"CiStatusText|canceled":[""],"CiStatusText|created":[""],"CiStatusText|failed":[""],"CiStatusText|manual":[""],"CiStatusText|passed":[""],"CiStatusText|pending":[""],"CiStatusText|skipped":[""],"CiStatus|running":[""],"Commit":["",""],"Commit message":[""],"CommitBoxTitle|Commit":[""],"CommitMessage|Add %{file_name}":[""],"Commits":[""],"Commits|History":[""],"Committed by":[""],"Compare":[""],"Contribution guide":[""],"Contributors":[""],"Copy URL to clipboard":[""],"Copy commit SHA to clipboard":[""],"Create New Directory":[""],"Create directory":[""],"Create empty bare repository":[""],"Create merge request":[""],"Create new...":[""],"CreateNewFork|Fork":[""],"CreateTag|Tag":[""],"Cron Timezone":[""],"Cron syntax":[""],"Custom notification events":[""],"Custom notification levels are the same as participating levels. With custom notification levels you will also receive notifications for select events. To find out more, check out %{notification_link}.":[""],"Cycle Analytics":[""],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":[""],"CycleAnalyticsStage|Code":[""],"CycleAnalyticsStage|Issue":[""],"CycleAnalyticsStage|Plan":[""],"CycleAnalyticsStage|Production":[""],"CycleAnalyticsStage|Review":[""],"CycleAnalyticsStage|Staging":[""],"CycleAnalyticsStage|Test":[""],"Define a custom pattern with cron syntax":[""],"Delete":[""],"Deploy":["",""],"Description":[""],"Directory name":[""],"Don't show again":[""],"Download":[""],"Download tar":[""],"Download tar.bz2":[""],"Download tar.gz":[""],"Download zip":[""],"DownloadArtifacts|Download":[""],"DownloadCommit|Email Patches":[""],"DownloadCommit|Plain Diff":[""],"DownloadSource|Download":[""],"Edit":[""],"Edit Pipeline Schedule %{id}":[""],"Every day (at 4:00am)":[""],"Every month (on the 1st at 4:00am)":[""],"Every week (Sundays at 4:00am)":[""],"Failed to change the owner":[""],"Failed to remove the pipeline schedule":[""],"Files":[""],"Find by path":[""],"Find file":[""],"FirstPushedBy|First":[""],"FirstPushedBy|pushed by":[""],"Fork":["",""],"ForkedFromProjectPath|Forked from":[""],"From issue creation until deploy to production":[""],"From merge request merge until deploy to production":[""],"Go to your fork":[""],"GoToYourFork|Fork":[""],"Home":[""],"Housekeeping successfully started":[""],"Import repository":[""],"Interval Pattern":[""],"Introducing Cycle Analytics":[""],"LFSStatus|Disabled":[""],"LFSStatus|Enabled":[""],"Last %d day":["",""],"Last Pipeline":[""],"Last Update":[""],"Last commit":[""],"Learn more in the":[""],"Learn more in the|pipeline schedules documentation":[""],"Leave group":[""],"Leave project":[""],"Limited to showing %d event at most":["",""],"Median":[""],"MissingSSHKeyWarningLink|add an SSH key":[""],"New Issue":["",""],"New Pipeline Schedule":[""],"New branch":[""],"New directory":[""],"New file":[""],"New issue":[""],"New merge request":[""],"New schedule":[""],"New snippet":[""],"New tag":[""],"No repository":[""],"No schedules":[""],"Not available":[""],"Not enough data":[""],"Notification events":[""],"NotificationEvent|Close issue":[""],"NotificationEvent|Close merge request":[""],"NotificationEvent|Failed pipeline":[""],"NotificationEvent|Merge merge request":[""],"NotificationEvent|New issue":[""],"NotificationEvent|New merge request":[""],"NotificationEvent|New note":[""],"NotificationEvent|Reassign issue":[""],"NotificationEvent|Reassign merge request":[""],"NotificationEvent|Reopen issue":[""],"NotificationEvent|Successful pipeline":[""],"NotificationLevel|Custom":[""],"NotificationLevel|Disabled":[""],"NotificationLevel|Global":[""],"NotificationLevel|On mention":[""],"NotificationLevel|Participate":[""],"NotificationLevel|Watch":[""],"OfSearchInADropdown|Filter":[""],"OpenedNDaysAgo|Opened":[""],"Options":[""],"Owner":[""],"Pipeline":[""],"Pipeline Health":[""],"Pipeline Schedule":[""],"Pipeline Schedules":[""],"PipelineSchedules|Activated":[""],"PipelineSchedules|Active":[""],"PipelineSchedules|All":[""],"PipelineSchedules|Inactive":[""],"PipelineSchedules|Next Run":[""],"PipelineSchedules|None":[""],"PipelineSchedules|Provide a short description for this pipeline":[""],"PipelineSchedules|Take ownership":[""],"PipelineSchedules|Target":[""],"PipelineSheduleIntervalPattern|Custom":[""],"Pipeline|with stage":[""],"Pipeline|with stages":[""],"Project '%{project_name}' queued for deletion.":[""],"Project '%{project_name}' was successfully created.":[""],"Project '%{project_name}' was successfully updated.":[""],"Project '%{project_name}' will be deleted.":[""],"Project access must be granted explicitly to each user.":[""],"Project export could not be deleted.":[""],"Project export has been deleted.":[""],"Project export link has expired. Please generate a new export from your project settings.":[""],"Project export started. A download link will be sent by email.":[""],"Project home":[""],"ProjectFeature|Disabled":[""],"ProjectFeature|Everyone with access":[""],"ProjectFeature|Only team members":[""],"ProjectFileTree|Name":[""],"ProjectLastActivity|Never":[""],"ProjectLifecycle|Stage":[""],"ProjectNetworkGraph|Graph":[""],"Read more":[""],"Readme":[""],"RefSwitcher|Branches":[""],"RefSwitcher|Tags":[""],"Related Commits":[""],"Related Deployed Jobs":[""],"Related Issues":[""],"Related Jobs":[""],"Related Merge Requests":[""],"Related Merged Requests":[""],"Remind later":[""],"Remove project":[""],"Request Access":[""],"Revert this commit":[""],"Revert this merge request":[""],"Save pipeline schedule":[""],"Schedule a new pipeline":[""],"Scheduling Pipelines":[""],"Search branches and tags":[""],"Select Archive Format":[""],"Select a timezone":[""],"Select target branch":[""],"Set a password on your account to pull or push via %{protocol}":[""],"Set up CI":[""],"Set up Koding":[""],"Set up auto deploy":[""],"SetPasswordToCloneLink|set a password":[""],"Showing %d event":["",""],"Source code":[""],"StarProject|Star":[""],"Start a %{new_merge_request} with these changes":[""],"Start a <strong>new merge request</strong> with these changes":[""],"Switch branch/tag":[""],"Tag":["",""],"Tags":[""],"Target Branch":[""],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":[""],"The collection of events added to the data gathered for that stage.":[""],"The fork relationship has been removed.":[""],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":[""],"The phase of the development lifecycle.":[""],"The pipelines schedule runs pipelines in the future, repeatedly, for specific branches or tags. Those scheduled pipelines will inherit limited project access based on their associated user.":[""],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":[""],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":[""],"The project can be accessed by any logged in user.":[""],"The project can be accessed without any authentication.":[""],"The repository for this project does not exist.":[""],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":[""],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":[""],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":[""],"The time taken by each data entry gathered by that stage.":[""],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":[""],"This means you can not push code until you create an empty repository or import existing one.":[""],"Time before an issue gets scheduled":[""],"Time before an issue starts implementation":[""],"Time between merge request creation and merge/close":[""],"Time until first merge request":[""],"Timeago|%s days ago":[""],"Timeago|%s days remaining":[""],"Timeago|%s hours remaining":[""],"Timeago|%s minutes ago":[""],"Timeago|%s minutes remaining":[""],"Timeago|%s months ago":[""],"Timeago|%s months remaining":[""],"Timeago|%s seconds remaining":[""],"Timeago|%s weeks ago":[""],"Timeago|%s weeks remaining":[""],"Timeago|%s years ago":[""],"Timeago|%s years remaining":[""],"Timeago|1 day remaining":[""],"Timeago|1 hour remaining":[""],"Timeago|1 minute remaining":[""],"Timeago|1 month remaining":[""],"Timeago|1 week remaining":[""],"Timeago|1 year remaining":[""],"Timeago|Past due":[""],"Timeago|a day ago":[""],"Timeago|a month ago":[""],"Timeago|a week ago":[""],"Timeago|a while":[""],"Timeago|a year ago":[""],"Timeago|about %s hours ago":[""],"Timeago|about a minute ago":[""],"Timeago|about an hour ago":[""],"Timeago|in %s days":[""],"Timeago|in %s hours":[""],"Timeago|in %s minutes":[""],"Timeago|in %s months":[""],"Timeago|in %s seconds":[""],"Timeago|in %s weeks":[""],"Timeago|in %s years":[""],"Timeago|in 1 day":[""],"Timeago|in 1 hour":[""],"Timeago|in 1 minute":[""],"Timeago|in 1 month":[""],"Timeago|in 1 week":[""],"Timeago|in 1 year":[""],"Timeago|less than a minute ago":[""],"Time|hr":["",""],"Time|min":["",""],"Time|s":[""],"Total Time":[""],"Total test time for all commits/merges":[""],"Unstar":[""],"Upload New File":[""],"Upload file":[""],"Use your global notification setting":[""],"VisibilityLevel|Internal":[""],"VisibilityLevel|Private":[""],"VisibilityLevel|Public":[""],"Want to see the data? Please ask an administrator for access.":[""],"We don't have enough data to show this stage.":[""],"Withdraw Access Request":[""],"You are going to remove %{project_name_with_namespace}.\\nRemoved project CANNOT be restored!\\nAre you ABSOLUTELY sure?":[""],"You are going to remove the fork relationship to source project %{forked_from_project}. Are you ABSOLUTELY sure?":[""],"You are going to transfer %{project_name_with_namespace} to another owner. Are you ABSOLUTELY sure?":[""],"You can only add files when you are on a branch":[""],"You must sign in to star a project":[""],"You need permission.":[""],"You will not get any notifications via email":[""],"You will only receive notifications for the events you choose":[""],"You will only receive notifications for threads you have participated in":[""],"You will receive notifications for any activity":[""],"You will receive notifications only for comments in which you were @mentioned":[""],"You won't be able to pull or push project code via %{protocol} until you %{set_password_link} on your account":[""],"You won't be able to pull or push project code via SSH until you %{add_ssh_key_link} to your profile":[""],"Your name":[""],"day":["",""],"new merge request":[""],"notification emails":[""],"parent":["",""]}}};
\ No newline at end of file diff --git a/app/assets/javascripts/locale/eo/app.js b/app/assets/javascripts/locale/eo/app.js new file mode 100644 index 00000000000..55f000e9b88 --- /dev/null +++ b/app/assets/javascripts/locale/eo/app.js @@ -0,0 +1 @@ +var locales = locales || {}; locales['eo'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","POT-Creation-Date":"2017-06-15 21:59-0500","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","PO-Revision-Date":"2017-06-20 06:24-0400","Last-Translator":"Lyubomir Vasilev <lyubomirv@abv.bg>","Language-Team":"Esperanto (https://translate.zanata.org/project/view/GitLab)","Language":"eo","X-Generator":"Zanata 3.9.6","Plural-Forms":"nplurals=2; plural=(n != 1)","lang":"eo","domain":"app","plural_forms":"nplurals=2; plural=(n != 1)"},"%{commit_author_link} committed %{commit_timeago}":["%{commit_author_link} enmetis %{commit_timeago}"],"About auto deploy":["Pri la aŭtomata disponigado"],"Active":["Aktiva"],"Activity":["Aktiveco"],"Add Changelog":["Aldoni liston de ŝanĝoj"],"Add Contribution guide":["Aldoni gvidliniojn por kontribuado"],"Add License":["Aldoni rajtigilon"],"Add an SSH key to your profile to pull or push via SSH.":["Aldonu SSH-ŝlosilon al via profilo por ebligi al vi eltiri kaj alpuŝi per SSH."],"Add new directory":["Aldoni novan dosierujon"],"Archived project! Repository is read-only":["Arkivita projekto! La deponejo permesas nur legadon"],"Are you sure you want to delete this pipeline schedule?":["Ĉu vi certe volas forigi ĉi tiun ĉenstablan planon?"],"Attach a file by drag & drop or %{upload_link}":["Alkroĉu dosieron per ŝovmetado aŭ %{upload_link}"],"Branch":["Branĉo","Branĉoj"],"Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, choose a GitLab CI Yaml template and commit your changes. %{link_to_autodeploy_doc}":["La branĉo <strong>%{branch_name}</strong> estis kreita. Por agordi aŭtomatan disponigadon, bonvolu elekti Yaml-ŝablonon por GitLab CI kaj enmeti viajn ŝanĝojn. %{link_to_autodeploy_doc}"],"Branches":["Branĉoj"],"Browse files":["Elekti dosierojn"],"ByAuthor|by":["de"],"CI configuration":["Agordoj de seninterrompa integrado"],"Cancel":["Nuligi"],"ChangeTypeActionLabel|Pick into branch":["Elekti en branĉon"],"ChangeTypeActionLabel|Revert in branch":["Malfari en branĉo"],"ChangeTypeAction|Cherry-pick":["Precize elekti"],"ChangeTypeAction|Revert":["Malfari"],"Changelog":["Listo de ŝanĝoj"],"Charts":["Diagramoj"],"Cherry-pick this commit":["Precize elekti ĉi tiun kunmetadon"],"Cherry-pick this merge request":["Precize elekti ĉi tiun peton pri kunfando"],"CiStatusLabel|canceled":["nuligita"],"CiStatusLabel|created":["kreita"],"CiStatusLabel|failed":["malsukcesa"],"CiStatusLabel|manual action":["mana ago"],"CiStatusLabel|passed":["sukcesa"],"CiStatusLabel|passed with warnings":["sukcesa, kun avertoj"],"CiStatusLabel|pending":["okazonta"],"CiStatusLabel|skipped":["transsaltita"],"CiStatusLabel|waiting for manual action":["atendanta manan agon"],"CiStatusText|blocked":["blokita"],"CiStatusText|canceled":["nuligita"],"CiStatusText|created":["kreita"],"CiStatusText|failed":["malsukcesa"],"CiStatusText|manual":["mana"],"CiStatusText|passed":["sukcesa"],"CiStatusText|pending":["okazonta"],"CiStatusText|skipped":["transsaltita"],"CiStatus|running":["plenumiĝanta"],"Commit":["Enmetado","Enmetadoj"],"Commit message":["Mesaĝo pri la enmetado"],"CommitBoxTitle|Commit":["Enmeti"],"CommitMessage|Add %{file_name}":["Aldoni „%{file_name}“"],"Commits":["Enmetadoj"],"Commits|History":["Historio"],"Committed by":["Enmetita de"],"Compare":["Kompari"],"Contribution guide":["Gvidlinioj por kontribuado"],"Contributors":["Kontribuantoj"],"Copy URL to clipboard":["Kopii la adreson en la kopibufron"],"Copy commit SHA to clipboard":["Kopii la identigilon de la enmetado"],"Create New Directory":["Krei novan dosierujon"],"Create directory":["Krei dosierujon"],"Create empty bare repository":["Krei malplenan deponejon"],"Create merge request":["Krei peton pri kunfando"],"Create new...":["Krei novan…"],"CreateNewFork|Fork":["Disbranĉigi"],"CreateTag|Tag":["Etikedo"],"Cron Timezone":["Horzono por Cron"],"Cron syntax":["La sintakso de Cron"],"Custom notification events":["Propraj sciigaj eventoj"],"Custom notification levels are the same as participating levels. With custom notification levels you will also receive notifications for select events. To find out more, check out %{notification_link}.":["La propraj sciigaj niveloj estas la samaj kiel la niveloj de partoprenado. Uzante la proprajn sciigajn nivelojn, vi ricevos ankaŭ sciigojn por elektitaj de vi eventoj. Por lerni pli, bonvolu vidi %{notification_link}."],"Cycle Analytics":["Cikla analizo"],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":["La cikla analizo esploras kiom da tempo necesas por disvolvi ideon ĝis ĝi fariĝos realaĵo."],"CycleAnalyticsStage|Code":["Programado"],"CycleAnalyticsStage|Issue":["Problemo"],"CycleAnalyticsStage|Plan":["Plano"],"CycleAnalyticsStage|Production":["Eldonado"],"CycleAnalyticsStage|Review":["Kontrolo"],"CycleAnalyticsStage|Staging":["Preparo por eldono"],"CycleAnalyticsStage|Test":["Testado"],"Define a custom pattern with cron syntax":["Difini propran ŝablonon, uzante la sintakson de Cron"],"Delete":["Forigi"],"Deploy":["Disponigado","Disponigadoj"],"Description":["Priskribo"],"Directory name":["Nomo de dosierujo"],"Don't show again":["Ne montru denove"],"Download":["Elŝuti"],"Download tar":["Elŝuti en formato „tar“"],"Download tar.bz2":["Elŝuti en formato „tar.bz2“"],"Download tar.gz":["Elŝuti en formato „tar.gz“"],"Download zip":["Elŝuti en formato „zip“"],"DownloadArtifacts|Download":["Elŝuti"],"DownloadCommit|Email Patches":["Sendi flikaĵojn per retpoŝto"],"DownloadCommit|Plain Diff":["Normala dosiero kun diferencoj"],"DownloadSource|Download":["Elŝuti"],"Edit":["Redakti"],"Edit Pipeline Schedule %{id}":["Redakti ĉenstablan planon %{id}"],"Every day (at 4:00am)":["Ĉiutage (je 4:00)"],"Every month (on the 1st at 4:00am)":["Ĉiumonate (en la 1a de la monato, je 4:00)"],"Every week (Sundays at 4:00am)":["Ĉiusemajne (en dimanĉo, je 4:00)"],"Failed to change the owner":["Ne eblas ŝanĝi la posedanton"],"Failed to remove the pipeline schedule":["Ne eblas forigi la ĉenstablan planon"],"Files":["Dosieroj"],"Find by path":["Trovi per dosierindiko"],"Find file":["Trovi dosieron"],"FirstPushedBy|First":["Unue"],"FirstPushedBy|pushed by":["alpuŝita de"],"Fork":["Disbranĉigo","Disbranĉigoj"],"ForkedFromProjectPath|Forked from":["Disbranĉigita el"],"From issue creation until deploy to production":["De la kreado de la problemo ĝis la disponigado en la publika versio"],"From merge request merge until deploy to production":["De la kunfandado de la peto pri kunfando ĝis la disponigado en la publika versio"],"Go to your fork":["Al via disbranĉigo"],"GoToYourFork|Fork":["Disbranĉigo"],"Home":["Hejmo"],"Housekeeping successfully started":["La refreŝigo komenciĝis sukcese"],"Import repository":["Enporti deponejon"],"Interval Pattern":["Intervala ŝablono"],"Introducing Cycle Analytics":["Ni prezentas al vi la ciklan analizon"],"LFSStatus|Disabled":["Malŝaltita"],"LFSStatus|Enabled":["Ŝaltita"],"Last %d day":["La lasta %d tago","La lastaj %d tagoj"],"Last Pipeline":["Lasta ĉenstablo"],"Last Update":["Lasta ĝisdatigo"],"Last commit":["Lasta enmetado"],"Learn more in the":["Lernu pli en la"],"Learn more in the|pipeline schedules documentation":["dokumentado pri ĉenstablaj planoj"],"Leave group":["Forlasi la grupon"],"Leave project":["Forlasi la projekton"],"Limited to showing %d event at most":["Limigita al montrado de ne pli ol %d evento","Limigita al montrado de ne pli ol %d eventoj"],"Median":["Mediano"],"MissingSSHKeyWarningLink|add an SSH key":["aldonos SSH-ŝlosilon"],"New Issue":["Nova problemo","Novaj problemoj"],"New Pipeline Schedule":["Nova ĉenstabla plano"],"New branch":["Nova branĉo"],"New directory":["Nova dosierujo"],"New file":["Nova dosiero"],"New issue":["Nova problemo"],"New merge request":["Nova peto pri kunfando"],"New schedule":["Nova plano"],"New snippet":["Nova kodaĵo"],"New tag":["Nova etikedo"],"No repository":["Ne estas deponejo"],"No schedules":["Ne estas planoj"],"Not available":["Ne disponebla"],"Not enough data":["Ne estas sufiĉe da datenoj"],"Notification events":["Sciigaj eventoj"],"NotificationEvent|Close issue":["Fermi problemon"],"NotificationEvent|Close merge request":["Fermi peton pri kunfando"],"NotificationEvent|Failed pipeline":["Malsukcesa ĉenstablo"],"NotificationEvent|Merge merge request":["Apliki peton pri kunfando"],"NotificationEvent|New issue":["Nova problemo"],"NotificationEvent|New merge request":["Nova peto pri kunfando"],"NotificationEvent|New note":["Nova noto"],"NotificationEvent|Reassign issue":["Reatribui problemon"],"NotificationEvent|Reassign merge request":["Reatribui peton pri kunfando"],"NotificationEvent|Reopen issue":["Remalfermi problemon"],"NotificationEvent|Successful pipeline":["Sukcesa ĉenstablo"],"NotificationLevel|Custom":["Propraj"],"NotificationLevel|Disabled":["Malŝaltitaj"],"NotificationLevel|Global":["Ĝeneralaj"],"NotificationLevel|On mention":["Ĉe mencio"],"NotificationLevel|Participate":["Partoprenado"],"NotificationLevel|Watch":["Rigardado"],"OfSearchInADropdown|Filter":["Filtrilo"],"OpenedNDaysAgo|Opened":["Malfermita"],"Options":["Opcioj"],"Owner":["Posedanto"],"Pipeline":["Ĉenstablo"],"Pipeline Health":["Stato"],"Pipeline Schedule":["Ĉenstabla plano"],"Pipeline Schedules":["Ĉenstablaj planoj"],"PipelineSchedules|Activated":["Ŝaltita"],"PipelineSchedules|Active":["Ŝaltitaj"],"PipelineSchedules|All":["Ĉiuj"],"PipelineSchedules|Inactive":["Malŝaltitaj"],"PipelineSchedules|Next Run":["Sekvanta plenumo"],"PipelineSchedules|None":["Nenio"],"PipelineSchedules|Provide a short description for this pipeline":["Entajpu mallongan priskribon pri ĉi tiu ĉenstablo"],"PipelineSchedules|Take ownership":["Akiri posedon"],"PipelineSchedules|Target":["Celo"],"PipelineSheduleIntervalPattern|Custom":["Propra"],"Pipeline|with stage":["kun etapo"],"Pipeline|with stages":["kun etapoj"],"Project '%{project_name}' queued for deletion.":["La projekto „%{project_name}“ estis alvicigita por forigado."],"Project '%{project_name}' was successfully created.":["La projekto „%{project_name}“ estis sukcese kreita."],"Project '%{project_name}' was successfully updated.":["La projekto „%{project_name}“ estis sukcese ĝisdatigita."],"Project '%{project_name}' will be deleted.":["La projekto „%{project_name}“ estos forigita."],"Project access must be granted explicitly to each user.":["Ĉiu uzanto devas akiri propran atingon al la projekto."],"Project export could not be deleted.":["Ne eblas forigi la projektan elporton."],"Project export has been deleted.":["La projekta elporto estis forigita."],"Project export link has expired. Please generate a new export from your project settings.":["La ligilo por la projekta elporto eksvalidiĝis. Bonvolu krei novan elporton en la agordoj de la projekto."],"Project export started. A download link will be sent by email.":["La elporto de la projekto komenciĝis. Vi ricevos ligilon per retpoŝto por elŝuti la datenoj."],"Project home":["Hejmo de la projekto"],"ProjectFeature|Disabled":["Malŝaltita"],"ProjectFeature|Everyone with access":["Ĉiu, kiu havas atingon"],"ProjectFeature|Only team members":["Nur skipanoj"],"ProjectFileTree|Name":["Nomo"],"ProjectLastActivity|Never":["Neniam"],"ProjectLifecycle|Stage":["Etapo"],"ProjectNetworkGraph|Graph":["Grafeo"],"Read more":["Legu pli"],"Readme":["LeguMin"],"RefSwitcher|Branches":["Branĉoj"],"RefSwitcher|Tags":["Etikedoj"],"Related Commits":["Rilataj enmetadoj"],"Related Deployed Jobs":["Rilataj disponigitaj taskoj"],"Related Issues":["Rilataj problemoj"],"Related Jobs":["Rilataj taskoj"],"Related Merge Requests":["Rilataj petoj pri kunfando"],"Related Merged Requests":["Rilataj aplikitaj petoj pri kunfando"],"Remind later":["Rememorigu denove"],"Remove project":["Forigi la projekton"],"Request Access":["Peti atingeblon"],"Revert this commit":["Malfari ĉi tiun enmetadon"],"Revert this merge request":["Malfari ĉi tiun peton pri kunfando"],"Save pipeline schedule":["Konservi ĉenstablan planon"],"Schedule a new pipeline":["Plani novan ĉenstablon"],"Scheduling Pipelines":["Planado de la ĉenstabloj"],"Search branches and tags":["Serĉu branĉon aŭ etikedon"],"Select Archive Format":["Elektu formaton de arkivo"],"Select a timezone":["Elektu horzonon"],"Select target branch":["Elektu celan branĉon"],"Set a password on your account to pull or push via %{protocol}":["Kreu pasvorton por via konto por ebligi al vi eltiri kaj alpuŝi per %{protocol}"],"Set up CI":["Agordi SI"],"Set up Koding":["Agordi „Koding“"],"Set up auto deploy":["Agordi aŭtomatan disponigadon"],"SetPasswordToCloneLink|set a password":["kreos pasvorton"],"Showing %d event":["Estas montrata %d evento","Estas montrataj %d eventoj"],"Source code":["Kodo"],"StarProject|Star":["Steligi"],"Start a %{new_merge_request} with these changes":["Kreu %{new_merge_request} kun ĉi tiuj ŝanĝoj"],"Switch branch/tag":["Iri al branĉo/etikedo"],"Tag":["Etikedo","Etikedoj"],"Tags":["Etikedoj"],"Target Branch":["Cela branĉo"],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":["La etapo de programado montras la tempon de la unua enmetado ĝis la kreado de la peto pri kunfando. La datenoj aldoniĝos aŭtomate ĉi tie post kiam vi kreas la unuan peton pri kunfando."],"The collection of events added to the data gathered for that stage.":["La aro da eventoj, kiuj estas aldonitaj al la datenoj kolektitaj por la etapo."],"The fork relationship has been removed.":["La rilato de disbranĉigo estis forigita."],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":["La etapo de la problemo montras kiom la tempo pasas de la kreado de problemo ĝis la atribuado de la problemo al cela etapo de la projekto, aŭ al listo sur la problemtabulo. Komencu krei problemojn por vidi la datenojn por ĉi tiu etapo."],"The phase of the development lifecycle.":["La etapo de la disvolva ciklo."],"The pipelines schedule runs pipelines in the future, repeatedly, for specific branches or tags. Those scheduled pipelines will inherit limited project access based on their associated user.":["La ĉenstabla plano plenumas ĉenstablojn en la estonteco, ripete, por difinitaj branĉoj aŭ etikedoj. Tiuj planitaj ĉenstabloj heredos la limigitan atingon al la projekto de la rilata uzanto."],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":["La etapo de la plano montras la tempon de la antaŭa ŝtupo ĝis la alpuŝado de via unua enmetado. Ĉi tiu tempo aldoniĝos aŭtomate post kiam vi alpuŝas la unuan enmetadon."],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":["La etapo de eldonado montras la tutan tempon de la kreado de problemo ĝis la disponigado en la publika versio. La datenoj aldoniĝos aŭtomate post kiam vi kompletigos plenan ciklon de ideo ĝis realaĵo."],"The project can be accessed by any logged in user.":["Ĉiu ensalutita uzanto havas atingon al la projekto"],"The project can be accessed without any authentication.":["Ĉiu povas havi atingon al la projekto, sen ensaluti"],"The repository for this project does not exist.":["La deponejo por ĉi tiu projekto ne ekzistas."],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":["La etapo de la kontrolo montras la tempon de la kreado de la peto pri kunfando ĝis ĝia aplikado. La datenoj aldoniĝos aŭtomate post kiam vi aplikos la unuan peton pri kunfando."],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":["La etapo de preparo por eldono montras la tempon inter la aplikado de la peto pri kunfando kaj la disponigado de la kodo en la publika versio. La datenoj aldoniĝos aŭtomate post kiam vi faros la unuan disponigadon en la publika versio."],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":["La etapo de testado montras kiom da tempo necesas al „GitLab CI“ por plenumi ĉiujn ĉenstablojn por la rilata peto pri kunfando. La datenoj aldoniĝos aŭtomate post kiam via unua ĉenstablo finiĝos."],"The time taken by each data entry gathered by that stage.":["La tempo, kiu estas necesa por ĉiu dateno kolektita de la etapo."],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":["La valoro, kiu troviĝas en la mezo de aro da rigardataj valoroj. Ekzemple: inter 3, 5 kaj 9, la mediano estas 5. Inter 3, 5, 7 kaj 8, la mediano estas (5+7)/2 = 6."],"This means you can not push code until you create an empty repository or import existing one.":["Ĉi tiu signifas, ke vi ne povos alpuŝi kodon, antaŭ ol vi kreos malplenan deponejon aŭ enportos jam ekzistantan."],"Time before an issue gets scheduled":["Tempo antaŭ problemo estas planita por ellabori"],"Time before an issue starts implementation":["Tempo antaŭ la komenco de laboro super problemo"],"Time between merge request creation and merge/close":["Tempo inter la kreado de poeto pri kunfando kaj ĝia aplikado/fermado"],"Time until first merge request":["Tempo ĝis la unua peto pri kunfando"],"Timeago|%s days ago":["antaŭ %s tagoj"],"Timeago|%s days remaining":["restas %s tagoj"],"Timeago|%s hours remaining":["restas %s horoj"],"Timeago|%s minutes ago":["antaŭ %s minutoj"],"Timeago|%s minutes remaining":["restas %s minutoj"],"Timeago|%s months ago":["antaŭ %s monatoj"],"Timeago|%s months remaining":["restas %s monatoj"],"Timeago|%s seconds remaining":["restas %s sekundoj"],"Timeago|%s weeks ago":["antaŭ %s semajnoj"],"Timeago|%s weeks remaining":["restas %s semajnoj"],"Timeago|%s years ago":["antaŭ %s jaroj"],"Timeago|%s years remaining":["restas %s jaroj"],"Timeago|1 day remaining":["restas 1 tago"],"Timeago|1 hour remaining":["restas 1 horo"],"Timeago|1 minute remaining":["restas 1 minuto"],"Timeago|1 month remaining":["restas 1 monato"],"Timeago|1 week remaining":["restas 1 semajno"],"Timeago|1 year remaining":["restas 1 jaro"],"Timeago|Past due":["Malfruiĝis"],"Timeago|a day ago":["antaŭ unu tago"],"Timeago|a month ago":["antaŭ unu monato"],"Timeago|a week ago":["antaŭ unu semajno"],"Timeago|a while":["antaŭ iom da tempo"],"Timeago|a year ago":["antaŭ unu jaro"],"Timeago|about %s hours ago":["antaŭ ĉirkaŭ %s horoj"],"Timeago|about a minute ago":["antaŭ ĉirkaŭ unu minuto"],"Timeago|about an hour ago":["antaŭ ĉirkaŭ unu horo"],"Timeago|in %s days":["post %s tagoj"],"Timeago|in %s hours":["post %s horoj"],"Timeago|in %s minutes":["post %s minutoj"],"Timeago|in %s months":["post %s monatoj"],"Timeago|in %s seconds":["post %s sekundoj"],"Timeago|in %s weeks":["post %s semajnoj"],"Timeago|in %s years":["post %s jaroj"],"Timeago|in 1 day":["post 1 tago"],"Timeago|in 1 hour":["post 1 horo"],"Timeago|in 1 minute":["post 1 minuto"],"Timeago|in 1 month":["post 1 monato"],"Timeago|in 1 week":["post 1 semajno"],"Timeago|in 1 year":["post 1 jaro"],"Timeago|less than a minute ago":["antaŭ malpli ol minuto"],"Time|hr":["h","h"],"Time|min":["min","min"],"Time|s":["s"],"Total Time":["Totala tempo"],"Total test time for all commits/merges":["Totala tempo por la testado de ĉiuj enmetadoj/kunfandoj"],"Unstar":["Malsteligi"],"Upload New File":["Alŝuti novan dosieron"],"Upload file":["Alŝuti dosieron"],"Use your global notification setting":["Uzi vian ĝeneralan agordon pri la sciigoj"],"VisibilityLevel|Internal":["Interna"],"VisibilityLevel|Private":["Privata"],"VisibilityLevel|Public":["Publika"],"Want to see the data? Please ask an administrator for access.":["Ĉu vi volas vidi la datenojn? Bonvolu peti atingeblon de administranto."],"We don't have enough data to show this stage.":["Ne estas sufiĉe da datenoj por montri ĉi tiun etapon."],"Withdraw Access Request":["Nuligi la peton pri atingeblo"],"You are going to remove %{project_name_with_namespace}.\\nRemoved project CANNOT be restored!\\nAre you ABSOLUTELY sure?":["Vi forigos „%{project_name_with_namespace}“.\\nOni NE POVAS malfari la forigon de projekto!\\nĈu vi estas ABSOLUTE certa?"],"You are going to remove the fork relationship to source project %{forked_from_project}. Are you ABSOLUTELY sure?":["Vi forigos la rilaton de la disbranĉigo al la originala projekto, „%{forked_from_project}“. Ĉu vi estas ABSOLUTE certa?"],"You are going to transfer %{project_name_with_namespace} to another owner. Are you ABSOLUTELY sure?":["Vi transigos „%{project_name_with_namespace}“ al alia posedanto. Ĉu vi estas ABSOLUTE certa?"],"You can only add files when you are on a branch":["Oni povas aldoni dosierojn nur kiam oni estas en branĉo"],"You have reached your project limit":["Vi ne povas krei pliajn projektojn"],"You must sign in to star a project":["Oni devas ensaluti por steligi projekton"],"You need permission.":["VI bezonas permeson."],"You will not get any notifications via email":["VI ne ricevos sciigojn per retpoŝto"],"You will only receive notifications for the events you choose":["Vi ricevos sciigojn nur por la eventoj elektitaj de vi"],"You will only receive notifications for threads you have participated in":["Vi ricevos sciigojn nur por la fadenoj, en kiuj vi partoprenis"],"You will receive notifications for any activity":["Vi ricevos sciigojn por ĉiu ago"],"You will receive notifications only for comments in which you were @mentioned":["Vi ricevos sciigojn nur por komentoj, en kiuj vi estas @menciita"],"You won't be able to pull or push project code via %{protocol} until you %{set_password_link} on your account":["Vi ne povos eltiri aŭ alpuŝi kodon per %{protocol} antaŭ ol vi %{set_password_link} por via konto"],"You won't be able to pull or push project code via SSH until you %{add_ssh_key_link} to your profile":["Vi ne povos eltiri aŭ alpuŝi kodon per SSH antaŭ ol vi %{add_ssh_key_link} al via profilo"],"Your name":["Via nomo"],"day":["tago","tagoj"],"new merge request":["novan peton pri kunfando"],"notification emails":["sciigoj per retpoŝto"],"parent":["patro","patroj"]}}};
\ No newline at end of file diff --git a/app/assets/javascripts/locale/es/app.js b/app/assets/javascripts/locale/es/app.js deleted file mode 100644 index f198809cc20..00000000000 --- a/app/assets/javascripts/locale/es/app.js +++ /dev/null @@ -1 +0,0 @@ -var locales = locales || {}; locales['es'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-06-15 21:59-0500","Language-Team":"Spanish","Language":"es","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Plural-Forms":"nplurals=2; plural=n != 1;","Last-Translator":"Bob Van Landuyt <bob@gitlab.com>","X-Generator":"Poedit 2.0.2","lang":"es","domain":"app","plural_forms":"nplurals=2; plural=n != 1;"},"%{commit_author_link} committed %{commit_timeago}":["%{commit_author_link} cambió %{commit_timeago}"],"About auto deploy":["Acerca del auto despliegue"],"Active":["Activo"],"Activity":["Actividad"],"Add Changelog":["Agregar Changelog"],"Add Contribution guide":["Agregar guía de contribución"],"Add License":["Agregar Licencia"],"Add an SSH key to your profile to pull or push via SSH.":["Agregar una clave SSH a tu perfil para actualizar o enviar a través de SSH."],"Add new directory":["Agregar nuevo directorio"],"Archived project! Repository is read-only":["¡Proyecto archivado! El repositorio es de solo lectura"],"Are you sure you want to delete this pipeline schedule?":["¿Estás seguro que deseas eliminar esta programación del pipeline?"],"Attach a file by drag & drop or %{upload_link}":["Adjunte un archivo arrastrando & soltando o %{upload_link}"],"Branch":["Rama","Ramas"],"Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, choose a GitLab CI Yaml template and commit your changes. %{link_to_autodeploy_doc}":["La rama <strong>%{branch_name}</strong> fue creada. Para configurar el auto despliegue, escoge una plantilla Yaml para GitLab CI y envía tus cambios. %{link_to_autodeploy_doc}"],"Branches":["Ramas"],"Browse files":["Examinar los archivos"],"ByAuthor|by":["por"],"CI configuration":["Configuración de CI"],"Cancel":["Cancelar"],"ChangeTypeActionLabel|Pick into branch":["Escoger en la rama"],"ChangeTypeActionLabel|Revert in branch":["Revertir en la rama"],"ChangeTypeAction|Cherry-pick":["Cherry-pick"],"ChangeTypeAction|Revert":["Revertir"],"Changelog":["Changelog"],"Charts":["Gráficos"],"Cherry-pick this commit":["Escoger este cambio"],"Cherry-pick this merge request":["Escoger esta solicitud de fusión"],"CiStatusLabel|canceled":["cancelado"],"CiStatusLabel|created":["creado"],"CiStatusLabel|failed":["fallido"],"CiStatusLabel|manual action":["acción manual"],"CiStatusLabel|passed":["pasó"],"CiStatusLabel|passed with warnings":["pasó con advertencias"],"CiStatusLabel|pending":["pendiente"],"CiStatusLabel|skipped":["omitido"],"CiStatusLabel|waiting for manual action":["esperando acción manual"],"CiStatusText|blocked":["bloqueado"],"CiStatusText|canceled":["cancelado"],"CiStatusText|created":["creado"],"CiStatusText|failed":["fallado"],"CiStatusText|manual":["manual"],"CiStatusText|passed":["pasó"],"CiStatusText|pending":["pendiente"],"CiStatusText|skipped":["omitido"],"CiStatus|running":["en ejecución"],"Commit":["Cambio","Cambios"],"Commit message":["Mensaje del cambio"],"CommitBoxTitle|Commit":["Cambio"],"CommitMessage|Add %{file_name}":["Agregar %{file_name}"],"Commits":["Cambios"],"Commits|History":["Historial"],"Committed by":["Enviado por"],"Compare":["Comparar"],"Contribution guide":["Guía de contribución"],"Contributors":["Contribuidores"],"Copy URL to clipboard":["Copiar URL al portapapeles"],"Copy commit SHA to clipboard":["Copiar SHA del cambio al portapapeles"],"Create New Directory":["Crear Nuevo Directorio"],"Create directory":["Crear directorio"],"Create empty bare repository":["Crear repositorio vacío"],"Create merge request":["Crear solicitud de fusión"],"Create new...":["Crear nuevo..."],"CreateNewFork|Fork":["Bifurcar"],"CreateTag|Tag":["Etiqueta"],"Cron Timezone":["Zona horaria del Cron"],"Cron syntax":["Sintaxis de Cron"],"Custom notification events":["Eventos de notificaciones personalizadas"],"Custom notification levels are the same as participating levels. With custom notification levels you will also receive notifications for select events. To find out more, check out %{notification_link}.":["Los niveles de notificación personalizados son los mismos que los niveles participantes. Con los niveles de notificación personalizados, también recibirá notificaciones para eventos seleccionados. Para obtener más información, consulte %{notification_link}."],"Cycle Analytics":["Cycle Analytics"],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":["Cycle Analytics ofrece una visión general de cuánto tiempo tarda en pasar de idea a producción en su proyecto."],"CycleAnalyticsStage|Code":["Código"],"CycleAnalyticsStage|Issue":["Incidencia"],"CycleAnalyticsStage|Plan":["Planificación"],"CycleAnalyticsStage|Production":["Producción"],"CycleAnalyticsStage|Review":["Revisión"],"CycleAnalyticsStage|Staging":["Puesta en escena"],"CycleAnalyticsStage|Test":["Pruebas"],"Define a custom pattern with cron syntax":["Definir un patrón personalizado con la sintaxis de cron"],"Delete":["Eliminar"],"Deploy":["Despliegue","Despliegues"],"Description":["Descripción"],"Directory name":["Nombre del directorio"],"Don't show again":["No mostrar de nuevo"],"Download":["Descargar"],"Download tar":["Descargar tar"],"Download tar.bz2":["Descargar tar.bz2"],"Download tar.gz":["Descargar tar.gz"],"Download zip":["Descargar zip"],"DownloadArtifacts|Download":["Descargar"],"DownloadCommit|Email Patches":["Parches por correo electrónico"],"DownloadCommit|Plain Diff":["Diferencias en texto plano"],"DownloadSource|Download":["Descargar"],"Edit":["Editar"],"Edit Pipeline Schedule %{id}":["Editar Programación del Pipeline %{id}"],"Every day (at 4:00am)":["Todos los días (a las 4:00 am)"],"Every month (on the 1st at 4:00am)":["Todos los meses (el día 1 a las 4:00 am)"],"Every week (Sundays at 4:00am)":["Todas las semanas (domingos a las 4:00 am)"],"Failed to change the owner":["Error al cambiar el propietario"],"Failed to remove the pipeline schedule":["Error al eliminar la programación del pipeline"],"Files":["Archivos"],"Find by path":["Buscar por ruta"],"Find file":["Buscar archivo"],"FirstPushedBy|First":["Primer"],"FirstPushedBy|pushed by":["enviado por"],"Fork":["Bifurcación","Bifurcaciones"],"ForkedFromProjectPath|Forked from":["Bifurcado de"],"From issue creation until deploy to production":["Desde la creación de la incidencia hasta el despliegue a producción"],"From merge request merge until deploy to production":["Desde la integración de la solicitud de fusión hasta el despliegue a producción"],"Go to your fork":["Ir a tu bifurcación"],"GoToYourFork|Fork":["Bifurcación"],"Home":["Inicio"],"Housekeeping successfully started":["Servicio de limpieza iniciado con éxito"],"Import repository":["Importar repositorio"],"Interval Pattern":["Patrón de intervalo"],"Introducing Cycle Analytics":["Introducción a Cycle Analytics"],"LFSStatus|Disabled":["Deshabilitado"],"LFSStatus|Enabled":["Habilitado"],"Last %d day":["Último %d día","Últimos %d días"],"Last Pipeline":["Último Pipeline"],"Last Update":["Última actualización"],"Last commit":["Último cambio"],"Learn more in the":["Más información en la"],"Learn more in the|pipeline schedules documentation":["documentación sobre la programación de pipelines"],"Leave group":["Abandonar grupo"],"Leave project":["Abandonar proyecto"],"Limited to showing %d event at most":["Limitado a mostrar máximo %d evento","Limitado a mostrar máximo %d eventos"],"Median":["Mediana"],"MissingSSHKeyWarningLink|add an SSH key":["agregar una clave SSH"],"New Issue":["Nueva incidencia","Nuevas incidencias"],"New Pipeline Schedule":["Nueva Programación del Pipeline"],"New branch":["Nueva rama"],"New directory":["Nuevo directorio"],"New file":["Nuevo archivo"],"New issue":["Nueva incidencia"],"New merge request":["Nueva solicitud de fusión"],"New schedule":["Nueva programación"],"New snippet":["Nuevo fragmento de código"],"New tag":["Nueva etiqueta"],"No repository":["No hay repositorio"],"No schedules":["No hay programaciones"],"Not available":["No disponible"],"Not enough data":["No hay suficientes datos"],"Notification events":["Eventos de notificación"],"NotificationEvent|Close issue":["Cerrar incidencia"],"NotificationEvent|Close merge request":["Cerrar solicitud de fusión"],"NotificationEvent|Failed pipeline":["Pipeline fallido"],"NotificationEvent|Merge merge request":["Integrar solicitud de fusión"],"NotificationEvent|New issue":["Nueva incidencia"],"NotificationEvent|New merge request":["Nueva solicitud de fusión"],"NotificationEvent|New note":["Nueva nota"],"NotificationEvent|Reassign issue":["Reasignar incidencia"],"NotificationEvent|Reassign merge request":["Reasignar solicitud de fusión"],"NotificationEvent|Reopen issue":["Reabrir incidencia"],"NotificationEvent|Successful pipeline":["Pipeline exitoso"],"NotificationLevel|Custom":["Personalizado"],"NotificationLevel|Disabled":["Deshabilitado"],"NotificationLevel|Global":["Global"],"NotificationLevel|On mention":["Cuando me mencionan"],"NotificationLevel|Participate":["Participación"],"NotificationLevel|Watch":["Vigilancia"],"OfSearchInADropdown|Filter":["Filtrar"],"OpenedNDaysAgo|Opened":["Abierto"],"Options":["Opciones"],"Owner":["Propietario"],"Pipeline":["Pipeline"],"Pipeline Health":["Estado del Pipeline"],"Pipeline Schedule":["Programación del Pipeline"],"Pipeline Schedules":["Programaciones de los Pipelines"],"PipelineSchedules|Activated":["Activado"],"PipelineSchedules|Active":["Activos"],"PipelineSchedules|All":["Todos"],"PipelineSchedules|Inactive":["Inactivos"],"PipelineSchedules|Next Run":["Próxima Ejecución"],"PipelineSchedules|None":["Ninguno"],"PipelineSchedules|Provide a short description for this pipeline":["Proporcione una breve descripción para este pipeline"],"PipelineSchedules|Take ownership":["Tomar posesión"],"PipelineSchedules|Target":["Destino"],"PipelineSheduleIntervalPattern|Custom":["Personalizado"],"Pipeline|with stage":["con etapa"],"Pipeline|with stages":["con etapas"],"Project '%{project_name}' queued for deletion.":["Proyecto ‘%{project_name}’ en cola para eliminación."],"Project '%{project_name}' was successfully created.":["Proyecto ‘%{project_name}’ fue creado satisfactoriamente."],"Project '%{project_name}' was successfully updated.":["Proyecto ‘%{project_name}’ fue actualizado satisfactoriamente."],"Project '%{project_name}' will be deleted.":["Proyecto ‘%{project_name}’ será eliminado."],"Project access must be granted explicitly to each user.":["El acceso al proyecto debe concederse explícitamente a cada usuario."],"Project export could not be deleted.":["No se pudo eliminar la exportación del proyecto."],"Project export has been deleted.":["La exportación del proyecto ha sido eliminada."],"Project export link has expired. Please generate a new export from your project settings.":["El enlace de exportación del proyecto ha caducado. Por favor, genera una nueva exportación desde la configuración del proyecto."],"Project export started. A download link will be sent by email.":["Se inició la exportación del proyecto. Se enviará un enlace de descarga por correo electrónico."],"Project home":["Inicio del proyecto"],"ProjectFeature|Disabled":["Deshabilitada"],"ProjectFeature|Everyone with access":["Todos con acceso"],"ProjectFeature|Only team members":["Solo miembros del equipo"],"ProjectFileTree|Name":["Nombre"],"ProjectLastActivity|Never":["Nunca"],"ProjectLifecycle|Stage":["Etapa"],"ProjectNetworkGraph|Graph":["Historial gráfico"],"Read more":["Leer más"],"Readme":["Léeme"],"RefSwitcher|Branches":["Ramas"],"RefSwitcher|Tags":["Etiquetas"],"Related Commits":["Cambios Relacionados"],"Related Deployed Jobs":["Trabajos Desplegados Relacionados"],"Related Issues":["Incidencias Relacionadas"],"Related Jobs":["Trabajos Relacionados"],"Related Merge Requests":["Solicitudes de fusión Relacionadas"],"Related Merged Requests":["Solicitudes de fusión Relacionadas"],"Remind later":["Recordar después"],"Remove project":["Eliminar proyecto"],"Request Access":["Solicitar acceso"],"Revert this commit":["Revertir este cambio"],"Revert this merge request":["Revertir esta solicitud de fusión"],"Save pipeline schedule":["Guardar programación del pipeline"],"Schedule a new pipeline":["Programar un nuevo pipeline"],"Scheduling Pipelines":["Programación de Pipelines"],"Search branches and tags":["Buscar ramas y etiquetas"],"Select Archive Format":["Seleccionar formato de archivo"],"Select a timezone":["Selecciona una zona horaria"],"Select target branch":["Selecciona una rama de destino"],"Set a password on your account to pull or push via %{protocol}":["Establezca una contraseña en su cuenta para actualizar o enviar a través de %{protocol}"],"Set up CI":["Configurar CI"],"Set up Koding":["Configurar Koding"],"Set up auto deploy":["Configurar auto despliegue"],"SetPasswordToCloneLink|set a password":["establecer una contraseña"],"Showing %d event":["Mostrando %d evento","Mostrando %d eventos"],"Source code":["Código fuente"],"StarProject|Star":["Destacar"],"Start a %{new_merge_request} with these changes":["Iniciar una %{new_merge_request} con estos cambios"],"Switch branch/tag":["Cambiar rama/etiqueta"],"Tag":["Etiqueta","Etiquetas"],"Tags":["Etiquetas"],"Target Branch":["Rama de destino"],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":["La etapa de desarrollo muestra el tiempo desde el primer cambio hasta la creación de la solicitud de fusión. Los datos serán automáticamente incorporados aquí una vez creada tu primera solicitud de fusión."],"The collection of events added to the data gathered for that stage.":["La colección de eventos agregados a los datos recopilados para esa etapa."],"The fork relationship has been removed.":["La relación con la bifurcación se ha eliminado."],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":["La etapa de incidencia muestra el tiempo que toma desde la creación de un tema hasta asignar el tema a un hito, o añadir el tema a una lista en el panel de temas. Empieza a crear temas para ver los datos de esta etapa."],"The phase of the development lifecycle.":["La etapa del ciclo de vida de desarrollo."],"The pipelines schedule runs pipelines in the future, repeatedly, for specific branches or tags. Those scheduled pipelines will inherit limited project access based on their associated user.":["La programación de pipelines ejecuta pipelines en el futuro, repetidamente, para ramas o etiquetas específicas. Los pipelines programados heredarán acceso limitado al proyecto basado en su usuario asociado."],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":["La etapa de planificación muestra el tiempo desde el paso anterior hasta el envío de tu primera confirmación. Este tiempo se añadirá automáticamente una vez que usted envíe el primer cambio."],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":["La etapa de producción muestra el tiempo total que tarda entre la creación de una incidencia y el despliegue del código a producción. Los datos se añadirán automáticamente una vez haya finalizado por completo el ciclo de idea a producción."],"The project can be accessed by any logged in user.":["El proyecto puede ser accedido por cualquier usuario conectado."],"The project can be accessed without any authentication.":["El proyecto puede accederse sin ninguna autenticación."],"The repository for this project does not exist.":["El repositorio para este proyecto no existe."],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":["La etapa de revisión muestra el tiempo desde la creación de la solicitud de fusión hasta que los cambios se fusionaron. Los datos se añadirán automáticamente después de fusionar su primera solicitud de fusión."],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":["La etapa de puesta en escena muestra el tiempo entre la fusión y el despliegue de código en el entorno de producción. Los datos se añadirán automáticamente una vez que se despliega a producción por primera vez."],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":["La etapa de pruebas muestra el tiempo que GitLab CI toma para ejecutar cada pipeline para la solicitud de fusión relacionada. Los datos se añadirán automáticamente luego de que el primer pipeline termine de ejecutarse."],"The time taken by each data entry gathered by that stage.":["El tiempo utilizado por cada entrada de datos obtenido por esa etapa."],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":["El valor en el punto medio de una serie de valores observados. Por ejemplo, entre 3, 5, 9, la mediana es 5. Entre 3, 5, 7, 8, la mediana es (5 + 7) / 2 = 6."],"This means you can not push code until you create an empty repository or import existing one.":["Esto significa que no puede enviar código hasta que cree un repositorio vacío o importe uno existente."],"Time before an issue gets scheduled":["Tiempo antes de que una incidencia sea programada"],"Time before an issue starts implementation":["Tiempo antes de que empieze la implementación de una incidencia"],"Time between merge request creation and merge/close":["Tiempo entre la creación de la solicitud de fusión y la integración o cierre de ésta"],"Time until first merge request":["Tiempo hasta la primera solicitud de fusión"],"Timeago|%s days ago":["hace %s días"],"Timeago|%s days remaining":["%s días restantes"],"Timeago|%s hours remaining":["%s horas restantes"],"Timeago|%s minutes ago":["hace %s minutos"],"Timeago|%s minutes remaining":["%s minutos restantes"],"Timeago|%s months ago":["hace %s meses"],"Timeago|%s months remaining":["%s meses restantes"],"Timeago|%s seconds remaining":["%s segundos restantes"],"Timeago|%s weeks ago":["hace %s semanas"],"Timeago|%s weeks remaining":["%s semanas restantes"],"Timeago|%s years ago":["hace %s años"],"Timeago|%s years remaining":["%s años restantes"],"Timeago|1 day remaining":["1 día restante"],"Timeago|1 hour remaining":["1 hora restante"],"Timeago|1 minute remaining":["1 minuto restante"],"Timeago|1 month remaining":["1 mes restante"],"Timeago|1 week remaining":["1 semana restante"],"Timeago|1 year remaining":["1 año restante"],"Timeago|Past due":["Atrasado"],"Timeago|a day ago":["hace un día"],"Timeago|a month ago":["hace un mes"],"Timeago|a week ago":["hace una semana"],"Timeago|a while":["hace un momento"],"Timeago|a year ago":["hace un año"],"Timeago|about %s hours ago":["hace alrededor de %s horas"],"Timeago|about a minute ago":["hace alrededor de 1 minuto"],"Timeago|about an hour ago":["hace alrededor de 1 hora"],"Timeago|in %s days":["en %s días"],"Timeago|in %s hours":["en %s horas"],"Timeago|in %s minutes":["en %s minutos"],"Timeago|in %s months":["en %s meses"],"Timeago|in %s seconds":["en %s segundos"],"Timeago|in %s weeks":["en %s semanas"],"Timeago|in %s years":["en %s años"],"Timeago|in 1 day":["en 1 día"],"Timeago|in 1 hour":["en 1 hora"],"Timeago|in 1 minute":["en 1 minuto"],"Timeago|in 1 month":["en 1 mes"],"Timeago|in 1 week":["en 1 semana"],"Timeago|in 1 year":["en 1 año"],"Timeago|less than a minute ago":["hace menos de 1 minuto"],"Time|hr":["hr","hrs"],"Time|min":["min","mins"],"Time|s":["s"],"Total Time":["Tiempo Total"],"Total test time for all commits/merges":["Tiempo total de pruebas para todos los cambios o integraciones"],"Unstar":["No Destacar"],"Upload New File":["Subir nuevo archivo"],"Upload file":["Subir archivo"],"Use your global notification setting":["Utiliza tu configuración de notificación global"],"VisibilityLevel|Internal":["Interno"],"VisibilityLevel|Private":["Privado"],"VisibilityLevel|Public":["Público"],"Want to see the data? Please ask an administrator for access.":["¿Quieres ver los datos? Por favor pide acceso al administrador."],"We don't have enough data to show this stage.":["No hay suficientes datos para mostrar en esta etapa."],"Withdraw Access Request":["Retirar Solicitud de Acceso"],"You are going to remove %{project_name_with_namespace}.\\nRemoved project CANNOT be restored!\\nAre you ABSOLUTELY sure?":["Va a eliminar %{project_name_with_namespace}.\\n¡El proyecto eliminado NO puede ser restaurado!\\n¿Estás TOTALMENTE seguro?"],"You are going to remove the fork relationship to source project %{forked_from_project}. Are you ABSOLUTELY sure?":["Vas a eliminar el enlace de la bifurcación con el proyecto original %{forked_from_project}. ¿Estás TOTALMENTE seguro?"],"You are going to transfer %{project_name_with_namespace} to another owner. Are you ABSOLUTELY sure?":["Vas a transferir %{project_name_with_namespace} a otro propietario. ¿Estás TOTALMENTE seguro?"],"You can only add files when you are on a branch":["Solo puedes agregar archivos cuando estás en una rama"],"You must sign in to star a project":["Debes iniciar sesión para destacar un proyecto"],"You need permission.":["Necesitas permisos."],"You will not get any notifications via email":["No recibirás ninguna notificación por correo electrónico"],"You will only receive notifications for the events you choose":["Solo recibirás notificaciones de los eventos que elijas"],"You will only receive notifications for threads you have participated in":["Solo recibirás notificaciones de los temas en los que has participado"],"You will receive notifications for any activity":["Recibirás notificaciones por cualquier actividad"],"You will receive notifications only for comments in which you were @mentioned":["Recibirás notificaciones solo para los comentarios en los que se te mencionó"],"You won't be able to pull or push project code via %{protocol} until you %{set_password_link} on your account":["No podrás actualizar o enviar código al proyecto a través de %{protocol} hasta que %{set_password_link} en tu cuenta"],"You won't be able to pull or push project code via SSH until you %{add_ssh_key_link} to your profile":["No podrás actualizar o enviar código al proyecto a través de SSH hasta que %{add_ssh_key_link} en su perfil"],"Your name":["Tu nombre"],"day":["día","días"],"new merge request":["nueva solicitud de fusión"],"notification emails":["correos electrónicos de notificación"],"parent":["padre","padres"]}}};
\ No newline at end of file diff --git a/app/assets/javascripts/locale/fr/app.js b/app/assets/javascripts/locale/fr/app.js deleted file mode 100644 index f9904ea61ea..00000000000 --- a/app/assets/javascripts/locale/fr/app.js +++ /dev/null @@ -1 +0,0 @@ -var locales = locales || {}; locales['fr'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","POT-Creation-Date":"2017-06-15 20:38+0000","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","PO-Revision-Date":"2017-06-14 04:21-0400","Last-Translator":"Dremor <egeorget@opmbx.org>","Language-Team":"French (https://www.transifex.com/gitlab-fr/teams/75145/fr/)","Language":"fr","Plural-Forms":"nplurals=2; plural=(n > 1);","X-Generator":"Zanata 3.9.6","lang":"fr","domain":"app","plural_forms":"nplurals=2; plural=(n > 1);"},"ByAuthor|by":["par"],"Commit":["Validation","Validations"],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":["L’analyseur de cycle permet d’avoir une vue d’ensemble du temps nécessaire pour aller d’une idée à sa mise en production pour votre projet."],"CycleAnalyticsStage|Code":["Code"],"CycleAnalyticsStage|Issue":["Incident"],"CycleAnalyticsStage|Plan":["Planification"],"CycleAnalyticsStage|Production":["Production"],"CycleAnalyticsStage|Review":["Examen"],"CycleAnalyticsStage|Staging":["Pré-production"],"CycleAnalyticsStage|Test":["Test"],"Deploy":["Déploiement","Déploiements"],"FirstPushedBy|First":["En premier"],"FirstPushedBy|pushed by":["poussé par"],"From issue creation until deploy to production":["Depuis la création de l'incident jusqu'au déploiement en production"],"From merge request merge until deploy to production":["Depuis la fusion de la demande de fusion jusqu'au déploiement en production"],"Introducing Cycle Analytics":["Introduction à l'analyseur de cycle"],"Last %d day":["Le dernier %d jour","Les derniers %d jours"],"Limited to showing %d event at most":["Limiter l'affichage au plus à %d évènement","Limiter l'affichage au plus à %d évènements"],"Median":["Médian"],"New Issue":["Nouvel incident","Nouveaux incidents"],"Not available":["Indisponible"],"Not enough data":["Données insuffisantes"],"OpenedNDaysAgo|Opened":["Ouvert"],"Pipeline Health":["Santé du Pipeline"],"ProjectLifecycle|Stage":["Étape"],"Read more":["Lire plus"],"Related Commits":["Validations liés"],"Related Deployed Jobs":["Tâches de déploiement liés"],"Related Issues":["Incidents liés"],"Related Jobs":["Tâches liées"],"Related Merge Requests":["Demandes de fusion liées"],"Related Merged Requests":["Demandes fusionnées liées"],"Showing %d event":["Affichage de %d évènement","Affichage de %d évènements"],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":["L’étape de développement montre le temps entre la première validation et la création de la demande de fusion. Les données seront automatiquement ajoutées ici une fois que vous aurez créé votre première demande de fusion."],"The collection of events added to the data gathered for that stage.":["L’ensemble d’évènements ajoutés aux données récupérées pour cette étape."],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":["L'étape des incidents montre le temps nécessaire entre la création d'un incident et son assignation à un jalon, ou son ajout à une liste d'un tableau d'incident. Débutez à créer des incidents pour voir des données pour cette étape."],"The phase of the development lifecycle.":["Les étapes du cycle de développement."],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":["L’étape de planification montre le temps entre l’étape précédente et l’envoi de votre première validation. Ce temps sera automatiquement ajouté quand vous pousserez votre première validation."],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":["L’étape de mise en production montre le temps nécessaire entre la création d’un incident et le déploiement du code en production. Les données seront automatiquement ajoutées une fois que vous aurez complété le cycle complet, depuis l’idée jusqu’à la mise en production."],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":["L’étape d’évaluation montre le temps entre la création de la demande de fusion et la fusion effective de celle-ci. Ces données seront automatiquement ajoutées après que vous ayez fusionné votre première demande de fusion."],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":["L’étape de pré-production indique le temps entre la fusion de la RF et le déploiement du code dans l’environnent de production. Les données seront automatiquement ajoutées une fois que vous déploierez en production pour la première fois."],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":["L’étape de test montre le temps que le CI de GitLab met pour exécuter chaque pipeline liés à la demande de fusion. Les données seront automatiquement ajoutées après que votre premier pipeline s’achèvera."],"The time taken by each data entry gathered by that stage.":["Le temps pris par chaque entrée récoltée durant cette étape."],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":["La valeur située au point médian d’une série de valeur observée. C.à.d., entre 3, 5, 9, le médian est 5. Entre 3, 5, 7, 8, le médian est (5+7)/2 = 6."],"Time before an issue gets scheduled":["Temps avant qu’un incident ne soit planifié"],"Time before an issue starts implementation":["Temps avant que résolution ne débute"],"Time between merge request creation and merge/close":["Temps entre la création d'une demande de fusion et sa fusion/clôture"],"Time until first merge request":["Temps jusqu’à la première demande de fusion"],"Time|hr":["hr","hrs"],"Time|min":["min","mins"],"Time|s":["s"],"Total Time":["Temps total"],"Total test time for all commits/merges":["Temps total de test pour toutes les validations/fusions"],"Want to see the data? Please ask an administrator for access.":["Vous voulez voir les données ? Merci de contacter un administrateur pour en obtenir l’accès."],"We don't have enough data to show this stage.":["Nous n'avons pas suffisamment de données pour afficher cette étape."],"You need permission.":["Vous avez besoin d’une autorisation."],"day":["jour","jours"],"%{commit_author_link} committed %{commit_timeago}":["%{commit_author_link} a validé %{commit_timeago}"],"About auto deploy":["A propos de l'auto-déploiement"],"Active":["Actif"],"Activity":["Activité"],"Add Changelog":["Ajouter un journal des modifications"],"Add Contribution guide":["Ajouter un guide de contribution"],"Add License":["Ajouter une licence"],"Add an SSH key to your profile to pull or push via SSH.":["Ajoutez une clef SSH à votre profil pour pouvoir récupérer et pousser par SSH."],"Add new directory":["Ajouter un nouveau dossier"],"Archived project! Repository is read-only":["Projet archivé ! Le dépôt est en lecture seule"],"Are you sure you want to delete this pipeline schedule?":["Êtes-vous sûr de vouloir supprimer ce pipeline programmé"],"Attach a file by drag & drop or %{upload_link}":["Attachez un fichier par glisser & déposer ou %{upload_link}"],"Branch":["Branche","Branches"],"#~ \"Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, cho\"#~ \"ose a GitLab CI Yaml template and commit your changes. %{link_to_autodeploy_do\"#~ \"c}\"":["#~ \"La branche <strong>%{branch_name}</strong> a été crée. Pour mettre en place le\"#~ \" déploiement automatisé, sélectionnez un modèle de fichier Yaml pour Gitlab CI\"#~ \", et validez les modifications. %{link_to_autodeploy_doc}\""],"Branches":["Branches"],"Browse files":["Parcourir les fichiers"],"CI configuration":["Configuration du CI"],"Cancel":["Annuler"],"ChangeTypeActionLabel|Pick into branch":["Sélectionner dans la branche"],"ChangeTypeActionLabel|Revert in branch":["Annuler dans la branche"],"ChangeTypeAction|Cherry-pick":["Sélectionner"],"ChangeType|commit":["validation"],"ChangeType|merge request":["demande de fusion"],"Changelog":["Journal des modifications"],"Charts":["Graphiques"],"Cherry-pick this commit":["Sélectionner cette validation"],"Cherry-pick this merge-request":["Sélectionner cette demande de fusion"],"CiStatusLabel|canceled":["annulé"],"CiStatusLabel|created":["créé"],"CiStatusLabel|failed":["échoué"],"CiStatusLabel|manual action":["action manuelle"],"CiStatusLabel|passed":["passé"],"CiStatusLabel|passed with warnings":["passé avec des avertissements"],"CiStatusLabel|pending":["en attente"],"CiStatusLabel|skipped":["ignoré"],"CiStatusLabel|waiting for manual action":["en attente d'action manuelle"],"CiStatusText|blocked":["bloqué"],"CiStatusText|canceled":["annulé "],"CiStatusText|created":["créé"],"CiStatusText|failed":["échoué"],"CiStatusText|manual":["manuel"],"CiStatusText|passed":["passé"],"CiStatusText|pending":["en attente"],"CiStatusText|skipped":["ignoré"],"CiStatus|running":["en cours"],"Commit message":["Message de validation"],"CommitMessage|Add %{file_name}":["Ajout de %{file_name}"],"Commits":["Validations"],"Commits|History":["Historique"],"Committed by":["Validé par"],"Compare":["Comparer"],"Contribution guide":["Guilde de contribution"],"Contributors":["Contributeurs"],"Copy URL to clipboard":["Copier l'URL dans le presse-papier"],"Copy commit SHA to clipboard":["Copier le SAH de la validation"],"Create New Directory":["Créer un nouveau dossier"],"Create directory":["Créer un dossier"],"Create empty bare repository":["Créer un dépôt vide"],"Create merge request":["Créer une demande de fusion"],"Create new...":["Créer nouveau..."],"CreateNewFork|Fork":["Fork"],"CreateTag|Tag":["Étiquette"],"Cron Timezone":["Fuseau horaire de Cron"],"Cron syntax":["Syntaxe CRON"],"Custom":["Personnalisé"],"Custom notification events":["Événements de notification personnalisés"],"#~ \"Custom notification levels are the same as participating levels. With custom n\"#~ \"otification levels you will also receive notifications for select events. To f\"#~ \"ind out more, check out %{notification_link}.\"":["#~ \"Le niveau de notification Personnalisé est similaire au niveau Participation. \"#~ \"Il permet cependant également de recevoir des notifications pour des événement\"#~ \"s sélectionnés. Pour plus d’information, vous pouvez consulter %{notification_\"#~ \"link}.\""],"Cycle Analytics":["Analyseur de cycle"],"Define a custom pattern with cron syntax":["Définir un schéma personnalisé avec une syntaxe CRON"],"Delete":["Supprimer"],"Description":["Description"],"Directory name":["Nom du dossier"],"Don't show again":["Ne plus montrer"],"Download":["Télécharger"],"Download tar":["Télécharger tar"],"Download tar.bz2":["Télécharger tar.bz2"],"Download tar.gz":["Télécharger tar.gz"],"Download zip":["Télécharger zip"],"DownloadArtifacts|Download":["Télécharger"],"DownloadCommit|Email Patches":["Patch email"],"DownloadCommit|Plain Diff":["Diff simple"],"DownloadSource|Download":["Télécharger"],"Edit":["Éditer"],"Edit Pipeline Schedule %{id}":["Éditer le pipeline programmé %{id}"],"Every day (at 4:00am)":["Chaque jour (à 4:00 du matin)"],"Every month (on the 1st at 4:00am)":["Chaque mois (le 1er à 4:00 du matin)"],"Every week (Sundays at 4:00am)":["Chaque semaine (Dimanche à 4:00 du matin)"],"Failed to change the owner":["Échec du changement de propriétaire"],"Failed to remove the pipeline schedule":["Échec de la suppression du pipeline programmé"],"Files":["Fichiers"],"Find by path":["Rechercher par chemin"],"Find file":["Rechercher un fichier"],"Fork":["Fork","Forks"],"ForkedFromProjectPath|Forked from":["Forké depuis"],"Go to your fork":["Aller à votre fork"],"GoToYourFork|Fork":["Fork"],"Home":["Accueil"],"Housekeeping successfully started":["Maintenance démarrée avec succès"],"Import repository":["Importer un dépôt"],"Interval Pattern":["Schéma d’intervalle"],"LFSStatus|Disabled":["Désactivé"],"LFSStatus|Enabled":["Activé"],"Last Pipeline":["Dernier pipeline"],"Last Update":["Dernière mise à jour"],"Last commit":["Dernière validation"],"Learn more in the":["En apprendre plus dans le"],"Leave group":["Quitter le groupe"],"Leave project":["Quitter le projet"],"MissingSSHKeyWarningLink|add an SSH key":["ajouter un clef SSH"],"New Pipeline Schedule":["Nouveau pipeline programmé"],"New branch":["Nouvelle branche"],"New directory":["Nouveau dossier"],"New file":["Nouveau Fichier"],"New issue":["Nouvel incident"],"New merge request":["Nouvelle demande de fusion"],"New schedule":["Nouveau programme"],"New snippet":["Nouvel extrait de code"],"New tag":["Nouvelle étiquette"],"No repository":["Pas de dépôt"],"No schedules":["Aucun programme"],"Notification events":["Événement de notifications"],"NotificationEvent|Close issue":["Clore l'incident"],"NotificationEvent|Close merge request":["Clore la demande de fusion"],"NotificationEvent|Failed pipeline":["Pipeline échoué"],"NotificationEvent|Merge merge request":["Fusionner le demande de fusion"],"NotificationEvent|New issue":["Nouvel incident"],"NotificationEvent|New merge request":["Nouvelle demande de fusion"],"NotificationEvent|New note":["Nouvelle note"],"NotificationEvent|Reassign issue":["Réassigner l'incident"],"NotificationEvent|Reassign merge request":["Réassigner la demande de fusion"],"NotificationEvent|Reopen issue":["Ré-ouvrir l'incident"],"NotificationEvent|Successful pipeline":["Pipeline réussi"],"NotificationLevel|Custom":["Personnalisé"],"NotificationLevel|Disabled":["Désactivé"],"NotificationLevel|Global":["Global"],"NotificationLevel|On mention":["En cas de mention"],"NotificationLevel|Participate":["Participation"],"NotificationLevel|Watch":["Surveillé"],"OfSearchInADropdown|Filter":["Filtre"],"Options":["Options"],"Owner":["Propriétaire"],"Pipeline":["Pipeline"],"Pipeline Schedule":["Programmation de pipeline"],"Pipeline Schedules":["Programmations de pipeline"],"PipelineSchedules|Activated":["Activé"],"PipelineSchedules|Active":["Active"],"PipelineSchedules|All":["Tous"],"PipelineSchedules|Inactive":["Inactive"],"PipelineSchedules|Next Run":["Prochaine exécution"],"PipelineSchedules|None":["Aucune"],"PipelineSchedules|Provide a short description for this pipeline":["Indiquez une courte description"],"PipelineSchedules|Take ownership":["S’approprier"],"PipelineSchedules|Target":["Cible"],"Project '%{project_name}' queued for deletion.":["Projet '%{project_name}' en attente de suppression."],"Project '%{project_name}' was successfully created.":["Projet '%{project_name}' créé avec succès."],"Project '%{project_name}' was successfully updated.":["Projet '%{project_name}' mis à jour avec succès."],"Project '%{project_name}' will be deleted.":["Projet '%{project_name}' sera supprimé."],"Project access must be granted explicitly to each user.":["L’accès au projet doit être explicitement accordé à chaque utilisateur."],"Project export could not be deleted.":["L'export du projet n'a pas pu être supprimé."],"Project export has been deleted.":["L'export du projet a été supprimé."],"#~ \"Project export link has expired. Please generate a new export from your projec\"#~ \"t settings.\"":["#~ \"Le lien de l’export du projet a expiré. Merci de générer un nouvel export depu\"#~ \"is les paramètres du projet.\""],"Project export started. A download link will be sent by email.":["#~ \"L'export du projet a débuté. Un lien de téléchargement sera envoyé par courrie\"#~ \"l.\""],"Project home":["Accueil du projet"],"ProjectFeature|Disabled":["Désactivé"],"ProjectFeature|Everyone with access":["Toute personne ayant accès"],"ProjectFeature|Only team members":["Seulement les membres de l'équipe"],"ProjectFileTree|Name":["Nom"],"ProjectLastActivity|Never":["Jamais"],"ProjectNetworkGraph|Graph":["Graphique "],"Readme":["LisezMoi"],"RefSwitcher|Branches":["Branches"],"RefSwitcher|Tags":["Étiquettes"],"Remind later":["Me le rappeler ultérieurement"],"Remove project":["Supprimer le projet"],"Request Access":["Demander l'accès"],"Revert this commit":["Annuler cette validation"],"Revert this merge-request":["Annuler cette demande de fusion"],"Save pipeline schedule":["Sauvegarder le pipeline programmé"],"Schedule a new pipeline":["Programmer un nouveau pipeline"],"Scheduling Pipelines":["Programmer des pipelines"],"Search branches and tags":["Rechercher dans les branches et les étiquettes"],"Select Archive Format":["Sélectionnez le format de l'archive"],"Select a timezone":["Sélectionnez un fuseau horaire"],"Select target branch":["Sélectionnez une branche cible"],"Set a password on your account to pull or push via %{protocol}":["#~ \"Définissez un mot de passe pour votre compte pour pouvoir tirer ou pousser par\"#~ \" %{protocol}\""],"Set up CI":["Mettre en place le CI"],"Set up Koding":["Mettre en place Koding"],"Set up auto deploy":["Mettre en place l’auto-déploiement "],"SetPasswordToCloneLink|set a password":["définir un mot de passe"],"Source code":["Code source"],"StarProject|Star":["S'abonner"],"Start a <strong>new merge request</strong> with these changes":["Créer une <strong>nouvelle demande de fusion</strong> avec ces changements"],"Switch branch/tag":["Changer de branche / d'étiquette"],"Tag":["Étiquette","Étiquettes"],"Tags":["Étiquettes"],"Target Branch":["Branche cible"],"The fork relationship has been removed.":["La relation de fork a été supprimée."],"#~ \"The pipelines schedule runs pipelines in the future, repeatedly, for specific \"#~ \"branches or tags. Those scheduled pipelines will inherit limited project acces\"#~ \"s based on their associated user.\"":["#~ \"Les pipelines programmés exécutent des pipelines dans le futur, de façon répét\"#~ \"ée, pour les branches et étiquettes spécifiées. Ces pipelines programmés hérit\"#~ \"ent d’un accès partiel au projet basé sur l’utilisateur que leurs est associé.\""],"The project can be accessed by any logged in user.":["Votre projet peut être accédé par n’importe quel utilisateur authentifié"],"The project can be accessed without any authentication.":["Votre projet peut être accédé sans aucune authentification."],"The repository for this project does not exist.":["Le dépôt pour ce projet n'existe pas."],"#~ \"This means you can not push code until you create an empty repository or impor\"#~ \"t existing one.\"":["#~ \"Cela signifie que vous ne pouvez pas pousser du code tant que vous ne créez pa\"#~ \"s un dépôt vide, ou importez une dépôt existant.\""],"Timeago|%s days ago":["Il y a %s jours"],"Timeago|%s days remaining":["Il reste %s jours"],"Timeago|%s hours remaining":["Il reste %s heures"],"Timeago|%s minutes ago":["Il y a %s minutes"],"Timeago|%s minutes remaining":["Il reste %s minutes"],"Timeago|%s months ago":["Il y a %s mois"],"Timeago|%s months remaining":["Il reste %s mois"],"Timeago|%s seconds remaining":["Il reste %s secondes"],"Timeago|%s weeks ago":["Il y a %s semaines"],"Timeago|%s weeks remaining":["Il reste %s semaines"],"Timeago|%s years ago":["Il y a %s ans"],"Timeago|%s years remaining":["Il reste %s ans"],"Timeago|1 day remaining":["Il reste un jour"],"Timeago|1 hour remaining":["Il reste une heure"],"Timeago|1 minute remaining":["Il reste une minute"],"Timeago|1 month remaining":["Il reste un mois"],"Timeago|1 week remaining":["Il reste une semaine"],"Timeago|1 year remaining":["Il reste un an"],"Timeago|Past due":["En retard"],"Timeago|a day ago":["Il y a un jour"],"Timeago|a month ago":["Il y a un mois"],"Timeago|a week ago":["Il y a une semaine"],"Timeago|a while":["Il y a un moment"],"Timeago|a year ago":["Il y a un an"],"Timeago|about %s hours ago":["Il y a environ %s heures"],"Timeago|about a minute ago":["Il y a environ une minute"],"Timeago|about an hour ago":["Il y a environ une heure"],"Timeago|in %s days":["Dans %s jours"],"Timeago|in %s hours":["Dans %s heures"],"Timeago|in %s minutes":["Dans %s minutes"],"Timeago|in %s months":["Dans %s mois"],"Timeago|in %s seconds":["Dans %s secondes"],"Timeago|in %s weeks":["Dans %s semaines"],"Timeago|in %s years":["Dans %s années"],"Timeago|in 1 day":["Dans 1 jour"],"Timeago|in 1 hour":["Dans 1 heure"],"Timeago|in 1 minute":["Dans 1 minute"],"Timeago|in 1 month":["Dans 1 mois"],"Timeago|in 1 week":["Dans 1 semaine"],"Timeago|in 1 year":["Dans 1 an"],"Timeago|less than a minute ago":["il y a moins d'une minute"],"Unstar":["Se désabonner"],"Upload New File":["Téléverser un nouveau fichier"],"Upload file":["Téléverser un fichier"],"Use your global notification setting":["Utiliser vos paramètres de notification globaux"],"VisibilityLevel|Internal":["Interne"],"VisibilityLevel|Private":["Privé"],"VisibilityLevel|Public":["Publique"],"Withdraw Access Request":["Retirer la demande d'accès"],"#~ \"You are going to remove %{project_name_with_namespace}.\\n\"#~ \"Removed project CANNOT be restored!\\n\"#~ \"Are you ABSOLUTELY sure?\"":["#~ \"Vous êtes sur le point de supprimer %{project_name_with_namespace}.\\n\"#~ \"Les projets supprimés NE PEUVENT PAS être restaurés !\\n\"#~ \"Êtes vous ABSOLUMENT sûr ? \""],"#~ \"You are going to remove the fork relationship to source project %{forked_from_\"#~ \"project}. Are you ABSOLUTELY sure?\"":["#~ \"Vous allez supprimer la relation de fork avec le projet source %{forked_from_p\"#~ \"roject}. Êtes-vous VRAIMENT sûr.\""],"#~ \"You are going to transfer %{project_name_with_namespace} to another owner. Are\"#~ \" you ABSOLUTELY sure?\"":["#~ \"Vous allez transférer %{project_name_with_namespace} à un nouveau propriétaire\"#~ \". Êtes vous VRAIMENT sûr ?\""],"You can only add files when you are on a branch":["Vous ne pouvez ajouter de fichier que dans une branche"],"You must sign in to star a project":["Vous devez vous identifier pour vous abonner à un projet"],"You will not get any notifications via email":["Vous ne recevrez aucune notification par courriel"],"You will only receive notifications for the events you choose":["#~ \"Vous ne recevrez de notification que pour les évènements que vous aurez choisi\"#~ \"s\""],"You will only receive notifications for threads you have participated in":["#~ \"Vous ne recevrez de notification que pour les sujets auxquels vous avez partic\"#~ \"ipé\""],"You will receive notifications for any activity":["Vous recevrez des notifications pour n’importe quelles activités"],"You will receive notifications only for comments in which you were @mentioned":["#~ \"Vous ne recevrez de notifications que pour les commentaires où vous êtes @ment\"#~ \"ionné\""],"#~ \"You won't be able to pull or push project code via %{protocol} until you %{set\"#~ \"_password_link} on your account\"":["#~ \"Vous ne pourrez pas récupérer ou pousser de code par %{protocol} tant que vo\"#~ \"us n'aurez pas %{set_password_link} pour votre compte\""],"#~ \"You won't be able to pull or push project code via SSH until you %{add_ssh_key\"#~ \"_link} to your profile\"":["#~ \"Vous ne pourrez pas récupérer ou pousser de code par SSH tant que vous n’aur\"#~ \"ez pas %{add_ssh_key_link} dans votre profil\""],"Your name":["Votre nom"],"notification emails":["courriels de notification"],"parent":["parent","parents"],"pipeline schedules documentation":["documentation des pipeline programmés"],"with stage":["avec l'étape","avec les étapes"]}}};
\ No newline at end of file diff --git a/app/assets/javascripts/locale/pt_BR/app.js b/app/assets/javascripts/locale/pt_BR/app.js deleted file mode 100644 index f2eed3da064..00000000000 --- a/app/assets/javascripts/locale/pt_BR/app.js +++ /dev/null @@ -1 +0,0 @@ -var locales = locales || {}; locales['pt_BR'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","POT-Creation-Date":"2017-05-04 19:24-0500","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","PO-Revision-Date":"2017-06-05 03:29-0400","Last-Translator":"Alexandre Alencar <alexandre.alencar@gmail.com>","Language-Team":"Portuguese (Brazil)","Language":"pt-BR","X-Generator":"Zanata 3.9.6","Plural-Forms":"nplurals=2; plural=(n != 1)","lang":"pt_BR","domain":"app","plural_forms":"nplurals=2; plural=(n != 1)"},"ByAuthor|by":["por"],"Commit":["Commit","Commits"],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":["A Análise de Ciclo fornece uma visão geral de quanto tempo uma ideia demora para ir para produção em seu projeto."],"CycleAnalyticsStage|Code":["Código"],"CycleAnalyticsStage|Issue":["Tarefa"],"CycleAnalyticsStage|Plan":["Plano"],"CycleAnalyticsStage|Production":["Produção"],"CycleAnalyticsStage|Review":["Revisão"],"CycleAnalyticsStage|Staging":["Homologação"],"CycleAnalyticsStage|Test":["Teste"],"Deploy":["Implantação","Implantações"],"FirstPushedBy|First":["Primeiro"],"FirstPushedBy|pushed by":["publicado por"],"From issue creation until deploy to production":["Da criação de tarefas até a implantação para a produção"],"From merge request merge until deploy to production":["Da incorporação do merge request até a implantação em produção"],"Introducing Cycle Analytics":["Apresentando a Análise de Ciclo"],"Last %d day":["Último %d dia","Últimos %d dias"],"Limited to showing %d event at most":["Limitado a mostrar %d evento no máximo","Limitado a mostrar %d eventos no máximo"],"Median":["Mediana"],"New Issue":["Nova Tarefa","Novas Tarefas"],"Not available":["Não disponível"],"Not enough data":["Dados insuficientes"],"OpenedNDaysAgo|Opened":["Aberto"],"Pipeline Health":["Saúde da Pipeline"],"ProjectLifecycle|Stage":["Etapa"],"Read more":["Ler mais"],"Related Commits":["Commits Relacionados"],"Related Deployed Jobs":["Jobs Relacionados Incorporados"],"Related Issues":["Tarefas Relacionadas"],"Related Jobs":["Jobs Relacionados"],"Related Merge Requests":["Merge Requests Relacionados"],"Related Merged Requests":["Merge Requests Relacionados"],"Showing %d event":["Mostrando %d evento","Mostrando %d eventos"],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":["O estágio de codificação mostra o tempo desde o primeiro commit até a criação do merge request. \\nOs dados serão automaticamente adicionados aqui uma vez que você tenha criado seu primeiro merge request."],"The collection of events added to the data gathered for that stage.":["A coleção de eventos adicionados aos dados coletados para esse estágio."],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":["O estágio em questão mostra o tempo que leva desde a criação de uma tarefa até a sua assinatura para um milestone, ou a sua adição para a lista no seu Painel de Tarefas. Comece a criar tarefas para ver dados para esta etapa."],"The phase of the development lifecycle.":["A fase do ciclo de vida do desenvolvimento."],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":["A fase de planejamento mostra o tempo do passo anterior até empurrar o seu primeiro commit. Este tempo será adicionado automaticamente assim que você realizar seu primeiro commit."],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":["O estágio de produção mostra o tempo total que leva entre criar uma tarefa e implantar o código na produção. Os dados serão adicionados automaticamente até que você complete todo o ciclo de produção."],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":["A etapa de revisão mostra o tempo de criação de um merge request até que o merge seja feito. Os dados serão automaticamente adicionados depois que você fizer seu primeiro merge request."],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":["O estágio de estágio mostra o tempo entre a fusão do MR e o código de implantação para o ambiente de produção. Os dados serão automaticamente adicionados depois de implantar na produção pela primeira vez."],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":["A fase de teste mostra o tempo que o GitLab CI leva para executar cada pipeline para o merge request relacionado. Os dados serão automaticamente adicionados após a conclusão do primeiro pipeline."],"The time taken by each data entry gathered by that stage.":["O tempo necessário para cada entrada de dados reunida por essa etapa."],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":["O valor situado no ponto médio de uma série de valores observados. Ex., entre 3, 5, 9, a mediana é 5. Entre 3, 5, 7, 8, a mediana é (5 + 7) / 2 = 6."],"Time before an issue gets scheduled":["Tempo até que uma tarefa seja planejada"],"Time before an issue starts implementation":["Tempo até que uma tarefa comece a ser implementada"],"Time between merge request creation and merge/close":["Tempo entre a criação do merge request e o merge/fechamento"],"Time until first merge request":["Tempo até o primeiro merge request"],"Time|hr":["h","hs"],"Time|min":["min","mins"],"Time|s":["s"],"Total Time":["Tempo Total"],"Total test time for all commits/merges":["Tempo de teste total para todos os commits/merges"],"Want to see the data? Please ask an administrator for access.":["Precisa visualizar os dados? Solicite acesso ao administrador."],"We don't have enough data to show this stage.":["Não temos dados suficientes para mostrar esta fase."],"You need permission.":["Você precisa de permissão."],"day":["dia","dias"]}}};
\ No newline at end of file diff --git a/app/assets/javascripts/locale/zh_CN/app.js b/app/assets/javascripts/locale/zh_CN/app.js deleted file mode 100644 index d1335cfbc0f..00000000000 --- a/app/assets/javascripts/locale/zh_CN/app.js +++ /dev/null @@ -1 +0,0 @@ -var locales = locales || {}; locales['zh_CN'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-05-04 19:24-0500","Last-Translator":"HuangTao <htve@outlook.com>, 2017","Language-Team":"Chinese (China) (https://www.transifex.com/gitlab-zh/teams/75177/zh_CN/)","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Language":"zh_CN","Plural-Forms":"nplurals=1; plural=0;","lang":"zh_CN","domain":"app","plural_forms":"nplurals=1; plural=0;"},"Are you sure you want to delete this pipeline schedule?":[""],"ByAuthor|by":["作者:"],"Cancel":[""],"Commit":["提交"],"Cron Timezone":[""],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":["周期分析概述了项目从想法到产品实现的各阶段所需的时间。"],"CycleAnalyticsStage|Code":["编码"],"CycleAnalyticsStage|Issue":["议题"],"CycleAnalyticsStage|Plan":["计划"],"CycleAnalyticsStage|Production":["生产"],"CycleAnalyticsStage|Review":["评审"],"CycleAnalyticsStage|Staging":["预发布"],"CycleAnalyticsStage|Test":["测试"],"Delete":[""],"Deploy":["部署"],"Description":[""],"Edit":[""],"Edit Pipeline Schedule %{id}":[""],"Failed to change the owner":[""],"Failed to remove the pipeline schedule":[""],"Filter":[""],"FirstPushedBy|First":["首次推送"],"FirstPushedBy|pushed by":["推送者:"],"From issue creation until deploy to production":["从创建议题到部署至生产环境"],"From merge request merge until deploy to production":["从合并请求被合并后到部署至生产环境"],"Interval Pattern":[""],"Introducing Cycle Analytics":["周期分析简介"],"Last %d day":["最后 %d 天"],"Last Pipeline":[""],"Limited to showing %d event at most":["最多显示 %d 个事件"],"Median":["中位数"],"New Issue":["新议题"],"New Pipeline Schedule":[""],"No schedules":[""],"Not available":["数据不足"],"Not enough data":["数据不足"],"OpenedNDaysAgo|Opened":["开始于"],"Owner":[""],"Pipeline Health":["流水线健康指标"],"Pipeline Schedule":[""],"Pipeline Schedules":[""],"PipelineSchedules|Activated":[""],"PipelineSchedules|Active":[""],"PipelineSchedules|All":[""],"PipelineSchedules|Inactive":[""],"PipelineSchedules|Next Run":[""],"PipelineSchedules|None":[""],"PipelineSchedules|Provide a short description for this pipeline":[""],"PipelineSchedules|Take ownership":[""],"PipelineSchedules|Target":[""],"ProjectLifecycle|Stage":["项目生命周期"],"Read more":["了解更多"],"Related Commits":["相关的提交"],"Related Deployed Jobs":["相关的部署作业"],"Related Issues":["相关的议题"],"Related Jobs":["相关的作业"],"Related Merge Requests":["相关的合并请求"],"Related Merged Requests":["相关已合并的合并请求"],"Save pipeline schedule":[""],"Schedule a new pipeline":[""],"Select a timezone":[""],"Select target branch":[""],"Showing %d event":["显示 %d 个事件"],"Target Branch":[""],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":["编码阶段概述了从第一次提交到创建合并请求的时间。创建第一个合并请求后,数据将自动添加到此处。"],"The collection of events added to the data gathered for that stage.":["与该阶段相关的事件。"],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":["议题阶段概述了从创建议题到将议题设置里程碑或将议题添加到议题看板的时间。开始创建议题以查看此阶段的数据。"],"The phase of the development lifecycle.":["项目生命周期中的各个阶段。"],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":["计划阶段概述了从议题添加到日程后到推送首次提交的时间。当首次推送提交后,数据将自动添加到此处。"],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":["生产阶段概述了从创建一个议题到将代码部署到生产环境的总时间。当完成想法到部署生产的循环,数据将自动添加到此处。"],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":["评审阶段概述了从创建合并请求到被合并的时间。当创建第一个合并请求后,数据将自动添加到此处。"],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":["预发布阶段概述了从合并请求被合并到部署至生产环境的总时间。首次部署到生产环境后,数据将自动添加到此处。"],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":["测试阶段概述了GitLab CI为相关合并请求运行每个流水线所需的时间。当第一个流水线运行完成后,数据将自动添加到此处。"],"The time taken by each data entry gathered by that stage.":["该阶段每条数据所花的时间"],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":["中位数是一个数列中最中间的值。例如在 3、5、9 之间,中位数是 5。在 3、5、7、8 之间,中位数是 (5 + 7)/ 2 = 6。"],"Time before an issue gets scheduled":["议题被列入日程表的时间"],"Time before an issue starts implementation":["开始进行编码前的时间"],"Time between merge request creation and merge/close":["从创建合并请求到被合并或关闭的时间"],"Time until first merge request":["创建第一个合并请求之前的时间"],"Time|hr":["小时"],"Time|min":["分钟"],"Time|s":["秒"],"Total Time":["总时间"],"Total test time for all commits/merges":["所有提交和合并的总测试时间"],"Want to see the data? Please ask an administrator for access.":["权限不足。如需查看相关数据,请向管理员申请权限。"],"We don't have enough data to show this stage.":["该阶段的数据不足,无法显示。"],"You need permission.":["您需要相关的权限。"],"day":["天"]}}};
\ No newline at end of file diff --git a/app/assets/javascripts/locale/zh_HK/app.js b/app/assets/javascripts/locale/zh_HK/app.js deleted file mode 100644 index 30cb1e6b89e..00000000000 --- a/app/assets/javascripts/locale/zh_HK/app.js +++ /dev/null @@ -1 +0,0 @@ -var locales = locales || {}; locales['zh_HK'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-05-04 19:24-0500","Last-Translator":"HuangTao <htve@outlook.com>, 2017","Language-Team":"Chinese (Hong Kong) (https://www.transifex.com/gitlab-zh/teams/75177/zh_HK/)","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Language":"zh_HK","Plural-Forms":"nplurals=1; plural=0;","lang":"zh_HK","domain":"app","plural_forms":"nplurals=1; plural=0;"},"Are you sure you want to delete this pipeline schedule?":[""],"ByAuthor|by":["作者:"],"Cancel":[""],"Commit":["提交"],"Cron Timezone":[""],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":["週期分析概述了項目從想法到產品實現的各階段所需的時間。"],"CycleAnalyticsStage|Code":["編碼"],"CycleAnalyticsStage|Issue":["議題"],"CycleAnalyticsStage|Plan":["計劃"],"CycleAnalyticsStage|Production":["生產"],"CycleAnalyticsStage|Review":["評審"],"CycleAnalyticsStage|Staging":["預發布"],"CycleAnalyticsStage|Test":["測試"],"Delete":[""],"Deploy":["部署"],"Description":[""],"Edit":[""],"Edit Pipeline Schedule %{id}":[""],"Failed to change the owner":[""],"Failed to remove the pipeline schedule":[""],"Filter":[""],"FirstPushedBy|First":["首次推送"],"FirstPushedBy|pushed by":["推送者:"],"From issue creation until deploy to production":["從創建議題到部署到生產環境"],"From merge request merge until deploy to production":["從合併請求的合併到部署至生產環境"],"Interval Pattern":[""],"Introducing Cycle Analytics":["週期分析簡介"],"Last %d day":["最後 %d 天"],"Last Pipeline":[""],"Limited to showing %d event at most":["最多顯示 %d 個事件"],"Median":["中位數"],"New Issue":["新議題"],"New Pipeline Schedule":[""],"No schedules":[""],"Not available":["不可用"],"Not enough data":["數據不足"],"OpenedNDaysAgo|Opened":["開始於"],"Owner":[""],"Pipeline Health":["流水線健康指標"],"Pipeline Schedule":[""],"Pipeline Schedules":[""],"PipelineSchedules|Activated":[""],"PipelineSchedules|Active":[""],"PipelineSchedules|All":[""],"PipelineSchedules|Inactive":[""],"PipelineSchedules|Next Run":[""],"PipelineSchedules|None":[""],"PipelineSchedules|Provide a short description for this pipeline":[""],"PipelineSchedules|Take ownership":[""],"PipelineSchedules|Target":[""],"ProjectLifecycle|Stage":["項目生命週期"],"Read more":["了解更多"],"Related Commits":["相關的提交"],"Related Deployed Jobs":["相關的部署作業"],"Related Issues":["相關的議題"],"Related Jobs":["相關的作業"],"Related Merge Requests":["相關的合併請求"],"Related Merged Requests":["相關已合併的合並請求"],"Save pipeline schedule":[""],"Schedule a new pipeline":[""],"Select a timezone":[""],"Select target branch":[""],"Showing %d event":["顯示 %d 個事件"],"Target Branch":[""],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":["編碼階段概述了從第一次提交到創建合併請求的時間。創建第壹個合並請求後,數據將自動添加到此處。"],"The collection of events added to the data gathered for that stage.":["與該階段相關的事件。"],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":["議題階段概述了從創建議題到將議題設置裏程碑或將議題添加到議題看板的時間。創建一個議題後,數據將自動添加到此處。"],"The phase of the development lifecycle.":["項目生命週期中的各個階段。"],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":["計劃階段概述了從議題添加到日程後到推送首次提交的時間。當首次推送提交後,數據將自動添加到此處。"],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":["生產階段概述了從創建議題到將代碼部署到生產環境的時間。當完成完整的想法到部署生產,數據將自動添加到此處。"],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":["評審階段概述了從創建合並請求到合併的時間。當創建第壹個合並請求後,數據將自動添加到此處。"],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":["預發布階段概述了合並請求的合併到部署代碼到生產環境的總時間。當首次部署到生產環境後,數據將自動添加到此處。"],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":["測試階段概述了GitLab CI為相關合併請求運行每個流水線所需的時間。當第壹個流水線運行完成後,數據將自動添加到此處。"],"The time taken by each data entry gathered by that stage.":["該階段每條數據所花的時間"],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":["中位數是一個數列中最中間的值。例如在 3、5、9 之間,中位數是 5。在 3、5、7、8 之間,中位數是 (5 + 7)/ 2 = 6。"],"Time before an issue gets scheduled":["議題被列入日程表的時間"],"Time before an issue starts implementation":["開始進行編碼前的時間"],"Time between merge request creation and merge/close":["從創建合併請求到被合並或關閉的時間"],"Time until first merge request":["創建第壹個合併請求之前的時間"],"Time|hr":["小時"],"Time|min":["分鐘"],"Time|s":["秒"],"Total Time":["總時間"],"Total test time for all commits/merges":["所有提交和合併的總測試時間"],"Want to see the data? Please ask an administrator for access.":["權限不足。如需查看相關數據,請向管理員申請權限。"],"We don't have enough data to show this stage.":["該階段的數據不足,無法顯示。"],"You need permission.":["您需要相關的權限。"],"day":["天"]}}};
\ No newline at end of file diff --git a/app/assets/javascripts/locale/zh_TW/app.js b/app/assets/javascripts/locale/zh_TW/app.js deleted file mode 100644 index f0fe1e31f18..00000000000 --- a/app/assets/javascripts/locale/zh_TW/app.js +++ /dev/null @@ -1 +0,0 @@ -var locales = locales || {}; locales['zh_TW'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-05-04 19:24-0500","Last-Translator":"HuangTao <htve@outlook.com>, 2017","Language-Team":"Chinese (Taiwan) (https://www.transifex.com/gitlab-zh/teams/75177/zh_TW/)","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Language":"zh_TW","Plural-Forms":"nplurals=1; plural=0;","lang":"zh_TW","domain":"app","plural_forms":"nplurals=1; plural=0;"},"Are you sure you want to delete this pipeline schedule?":[""],"ByAuthor|by":["作者:"],"Cancel":[""],"Commit":["送交"],"Cron Timezone":[""],"Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project.":["週期分析概述了你的專案從想法到產品實現,各階段所需的時間。"],"CycleAnalyticsStage|Code":["程式開發"],"CycleAnalyticsStage|Issue":["議題"],"CycleAnalyticsStage|Plan":["計劃"],"CycleAnalyticsStage|Production":["上線"],"CycleAnalyticsStage|Review":["複閱"],"CycleAnalyticsStage|Staging":["預備"],"CycleAnalyticsStage|Test":["測試"],"Delete":[""],"Deploy":["部署"],"Description":[""],"Edit":[""],"Edit Pipeline Schedule %{id}":[""],"Failed to change the owner":[""],"Failed to remove the pipeline schedule":[""],"Filter":[""],"FirstPushedBy|First":["首次推送"],"FirstPushedBy|pushed by":["推送者:"],"From issue creation until deploy to production":["從議題建立至線上部署"],"From merge request merge until deploy to production":["從請求被合併後至線上部署"],"Interval Pattern":[""],"Introducing Cycle Analytics":["週期分析簡介"],"Last %d day":["最後 %d 天"],"Last Pipeline":[""],"Limited to showing %d event at most":["最多顯示 %d 個事件"],"Median":["中位數"],"New Issue":["新議題"],"New Pipeline Schedule":[""],"No schedules":[""],"Not available":["無法使用"],"Not enough data":["資料不足"],"OpenedNDaysAgo|Opened":["開始於"],"Owner":[""],"Pipeline Health":["流水線健康指標"],"Pipeline Schedule":[""],"Pipeline Schedules":[""],"PipelineSchedules|Activated":[""],"PipelineSchedules|Active":[""],"PipelineSchedules|All":[""],"PipelineSchedules|Inactive":[""],"PipelineSchedules|Next Run":[""],"PipelineSchedules|None":[""],"PipelineSchedules|Provide a short description for this pipeline":[""],"PipelineSchedules|Take ownership":[""],"PipelineSchedules|Target":[""],"ProjectLifecycle|Stage":["專案生命週期"],"Read more":["了解更多"],"Related Commits":["相關的送交"],"Related Deployed Jobs":["相關的部署作業"],"Related Issues":["相關的議題"],"Related Jobs":["相關的作業"],"Related Merge Requests":["相關的合併請求"],"Related Merged Requests":["相關已合併的請求"],"Save pipeline schedule":[""],"Schedule a new pipeline":[""],"Select a timezone":[""],"Select target branch":[""],"Showing %d event":["顯示 %d 個事件"],"Target Branch":[""],"The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.":["程式開發階段顯示從第一次送交到建立合併請求的時間。建立第一個合併請求後,資料將自動填入。"],"The collection of events added to the data gathered for that stage.":["與該階段相關的事件。"],"The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.":["議題階段顯示從議題建立到設置里程碑、或將該議題加至議題看板的時間。建立第一個議題後,資料將自動填入。"],"The phase of the development lifecycle.":["專案開發生命週期的各個階段。"],"The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.":["計劃階段顯示從議題添加到日程後至推送第一個送交的時間。當第一次推送送交後,資料將自動填入。"],"The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.":["上線階段顯示從建立一個議題到部署程式至線上的總時間。當完成從想法到產品實現的循環後,資料將自動填入。"],"The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.":["複閱階段顯示從合併請求建立後至被合併的時間。當建立第一個合併請求後,資料將自動填入。"],"The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.":["預備階段顯示從合併請求被合併後至部署上線的時間。當第一次部署上線後,資料將自動填入。"],"The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running.":["測試階段顯示相關合併請求的流水線所花的時間。當第一個流水線運作完畢後,資料將自動填入。"],"The time taken by each data entry gathered by that stage.":["每筆該階段相關資料所花的時間。"],"The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6.":["中位數是一個數列中最中間的值。例如在 3、5、9 之間,中位數是 5。在 3、5、7、8 之間,中位數是 (5 + 7)/ 2 = 6。"],"Time before an issue gets scheduled":["議題被列入日程表的時間"],"Time before an issue starts implementation":["議題等待開始實作的時間"],"Time between merge request creation and merge/close":["合併請求被合併或是關閉的時間"],"Time until first merge request":["第一個合併請求被建立前的時間"],"Time|hr":["小時"],"Time|min":["分鐘"],"Time|s":["秒"],"Total Time":["總時間"],"Total test time for all commits/merges":["所有送交和合併的總測試時間"],"Want to see the data? Please ask an administrator for access.":["權限不足。如需查看相關資料,請向管理員申請權限。"],"We don't have enough data to show this stage.":["因該階段的資料不足而無法顯示相關資訊"],"You need permission.":["您需要相關的權限。"],"day":["天"]}}};
\ No newline at end of file diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index ed7629948ca..d27b4ec78c6 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -299,9 +299,10 @@ $(function () { // Commit show suppressed diff }); $('.navbar-toggle').on('click', function () { - $('.header-content .title').toggle(); + $('.header-content .title, .header-content .navbar-sub-nav').toggle(); $('.header-content .header-logo').toggle(); $('.header-content .navbar-collapse').toggle(); + $('.js-navbar-toggle-left, .js-navbar-toggle-right, .title-container').toggle(); return $('.navbar-toggle').toggleClass('active'); }); // Show/hide comments on diff diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 894ed81b044..786b6014dc6 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -155,7 +155,10 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; scrollToElement(container) { if (location.hash) { - const offset = -$('.js-tabs-affix').outerHeight(); + const offset = 0 - ( + $('.navbar-gitlab').outerHeight() + + $('.js-tabs-affix').outerHeight() + ); const $el = $(`${container} ${location.hash}:not(.match)`); if ($el.length) { $.scrollTo($el[0], { offset }); @@ -233,11 +236,18 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; } mountPipelinesView() { - this.commitPipelinesTable = new gl.CommitPipelinesTable().$mount(); + const pipelineTableViewEl = document.querySelector('#commit-pipeline-table-view'); + const CommitPipelinesTable = gl.CommitPipelinesTable; + this.commitPipelinesTable = new CommitPipelinesTable({ + propsData: { + endpoint: pipelineTableViewEl.dataset.endpoint, + helpPagePath: pipelineTableViewEl.dataset.helpPagePath, + }, + }).$mount(); + // $mount(el) replaces the el with the new rendered component. We need it in order to mount // it everytime this tab is clicked - https://vuejs.org/v2/api/#vm-mount - document.querySelector('#commit-pipeline-table-view') - .appendChild(this.commitPipelinesTable.$el); + pipelineTableViewEl.appendChild(this.commitPipelinesTable.$el); } loadDiff(source) { @@ -284,7 +294,7 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; // Scroll any linked note into view // Similar to `toggler_behavior` in the discussion tab const hash = window.gl.utils.getLocationHash(); - const anchor = hash && $container.find(`[id="${hash}"]`); + const anchor = hash && $container.find(`.note[id="${hash}"]`); if (anchor && anchor.length > 0) { const notesContent = anchor.closest('.notes_content'); const lineType = notesContent.hasClass('new') ? 'new' : 'old'; @@ -294,6 +304,7 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; forceShow: true, }); anchor[0].scrollIntoView(); + window.gl.utils.handleLocationHash(); // We have multiple elements on the page with `#note_xxx` // (discussion and diff tabs) and `:target` only applies to the first anchor.addClass('target'); diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 6a6dabfd00c..34476f3303f 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -4,7 +4,7 @@ no-unused-expressions, quotes, max-len, one-var, one-var-declaration-per-line, default-case, prefer-template, consistent-return, no-alert, no-return-assign, no-param-reassign, prefer-arrow-callback, no-else-return, comma-dangle, no-new, brace-style, no-lonely-if, vars-on-top, no-unused-vars, no-sequences, no-shadow, -newline-per-chained-call, no-useless-escape */ +newline-per-chained-call, no-useless-escape, class-methods-use-this */ /* global Flash */ /* global Autosave */ /* global ResolveService */ @@ -25,1507 +25,1489 @@ import './task_list'; window.autosize = autosize; window.Dropzone = Dropzone; -const normalizeNewlines = function(str) { +function normalizeNewlines(str) { return str.replace(/\r\n/g, '\n'); -}; - -(function() { - this.Notes = (function() { - const MAX_VISIBLE_COMMIT_LIST_COUNT = 3; - const REGEX_QUICK_ACTIONS = /^\/\w+.*$/gm; - - Notes.interval = null; - - function Notes(notes_url, note_ids, last_fetched_at, view, enableGFM = true) { - this.updateTargetButtons = this.updateTargetButtons.bind(this); - this.updateComment = this.updateComment.bind(this); - this.visibilityChange = this.visibilityChange.bind(this); - this.cancelDiscussionForm = this.cancelDiscussionForm.bind(this); - this.onAddDiffNote = this.onAddDiffNote.bind(this); - this.setupDiscussionNoteForm = this.setupDiscussionNoteForm.bind(this); - this.onReplyToDiscussionNote = this.onReplyToDiscussionNote.bind(this); - this.removeNote = this.removeNote.bind(this); - this.cancelEdit = this.cancelEdit.bind(this); - this.updateNote = this.updateNote.bind(this); - this.addDiscussionNote = this.addDiscussionNote.bind(this); - this.addNoteError = this.addNoteError.bind(this); - this.addNote = this.addNote.bind(this); - this.resetMainTargetForm = this.resetMainTargetForm.bind(this); - this.refresh = this.refresh.bind(this); - this.keydownNoteText = this.keydownNoteText.bind(this); - this.toggleCommitList = this.toggleCommitList.bind(this); - this.postComment = this.postComment.bind(this); - this.clearFlashWrapper = this.clearFlash.bind(this); - this.onHashChange = this.onHashChange.bind(this); - - this.notes_url = notes_url; - this.note_ids = note_ids; - this.enableGFM = enableGFM; - // Used to keep track of updated notes while people are editing things - this.updatedNotesTrackingMap = {}; - this.last_fetched_at = last_fetched_at; - this.noteable_url = document.URL; - this.notesCountBadge || (this.notesCountBadge = $('.issuable-details').find('.notes-tab .badge')); - this.basePollingInterval = 15000; - this.maxPollingSteps = 4; - - this.cleanBinding(); - this.addBinding(); - this.setPollingInterval(); - this.setupMainTargetNoteForm(); - this.taskList = new gl.TaskList({ - dataType: 'note', - fieldName: 'note', - selector: '.notes' - }); - this.collapseLongCommitList(); - this.setViewType(view); - - // We are in the Merge Requests page so we need another edit form for Changes tab - if (gl.utils.getPagePath(1) === 'merge_requests') { - $('.note-edit-form').clone() - .addClass('mr-note-edit-form').insertAfter('.note-edit-form'); - } +} + +const MAX_VISIBLE_COMMIT_LIST_COUNT = 3; +const REGEX_QUICK_ACTIONS = /^\/\w+.*$/gm; + +export default class Notes { + constructor(notes_url, note_ids, last_fetched_at, view, enableGFM = true) { + this.updateTargetButtons = this.updateTargetButtons.bind(this); + this.updateComment = this.updateComment.bind(this); + this.visibilityChange = this.visibilityChange.bind(this); + this.cancelDiscussionForm = this.cancelDiscussionForm.bind(this); + this.onAddDiffNote = this.onAddDiffNote.bind(this); + this.setupDiscussionNoteForm = this.setupDiscussionNoteForm.bind(this); + this.onReplyToDiscussionNote = this.onReplyToDiscussionNote.bind(this); + this.removeNote = this.removeNote.bind(this); + this.cancelEdit = this.cancelEdit.bind(this); + this.updateNote = this.updateNote.bind(this); + this.addDiscussionNote = this.addDiscussionNote.bind(this); + this.addNoteError = this.addNoteError.bind(this); + this.addNote = this.addNote.bind(this); + this.resetMainTargetForm = this.resetMainTargetForm.bind(this); + this.refresh = this.refresh.bind(this); + this.keydownNoteText = this.keydownNoteText.bind(this); + this.toggleCommitList = this.toggleCommitList.bind(this); + this.postComment = this.postComment.bind(this); + this.clearFlashWrapper = this.clearFlash.bind(this); + this.onHashChange = this.onHashChange.bind(this); + + this.notes_url = notes_url; + this.note_ids = note_ids; + this.enableGFM = enableGFM; + // Used to keep track of updated notes while people are editing things + this.updatedNotesTrackingMap = {}; + this.last_fetched_at = last_fetched_at; + this.noteable_url = document.URL; + this.notesCountBadge || (this.notesCountBadge = $('.issuable-details').find('.notes-tab .badge')); + this.basePollingInterval = 15000; + this.maxPollingSteps = 4; + + this.cleanBinding(); + this.addBinding(); + this.setPollingInterval(); + this.setupMainTargetNoteForm(); + this.taskList = new gl.TaskList({ + dataType: 'note', + fieldName: 'note', + selector: '.notes' + }); + this.collapseLongCommitList(); + this.setViewType(view); + + // We are in the Merge Requests page so we need another edit form for Changes tab + if (gl.utils.getPagePath(1) === 'merge_requests') { + $('.note-edit-form').clone() + .addClass('mr-note-edit-form').insertAfter('.note-edit-form'); + } + } + + setViewType(view) { + this.view = Cookies.get('diff_view') || view; + } + + addBinding() { + // Edit note link + $(document).on('click', '.js-note-edit', this.showEditForm.bind(this)); + $(document).on('click', '.note-edit-cancel', this.cancelEdit); + // Reopen and close actions for Issue/MR combined with note form submit + $(document).on('click', '.js-comment-submit-button', this.postComment); + $(document).on('click', '.js-comment-save-button', this.updateComment); + $(document).on('keyup input', '.js-note-text', this.updateTargetButtons); + // resolve a discussion + $(document).on('click', '.js-comment-resolve-button', this.postComment); + // remove a note (in general) + $(document).on('click', '.js-note-delete', this.removeNote); + // delete note attachment + $(document).on('click', '.js-note-attachment-delete', this.removeAttachment); + // reset main target form when clicking discard + $(document).on('click', '.js-note-discard', this.resetMainTargetForm); + // update the file name when an attachment is selected + $(document).on('change', '.js-note-attachment-input', this.updateFormAttachment); + // reply to diff/discussion notes + $(document).on('click', '.js-discussion-reply-button', this.onReplyToDiscussionNote); + // add diff note + $(document).on('click', '.js-add-diff-note-button', this.onAddDiffNote); + // hide diff note form + $(document).on('click', '.js-close-discussion-note-form', this.cancelDiscussionForm); + // toggle commit list + $(document).on('click', '.system-note-commit-list-toggler', this.toggleCommitList); + // fetch notes when tab becomes visible + $(document).on('visibilitychange', this.visibilityChange); + // when issue status changes, we need to refresh data + $(document).on('issuable:change', this.refresh); + // ajax:events that happen on Form when actions like Reopen, Close are performed on Issues and MRs. + $(document).on('ajax:success', '.js-main-target-form', this.addNote); + $(document).on('ajax:success', '.js-discussion-note-form', this.addDiscussionNote); + $(document).on('ajax:success', '.js-main-target-form', this.resetMainTargetForm); + $(document).on('ajax:complete', '.js-main-target-form', this.reenableTargetFormSubmitButton); + // when a key is clicked on the notes + $(document).on('keydown', '.js-note-text', this.keydownNoteText); + // When the URL fragment/hash has changed, `#note_xxx` + return $(window).on('hashchange', this.onHashChange); + } + + cleanBinding() { + $(document).off('click', '.js-note-edit'); + $(document).off('click', '.note-edit-cancel'); + $(document).off('click', '.js-note-delete'); + $(document).off('click', '.js-note-attachment-delete'); + $(document).off('click', '.js-discussion-reply-button'); + $(document).off('click', '.js-add-diff-note-button'); + $(document).off('visibilitychange'); + $(document).off('keyup input', '.js-note-text'); + $(document).off('click', '.js-note-target-reopen'); + $(document).off('click', '.js-note-target-close'); + $(document).off('click', '.js-note-discard'); + $(document).off('keydown', '.js-note-text'); + $(document).off('click', '.js-comment-resolve-button'); + $(document).off('click', '.system-note-commit-list-toggler'); + $(document).off('ajax:success', '.js-main-target-form'); + $(document).off('ajax:success', '.js-discussion-note-form'); + $(document).off('ajax:complete', '.js-main-target-form'); + $(window).off('hashchange', this.onHashChange); + } + + static initCommentTypeToggle(form) { + const dropdownTrigger = form.querySelector('.js-comment-type-dropdown .dropdown-toggle'); + const dropdownList = form.querySelector('.js-comment-type-dropdown .dropdown-menu'); + const noteTypeInput = form.querySelector('#note_type'); + const submitButton = form.querySelector('.js-comment-type-dropdown .js-comment-submit-button'); + const closeButton = form.querySelector('.js-note-target-close'); + const reopenButton = form.querySelector('.js-note-target-reopen'); + + const commentTypeToggle = new CommentTypeToggle({ + dropdownTrigger, + dropdownList, + noteTypeInput, + submitButton, + closeButton, + reopenButton, + }); + + commentTypeToggle.initDroplab(); + } + + keydownNoteText(e) { + var $textarea, discussionNoteForm, editNote, myLastNote, myLastNoteEditBtn, newText, originalText; + if (gl.utils.isMetaKey(e)) { + return; } - Notes.prototype.setViewType = function(view) { - this.view = Cookies.get('diff_view') || view; - }; - - Notes.prototype.addBinding = function() { - // Edit note link - $(document).on('click', '.js-note-edit', this.showEditForm.bind(this)); - $(document).on('click', '.note-edit-cancel', this.cancelEdit); - // Reopen and close actions for Issue/MR combined with note form submit - $(document).on('click', '.js-comment-submit-button', this.postComment); - $(document).on('click', '.js-comment-save-button', this.updateComment); - $(document).on('keyup input', '.js-note-text', this.updateTargetButtons); - // resolve a discussion - $(document).on('click', '.js-comment-resolve-button', this.postComment); - // remove a note (in general) - $(document).on('click', '.js-note-delete', this.removeNote); - // delete note attachment - $(document).on('click', '.js-note-attachment-delete', this.removeAttachment); - // reset main target form when clicking discard - $(document).on('click', '.js-note-discard', this.resetMainTargetForm); - // update the file name when an attachment is selected - $(document).on('change', '.js-note-attachment-input', this.updateFormAttachment); - // reply to diff/discussion notes - $(document).on('click', '.js-discussion-reply-button', this.onReplyToDiscussionNote); - // add diff note - $(document).on('click', '.js-add-diff-note-button', this.onAddDiffNote); - // hide diff note form - $(document).on('click', '.js-close-discussion-note-form', this.cancelDiscussionForm); - // toggle commit list - $(document).on('click', '.system-note-commit-list-toggler', this.toggleCommitList); - // fetch notes when tab becomes visible - $(document).on('visibilitychange', this.visibilityChange); - // when issue status changes, we need to refresh data - $(document).on('issuable:change', this.refresh); - // ajax:events that happen on Form when actions like Reopen, Close are performed on Issues and MRs. - $(document).on('ajax:success', '.js-main-target-form', this.addNote); - $(document).on('ajax:success', '.js-discussion-note-form', this.addDiscussionNote); - $(document).on('ajax:success', '.js-main-target-form', this.resetMainTargetForm); - $(document).on('ajax:complete', '.js-main-target-form', this.reenableTargetFormSubmitButton); - // when a key is clicked on the notes - $(document).on('keydown', '.js-note-text', this.keydownNoteText); - // When the URL fragment/hash has changed, `#note_xxx` - return $(window).on('hashchange', this.onHashChange); - }; - - Notes.prototype.cleanBinding = function() { - $(document).off('click', '.js-note-edit'); - $(document).off('click', '.note-edit-cancel'); - $(document).off('click', '.js-note-delete'); - $(document).off('click', '.js-note-attachment-delete'); - $(document).off('click', '.js-discussion-reply-button'); - $(document).off('click', '.js-add-diff-note-button'); - $(document).off('visibilitychange'); - $(document).off('keyup input', '.js-note-text'); - $(document).off('click', '.js-note-target-reopen'); - $(document).off('click', '.js-note-target-close'); - $(document).off('click', '.js-note-discard'); - $(document).off('keydown', '.js-note-text'); - $(document).off('click', '.js-comment-resolve-button'); - $(document).off('click', '.system-note-commit-list-toggler'); - $(document).off('ajax:success', '.js-main-target-form'); - $(document).off('ajax:success', '.js-discussion-note-form'); - $(document).off('ajax:complete', '.js-main-target-form'); - $(window).off('hashchange', this.onHashChange); - }; - - Notes.initCommentTypeToggle = function (form) { - const dropdownTrigger = form.querySelector('.js-comment-type-dropdown .dropdown-toggle'); - const dropdownList = form.querySelector('.js-comment-type-dropdown .dropdown-menu'); - const noteTypeInput = form.querySelector('#note_type'); - const submitButton = form.querySelector('.js-comment-type-dropdown .js-comment-submit-button'); - const closeButton = form.querySelector('.js-note-target-close'); - const reopenButton = form.querySelector('.js-note-target-reopen'); - - const commentTypeToggle = new CommentTypeToggle({ - dropdownTrigger, - dropdownList, - noteTypeInput, - submitButton, - closeButton, - reopenButton, - }); - - commentTypeToggle.initDroplab(); - }; - - Notes.prototype.keydownNoteText = function(e) { - var $textarea, discussionNoteForm, editNote, myLastNote, myLastNoteEditBtn, newText, originalText; - if (gl.utils.isMetaKey(e)) { - return; - } - - $textarea = $(e.target); - // Edit previous note when UP arrow is hit - switch (e.which) { - case 38: + $textarea = $(e.target); + // Edit previous note when UP arrow is hit + switch (e.which) { + case 38: + if ($textarea.val() !== '') { + return; + } + myLastNote = $(`li.note[data-author-id='${gon.current_user_id}'][data-editable]:last`, $textarea.closest('.note, .notes_holder, #notes')); + if (myLastNote.length) { + myLastNoteEditBtn = myLastNote.find('.js-note-edit'); + return myLastNoteEditBtn.trigger('click', [true, myLastNote]); + } + break; + // Cancel creating diff note or editing any note when ESCAPE is hit + case 27: + discussionNoteForm = $textarea.closest('.js-discussion-note-form'); + if (discussionNoteForm.length) { if ($textarea.val() !== '') { - return; - } - myLastNote = $(`li.note[data-author-id='${gon.current_user_id}'][data-editable]:last`, $textarea.closest('.note, #notes')); - if (myLastNote.length) { - myLastNoteEditBtn = myLastNote.find('.js-note-edit'); - return myLastNoteEditBtn.trigger('click', [true, myLastNote]); - } - break; - // Cancel creating diff note or editing any note when ESCAPE is hit - case 27: - discussionNoteForm = $textarea.closest('.js-discussion-note-form'); - if (discussionNoteForm.length) { - if ($textarea.val() !== '') { - if (!confirm('Are you sure you want to cancel creating this comment?')) { - return; - } + if (!confirm('Are you sure you want to cancel creating this comment?')) { + return; } - this.removeDiscussionNoteForm(discussionNoteForm); - return; } - editNote = $textarea.closest('.note'); - if (editNote.length) { - originalText = $textarea.closest('form').data('original-note'); - newText = $textarea.val(); - if (originalText !== newText) { - if (!confirm('Are you sure you want to cancel editing this comment?')) { - return; - } + this.removeDiscussionNoteForm(discussionNoteForm); + return; + } + editNote = $textarea.closest('.note'); + if (editNote.length) { + originalText = $textarea.closest('form').data('original-note'); + newText = $textarea.val(); + if (originalText !== newText) { + if (!confirm('Are you sure you want to cancel editing this comment?')) { + return; } - return this.removeNoteEditForm(editNote); } - } - }; + return this.removeNoteEditForm(editNote); + } + } + } - Notes.prototype.initRefresh = function() { + initRefresh() { + if (Notes.interval) { clearInterval(Notes.interval); - return Notes.interval = setInterval((function(_this) { - return function() { - return _this.refresh(); - }; - })(this), this.pollingInterval); - }; + } + return Notes.interval = setInterval((function(_this) { + return function() { + return _this.refresh(); + }; + })(this), this.pollingInterval); + } - Notes.prototype.refresh = function() { - if (!document.hidden) { - return this.getContent(); - } - }; + refresh() { + if (!document.hidden) { + return this.getContent(); + } + } - Notes.prototype.getContent = function() { - if (this.refreshing) { - return; - } - this.refreshing = true; - return $.ajax({ - url: this.notes_url, - headers: { 'X-Last-Fetched-At': this.last_fetched_at }, - dataType: 'json', - success: (function(_this) { - return function(data) { - var notes; - notes = data.notes; - _this.last_fetched_at = data.last_fetched_at; - _this.setPollingInterval(data.notes.length); - return $.each(notes, function(i, note) { - _this.renderNote(note); - }); - }; - })(this) - }).always((function(_this) { - return function() { - return _this.refreshing = false; + getContent() { + if (this.refreshing) { + return; + } + this.refreshing = true; + return $.ajax({ + url: this.notes_url, + headers: { 'X-Last-Fetched-At': this.last_fetched_at }, + dataType: 'json', + success: (function(_this) { + return function(data) { + var notes; + notes = data.notes; + _this.last_fetched_at = data.last_fetched_at; + _this.setPollingInterval(data.notes.length); + return $.each(notes, function(i, note) { + _this.renderNote(note); + }); }; - })(this)); - }; - - /* - Increase @pollingInterval up to 120 seconds on every function call, - if `shouldReset` has a truthy value, 'null' or 'undefined' the variable - will reset to @basePollingInterval. - - Note: this function is used to gradually increase the polling interval - if there aren't new notes coming from the server - */ - - Notes.prototype.setPollingInterval = function(shouldReset) { - var nthInterval; - if (shouldReset == null) { - shouldReset = true; - } - nthInterval = this.basePollingInterval * Math.pow(2, this.maxPollingSteps - 1); - if (shouldReset) { - this.pollingInterval = this.basePollingInterval; - } else if (this.pollingInterval < nthInterval) { - this.pollingInterval *= 2; + })(this) + }).always((function(_this) { + return function() { + return _this.refreshing = false; + }; + })(this)); + } + + /** + * Increase @pollingInterval up to 120 seconds on every function call, + * if `shouldReset` has a truthy value, 'null' or 'undefined' the variable + * will reset to @basePollingInterval. + * + * Note: this function is used to gradually increase the polling interval + * if there aren't new notes coming from the server + */ + setPollingInterval(shouldReset) { + var nthInterval; + if (shouldReset == null) { + shouldReset = true; + } + nthInterval = this.basePollingInterval * Math.pow(2, this.maxPollingSteps - 1); + if (shouldReset) { + this.pollingInterval = this.basePollingInterval; + } else if (this.pollingInterval < nthInterval) { + this.pollingInterval *= 2; + } + return this.initRefresh(); + } + + handleQuickActions(noteEntity) { + var votesBlock; + if (noteEntity.commands_changes) { + if ('merge' in noteEntity.commands_changes) { + Notes.checkMergeRequestStatus(); } - return this.initRefresh(); - }; - - Notes.prototype.handleQuickActions = function(noteEntity) { - var votesBlock; - if (noteEntity.commands_changes) { - if ('merge' in noteEntity.commands_changes) { - Notes.checkMergeRequestStatus(); - } - if ('emoji_award' in noteEntity.commands_changes) { - votesBlock = $('.js-awards-block').eq(0); - gl.awardsHandler.addAwardToEmojiBar(votesBlock, noteEntity.commands_changes.emoji_award); - return gl.awardsHandler.scrollToAwards(); - } + if ('emoji_award' in noteEntity.commands_changes) { + votesBlock = $('.js-awards-block').eq(0); + gl.awardsHandler.addAwardToEmojiBar(votesBlock, noteEntity.commands_changes.emoji_award); + return gl.awardsHandler.scrollToAwards(); } - }; - - Notes.prototype.setupNewNote = function($note) { - // Update datetime format on the recent note - gl.utils.localTimeAgo($note.find('.js-timeago'), false); - - this.collapseLongCommitList(); - this.taskList.init(); - - // This stops the note highlight, #note_xxx`, from being removed after real time update - // The `:target` selector does not re-evaluate after we replace element in the DOM - Notes.updateNoteTargetSelector($note); - this.$noteToCleanHighlight = $note; - }; - - Notes.prototype.onHashChange = function() { - if (this.$noteToCleanHighlight) { - Notes.updateNoteTargetSelector(this.$noteToCleanHighlight); - } - - this.$noteToCleanHighlight = null; - }; - - Notes.updateNoteTargetSelector = function($note) { - const hash = gl.utils.getLocationHash(); - // Needs to be an explicit true/false for the jQuery `toggleClass(force)` - const addTargetClass = Boolean(hash && $note.filter(`#${hash}`).length > 0); - $note.toggleClass('target', addTargetClass); - }; - - /* - Render note in main comments area. + } + } - Note: for rendering inline notes use renderDiscussionNote - */ + setupNewNote($note) { + // Update datetime format on the recent note + gl.utils.localTimeAgo($note.find('.js-timeago'), false); - Notes.prototype.renderNote = function(noteEntity, $form, $notesList = $('.main-notes-list')) { - if (noteEntity.discussion_html) { - return this.renderDiscussionNote(noteEntity, $form); - } + this.collapseLongCommitList(); + this.taskList.init(); - if (!noteEntity.valid) { - if (noteEntity.errors.commands_only) { - this.addFlash(noteEntity.errors.commands_only, 'notice', this.parentTimeline); - this.refresh(); - } - return; - } + // This stops the note highlight, #note_xxx`, from being removed after real time update + // The `:target` selector does not re-evaluate after we replace element in the DOM + Notes.updateNoteTargetSelector($note); + this.$noteToCleanHighlight = $note; + } - const $note = $notesList.find(`#note_${noteEntity.id}`); - if (Notes.isNewNote(noteEntity, this.note_ids)) { - this.note_ids.push(noteEntity.id); + onHashChange() { + if (this.$noteToCleanHighlight) { + Notes.updateNoteTargetSelector(this.$noteToCleanHighlight); + } - if ($notesList.length) { - $notesList.find('.system-note.being-posted').remove(); - } - const $newNote = Notes.animateAppendNote(noteEntity.html, $notesList); + this.$noteToCleanHighlight = null; + } + + static updateNoteTargetSelector($note) { + const hash = gl.utils.getLocationHash(); + // Needs to be an explicit true/false for the jQuery `toggleClass(force)` + const addTargetClass = Boolean(hash && $note.filter(`#${hash}`).length > 0); + $note.toggleClass('target', addTargetClass); + } + + /** + * Render note in main comments area. + * + * Note: for rendering inline notes use renderDiscussionNote + */ + renderNote(noteEntity, $form, $notesList = $('.main-notes-list')) { + if (noteEntity.discussion_html) { + return this.renderDiscussionNote(noteEntity, $form); + } - this.setupNewNote($newNote); + if (!noteEntity.valid) { + if (noteEntity.errors.commands_only) { + this.addFlash(noteEntity.errors.commands_only, 'notice', this.parentTimeline); this.refresh(); - return this.updateNotesCount(1); } - // The server can send the same update multiple times so we need to make sure to only update once per actual update. - else if (Notes.isUpdatedNote(noteEntity, $note)) { - const isEditing = $note.hasClass('is-editing'); - const initialContent = normalizeNewlines( - $note.find('.original-note-content').text().trim() - ); - const $textarea = $note.find('.js-note-text'); - const currentContent = $textarea.val(); - // There can be CRLF vs LF mismatches if we don't sanitize and compare the same way - const sanitizedNoteNote = normalizeNewlines(noteEntity.note); - const isTextareaUntouched = currentContent === initialContent || currentContent === sanitizedNoteNote; - - if (isEditing && isTextareaUntouched) { - $textarea.val(noteEntity.note); - this.updatedNotesTrackingMap[noteEntity.id] = noteEntity; - } - else if (isEditing && !isTextareaUntouched) { - this.putConflictEditWarningInPlace(noteEntity, $note); - this.updatedNotesTrackingMap[noteEntity.id] = noteEntity; - } - else { - const $updatedNote = Notes.animateUpdateNote(noteEntity.html, $note); - this.setupNewNote($updatedNote); - } - } - }; - - Notes.prototype.isParallelView = function() { - return Cookies.get('diff_view') === 'parallel'; - }; - - /* - Render note in discussion area. - - Note: for rendering inline notes use renderDiscussionNote - */ + return; + } - Notes.prototype.renderDiscussionNote = function(noteEntity, $form) { - var discussionContainer, form, row, lineType, diffAvatarContainer; - if (!Notes.isNewNote(noteEntity, this.note_ids)) { - return; - } + const $note = $notesList.find(`#note_${noteEntity.id}`); + if (Notes.isNewNote(noteEntity, this.note_ids)) { this.note_ids.push(noteEntity.id); - form = $form || $(`.js-discussion-note-form[data-discussion-id="${noteEntity.discussion_id}"]`); - row = form.closest('tr'); - lineType = this.isParallelView() ? form.find('#line_type').val() : 'old'; - diffAvatarContainer = row.prevAll('.line_holder').first().find('.js-avatar-container.' + lineType + '_line'); - // is this the first note of discussion? - discussionContainer = $(`.notes[data-discussion-id="${noteEntity.discussion_id}"]`); - if (!discussionContainer.length) { - discussionContainer = form.closest('.discussion').find('.notes'); - } - if (discussionContainer.length === 0) { - if (noteEntity.diff_discussion_html) { - var $discussion = $(noteEntity.diff_discussion_html).renderGFM(); - - if (!this.isParallelView() || row.hasClass('js-temp-notes-holder')) { - // insert the note and the reply button after the temp row - row.after($discussion); - } else { - // Merge new discussion HTML in - var $notes = $discussion.find(`.notes[data-discussion-id="${noteEntity.discussion_id}"]`); - var contentContainerClass = '.' + $notes.closest('.notes_content') - .attr('class') - .split(' ') - .join('.'); - - row.find(contentContainerClass + ' .content').append($notes.closest('.content').children()); - } - } - // Init discussion on 'Discussion' page if it is merge request page - const page = $('body').attr('data-page'); - if ((page && page.indexOf('projects:merge_request') !== -1) || !noteEntity.diff_discussion_html) { - Notes.animateAppendNote(noteEntity.discussion_html, $('.main-notes-list')); - } - } else { - // append new note to all matching discussions - Notes.animateAppendNote(noteEntity.html, discussionContainer); - } - if (typeof gl.diffNotesCompileComponents !== 'undefined' && noteEntity.discussion_resolvable) { - gl.diffNotesCompileComponents(); - this.renderDiscussionAvatar(diffAvatarContainer, noteEntity); + if ($notesList.length) { + $notesList.find('.system-note.being-posted').remove(); } + const $newNote = Notes.animateAppendNote(noteEntity.html, $notesList); - gl.utils.localTimeAgo($('.js-timeago'), false); - Notes.checkMergeRequestStatus(); + this.setupNewNote($newNote); + this.refresh(); return this.updateNotesCount(1); - }; - - Notes.prototype.getLineHolder = function(changesDiscussionContainer) { - return $(changesDiscussionContainer).closest('.notes_holder') - .prevAll('.line_holder') - .first() - .get(0); - }; - - Notes.prototype.renderDiscussionAvatar = function(diffAvatarContainer, noteEntity) { - var commentButton = diffAvatarContainer.find('.js-add-diff-note-button'); - var avatarHolder = diffAvatarContainer.find('.diff-comment-avatar-holders'); - - if (!avatarHolder.length) { - avatarHolder = document.createElement('diff-note-avatars'); - avatarHolder.setAttribute('discussion-id', noteEntity.discussion_id); - - diffAvatarContainer.append(avatarHolder); + } + // The server can send the same update multiple times so we need to make sure to only update once per actual update. + else if (Notes.isUpdatedNote(noteEntity, $note)) { + const isEditing = $note.hasClass('is-editing'); + const initialContent = normalizeNewlines( + $note.find('.original-note-content').text().trim() + ); + const $textarea = $note.find('.js-note-text'); + const currentContent = $textarea.val(); + // There can be CRLF vs LF mismatches if we don't sanitize and compare the same way + const sanitizedNoteNote = normalizeNewlines(noteEntity.note); + const isTextareaUntouched = currentContent === initialContent || currentContent === sanitizedNoteNote; - gl.diffNotesCompileComponents(); + if (isEditing && isTextareaUntouched) { + $textarea.val(noteEntity.note); + this.updatedNotesTrackingMap[noteEntity.id] = noteEntity; } - - if (commentButton.length) { - commentButton.remove(); + else if (isEditing && !isTextareaUntouched) { + this.putConflictEditWarningInPlace(noteEntity, $note); + this.updatedNotesTrackingMap[noteEntity.id] = noteEntity; } - }; - - /* - Called in response the main target form has been successfully submitted. - - Removes any errors. - Resets text and preview. - Resets buttons. - */ - - Notes.prototype.resetMainTargetForm = function(e) { - var form; - form = $('.js-main-target-form'); - // remove validation errors - form.find('.js-errors').remove(); - // reset text and preview - form.find('.js-md-write-button').click(); - form.find('.js-note-text').val('').trigger('input'); - form.find('.js-note-text').data('autosave').reset(); - - var event = document.createEvent('Event'); - event.initEvent('autosize:update', true, false); - form.find('.js-autosize')[0].dispatchEvent(event); - - this.updateTargetButtons(e); - }; - - Notes.prototype.reenableTargetFormSubmitButton = function() { - var form; - form = $('.js-main-target-form'); - return form.find('.js-note-text').trigger('input'); - }; - - /* - Shows the main form and does some setup on it. - - Sets some hidden fields in the form. - */ - - Notes.prototype.setupMainTargetNoteForm = function() { - var form; - // find the form - form = $('.js-new-note-form'); - // Set a global clone of the form for later cloning - this.formClone = form.clone(); - // show the form - this.setupNoteForm(form); - // fix classes - form.removeClass('js-new-note-form'); - form.addClass('js-main-target-form'); - form.find('#note_line_code').remove(); - form.find('#note_position').remove(); - form.find('#note_type').val(''); - form.find('#in_reply_to_discussion_id').remove(); - form.find('.js-comment-resolve-button').closest('comment-and-resolve-btn').remove(); - this.parentTimeline = form.parents('.timeline'); - - if (form.length) { - Notes.initCommentTypeToggle(form.get(0)); - } - }; - - /* - General note form setup. - - deactivates the submit button when text is empty - hides the preview button when text is empty - setup GFM auto complete - show the form - */ - - Notes.prototype.setupNoteForm = function(form) { - var textarea, key; - new gl.GLForm(form, this.enableGFM); - textarea = form.find('.js-note-text'); - key = [ - 'Note', - form.find('#note_noteable_type').val(), - form.find('#note_noteable_id').val(), - form.find('#note_commit_id').val(), - form.find('#note_type').val(), - form.find('#in_reply_to_discussion_id').val(), - - // LegacyDiffNote - form.find('#note_line_code').val(), - - // DiffNote - form.find('#note_position').val() - ]; - return new Autosave(textarea, key); - }; - - /* - Called in response to the new note form being submitted - - Adds new note to list. - */ - - Notes.prototype.addNote = function($form, note) { - return this.renderNote(note); - }; - - Notes.prototype.addNoteError = function($form) { - let formParentTimeline; - if ($form.hasClass('js-main-target-form')) { - formParentTimeline = $form.parents('.timeline'); - } else if ($form.hasClass('js-discussion-note-form')) { - formParentTimeline = $form.closest('.discussion-notes').find('.notes'); + else { + const $updatedNote = Notes.animateUpdateNote(noteEntity.html, $note); + this.setupNewNote($updatedNote); } - return this.addFlash('Your comment could not be submitted! Please check your network connection and try again.', 'alert', formParentTimeline); - }; - - Notes.prototype.updateNoteError = $parentTimeline => new Flash('Your comment could not be updated! Please check your network connection and try again.'); - - /* - Called in response to the new note form being submitted - - Adds new note to list. - */ - - Notes.prototype.addDiscussionNote = function($form, note, isNewDiffComment) { - if ($form.attr('data-resolve-all') != null) { - var projectPath = $form.data('project-path'); - var discussionId = $form.data('discussion-id'); - var mergeRequestId = $form.data('noteable-iid'); + } + } + + isParallelView() { + return Cookies.get('diff_view') === 'parallel'; + } + + /** + * Render note in discussion area. + * + * Note: for rendering inline notes use renderDiscussionNote + */ + renderDiscussionNote(noteEntity, $form) { + var discussionContainer, form, row, lineType, diffAvatarContainer; + if (!Notes.isNewNote(noteEntity, this.note_ids)) { + return; + } + this.note_ids.push(noteEntity.id); + form = $form || $(`.js-discussion-note-form[data-discussion-id="${noteEntity.discussion_id}"]`); + row = form.closest('tr'); + lineType = this.isParallelView() ? form.find('#line_type').val() : 'old'; + diffAvatarContainer = row.prevAll('.line_holder').first().find('.js-avatar-container.' + lineType + '_line'); + // is this the first note of discussion? + discussionContainer = $(`.notes[data-discussion-id="${noteEntity.discussion_id}"]`); + if (!discussionContainer.length) { + discussionContainer = form.closest('.discussion').find('.notes'); + } + if (discussionContainer.length === 0) { + if (noteEntity.diff_discussion_html) { + var $discussion = $(noteEntity.diff_discussion_html).renderGFM(); - if (ResolveService != null) { - ResolveService.toggleResolveForDiscussion(mergeRequestId, discussionId); + if (!this.isParallelView() || row.hasClass('js-temp-notes-holder')) { + // insert the note and the reply button after the temp row + row.after($discussion); + } else { + // Merge new discussion HTML in + var $notes = $discussion.find(`.notes[data-discussion-id="${noteEntity.discussion_id}"]`); + var contentContainerClass = '.' + $notes.closest('.notes_content') + .attr('class') + .split(' ') + .join('.'); + + row.find(contentContainerClass + ' .content').append($notes.closest('.content').children()); } } - - this.renderNote(note, $form); - // cleanup after successfully creating a diff/discussion note - if (isNewDiffComment) { - this.removeDiscussionNoteForm($form); + // Init discussion on 'Discussion' page if it is merge request page + const page = $('body').attr('data-page'); + if ((page && page.indexOf('projects:merge_request') !== -1) || !noteEntity.diff_discussion_html) { + Notes.animateAppendNote(noteEntity.discussion_html, $('.main-notes-list')); } - }; + } else { + // append new note to all matching discussions + Notes.animateAppendNote(noteEntity.html, discussionContainer); + } - /* - Called in response to the edit note form being submitted + if (typeof gl.diffNotesCompileComponents !== 'undefined' && noteEntity.discussion_resolvable) { + gl.diffNotesCompileComponents(); + this.renderDiscussionAvatar(diffAvatarContainer, noteEntity); + } - Updates the current note field. - */ + gl.utils.localTimeAgo($('.js-timeago'), false); + Notes.checkMergeRequestStatus(); + return this.updateNotesCount(1); + } - Notes.prototype.updateNote = function(noteEntity, $targetNote) { - var $noteEntityEl, $note_li; - // Convert returned HTML to a jQuery object so we can modify it further - $noteEntityEl = $(noteEntity.html); - $noteEntityEl.addClass('fade-in-full'); - this.revertNoteEditForm($targetNote); - $noteEntityEl.renderGFM(); - // Find the note's `li` element by ID and replace it with the updated HTML - $note_li = $('.note-row-' + noteEntity.id); + getLineHolder(changesDiscussionContainer) { + return $(changesDiscussionContainer).closest('.notes_holder') + .prevAll('.line_holder') + .first() + .get(0); + } - $note_li.replaceWith($noteEntityEl); - this.setupNewNote($noteEntityEl); + renderDiscussionAvatar(diffAvatarContainer, noteEntity) { + var commentButton = diffAvatarContainer.find('.js-add-diff-note-button'); + var avatarHolder = diffAvatarContainer.find('.diff-comment-avatar-holders'); - if (typeof gl.diffNotesCompileComponents !== 'undefined') { - gl.diffNotesCompileComponents(); - } - }; + if (!avatarHolder.length) { + avatarHolder = document.createElement('diff-note-avatars'); + avatarHolder.setAttribute('discussion-id', noteEntity.discussion_id); - Notes.prototype.checkContentToAllowEditing = function($el) { - var initialContent = $el.find('.original-note-content').text().trim(); - var currentContent = $el.find('.js-note-text').val(); - var isAllowed = true; + diffAvatarContainer.append(avatarHolder); - if (currentContent === initialContent) { - this.removeNoteEditForm($el); - } - else { - var $buttons = $el.find('.note-form-actions'); - var isWidgetVisible = gl.utils.isInViewport($el.get(0)); - - if (!isWidgetVisible) { - gl.utils.scrollToElement($el); - } + gl.diffNotesCompileComponents(); + } - $el.find('.js-finish-edit-warning').show(); - isAllowed = false; - } + if (commentButton.length) { + commentButton.remove(); + } + } + + /** + * Called in response the main target form has been successfully submitted. + * + * Removes any errors. + * Resets text and preview. + * Resets buttons. + */ + resetMainTargetForm(e) { + var form; + form = $('.js-main-target-form'); + // remove validation errors + form.find('.js-errors').remove(); + // reset text and preview + form.find('.js-md-write-button').click(); + form.find('.js-note-text').val('').trigger('input'); + form.find('.js-note-text').data('autosave').reset(); + + var event = document.createEvent('Event'); + event.initEvent('autosize:update', true, false); + form.find('.js-autosize')[0].dispatchEvent(event); + + this.updateTargetButtons(e); + } + + reenableTargetFormSubmitButton() { + var form; + form = $('.js-main-target-form'); + return form.find('.js-note-text').trigger('input'); + } + + /** + * Shows the main form and does some setup on it. + * + * Sets some hidden fields in the form. + */ + setupMainTargetNoteForm() { + var form; + // find the form + form = $('.js-new-note-form'); + // Set a global clone of the form for later cloning + this.formClone = form.clone(); + // show the form + this.setupNoteForm(form); + // fix classes + form.removeClass('js-new-note-form'); + form.addClass('js-main-target-form'); + form.find('#note_line_code').remove(); + form.find('#note_position').remove(); + form.find('#note_type').val(''); + form.find('#in_reply_to_discussion_id').remove(); + form.find('.js-comment-resolve-button').closest('comment-and-resolve-btn').remove(); + this.parentTimeline = form.parents('.timeline'); + + if (form.length) { + Notes.initCommentTypeToggle(form.get(0)); + } + } + + /** + * General note form setup. + * + * deactivates the submit button when text is empty + * hides the preview button when text is empty + * setup GFM auto complete + * show the form + */ + setupNoteForm(form) { + var textarea, key; + new gl.GLForm(form, this.enableGFM); + textarea = form.find('.js-note-text'); + key = [ + 'Note', + form.find('#note_noteable_type').val(), + form.find('#note_noteable_id').val(), + form.find('#note_commit_id').val(), + form.find('#note_type').val(), + form.find('#in_reply_to_discussion_id').val(), - return isAllowed; - }; + // LegacyDiffNote + form.find('#note_line_code').val(), - /* - Called in response to clicking the edit note link + // DiffNote + form.find('#note_position').val() + ]; + return new Autosave(textarea, key); + } + + /** + * Called in response to the new note form being submitted + * + * Adds new note to list. + */ + addNote($form, note) { + return this.renderNote(note); + } + + addNoteError($form) { + let formParentTimeline; + if ($form.hasClass('js-main-target-form')) { + formParentTimeline = $form.parents('.timeline'); + } else if ($form.hasClass('js-discussion-note-form')) { + formParentTimeline = $form.closest('.discussion-notes').find('.notes'); + } + return this.addFlash('Your comment could not be submitted! Please check your network connection and try again.', 'alert', formParentTimeline); + } + + updateNoteError($parentTimeline) { + new Flash('Your comment could not be updated! Please check your network connection and try again.'); + } + + /** + * Called in response to the new note form being submitted + * + * Adds new note to list. + */ + addDiscussionNote($form, note, isNewDiffComment) { + if ($form.attr('data-resolve-all') != null) { + var projectPath = $form.data('project-path'); + var discussionId = $form.data('discussion-id'); + var mergeRequestId = $form.data('noteable-iid'); + + if (ResolveService != null) { + ResolveService.toggleResolveForDiscussion(mergeRequestId, discussionId); + } + } - Replaces the note text with the note edit form - Adds a data attribute to the form with the original content of the note for cancellations - */ - Notes.prototype.showEditForm = function(e, scrollTo, myLastNote) { - e.preventDefault(); + this.renderNote(note, $form); + // cleanup after successfully creating a diff/discussion note + if (isNewDiffComment) { + this.removeDiscussionNoteForm($form); + } + } + + /** + * Called in response to the edit note form being submitted + * + * Updates the current note field. + */ + updateNote(noteEntity, $targetNote) { + var $noteEntityEl, $note_li; + // Convert returned HTML to a jQuery object so we can modify it further + $noteEntityEl = $(noteEntity.html); + $noteEntityEl.addClass('fade-in-full'); + this.revertNoteEditForm($targetNote); + $noteEntityEl.renderGFM(); + // Find the note's `li` element by ID and replace it with the updated HTML + $note_li = $('.note-row-' + noteEntity.id); + + $note_li.replaceWith($noteEntityEl); + this.setupNewNote($noteEntityEl); + + if (typeof gl.diffNotesCompileComponents !== 'undefined') { + gl.diffNotesCompileComponents(); + } + } - var $target = $(e.target); - var $editForm = $(this.getEditFormSelector($target)); - var $note = $target.closest('.note'); - var $currentlyEditing = $('.note.is-editing:visible'); + checkContentToAllowEditing($el) { + var initialContent = $el.find('.original-note-content').text().trim(); + var currentContent = $el.find('.js-note-text').val(); + var isAllowed = true; - if ($currentlyEditing.length) { - var isEditAllowed = this.checkContentToAllowEditing($currentlyEditing); + if (currentContent === initialContent) { + this.removeNoteEditForm($el); + } + else { + var $buttons = $el.find('.note-form-actions'); + var isWidgetVisible = gl.utils.isInViewport($el.get(0)); - if (!isEditAllowed) { - return; - } + if (!isWidgetVisible) { + gl.utils.scrollToElement($el); } - $note.find('.js-note-attachment-delete').show(); - $editForm.addClass('current-note-edit-form'); - $note.addClass('is-editing'); - this.putEditFormInPlace($target); - }; + $el.find('.js-finish-edit-warning').show(); + isAllowed = false; + } - /* - Called in response to clicking the edit note link + return isAllowed; + } - Hides edit form and restores the original note text to the editor textarea. - */ + /** + * Called in response to clicking the edit note link + * + * Replaces the note text with the note edit form + * Adds a data attribute to the form with the original content of the note for cancellations + */ + showEditForm(e, scrollTo, myLastNote) { + e.preventDefault(); - Notes.prototype.cancelEdit = function(e) { - e.preventDefault(); - const $target = $(e.target); - const $note = $target.closest('.note'); - const noteId = $note.attr('data-note-id'); + var $target = $(e.target); + var $editForm = $(this.getEditFormSelector($target)); + var $note = $target.closest('.note'); + var $currentlyEditing = $('.note.is-editing:visible'); - this.revertNoteEditForm($target); + if ($currentlyEditing.length) { + var isEditAllowed = this.checkContentToAllowEditing($currentlyEditing); - if (this.updatedNotesTrackingMap[noteId]) { - const $newNote = $(this.updatedNotesTrackingMap[noteId].html); - $note.replaceWith($newNote); - this.setupNewNote($newNote); - // Now that we have taken care of the update, clear it out - delete this.updatedNotesTrackingMap[noteId]; - } - else { - $note.find('.js-finish-edit-warning').hide(); - this.removeNoteEditForm($note); + if (!isEditAllowed) { + return; } - }; - - Notes.prototype.revertNoteEditForm = function($target) { - $target = $target || $('.note.is-editing:visible'); - var selector = this.getEditFormSelector($target); - var $editForm = $(selector); + } - $editForm.insertBefore('.notes-form'); - $editForm.find('.js-comment-save-button').enable(); - $editForm.find('.js-finish-edit-warning').hide(); - }; + $note.find('.js-note-attachment-delete').show(); + $editForm.addClass('current-note-edit-form'); + $note.addClass('is-editing'); + this.putEditFormInPlace($target); + } + + /** + * Called in response to clicking the edit note link + * + * Hides edit form and restores the original note text to the editor textarea. + */ + cancelEdit(e) { + e.preventDefault(); + const $target = $(e.target); + const $note = $target.closest('.note'); + const noteId = $note.attr('data-note-id'); + + this.revertNoteEditForm($target); + + if (this.updatedNotesTrackingMap[noteId]) { + const $newNote = $(this.updatedNotesTrackingMap[noteId].html); + $note.replaceWith($newNote); + this.setupNewNote($newNote); + // Now that we have taken care of the update, clear it out + delete this.updatedNotesTrackingMap[noteId]; + } + else { + $note.find('.js-finish-edit-warning').hide(); + this.removeNoteEditForm($note); + } + } - Notes.prototype.getEditFormSelector = function($el) { - var selector = '.note-edit-form:not(.mr-note-edit-form)'; + revertNoteEditForm($target) { + $target = $target || $('.note.is-editing:visible'); + var selector = this.getEditFormSelector($target); + var $editForm = $(selector); - if ($el.parents('#diffs').length) { - selector = '.note-edit-form.mr-note-edit-form'; - } + $editForm.insertBefore('.notes-form'); + $editForm.find('.js-comment-save-button').enable(); + $editForm.find('.js-finish-edit-warning').hide(); + } - return selector; - }; + getEditFormSelector($el) { + var selector = '.note-edit-form:not(.mr-note-edit-form)'; - Notes.prototype.removeNoteEditForm = function($note) { - var form = $note.find('.current-note-edit-form'); - $note.removeClass('is-editing'); - form.removeClass('current-note-edit-form'); - form.find('.js-finish-edit-warning').hide(); - // Replace markdown textarea text with original note text. - return form.find('.js-note-text').val(form.find('form.edit-note').data('original-note')); - }; + if ($el.parents('#diffs').length) { + selector = '.note-edit-form.mr-note-edit-form'; + } - /* - Called in response to deleting a note of any kind. - - Removes the actual note from view. - Removes the whole discussion if the last note is being removed. - */ - - Notes.prototype.removeNote = function(e) { - var noteElId, noteId, dataNoteId, $note, lineHolder; - $note = $(e.currentTarget).closest('.note'); - noteElId = $note.attr('id'); - noteId = $note.attr('data-note-id'); - lineHolder = $(e.currentTarget).closest('.notes[data-discussion-id]') - .closest('.notes_holder') - .prev('.line_holder'); - $(`.note[id="${noteElId}"]`).each((function(_this) { - // A same note appears in the "Discussion" and in the "Changes" tab, we have - // to remove all. Using $('.note[id='noteId']') ensure we get all the notes, - // where $('#noteId') would return only one. - return function(i, el) { - var $note, $notes; - $note = $(el); - $notes = $note.closest('.discussion-notes'); - - if (typeof gl.diffNotesCompileComponents !== 'undefined') { - if (gl.diffNoteApps[noteElId]) { - gl.diffNoteApps[noteElId].$destroy(); - } + return selector; + } + + removeNoteEditForm($note) { + var form = $note.find('.current-note-edit-form'); + $note.removeClass('is-editing'); + form.removeClass('current-note-edit-form'); + form.find('.js-finish-edit-warning').hide(); + // Replace markdown textarea text with original note text. + return form.find('.js-note-text').val(form.find('form.edit-note').data('original-note')); + } + + /** + * Called in response to deleting a note of any kind. + * + * Removes the actual note from view. + * Removes the whole discussion if the last note is being removed. + */ + removeNote(e) { + var noteElId, noteId, dataNoteId, $note, lineHolder; + $note = $(e.currentTarget).closest('.note'); + noteElId = $note.attr('id'); + noteId = $note.attr('data-note-id'); + lineHolder = $(e.currentTarget).closest('.notes[data-discussion-id]') + .closest('.notes_holder') + .prev('.line_holder'); + $(`.note[id="${noteElId}"]`).each((function(_this) { + // A same note appears in the "Discussion" and in the "Changes" tab, we have + // to remove all. Using $('.note[id='noteId']') ensure we get all the notes, + // where $('#noteId') would return only one. + return function(i, el) { + var $note, $notes; + $note = $(el); + $notes = $note.closest('.discussion-notes'); + + if (typeof gl.diffNotesCompileComponents !== 'undefined') { + if (gl.diffNoteApps[noteElId]) { + gl.diffNoteApps[noteElId].$destroy(); } + } - $note.remove(); + $note.remove(); - // check if this is the last note for this line - if ($notes.find('.note').length === 0) { - var notesTr = $notes.closest('tr'); + // check if this is the last note for this line + if ($notes.find('.note').length === 0) { + var notesTr = $notes.closest('tr'); - // "Discussions" tab - $notes.closest('.timeline-entry').remove(); + // "Discussions" tab + $notes.closest('.timeline-entry').remove(); - // The notes tr can contain multiple lists of notes, like on the parallel diff - if (notesTr.find('.discussion-notes').length > 1) { - $notes.remove(); - } else { - notesTr.remove(); - } + // The notes tr can contain multiple lists of notes, like on the parallel diff + if (notesTr.find('.discussion-notes').length > 1) { + $notes.remove(); + } else { + notesTr.remove(); } - }; - })(this)); - - Notes.checkMergeRequestStatus(); - return this.updateNotesCount(-1); - }; - - /* - Called in response to clicking the delete attachment link - - Removes the attachment wrapper view, including image tag if it exists - Resets the note editing form - */ + } + }; + })(this)); + + Notes.checkMergeRequestStatus(); + return this.updateNotesCount(-1); + } + + /** + * Called in response to clicking the delete attachment link + * + * Removes the attachment wrapper view, including image tag if it exists + * Resets the note editing form + */ + removeAttachment() { + const $note = $(this).closest('.note'); + $note.find('.note-attachment').remove(); + $note.find('.note-body > .note-text').show(); + $note.find('.note-header').show(); + return $note.find('.current-note-edit-form').remove(); + } + + /** + * Called when clicking on the "reply" button for a diff line. + * + * Shows the note form below the notes. + */ + onReplyToDiscussionNote(e) { + this.replyToDiscussionNote(e.target); + } + + replyToDiscussionNote(target) { + var form, replyLink; + form = this.cleanForm(this.formClone.clone()); + replyLink = $(target).closest('.js-discussion-reply-button'); + // insert the form after the button + replyLink + .closest('.discussion-reply-holder') + .hide() + .after(form); + // show the form + return this.setupDiscussionNoteForm(replyLink, form); + } + + /** + * Shows the diff or discussion form and does some setup on it. + * + * Sets some hidden fields in the form. + * + * Note: dataHolder must have the "discussionId" and "lineCode" data attributes set. + */ + setupDiscussionNoteForm(dataHolder, form) { + // setup note target + var discussionID = dataHolder.data('discussionId'); + + if (discussionID) { + form.attr('data-discussion-id', discussionID); + form.find('#in_reply_to_discussion_id').val(discussionID); + } - Notes.prototype.removeAttachment = function() { - const $note = $(this).closest('.note'); - $note.find('.note-attachment').remove(); - $note.find('.note-body > .note-text').show(); - $note.find('.note-header').show(); - return $note.find('.current-note-edit-form').remove(); - }; + form.attr('data-line-code', dataHolder.data('lineCode')); + form.find('#line_type').val(dataHolder.data('lineType')); - /* - Called when clicking on the "reply" button for a diff line. + form.find('#note_noteable_type').val(dataHolder.data('noteableType')); + form.find('#note_noteable_id').val(dataHolder.data('noteableId')); + form.find('#note_commit_id').val(dataHolder.data('commitId')); + form.find('#note_type').val(dataHolder.data('noteType')); - Shows the note form below the notes. - */ + // LegacyDiffNote + form.find('#note_line_code').val(dataHolder.data('lineCode')); - Notes.prototype.onReplyToDiscussionNote = function(e) { - this.replyToDiscussionNote(e.target); - }; + // DiffNote + form.find('#note_position').val(dataHolder.attr('data-position')); - Notes.prototype.replyToDiscussionNote = function(target) { - var form, replyLink; - form = this.cleanForm(this.formClone.clone()); - replyLink = $(target).closest('.js-discussion-reply-button'); - // insert the form after the button - replyLink - .closest('.discussion-reply-holder') - .hide() - .after(form); - // show the form - return this.setupDiscussionNoteForm(replyLink, form); - }; + form.find('.js-note-discard').show().removeClass('js-note-discard').addClass('js-close-discussion-note-form').text(form.find('.js-close-discussion-note-form').data('cancel-text')); + form.find('.js-note-target-close').remove(); + form.find('.js-note-new-discussion').remove(); + this.setupNoteForm(form); - /* - Shows the diff or discussion form and does some setup on it. + form + .removeClass('js-main-target-form') + .addClass('discussion-form js-discussion-note-form'); - Sets some hidden fields in the form. + if (typeof gl.diffNotesCompileComponents !== 'undefined') { + var $commentBtn = form.find('comment-and-resolve-btn'); + $commentBtn.attr(':discussion-id', `'${discussionID}'`); - Note: dataHolder must have the "discussionId" and "lineCode" data attributes set. - */ + gl.diffNotesCompileComponents(); + } - Notes.prototype.setupDiscussionNoteForm = function(dataHolder, form) { - // setup note target - var discussionID = dataHolder.data('discussionId'); + form.find('.js-note-text').focus(); + form + .find('.js-comment-resolve-button') + .attr('data-discussion-id', discussionID); + } + + /** + * Called when clicking on the "add a comment" button on the side of a diff line. + * + * Inserts a temporary row for the form below the line. + * Sets up the form and shows it. + */ + onAddDiffNote(e) { + e.preventDefault(); + const link = e.currentTarget || e.target; + const $link = $(link); + const showReplyInput = !$link.hasClass('js-diff-comment-avatar'); + this.toggleDiffNote({ + target: $link, + lineType: link.dataset.lineType, + showReplyInput + }); + } + + toggleDiffNote({ + target, + lineType, + forceShow, + showReplyInput = false, + }) { + var $link, addForm, hasNotes, newForm, noteForm, replyButton, row, rowCssToAdd, targetContent, isDiffCommentAvatar; + $link = $(target); + row = $link.closest('tr'); + const nextRow = row.next(); + let targetRow = row; + if (nextRow.is('.notes_holder')) { + targetRow = nextRow; + } - if (discussionID) { - form.attr('data-discussion-id', discussionID); - form.find('#in_reply_to_discussion_id').val(discussionID); + hasNotes = nextRow.is('.notes_holder'); + addForm = false; + let lineTypeSelector = ''; + rowCssToAdd = '<tr class="notes_holder js-temp-notes-holder"><td class="notes_line" colspan="2"></td><td class="notes_content"><div class="content"></div></td></tr>'; + // In parallel view, look inside the correct left/right pane + if (this.isParallelView()) { + lineTypeSelector = `.${lineType}`; + rowCssToAdd = '<tr class="notes_holder js-temp-notes-holder"><td class="notes_line old"></td><td class="notes_content parallel old"><div class="content"></div></td><td class="notes_line new"></td><td class="notes_content parallel new"><div class="content"></div></td></tr>'; + } + const notesContentSelector = `.notes_content${lineTypeSelector} .content`; + let notesContent = targetRow.find(notesContentSelector); + + if (hasNotes && showReplyInput) { + targetRow.show(); + notesContent = targetRow.find(notesContentSelector); + if (notesContent.length) { + notesContent.show(); + replyButton = notesContent.find('.js-discussion-reply-button:visible'); + if (replyButton.length) { + this.replyToDiscussionNote(replyButton[0]); + } else { + // In parallel view, the form may not be present in one of the panes + noteForm = notesContent.find('.js-discussion-note-form'); + if (noteForm.length === 0) { + addForm = true; + } + } } + } else if (showReplyInput) { + // add a notes row and insert the form + row.after(rowCssToAdd); + targetRow = row.next(); + notesContent = targetRow.find(notesContentSelector); + addForm = true; + } else { + const isCurrentlyShown = targetRow.find('.content:not(:empty)').is(':visible'); + const isForced = forceShow === true || forceShow === false; + const showNow = forceShow === true || (!isCurrentlyShown && !isForced); + + targetRow.toggle(showNow); + notesContent.toggle(showNow); + } - form.attr('data-line-code', dataHolder.data('lineCode')); - form.find('#line_type').val(dataHolder.data('lineType')); - - form.find('#note_noteable_type').val(dataHolder.data('noteableType')); - form.find('#note_noteable_id').val(dataHolder.data('noteableId')); - form.find('#note_commit_id').val(dataHolder.data('commitId')); - form.find('#note_type').val(dataHolder.data('noteType')); - - // LegacyDiffNote - form.find('#note_line_code').val(dataHolder.data('lineCode')); - - // DiffNote - form.find('#note_position').val(dataHolder.attr('data-position')); - - form.find('.js-note-discard').show().removeClass('js-note-discard').addClass('js-close-discussion-note-form').text(form.find('.js-close-discussion-note-form').data('cancel-text')); - form.find('.js-note-target-close').remove(); - form.find('.js-note-new-discussion').remove(); - this.setupNoteForm(form); - - form - .removeClass('js-main-target-form') - .addClass('discussion-form js-discussion-note-form'); - - if (typeof gl.diffNotesCompileComponents !== 'undefined') { - var $commentBtn = form.find('comment-and-resolve-btn'); - $commentBtn.attr(':discussion-id', `'${discussionID}'`); - - gl.diffNotesCompileComponents(); + if (addForm) { + newForm = this.cleanForm(this.formClone.clone()); + newForm.appendTo(notesContent); + // show the form + return this.setupDiscussionNoteForm($link, newForm); + } + } + + /** + * Called in response to "cancel" on a diff note form. + * + * Shows the reply button again. + * Removes the form and if necessary it's temporary row. + */ + removeDiscussionNoteForm(form) { + var glForm, row; + row = form.closest('tr'); + glForm = form.data('gl-form'); + glForm.destroy(); + form.find('.js-note-text').data('autosave').reset(); + // show the reply button (will only work for replies) + form + .prev('.discussion-reply-holder') + .show(); + if (row.is('.js-temp-notes-holder')) { + // remove temporary row for diff lines + return row.remove(); + } else { + // only remove the form + return form.remove(); + } + } + + cancelDiscussionForm(e) { + var form; + e.preventDefault(); + form = $(e.target).closest('.js-discussion-note-form'); + return this.removeDiscussionNoteForm(form); + } + + /** + * Called after an attachment file has been selected. + * + * Updates the file name for the selected attachment. + */ + updateFormAttachment() { + var filename, form; + form = $(this).closest('form'); + // get only the basename + filename = $(this).val().replace(/^.*[\\\/]/, ''); + return form.find('.js-attachment-filename').text(filename); + } + + /** + * Called when the tab visibility changes + */ + visibilityChange() { + return this.refresh(); + } + + updateTargetButtons(e) { + var closebtn, closetext, discardbtn, form, reopenbtn, reopentext, textarea; + textarea = $(e.target); + form = textarea.parents('form'); + reopenbtn = form.find('.js-note-target-reopen'); + closebtn = form.find('.js-note-target-close'); + discardbtn = form.find('.js-note-discard'); + + if (textarea.val().trim().length > 0) { + reopentext = reopenbtn.attr('data-alternative-text'); + closetext = closebtn.attr('data-alternative-text'); + if (reopenbtn.text() !== reopentext) { + reopenbtn.text(reopentext); } - - form.find('.js-note-text').focus(); - form - .find('.js-comment-resolve-button') - .attr('data-discussion-id', discussionID); - }; - - /* - Called when clicking on the "add a comment" button on the side of a diff line. - - Inserts a temporary row for the form below the line. - Sets up the form and shows it. - */ - - Notes.prototype.onAddDiffNote = function(e) { - e.preventDefault(); - const link = e.currentTarget || e.target; - const $link = $(link); - const showReplyInput = !$link.hasClass('js-diff-comment-avatar'); - this.toggleDiffNote({ - target: $link, - lineType: link.dataset.lineType, - showReplyInput - }); - }; - - Notes.prototype.toggleDiffNote = function({ - target, - lineType, - forceShow, - showReplyInput = false, - }) { - var $link, addForm, hasNotes, newForm, noteForm, replyButton, row, rowCssToAdd, targetContent, isDiffCommentAvatar; - $link = $(target); - row = $link.closest('tr'); - const nextRow = row.next(); - let targetRow = row; - if (nextRow.is('.notes_holder')) { - targetRow = nextRow; + if (closebtn.text() !== closetext) { + closebtn.text(closetext); } - - hasNotes = nextRow.is('.notes_holder'); - addForm = false; - let lineTypeSelector = ''; - rowCssToAdd = '<tr class="notes_holder js-temp-notes-holder"><td class="notes_line" colspan="2"></td><td class="notes_content"><div class="content"></div></td></tr>'; - // In parallel view, look inside the correct left/right pane - if (this.isParallelView()) { - lineTypeSelector = `.${lineType}`; - rowCssToAdd = '<tr class="notes_holder js-temp-notes-holder"><td class="notes_line old"></td><td class="notes_content parallel old"><div class="content"></div></td><td class="notes_line new"></td><td class="notes_content parallel new"><div class="content"></div></td></tr>'; + if (reopenbtn.is(':not(.btn-comment-and-reopen)')) { + reopenbtn.addClass('btn-comment-and-reopen'); } - const notesContentSelector = `.notes_content${lineTypeSelector} .content`; - let notesContent = targetRow.find(notesContentSelector); - - if (hasNotes && showReplyInput) { - targetRow.show(); - notesContent = targetRow.find(notesContentSelector); - if (notesContent.length) { - notesContent.show(); - replyButton = notesContent.find('.js-discussion-reply-button:visible'); - if (replyButton.length) { - this.replyToDiscussionNote(replyButton[0]); - } else { - // In parallel view, the form may not be present in one of the panes - noteForm = notesContent.find('.js-discussion-note-form'); - if (noteForm.length === 0) { - addForm = true; - } - } - } - } else if (showReplyInput) { - // add a notes row and insert the form - row.after(rowCssToAdd); - targetRow = row.next(); - notesContent = targetRow.find(notesContentSelector); - addForm = true; - } else { - const isCurrentlyShown = targetRow.find('.content:not(:empty)').is(':visible'); - const isForced = forceShow === true || forceShow === false; - const showNow = forceShow === true || (!isCurrentlyShown && !isForced); - - targetRow.toggle(showNow); - notesContent.toggle(showNow); + if (closebtn.is(':not(.btn-comment-and-close)')) { + closebtn.addClass('btn-comment-and-close'); } - - if (addForm) { - newForm = this.cleanForm(this.formClone.clone()); - newForm.appendTo(notesContent); - // show the form - return this.setupDiscussionNoteForm($link, newForm); + if (discardbtn.is(':hidden')) { + return discardbtn.show(); } - }; - - /* - Called in response to "cancel" on a diff note form. - - Shows the reply button again. - Removes the form and if necessary it's temporary row. - */ - - Notes.prototype.removeDiscussionNoteForm = function(form) { - var glForm, row; - row = form.closest('tr'); - glForm = form.data('gl-form'); - glForm.destroy(); - form.find('.js-note-text').data('autosave').reset(); - // show the reply button (will only work for replies) - form - .prev('.discussion-reply-holder') - .show(); - if (row.is('.js-temp-notes-holder')) { - // remove temporary row for diff lines - return row.remove(); - } else { - // only remove the form - return form.remove(); + } else { + reopentext = reopenbtn.data('original-text'); + closetext = closebtn.data('original-text'); + if (reopenbtn.text() !== reopentext) { + reopenbtn.text(reopentext); } - }; - - Notes.prototype.cancelDiscussionForm = function(e) { - var form; - e.preventDefault(); - form = $(e.target).closest('.js-discussion-note-form'); - return this.removeDiscussionNoteForm(form); - }; - - /* - Called after an attachment file has been selected. - - Updates the file name for the selected attachment. - */ - - Notes.prototype.updateFormAttachment = function() { - var filename, form; - form = $(this).closest('form'); - // get only the basename - filename = $(this).val().replace(/^.*[\\\/]/, ''); - return form.find('.js-attachment-filename').text(filename); - }; - - /* - Called when the tab visibility changes - */ - - Notes.prototype.visibilityChange = function() { - return this.refresh(); - }; - - Notes.prototype.updateTargetButtons = function(e) { - var closebtn, closetext, discardbtn, form, reopenbtn, reopentext, textarea; - textarea = $(e.target); - form = textarea.parents('form'); - reopenbtn = form.find('.js-note-target-reopen'); - closebtn = form.find('.js-note-target-close'); - discardbtn = form.find('.js-note-discard'); - - if (textarea.val().trim().length > 0) { - reopentext = reopenbtn.attr('data-alternative-text'); - closetext = closebtn.attr('data-alternative-text'); - if (reopenbtn.text() !== reopentext) { - reopenbtn.text(reopentext); - } - if (closebtn.text() !== closetext) { - closebtn.text(closetext); - } - if (reopenbtn.is(':not(.btn-comment-and-reopen)')) { - reopenbtn.addClass('btn-comment-and-reopen'); - } - if (closebtn.is(':not(.btn-comment-and-close)')) { - closebtn.addClass('btn-comment-and-close'); - } - if (discardbtn.is(':hidden')) { - return discardbtn.show(); - } - } else { - reopentext = reopenbtn.data('original-text'); - closetext = closebtn.data('original-text'); - if (reopenbtn.text() !== reopentext) { - reopenbtn.text(reopentext); - } - if (closebtn.text() !== closetext) { - closebtn.text(closetext); - } - if (reopenbtn.is('.btn-comment-and-reopen')) { - reopenbtn.removeClass('btn-comment-and-reopen'); - } - if (closebtn.is('.btn-comment-and-close')) { - closebtn.removeClass('btn-comment-and-close'); - } - if (discardbtn.is(':visible')) { - return discardbtn.hide(); - } + if (closebtn.text() !== closetext) { + closebtn.text(closetext); } - }; - - Notes.prototype.putEditFormInPlace = function($el) { - var $editForm = $(this.getEditFormSelector($el)); - var $note = $el.closest('.note'); - - $editForm.insertAfter($note.find('.note-text')); - - var $originalContentEl = $note.find('.original-note-content'); - var originalContent = $originalContentEl.text().trim(); - var postUrl = $originalContentEl.data('post-url'); - var targetId = $originalContentEl.data('target-id'); - var targetType = $originalContentEl.data('target-type'); - - new gl.GLForm($editForm.find('form'), this.enableGFM); - - $editForm.find('form') - .attr('action', postUrl) - .attr('data-remote', 'true'); - $editForm.find('.js-form-target-id').val(targetId); - $editForm.find('.js-form-target-type').val(targetType); - $editForm.find('.js-note-text').focus().val(originalContent); - $editForm.find('.js-md-write-button').trigger('click'); - $editForm.find('.referenced-users').hide(); - }; - - Notes.prototype.putConflictEditWarningInPlace = function(noteEntity, $note) { - if ($note.find('.js-conflict-edit-warning').length === 0) { - const $alert = $(`<div class="js-conflict-edit-warning alert alert-danger"> - This comment has changed since you started editing, please review the - <a href="#note_${noteEntity.id}" target="_blank" rel="noopener noreferrer"> - updated comment - </a> - to ensure information is not lost - </div>`); - $alert.insertAfter($note.find('.note-text')); + if (reopenbtn.is('.btn-comment-and-reopen')) { + reopenbtn.removeClass('btn-comment-and-reopen'); } - }; - - Notes.prototype.updateNotesCount = function(updateCount) { - return this.notesCountBadge.text(parseInt(this.notesCountBadge.text(), 10) + updateCount); - }; - - Notes.prototype.toggleCommitList = function(e) { - const $element = $(e.currentTarget); - const $closestSystemCommitList = $element.siblings('.system-note-commit-list'); - - $element.find('.fa').toggleClass('fa-angle-down').toggleClass('fa-angle-up'); - $closestSystemCommitList.toggleClass('hide-shade'); - }; - - /** - Scans system notes with `ul` elements in system note body - then collapse long commit list pushed by user to make it less - intrusive. - */ - Notes.prototype.collapseLongCommitList = function() { - const systemNotes = $('#notes-list').find('li.system-note').has('ul'); - - $.each(systemNotes, function(index, systemNote) { - const $systemNote = $(systemNote); - const headerMessage = $systemNote.find('.note-text').find('p:first').text().replace(':', ''); - - $systemNote.find('.note-header .system-note-message').html(headerMessage); - - if ($systemNote.find('li').length > MAX_VISIBLE_COMMIT_LIST_COUNT) { - $systemNote.find('.note-text').addClass('system-note-commit-list'); - $systemNote.find('.system-note-commit-list-toggler').show(); - } else { - $systemNote.find('.note-text').addClass('system-note-commit-list hide-shade'); - } - }); - }; - - Notes.prototype.addFlash = function(...flashParams) { - this.flashInstance = new Flash(...flashParams); - }; - - Notes.prototype.clearFlash = function() { - if (this.flashInstance && this.flashInstance.flashContainer) { - this.flashInstance.flashContainer.hide(); - this.flashInstance = null; + if (closebtn.is('.btn-comment-and-close')) { + closebtn.removeClass('btn-comment-and-close'); } - }; - - Notes.prototype.cleanForm = function($form) { - // Remove JS classes that are not needed here - $form - .find('.js-comment-type-dropdown') - .removeClass('btn-group'); - - // Remove dropdown - $form - .find('.dropdown-menu') - .remove(); - - return $form; - }; - - /** - * Check if note does not exists on page - */ - Notes.isNewNote = function(noteEntity, noteIds) { - return $.inArray(noteEntity.id, noteIds) === -1; - }; - - /** - * Check if $note already contains the `noteEntity` content - */ - Notes.isUpdatedNote = function(noteEntity, $note) { - // There can be CRLF vs LF mismatches if we don't sanitize and compare the same way - const sanitizedNoteEntityText = normalizeNewlines(noteEntity.note.trim()); - const currentNoteText = normalizeNewlines( - $note.find('.original-note-content').first().text().trim() - ); - return sanitizedNoteEntityText !== currentNoteText; - }; - - Notes.checkMergeRequestStatus = function() { - if (gl.utils.getPagePath(1) === 'merge_requests') { - gl.mrWidget.checkStatus(); + if (discardbtn.is(':visible')) { + return discardbtn.hide(); } - }; + } + } + + putEditFormInPlace($el) { + var $editForm = $(this.getEditFormSelector($el)); + var $note = $el.closest('.note'); + + $editForm.insertAfter($note.find('.note-text')); + + var $originalContentEl = $note.find('.original-note-content'); + var originalContent = $originalContentEl.text().trim(); + var postUrl = $originalContentEl.data('post-url'); + var targetId = $originalContentEl.data('target-id'); + var targetType = $originalContentEl.data('target-type'); + + new gl.GLForm($editForm.find('form'), this.enableGFM); + + $editForm.find('form') + .attr('action', postUrl) + .attr('data-remote', 'true'); + $editForm.find('.js-form-target-id').val(targetId); + $editForm.find('.js-form-target-type').val(targetType); + $editForm.find('.js-note-text').focus().val(originalContent); + $editForm.find('.js-md-write-button').trigger('click'); + $editForm.find('.referenced-users').hide(); + } + + putConflictEditWarningInPlace(noteEntity, $note) { + if ($note.find('.js-conflict-edit-warning').length === 0) { + const $alert = $(`<div class="js-conflict-edit-warning alert alert-danger"> + This comment has changed since you started editing, please review the + <a href="#note_${noteEntity.id}" target="_blank" rel="noopener noreferrer"> + updated comment + </a> + to ensure information is not lost + </div>`); + $alert.insertAfter($note.find('.note-text')); + } + } - Notes.animateAppendNote = function(noteHtml, $notesList) { - const $note = $(noteHtml); + updateNotesCount(updateCount) { + return this.notesCountBadge.text(parseInt(this.notesCountBadge.text(), 10) + updateCount); + } - $note.addClass('fade-in-full').renderGFM(); - $notesList.append($note); - return $note; - }; + toggleCommitList(e) { + const $element = $(e.currentTarget); + const $closestSystemCommitList = $element.siblings('.system-note-commit-list'); - Notes.animateUpdateNote = function(noteHtml, $note) { - const $updatedNote = $(noteHtml); + $element.find('.fa').toggleClass('fa-angle-down').toggleClass('fa-angle-up'); + $closestSystemCommitList.toggleClass('hide-shade'); + } - $updatedNote.addClass('fade-in').renderGFM(); - $note.replaceWith($updatedNote); - return $updatedNote; - }; + /** + * Scans system notes with `ul` elements in system note body + * then collapse long commit list pushed by user to make it less + * intrusive. + */ + collapseLongCommitList() { + const systemNotes = $('#notes-list').find('li.system-note').has('ul'); - /** - * Get data from Form attributes to use for saving/submitting comment. - */ - Notes.prototype.getFormData = function($form) { - return { - formData: $form.serialize(), - formContent: _.escape($form.find('.js-note-text').val()), - formAction: $form.attr('action'), - }; - }; + $.each(systemNotes, function(index, systemNote) { + const $systemNote = $(systemNote); + const headerMessage = $systemNote.find('.note-text').find('p:first').text().replace(':', ''); - /** - * Identify if comment has any quick actions - */ - Notes.prototype.hasQuickActions = function(formContent) { - return REGEX_QUICK_ACTIONS.test(formContent); - }; - - /** - * Remove quick actions and leave comment with pure message - */ - Notes.prototype.stripQuickActions = function(formContent) { - return formContent.replace(REGEX_QUICK_ACTIONS, '').trim(); - }; + $systemNote.find('.note-header .system-note-message').html(headerMessage); - /** - * Gets appropriate description from quick actions found in provided `formContent` - */ - Notes.prototype.getQuickActionDescription = function (formContent, availableQuickActions = []) { - let tempFormContent; + if ($systemNote.find('li').length > MAX_VISIBLE_COMMIT_LIST_COUNT) { + $systemNote.find('.note-text').addClass('system-note-commit-list'); + $systemNote.find('.system-note-commit-list-toggler').show(); + } else { + $systemNote.find('.note-text').addClass('system-note-commit-list hide-shade'); + } + }); + } - // Identify executed quick actions from `formContent` - const executedCommands = availableQuickActions.filter((command, index) => { - const commandRegex = new RegExp(`/${command.name}`); - return commandRegex.test(formContent); - }); + addFlash(...flashParams) { + this.flashInstance = new Flash(...flashParams); + } - if (executedCommands && executedCommands.length) { - if (executedCommands.length > 1) { - tempFormContent = 'Applying multiple commands'; - } else { - const commandDescription = executedCommands[0].description.toLowerCase(); - tempFormContent = `Applying command to ${commandDescription}`; - } + clearFlash() { + if (this.flashInstance && this.flashInstance.flashContainer) { + this.flashInstance.flashContainer.hide(); + this.flashInstance = null; + } + } + + cleanForm($form) { + // Remove JS classes that are not needed here + $form + .find('.js-comment-type-dropdown') + .removeClass('btn-group'); + + // Remove dropdown + $form + .find('.dropdown-menu') + .remove(); + + return $form; + } + + /** + * Check if note does not exists on page + */ + static isNewNote(noteEntity, noteIds) { + return $.inArray(noteEntity.id, noteIds) === -1; + } + + /** + * Check if $note already contains the `noteEntity` content + */ + static isUpdatedNote(noteEntity, $note) { + // There can be CRLF vs LF mismatches if we don't sanitize and compare the same way + const sanitizedNoteEntityText = normalizeNewlines(noteEntity.note.trim()); + const currentNoteText = normalizeNewlines( + $note.find('.original-note-content').first().text().trim() + ); + return sanitizedNoteEntityText !== currentNoteText; + } + + static checkMergeRequestStatus() { + if (gl.utils.getPagePath(1) === 'merge_requests') { + gl.mrWidget.checkStatus(); + } + } + + static animateAppendNote(noteHtml, $notesList) { + const $note = $(noteHtml); + + $note.addClass('fade-in-full').renderGFM(); + $notesList.append($note); + return $note; + } + + static animateUpdateNote(noteHtml, $note) { + const $updatedNote = $(noteHtml); + + $updatedNote.addClass('fade-in').renderGFM(); + $note.replaceWith($updatedNote); + return $updatedNote; + } + + /** + * Get data from Form attributes to use for saving/submitting comment. + */ + getFormData($form) { + return { + formData: $form.serialize(), + formContent: _.escape($form.find('.js-note-text').val()), + formAction: $form.attr('action'), + }; + } + + /** + * Identify if comment has any quick actions + */ + hasQuickActions(formContent) { + return REGEX_QUICK_ACTIONS.test(formContent); + } + + /** + * Remove quick actions and leave comment with pure message + */ + stripQuickActions(formContent) { + return formContent.replace(REGEX_QUICK_ACTIONS, '').trim(); + } + + /** + * Gets appropriate description from quick actions found in provided `formContent` + */ + getQuickActionDescription(formContent, availableQuickActions = []) { + let tempFormContent; + + // Identify executed quick actions from `formContent` + const executedCommands = availableQuickActions.filter((command, index) => { + const commandRegex = new RegExp(`/${command.name}`); + return commandRegex.test(formContent); + }); + + if (executedCommands && executedCommands.length) { + if (executedCommands.length > 1) { + tempFormContent = 'Applying multiple commands'; } else { - tempFormContent = 'Applying command'; + const commandDescription = executedCommands[0].description.toLowerCase(); + tempFormContent = `Applying command to ${commandDescription}`; } + } else { + tempFormContent = 'Applying command'; + } - return tempFormContent; - }; - - /** - * Create placeholder note DOM element populated with comment body - * that we will show while comment is being posted. - * Once comment is _actually_ posted on server, we will have final element - * in response that we will show in place of this temporary element. - */ - Notes.prototype.createPlaceholderNote = function ({ formContent, uniqueId, isDiscussionNote, currentUsername, currentUserFullname, currentUserAvatar }) { - const discussionClass = isDiscussionNote ? 'discussion' : ''; - const $tempNote = $( - `<li id="${uniqueId}" class="note being-posted fade-in-half timeline-entry"> - <div class="timeline-entry-inner"> - <div class="timeline-icon"> - <a href="/${currentUsername}"> - <img class="avatar s40" src="${currentUserAvatar}"> - </a> - </div> - <div class="timeline-content ${discussionClass}"> - <div class="note-header"> - <div class="note-header-info"> - <a href="/${currentUsername}"> - <span class="hidden-xs">${currentUserFullname}</span> - <span class="note-headline-light">@${currentUsername}</span> - </a> - </div> + return tempFormContent; + } + + /** + * Create placeholder note DOM element populated with comment body + * that we will show while comment is being posted. + * Once comment is _actually_ posted on server, we will have final element + * in response that we will show in place of this temporary element. + */ + createPlaceholderNote({ formContent, uniqueId, isDiscussionNote, currentUsername, currentUserFullname, currentUserAvatar }) { + const discussionClass = isDiscussionNote ? 'discussion' : ''; + const $tempNote = $( + `<li id="${uniqueId}" class="note being-posted fade-in-half timeline-entry"> + <div class="timeline-entry-inner"> + <div class="timeline-icon"> + <a href="/${currentUsername}"> + <img class="avatar s40" src="${currentUserAvatar}"> + </a> + </div> + <div class="timeline-content ${discussionClass}"> + <div class="note-header"> + <div class="note-header-info"> + <a href="/${currentUsername}"> + <span class="hidden-xs">${currentUserFullname}</span> + <span class="note-headline-light">@${currentUsername}</span> + </a> + </div> + </div> + <div class="note-body"> + <div class="note-text"> + <p>${formContent}</p> </div> - <div class="note-body"> - <div class="note-text"> - <p>${formContent}</p> - </div> - </div> - </div> + </div> + </div> + </div> + </li>` + ); + + return $tempNote; + } + + /** + * Create Placeholder System Note DOM element populated with quick action description + */ + createPlaceholderSystemNote({ formContent, uniqueId }) { + const $tempNote = $( + `<li id="${uniqueId}" class="note system-note timeline-entry being-posted fade-in-half"> + <div class="timeline-entry-inner"> + <div class="timeline-content"> + <i>${formContent}</i> </div> - </li>` - ); - - return $tempNote; - }; - - /** - * Create Placeholder System Note DOM element populated with quick action description - */ - Notes.prototype.createPlaceholderSystemNote = function ({ formContent, uniqueId }) { - const $tempNote = $( - `<li id="${uniqueId}" class="note system-note timeline-entry being-posted fade-in-half"> - <div class="timeline-entry-inner"> - <div class="timeline-content"> - <i>${formContent}</i> - </div> - </div> - </li>` - ); + </div> + </li>` + ); + + return $tempNote; + } + + /** + * This method does following tasks step-by-step whenever a new comment + * is submitted by user (both main thread comments as well as discussion comments). + * + * 1) Get Form metadata + * 2) Identify comment type; a) Main thread b) Discussion thread c) Discussion resolve + * 3) Build temporary placeholder element (using `createPlaceholderNote`) + * 4) Show placeholder note on UI + * 5) Perform network request to submit the note using `gl.utils.ajaxPost` + * a) If request is successfully completed + * 1. Remove placeholder element + * 2. Show submitted Note element + * 3. Perform post-submit errands + * a. Mark discussion as resolved if comment submission was for resolve. + * b. Reset comment form to original state. + * b) If request failed + * 1. Remove placeholder element + * 2. Show error Flash message about failure + */ + postComment(e) { + e.preventDefault(); + + // Get Form metadata + const $submitBtn = $(e.target); + let $form = $submitBtn.parents('form'); + const $closeBtn = $form.find('.js-note-target-close'); + const isDiscussionNote = $submitBtn.parent().find('li.droplab-item-selected').attr('id') === 'discussion'; + const isMainForm = $form.hasClass('js-main-target-form'); + const isDiscussionForm = $form.hasClass('js-discussion-note-form'); + const isDiscussionResolve = $submitBtn.hasClass('js-comment-resolve-button'); + const { formData, formContent, formAction } = this.getFormData($form); + let noteUniqueId; + let systemNoteUniqueId; + let hasQuickActions = false; + let $notesContainer; + let tempFormContent; + + // Get reference to notes container based on type of comment + if (isDiscussionForm) { + $notesContainer = $form.parent('.discussion-notes').find('.notes'); + } else if (isMainForm) { + $notesContainer = $('ul.main-notes-list'); + } - return $tempNote; - }; + // If comment is to resolve discussion, disable submit buttons while + // comment posting is finished. + if (isDiscussionResolve) { + $submitBtn.disable(); + $form.find('.js-comment-submit-button').disable(); + } - /** - * This method does following tasks step-by-step whenever a new comment - * is submitted by user (both main thread comments as well as discussion comments). - * - * 1) Get Form metadata - * 2) Identify comment type; a) Main thread b) Discussion thread c) Discussion resolve - * 3) Build temporary placeholder element (using `createPlaceholderNote`) - * 4) Show placeholder note on UI - * 5) Perform network request to submit the note using `gl.utils.ajaxPost` - * a) If request is successfully completed - * 1. Remove placeholder element - * 2. Show submitted Note element - * 3. Perform post-submit errands - * a. Mark discussion as resolved if comment submission was for resolve. - * b. Reset comment form to original state. - * b) If request failed - * 1. Remove placeholder element - * 2. Show error Flash message about failure - */ - Notes.prototype.postComment = function(e) { - e.preventDefault(); - - // Get Form metadata - const $submitBtn = $(e.target); - let $form = $submitBtn.parents('form'); - const $closeBtn = $form.find('.js-note-target-close'); - const isDiscussionNote = $submitBtn.parent().find('li.droplab-item-selected').attr('id') === 'discussion'; - const isMainForm = $form.hasClass('js-main-target-form'); - const isDiscussionForm = $form.hasClass('js-discussion-note-form'); - const isDiscussionResolve = $submitBtn.hasClass('js-comment-resolve-button'); - const { formData, formContent, formAction } = this.getFormData($form); - let noteUniqueId; - let systemNoteUniqueId; - let hasQuickActions = false; - let $notesContainer; - let tempFormContent; - - // Get reference to notes container based on type of comment - if (isDiscussionForm) { - $notesContainer = $form.parent('.discussion-notes').find('.notes'); - } else if (isMainForm) { - $notesContainer = $('ul.main-notes-list'); - } + tempFormContent = formContent; + if (this.hasQuickActions(formContent)) { + tempFormContent = this.stripQuickActions(formContent); + hasQuickActions = true; + } - // If comment is to resolve discussion, disable submit buttons while - // comment posting is finished. - if (isDiscussionResolve) { - $submitBtn.disable(); - $form.find('.js-comment-submit-button').disable(); - } + // Show placeholder note + if (tempFormContent) { + noteUniqueId = _.uniqueId('tempNote_'); + $notesContainer.append(this.createPlaceholderNote({ + formContent: tempFormContent, + uniqueId: noteUniqueId, + isDiscussionNote, + currentUsername: gon.current_username, + currentUserFullname: gon.current_user_fullname, + currentUserAvatar: gon.current_user_avatar_url, + })); + } - tempFormContent = formContent; - if (this.hasQuickActions(formContent)) { - tempFormContent = this.stripQuickActions(formContent); - hasQuickActions = true; - } + // Show placeholder system note + if (hasQuickActions) { + systemNoteUniqueId = _.uniqueId('tempSystemNote_'); + $notesContainer.append(this.createPlaceholderSystemNote({ + formContent: this.getQuickActionDescription(formContent, AjaxCache.get(gl.GfmAutoComplete.dataSources.commands)), + uniqueId: systemNoteUniqueId, + })); + } - // Show placeholder note - if (tempFormContent) { - noteUniqueId = _.uniqueId('tempNote_'); - $notesContainer.append(this.createPlaceholderNote({ - formContent: tempFormContent, - uniqueId: noteUniqueId, - isDiscussionNote, - currentUsername: gon.current_username, - currentUserFullname: gon.current_user_fullname, - currentUserAvatar: gon.current_user_avatar_url, - })); + // Clear the form textarea + if ($notesContainer.length) { + if (isMainForm) { + this.resetMainTargetForm(e); + } else if (isDiscussionForm) { + this.removeDiscussionNoteForm($form); } + } - // Show placeholder system note - if (hasQuickActions) { - systemNoteUniqueId = _.uniqueId('tempSystemNote_'); - $notesContainer.append(this.createPlaceholderSystemNote({ - formContent: this.getQuickActionDescription(formContent, AjaxCache.get(gl.GfmAutoComplete.dataSources.commands)), - uniqueId: systemNoteUniqueId, - })); - } + /* eslint-disable promise/catch-or-return */ + // Make request to submit comment on server + gl.utils.ajaxPost(formAction, formData) + .then((note) => { + // Submission successful! remove placeholder + $notesContainer.find(`#${noteUniqueId}`).remove(); - // Clear the form textarea - if ($notesContainer.length) { - if (isMainForm) { - this.resetMainTargetForm(e); - } else if (isDiscussionForm) { - this.removeDiscussionNoteForm($form); + // Reset cached commands list when command is applied + if (hasQuickActions) { + $form.find('textarea.js-note-text').trigger('clear-commands-cache.atwho'); } - } - - /* eslint-disable promise/catch-or-return */ - // Make request to submit comment on server - gl.utils.ajaxPost(formAction, formData) - .then((note) => { - // Submission successful! remove placeholder - $notesContainer.find(`#${noteUniqueId}`).remove(); - // Reset cached commands list when command is applied - if (hasQuickActions) { - $form.find('textarea.js-note-text').trigger('clear-commands-cache.atwho'); - } - - // Clear previous form errors - this.clearFlashWrapper(); + // Clear previous form errors + this.clearFlashWrapper(); - // Check if this was discussion comment - if (isDiscussionForm) { - // Remove flash-container - $notesContainer.find('.flash-container').remove(); + // Check if this was discussion comment + if (isDiscussionForm) { + // Remove flash-container + $notesContainer.find('.flash-container').remove(); - // If comment intends to resolve discussion, do the same. - if (isDiscussionResolve) { - $form - .attr('data-discussion-id', $submitBtn.data('discussion-id')) - .attr('data-resolve-all', 'true') - .attr('data-project-path', $submitBtn.data('project-path')); - } + // If comment intends to resolve discussion, do the same. + if (isDiscussionResolve) { + $form + .attr('data-discussion-id', $submitBtn.data('discussion-id')) + .attr('data-resolve-all', 'true') + .attr('data-project-path', $submitBtn.data('project-path')); + } - // Show final note element on UI - this.addDiscussionNote($form, note, $notesContainer.length === 0); + // Show final note element on UI + this.addDiscussionNote($form, note, $notesContainer.length === 0); - // append flash-container to the Notes list - if ($notesContainer.length) { - $notesContainer.append('<div class="flash-container" style="display: none;"></div>'); - } - } else if (isMainForm) { // Check if this was main thread comment - // Show final note element on UI and perform form and action buttons cleanup - this.addNote($form, note); - this.reenableTargetFormSubmitButton(e); + // append flash-container to the Notes list + if ($notesContainer.length) { + $notesContainer.append('<div class="flash-container" style="display: none;"></div>'); } + } else if (isMainForm) { // Check if this was main thread comment + // Show final note element on UI and perform form and action buttons cleanup + this.addNote($form, note); + this.reenableTargetFormSubmitButton(e); + } - if (note.commands_changes) { - this.handleQuickActions(note); - } + if (note.commands_changes) { + this.handleQuickActions(note); + } - $form.trigger('ajax:success', [note]); - }).fail(() => { - // Submission failed, remove placeholder note and show Flash error message - $notesContainer.find(`#${noteUniqueId}`).remove(); + $form.trigger('ajax:success', [note]); + }).fail(() => { + // Submission failed, remove placeholder note and show Flash error message + $notesContainer.find(`#${noteUniqueId}`).remove(); - if (hasQuickActions) { - $notesContainer.find(`#${systemNoteUniqueId}`).remove(); - } + if (hasQuickActions) { + $notesContainer.find(`#${systemNoteUniqueId}`).remove(); + } - // Show form again on UI on failure - if (isDiscussionForm && $notesContainer.length) { - const replyButton = $notesContainer.parent().find('.js-discussion-reply-button'); - this.replyToDiscussionNote(replyButton[0]); - $form = $notesContainer.parent().find('form'); - } + // Show form again on UI on failure + if (isDiscussionForm && $notesContainer.length) { + const replyButton = $notesContainer.parent().find('.js-discussion-reply-button'); + this.replyToDiscussionNote(replyButton[0]); + $form = $notesContainer.parent().find('form'); + } - $form.find('.js-note-text').val(formContent); - this.reenableTargetFormSubmitButton(e); - this.addNoteError($form); - }); + $form.find('.js-note-text').val(formContent); + this.reenableTargetFormSubmitButton(e); + this.addNoteError($form); + }); - return $closeBtn.text($closeBtn.data('original-text')); - }; + return $closeBtn.text($closeBtn.data('original-text')); + } + + /** + * This method does following tasks step-by-step whenever an existing comment + * is updated by user (both main thread comments as well as discussion comments). + * + * 1) Get Form metadata + * 2) Update note element with new content + * 3) Perform network request to submit the updated note using `gl.utils.ajaxPost` + * a) If request is successfully completed + * 1. Show submitted Note element + * b) If request failed + * 1. Revert Note element to original content + * 2. Show error Flash message about failure + */ + updateComment(e) { + e.preventDefault(); + + // Get Form metadata + const $submitBtn = $(e.target); + const $form = $submitBtn.parents('form'); + const $closeBtn = $form.find('.js-note-target-close'); + const $editingNote = $form.parents('.note.is-editing'); + const $noteBody = $editingNote.find('.js-task-list-container'); + const $noteBodyText = $noteBody.find('.note-text'); + const { formData, formContent, formAction } = this.getFormData($form); + + // Cache original comment content + const cachedNoteBodyText = $noteBodyText.html(); + + // Show updated comment content temporarily + $noteBodyText.html(formContent); + $editingNote.removeClass('is-editing fade-in-full').addClass('being-posted fade-in-half'); + $editingNote.find('.note-headline-meta a').html('<i class="fa fa-spinner fa-spin" aria-label="Comment is being updated" aria-hidden="true"></i>'); + + /* eslint-disable promise/catch-or-return */ + // Make request to update comment on server + gl.utils.ajaxPost(formAction, formData) + .then((note) => { + // Submission successful! render final note element + this.updateNote(note, $editingNote); + }) + .fail(() => { + // Submission failed, revert back to original note + $noteBodyText.html(_.escape(cachedNoteBodyText)); + $editingNote.removeClass('being-posted fade-in'); + $editingNote.find('.fa.fa-spinner').remove(); + + // Show Flash message about failure + this.updateNoteError(); + }); - /** - * This method does following tasks step-by-step whenever an existing comment - * is updated by user (both main thread comments as well as discussion comments). - * - * 1) Get Form metadata - * 2) Update note element with new content - * 3) Perform network request to submit the updated note using `gl.utils.ajaxPost` - * a) If request is successfully completed - * 1. Show submitted Note element - * b) If request failed - * 1. Revert Note element to original content - * 2. Show error Flash message about failure - */ - Notes.prototype.updateComment = function(e) { - e.preventDefault(); - - // Get Form metadata - const $submitBtn = $(e.target); - const $form = $submitBtn.parents('form'); - const $closeBtn = $form.find('.js-note-target-close'); - const $editingNote = $form.parents('.note.is-editing'); - const $noteBody = $editingNote.find('.js-task-list-container'); - const $noteBodyText = $noteBody.find('.note-text'); - const { formData, formContent, formAction } = this.getFormData($form); - - // Cache original comment content - const cachedNoteBodyText = $noteBodyText.html(); - - // Show updated comment content temporarily - $noteBodyText.html(_.escape(formContent)); - $editingNote.removeClass('is-editing fade-in-full').addClass('being-posted fade-in-half'); - $editingNote.find('.note-headline-meta a').html('<i class="fa fa-spinner fa-spin" aria-label="Comment is being updated" aria-hidden="true"></i>'); - - /* eslint-disable promise/catch-or-return */ - // Make request to update comment on server - gl.utils.ajaxPost(formAction, formData) - .then((note) => { - // Submission successful! render final note element - this.updateNote(note, $editingNote); - }) - .fail(() => { - // Submission failed, revert back to original note - $noteBodyText.html(_.escape(cachedNoteBodyText)); - $editingNote.removeClass('being-posted fade-in'); - $editingNote.find('.fa.fa-spinner').remove(); - - // Show Flash message about failure - this.updateNoteError(); - }); - - return $closeBtn.text($closeBtn.data('original-text')); - }; + return $closeBtn.text($closeBtn.data('original-text')); + } +} - return Notes; - })(); -}).call(window); +window.Notes = Notes; diff --git a/app/assets/javascripts/pipeline_schedules/components/interval_pattern_input.js b/app/assets/javascripts/pipeline_schedules/components/interval_pattern_input.js deleted file mode 100644 index 901adbe9fce..00000000000 --- a/app/assets/javascripts/pipeline_schedules/components/interval_pattern_input.js +++ /dev/null @@ -1,148 +0,0 @@ -import Vue from 'vue'; -import Translate from '../../vue_shared/translate'; - -Vue.use(Translate); - -const inputNameAttribute = 'schedule[cron]'; - -export default { - props: { - initialCronInterval: { - type: String, - required: false, - default: '', - }, - }, - data() { - return { - inputNameAttribute, - cronInterval: this.initialCronInterval, - cronIntervalPresets: { - everyDay: '0 4 * * *', - everyWeek: '0 4 * * 0', - everyMonth: '0 4 1 * *', - }, - cronSyntaxUrl: 'https://en.wikipedia.org/wiki/Cron', - customInputEnabled: false, - }; - }, - computed: { - intervalIsPreset() { - return _.contains(this.cronIntervalPresets, this.cronInterval); - }, - // The text input is editable when there's a custom interval, or when it's - // a preset interval and the user clicks the 'custom' radio button - isEditable() { - return !!(this.customInputEnabled || !this.intervalIsPreset); - }, - }, - methods: { - toggleCustomInput(shouldEnable) { - this.customInputEnabled = shouldEnable; - - if (shouldEnable) { - // We need to change the value so other radios don't remain selected - // because the model (cronInterval) hasn't changed. The server trims it. - this.cronInterval = `${this.cronInterval} `; - } - }, - }, - created() { - if (this.intervalIsPreset) { - this.enableCustomInput = false; - } - }, - watch: { - cronInterval() { - // updates field validation state when model changes, as - // glFieldError only updates on input. - Vue.nextTick(() => { - gl.pipelineScheduleFieldErrors.updateFormValidityState(); - }); - }, - }, - template: ` - <div class="interval-pattern-form-group"> - <div class="cron-preset-radio-input"> - <input - id="custom" - class="label-light" - type="radio" - :name="inputNameAttribute" - :value="cronInterval" - :checked="isEditable" - @click="toggleCustomInput(true)" - /> - - <label for="custom"> - {{ s__('PipelineSheduleIntervalPattern|Custom') }} - </label> - - <span class="cron-syntax-link-wrap"> - (<a :href="cronSyntaxUrl" target="_blank">{{ __('Cron syntax') }}</a>) - </span> - </div> - - <div class="cron-preset-radio-input"> - <input - id="every-day" - class="label-light" - type="radio" - v-model="cronInterval" - :name="inputNameAttribute" - :value="cronIntervalPresets.everyDay" - @click="toggleCustomInput(false)" - /> - - <label class="label-light" for="every-day"> - {{ __('Every day (at 4:00am)') }} - </label> - </div> - - <div class="cron-preset-radio-input"> - <input - id="every-week" - class="label-light" - type="radio" - v-model="cronInterval" - :name="inputNameAttribute" - :value="cronIntervalPresets.everyWeek" - @click="toggleCustomInput(false)" - /> - - <label class="label-light" for="every-week"> - {{ __('Every week (Sundays at 4:00am)') }} - </label> - </div> - - <div class="cron-preset-radio-input"> - <input - id="every-month" - class="label-light" - type="radio" - v-model="cronInterval" - :name="inputNameAttribute" - :value="cronIntervalPresets.everyMonth" - @click="toggleCustomInput(false)" - /> - - <label class="label-light" for="every-month"> - {{ __('Every month (on the 1st at 4:00am)') }} - </label> - </div> - - <div class="cron-interval-input-wrapper"> - <input - id="schedule_cron" - class="form-control inline cron-interval-input" - type="text" - :placeholder="__('Define a custom pattern with cron syntax')" - required="true" - v-model="cronInterval" - :name="inputNameAttribute" - :disabled="!isEditable" - /> - </div> - </div> - `, -}; diff --git a/app/assets/javascripts/pipeline_schedules/components/interval_pattern_input.vue b/app/assets/javascripts/pipeline_schedules/components/interval_pattern_input.vue new file mode 100644 index 00000000000..ce46b3fa3fa --- /dev/null +++ b/app/assets/javascripts/pipeline_schedules/components/interval_pattern_input.vue @@ -0,0 +1,144 @@ +<script> + export default { + props: { + initialCronInterval: { + type: String, + required: false, + default: '', + }, + }, + data() { + return { + inputNameAttribute: 'schedule[cron]', + cronInterval: this.initialCronInterval, + cronIntervalPresets: { + everyDay: '0 4 * * *', + everyWeek: '0 4 * * 0', + everyMonth: '0 4 1 * *', + }, + cronSyntaxUrl: 'https://en.wikipedia.org/wiki/Cron', + customInputEnabled: false, + }; + }, + computed: { + intervalIsPreset() { + return _.contains(this.cronIntervalPresets, this.cronInterval); + }, + // The text input is editable when there's a custom interval, or when it's + // a preset interval and the user clicks the 'custom' radio button + isEditable() { + return !!(this.customInputEnabled || !this.intervalIsPreset); + }, + }, + methods: { + toggleCustomInput(shouldEnable) { + this.customInputEnabled = shouldEnable; + + if (shouldEnable) { + // We need to change the value so other radios don't remain selected + // because the model (cronInterval) hasn't changed. The server trims it. + this.cronInterval = `${this.cronInterval} `; + } + }, + }, + created() { + if (this.intervalIsPreset) { + this.enableCustomInput = false; + } + }, + watch: { + cronInterval() { + // updates field validation state when model changes, as + // glFieldError only updates on input. + this.$nextTick(() => { + gl.pipelineScheduleFieldErrors.updateFormValidityState(); + }); + }, + }, + }; +</script> + +<template> + <div class="interval-pattern-form-group"> + <div class="cron-preset-radio-input"> + <input + id="custom" + class="label-light" + type="radio" + :name="inputNameAttribute" + :value="cronInterval" + :checked="isEditable" + @click="toggleCustomInput(true)" + /> + + <label for="custom"> + {{ s__('PipelineSheduleIntervalPattern|Custom') }} + </label> + + <span class="cron-syntax-link-wrap"> + (<a :href="cronSyntaxUrl" target="_blank">{{ __('Cron syntax') }}</a>) + </span> + </div> + + <div class="cron-preset-radio-input"> + <input + id="every-day" + class="label-light" + type="radio" + v-model="cronInterval" + :name="inputNameAttribute" + :value="cronIntervalPresets.everyDay" + @click="toggleCustomInput(false)" + /> + + <label class="label-light" for="every-day"> + {{ __('Every day (at 4:00am)') }} + </label> + </div> + + <div class="cron-preset-radio-input"> + <input + id="every-week" + class="label-light" + type="radio" + v-model="cronInterval" + :name="inputNameAttribute" + :value="cronIntervalPresets.everyWeek" + @click="toggleCustomInput(false)" + /> + + <label class="label-light" for="every-week"> + {{ __('Every week (Sundays at 4:00am)') }} + </label> + </div> + + <div class="cron-preset-radio-input"> + <input + id="every-month" + class="label-light" + type="radio" + v-model="cronInterval" + :name="inputNameAttribute" + :value="cronIntervalPresets.everyMonth" + @click="toggleCustomInput(false)" + /> + + <label class="label-light" for="every-month"> + {{ __('Every month (on the 1st at 4:00am)') }} + </label> + </div> + + <div class="cron-interval-input-wrapper"> + <input + id="schedule_cron" + class="form-control inline cron-interval-input" + type="text" + :placeholder="__('Define a custom pattern with cron syntax')" + required="true" + v-model="cronInterval" + :name="inputNameAttribute" + :disabled="!isEditable" + /> + </div> + </div> +</template> diff --git a/app/assets/javascripts/pipeline_schedules/pipeline_schedule_form_bundle.js b/app/assets/javascripts/pipeline_schedules/pipeline_schedule_form_bundle.js index c60e77decce..b424e7f205d 100644 --- a/app/assets/javascripts/pipeline_schedules/pipeline_schedule_form_bundle.js +++ b/app/assets/javascripts/pipeline_schedules/pipeline_schedule_form_bundle.js @@ -1,20 +1,41 @@ import Vue from 'vue'; -import IntervalPatternInput from './components/interval_pattern_input'; +import Translate from '../vue_shared/translate'; +import intervalPatternInput from './components/interval_pattern_input.vue'; import TimezoneDropdown from './components/timezone_dropdown'; import TargetBranchDropdown from './components/target_branch_dropdown'; -document.addEventListener('DOMContentLoaded', () => { - const IntervalPatternInputComponent = Vue.extend(IntervalPatternInput); +Vue.use(Translate); + +function initIntervalPatternInput() { const intervalPatternMount = document.getElementById('interval-pattern-input'); const initialCronInterval = intervalPatternMount ? intervalPatternMount.dataset.initialInterval : ''; - new IntervalPatternInputComponent({ - propsData: { - initialCronInterval, + return new Vue({ + el: intervalPatternMount, + components: { + intervalPatternInput, }, - }).$mount(intervalPatternMount); + render(createElement) { + return createElement('interval-pattern-input', { + props: { + initialCronInterval, + }, + }); + }, + }); +} + +document.addEventListener('DOMContentLoaded', () => { + /* Most of the form is written in haml, but for fields with more complex behaviors, + * you should mount individual Vue components here. If at some point components need + * to share state, it may make sense to refactor the whole form to Vue */ + + initIntervalPatternInput(); + + // Initialize non-Vue JS components in the form const formElement = document.getElementById('new-pipeline-schedule-form'); + gl.timezoneDropdown = new TimezoneDropdown(); gl.targetBranchDropdown = new TargetBranchDropdown(); gl.pipelineScheduleFieldErrors = new gl.GlFieldErrors(formElement); diff --git a/app/assets/javascripts/pipelines/components/async_button.vue b/app/assets/javascripts/pipelines/components/async_button.vue index 37a6f02d8fd..16cc0761fc1 100644 --- a/app/assets/javascripts/pipelines/components/async_button.vue +++ b/app/assets/javascripts/pipelines/components/async_button.vue @@ -1,9 +1,9 @@ <script> /* eslint-disable no-new, no-alert */ -/* global Flash */ -import '~/flash'; + import eventHub from '../event_hub'; import loadingIcon from '../../vue_shared/components/loading_icon.vue'; +import tooltip from '../../vue_shared/directives/tooltip'; export default { props: { @@ -11,53 +11,42 @@ export default { type: String, required: true, }, - - service: { - type: Object, - required: true, - }, - title: { type: String, required: true, }, - icon: { type: String, required: true, }, - cssClass: { type: String, required: true, }, - confirmActionMessage: { type: String, required: false, }, }, - + directives: { + tooltip, + }, components: { loadingIcon, }, - data() { return { isLoading: false, }; }, - computed: { iconClass() { return `fa fa-${this.icon}`; }, - buttonClass() { - return `btn has-tooltip ${this.cssClass}`; + return `btn ${this.cssClass}`; }, }, - methods: { onClick() { if (this.confirmActionMessage && confirm(this.confirmActionMessage)) { @@ -66,21 +55,10 @@ export default { this.makeRequest(); } }, - makeRequest() { this.isLoading = true; - $(this.$el).tooltip('destroy'); - - this.service.postAction(this.endpoint) - .then(() => { - this.isLoading = false; - eventHub.$emit('refreshPipelines'); - }) - .catch(() => { - this.isLoading = false; - new Flash('An error occured while making the request.'); - }); + eventHub.$emit('postAction', this.endpoint); }, }, }; @@ -88,6 +66,7 @@ export default { <template> <button + v-tooltip type="button" @click="onClick" :class="buttonClass" @@ -98,7 +77,8 @@ export default { :disabled="isLoading"> <i :class="iconClass" - aria-hidden="true" /> + aria-hidden="true"> + </i> <loading-icon v-if="isLoading" /> </button> </template> diff --git a/app/assets/javascripts/pipelines/components/graph/action_component.vue b/app/assets/javascripts/pipelines/components/graph/action_component.vue index 1f9e3d39779..54227425d2a 100644 --- a/app/assets/javascripts/pipelines/components/graph/action_component.vue +++ b/app/assets/javascripts/pipelines/components/graph/action_component.vue @@ -1,6 +1,6 @@ <script> import getActionIcon from '../../../vue_shared/ci_action_icons'; - import tooltipMixin from '../../../vue_shared/mixins/tooltip'; + import tooltip from '../../../vue_shared/directives/tooltip'; /** * Renders either a cancel, retry or play icon pointing to the given path. @@ -29,9 +29,9 @@ }, }, - mixins: [ - tooltipMixin, - ], + directives: { + tooltip, + }, computed: { actionIconSvg() { @@ -46,12 +46,11 @@ </script> <template> <a + v-tooltip :data-method="actionMethod" :title="tooltipText" :href="link" - ref="tooltip" class="ci-action-icon-container" - data-toggle="tooltip" data-container="body"> <i diff --git a/app/assets/javascripts/pipelines/components/graph/dropdown_action_component.vue b/app/assets/javascripts/pipelines/components/graph/dropdown_action_component.vue index 19cafff4e1c..18fe1847eef 100644 --- a/app/assets/javascripts/pipelines/components/graph/dropdown_action_component.vue +++ b/app/assets/javascripts/pipelines/components/graph/dropdown_action_component.vue @@ -1,6 +1,6 @@ <script> import getActionIcon from '../../../vue_shared/ci_action_icons'; - import tooltipMixin from '../../../vue_shared/mixins/tooltip'; + import tooltip from '../../../vue_shared/directives/tooltip'; /** * Renders either a cancel, retry or play icon pointing to the given path. @@ -29,9 +29,9 @@ }, }, - mixins: [ - tooltipMixin, - ], + directives: { + tooltip, + }, computed: { actionIconSvg() { @@ -42,13 +42,12 @@ </script> <template> <a + v-tooltip :data-method="actionMethod" :title="tooltipText" :href="link" - ref="tooltip" rel="nofollow" class="ci-action-icon-wrapper js-ci-status-icon" - data-toggle="tooltip" data-container="body" v-html="actionIconSvg" aria-label="Job's action"> diff --git a/app/assets/javascripts/pipelines/components/graph/dropdown_job_component.vue b/app/assets/javascripts/pipelines/components/graph/dropdown_job_component.vue index d597af8dfb5..2944689a5a7 100644 --- a/app/assets/javascripts/pipelines/components/graph/dropdown_job_component.vue +++ b/app/assets/javascripts/pipelines/components/graph/dropdown_job_component.vue @@ -1,7 +1,7 @@ <script> import jobNameComponent from './job_name_component.vue'; import jobComponent from './job_component.vue'; - import tooltipMixin from '../../../vue_shared/mixins/tooltip'; + import tooltip from '../../../vue_shared/directives/tooltip'; /** * Renders the dropdown for the pipeline graph. @@ -34,9 +34,9 @@ }, }, - mixins: [ - tooltipMixin, - ], + directives: { + tooltip, + }, components: { jobComponent, @@ -53,12 +53,12 @@ <template> <div> <button + v-tooltip type="button" data-toggle="dropdown" data-container="body" class="dropdown-menu-toggle build-content" - :title="tooltipText" - ref="tooltip"> + :title="tooltipText"> <job-name-component :name="job.name" diff --git a/app/assets/javascripts/pipelines/components/graph/job_component.vue b/app/assets/javascripts/pipelines/components/graph/job_component.vue index b39c936101e..1f5ed3f1074 100644 --- a/app/assets/javascripts/pipelines/components/graph/job_component.vue +++ b/app/assets/javascripts/pipelines/components/graph/job_component.vue @@ -2,7 +2,7 @@ import actionComponent from './action_component.vue'; import dropdownActionComponent from './dropdown_action_component.vue'; import jobNameComponent from './job_name_component.vue'; - import tooltipMixin from '../../../vue_shared/mixins/tooltip'; + import tooltip from '../../../vue_shared/directives/tooltip'; /** * Renders the badge for the pipeline graph and the job's dropdown. @@ -54,9 +54,9 @@ jobNameComponent, }, - mixins: [ - tooltipMixin, - ], + directives: { + tooltip, + }, computed: { tooltipText() { @@ -77,12 +77,11 @@ <template> <div> <a + v-tooltip v-if="job.status.details_path" :href="job.status.details_path" :title="tooltipText" :class="cssClassJobName" - ref="tooltip" - data-toggle="tooltip" data-container="body"> <job-name-component @@ -93,10 +92,9 @@ <div v-else + v-tooltip :title="tooltipText" :class="cssClassJobName" - ref="tooltip" - data-toggle="tooltip" data-container="body"> <job-name-component diff --git a/app/assets/javascripts/pipelines/components/pipeline_url.vue b/app/assets/javascripts/pipelines/components/pipeline_url.vue index 8333ec0fbc3..2ca5ac2912f 100644 --- a/app/assets/javascripts/pipelines/components/pipeline_url.vue +++ b/app/assets/javascripts/pipelines/components/pipeline_url.vue @@ -1,6 +1,6 @@ <script> import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue'; -import tooltipMixin from '../../vue_shared/mixins/tooltip'; +import tooltip from '../../vue_shared/directives/tooltip'; export default { props: { @@ -12,9 +12,9 @@ export default { components: { userAvatarLink, }, - mixins: [ - tooltipMixin, - ], + directives: { + tooltip, + }, computed: { user() { return this.pipeline.user; @@ -45,16 +45,16 @@ export default { <div class="label-container"> <span v-if="pipeline.flags.latest" + v-tooltip class="js-pipeline-url-latest label label-success" - title="Latest pipeline for this branch" - ref="tooltip"> + title="Latest pipeline for this branch"> latest </span> <span v-if="pipeline.flags.yaml_errors" + v-tooltip class="js-pipeline-url-yaml label label-danger" - :title="pipeline.yaml_errors" - ref="tooltip"> + :title="pipeline.yaml_errors"> yaml invalid </span> <span diff --git a/app/assets/javascripts/pipelines/components/pipelines.vue b/app/assets/javascripts/pipelines/components/pipelines.vue index fed42d23112..01ae07aad65 100644 --- a/app/assets/javascripts/pipelines/components/pipelines.vue +++ b/app/assets/javascripts/pipelines/components/pipelines.vue @@ -1,15 +1,9 @@ <script> - import Visibility from 'visibilityjs'; import PipelinesService from '../services/pipelines_service'; - import eventHub from '../event_hub'; - import pipelinesTableComponent from '../../vue_shared/components/pipelines_table.vue'; + import pipelinesMixin from '../mixins/pipelines'; import tablePagination from '../../vue_shared/components/table_pagination.vue'; - import emptyState from './empty_state.vue'; - import errorState from './error_state.vue'; import navigationTabs from './navigation_tabs.vue'; import navigationControls from './nav_controls.vue'; - import loadingIcon from '../../vue_shared/components/loading_icon.vue'; - import Poll from '../../lib/utils/poll'; export default { props: { @@ -20,13 +14,12 @@ }, components: { tablePagination, - pipelinesTableComponent, - emptyState, - errorState, navigationTabs, navigationControls, - loadingIcon, }, + mixins: [ + pipelinesMixin, + ], data() { const pipelinesData = document.querySelector('#pipelines-list-vue').dataset; @@ -47,11 +40,6 @@ state: this.store.state, apiScope: 'all', pagenum: 1, - isLoading: false, - hasError: false, - isMakingRequest: false, - updateGraphDropdown: false, - hasMadeRequest: false, }; }, computed: { @@ -62,9 +50,6 @@ const scope = gl.utils.getParameterByName('scope'); return scope === null ? 'all' : scope; }, - shouldRenderErrorState() { - return this.hasError && !this.isLoading; - }, /** * The empty state should only be rendered when the request is made to fetch all pipelines @@ -106,7 +91,6 @@ this.state.pipelines.length && this.state.pageInfo.total > this.state.pageInfo.perPage; }, - hasCiEnabled() { return this.hasCi !== undefined; }, @@ -129,37 +113,7 @@ }, created() { this.service = new PipelinesService(this.endpoint); - - const poll = new Poll({ - resource: this.service, - method: 'getPipelines', - data: { page: this.pageParameter, scope: this.scopeParameter }, - successCallback: this.successCallback, - errorCallback: this.errorCallback, - notificationCallback: this.setIsMakingRequest, - }); - - if (!Visibility.hidden()) { - this.isLoading = true; - poll.makeRequest(); - } else { - // If tab is not visible we need to make the first request so we don't show the empty - // state without knowing if there are any pipelines - this.fetchPipelines(); - } - - Visibility.change(() => { - if (!Visibility.hidden()) { - poll.restart(); - } else { - poll.stop(); - } - }); - - eventHub.$on('refreshPipelines', this.fetchPipelines); - }, - beforeDestroy() { - eventHub.$off('refreshPipelines'); + this.requestData = { page: this.pageParameter, scope: this.scopeParameter }; }, methods: { /** @@ -174,15 +128,6 @@ return param; }, - fetchPipelines() { - if (!this.isMakingRequest) { - this.isLoading = true; - - this.service.getPipelines({ scope: this.scopeParameter, page: this.pageParameter }) - .then(response => this.successCallback(response)) - .catch(() => this.errorCallback()); - } - }, successCallback(resp) { const response = { headers: resp.headers, @@ -190,33 +135,14 @@ }; this.store.storeCount(response.body.count); - this.store.storePipelines(response.body.pipelines); this.store.storePagination(response.headers); - - this.isLoading = false; - this.updateGraphDropdown = true; - this.hasMadeRequest = true; - }, - - errorCallback() { - this.hasError = true; - this.isLoading = false; - this.updateGraphDropdown = false; - }, - - setIsMakingRequest(isMakingRequest) { - this.isMakingRequest = isMakingRequest; - - if (isMakingRequest) { - this.updateGraphDropdown = false; - } + this.setCommonData(response.body.pipelines); }, }, }; </script> <template> <div :class="cssClass"> - <div class="top-area scrolling-tabs-container inner-page-scroll-tabs" v-if="!isLoading && !shouldRenderEmptyState"> @@ -274,7 +200,6 @@ <pipelines-table-component :pipelines="state.pipelines" - :service="service" :update-graph-dropdown="updateGraphDropdown" /> </div> diff --git a/app/assets/javascripts/pipelines/components/pipelines_actions.vue b/app/assets/javascripts/pipelines/components/pipelines_actions.vue index 97b4de26214..01dfe51cc17 100644 --- a/app/assets/javascripts/pipelines/components/pipelines_actions.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_actions.vue @@ -4,6 +4,7 @@ import playIconSvg from 'icons/_icon_play.svg'; import eventHub from '../event_hub'; import loadingIcon from '../../vue_shared/components/loading_icon.vue'; + import tooltip from '../../vue_shared/directives/tooltip'; export default { props: { @@ -11,10 +12,9 @@ type: Array, required: true, }, - service: { - type: Object, - required: true, - }, + }, + directives: { + tooltip, }, components: { loadingIcon, @@ -29,19 +29,9 @@ onClickAction(endpoint) { this.isLoading = true; - $(this.$refs.tooltip).tooltip('destroy'); - - this.service.postAction(endpoint) - .then(() => { - this.isLoading = false; - eventHub.$emit('refreshPipelines'); - }) - .catch(() => { - this.isLoading = false; - // eslint-disable-next-line no-new - new Flash('An error occured while making the request.'); - }); + eventHub.$emit('postAction', endpoint); }, + isActionDisabled(action) { if (action.playable === undefined) { return false; @@ -55,13 +45,13 @@ <template> <div class="btn-group"> <button + v-tooltip type="button" - class="dropdown-new btn btn-default has-tooltip js-pipeline-dropdown-manual-actions" + class="dropdown-new btn btn-default js-pipeline-dropdown-manual-actions" title="Manual job" data-toggle="dropdown" data-placement="top" aria-label="Manual job" - ref="tooltip" :disabled="isLoading"> <span v-html="playIconSvg"></span> <i diff --git a/app/assets/javascripts/pipelines/components/pipelines_artifacts.vue b/app/assets/javascripts/pipelines/components/pipelines_artifacts.vue index b4520481cdc..b19bd509a00 100644 --- a/app/assets/javascripts/pipelines/components/pipelines_artifacts.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_artifacts.vue @@ -1,5 +1,5 @@ <script> - import tooltipMixin from '../../vue_shared/mixins/tooltip'; + import tooltip from '../../vue_shared/directives/tooltip'; export default { props: { @@ -8,9 +8,9 @@ required: true, }, }, - mixins: [ - tooltipMixin, - ], + directives: { + tooltip, + }, }; </script> <template> @@ -18,12 +18,12 @@ class="btn-group" role="group"> <button + v-tooltip class="dropdown-toggle btn btn-default build-artifacts js-pipeline-dropdown-download" title="Artifacts" data-placement="top" data-toggle="dropdown" - aria-label="Artifacts" - ref="tooltip"> + aria-label="Artifacts"> <i class="fa fa-download" aria-hidden="true"> diff --git a/app/assets/javascripts/vue_shared/components/pipelines_table.vue b/app/assets/javascripts/pipelines/components/pipelines_table.vue index 884f1ce9689..5088d92209f 100644 --- a/app/assets/javascripts/vue_shared/components/pipelines_table.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_table.vue @@ -12,10 +12,6 @@ type: Array, required: true, }, - service: { - type: Object, - required: true, - }, updateGraphDropdown: { type: Boolean, required: false, @@ -57,7 +53,6 @@ v-for="model in pipelines" :key="model.id" :pipeline="model" - :service="service" :update-graph-dropdown="updateGraphDropdown" /> </div> diff --git a/app/assets/javascripts/vue_shared/components/pipelines_table_row.vue b/app/assets/javascripts/pipelines/components/pipelines_table_row.vue index 4d5ebe2e9ed..c3f1c426d8a 100644 --- a/app/assets/javascripts/vue_shared/components/pipelines_table_row.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_table_row.vue @@ -1,13 +1,13 @@ <script> /* eslint-disable no-param-reassign */ -import asyncButtonComponent from '../../pipelines/components/async_button.vue'; -import pipelinesActionsComponent from '../../pipelines/components/pipelines_actions.vue'; -import pipelinesArtifactsComponent from '../../pipelines/components/pipelines_artifacts.vue'; -import ciBadge from './ci_badge_link.vue'; -import pipelineStage from '../../pipelines/components/stage.vue'; -import pipelineUrl from '../../pipelines/components/pipeline_url.vue'; -import pipelinesTimeago from '../../pipelines/components/time_ago.vue'; -import commitComponent from './commit.vue'; +import asyncButtonComponent from './async_button.vue'; +import pipelinesActionsComponent from './pipelines_actions.vue'; +import pipelinesArtifactsComponent from './pipelines_artifacts.vue'; +import ciBadge from '../../vue_shared/components/ci_badge_link.vue'; +import pipelineStage from './stage.vue'; +import pipelineUrl from './pipeline_url.vue'; +import pipelinesTimeago from './time_ago.vue'; +import commitComponent from '../../vue_shared/components/commit.vue'; /** * Pipeline table row. @@ -20,10 +20,6 @@ export default { type: Object, required: true, }, - service: { - type: Object, - required: true, - }, updateGraphDropdown: { type: Boolean, required: false, @@ -271,7 +267,6 @@ export default { <pipelines-actions-component v-if="pipeline.details.manual_actions.length" :actions="pipeline.details.manual_actions" - :service="service" /> <pipelines-artifacts-component @@ -282,7 +277,6 @@ export default { <async-button-component v-if="pipeline.flags.retryable" - :service="service" :endpoint="pipeline.retry_path" css-class="js-pipelines-retry-button btn-default btn-retry" title="Retry" @@ -291,7 +285,6 @@ export default { <async-button-component v-if="pipeline.flags.cancelable" - :service="service" :endpoint="pipeline.cancel_path" css-class="js-pipelines-cancel-button btn-remove" title="Cancel" diff --git a/app/assets/javascripts/pipelines/components/stage.vue b/app/assets/javascripts/pipelines/components/stage.vue index c05c76c9a64..87b2725a045 100644 --- a/app/assets/javascripts/pipelines/components/stage.vue +++ b/app/assets/javascripts/pipelines/components/stage.vue @@ -16,7 +16,7 @@ /* global Flash */ import { borderlessStatusIconEntityMap } from '../../vue_shared/ci_status_icons'; import loadingIcon from '../../vue_shared/components/loading_icon.vue'; -import tooltipMixin from '../../vue_shared/mixins/tooltip'; +import tooltip from '../../vue_shared/directives/tooltip'; export default { props: { @@ -32,15 +32,14 @@ export default { }, }, - mixins: [ - tooltipMixin, - ], + directives: { + tooltip, + }, data() { return { isLoading: false, dropdownContent: '', - endpoint: this.stage.dropdown_path, }; }, @@ -73,7 +72,7 @@ export default { }, fetchJobs() { - this.$http.get(this.endpoint) + this.$http.get(this.stage.dropdown_path) .then((response) => { this.dropdownContent = response.json().html; this.isLoading = false; @@ -132,7 +131,7 @@ export default { <template> <div class="dropdown"> <button - ref="tooltip" + v-tooltip :class="triggerButtonClass" @click="onClickStage" class="mini-pipeline-graph-dropdown-toggle js-builds-dropdown-button" diff --git a/app/assets/javascripts/pipelines/components/time_ago.vue b/app/assets/javascripts/pipelines/components/time_ago.vue index be3f32afa09..037684b4e72 100644 --- a/app/assets/javascripts/pipelines/components/time_ago.vue +++ b/app/assets/javascripts/pipelines/components/time_ago.vue @@ -1,7 +1,7 @@ <script> import iconTimerSvg from 'icons/_icon_timer.svg'; import '../../lib/utils/datetime_utility'; - import tooltipMixin from '../../vue_shared/mixins/tooltip'; + import tooltip from '../../vue_shared/directives/tooltip'; import timeagoMixin from '../../vue_shared/mixins/timeago'; export default { @@ -16,9 +16,11 @@ }, }, mixins: [ - tooltipMixin, timeagoMixin, ], + directives: { + tooltip, + }, data() { return { iconTimerSvg, @@ -81,7 +83,7 @@ </i> <time - ref="tooltip" + v-tooltip data-placement="top" data-container="body" :title="tooltipTitle(finishedTime)"> diff --git a/app/assets/javascripts/pipelines/mixins/pipelines.js b/app/assets/javascripts/pipelines/mixins/pipelines.js new file mode 100644 index 00000000000..9adc15e6266 --- /dev/null +++ b/app/assets/javascripts/pipelines/mixins/pipelines.js @@ -0,0 +1,103 @@ +/* global Flash */ +import '~/flash'; +import Visibility from 'visibilityjs'; +import Poll from '../../lib/utils/poll'; +import emptyState from '../components/empty_state.vue'; +import errorState from '../components/error_state.vue'; +import loadingIcon from '../../vue_shared/components/loading_icon.vue'; +import pipelinesTableComponent from '../components/pipelines_table.vue'; +import eventHub from '../event_hub'; + +export default { + components: { + pipelinesTableComponent, + errorState, + emptyState, + loadingIcon, + }, + computed: { + shouldRenderErrorState() { + return this.hasError && !this.isLoading; + }, + }, + data() { + return { + isLoading: false, + hasError: false, + isMakingRequest: false, + updateGraphDropdown: false, + hasMadeRequest: false, + }; + }, + beforeMount() { + this.poll = new Poll({ + resource: this.service, + method: 'getPipelines', + data: this.requestData ? this.requestData : undefined, + successCallback: this.successCallback, + errorCallback: this.errorCallback, + notificationCallback: this.setIsMakingRequest, + }); + + if (!Visibility.hidden()) { + this.isLoading = true; + this.poll.makeRequest(); + } else { + // If tab is not visible we need to make the first request so we don't show the empty + // state without knowing if there are any pipelines + this.fetchPipelines(); + } + + Visibility.change(() => { + if (!Visibility.hidden()) { + this.poll.restart(); + } else { + this.poll.stop(); + } + }); + + eventHub.$on('refreshPipelines', this.fetchPipelines); + eventHub.$on('postAction', this.postAction); + }, + beforeDestroy() { + eventHub.$off('refreshPipelines'); + eventHub.$on('postAction', this.postAction); + }, + destroyed() { + this.poll.stop(); + }, + methods: { + fetchPipelines() { + if (!this.isMakingRequest) { + this.isLoading = true; + + this.service.getPipelines(this.requestData) + .then(response => this.successCallback(response)) + .catch(() => this.errorCallback()); + } + }, + setCommonData(pipelines) { + this.store.storePipelines(pipelines); + this.isLoading = false; + this.updateGraphDropdown = true; + this.hasMadeRequest = true; + }, + errorCallback() { + this.hasError = true; + this.isLoading = false; + this.updateGraphDropdown = false; + }, + setIsMakingRequest(isMakingRequest) { + this.isMakingRequest = isMakingRequest; + + if (isMakingRequest) { + this.updateGraphDropdown = false; + } + }, + postAction(endpoint) { + this.service.postAction(endpoint) + .then(() => eventHub.$emit('refreshPipelines')) + .catch(() => new Flash('An error occured while making the request.')); + }, + }, +}; diff --git a/app/assets/javascripts/prometheus_metrics/constants.js b/app/assets/javascripts/prometheus_metrics/constants.js new file mode 100644 index 00000000000..50f1248456e --- /dev/null +++ b/app/assets/javascripts/prometheus_metrics/constants.js @@ -0,0 +1,5 @@ +export default { + EMPTY: 'empty', + LOADING: 'loading', + LIST: 'list', +}; diff --git a/app/assets/javascripts/prometheus_metrics/index.js b/app/assets/javascripts/prometheus_metrics/index.js new file mode 100644 index 00000000000..a0c43c5abe1 --- /dev/null +++ b/app/assets/javascripts/prometheus_metrics/index.js @@ -0,0 +1,6 @@ +import PrometheusMetrics from './prometheus_metrics'; + +$(() => { + const prometheusMetrics = new PrometheusMetrics('.js-prometheus-metrics-monitoring'); + prometheusMetrics.loadActiveMetrics(); +}); diff --git a/app/assets/javascripts/prometheus_metrics/prometheus_metrics.js b/app/assets/javascripts/prometheus_metrics/prometheus_metrics.js new file mode 100644 index 00000000000..ef4d6df5138 --- /dev/null +++ b/app/assets/javascripts/prometheus_metrics/prometheus_metrics.js @@ -0,0 +1,109 @@ +import PANEL_STATE from './constants'; + +export default class PrometheusMetrics { + constructor(wrapperSelector) { + this.backOffRequestCounter = 0; + + this.$wrapper = $(wrapperSelector); + + this.$monitoredMetricsPanel = this.$wrapper.find('.js-panel-monitored-metrics'); + this.$monitoredMetricsCount = this.$monitoredMetricsPanel.find('.js-monitored-count'); + this.$monitoredMetricsLoading = this.$monitoredMetricsPanel.find('.js-loading-metrics'); + this.$monitoredMetricsEmpty = this.$monitoredMetricsPanel.find('.js-empty-metrics'); + this.$monitoredMetricsList = this.$monitoredMetricsPanel.find('.js-metrics-list'); + + this.$missingEnvVarPanel = this.$wrapper.find('.js-panel-missing-env-vars'); + this.$panelToggle = this.$missingEnvVarPanel.find('.js-panel-toggle'); + this.$missingEnvVarMetricCount = this.$missingEnvVarPanel.find('.js-env-var-count'); + this.$missingEnvVarMetricsList = this.$missingEnvVarPanel.find('.js-missing-var-metrics-list'); + + this.activeMetricsEndpoint = this.$monitoredMetricsPanel.data('active-metrics'); + + this.$panelToggle.on('click', e => this.handlePanelToggle(e)); + } + + /* eslint-disable class-methods-use-this */ + handlePanelToggle(e) { + const $toggleBtn = $(e.currentTarget); + const $currentPanelBody = $toggleBtn.closest('.panel').find('.panel-body'); + $currentPanelBody.toggleClass('hidden'); + if ($toggleBtn.hasClass('fa-caret-down')) { + $toggleBtn.removeClass('fa-caret-down').addClass('fa-caret-right'); + } else { + $toggleBtn.removeClass('fa-caret-right').addClass('fa-caret-down'); + } + } + + showMonitoringMetricsPanelState(stateName) { + switch (stateName) { + case PANEL_STATE.LOADING: + this.$monitoredMetricsLoading.removeClass('hidden'); + this.$monitoredMetricsEmpty.addClass('hidden'); + this.$monitoredMetricsList.addClass('hidden'); + break; + case PANEL_STATE.LIST: + this.$monitoredMetricsLoading.addClass('hidden'); + this.$monitoredMetricsEmpty.addClass('hidden'); + this.$monitoredMetricsList.removeClass('hidden'); + break; + default: + this.$monitoredMetricsLoading.addClass('hidden'); + this.$monitoredMetricsEmpty.removeClass('hidden'); + this.$monitoredMetricsList.addClass('hidden'); + break; + } + } + + populateActiveMetrics(metrics) { + let totalMonitoredMetrics = 0; + let totalMissingEnvVarMetrics = 0; + + metrics.forEach((metric) => { + this.$monitoredMetricsList.append(`<li>${metric.group}<span class="badge">${metric.active_metrics}</span></li>`); + totalMonitoredMetrics += metric.active_metrics; + if (metric.metrics_missing_requirements > 0) { + this.$missingEnvVarMetricsList.append(`<li>${metric.group}</li>`); + totalMissingEnvVarMetrics += 1; + } + }); + + this.$monitoredMetricsCount.text(totalMonitoredMetrics); + this.showMonitoringMetricsPanelState(PANEL_STATE.LIST); + + if (totalMissingEnvVarMetrics > 0) { + this.$missingEnvVarPanel.removeClass('hidden'); + this.$missingEnvVarPanel.find('.flash-container').off('click'); + this.$missingEnvVarMetricCount.text(totalMissingEnvVarMetrics); + } + } + + loadActiveMetrics() { + this.showMonitoringMetricsPanelState(PANEL_STATE.LOADING); + gl.utils.backOff((next, stop) => { + $.getJSON(this.activeMetricsEndpoint) + .done((res) => { + if (res && res.success) { + stop(res); + } else { + this.backOffRequestCounter = this.backOffRequestCounter += 1; + if (this.backOffRequestCounter < 3) { + next(); + } else { + stop(res); + } + } + }) + .fail(stop); + }) + .then((res) => { + if (res && res.data && res.data.length) { + this.populateActiveMetrics(res.data); + } else { + this.showMonitoringMetricsPanelState(PANEL_STATE.EMPTY); + } + }) + .catch(() => { + this.showMonitoringMetricsPanelState(PANEL_STATE.EMPTY); + }); + } +} diff --git a/app/assets/javascripts/right_sidebar.js b/app/assets/javascripts/right_sidebar.js index b71c3097706..322162afdb8 100644 --- a/app/assets/javascripts/right_sidebar.js +++ b/app/assets/javascripts/right_sidebar.js @@ -7,6 +7,11 @@ import Cookies from 'js-cookie'; function Sidebar(currentUser) { this.toggleTodo = this.toggleTodo.bind(this); this.sidebar = $('aside'); + + this.$sidebarInner = this.sidebar.find('.issuable-sidebar'); + this.$navGitlab = $('.navbar-gitlab'); + this.$rightSidebar = $('.js-right-sidebar'); + this.removeListeners(); this.addEventListeners(); } @@ -21,14 +26,15 @@ import Cookies from 'js-cookie'; Sidebar.prototype.addEventListeners = function() { const $document = $(document); - const throttledSetSidebarHeight = _.throttle(this.setSidebarHeight, 10); + const throttledSetSidebarHeight = _.throttle(this.setSidebarHeight.bind(this), 20); + const debouncedSetSidebarHeight = _.debounce(this.setSidebarHeight.bind(this), 200); this.sidebar.on('click', '.sidebar-collapsed-icon', this, this.sidebarCollapseClicked); $('.dropdown').on('hidden.gl.dropdown', this, this.onSidebarDropdownHidden); $('.dropdown').on('loading.gl.dropdown', this.sidebarDropdownLoading); $('.dropdown').on('loaded.gl.dropdown', this.sidebarDropdownLoaded); $(window).on('resize', () => throttledSetSidebarHeight()); - $document.on('scroll', () => throttledSetSidebarHeight()); + $document.on('scroll', () => debouncedSetSidebarHeight()); $document.on('click', '.js-sidebar-toggle', function(e, triggered) { var $allGutterToggleIcons, $this, $thisIcon; e.preventDefault(); @@ -207,13 +213,14 @@ import Cookies from 'js-cookie'; }; Sidebar.prototype.setSidebarHeight = function() { - const $navHeight = $('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight() + $('.sub-nav-scroll').outerHeight(); - const $rightSidebar = $('.js-right-sidebar'); + const $navHeight = this.$navGitlab.outerHeight(); const diff = $navHeight - $(window).scrollTop(); if (diff > 0) { - $rightSidebar.outerHeight($(window).height() - diff); + this.$rightSidebar.outerHeight($(window).height() - diff); + this.$sidebarInner.height('100%'); } else { - $rightSidebar.outerHeight('100%'); + this.$rightSidebar.outerHeight('100%'); + this.$sidebarInner.height(''); } }; diff --git a/app/assets/javascripts/settings_panels.js b/app/assets/javascripts/settings_panels.js index e67f449e1a2..7fa5996d600 100644 --- a/app/assets/javascripts/settings_panels.js +++ b/app/assets/javascripts/settings_panels.js @@ -1,11 +1,28 @@ +function expandSectionParent($section, $content) { + $section.addClass('expanded'); + $content.off('animationend.expandSectionParent'); +} + function expandSection($section) { - $section.find('.js-settings-toggle').text('Close'); - $section.find('.settings-content').addClass('expanded').off('scroll').scrollTop(0); + $section.find('.js-settings-toggle').text('Collapse'); + + const $content = $section.find('.settings-content'); + $content.addClass('expanded').off('scroll.expandSection').scrollTop(0); + + if ($content.hasClass('no-animate')) { + expandSectionParent($section, $content); + } else { + $content.on('animationend.expandSectionParent', () => expandSectionParent($section, $content)); + } } function closeSection($section) { $section.find('.js-settings-toggle').text('Expand'); - $section.find('.settings-content').removeClass('expanded').on('scroll', () => expandSection($section)); + + const $content = $section.find('.settings-content'); + $content.removeClass('expanded').on('scroll.expandSection', () => expandSection($section)); + + $section.removeClass('expanded'); } function toggleSection($section) { @@ -21,7 +38,7 @@ function toggleSection($section) { export default function initSettingsPanels() { $('.settings').each((i, elm) => { const $section = $(elm); - $section.on('click', '.js-settings-toggle', () => toggleSection($section)); - $section.find('.settings-content:not(.expanded)').on('scroll', () => expandSection($section)); + $section.on('click.toggleSection', '.js-settings-toggle', () => toggleSection($section)); + $section.find('.settings-content:not(.expanded)').on('scroll.expandSection', () => expandSection($section)); }); } diff --git a/app/assets/javascripts/sidebar/components/assignees/assignee_title.js b/app/assets/javascripts/sidebar/components/assignees/assignee_title.js index a9ad3708514..5a6e47e566e 100644 --- a/app/assets/javascripts/sidebar/components/assignees/assignee_title.js +++ b/app/assets/javascripts/sidebar/components/assignees/assignee_title.js @@ -14,6 +14,11 @@ export default { type: Boolean, required: true, }, + showToggle: { + type: Boolean, + required: false, + default: false, + }, }, computed: { assigneeTitle() { @@ -36,6 +41,19 @@ export default { > Edit </a> + <a + v-if="showToggle" + aria-label="Toggle sidebar" + class="gutter-toggle pull-right js-sidebar-toggle" + href="#" + role="button" + > + <i + aria-hidden="true" + data-hidden="true" + class="fa fa-angle-double-right" + /> + </a> </div> `, }; diff --git a/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.js b/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.js index da4abf0b68f..f83c3b037ed 100644 --- a/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.js +++ b/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.js @@ -64,6 +64,7 @@ export default { }, beforeMount() { this.field = this.$el.dataset.field; + this.signedIn = typeof this.$el.dataset.signedIn !== 'undefined'; }, template: ` <div> @@ -71,6 +72,7 @@ export default { :number-of-assignees="store.assignees.length" :loading="loading || store.isFetching.assignees" :editable="store.editable" + :show-toggle="!signedIn" /> <assignees v-if="!store.isFetching.assignees" diff --git a/app/assets/javascripts/users_select.js b/app/assets/javascripts/users_select.js index ec45253e50b..46efdcf4202 100644 --- a/app/assets/javascripts/users_select.js +++ b/app/assets/javascripts/users_select.js @@ -643,7 +643,7 @@ UsersSelect.prototype.formatResult = function(user) { } else { avatar = gon.default_avatar_url; } - return "<div class='user-result " + (!user.username ? 'no-username' : void 0) + "'> <div class='user-image'><img class='avatar s24' src='" + avatar + "'></div> <div class='user-name'>" + user.name + "</div> <div class='user-username'>" + (user.username || "") + "</div> </div>"; + return "<div class='user-result " + (!user.username ? 'no-username' : void 0) + "'> <div class='user-image'><img class='avatar avatar-inline s32' src='" + avatar + "'></div> <div class='user-name dropdown-menu-user-full-name'>" + user.name + "</div> <div class='user-username dropdown-menu-user-username'>" + ("@" + user.username || "") + "</div> </div>"; }; UsersSelect.prototype.formatSelection = function(user) { diff --git a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.js b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.js index c02e10128e2..e8b3cf2f729 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.js +++ b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.js @@ -17,6 +17,9 @@ export default { return hasCI && !ciStatus; }, + hasPipeline() { + return Object.keys(this.mr.pipeline || {}).length > 0; + }, svg() { return statusIconEntityMap.icon_status_failed; }, @@ -30,7 +33,11 @@ export default { template: ` <div class="mr-widget-heading"> <div class="ci-widget"> - <template v-if="hasCIError"> + <template v-if="!hasPipeline"> + <i class="fa fa-spinner fa-spin append-right-10" aria-hidden="true"></i> + Waiting for pipeline... + </template> + <template v-else-if="hasCIError"> <div class="ci-status-icon ci-status-icon-failed ci-error js-ci-error"> <span class="js-icon-link icon-link"> <span diff --git a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.js b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.js index 686cb38cbb1..205804670fa 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.js +++ b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.js @@ -1,63 +1,42 @@ export default { name: 'MRWidgetRelatedLinks', props: { - isMerged: { type: Boolean, required: true }, relatedLinks: { type: Object, required: true }, }, computed: { - // TODO: the following should be handled by i18n - closingText() { - if (this.isMerged) { - return `Closed ${this.issueLabel('closing')}`; - } - - return `Closes ${this.issueLabel('closing')}`; - }, hasLinks() { const { closing, mentioned, assignToMe } = this.relatedLinks; return closing || mentioned || assignToMe; }, - // TODO: the following should be handled by i18n - mentionedText() { - if (this.isMerged) { - if (this.hasMultipleIssues(this.relatedLinks.mentioned)) { - return 'are mentioned but were not closed'; - } - - return 'is mentioned but was not closed'; - } - - if (this.hasMultipleIssues(this.relatedLinks.mentioned)) { - return 'are mentioned but will not be closed'; - } - - return 'is mentioned but will not be closed'; - }, }, methods: { hasMultipleIssues(text) { - return /<\/a>,? and <a/.test(text); + return !text ? false : text.match(/<\/a> and <a/); }, - // TODO: the following should be handled by i18n issueLabel(field) { return this.hasMultipleIssues(this.relatedLinks[field]) ? 'issues' : 'issue'; }, + verbLabel(field) { + return this.hasMultipleIssues(this.relatedLinks[field]) ? 'are' : 'is'; + }, }, template: ` - <div v-if="hasLinks"> + <section + v-if="hasLinks" + class="mr-info-list mr-links"> <div class="legend"></div> <p v-if="relatedLinks.closing"> - {{closingText}} + Closes {{issueLabel('closing')}} <span v-html="relatedLinks.closing"></span>. </p> <p v-if="relatedLinks.mentioned"> <span class="capitalize">{{issueLabel('mentioned')}}</span> <span v-html="relatedLinks.mentioned"></span> - {{mentionedText}} + {{verbLabel('mentioned')}} mentioned but will not be closed. </p> <p v-if="relatedLinks.assignToMe"> <span v-html="relatedLinks.assignToMe"></span> </p> - </div> + </section> `, }; diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merged.js b/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merged.js index 9b8eed9016d..c7d32d18141 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merged.js +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merged.js @@ -1,9 +1,7 @@ /* global Flash */ import mrWidgetAuthorTime from '../../components/mr_widget_author_time'; -import mrWidgetRelatedLinks from '../../components/mr_widget_related_links'; import eventHub from '../../event_hub'; -import '../../../flash'; export default { name: 'MRWidgetMerged', @@ -13,7 +11,6 @@ export default { }, components: { 'mr-widget-author-and-time': mrWidgetAuthorTime, - 'mr-widget-related-links': mrWidgetRelatedLinks, }, data() { return { @@ -21,9 +18,6 @@ export default { }; }, computed: { - shouldRenderRelatedLinks() { - return this.mr.relatedLinks && this.mr.isMerged; - }, shouldShowRemoveSourceBranch() { const { sourceBranchRemoved, isRemovingSourceBranch, canRemoveSourceBranch } = this.mr; @@ -92,10 +86,6 @@ export default { aria-hidden="true" /> The source branch is being removed. </p> - <mr-widget-related-links - v-if="shouldRenderRelatedLinks" - :is-merged="mr.isMerged()" - :related-links="mr.relatedLinks" /> </section> <div v-if="shouldShowMergedButtons" diff --git a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js index 222d0b7f79e..2339a00ddd0 100644 --- a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js +++ b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js @@ -48,7 +48,7 @@ export default { return stateMaps.stateToComponentMap[this.mr.state]; }, shouldRenderMergeHelp() { - return !this.mr.isMerged; + return stateMaps.statesToShowHelpWidget.indexOf(this.mr.state) > -1; }, shouldRenderPipelines() { return Object.keys(this.mr.pipeline).length || this.mr.hasCI; @@ -238,14 +238,9 @@ export default { :is="componentName" :mr="mr" :service="service" /> - <section + <mr-widget-related-links v-if="shouldRenderRelatedLinks" - class="mr-info-list mr-links"> - <div class="legend"></div> - <mr-widget-related-links - :is-merged="mr.isMerged" - :related-links="mr.relatedLinks" /> - </section> + :related-links="mr.relatedLinks" /> <mr-widget-merge-help v-if="shouldRenderMergeHelp" /> </div> `, diff --git a/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js b/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js index ad73efb37e1..69bc1436284 100644 --- a/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js +++ b/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js @@ -1,18 +1,6 @@ import Timeago from 'timeago.js'; import { getStateKey } from '../dependencies'; -const unmergedStates = [ - 'locked', - 'conflicts', - 'workInProgress', - 'readyToMerge', - 'checking', - 'unresolvedDiscussions', - 'pipelineFailed', - 'pipelineBlocked', - 'autoMergeFailed', -]; - export default class MergeRequestStore { constructor(data) { @@ -77,7 +65,6 @@ export default class MergeRequestStore { this.mergeActionsContentPath = data.commit_change_content_path; this.isRemovingSourceBranch = this.isRemovingSourceBranch || false; this.isOpen = data.state === 'opened' || data.state === 'reopened' || false; - this.isMerged = unmergedStates.indexOf(data.state) === -1; this.hasMergeableDiscussionsState = data.mergeable_discussions_state === false; this.canRemoveSourceBranch = currentUser.can_remove_source_branch || false; this.canMerge = !!data.merge_path; diff --git a/app/assets/javascripts/vue_merge_request_widget/stores/state_maps.js b/app/assets/javascripts/vue_merge_request_widget/stores/state_maps.js index dd939d98d0f..605dd3a1ff4 100644 --- a/app/assets/javascripts/vue_merge_request_widget/stores/state_maps.js +++ b/app/assets/javascripts/vue_merge_request_widget/stores/state_maps.js @@ -19,6 +19,19 @@ const stateToComponentMap = { shaMismatch: 'mr-widget-sha-mismatch', }; +const statesToShowHelpWidget = [ + 'locked', + 'conflicts', + 'workInProgress', + 'readyToMerge', + 'checking', + 'unresolvedDiscussions', + 'pipelineFailed', + 'pipelineBlocked', + 'autoMergeFailed', +]; + export default { stateToComponentMap, + statesToShowHelpWidget, }; diff --git a/app/assets/javascripts/vue_shared/components/header_ci_component.vue b/app/assets/javascripts/vue_shared/components/header_ci_component.vue index 1d4d90f75b6..bdc059f4a03 100644 --- a/app/assets/javascripts/vue_shared/components/header_ci_component.vue +++ b/app/assets/javascripts/vue_shared/components/header_ci_component.vue @@ -2,7 +2,7 @@ import ciIconBadge from './ci_badge_link.vue'; import loadingIcon from './loading_icon.vue'; import timeagoTooltip from './time_ago_tooltip.vue'; -import tooltipMixin from '../mixins/tooltip'; +import tooltip from '../directives/tooltip'; import userAvatarImage from './user_avatar/user_avatar_image.vue'; /** @@ -47,9 +47,9 @@ export default { }, }, - mixins: [ - tooltipMixin, - ], + directives: { + tooltip, + }, components: { ciIconBadge, @@ -90,10 +90,10 @@ export default { <template v-if="user"> <a + v-tooltip :href="user.path" :title="user.email" - class="js-user-link commit-committer-link" - ref="tooltip"> + class="js-user-link commit-committer-link"> <user-avatar-image :img-src="user.avatar_url" diff --git a/app/assets/javascripts/vue_shared/components/loading_icon.vue b/app/assets/javascripts/vue_shared/components/loading_icon.vue index 41b1d0165b0..15581d5c2a0 100644 --- a/app/assets/javascripts/vue_shared/components/loading_icon.vue +++ b/app/assets/javascripts/vue_shared/components/loading_icon.vue @@ -12,9 +12,18 @@ required: false, default: '1', }, + + inline: { + type: Boolean, + required: false, + default: false, + }, }, computed: { + rootElementType() { + return this.inline ? 'span' : 'div'; + }, cssClass() { return `fa-${this.size}x`; }, @@ -22,12 +31,14 @@ }; </script> <template> - <div class="text-center"> + <component + :is="this.rootElementType" + class="text-center"> <i class="fa fa-spin fa-spinner" :class="cssClass" aria-hidden="true" :aria-label="label"> </i> - </div> + </component> </template> diff --git a/app/assets/javascripts/vue_shared/components/markdown/header.vue b/app/assets/javascripts/vue_shared/components/markdown/header.vue index 1a11f493b7f..5bf2a90cc3b 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/header.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/header.vue @@ -1,17 +1,17 @@ <script> - import tooltipMixin from '../../mixins/tooltip'; + import tooltip from '../../directives/tooltip'; import toolbarButton from './toolbar_button.vue'; export default { - mixins: [ - tooltipMixin, - ], props: { previewMarkdown: { type: Boolean, required: true, }, }, + directives: { + tooltip, + }, components: { toolbarButton, }, @@ -94,13 +94,13 @@ </div> <div class="toolbar-group"> <button + v-tooltip aria-label="Go full screen" class="toolbar-btn js-zen-enter" data-container="body" tabindex="-1" title="Go full screen" - type="button" - ref="tooltip"> + type="button"> <i aria-hidden="true" class="fa fa-arrows-alt fa-fw"> diff --git a/app/assets/javascripts/vue_shared/components/markdown/toolbar_button.vue b/app/assets/javascripts/vue_shared/components/markdown/toolbar_button.vue index 096be507625..f7da7ebfcfe 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/toolbar_button.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/toolbar_button.vue @@ -1,10 +1,7 @@ <script> - import tooltipMixin from '../../mixins/tooltip'; + import tooltip from '../../directives/tooltip'; export default { - mixins: [ - tooltipMixin, - ], props: { buttonTitle: { type: String, @@ -29,6 +26,9 @@ default: false, }, }, + directives: { + tooltip, + }, computed: { iconClass() { return `fa-${this.icon}`; @@ -39,10 +39,10 @@ <template> <button + v-tooltip type="button" class="toolbar-btn js-md hidden-xs" tabindex="-1" - ref="tooltip" data-container="body" :data-md-tag="tag" :data-md-block="tagBlock" diff --git a/app/assets/javascripts/vue_shared/components/time_ago_tooltip.vue b/app/assets/javascripts/vue_shared/components/time_ago_tooltip.vue index 1c6ef071a6d..3ff7f6e2c4e 100644 --- a/app/assets/javascripts/vue_shared/components/time_ago_tooltip.vue +++ b/app/assets/javascripts/vue_shared/components/time_ago_tooltip.vue @@ -1,5 +1,5 @@ <script> -import tooltipMixin from '../mixins/tooltip'; +import tooltip from '../directives/tooltip'; import timeagoMixin from '../mixins/timeago'; import '../../lib/utils/datetime_utility'; @@ -28,19 +28,21 @@ export default { }, mixins: [ - tooltipMixin, timeagoMixin, ], + + directives: { + tooltip, + }, }; </script> <template> <time + v-tooltip :class="cssClass" - class="js-vue-timeago" :title="tooltipTitle(time)" :data-placement="tooltipPlacement" - data-container="body" - ref="tooltip"> + data-container="body"> {{timeFormated(time)}} </time> </template> diff --git a/app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_image.vue b/app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_image.vue index cd6f8c7aee4..dd9a2ebb184 100644 --- a/app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_image.vue +++ b/app/assets/javascripts/vue_shared/components/user_avatar/user_avatar_image.vue @@ -16,11 +16,10 @@ */ import defaultAvatarUrl from 'images/no_avatar.png'; -import TooltipMixin from '../../mixins/tooltip'; +import tooltip from '../../directives/tooltip'; export default { name: 'UserAvatarImage', - mixins: [TooltipMixin], props: { imgSrc: { type: String, @@ -53,6 +52,9 @@ export default { default: 'top', }, }, + directives: { + tooltip, + }, computed: { tooltipContainer() { return this.tooltipText ? 'body' : null; @@ -72,6 +74,7 @@ export default { <template> <img + v-tooltip class="avatar" :class="[avatarSizeClass, cssClasses]" :src="imageSource" @@ -81,6 +84,5 @@ export default { :data-container="tooltipContainer" :data-placement="tooltipPlacement" :title="tooltipText" - ref="tooltip" /> </template> diff --git a/app/assets/javascripts/vue_shared/directives/tooltip.js b/app/assets/javascripts/vue_shared/directives/tooltip.js new file mode 100644 index 00000000000..dc896cf5c7d --- /dev/null +++ b/app/assets/javascripts/vue_shared/directives/tooltip.js @@ -0,0 +1,13 @@ +export default { + bind(el) { + $(el).tooltip(); + }, + + componentUpdated(el) { + $(el).tooltip('fixTitle'); + }, + + unbind(el) { + $(el).tooltip('destroy'); + }, +}; diff --git a/app/assets/javascripts/vue_shared/mixins/tooltip.js b/app/assets/javascripts/vue_shared/mixins/tooltip.js deleted file mode 100644 index 995c0c98505..00000000000 --- a/app/assets/javascripts/vue_shared/mixins/tooltip.js +++ /dev/null @@ -1,13 +0,0 @@ -export default { - mounted() { - $(this.$refs.tooltip).tooltip(); - }, - - updated() { - $(this.$refs.tooltip).tooltip('fixTitle'); - }, - - beforeDestroy() { - $(this.$refs.tooltip).tooltip('destroy'); - }, -}; diff --git a/app/assets/stylesheets/framework/blocks.scss b/app/assets/stylesheets/framework/blocks.scss index fefe5575d9b..95a08c960ea 100644 --- a/app/assets/stylesheets/framework/blocks.scss +++ b/app/assets/stylesheets/framework/blocks.scss @@ -254,7 +254,7 @@ } .landing { - margin-bottom: $gl-padding; + margin: $gl-padding auto; overflow: hidden; display: flex; position: relative; diff --git a/app/assets/stylesheets/framework/dropdowns.scss b/app/assets/stylesheets/framework/dropdowns.scss index cba890ce831..4f54ca24940 100644 --- a/app/assets/stylesheets/framework/dropdowns.scss +++ b/app/assets/stylesheets/framework/dropdowns.scss @@ -395,6 +395,11 @@ .dropdown-menu-align-right { left: auto; right: 0; + margin-top: -5px; + + @media (max-width: $screen-xs-max) { + left: 0; + } } .dropdown-menu-selectable { diff --git a/app/assets/stylesheets/framework/files.scss b/app/assets/stylesheets/framework/files.scss index da03e4f5b5e..245117b2559 100644 --- a/app/assets/stylesheets/framework/files.scss +++ b/app/assets/stylesheets/framework/files.scss @@ -12,6 +12,12 @@ &.readme-holder { margin: $gl-padding 0; + + &.limited-width-container .file-content { + max-width: $limited-layout-width-sm; + margin-left: auto; + margin-right: auto; + } } table { @@ -123,7 +129,7 @@ } /** - * Annotate file + * Blame file */ &.blame { table { diff --git a/app/assets/stylesheets/framework/filters.scss b/app/assets/stylesheets/framework/filters.scss index 880ab52fa1b..767cf5ffea5 100644 --- a/app/assets/stylesheets/framework/filters.scss +++ b/app/assets/stylesheets/framework/filters.scss @@ -236,9 +236,6 @@ width: 35px; background-color: $white-light; border: none; - position: static; - right: 0; - height: 100%; outline: none; z-index: 1; diff --git a/app/assets/stylesheets/framework/header.scss b/app/assets/stylesheets/framework/header.scss index d8645afb7da..5bd6c095109 100644 --- a/app/assets/stylesheets/framework/header.scss +++ b/app/assets/stylesheets/framework/header.scss @@ -34,6 +34,8 @@ header { top: 0; left: 0; right: 0; + color: $gl-text-color-secondary; + border-radius: 0; @media (max-width: $screen-xs-min) { padding: 0 16px; @@ -59,7 +61,7 @@ header { padding: 0; .nav > li > a { - color: $gl-text-color-secondary; + color: currentColor; font-size: 18px; padding: 0; margin: (($header-height - 28) / 2) 3px; @@ -84,7 +86,7 @@ header { &:hover, &:focus, &:active { - background-color: $gray-light; + background-color: transparent; color: $gl-text-color; svg { @@ -96,13 +98,19 @@ header { font-size: 14px; } + .fa-chevron-down { + position: relative; + top: -3px; + font-size: 10px; + } + svg { position: relative; top: 2px; height: 17px; // hack to get SVG to line up with FA icons width: 23px; - fill: $gl-text-color-secondary; + fill: currentColor; } } @@ -225,7 +233,7 @@ header { } a { - color: $gl-text-color; + color: currentColor; &:hover { text-decoration: underline; @@ -346,6 +354,8 @@ header { width: auto; min-width: 140px; margin-top: -5px; + color: $gl-text-color; + left: auto; .current-user { padding: 5px 18px; diff --git a/app/assets/stylesheets/framework/layout.scss b/app/assets/stylesheets/framework/layout.scss index 49bff23452d..4a9d41b4fda 100644 --- a/app/assets/stylesheets/framework/layout.scss +++ b/app/assets/stylesheets/framework/layout.scss @@ -53,7 +53,7 @@ body { } &.limit-container-width-sm { - max-width: 790px; + max-width: $limited-layout-width-sm; } } diff --git a/app/assets/stylesheets/framework/nav.scss b/app/assets/stylesheets/framework/nav.scss index 3787ef370b2..28b2a7cfacd 100644 --- a/app/assets/stylesheets/framework/nav.scss +++ b/app/assets/stylesheets/framework/nav.scss @@ -45,8 +45,7 @@ li { display: flex; - a, - .btn-link { + a { padding: $gl-btn-padding; padding-bottom: 11px; font-size: 14px; @@ -68,29 +67,7 @@ } } - .btn-link { - padding-top: 16px; - padding-left: 15px; - padding-right: 15px; - border-left: none; - border-right: none; - border-top: none; - border-radius: 0; - - &:hover, - &:active, - &:focus { - background-color: transparent; - } - - &:active { - outline: 0; - box-shadow: none; - } - } - - &.active a, - &.active .btn-link { + &.active a { border-bottom: 2px solid $link-underline-blue; color: $black; font-weight: 600; diff --git a/app/assets/stylesheets/framework/sidebar.scss b/app/assets/stylesheets/framework/sidebar.scss index d4421e3af74..5cf9330b8f8 100644 --- a/app/assets/stylesheets/framework/sidebar.scss +++ b/app/assets/stylesheets/framework/sidebar.scss @@ -97,17 +97,19 @@ .issues-bulk-update.right-sidebar { @include maintain-sidebar-dimensions; - transition: right $sidebar-transition-duration; - right: -$gutter-width; + width: 0; + padding: 0; + transition: width $sidebar-transition-duration; &.right-sidebar-expanded { @include maintain-sidebar-dimensions; - right: 0; + width: $gutter-width; } &.right-sidebar-collapsed { @include maintain-sidebar-dimensions; - right: -$gutter-width; + width: 0; + padding: 0; .block { padding: 16px 0; @@ -118,5 +120,6 @@ .issuable-sidebar { padding: 0 3px; + width: calc(100% + 35px); } } diff --git a/app/assets/stylesheets/framework/timeline.scss b/app/assets/stylesheets/framework/timeline.scss index 10881987038..3d68a50f91f 100644 --- a/app/assets/stylesheets/framework/timeline.scss +++ b/app/assets/stylesheets/framework/timeline.scss @@ -44,6 +44,10 @@ &:target, &.target { background: $line-target-blue; + + &.system-note .note-body .note-text.system-note-commit-list::after { + background: linear-gradient(rgba($line-target-blue, 0.1) -100px, $line-target-blue 100%); + } } .avatar { diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index 71513199d84..da4d91511e0 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -74,6 +74,12 @@ $red-700: #a62d19; $red-800: #8b2615; $red-900: #711e11; +$purple-600: #6e49cb; +$purple-650: #5c35ae; +$purple-700: #4a2192; +$purple-800: #2c0a5c; +$purple-900: #380d75; + $black: #000; $black-transparent: rgba(0, 0, 0, 0.3); @@ -99,6 +105,7 @@ $well-light-text-color: #5b6169; */ $gl-font-size: 14px; $gl-text-color: rgba(0, 0, 0, .85); +$gl-text-color-light: rgba(0, 0, 0, .7); $gl-text-color-secondary: rgba(0, 0, 0, .55); $gl-text-color-disabled: rgba(0, 0, 0, .35); $gl-text-color-inverted: rgba(255, 255, 255, 1.0); @@ -161,6 +168,7 @@ $progress-color: #c0392b; $header-height: 50px; $fixed-layout-width: 1280px; $limited-layout-width: 990px; +$limited-layout-width-sm: 790px; $gl-avatar-size: 40px; $error-exclamation-point: $red-500; $border-radius-default: 3px; @@ -323,6 +331,7 @@ $note-disabled-comment-color: #b2b2b2; $note-targe3-outside: #fffff0; $note-targe3-inside: #ffffd3; $note-line2-border: #ddd; +$note-icon-gutter-width: 55px; /* diff --git a/app/assets/stylesheets/new_nav.scss b/app/assets/stylesheets/new_nav.scss new file mode 100644 index 00000000000..441bfc479f6 --- /dev/null +++ b/app/assets/stylesheets/new_nav.scss @@ -0,0 +1,267 @@ +@import "framework/variables"; +@import 'framework/tw_bootstrap_variables'; +@import "bootstrap/variables"; + +header.navbar-gitlab-new { + color: $white-light; + background-color: $purple-900; + border-bottom: 0; + + .header-content { + padding-left: 0; + + .title-container { + padding-top: 0; + overflow: visible; + } + + .title { + display: block; + height: 100%; + padding-right: 0; + color: currentColor; + + > a { + display: flex; + align-items: center; + height: 100%; + padding-top: 3px; + padding-right: $gl-padding; + padding-left: $gl-padding; + margin-left: -$gl-padding; + border-bottom: 3px solid transparent; + + @media (min-width: $screen-sm-min) { + padding-right: $gl-padding; + padding-left: $gl-padding; + } + + svg { + margin-top: -3px; + + @media (min-width: $screen-sm-min) { + margin-right: 10px; + } + } + + &:hover, + &:focus { + color: currentColor; + text-decoration: none; + border-bottom-color: $white-light; + } + } + } + + .dropdown.open { + > a { + border-bottom-color: $white-light; + } + } + + .dropdown-menu { + margin-top: 4px; + min-width: 130px; + + @media (max-width: $screen-xs-max) { + left: auto; + right: 0; + } + } + } + + .navbar-collapse { + padding-left: 0; + color: $white-light; + box-shadow: 0; + + @media (max-width: $screen-xs-max) { + margin-left: -$gl-padding; + margin-right: -10px; + } + + .dropdown-bold-header { + color: initial; + } + + .nav { + > li:not(.hidden-xs) a { + @media (max-width: $screen-xs-max) { + margin-left: 0; + min-width: 100%; + } + } + } + } + + .container-fluid { + .navbar-toggle { + min-width: 45px; + padding: 6px $gl-padding; + margin-right: -7px; + font-size: 14px; + text-align: center; + color: currentColor; + border-left: 1px solid lighten($purple-700, 10%); + + &:hover, + &:focus, + &.active { + color: currentColor; + background-color: transparent; + } + } + + .navbar-nav { + @media (max-width: $screen-xs-max) { + display: flex; + padding-right: 10px; + } + + li { + .badge { + box-shadow: none; + } + } + } + + .nav > li { + &.header-user { + @media (max-width: $screen-xs-max) { + padding-left: 10px; + } + } + + > a { + background: none; + opacity: .9; + will-change: opacity; + + &.header-user-dropdown-toggle { + .header-user-avatar { + border-color: $white-light; + } + } + + &:hover, + &:focus { + color: $white-light; + opacity: 1; + + > svg { + fill: $white-light; + } + + &.header-user-dropdown-toggle { + .header-user-avatar { + border-color: $white-light; + } + } + } + } + } + } +} + +.navbar-sub-nav { + display: flex; + margin-bottom: 0; + color: $white-light; + + > li { + &.active > a, + a:hover, + a:focus { + border-bottom-color: $white-light; + text-decoration: none; + outline: 0; + opacity: 1; + } + + > a { + display: block; + padding: 16px 10px 13px; + font-size: 13px; + color: currentColor; + border-bottom: 3px solid transparent; + opacity: .9; + will-change: opacity; + + @media (min-width: $screen-sm-min) { + padding: 15px $gl-padding 12px; + font-size: 14px; + } + } + } + + .dropdown-chevron { + position: relative; + top: -1px; + font-size: 10px; + } +} + +.header-user .dropdown-menu-nav, +.header-new .dropdown-menu-nav { + margin-top: 4px; +} + +.search { + form { + border-color: $purple-800; + + &:hover { + border-color: rgba($white-light, .6); + box-shadow: none; + } + } + + &.search-active form { + border-color: $white-light; + } + + form, + .search-input { + background-color: $purple-700; + } + + .search-input { + color: $white-light; + } + + .search-input::placeholder { + color: rgba($white-light, .6); + } + + .location-badge { + font-size: 12px; + color: rgba($white-light, .6); + background-color: $purple-800; + transition: color 0.15s; + will-change: color; + } + + .search-input-wrap { + .search-icon, + .clear-icon { + color: rgba($white-light, .6); + } + } + + &.search-active { + .location-badge { + color: $white-light; + background-color: $purple-800; + } + + .search-input-wrap { + .search-icon { + color: rgba($white-light, .6); + } + + .clear-icon { + color: $white-light; + } + } + } +} diff --git a/app/assets/stylesheets/new_sidebar.scss b/app/assets/stylesheets/new_sidebar.scss new file mode 100644 index 00000000000..06c6025ed6b --- /dev/null +++ b/app/assets/stylesheets/new_sidebar.scss @@ -0,0 +1,121 @@ +@import "framework/variables"; +@import 'framework/tw_bootstrap_variables'; +@import "bootstrap/variables"; + +$new-sidebar-width: 220px; + +.page-with-new-sidebar { + + @media (min-width: $screen-sm-min) { + padding-left: $new-sidebar-width; + } + + .right-sidebar { + position: fixed; + height: 100%; + } +} + +.nav-sidebar { + position: fixed; + z-index: 400; + width: $new-sidebar-width; + top: 50px; + bottom: 0; + left: 0; + overflow: auto; + background-color: $gray-light; + border-right: 1px solid $border-color; + + ul { + padding: 0; + list-style: none; + } + + li { + a { + display: block; + padding: 12px 14px; + } + } + + a { + color: $gl-text-color; + text-decoration: none; + } +} + +.sidebar-sub-level-items { + display: none; + + > li { + a { + padding: 12px 24px; + color: $gl-text-color-light; + + &:hover { + color: $gl-text-color; + background-color: $border-color; + } + } + + &.active { + > a { + color: $purple-650; + font-weight: 600; + } + } + } +} + +.sidebar-top-level-items { + > li { + .badge { + float: right; + background-color: $border-color; + color: $gl-text-color; + } + + &.active { + > a { + background-color: $purple-600; + color: $white-light; + font-weight: 600; + } + + .badge { + background-color: $purple-700; + color: $white-light; + } + + .sidebar-sub-level-items { + background-color: $gray-normal; + border-left: 6px solid $purple-600; + display: block; + } + } + + &:not(.active) > a:hover { + background-color: $border-color; + + .badge { + transition: background-color 100ms linear; + background-color: $gray-normal; + } + } + } +} + + +// Make issue boards full-height now that sub-nav is gone + +.boards-list { + height: calc(100vh - 50px); + + @media (min-width: $screen-sm-min) { + height: 475px; // Needed for PhantomJS + // scss-lint:disable DuplicateProperty + height: calc(100vh - 120px); + // scss-lint:enable DuplicateProperty + } +} diff --git a/app/assets/stylesheets/pages/cycle_analytics.scss b/app/assets/stylesheets/pages/cycle_analytics.scss index 7bec4bd5f56..3039732ca5b 100644 --- a/app/assets/stylesheets/pages/cycle_analytics.scss +++ b/app/assets/stylesheets/pages/cycle_analytics.scss @@ -4,7 +4,7 @@ position: relative; .landing { - margin-top: 10px; + margin-top: 0; .inner-content { white-space: normal; diff --git a/app/assets/stylesheets/pages/environments.scss b/app/assets/stylesheets/pages/environments.scss index 89bd437b362..1046ebfa2e2 100644 --- a/app/assets/stylesheets/pages/environments.scss +++ b/app/assets/stylesheets/pages/environments.scss @@ -83,6 +83,7 @@ .avatar { float: none; + margin-right: 0; } } diff --git a/app/assets/stylesheets/pages/groups.scss b/app/assets/stylesheets/pages/groups.scss index 72d73b89a2a..6f6c6839975 100644 --- a/app/assets/stylesheets/pages/groups.scss +++ b/app/assets/stylesheets/pages/groups.scss @@ -90,8 +90,6 @@ } .explore-groups.landing { - margin-top: 10px; - .inner-content { padding: 0; diff --git a/app/assets/stylesheets/pages/issuable.scss b/app/assets/stylesheets/pages/issuable.scss index b3f310ff67d..e3ebcc8af6c 100644 --- a/app/assets/stylesheets/pages/issuable.scss +++ b/app/assets/stylesheets/pages/issuable.scss @@ -11,7 +11,9 @@ .commit-box, .info-well, .commit-ci-menu, - .files-changed { + .files-changed, + .limited-header-width, + .limited-width-notes { @extend .fixed-width-container; } @@ -204,7 +206,7 @@ .issuable-sidebar { width: calc(100% + 100px); - height: 100%; + height: calc(100% - #{$header-height}); overflow-y: scroll; overflow-x: hidden; -webkit-overflow-scrolling: touch; @@ -226,6 +228,12 @@ padding-top: 10px; } + &:not(.issue-boards-sidebar):not([data-signed-in]) { + .issuable-sidebar-header { + display: none; + } + } + .assign-yourself .btn-link { padding-left: 0; } @@ -247,6 +255,10 @@ border-left: 1px solid $border-gray-normal; } + .title .gutter-toggle { + margin-top: 0; + } + .assignee .avatar { float: left; margin-right: 10px; @@ -729,33 +741,3 @@ } } } - -.confidential-issue-warning { - background-color: $gl-gray; - border-radius: 3px; - padding: $gl-btn-padding $gl-padding; - margin-top: $gl-padding-top; - font-size: 14px; - color: $white-light; - - .fa { - margin-right: 8px; - } - - a { - color: $white-light; - text-decoration: underline; - } - - &.affix { - position: static; - width: initial; - - @media (min-width: $screen-sm-min) { - position: sticky; - position: -webkit-sticky; - top: 60px; - z-index: 200; - } - } -} diff --git a/app/assets/stylesheets/pages/labels.scss b/app/assets/stylesheets/pages/labels.scss index c10588ac58e..b158416b940 100644 --- a/app/assets/stylesheets/pages/labels.scss +++ b/app/assets/stylesheets/pages/labels.scss @@ -138,6 +138,7 @@ .fa { font-size: 18px; vertical-align: middle; + pointer-events: none; } &:hover { diff --git a/app/assets/stylesheets/pages/members.scss b/app/assets/stylesheets/pages/members.scss index 4be0e133b69..f21005895e4 100644 --- a/app/assets/stylesheets/pages/members.scss +++ b/app/assets/stylesheets/pages/members.scss @@ -136,10 +136,6 @@ width: 250px; } - @media (min-width: $screen-md-min) { - width: 350px; - } - &.input-short { @media (min-width: $screen-md-min) { width: 170px; diff --git a/app/assets/stylesheets/pages/merge_requests.scss b/app/assets/stylesheets/pages/merge_requests.scss index c0bd045f1fc..59e0624d94e 100644 --- a/app/assets/stylesheets/pages/merge_requests.scss +++ b/app/assets/stylesheets/pages/merge_requests.scss @@ -372,10 +372,6 @@ margin-left: 12px; } - &.mr-state-locked + .mr-info-list.mr-links { - margin-top: -16px; - } - &.empty-state { .artwork { margin-bottom: $gl-padding; @@ -423,7 +419,7 @@ .commit { margin: 0; - padding: 10px 0; + padding: 10px; list-style: none; &:hover { diff --git a/app/assets/stylesheets/pages/note_form.scss b/app/assets/stylesheets/pages/note_form.scss index aa307414737..9877ed2cfd6 100644 --- a/app/assets/stylesheets/pages/note_form.scss +++ b/app/assets/stylesheets/pages/note_form.scss @@ -103,6 +103,42 @@ } } +.confidential-issue-warning { + background-color: $gray-normal; + border-radius: 3px; + padding: 3px 12px; + margin: auto; + margin-top: 0; + text-align: center; + font-size: 12px; + align-items: center; + + @media (max-width: $screen-md-max) { + // On smaller devices the warning becomes the fourth item in the list, + // rather than centering, and grows to span the full width of the + // comment area. + order: 4; + margin: 6px auto; + width: 100%; + } + + .fa { + margin-right: 8px; + } +} + +.right-sidebar-expanded { + .confidential-issue-warning { + // When the sidebar is open the warning becomes the fourth item in the list, + // rather than centering, and grows to span the full width of the + // comment area. + order: 4; + margin: 6px auto; + width: 100%; + } +} + + .discussion-form { padding: $gl-padding-top $gl-padding $gl-padding; background-color: $white-light; @@ -112,8 +148,20 @@ padding: 6px 0; } -.notes-form > li { - border: 0; +.notes.notes-form > li.timeline-entry { + @include notes-media('max', $screen-sm-max) { + padding: 0; + } + + .timeline-content { + @include notes-media('max', $screen-sm-max) { + margin: 0; + } + } + + .timeline-entry-inner { + border: 0; + } } .note-edit-form { diff --git a/app/assets/stylesheets/pages/notes.scss b/app/assets/stylesheets/pages/notes.scss index 8b7df4dd72b..53d5cf2f7bc 100644 --- a/app/assets/stylesheets/pages/notes.scss +++ b/app/assets/stylesheets/pages/notes.scss @@ -14,16 +14,6 @@ ul.notes { margin: 0; padding: 0; - .timeline-content { - margin-left: 55px; - - &.timeline-content-form { - @include notes-media('max', $screen-sm-max) { - margin-left: 0; - } - } - } - .note-created-ago, .note-updated-at { white-space: nowrap; @@ -46,17 +36,49 @@ ul.notes { } } - > li { - padding: $gl-padding $gl-btn-padding; + > li { // .timeline-entry + padding: 0; display: block; position: relative; - border-bottom: 1px solid $white-normal; + border-bottom: 0; - &:last-child { - // Override `.timeline > li:last-child { border-bottom: none; }` + @include notes-media('min', $screen-sm-min) { + padding-left: $note-icon-gutter-width; + } + + .timeline-entry-inner { + padding: $gl-padding $gl-btn-padding; border-bottom: 1px solid $white-normal; } + &:target, + &.target { + border-bottom: 1px solid $white-normal; + + &:not(:first-child) { + border-top: 1px solid $white-normal; + margin-top: -1px; + } + + .timeline-entry-inner { + border-bottom: 0; + } + } + + .timeline-icon { + @include notes-media('min', $screen-sm-min) { + margin-left: -$note-icon-gutter-width; + } + } + + .timeline-content { + margin-left: $note-icon-gutter-width; + + @include notes-media('min', $screen-sm-min) { + margin-left: 0; + } + } + &.being-posted { pointer-events: none; opacity: 0.5; @@ -73,7 +95,7 @@ ul.notes { } &.note-discussion { - &.timeline-entry { + .timeline-entry-inner { padding: $gl-padding 10px; } } @@ -152,13 +174,8 @@ ul.notes { .system-note { font-size: 14px; - padding-left: 0; clear: both; - @include notes-media('min', $screen-sm-min) { - margin-left: 65px; - } - .note-header-info { padding-bottom: 0; } @@ -192,13 +209,16 @@ ul.notes { .timeline-icon { float: left; + @include notes-media('min', $screen-sm-min) { + margin-left: 0; + width: auto; + } + svg { width: 16px; height: 16px; fill: $gray-darkest; - position: absolute; - left: 0; - top: 2px; + margin-top: 2px; } } @@ -250,7 +270,7 @@ ul.notes { &::after { content: ''; width: 100%; - height: 67px; + height: 70px; position: absolute; left: 0; bottom: 0; @@ -453,7 +473,7 @@ ul.notes { } .more-actions { - display: inline; + display: inline-block; .tooltip { white-space: nowrap; @@ -639,15 +659,12 @@ ul.notes { .discussion-body, .diff-file { .notes .note { - padding-left: $gl-padding; - padding-right: $gl-padding; - - &.system-note { - padding-left: 0; + border-bottom: 1px solid $white-normal; - @media (min-width: $screen-sm-min) { - margin-left: 70px; - } + .timeline-entry-inner { + padding-left: $gl-padding; + padding-right: $gl-padding; + border-bottom: none; } } } diff --git a/app/assets/stylesheets/pages/pipelines.scss b/app/assets/stylesheets/pages/pipelines.scss index a85ba3a5955..9637d26e56d 100644 --- a/app/assets/stylesheets/pages/pipelines.scss +++ b/app/assets/stylesheets/pages/pipelines.scss @@ -133,7 +133,7 @@ overflow: hidden; display: inline-block; white-space: nowrap; - vertical-align: top; + vertical-align: middle; text-overflow: ellipsis; } diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss index 062665bc634..562ecbc6986 100644 --- a/app/assets/stylesheets/pages/projects.scss +++ b/app/assets/stylesheets/pages/projects.scss @@ -380,7 +380,7 @@ a.deploy-project-label { padding: 0; background: transparent; border: none; - line-height: 36px; + line-height: 34px; margin: 0; > li + li::before { diff --git a/app/assets/stylesheets/pages/settings.scss b/app/assets/stylesheets/pages/settings.scss index 33b3c083fd2..d69a8e0995c 100644 --- a/app/assets/stylesheets/pages/settings.scss +++ b/app/assets/stylesheets/pages/settings.scss @@ -29,6 +29,10 @@ &:first-of-type { margin-top: 10px; } + + &.expanded { + overflow: visible; + } } .settings-header { @@ -122,3 +126,66 @@ margin-left: 5px; } } + +.prometheus-metrics-monitoring { + .panel { + .panel-toggle { + width: 14px; + } + + .badge { + font-size: inherit; + } + + .panel-heading .badge-count { + color: $white-light; + background: $common-gray-dark; + } + + .panel-body { + padding: 0; + } + + .flash-container { + margin-bottom: 0; + cursor: default; + + .flash-notice { + border-radius: 0; + } + } + } + + .loading-metrics, + .empty-metrics { + padding: 30px 10px; + + p, + .btn { + margin-top: 10px; + margin-bottom: 0; + } + } + + .loading-metrics .metrics-load-spinner { + color: $loading-color; + } + + .metrics-list { + margin-bottom: 0; + + li { + padding: $gl-padding; + + .badge { + margin-left: 5px; + background: $badge-bg; + } + } + + /* Ensure we don't add border if there's only single li */ + li + li { + border-top: 1px solid $border-color; + } + } +} diff --git a/app/assets/stylesheets/pages/tree.scss b/app/assets/stylesheets/pages/tree.scss index ab63225147f..ce1a13c6afa 100644 --- a/app/assets/stylesheets/pages/tree.scss +++ b/app/assets/stylesheets/pages/tree.scss @@ -1,6 +1,72 @@ .tree-holder { - > .nav-block { - margin: 11px 0; + .nav-block { + margin: 10px 0; + + @media (min-width: $screen-sm-min) { + display: flex; + + .tree-ref-container { + flex: 1; + } + + .tree-controls { + text-align: right; + + .btn-group { + margin-left: 10px; + } + } + + .tree-ref-holder { + float: left; + margin-right: 15px; + } + + .repo-breadcrumb { + li:last-of-type { + position: relative; + } + } + + .add-to-tree-dropdown { + position: absolute; + left: 18px; + } + } + } + + @media (max-width: $screen-xs-max) { + .repo-breadcrumb { + margin-top: 10px; + position: relative; + + .dropdown-menu { + min-width: 100%; + width: 100%; + left: inherit; + right: 0; + } + } + + .add-to-tree-dropdown { + position: absolute; + left: 0; + right: 0; + } + + .tree-controls { + margin-bottom: 10px; + + .btn, + .dropdown, + .btn-group { + width: 100%; + } + + .btn { + margin: 10px 0 0; + } + } } .file-finder { @@ -131,11 +197,6 @@ } } -.tree-ref-holder { - float: left; - margin-right: 15px; -} - .blob-commit-info { list-style: none; margin: 0; @@ -159,16 +220,6 @@ color: $md-link-color; } -.tree-controls { - float: right; - position: relative; - z-index: 2; - - .project-action-button { - margin-left: $btn-side-margin; - } -} - .repo-charts { .sub-header { margin: 20px 0; diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index b09eef17c23..fa1bc72560e 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -54,7 +54,7 @@ class Admin::UsersController < Admin::ApplicationController end def block - if user.block + if update_user { |user| user.block } redirect_back_or_admin_user(notice: "Successfully blocked") else redirect_back_or_admin_user(alert: "Error occurred. User was not blocked") @@ -64,7 +64,7 @@ class Admin::UsersController < Admin::ApplicationController def unblock if user.ldap_blocked? redirect_back_or_admin_user(alert: "This user cannot be unlocked manually from GitLab") - elsif user.activate + elsif update_user { |user| user.activate } redirect_back_or_admin_user(notice: "Successfully unblocked") else redirect_back_or_admin_user(alert: "Error occurred. User was not unblocked") @@ -72,7 +72,7 @@ class Admin::UsersController < Admin::ApplicationController end def unlock - if user.unlock_access! + if update_user { |user| user.unlock_access! } redirect_back_or_admin_user(alert: "Successfully unlocked") else redirect_back_or_admin_user(alert: "Error occurred. User was not unlocked") @@ -80,7 +80,7 @@ class Admin::UsersController < Admin::ApplicationController end def confirm - if user.confirm + if update_user { |user| user.confirm } redirect_back_or_admin_user(notice: "Successfully confirmed") else redirect_back_or_admin_user(alert: "Error occurred. User was not confirmed") @@ -88,7 +88,8 @@ class Admin::UsersController < Admin::ApplicationController end def disable_two_factor - user.disable_two_factor! + update_user { |user| user.disable_two_factor! } + redirect_to admin_user_path(user), notice: 'Two-factor Authentication has been disabled for this user' end @@ -124,15 +125,18 @@ class Admin::UsersController < Admin::ApplicationController end respond_to do |format| - user.skip_reconfirmation! - if user.update_attributes(user_params_with_pass) + result = Users::UpdateService.new(user, user_params_with_pass).execute do |user| + user.skip_reconfirmation! + end + + if result[:status] == :success format.html { redirect_to [:admin, user], notice: 'User was successfully updated.' } format.json { head :ok } else # restore username to keep form action url. user.username = params[:id] format.html { render "edit" } - format.json { render json: user.errors, status: :unprocessable_entity } + format.json { render json: [result[:message]], status: result[:status] } end end end @@ -148,13 +152,16 @@ class Admin::UsersController < Admin::ApplicationController def remove_email email = user.emails.find(params[:email_id]) - email.destroy - - user.update_secondary_emails! + success = Emails::DestroyService.new(user, email: email.email).execute respond_to do |format| - format.html { redirect_back_or_admin_user(notice: "Successfully removed email.") } - format.js { head :ok } + if success + format.html { redirect_back_or_admin_user(notice: 'Successfully removed email.') } + format.json { head :ok } + else + format.html { redirect_back_or_admin_user(alert: 'There was an error removing the e-mail.') } + format.json { render json: 'There was an error removing the e-mail.', status: 400 } + end end end @@ -202,4 +209,10 @@ class Admin::UsersController < Admin::ApplicationController :website_url ] end + + def update_user(&block) + result = Users::UpdateService.new(user).execute(&block) + + result[:status] == :success + end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 91694ebcd1d..824ce845706 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -40,6 +40,10 @@ class ApplicationController < ActionController::Base render_404 end + rescue_from(ActionController::UnknownFormat) do + render_404 + end + rescue_from Gitlab::Access::AccessDeniedError do |exception| render_403 end diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb index 36ad307a93b..1a9904bbe57 100644 --- a/app/controllers/concerns/creates_commit.rb +++ b/app/controllers/concerns/creates_commit.rb @@ -97,8 +97,8 @@ module CreatesCommit def merge_request_exists? return @merge_request if defined?(@merge_request) - @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened. - find_by(source_project_id: @project_to_commit_into, source_branch: @branch_name, target_branch: @start_branch) + @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened + .find_by(source_project_id: @project_to_commit_into, source_branch: @branch_name, target_branch: @start_branch) end def different_project? diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb index 8d07780f6c2..47d9ae350ae 100644 --- a/app/controllers/concerns/membership_actions.rb +++ b/app/controllers/concerns/membership_actions.rb @@ -15,8 +15,8 @@ module MembershipActions end def destroy - Members::DestroyService.new(membershipable, current_user, params). - execute(:all) + Members::DestroyService.new(membershipable, current_user, params) + .execute(:all) respond_to do |format| format.html do @@ -42,8 +42,8 @@ module MembershipActions end def leave - member = Members::DestroyService.new(membershipable, current_user, user_id: current_user.id). - execute(:all) + member = Members::DestroyService.new(membershipable, current_user, user_id: current_user.id) + .execute(:all) notice = if member.request? diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb index 641c502dbe4..91c1e4dff79 100644 --- a/app/controllers/dashboard/projects_controller.rb +++ b/app/controllers/dashboard/projects_controller.rb @@ -22,8 +22,8 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController end def starred - @projects = load_projects(params.merge(starred: true)). - includes(:forked_from_project, :tags).page(params[:page]) + @projects = load_projects(params.merge(starred: true)) + .includes(:forked_from_project, :tags).page(params[:page]) @groups = [] @@ -45,8 +45,8 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController end def load_projects(finder_params) - ProjectsFinder.new(params: finder_params, current_user: current_user). - execute.includes(:route, namespace: :route) + ProjectsFinder.new(params: finder_params, current_user: current_user) + .execute.includes(:route, namespace: :route) end def load_events diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb index 8f1870759e4..741879dee35 100644 --- a/app/controllers/explore/projects_controller.rb +++ b/app/controllers/explore/projects_controller.rb @@ -49,7 +49,7 @@ class Explore::ProjectsController < Explore::ApplicationController private def load_projects - ProjectsFinder.new(current_user: current_user, params: params). - execute.includes(:route, namespace: :route) + ProjectsFinder.new(current_user: current_user, params: params) + .execute.includes(:route, namespace: :route) end end diff --git a/app/controllers/jwt_controller.rb b/app/controllers/jwt_controller.rb index 11db164b3fa..4bceb1d67a3 100644 --- a/app/controllers/jwt_controller.rb +++ b/app/controllers/jwt_controller.rb @@ -11,8 +11,8 @@ class JwtController < ApplicationController service = SERVICES[params[:service]] return head :not_found unless service - result = service.new(@authentication_result.project, @authentication_result.actor, auth_params). - execute(authentication_abilities: @authentication_result.authentication_abilities) + result = service.new(@authentication_result.project, @authentication_result.actor, auth_params) + .execute(authentication_abilities: @authentication_result.authentication_abilities) render json: result, status: result[:http_status] end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 2a8c8ca4bad..b82681b197e 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -144,7 +144,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end def log_audit_event(user, options = {}) - AuditEventService.new(user, user, options). - for_authentication.security_event + AuditEventService.new(user, user, options) + .for_authentication.security_event end end diff --git a/app/controllers/profiles/avatars_controller.rb b/app/controllers/profiles/avatars_controller.rb index 933e0f3bceb..408650aac54 100644 --- a/app/controllers/profiles/avatars_controller.rb +++ b/app/controllers/profiles/avatars_controller.rb @@ -1,9 +1,8 @@ class Profiles::AvatarsController < Profiles::ApplicationController def destroy @user = current_user - @user.remove_avatar! - @user.save + Users::UpdateService.new(@user).execute { |user| user.remove_avatar! } redirect_to profile_path, status: 302 end diff --git a/app/controllers/profiles/emails_controller.rb b/app/controllers/profiles/emails_controller.rb index 5655fb2ba0e..17b66df43e7 100644 --- a/app/controllers/profiles/emails_controller.rb +++ b/app/controllers/profiles/emails_controller.rb @@ -5,9 +5,9 @@ class Profiles::EmailsController < Profiles::ApplicationController end def create - @email = current_user.emails.new(email_params) + @email = Emails::CreateService.new(current_user, email_params).execute - if @email.save + if @email.errors.blank? NotificationService.new.new_email(@email) else flash[:alert] = @email.errors.full_messages.first @@ -18,9 +18,8 @@ class Profiles::EmailsController < Profiles::ApplicationController def destroy @email = current_user.emails.find(params[:id]) - @email.destroy - current_user.update_secondary_emails! + Emails::DestroyService.new(current_user, email: @email.email).execute respond_to do |format| format.html { redirect_to profile_emails_url, status: 302 } diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb index a271e2dfc4b..960b7512602 100644 --- a/app/controllers/profiles/notifications_controller.rb +++ b/app/controllers/profiles/notifications_controller.rb @@ -7,7 +7,9 @@ class Profiles::NotificationsController < Profiles::ApplicationController end def update - if current_user.update_attributes(user_params) + result = Users::UpdateService.new(current_user, user_params).execute + + if result[:status] == :success flash[:notice] = "Notification settings saved" else flash[:alert] = "Failed to save new settings" diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb index 6217ec5ecef..10145bae0d3 100644 --- a/app/controllers/profiles/passwords_controller.rb +++ b/app/controllers/profiles/passwords_controller.rb @@ -15,17 +15,17 @@ class Profiles::PasswordsController < Profiles::ApplicationController return end - new_password = user_params[:password] - new_password_confirmation = user_params[:password_confirmation] - - result = @user.update_attributes( - password: new_password, - password_confirmation: new_password_confirmation, + password_attributes = { + password: user_params[:password], + password_confirmation: user_params[:password_confirmation], password_automatically_set: false - ) + } + + result = Users::UpdateService.new(@user, password_attributes).execute + + if result[:status] == :success + Users::UpdateService.new(@user, password_expires_at: nil).execute - if result - @user.update_attributes(password_expires_at: nil) redirect_to root_path, notice: 'Password successfully changed' else render :new @@ -46,7 +46,9 @@ class Profiles::PasswordsController < Profiles::ApplicationController return end - if @user.update_attributes(password_attributes) + result = Users::UpdateService.new(@user, password_attributes).execute + + if result[:status] == :success flash[:notice] = "Password was successfully updated. Please login with it" redirect_to new_user_session_path else diff --git a/app/controllers/profiles/preferences_controller.rb b/app/controllers/profiles/preferences_controller.rb index 5414142e2df..1e557c47638 100644 --- a/app/controllers/profiles/preferences_controller.rb +++ b/app/controllers/profiles/preferences_controller.rb @@ -6,7 +6,9 @@ class Profiles::PreferencesController < Profiles::ApplicationController def update begin - if @user.update_attributes(preferences_params) + result = Users::UpdateService.new(user, preferences_params).execute + + if result[:status] == :success flash[:notice] = 'Preferences saved.' else flash[:alert] = 'Failed to save preferences.' diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb index 313cdcd1c15..1a4f77639e7 100644 --- a/app/controllers/profiles/two_factor_auths_controller.rb +++ b/app/controllers/profiles/two_factor_auths_controller.rb @@ -10,7 +10,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController current_user.otp_grace_period_started_at = Time.current end - current_user.save! if current_user.changed? + Users::UpdateService.new(current_user).execute! if two_factor_authentication_required? && !current_user.two_factor_enabled? two_factor_authentication_reason( @@ -41,9 +41,9 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController def create if current_user.validate_and_consume_otp!(params[:pin_code]) - current_user.otp_required_for_login = true - @codes = current_user.generate_otp_backup_codes! - current_user.save! + Users::UpdateService.new(current_user, otp_required_for_login: true).execute! do |user| + @codes = user.generate_otp_backup_codes! + end render 'create' else @@ -70,8 +70,9 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController end def codes - @codes = current_user.generate_otp_backup_codes! - current_user.save! + Users::UpdateService.new(current_user).execute! do |user| + @codes = user.generate_otp_backup_codes! + end end def destroy diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 72f34930ca8..076076fd1b3 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -12,55 +12,64 @@ class ProfilesController < Profiles::ApplicationController user_params.except!(:email) if @user.external_email? respond_to do |format| - if @user.update_attributes(user_params) + result = Users::UpdateService.new(@user, user_params).execute + + if result[:status] == :success message = "Profile was successfully updated" + format.html { redirect_back_or_default(default: { action: 'show' }, options: { notice: message }) } format.json { render json: { message: message } } else - message = @user.errors.full_messages.uniq.join('. ') - format.html { redirect_back_or_default(default: { action: 'show' }, options: { alert: "Failed to update profile. #{message}" }) } - format.json { render json: { message: message }, status: :unprocessable_entity } + format.html { redirect_back_or_default(default: { action: 'show' }, options: { alert: result[:message] }) } + format.json { render json: result } end end end def reset_private_token - if current_user.reset_authentication_token! - flash[:notice] = "Private token was successfully reset" + Users::UpdateService.new(@user).execute! do |user| + user.reset_authentication_token! end + flash[:notice] = "Private token was successfully reset" + redirect_to profile_account_path end def reset_incoming_email_token - if current_user.reset_incoming_email_token! - flash[:notice] = "Incoming email token was successfully reset" + Users::UpdateService.new(@user).execute! do |user| + user.reset_incoming_email_token! end + flash[:notice] = "Incoming email token was successfully reset" + redirect_to profile_account_path end def reset_rss_token - if current_user.reset_rss_token! - flash[:notice] = "RSS token was successfully reset" + Users::UpdateService.new(@user).execute! do |user| + user.reset_rss_token! end + flash[:notice] = "RSS token was successfully reset" + redirect_to profile_account_path end def audit_log - @events = AuditEvent.where(entity_type: "User", entity_id: current_user.id). - order("created_at DESC"). - page(params[:page]) + @events = AuditEvent.where(entity_type: "User", entity_id: current_user.id) + .order("created_at DESC") + .page(params[:page]) end def update_username - if @user.update_attributes(username: user_params[:username]) - options = { notice: "Username successfully changed" } - else - message = @user.errors.full_messages.uniq.join('. ') - options = { alert: "Username change failed - #{message}" } - end + result = Users::UpdateService.new(@user, username: user_params[:username]).execute + + options = if result[:status] == :success + { notice: "Username successfully changed" } + else + { alert: "Username change failed - #{result[:message]}" } + end redirect_back_or_default(default: { action: 'show' }, options: options) end diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 603a51266da..3d7ce4f0222 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -53,9 +53,21 @@ class Projects::ApplicationController < ApplicationController end end + def check_project_feature_available!(feature) + render_404 unless project.feature_available?(feature, current_user) + end + + def check_issuables_available! + render_404 unless project.feature_available?(:issues, current_user) || + project.feature_available?(:merge_requests, current_user) + end + def method_missing(method_sym, *arguments, &block) - if method_sym.to_s =~ /\Aauthorize_(.*)!\z/ + case method_sym.to_s + when /\Aauthorize_(.*)!\z/ authorize_action!($1.to_sym) + when /\Acheck_(.*)_available!\z/ + check_project_feature_available!($1.to_sym) else super end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 66e6a9a451c..a82d6fd5a4a 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -187,7 +187,7 @@ class Projects::BlobController < Projects::ApplicationController end def set_last_commit_sha - @last_commit_sha = Gitlab::Git::Commit. - last_for_path(@repository, @ref, @path).sha + @last_commit_sha = Gitlab::Git::Commit + .last_for_path(@repository, @ref, @path).sha end end diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 70b06cfd9b4..94a752c21eb 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -37,8 +37,8 @@ class Projects::BranchesController < Projects::ApplicationController redirect_to_autodeploy = project.empty_repo? && project.deployment_services.present? - result = CreateBranchService.new(project, current_user). - execute(branch_name, ref) + result = CreateBranchService.new(project, current_user) + .execute(branch_name, ref) if params[:issue_iid] issue = IssuesFinder.new(current_user, project_id: @project.id).find_by(iid: params[:issue_iid]) diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index f33797ca310..37b5a6e9d48 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -18,11 +18,11 @@ class Projects::CommitsController < Projects::ApplicationController @repository.commits(@ref, path: @path, limit: @limit, offset: @offset) end - @note_counts = project.notes.where(commit_id: @commits.map(&:id)). - group(:commit_id).count + @note_counts = project.notes.where(commit_id: @commits.map(&:id)) + .group(:commit_id).count - @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened. - find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref) + @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened + .find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref) respond_to do |format| format.html diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 88dd600e5fe..ef400c4d745 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -61,7 +61,7 @@ class Projects::CompareController < Projects::ApplicationController end def merge_request - @merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened. - find_by(source_project: @project, source_branch: @head_ref, target_branch: @start_ref) + @merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened + .find_by(source_project: @project, source_branch: @head_ref, target_branch: @start_ref) end end diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb index 7f1469e107d..c2e621fa190 100644 --- a/app/controllers/projects/deploy_keys_controller.rb +++ b/app/controllers/projects/deploy_keys_controller.rb @@ -6,7 +6,7 @@ class Projects::DeployKeysController < Projects::ApplicationController before_action :authorize_admin_project! before_action :authorize_update_deploy_key!, only: [:edit, :update] - layout "project_settings" + layout 'project_settings' def index respond_to do |format| @@ -66,7 +66,7 @@ class Projects::DeployKeysController < Projects::ApplicationController protected def deploy_key - @deploy_key ||= @project.deploy_keys.find(params[:id]) + @deploy_key ||= DeployKey.find(params[:id]) end def create_params diff --git a/app/controllers/projects/deployments_controller.rb b/app/controllers/projects/deployments_controller.rb index 6644deb49c9..47c312ffddf 100644 --- a/app/controllers/projects/deployments_controller.rb +++ b/app/controllers/projects/deployments_controller.rb @@ -22,6 +22,22 @@ class Projects::DeploymentsController < Projects::ApplicationController render_404 end + def additional_metrics + return render_404 unless deployment.has_additional_metrics? + + respond_to do |format| + format.json do + metrics = deployment.additional_metrics + + if metrics.any? + render json: metrics + else + head :no_content + end + end + end + end + private def deployment diff --git a/app/controllers/projects/discussions_controller.rb b/app/controllers/projects/discussions_controller.rb index f4a18a5e8f7..2e6ab7903b8 100644 --- a/app/controllers/projects/discussions_controller.rb +++ b/app/controllers/projects/discussions_controller.rb @@ -1,5 +1,5 @@ class Projects::DiscussionsController < Projects::ApplicationController - before_action :module_enabled + before_action :check_merge_requests_available! before_action :merge_request before_action :discussion before_action :authorize_resolve_discussion! @@ -34,8 +34,4 @@ class Projects::DiscussionsController < Projects::ApplicationController def authorize_resolve_discussion! access_denied! unless discussion.can_resolve?(current_user) end - - def module_enabled - render_404 unless @project.feature_available?(:merge_requests, current_user) - end end diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 4630f451445..f88a1ffd1e9 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -15,8 +15,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController respond_to do |format| format.html format.json do - Gitlab::PollingInterval.set_header(response, interval: 3_000) - render json: { environments: EnvironmentSerializer .new(project: @project, current_user: @current_user) @@ -131,6 +129,16 @@ class Projects::EnvironmentsController < Projects::ApplicationController end end + def additional_metrics + respond_to do |format| + format.json do + additional_metrics = environment.additional_metrics || {} + + render json: additional_metrics, status: additional_metrics.any? ? :ok : :no_content + end + end + end + private def verify_api_request! diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 56f76e752d0..dfc6baa34a4 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -9,7 +9,7 @@ class Projects::IssuesController < Projects::ApplicationController prepend_before_action :authenticate_user!, only: [:new] before_action :redirect_to_external_issue_tracker, only: [:index, :new] - before_action :module_enabled + before_action :check_issues_available! before_action :issue, except: [:index, :new, :create, :bulk_update] # Allow write(create) issue @@ -250,7 +250,7 @@ class Projects::IssuesController < Projects::ApplicationController return render_404 unless can?(current_user, :push_code, @project) && @issue.can_be_worked_on?(current_user) end - def module_enabled + def check_issues_available! return render_404 unless @project.feature_available?(:issues, current_user) && @project.default_issues_tracker? end diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 1beac202efe..daa973c9281 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -1,7 +1,7 @@ class Projects::LabelsController < Projects::ApplicationController include ToggleSubscriptionAction - before_action :module_enabled + before_action :check_issuables_available! before_action :label, only: [:edit, :update, :destroy, :promote] before_action :find_labels, only: [:index, :set_priorities, :remove_priority, :toggle_subscription] before_action :authorize_read_label! @@ -135,12 +135,6 @@ class Projects::LabelsController < Projects::ApplicationController protected - def module_enabled - unless @project.feature_available?(:issues, current_user) || @project.feature_available?(:merge_requests, current_user) - return render_404 - end - end - def label_params params.require(:label).permit(:title, :description, :color) end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 314906b5f09..879ff6d393e 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -7,7 +7,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController include ToggleAwardEmoji include IssuableCollections - before_action :module_enabled + before_action :check_merge_requests_available! before_action :merge_request, only: [ :edit, :update, :show, :diffs, :commits, :conflicts, :conflict_for_path, :pipelines, :merge, :pipeline_status, :ci_environments_status, :toggle_subscription, :cancel_merge_when_pipeline_succeeds, :remove_wip, :resolve_conflicts, :assign_related_issues, :commit_change_content @@ -143,8 +143,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController # Get commits from repository # or from cache if already merged @commits = @merge_request.commits - @note_counts = Note.where(commit_id: @commits.map(&:id)). - group(:commit_id).count + @note_counts = Note.where(commit_id: @commits.map(&:id)) + .group(:commit_id).count render json: { html: view_to_html_string('projects/merge_requests/show/_commits') } end @@ -192,9 +192,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController end begin - MergeRequests::Conflicts::ResolveService. - new(merge_request). - execute(current_user, params) + MergeRequests::Conflicts::ResolveService + .new(merge_request) + .execute(current_user, params) flash[:notice] = 'All merge conflicts were resolved. The merge request can now be merged.' @@ -461,10 +461,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController return render_404 unless @conflicts_list.can_be_resolved_by?(current_user) end - def module_enabled - return render_404 unless @project.feature_available?(:merge_requests, current_user) - end - def validates_merge_request # Show git not found page # if there is no saved commits between source & target branch @@ -562,8 +558,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController @commits = @merge_request.compare_commits.reverse @commit = @merge_request.diff_head_commit - @note_counts = Note.where(commit_id: @commits.map(&:id)). - group(:commit_id).count + @note_counts = Note.where(commit_id: @commits.map(&:id)) + .group(:commit_id).count @labels = LabelsFinder.new(current_user, project_id: @project.id).execute @@ -579,10 +575,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController def merge_request_params params.require(:merge_request) - .permit(merge_request_params_ce) + .permit(merge_request_params_attributes) end - def merge_request_params_ce + def merge_request_params_attributes [ :assignee_id, :description, @@ -602,7 +598,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController end def merge_params - params.permit(:should_remove_source_branch, :commit_message) + params.permit(merge_params_attributes) + end + + def merge_params_attributes + [:should_remove_source_branch, :commit_message] end # Make sure merge requests created before 8.0 diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index 62410d7f57f..953b1e83e49 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -1,7 +1,7 @@ class Projects::MilestonesController < Projects::ApplicationController include MilestoneActions - before_action :module_enabled + before_action :check_issuables_available! before_action :milestone, only: [:edit, :update, :destroy, :show, :merge_requests, :participants, :labels] # Allow read any milestone @@ -95,12 +95,6 @@ class Projects::MilestonesController < Projects::ApplicationController return render_404 unless can?(current_user, :admin_milestone, @project) end - def module_enabled - unless @project.feature_available?(:issues, current_user) || @project.feature_available?(:merge_requests, current_user) - return render_404 - end - end - def milestone_params params.require(:milestone).permit(:title, :description, :start_date, :due_date, :state_event) end diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 8effb792689..303e91a8dc0 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -135,7 +135,12 @@ class Projects::PipelinesController < Projects::ApplicationController @charts[:week] = Ci::Charts::WeekChart.new(project) @charts[:month] = Ci::Charts::MonthChart.new(project) @charts[:year] = Ci::Charts::YearChart.new(project) - @charts[:build_times] = Ci::Charts::BuildTime.new(project) + @charts[:pipeline_times] = Ci::Charts::PipelineTime.new(project) + + @counts = {} + @counts[:total] = @project.pipelines.count(:all) + @counts[:success] = @project.pipelines.success.count(:all) + @counts[:failed] = @project.pipelines.failed.count(:all) end private diff --git a/app/controllers/projects/prometheus_controller.rb b/app/controllers/projects/prometheus_controller.rb new file mode 100644 index 00000000000..507468d7102 --- /dev/null +++ b/app/controllers/projects/prometheus_controller.rb @@ -0,0 +1,24 @@ +class Projects::PrometheusController < Projects::ApplicationController + before_action :authorize_read_project! + before_action :require_prometheus_metrics! + + def active_metrics + respond_to do |format| + format.json do + matched_metrics = project.prometheus_service.matched_metrics || {} + + if matched_metrics.any? + render json: matched_metrics + else + head :no_content + end + end + end + end + + private + + def require_prometheus_metrics! + render_404 unless project.prometheus_service.present? + end +end diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 6f009d61950..24fe78bc1bd 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -14,8 +14,8 @@ module Projects def define_runners_variables @project_runners = @project.runners.ordered - @assignable_runners = current_user.ci_authorized_runners. - assignable_for(project).ordered.page(params[:page]).per(20) + @assignable_runners = current_user.ci_authorized_runners + .assignable_for(project).ordered.page(params[:page]).per(20) @shared_runners = Ci::Runner.shared.active @shared_runners_count = @shared_runners.count(:all) end diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index 8a8f8d6a27d..98dd307bd9d 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -5,7 +5,7 @@ class Projects::SnippetsController < Projects::ApplicationController include SnippetsActions include RendersBlob - before_action :module_enabled + before_action :check_snippets_available! before_action :snippet, only: [:show, :edit, :destroy, :update, :raw, :toggle_award_emoji, :mark_as_spam] # Allow read any snippet @@ -102,10 +102,6 @@ class Projects::SnippetsController < Projects::ApplicationController return render_404 unless can?(current_user, :admin_project_snippet, @snippet) end - def module_enabled - return render_404 unless @project.feature_available?(:snippets, current_user) - end - def snippet_params params.require(:project_snippet).permit(:title, :content, :file_name, :private, :visibility_level, :description) end diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index afbea3e2b40..ebc9f4edab4 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -29,8 +29,8 @@ class Projects::TagsController < Projects::ApplicationController end def create - result = Tags::CreateService.new(@project, current_user). - execute(params[:tag_name], params[:ref], params[:message], params[:release_description]) + result = Tags::CreateService.new(@project, current_user) + .execute(params[:tag_name], params[:ref], params[:message], params[:release_description]) if result[:status] == :success @tag = result[:tag] diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index d7c702b94f8..f39441a281e 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -60,10 +60,11 @@ class SessionsController < Devise::SessionsController return unless user && user.require_password? - token = user.generate_reset_token - user.save + Users::UpdateService.new(user).execute do |user| + @token = user.generate_reset_token + end - redirect_to edit_user_password_path(reset_password_token: token), + redirect_to edit_user_password_path(reset_password_token: @token), notice: "Please create a password for your new account." end @@ -128,8 +129,8 @@ class SessionsController < Devise::SessionsController end def log_audit_event(user, options = {}) - AuditEventService.new(user, user, options). - for_authentication.security_event + AuditEventService.new(user, user, options) + .for_authentication.security_event end def log_user_activity(user) diff --git a/app/controllers/sherlock/application_controller.rb b/app/controllers/sherlock/application_controller.rb index 682ca5e3821..6bdd3568a78 100644 --- a/app/controllers/sherlock/application_controller.rb +++ b/app/controllers/sherlock/application_controller.rb @@ -4,8 +4,8 @@ module Sherlock def find_transaction if params[:transaction_id] - @transaction = Gitlab::Sherlock.collection. - find_transaction(params[:transaction_id]) + @transaction = Gitlab::Sherlock.collection + .find_transaction(params[:transaction_id]) end end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c211106fbaa..8131eba6a2f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -106,11 +106,11 @@ class UsersController < ApplicationController def load_events # Get user activity feed for projects common for both users - @events = user.recent_events. - merge(projects_for_current_user). - references(:project). - with_associations. - limit_recent(20, params[:offset]) + @events = user.recent_events + .merge(projects_for_current_user) + .references(:project) + .with_associations + .limit_recent(20, params[:offset]) end def load_projects diff --git a/app/finders/events_finder.rb b/app/finders/events_finder.rb index b0450ddc1fd..46ecbaba73a 100644 --- a/app/finders/events_finder.rb +++ b/app/finders/events_finder.rb @@ -33,7 +33,8 @@ class EventsFinder private def by_current_user_access(events) - events.merge(ProjectsFinder.new(current_user: current_user).execute).references(:project) + events.merge(ProjectsFinder.new(current_user: current_user).execute) + .joins(:project) end def by_action(events) diff --git a/app/finders/group_members_finder.rb b/app/finders/group_members_finder.rb index fce3775f40e..067aff408df 100644 --- a/app/finders/group_members_finder.rb +++ b/app/finders/group_members_finder.rb @@ -8,9 +8,9 @@ class GroupMembersFinder return group_members unless @group.parent - parents_members = GroupMember.non_request. - where(source_id: @group.ancestors.select(:id)). - where.not(user_id: @group.users.select(:id)) + parents_members = GroupMember.non_request + .where(source_id: @group.ancestors.select(:id)) + .where.not(user_id: @group.users.select(:id)) wheres = ["members.id IN (#{group_members.select(:id).to_sql})"] wheres << "members.id IN (#{parents_members.select(:id).to_sql})" diff --git a/app/finders/group_projects_finder.rb b/app/finders/group_projects_finder.rb index f043c38c6f9..f2d3b90b8e2 100644 --- a/app/finders/group_projects_finder.rb +++ b/app/finders/group_projects_finder.rb @@ -29,35 +29,69 @@ class GroupProjectsFinder < ProjectsFinder private def init_collection - only_owned = options.fetch(:only_owned, false) - only_shared = options.fetch(:only_shared, false) + projects = if current_user + collection_with_user + else + collection_without_user + end - projects = [] + union(projects) + end - if current_user - if group.users.include?(current_user) - projects << group.projects unless only_shared - projects << group.shared_projects unless only_owned + def collection_with_user + if group.users.include?(current_user) + if only_shared? + [shared_projects] + elsif only_owned? + [owned_projects] else - unless only_shared - projects << group.projects.visible_to_user(current_user) - projects << group.projects.public_to_user(current_user) - end - - unless only_owned - projects << group.shared_projects.visible_to_user(current_user) - projects << group.shared_projects.public_to_user(current_user) - end + [shared_projects, owned_projects] end else - projects << group.projects.public_only unless only_shared - projects << group.shared_projects.public_only unless only_owned + if only_shared? + [shared_projects.public_or_visible_to_user(current_user)] + elsif only_owned? + [owned_projects.public_or_visible_to_user(current_user)] + else + [ + owned_projects.public_or_visible_to_user(current_user), + shared_projects.public_or_visible_to_user(current_user) + ] + end end + end - projects + def collection_without_user + if only_shared? + [shared_projects.public_only] + elsif only_owned? + [owned_projects.public_only] + else + [shared_projects.public_only, owned_projects.public_only] + end end def union(items) - find_union(items, Project) + if items.one? + items.first + else + find_union(items, Project) + end + end + + def only_owned? + options.fetch(:only_owned, false) + end + + def only_shared? + options.fetch(:only_shared, false) + end + + def owned_projects + group.projects + end + + def shared_projects + group.shared_projects end end diff --git a/app/finders/issues_finder.rb b/app/finders/issues_finder.rb index b4c074bc69c..3da5508aefd 100644 --- a/app/finders/issues_finder.rb +++ b/app/finders/issues_finder.rb @@ -41,7 +41,7 @@ class IssuesFinder < IssuableFinder def self.not_restricted_by_confidentiality(user) return Issue.where('issues.confidential IS NOT TRUE') if user.blank? - return Issue.all if user.admin? + return Issue.all if user.full_private_access? Issue.where(' issues.confidential IS NOT TRUE diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb index 5bf722d1ec6..8bfbe37c543 100644 --- a/app/finders/projects_finder.rb +++ b/app/finders/projects_finder.rb @@ -28,34 +28,56 @@ class ProjectsFinder < UnionFinder end def execute - items = init_collection - items = items.map do |item| - item = by_ids(item) - item = by_personal(item) - item = by_starred(item) - item = by_trending(item) - item = by_visibilty_level(item) - item = by_tags(item) - item = by_search(item) - by_archived(item) - end - items = union(items) - sort(items) + collection = init_collection + collection = by_ids(collection) + collection = by_personal(collection) + collection = by_starred(collection) + collection = by_trending(collection) + collection = by_visibilty_level(collection) + collection = by_tags(collection) + collection = by_search(collection) + collection = by_archived(collection) + + sort(collection) end private def init_collection - projects = [] + if current_user + collection_with_user + else + collection_without_user + end + end - if params[:owned].present? - projects << current_user.owned_projects if current_user + def collection_with_user + if owned_projects? + current_user.owned_projects else - projects << current_user.authorized_projects if current_user - projects << Project.unscoped.public_to_user(current_user) unless params[:non_public].present? + if private_only? + current_user.authorized_projects + else + Project.public_or_visible_to_user(current_user) + end end + end + + # Builds a collection for an anonymous user. + def collection_without_user + if private_only? || owned_projects? + Project.none + else + Project.public_to_user + end + end + + def owned_projects? + params[:owned].present? + end - projects + def private_only? + params[:non_public].present? end def by_ids(items) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 06bbed777d5..dc7ff78f3df 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -68,7 +68,7 @@ module ApplicationHelper end end - def avatar_icon(user_or_email = nil, size = nil, scale = 2) + def avatar_icon(user_or_email = nil, size = nil, scale = 2, only_path: true) user = if user_or_email.is_a?(User) user_or_email @@ -77,7 +77,7 @@ module ApplicationHelper end if user - user.avatar_url(size: size) || default_avatar + user.avatar_url(size: size, only_path: only_path) || default_avatar else gravatar_icon(user_or_email, size, scale) end @@ -300,4 +300,12 @@ module ApplicationHelper "https://www.twitter.com/#{name}" end end + + def can_toggle_new_nav? + Rails.env.development? + end + + def show_new_nav? + cookies["new_nav"] == "true" + end end diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb index 00464810054..ba84dbe4a7a 100644 --- a/app/helpers/button_helper.rb +++ b/app/helpers/button_helper.rb @@ -50,10 +50,17 @@ module ButtonHelper def http_clone_button(project, placement = 'right', append_link: true) klass = 'http-selector' - klass << ' has-tooltip' if current_user.try(:require_password?) + klass << ' has-tooltip' if current_user.try(:require_password?) || current_user.try(:require_personal_access_token?) protocol = gitlab_config.protocol.upcase + tooltip_title = + if current_user.try(:require_password?) + _("Set a password on your account to pull or push via %{protocol}.") % { protocol: protocol } + else + _("Create a personal access token on your account to pull or push via %{protocol}.") % { protocol: protocol } + end + content_tag (append_link ? :a : :span), protocol, class: klass, href: (project.http_url_to_repo if append_link), @@ -61,7 +68,7 @@ module ButtonHelper html: true, placement: placement, container: 'body', - title: _("Set a password on your account to pull or push via %{protocol}") % { protocol: protocol } + title: tooltip_title } end diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 5b5cdebe919..0accd1f8d77 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -85,20 +85,20 @@ module CommitsHelper if @path.blank? return link_to( - "Browse Files", + _("Browse Files"), namespace_project_tree_path(project.namespace, project, commit), class: "btn btn-default" ) elsif @repo.blob_at(commit.id, @path) return link_to( - "Browse File", + _("Browse File"), namespace_project_blob_path(project.namespace, project, tree_join(commit.id, @path)), class: "btn btn-default" ) elsif @path.present? return link_to( - "Browse Directory", + _("Browse Directory"), namespace_project_tree_path(project.namespace, project, tree_join(commit.id, @path)), class: "btn btn-default" diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 014fc46b130..8ceb5c36bda 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -8,10 +8,10 @@ module FormHelper content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do content_tag(:h4, headline) << content_tag(:ul) do - model.errors.full_messages. - map { |msg| content_tag(:li, msg) }. - join. - html_safe + model.errors.full_messages + .map { |msg| content_tag(:li, msg) } + .join + .html_safe end end end diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb index c2ab80f2e0d..2e9b72e9613 100644 --- a/app/helpers/graph_helper.rb +++ b/app/helpers/graph_helper.rb @@ -17,13 +17,10 @@ module GraphHelper ids.zip(parent_spaces) end - def success_ratio(success_builds, failed_builds) - failed_builds = failed_builds.count(:all) - success_builds = success_builds.count(:all) + def success_ratio(counts) + return 100 if counts[:failed].zero? - return 100 if failed_builds.zero? - - ratio = (success_builds.to_f / (success_builds + failed_builds)) * 100 + ratio = (counts[:success].to_f / (counts[:success] + counts[:failed])) * 100 ratio.to_i end end diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index c003b01e226..eb45241615f 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -15,7 +15,7 @@ module GroupsHelper @has_group_title = true full_title = '' - group.ancestors.each do |parent| + group.ancestors.reverse.each do |parent| full_title += link_to(simple_sanitize(parent.name), group_path(parent), class: 'group-path hidable') full_title += '<span class="hidable"> / </span>'.html_safe end diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 5e8f0849969..3259a9c1933 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -138,8 +138,8 @@ module IssuablesHelper end output << " ".html_safe - output << content_tag(:span, issuable.task_status, id: "task_status", class: "hidden-xs hidden-sm") - output << content_tag(:span, issuable.task_status_short, id: "task_status_short", class: "hidden-md hidden-lg") + output << content_tag(:span, (issuable.task_status if issuable.tasks?), id: "task_status", class: "hidden-xs hidden-sm") + output << content_tag(:span, (issuable.task_status_short if issuable.tasks?), id: "task_status_short", class: "hidden-md hidden-lg") output end @@ -216,7 +216,8 @@ module IssuablesHelper initialTitleHtml: markdown_field(issuable, :title), initialTitleText: issuable.title, initialDescriptionHtml: markdown_field(issuable, :description), - initialDescriptionText: issuable.description + initialDescriptionText: issuable.description, + initialTaskStatus: issuable.task_status } data.merge!(updated_at_by(issuable)) diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 4e6e6805920..6baf6f31d8f 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -133,21 +133,28 @@ module LabelsHelper end end + def can_subscribe_to_label_in_different_levels?(label) + defined?(@project) && label.is_a?(GroupLabel) + end + def label_subscription_status(label, project) - return 'project-level' if label.subscribed?(current_user, project) return 'group-level' if label.subscribed?(current_user) + return 'project-level' if label.subscribed?(current_user, project) 'unsubscribed' end - def group_label_unsubscribe_path(label, project) + def toggle_subscription_label_path(label, project) + return toggle_subscription_group_label_path(label.group, label) unless project + case label_subscription_status(label, project) - when 'project-level' then toggle_subscription_namespace_project_label_path(@project.namespace, @project, label) when 'group-level' then toggle_subscription_group_label_path(label.group, label) + when 'project-level' then toggle_subscription_namespace_project_label_path(project.namespace, project, label) + when 'unsubscribed' then toggle_subscription_namespace_project_label_path(project.namespace, project, label) end end - def label_subscription_toggle_button_text(label, project) + def label_subscription_toggle_button_text(label, project = nil) label.subscribed?(current_user, project) ? 'Unsubscribe' : 'Subscribe' end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 0d0459f5a70..c04b1419a19 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -194,8 +194,25 @@ module ProjectsHelper end def load_pipeline_status(projects) - Gitlab::Cache::Ci::ProjectPipelineStatus. - load_in_batch_for_projects(projects) + Gitlab::Cache::Ci::ProjectPipelineStatus + .load_in_batch_for_projects(projects) + end + + def show_no_ssh_key_message? + cookies[:hide_no_ssh_message].blank? && !current_user.hide_no_ssh_key && current_user.require_ssh_key? + end + + def show_no_password_message? + cookies[:hide_no_password_message].blank? && !current_user.hide_no_password && + ( current_user.require_password? || current_user.require_personal_access_token? ) + end + + def link_to_set_password + if current_user.require_password? + link_to s_('SetPasswordToCloneLink|set a password'), edit_profile_password_path + else + link_to s_('CreateTokenToCloneLink|create a personal access token'), profile_personal_access_tokens_path + end end private diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 9c46035057f..8f15904f068 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -97,8 +97,8 @@ module SearchHelper # Autocomplete results for the current user's projects def projects_autocomplete(term, limit = 5) - current_user.authorized_projects.search_by_title(term). - sorted_by_stars.non_archived.limit(limit).map do |p| + current_user.authorized_projects.search_by_title(term) + .sorted_by_stars.non_archived.limit(limit).map do |p| { category: "Projects", id: p.id, diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 9c623c9ba7c..b5f54d3e154 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -4,4 +4,14 @@ module UsersHelper title: user.email, class: 'has-tooltip commit-committer-link') end + + def user_email_help_text(user) + return 'We also use email for avatar detection if no avatar is uploaded.' unless user.unconfirmed_email.present? + + confirmation_link = link_to 'Resend confirmation e-mail', user_confirmation_path(user: { email: @user.unconfirmed_email }), method: :post + + h('Please click the link in the confirmation email before continuing. It was sent to ') + + content_tag(:strong) { user.unconfirmed_email } + h('.') + + content_tag(:p) { confirmation_link } + end end diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb index 3e3f6246fc5..99212a3438f 100644 --- a/app/helpers/wiki_helper.rb +++ b/app/helpers/wiki_helper.rb @@ -6,8 +6,8 @@ module WikiHelper # Returns a String composed of the capitalized name of each directory and the # capitalized name of the page itself. def breadcrumb(page_slug) - page_slug.split('/'). - map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize }. - join(' / ') + page_slug.split('/') + .map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize } + .join(' / ') end end diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb index ebe60441603..91b62dabbcd 100644 --- a/app/models/award_emoji.rb +++ b/app/models/award_emoji.rb @@ -19,9 +19,9 @@ class AwardEmoji < ActiveRecord::Base class << self def votes_for_collection(ids, type) - select('name', 'awardable_id', 'COUNT(*) as count'). - where('name IN (?) AND awardable_type = ? AND awardable_id IN (?)', [DOWNVOTE_NAME, UPVOTE_NAME], type, ids). - group('name', 'awardable_id') + select('name', 'awardable_id', 'COUNT(*) as count') + .where('name IN (?) AND awardable_type = ? AND awardable_id IN (?)', [DOWNVOTE_NAME, UPVOTE_NAME], type, ids) + .group('name', 'awardable_id') end end diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 58758f7ca8a..a300536532b 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -138,17 +138,6 @@ module Ci ExpandVariables.expand(environment, simple_variables) if environment end - def environment_url - return @environment_url if defined?(@environment_url) - - @environment_url = - if unexpanded_url = options&.dig(:environment, :url) - ExpandVariables.expand(unexpanded_url, simple_variables) - else - persisted_environment&.external_url - end - end - def has_environment? environment.present? end @@ -192,7 +181,7 @@ module Ci slugified.gsub(/[^a-z0-9]/, '-')[0..62] end - # Variables whose value does not depend on other variables + # Variables whose value does not depend on environment def simple_variables variables = predefined_variables variables += project.predefined_variables @@ -207,7 +196,8 @@ module Ci variables end - # All variables, including those dependent on other variables + # All variables, including those dependent on environment, which could + # contain unexpanded variables. def variables simple_variables.concat(persisted_environment_variables) end @@ -481,9 +471,10 @@ module Ci variables = persisted_environment.predefined_variables - if url = environment_url - variables << { key: 'CI_ENVIRONMENT_URL', value: url, public: true } - end + # Here we're passing unexpanded environment_url for runner to expand, + # and we need to make sure that CI_ENVIRONMENT_NAME and + # CI_ENVIRONMENT_SLUG so on are available for the URL be expanded. + variables << { key: 'CI_ENVIRONMENT_URL', value: environment_url, public: true } if environment_url variables end @@ -506,6 +497,10 @@ module Ci variables end + def environment_url + options&.dig(:environment, :url) || persisted_environment&.external_url + end + def build_attributes_from_config return {} unless pipeline.config_processor diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 9ddecba5183..1b3e5a25ac2 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -168,8 +168,8 @@ module Ci end def stages_names - statuses.order(:stage_idx).distinct. - pluck(:stage, :stage_idx).map(&:first) + statuses.order(:stage_idx).distinct + .pluck(:stage, :stage_idx).map(&:first) end def legacy_stage(name) diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 487ba61bc9c..d12f96f3d0b 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -30,8 +30,8 @@ module Ci scope :assignable_for, ->(project) do # FIXME: That `to_sql` is needed to workaround a weird Rails bug. # Without that, placeholders would miss one and couldn't match. - where(locked: false). - where.not("id IN (#{project.runners.select(:id).to_sql})").specific + where(locked: false) + .where.not("id IN (#{project.runners.select(:id).to_sql})").specific end validate :tag_constraints diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 3c9c6584e02..32af5566135 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -11,18 +11,21 @@ module HasStatus class_methods do def status_sql - scope = respond_to?(:exclude_ignored) ? exclude_ignored : all - - builds = scope.select('count(*)').to_sql - created = scope.created.select('count(*)').to_sql - success = scope.success.select('count(*)').to_sql - manual = scope.manual.select('count(*)').to_sql - pending = scope.pending.select('count(*)').to_sql - running = scope.running.select('count(*)').to_sql - skipped = scope.skipped.select('count(*)').to_sql - canceled = scope.canceled.select('count(*)').to_sql + scope_relevant = respond_to?(:exclude_ignored) ? exclude_ignored : all + scope_warnings = respond_to?(:failed_but_allowed) ? failed_but_allowed : none + + builds = scope_relevant.select('count(*)').to_sql + created = scope_relevant.created.select('count(*)').to_sql + success = scope_relevant.success.select('count(*)').to_sql + manual = scope_relevant.manual.select('count(*)').to_sql + pending = scope_relevant.pending.select('count(*)').to_sql + running = scope_relevant.running.select('count(*)').to_sql + skipped = scope_relevant.skipped.select('count(*)').to_sql + canceled = scope_relevant.canceled.select('count(*)').to_sql + warnings = scope_warnings.select('count(*) > 0').to_sql.presence || 'false' "(CASE + WHEN (#{builds})=(#{skipped}) AND (#{warnings}) THEN 'success' WHEN (#{builds})=(#{skipped}) THEN 'skipped' WHEN (#{builds})=(#{success}) THEN 'success' WHEN (#{builds})=(#{created}) THEN 'created' diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 8e367576c9d..d178ee4422b 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -161,9 +161,9 @@ module Issuable # milestones_due_date = 'MIN(milestones.due_date)' - order_milestone_due_asc. - order_labels_priority(excluded_labels: excluded_labels, extra_select_columns: [milestones_due_date]). - reorder(Gitlab::Database.nulls_last_order(milestones_due_date, 'ASC'), + order_milestone_due_asc + .order_labels_priority(excluded_labels: excluded_labels, extra_select_columns: [milestones_due_date]) + .reorder(Gitlab::Database.nulls_last_order(milestones_due_date, 'ASC'), Gitlab::Database.nulls_last_order('highest_priority', 'ASC')) end @@ -182,9 +182,9 @@ module Issuable "(#{highest_priority}) AS highest_priority" ] + extra_select_columns - select(select_columns.join(', ')). - group(arel_table[:id]). - reorder(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')) + select(select_columns.join(', ')) + .group(arel_table[:id]) + .reorder(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')) end def with_label(title, sort = nil) diff --git a/app/models/concerns/relative_positioning.rb b/app/models/concerns/relative_positioning.rb index f1d8532a6d6..7cb9a28a284 100644 --- a/app/models/concerns/relative_positioning.rb +++ b/app/models/concerns/relative_positioning.rb @@ -18,10 +18,10 @@ module RelativePositioning prev_pos = nil if self.relative_position - prev_pos = self.class. - in_projects(project.id). - where('relative_position < ?', self.relative_position). - maximum(:relative_position) + prev_pos = self.class + .in_projects(project.id) + .where('relative_position < ?', self.relative_position) + .maximum(:relative_position) end prev_pos @@ -31,10 +31,10 @@ module RelativePositioning next_pos = nil if self.relative_position - next_pos = self.class. - in_projects(project.id). - where('relative_position > ?', self.relative_position). - minimum(:relative_position) + next_pos = self.class + .in_projects(project.id) + .where('relative_position > ?', self.relative_position) + .minimum(:relative_position) end next_pos diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb index 63d02b76f6b..ec7796a9dbb 100644 --- a/app/models/concerns/routable.rb +++ b/app/models/concerns/routable.rb @@ -107,6 +107,14 @@ module Routable RequestStore[key] ||= uncached_full_path end + def build_full_path + if parent && path + parent.full_path + '/' + path + else + path + end + end + private def uncached_full_path @@ -135,14 +143,6 @@ module Routable end end - def build_full_path - if parent && path - parent.full_path + '/' + path - else - path - end - end - def update_route prepare_route route.save diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb index b9a2d812edd..a155a064032 100644 --- a/app/models/concerns/sortable.rb +++ b/app/models/concerns/sortable.rb @@ -39,12 +39,12 @@ module Sortable private def highest_label_priority(target_type_column: nil, target_type: nil, target_column:, project_column:, excluded_labels: []) - query = Label.select(LabelPriority.arel_table[:priority].minimum). - left_join_priorities. - joins(:label_links). - where("label_priorities.project_id = #{project_column}"). - where("label_links.target_id = #{target_column}"). - reorder(nil) + query = Label.select(LabelPriority.arel_table[:priority].minimum) + .left_join_priorities + .joins(:label_links) + .where("label_priorities.project_id = #{project_column}") + .where("label_links.target_id = #{target_column}") + .reorder(nil) query = if target_type_column diff --git a/app/models/concerns/subscribable.rb b/app/models/concerns/subscribable.rb index 83daa9b1a64..f60a0f8f438 100644 --- a/app/models/concerns/subscribable.rb +++ b/app/models/concerns/subscribable.rb @@ -27,16 +27,16 @@ module Subscribable end def subscribers(project) - subscriptions_available(project). - where(subscribed: true). - map(&:user) + subscriptions_available(project) + .where(subscribed: true) + .map(&:user) end def toggle_subscription(user, project = nil) unsubscribe_from_other_levels(user, project) - find_or_initialize_subscription(user, project). - update(subscribed: !subscribed?(user, project)) + find_or_initialize_subscription(user, project) + .update(subscribed: !subscribed?(user, project)) end def subscribe(user, project = nil) @@ -69,14 +69,14 @@ module Subscribable end def find_or_initialize_subscription(user, project) - subscriptions. - find_or_initialize_by(user_id: user.id, project_id: project.try(:id)) + subscriptions + .find_or_initialize_by(user_id: user.id, project_id: project.try(:id)) end def subscriptions_available(project) t = Subscription.arel_table - subscriptions. - where(t[:project_id].eq(nil).or(t[:project_id].eq(project.try(:id)))) + subscriptions + .where(t[:project_id].eq(nil).or(t[:project_id].eq(project.try(:id)))) end end diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 85e7901dfee..056c49e7162 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -58,10 +58,10 @@ class Deployment < ActiveRecord::Base def update_merge_request_metrics! return unless environment.update_merge_request_metrics? - merge_requests = project.merge_requests. - joins(:metrics). - where(target_branch: self.ref, merge_request_metrics: { first_deployed_to_production_at: nil }). - where("merge_request_metrics.merged_at <= ?", self.created_at) + merge_requests = project.merge_requests + .joins(:metrics) + .where(target_branch: self.ref, merge_request_metrics: { first_deployed_to_production_at: nil }) + .where("merge_request_metrics.merged_at <= ?", self.created_at) if previous_deployment merge_requests = merge_requests.where("merge_request_metrics.merged_at >= ?", previous_deployment.created_at) @@ -76,17 +76,17 @@ class Deployment < ActiveRecord::Base merge_requests.map(&:id) end - MergeRequest::Metrics. - where(merge_request_id: merge_request_ids, first_deployed_to_production_at: nil). - update_all(first_deployed_to_production_at: self.created_at) + MergeRequest::Metrics + .where(merge_request_id: merge_request_ids, first_deployed_to_production_at: nil) + .update_all(first_deployed_to_production_at: self.created_at) end def previous_deployment @previous_deployment ||= - project.deployments.joins(:environment). - where(environments: { name: self.environment.name }, ref: self.ref). - where.not(id: self.id). - take + project.deployments.joins(:environment) + .where(environments: { name: self.environment.name }, ref: self.ref) + .where.not(id: self.id) + .take end def stop_action @@ -114,6 +114,17 @@ class Deployment < ActiveRecord::Base project.monitoring_service.deployment_metrics(self) end + def has_additional_metrics? + project.prometheus_service.present? + end + + def additional_metrics + return {} unless project.prometheus_service.present? + + metrics = project.prometheus_service.additional_deployment_metrics(self) + metrics&.merge(deployment_time: created_at.to_i) || {} + end + private def ref_path diff --git a/app/models/environment.rb b/app/models/environment.rb index d5b974b2d31..66c96d0f586 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -40,11 +40,12 @@ class Environment < ActiveRecord::Base scope :stopped, -> { with_state(:stopped) } scope :order_by_last_deployed_at, -> do max_deployment_id_sql = - Deployment.select(Deployment.arel_table[:id].maximum). - where(Deployment.arel_table[:environment_id].eq(arel_table[:id])). - to_sql + Deployment.select(Deployment.arel_table[:id].maximum) + .where(Deployment.arel_table[:environment_id].eq(arel_table[:id])) + .to_sql order(Gitlab::Database.nulls_first_order("(#{max_deployment_id_sql})", 'ASC')) end + scope :in_review_folder, -> { where(environment_type: "review") } state_machine :state, initial: :available do event :start do @@ -157,6 +158,16 @@ class Environment < ActiveRecord::Base project.monitoring_service.environment_metrics(self) if has_metrics? end + def has_additional_metrics? + project.prometheus_service.present? && available? && last_deployment.present? + end + + def additional_metrics + if has_additional_metrics? + project.prometheus_service.additional_environment_metrics(self) + end + end + # An environment name is not necessarily suitable for use in URLs, DNS # or other third-party contexts, so provide a slugified version. A slug has # the following properties: diff --git a/app/models/event.rb b/app/models/event.rb index fad6ff03927..29bc141c5cd 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -376,9 +376,9 @@ class Event < ActiveRecord::Base # At this point it's possible for multiple threads/processes to try to # update the project. Only one query should actually perform the update, # hence we add the extra WHERE clause for last_activity_at. - Project.unscoped.where(id: project_id). - where('last_activity_at <= ?', RESET_PROJECT_ACTIVITY_INTERVAL.ago). - update_all(last_activity_at: created_at) + Project.unscoped.where(id: project_id) + .where('last_activity_at <= ?', RESET_PROJECT_ACTIVITY_INTERVAL.ago) + .update_all(last_activity_at: created_at) end def authored_by?(user) @@ -392,7 +392,7 @@ class Event < ActiveRecord::Base end def set_last_repository_updated_at - Project.unscoped.where(id: project_id). - update_all(last_repository_updated_at: created_at) + Project.unscoped.where(id: project_id) + .update_all(last_repository_updated_at: created_at) end end diff --git a/app/models/group.rb b/app/models/group.rb index 5bb2cdc5eff..0b93460d473 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -206,8 +206,8 @@ class Group < Namespace end def refresh_members_authorized_projects - UserProjectAccessChangedService.new(user_ids_for_project_authorizations). - execute + UserProjectAccessChangedService.new(user_ids_for_project_authorizations) + .execute end def user_ids_for_project_authorizations @@ -225,10 +225,10 @@ class Group < Namespace def max_member_access_for_user(user) return GroupMember::OWNER if user.admin? - members_with_parents. - where(user_id: user). - reorder(access_level: :desc). - first&. + members_with_parents + .where(user_id: user) + .reorder(access_level: :desc) + .first&. access_level || GroupMember::NO_ACCESS end diff --git a/app/models/issue.rb b/app/models/issue.rb index f0f525aea21..3a9a6dba601 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -124,8 +124,8 @@ class Issue < ActiveRecord::Base end def self.order_by_position_and_priority - order_labels_priority. - reorder(Gitlab::Database.nulls_last_order('relative_position', 'ASC'), + order_labels_priority + .reorder(Gitlab::Database.nulls_last_order('relative_position', 'ASC'), Gitlab::Database.nulls_last_order('highest_priority', 'ASC'), "id DESC") end diff --git a/app/models/issue_collection.rb b/app/models/issue_collection.rb index f0b7d9914c8..49f011c113f 100644 --- a/app/models/issue_collection.rb +++ b/app/models/issue_collection.rb @@ -17,9 +17,9 @@ class IssueCollection # Given all the issue projects we get a list of projects that the current # user has at least reporter access to. - projects_with_reporter_access = user. - projects_with_reporter_access_limited_to(project_ids). - pluck(:id) + projects_with_reporter_access = user + .projects_with_reporter_access_limited_to(project_ids) + .pluck(:id) collection.select do |issue| if projects_with_reporter_access.include?(issue.project_id) diff --git a/app/models/label.rb b/app/models/label.rb index 955d6b4079b..ed6a8411da9 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -46,9 +46,9 @@ class Label < ActiveRecord::Base labels = Label.arel_table priorities = LabelPriority.arel_table - label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin). - on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id))). - join_sources + label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin) + .on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id))) + .join_sources joins(label_priorities).where(priorities[:priority].eq(nil)) end @@ -57,9 +57,9 @@ class Label < ActiveRecord::Base labels = Label.arel_table priorities = LabelPriority.arel_table - label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin). - on(labels[:id].eq(priorities[:label_id])). - join_sources + label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin) + .on(labels[:id].eq(priorities[:label_id])) + .join_sources joins(label_priorities) end diff --git a/app/models/member.rb b/app/models/member.rb index 788a32dd8e3..dc9247bc9a0 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -99,9 +99,9 @@ class Member < ActiveRecord::Base users = User.arel_table members = Member.arel_table - member_users = members.join(users, Arel::Nodes::OuterJoin). - on(members[:user_id].eq(users[:id])). - join_sources + member_users = members.join(users, Arel::Nodes::OuterJoin) + .on(members[:user_id].eq(users[:id])) + .join_sources joins(member_users) end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index ea22ab53587..c099d731082 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -577,8 +577,8 @@ class MergeRequest < ActiveRecord::Base messages = [title, description] messages.concat(commits.map(&:safe_message)) if merge_request_diff - Gitlab::ClosingIssueExtractor.new(project, current_user). - closed_by_message(messages.join("\n")) + Gitlab::ClosingIssueExtractor.new(project, current_user) + .closed_by_message(messages.join("\n")) else [] end @@ -771,6 +771,7 @@ class MergeRequest < ActiveRecord::Base "refs/heads/#{source_branch}", ref_path ) + update_column(:ref_fetched, true) end def ref_path @@ -778,7 +779,13 @@ class MergeRequest < ActiveRecord::Base end def ref_fetched? - project.repository.ref_exists?(ref_path) + super || + begin + computed_value = project.repository.ref_exists?(ref_path) + update_column(:ref_fetched, true) if computed_value + + computed_value + end end def ensure_ref_fetched diff --git a/app/models/merge_requests_closing_issues.rb b/app/models/merge_requests_closing_issues.rb index daafb137be4..7f7c114803d 100644 --- a/app/models/merge_requests_closing_issues.rb +++ b/app/models/merge_requests_closing_issues.rb @@ -7,9 +7,9 @@ class MergeRequestsClosingIssues < ActiveRecord::Base class << self def count_for_collection(ids) - group(:issue_id). - where(issue_id: ids). - pluck('issue_id', 'COUNT(*) as count') + group(:issue_id) + .where(issue_id: ids) + .pluck('issue_id', 'COUNT(*) as count') end end end diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 0a6fc064aec..d2e2749f70d 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -98,11 +98,11 @@ class Milestone < ActiveRecord::Base if Gitlab::Database.postgresql? rel.order(:project_id, :due_date).select('DISTINCT ON (project_id) id') else - rel. - group(:project_id). - having('due_date = MIN(due_date)'). - pluck(:id, :project_id, :due_date). - map(&:first) + rel + .group(:project_id) + .having('due_date = MIN(due_date)') + .pluck(:id, :project_id, :due_date) + .map(&:first) end end diff --git a/app/models/namespace.rb b/app/models/namespace.rb index b48d73dcae7..583d4fb5244 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -181,16 +181,16 @@ class Namespace < ActiveRecord::Base def ancestors return self.class.none unless parent_id - Gitlab::GroupHierarchy. - new(self.class.where(id: parent_id)). - base_and_ancestors + Gitlab::GroupHierarchy + .new(self.class.where(id: parent_id)) + .base_and_ancestors end # Returns all the descendants of the current namespace. def descendants - Gitlab::GroupHierarchy. - new(self.class.where(parent_id: id)). - base_and_descendants + Gitlab::GroupHierarchy + .new(self.class.where(parent_id: id)) + .base_and_descendants end def user_ids_for_project_authorizations @@ -253,10 +253,10 @@ class Namespace < ActiveRecord::Base end def refresh_access_of_projects_invited_groups - Group. - joins(project_group_links: :project). - where(projects: { namespace_id: id }). - find_each(&:refresh_members_authorized_projects) + Group + .joins(project_group_links: :project) + .where(projects: { namespace_id: id }) + .find_each(&:refresh_members_authorized_projects) end def remove_exports! diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb index 59737bb6085..2bc00a082df 100644 --- a/app/models/network/graph.rb +++ b/app/models/network/graph.rb @@ -113,7 +113,7 @@ module Network opts[:ref] = @commit.id if @filter_ref - @repo.find_commits(opts) + Gitlab::Git::Commit.find_all(@repo.raw_repository, opts) end def commits_sort_by_ref diff --git a/app/models/note.rb b/app/models/note.rb index 3221e653e30..ca6999427c0 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -137,9 +137,9 @@ class Note < ActiveRecord::Base end def count_for_collection(ids, type) - user.select('noteable_id', 'COUNT(*) as count'). - group(:noteable_id). - where(noteable_type: type, noteable_id: ids) + user.select('noteable_id', 'COUNT(*) as count') + .group(:noteable_id) + .where(noteable_type: type, noteable_id: ids) end end diff --git a/app/models/project.rb b/app/models/project.rb index 4c394646787..1176bec8873 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -244,8 +244,8 @@ class Project < ActiveRecord::Base scope :inside_path, ->(path) do # We need routes alias rs for JOIN so it does not conflict with # includes(:route) which we use in ProjectsFinder. - joins("INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'"). - where('rs.path LIKE ?', "#{sanitize_sql_like(path)}/%") + joins("INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'") + .where('rs.path LIKE ?', "#{sanitize_sql_like(path)}/%") end # "enabled" here means "not disabled". It includes private features! @@ -266,20 +266,49 @@ class Project < ActiveRecord::Base enum auto_cancel_pending_pipelines: { disabled: 0, enabled: 1 } + # Returns a collection of projects that is either public or visible to the + # logged in user. + def self.public_or_visible_to_user(user = nil) + if user + authorized = user + .project_authorizations + .select(1) + .where('project_authorizations.project_id = projects.id') + + levels = Gitlab::VisibilityLevel.levels_for_user(user) + + where('EXISTS (?) OR projects.visibility_level IN (?)', authorized, levels) + else + public_to_user + end + end + # project features may be "disabled", "internal" or "enabled". If "internal", # they are only available to team members. This scope returns projects where # the feature is either enabled, or internal with permission for the user. + # + # This method uses an optimised version of `with_feature_access_level` for + # logged in users to more efficiently get private projects with the given + # feature. def self.with_feature_available_for_user(feature, user) - return with_feature_enabled(feature) if user.try(:admin?) + visible = [nil, ProjectFeature::ENABLED] - unconditional = with_feature_access_level(feature, [nil, ProjectFeature::ENABLED]) - return unconditional if user.nil? + if user&.admin? + with_feature_enabled(feature) + elsif user + column = ProjectFeature.quoted_access_level_column(feature) - conditional = with_feature_access_level(feature, ProjectFeature::PRIVATE) - authorized = user.authorized_projects.merge(conditional.reorder(nil)) + authorized = user.project_authorizations.select(1) + .where('project_authorizations.project_id = projects.id') - union = Gitlab::SQL::Union.new([unconditional.select(:id), authorized.select(:id)]) - where(arel_table[:id].in(Arel::Nodes::SqlLiteral.new(union.to_sql))) + with_project_feature + .where("#{column} IN (?) OR (#{column} = ? AND EXISTS (?))", + visible, + ProjectFeature::PRIVATE, + authorized) + else + with_feature_access_level(feature, visible) + end end scope :active, -> { joins(:issues, :notes, :merge_requests).order('issues.created_at, notes.created_at, merge_requests.created_at DESC') } @@ -321,7 +350,10 @@ class Project < ActiveRecord::Base project.run_after_commit { add_import_job } end - after_transition started: :finished, do: :reset_cache_and_import_attrs + after_transition started: :finished do |project, _| + project.reset_cache_and_import_attrs + project.perform_housekeeping + end end class << self @@ -340,14 +372,14 @@ class Project < ActiveRecord::Base # unscoping unnecessary conditions that'll be applied # when executing `where("projects.id IN (#{union.to_sql})")` projects = unscoped.select(:id).where( - ptable[:path].matches(pattern). - or(ptable[:name].matches(pattern)). - or(ptable[:description].matches(pattern)) + ptable[:path].matches(pattern) + .or(ptable[:name].matches(pattern)) + .or(ptable[:description].matches(pattern)) ) - namespaces = unscoped.select(:id). - joins(:namespace). - where(ntable[:name].matches(pattern)) + namespaces = unscoped.select(:id) + .joins(:namespace) + .where(ntable[:name].matches(pattern)) union = Gitlab::SQL::Union.new([projects, namespaces]) @@ -388,8 +420,8 @@ class Project < ActiveRecord::Base end def trending - joins('INNER JOIN trending_projects ON projects.id = trending_projects.project_id'). - reorder('trending_projects.id ASC') + joins('INNER JOIN trending_projects ON projects.id = trending_projects.project_id') + .reorder('trending_projects.id ASC') end def cached_count @@ -481,6 +513,18 @@ class Project < ActiveRecord::Base remove_import_data end + def perform_housekeeping + return unless repo_exists? + + run_after_commit do + begin + Projects::HousekeepingService.new(self).execute + rescue Projects::HousekeepingService::LeaseTaken => e + Rails.logger.info("Could not perform housekeeping for project #{self.path_with_namespace} (#{self.id}): #{e}") + end + end + end + def remove_import_data import_data&.destroy end @@ -660,7 +704,7 @@ class Project < ActiveRecord::Base end def last_activity_date - last_activity_at || updated_at + last_repository_updated_at || last_activity_at || updated_at end def project_id diff --git a/app/models/project_authorization.rb b/app/models/project_authorization.rb index def09675253..73302207e6b 100644 --- a/app/models/project_authorization.rb +++ b/app/models/project_authorization.rb @@ -7,9 +7,9 @@ class ProjectAuthorization < ActiveRecord::Base validates :user, uniqueness: { scope: [:project, :access_level] }, presence: true def self.select_from_union(union) - select(['project_id', 'MAX(access_level) AS access_level']). - from("(#{union.to_sql}) #{ProjectAuthorization.table_name}"). - group(:project_id) + select(['project_id', 'MAX(access_level) AS access_level']) + .from("(#{union.to_sql}) #{ProjectAuthorization.table_name}") + .group(:project_id) end def self.insert_authorizations(rows, per_batch = 1000) diff --git a/app/models/project_feature.rb b/app/models/project_feature.rb index e3ef4919b28..48edd0738ee 100644 --- a/app/models/project_feature.rb +++ b/app/models/project_feature.rb @@ -27,6 +27,13 @@ class ProjectFeature < ActiveRecord::Base "#{feature}_access_level".to_sym end + + def quoted_access_level_column(feature) + attribute = connection.quote_column_name(access_level_attribute(feature)) + table = connection.quote_table_name(table_name) + + "#{table}.#{attribute}" + end end # Default scopes force us to unscope here since a service may need to check @@ -83,7 +90,7 @@ class ProjectFeature < ActiveRecord::Base when DISABLED false when PRIVATE - user && (project.team.member?(user) || user.admin?) + user && (project.team.member?(user) || user.full_private_access?) when ENABLED true else diff --git a/app/models/project_services/chat_message/pipeline_message.rb b/app/models/project_services/chat_message/pipeline_message.rb index 3edc395033c..d63d4ec2b12 100644 --- a/app/models/project_services/chat_message/pipeline_message.rb +++ b/app/models/project_services/chat_message/pipeline_message.rb @@ -70,7 +70,7 @@ module ChatMessage end def branch_link - "`[#{ref}](#{branch_url})`" + "[#{ref}](#{branch_url})" end def project_link diff --git a/app/models/project_services/chat_message/push_message.rb b/app/models/project_services/chat_message/push_message.rb index 04a59d559ca..c52dd6ef8ef 100644 --- a/app/models/project_services/chat_message/push_message.rb +++ b/app/models/project_services/chat_message/push_message.rb @@ -61,7 +61,7 @@ module ChatMessage end def removed_branch_message - "#{user_name} removed #{ref_type} `#{ref}` from #{project_link}" + "#{user_name} removed #{ref_type} #{ref} from #{project_link}" end def push_message @@ -102,7 +102,7 @@ module ChatMessage end def branch_link - "`[#{ref}](#{branch_url})`" + "[#{ref}](#{branch_url})" end def project_link diff --git a/app/models/project_services/mattermost_slash_commands_service.rb b/app/models/project_services/mattermost_slash_commands_service.rb index c2f887e24a0..4d2037286a2 100644 --- a/app/models/project_services/mattermost_slash_commands_service.rb +++ b/app/models/project_services/mattermost_slash_commands_service.rb @@ -20,8 +20,8 @@ class MattermostSlashCommandsService < SlashCommandsService end def configure(user, params) - token = Mattermost::Command.new(user). - create(command(params)) + token = Mattermost::Command.new(user) + .create(command(params)) update(active: true, token: token) if token rescue Mattermost::Error => e diff --git a/app/models/project_services/prometheus_service.rb b/app/models/project_services/prometheus_service.rb index 110b8bc209b..217f753f05f 100644 --- a/app/models/project_services/prometheus_service.rb +++ b/app/models/project_services/prometheus_service.rb @@ -28,17 +28,6 @@ class PrometheusService < MonitoringService 'Prometheus monitoring' end - def help - <<-MD.strip_heredoc - Retrieves the Kubernetes node metrics `container_cpu_usage_seconds_total` - and `container_memory_usage_bytes` from the configured Prometheus server. - - If you are not using [Auto-Deploy](https://docs.gitlab.com/ee/ci/autodeploy/index.html) - or have set up your own Prometheus server, an `environment` label is required on each metric to - [identify the Environment](https://docs.gitlab.com/ce/user/project/integrations/prometheus.html#metrics-and-labels). - MD - end - def self.to_param 'prometheus' end @@ -50,6 +39,7 @@ class PrometheusService < MonitoringService name: 'api_url', title: 'API URL', placeholder: 'Prometheus API Base URL, like http://prometheus.example.com/', + help: 'By default, Prometheus listens on ‘http://localhost:9090’. It’s not recommended to change the default address and port as this might affect or conflict with other services running on the GitLab server.', required: true } ] @@ -65,23 +55,34 @@ class PrometheusService < MonitoringService end def environment_metrics(environment) - with_reactive_cache(Gitlab::Prometheus::Queries::EnvironmentQuery.name, environment.id, &:itself) + with_reactive_cache(Gitlab::Prometheus::Queries::EnvironmentQuery.name, environment.id, &method(:rename_data_to_metrics)) end def deployment_metrics(deployment) - metrics = with_reactive_cache(Gitlab::Prometheus::Queries::DeploymentQuery.name, deployment.id, &:itself) - metrics&.merge(deployment_time: created_at.to_i) || {} + metrics = with_reactive_cache(Gitlab::Prometheus::Queries::DeploymentQuery.name, deployment.id, &method(:rename_data_to_metrics)) + metrics&.merge(deployment_time: deployment.created_at.to_i) || {} + end + + def additional_environment_metrics(environment) + with_reactive_cache(Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery.name, environment.id, &:itself) + end + + def additional_deployment_metrics(deployment) + with_reactive_cache(Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery.name, deployment.id, &:itself) + end + + def matched_metrics + with_reactive_cache(Gitlab::Prometheus::Queries::MatchedMetricsQuery.name, &:itself) end # Cache metrics for specific environment def calculate_reactive_cache(query_class_name, *args) return unless active? && project && !project.pending_delete? - metrics = Kernel.const_get(query_class_name).new(client).query(*args) - + data = Kernel.const_get(query_class_name).new(client).query(*args) { success: true, - metrics: metrics, + data: data, last_update: Time.now.utc } rescue Gitlab::PrometheusError => err @@ -91,4 +92,11 @@ class PrometheusService < MonitoringService def client @prometheus ||= Gitlab::PrometheusClient.new(api_url: api_url) end + + private + + def rename_data_to_metrics(metrics) + metrics[:metrics] = metrics.delete :data + metrics + end end diff --git a/app/models/project_team.rb b/app/models/project_team.rb index e1cc56551ba..674eacd28e8 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -172,10 +172,10 @@ class ProjectTeam return access if user_ids.empty? - users_access = project.project_authorizations. - where(user: user_ids). - group(:user_id). - maximum(:access_level) + users_access = project.project_authorizations + .where(user: user_ids) + .group(:user_id) + .maximum(:access_level) access.merge!(users_access) diff --git a/app/models/repository.rb b/app/models/repository.rb index 7460515fea8..8c24e722a8b 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -241,11 +241,11 @@ class Repository cache.fetch(:"diverging_commit_counts_#{branch.name}") do # Rugged seems to throw a `ReferenceError` when given branch_names rather # than SHA-1 hashes - number_commits_behind = raw_repository. - count_commits_between(branch.dereferenced_target.sha, root_ref_hash) + number_commits_behind = raw_repository + .count_commits_between(branch.dereferenced_target.sha, root_ref_hash) - number_commits_ahead = raw_repository. - count_commits_between(root_ref_hash, branch.dereferenced_target.sha) + number_commits_ahead = raw_repository + .count_commits_between(root_ref_hash, branch.dereferenced_target.sha) { behind: number_commits_behind, ahead: number_commits_ahead } end @@ -605,22 +605,6 @@ class Repository end end - # Returns url for submodule - # - # Ex. - # @repository.submodule_url_for('master', 'rack') - # # => git@localhost:rack.git - # - def submodule_url_for(ref, path) - if submodules(ref).any? - submodule = submodules(ref)[path] - - if submodule - submodule['url'] - end - end - end - def last_commit_for_path(sha, path) sha = last_commit_id_for_path(sha, path) commit(sha) diff --git a/app/models/todo.rb b/app/models/todo.rb index 696d139af74..7af54b2beb2 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -70,9 +70,9 @@ class Todo < ActiveRecord::Base highest_priority = highest_label_priority(params).to_sql - select("#{table_name}.*, (#{highest_priority}) AS highest_priority"). - order(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')). - order('todos.created_at') + select("#{table_name}.*, (#{highest_priority}) AS highest_priority") + .order(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')) + .order('todos.created_at') end end diff --git a/app/models/user.rb b/app/models/user.rb index 782c162e1f3..6dd1b1415d6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -53,7 +53,7 @@ class User < ActiveRecord::Base lease = Gitlab::ExclusiveLease.new("user_update_tracked_fields:#{id}", timeout: 1.hour.to_i) return unless lease.try_obtain - save(validate: false) + Users::UpdateService.new(self).execute(validate: false) end attr_accessor :force_random_password @@ -223,13 +223,13 @@ class User < ActiveRecord::Base scope :order_oldest_sign_in, -> { reorder(Gitlab::Database.nulls_last_order('last_sign_in_at', 'ASC')) } def self.with_two_factor - joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"). - where("u2f.id IS NOT NULL OR otp_required_for_login = ?", true).distinct(arel_table[:id]) + joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id") + .where("u2f.id IS NOT NULL OR otp_required_for_login = ?", true).distinct(arel_table[:id]) end def self.without_two_factor - joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"). - where("u2f.id IS NULL AND otp_required_for_login = ?", false) + joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id") + .where("u2f.id IS NULL AND otp_required_for_login = ?", false) end # @@ -300,9 +300,9 @@ class User < ActiveRecord::Base pattern = "%#{query}%" where( - table[:name].matches(pattern). - or(table[:email].matches(pattern)). - or(table[:username].matches(pattern)) + table[:name].matches(pattern) + .or(table[:email].matches(pattern)) + .or(table[:username].matches(pattern)) ) end @@ -317,10 +317,10 @@ class User < ActiveRecord::Base matched_by_emails_user_ids = email_table.project(email_table[:user_id]).where(email_table[:email].matches(pattern)) where( - table[:name].matches(pattern). - or(table[:email].matches(pattern)). - or(table[:username].matches(pattern)). - or(table[:id].in(matched_by_emails_user_ids)) + table[:name].matches(pattern) + .or(table[:email].matches(pattern)) + .or(table[:username].matches(pattern)) + .or(table[:id].in(matched_by_emails_user_ids)) ) end @@ -494,17 +494,15 @@ class User < ActiveRecord::Base def update_emails_with_primary_email primary_email_record = emails.find_by(email: email) if primary_email_record - primary_email_record.destroy - emails.create(email: email_was) - - update_secondary_emails! + Emails::DestroyService.new(self, email: email).execute + Emails::CreateService.new(self, email: email_was).execute end end # Returns the groups a user has access to def authorized_groups - union = Gitlab::SQL::Union. - new([groups.select(:id), authorized_projects.select(:namespace_id)]) + union = Gitlab::SQL::Union + .new([groups.select(:id), authorized_projects.select(:namespace_id)]) Group.where("namespaces.id IN (#{union.to_sql})") end @@ -533,8 +531,8 @@ class User < ActiveRecord::Base projects = super() if min_access_level - projects = projects. - where('project_authorizations.access_level >= ?', min_access_level) + projects = projects + .where('project_authorizations.access_level >= ?', min_access_level) end projects @@ -572,7 +570,13 @@ class User < ActiveRecord::Base end def require_password? - password_automatically_set? && !ldap_user? + password_automatically_set? && !ldap_user? && current_application_settings.signin_enabled? + end + + def require_personal_access_token? + return false if current_application_settings.signin_enabled? || ldap_user? + + PersonalAccessTokensFinder.new(user: self, impersonation: false, state: 'active').execute.none? end def can_change_username? @@ -619,9 +623,9 @@ class User < ActiveRecord::Base next unless project if project.repository.branch_exists?(event.branch_name) - merge_requests = MergeRequest.where("created_at >= ?", event.created_at). - where(source_project_id: project.id, - source_branch: event.branch_name) + merge_requests = MergeRequest.where("created_at >= ?", event.created_at) + .where(source_project_id: project.id, + source_branch: event.branch_name) merge_requests.empty? end end @@ -832,8 +836,8 @@ class User < ActiveRecord::Base def toggle_star(project) UsersStarProject.transaction do - user_star_project = users_star_projects. - where(project: project, user: self).lock(true).first + user_star_project = users_star_projects + .where(project: project, user: self).lock(true).first if user_star_project user_star_project.destroy @@ -869,11 +873,11 @@ class User < ActiveRecord::Base # ms on a database with a similar size to GitLab.com's database. On the other # hand, using a subquery means we can get the exact same data in about 40 ms. def contributed_projects - events = Event.select(:project_id). - contributions.where(author_id: self). - where("created_at > ?", Time.now - 1.year). - uniq. - reorder(nil) + events = Event.select(:project_id) + .contributions.where(author_id: self) + .where("created_at > ?", Time.now - 1.year) + .uniq + .reorder(nil) Project.where(id: events) end @@ -884,9 +888,9 @@ class User < ActiveRecord::Base def ci_authorized_runners @ci_authorized_runners ||= begin - runner_ids = Ci::RunnerProject. - where("ci_runner_projects.project_id IN (#{ci_projects_union.to_sql})"). - select(:runner_id) + runner_ids = Ci::RunnerProject + .where("ci_runner_projects.project_id IN (#{ci_projects_union.to_sql})") + .select(:runner_id) Ci::Runner.specific.where(id: runner_ids) end end @@ -965,7 +969,7 @@ class User < ActiveRecord::Base if attempts_exceeded? lock_access! unless access_locked? else - save(validate: false) + Users::UpdateService.new(self).execute(validate: false) end end @@ -984,6 +988,12 @@ class User < ActiveRecord::Base self.admin = (new_level == 'admin') end + # Does the user have access to all private groups & projects? + # Overridden in EE to also check auditor? + def full_private_access? + admin? + end + def update_two_factor_requirement periods = expanded_groups_requiring_two_factor_authentication.pluck(:two_factor_grace_period) @@ -1123,7 +1133,8 @@ class User < ActiveRecord::Base email: email, &creation_block ) - user.save(validate: false) + + Users::UpdateService.new(user).execute(validate: false) user ensure Gitlab::ExclusiveLease.cancel(lease_key, uuid) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index c771c22f46a..224eb3cd4d0 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -22,16 +22,16 @@ class WikiPage def self.group_by_directory(pages) return [] if pages.blank? - pages.sort_by { |page| [page.directory, page.slug] }. - group_by(&:directory). - map do |dir, pages| + pages.sort_by { |page| [page.directory, page.slug] } + .group_by(&:directory) + .map do |dir, pages| if dir.present? WikiDirectory.new(dir, pages) else pages end - end. - flatten + end + .flatten end def self.unhyphenize(name) diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index 769749c9925..942145c4a8c 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -67,8 +67,8 @@ module Ci def update_merge_requests_head_pipeline return unless pipeline.latest? - MergeRequest.where(source_project: @pipeline.project, source_branch: @pipeline.ref). - update_all(head_pipeline_id: @pipeline.id) + MergeRequest.where(source_project: @pipeline.project, source_branch: @pipeline.ref) + .update_all(head_pipeline_id: @pipeline.id) end def skip_ci? diff --git a/app/services/ci/create_trigger_request_service.rb b/app/services/ci/create_trigger_request_service.rb index beb27a5a597..cf3d4aee2bc 100644 --- a/app/services/ci/create_trigger_request_service.rb +++ b/app/services/ci/create_trigger_request_service.rb @@ -3,8 +3,8 @@ module Ci def execute(project, trigger, ref, variables = nil) trigger_request = trigger.trigger_requests.create(variables: variables) - pipeline = Ci::CreatePipelineService.new(project, trigger.owner, ref: ref). - execute(:trigger, ignore_skip_ci: true, trigger_request: trigger_request) + pipeline = Ci::CreatePipelineService.new(project, trigger.owner, ref: ref) + .execute(:trigger, ignore_skip_ci: true, trigger_request: trigger_request) trigger_request if pipeline.persisted? end diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb index d6a4280ce4c..af84d4c7427 100644 --- a/app/services/ci/register_job_service.rb +++ b/app/services/ci/register_job_service.rb @@ -54,15 +54,15 @@ module Ci def builds_for_shared_runner new_builds. # don't run projects which have not enabled shared runners and builds - joins(:project).where(projects: { shared_runners_enabled: true }). - joins('LEFT JOIN project_features ON ci_builds.project_id = project_features.project_id'). - where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'). + joins(:project).where(projects: { shared_runners_enabled: true }) + .joins('LEFT JOIN project_features ON ci_builds.project_id = project_features.project_id') + .where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'). # Implement fair scheduling # this returns builds that are ordered by number of running builds # we prefer projects that don't use shared runners at all - joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.project_id=project_builds.project_id"). - order('COALESCE(project_builds.running_builds, 0) ASC', 'ci_builds.id ASC') + joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.project_id=project_builds.project_id") + .order('COALESCE(project_builds.running_builds, 0) ASC', 'ci_builds.id ASC') end def builds_for_specific_runner @@ -70,8 +70,8 @@ module Ci end def running_builds_for_shared_runners - Ci::Build.running.where(runner: Ci::Runner.shared). - group(:project_id).select(:project_id, 'count(*) AS running_builds') + Ci::Build.running.where(runner: Ci::Runner.shared) + .group(:project_id).select(:project_id, 'count(*) AS running_builds') end def new_builds diff --git a/app/services/concerns/issues/resolve_discussions.rb b/app/services/concerns/issues/resolve_discussions.rb index 910a2a15e5d..7d45b4aa26a 100644 --- a/app/services/concerns/issues/resolve_discussions.rb +++ b/app/services/concerns/issues/resolve_discussions.rb @@ -10,9 +10,9 @@ module Issues def merge_request_to_resolve_discussions_of return @merge_request_to_resolve_discussions_of if defined?(@merge_request_to_resolve_discussions_of) - @merge_request_to_resolve_discussions_of = MergeRequestsFinder.new(current_user, project_id: project.id). - execute. - find_by(iid: merge_request_to_resolve_discussions_of_iid) + @merge_request_to_resolve_discussions_of = MergeRequestsFinder.new(current_user, project_id: project.id) + .execute + .find_by(iid: merge_request_to_resolve_discussions_of_iid) end def discussions_to_resolve diff --git a/app/services/create_deployment_service.rb b/app/services/create_deployment_service.rb index 46823418bb0..63b85c3de7d 100644 --- a/app/services/create_deployment_service.rb +++ b/app/services/create_deployment_service.rb @@ -2,7 +2,7 @@ class CreateDeploymentService attr_reader :job delegate :expanded_environment_name, - :environment_url, + :variables, :project, to: :job @@ -14,7 +14,8 @@ class CreateDeploymentService return unless executable? ActiveRecord::Base.transaction do - environment.external_url = environment_url if environment_url + environment.external_url = expanded_environment_url if + expanded_environment_url environment.fire_state_event(action) return unless environment.save @@ -49,6 +50,17 @@ class CreateDeploymentService @environment_options ||= job.options&.dig(:environment) || {} end + def expanded_environment_url + return @expanded_environment_url if defined?(@expanded_environment_url) + + @expanded_environment_url = + ExpandVariables.expand(environment_url, variables) if environment_url + end + + def environment_url + environment_options[:url] + end + def on_stop environment_options[:on_stop] end diff --git a/app/services/emails/base_service.rb b/app/services/emails/base_service.rb new file mode 100644 index 00000000000..ace49889097 --- /dev/null +++ b/app/services/emails/base_service.rb @@ -0,0 +1,8 @@ +module Emails + class BaseService + def initialize(user, opts) + @user = user + @email = opts[:email] + end + end +end diff --git a/app/services/emails/create_service.rb b/app/services/emails/create_service.rb new file mode 100644 index 00000000000..b6491ee9804 --- /dev/null +++ b/app/services/emails/create_service.rb @@ -0,0 +1,7 @@ +module Emails + class CreateService < ::Emails::BaseService + def execute + @user.emails.create(email: @email) + end + end +end diff --git a/app/services/emails/destroy_service.rb b/app/services/emails/destroy_service.rb new file mode 100644 index 00000000000..d586b9dfe0c --- /dev/null +++ b/app/services/emails/destroy_service.rb @@ -0,0 +1,17 @@ +module Emails + class DestroyService < ::Emails::BaseService + def execute + Email.find_by_email!(@email).destroy && update_secondary_emails! + end + + private + + def update_secondary_emails! + result = ::Users::UpdateService.new(@user).execute do |user| + user.update_secondary_emails! + end + + result[:status] == 'success' + end + end +end diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb index f23a9f6d57c..bcca1386bed 100644 --- a/app/services/files/update_service.rb +++ b/app/services/files/update_service.rb @@ -28,8 +28,8 @@ module Files end def last_commit - @last_commit ||= Gitlab::Git::Commit. - last_for_path(@start_project.repository, @start_branch, @file_path) + @last_commit ||= Gitlab::Git::Commit + .last_for_path(@start_project.repository, @start_branch, @file_path) end def validate! diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index fb1d4aed58b..20d1fb29289 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -86,8 +86,8 @@ class GitPushService < BaseService push_commits.last(PROCESS_COMMIT_LIMIT).each do |commit| if commit.matches_cross_reference_regex? - ProcessCommitWorker. - perform_async(project.id, current_user.id, commit.to_hash, default) + ProcessCommitWorker + .perform_async(project.id, current_user.id, commit.to_hash, default) end end end diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index c8db4728aea..8dd0846f3bc 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -144,8 +144,8 @@ class IssuableBaseService < BaseService def merge_quick_actions_into_params!(issuable) description, command_params = - QuickActions::InterpretService.new(project, current_user). - execute(params[:description], issuable) + QuickActions::InterpretService.new(project, current_user) + .execute(params[:description], issuable) # Avoid a description already set on an issuable to be overwritten by a nil params[:description] = description if params.key?(:description) diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb index 3cf4b82b9f2..718a7ac1f22 100644 --- a/app/services/issues/create_service.rb +++ b/app/services/issues/create_service.rb @@ -30,8 +30,8 @@ module Issues Discussions::ResolveService.new(project, current_user, merge_request: merge_request_to_resolve_discussions_of, - follow_up_issue: issue). - execute(discussions_to_resolve) + follow_up_issue: issue) + .execute(discussions_to_resolve) end private diff --git a/app/services/labels/promote_service.rb b/app/services/labels/promote_service.rb index 76d0ba67b07..43b539ded53 100644 --- a/app/services/labels/promote_service.rb +++ b/app/services/labels/promote_service.rb @@ -26,29 +26,29 @@ module Labels private def label_ids_for_merge(new_label) - LabelsFinder. - new(current_user, title: new_label.title, group_id: project.group.id). - execute(skip_authorization: true). - where.not(id: new_label). - select(:id) # Can't use pluck() to avoid object-creation because of the batching + LabelsFinder + .new(current_user, title: new_label.title, group_id: project.group.id) + .execute(skip_authorization: true) + .where.not(id: new_label) + .select(:id) # Can't use pluck() to avoid object-creation because of the batching end def update_issuables(new_label, label_ids) - LabelLink. - where(label: label_ids). - update_all(label_id: new_label) + LabelLink + .where(label: label_ids) + .update_all(label_id: new_label) end def update_issue_board_lists(new_label, label_ids) - List. - where(label: label_ids). - update_all(label_id: new_label) + List + .where(label: label_ids) + .update_all(label_id: new_label) end def update_priorities(new_label, label_ids) - LabelPriority. - where(label: label_ids). - update_all(label_id: new_label) + LabelPriority + .where(label: label_ids) + .update_all(label_id: new_label) end def update_project_labels(label_ids) diff --git a/app/services/labels/transfer_service.rb b/app/services/labels/transfer_service.rb index 514679ed29d..d2ece354efc 100644 --- a/app/services/labels/transfer_service.rb +++ b/app/services/labels/transfer_service.rb @@ -41,16 +41,16 @@ module Labels end def group_labels_applied_to_issues - Label.joins(:issues). - where( + Label.joins(:issues) + .where( issues: { project_id: project.id }, labels: { type: 'GroupLabel', group_id: old_group.id } ) end def group_labels_applied_to_merge_requests - Label.joins(:merge_requests). - where( + Label.joins(:merge_requests) + .where( merge_requests: { target_project_id: project.id }, labels: { type: 'GroupLabel', group_id: old_group.id } ) @@ -64,15 +64,15 @@ module Labels end def update_label_links(labels, old_label_id:, new_label_id:) - LabelLink.joins(:label). - merge(labels). - where(label_id: old_label_id). - update_all(label_id: new_label_id) + LabelLink.joins(:label) + .merge(labels) + .where(label_id: old_label_id) + .update_all(label_id: new_label_id) end def update_label_priorities(old_label_id:, new_label_id:) - LabelPriority.where(project_id: project.id, label_id: old_label_id). - update_all(label_id: new_label_id) + LabelPriority.where(project_id: project.id, label_id: old_label_id) + .update_all(label_id: new_label_id) end end end diff --git a/app/services/members/authorized_destroy_service.rb b/app/services/members/authorized_destroy_service.rb index f846d72498f..de3a252d6c6 100644 --- a/app/services/members/authorized_destroy_service.rb +++ b/app/services/members/authorized_destroy_service.rb @@ -26,30 +26,30 @@ module Members def unassign_issues_and_merge_requests(member) if member.is_a?(GroupMember) - issues = Issue.unscoped.select(1). - joins(:project). - where('issues.id = issue_assignees.issue_id AND projects.namespace_id = ?', member.source_id) + issues = Issue.unscoped.select(1) + .joins(:project) + .where('issues.id = issue_assignees.issue_id AND projects.namespace_id = ?', member.source_id) # DELETE FROM issue_assignees WHERE user_id = X AND EXISTS (...) - IssueAssignee.unscoped. - where('user_id = :user_id AND EXISTS (:sub)', user_id: member.user_id, sub: issues). - delete_all + IssueAssignee.unscoped + .where('user_id = :user_id AND EXISTS (:sub)', user_id: member.user_id, sub: issues) + .delete_all - MergeRequestsFinder.new(user, group_id: member.source_id, assignee_id: member.user_id). - execute. - update_all(assignee_id: nil) + MergeRequestsFinder.new(user, group_id: member.source_id, assignee_id: member.user_id) + .execute + .update_all(assignee_id: nil) else project = member.source # SELECT 1 FROM issues WHERE issues.id = issue_assignees.issue_id AND issues.project_id = X - issues = Issue.unscoped.select(1). - where('issues.id = issue_assignees.issue_id'). - where(project_id: project.id) + issues = Issue.unscoped.select(1) + .where('issues.id = issue_assignees.issue_id') + .where(project_id: project.id) # DELETE FROM issue_assignees WHERE user_id = X AND EXISTS (...) - IssueAssignee.unscoped. - where('user_id = :user_id AND EXISTS (:sub)', user_id: member.user_id, sub: issues). - delete_all + IssueAssignee.unscoped + .where('user_id = :user_id AND EXISTS (:sub)', user_id: member.user_id, sub: issues) + .delete_all project.merge_requests.opened.assigned_to(member.user).update_all(assignee_id: nil) end diff --git a/app/services/merge_requests/conflicts/resolve_service.rb b/app/services/merge_requests/conflicts/resolve_service.rb index c2c335b8461..6b6e231f4f9 100644 --- a/app/services/merge_requests/conflicts/resolve_service.rb +++ b/app/services/merge_requests/conflicts/resolve_service.rb @@ -27,10 +27,10 @@ module MergeRequests tree: merge_index.write_tree(rugged) } - conflicts_for_resolution. - project. - repository. - resolve_conflicts(current_user, merge_request.source_branch, commit_params) + conflicts_for_resolution + .project + .repository + .resolve_conflicts(current_user, merge_request.source_branch, commit_params) end end diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index fac3ac7a4c7..b247cb89e5e 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -61,8 +61,8 @@ module MergeRequests MergeRequests::PostMergeService.new(project, current_user).execute(merge_request) if params[:should_remove_source_branch].present? || @merge_request.force_remove_source_branch? - DeleteBranchService.new(@merge_request.source_project, branch_deletion_user). - execute(merge_request.source_branch) + DeleteBranchService.new(@merge_request.source_project, branch_deletion_user) + .execute(merge_request.source_branch) end end diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index 81d217929d5..e0e7c43f802 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -43,9 +43,9 @@ module MergeRequests end filter_merge_requests(merge_requests).each do |merge_request| - MergeRequests::PostMergeService. - new(merge_request.target_project, @current_user). - execute(merge_request) + MergeRequests::PostMergeService + .new(merge_request.target_project, @current_user) + .execute(merge_request) end end @@ -56,8 +56,8 @@ module MergeRequests # Refresh merge request diff if we push to source or target branch of merge request # Note: we should update merge requests from forks too def reload_merge_requests - merge_requests = @project.merge_requests.opened. - by_source_or_target_branch(@branch_name).to_a + merge_requests = @project.merge_requests.opened + .by_source_or_target_branch(@branch_name).to_a # Fork merge requests merge_requests += MergeRequest.opened diff --git a/app/services/notes/quick_actions_service.rb b/app/services/notes/quick_actions_service.rb index 8f81b54164a..a8d0cc15527 100644 --- a/app/services/notes/quick_actions_service.rb +++ b/app/services/notes/quick_actions_service.rb @@ -22,8 +22,8 @@ module Notes def extract_commands(note, options = {}) return [note.note, {}] unless supported?(note) - QuickActions::InterpretService.new(project, current_user, options). - execute(note.note, note.noteable) + QuickActions::InterpretService.new(project, current_user, options) + .execute(note.note, note.noteable) end def execute(command_params, note) diff --git a/app/services/projects/transfer_service.rb b/app/services/projects/transfer_service.rb index 1c24b27a870..fd701e33524 100644 --- a/app/services/projects/transfer_service.rb +++ b/app/services/projects/transfer_service.rb @@ -12,87 +12,121 @@ module Projects TransferError = Class.new(StandardError) def execute(new_namespace) - if new_namespace.blank? + @new_namespace = new_namespace + + if @new_namespace.blank? raise TransferError, 'Please select a new namespace for your project.' end - unless allowed_transfer?(current_user, project, new_namespace) + + unless allowed_transfer?(current_user, project) raise TransferError, 'Transfer failed, please contact an admin.' end - transfer(project, new_namespace) + + transfer(project) + + true rescue Projects::TransferService::TransferError => ex project.reload project.errors.add(:new_namespace, ex.message) false end - def transfer(project, new_namespace) - old_namespace = project.namespace + private - Project.transaction do - old_path = project.path_with_namespace - old_group = project.group - new_path = File.join(new_namespace.try(:full_path) || '', project.path) + def transfer(project) + @old_path = project.path_with_namespace + @old_group = project.group + @new_path = File.join(@new_namespace.try(:full_path) || '', project.path) + @old_namespace = project.namespace - if Project.where(path: project.path, namespace_id: new_namespace.try(:id)).present? - raise TransferError.new("Project with same path in target namespace already exists") - end + if Project.where(path: project.path, namespace_id: @new_namespace.try(:id)).exists? + raise TransferError.new("Project with same path in target namespace already exists") + end - if project.has_container_registry_tags? - # we currently doesn't support renaming repository if it contains tags in container registry - raise TransferError.new('Project cannot be transferred, because tags are present in its container registry') - end + if project.has_container_registry_tags? + # We currently don't support renaming repository if it contains tags in container registry + raise TransferError.new('Project cannot be transferred, because tags are present in its container registry') + end - project.expire_caches_before_rename(old_path) + attempt_transfer_transaction + end + + def attempt_transfer_transaction + Project.transaction do + project.expire_caches_before_rename(@old_path) - # Apply new namespace id and visibility level - project.namespace = new_namespace - project.visibility_level = new_namespace.visibility_level unless project.visibility_level_allowed_by_group? - project.save! + update_namespace_and_visibility(@new_namespace) # Notifications - project.send_move_instructions(old_path) + project.send_move_instructions(@old_path) # Move main repository - unless gitlab_shell.mv_repository(project.repository_storage_path, old_path, new_path) + unless move_repo_folder(@old_path, @new_path) raise TransferError.new('Cannot move project') end # Move wiki repo also if present - gitlab_shell.mv_repository(project.repository_storage_path, "#{old_path}.wiki", "#{new_path}.wiki") + move_repo_folder("#{@old_path}.wiki", "#{@new_path}.wiki") # Move missing group labels to project - Labels::TransferService.new(current_user, old_group, project).execute + Labels::TransferService.new(current_user, @old_group, project).execute # Move uploads - Gitlab::UploadsTransfer.new.move_project(project.path, old_namespace.full_path, new_namespace.full_path) + Gitlab::UploadsTransfer.new.move_project(project.path, @old_namespace.full_path, @new_namespace.full_path) # Move pages - Gitlab::PagesTransfer.new.move_project(project.path, old_namespace.full_path, new_namespace.full_path) + Gitlab::PagesTransfer.new.move_project(project.path, @old_namespace.full_path, @new_namespace.full_path) - project.old_path_with_namespace = old_path + project.old_path_with_namespace = @old_path - SystemHooksService.new.execute_hooks_for(project, :transfer) + execute_system_hooks end - - refresh_permissions(old_namespace, new_namespace) - - true + rescue Exception # rubocop:disable Lint/RescueException + rollback_side_effects + raise + ensure + refresh_permissions end - def allowed_transfer?(current_user, project, namespace) - namespace && + def allowed_transfer?(current_user, project) + @new_namespace && can?(current_user, :change_namespace, project) && - namespace.id != project.namespace_id && - current_user.can?(:create_projects, namespace) + @new_namespace.id != project.namespace_id && + current_user.can?(:create_projects, @new_namespace) end - def refresh_permissions(old_namespace, new_namespace) + def update_namespace_and_visibility(to_namespace) + # Apply new namespace id and visibility level + project.namespace = to_namespace + project.visibility_level = to_namespace.visibility_level unless project.visibility_level_allowed_by_group? + project.save! + end + + def refresh_permissions # This ensures we only schedule 1 job for every user that has access to # the namespaces. - user_ids = old_namespace.user_ids_for_project_authorizations | - new_namespace.user_ids_for_project_authorizations + user_ids = @old_namespace.user_ids_for_project_authorizations | + @new_namespace.user_ids_for_project_authorizations UserProjectAccessChangedService.new(user_ids).execute end + + def rollback_side_effects + rollback_folder_move + update_namespace_and_visibility(@old_namespace) + end + + def rollback_folder_move + move_repo_folder(@new_path, @old_path) + move_repo_folder("#{@new_path}.wiki", "#{@old_path}.wiki") + end + + def move_repo_folder(from_name, to_name) + gitlab_shell.mv_repository(project.repository_storage_path, from_name, to_name) + end + + def execute_system_hooks + SystemHooksService.new.execute_hooks_for(project, :transfer) + end end end diff --git a/app/services/tags/create_service.rb b/app/services/tags/create_service.rb index 1756da9e519..674792f6138 100644 --- a/app/services/tags/create_service.rb +++ b/app/services/tags/create_service.rb @@ -19,8 +19,8 @@ module Tags if new_tag if release_description - CreateReleaseService.new(@project, @current_user). - execute(tag_name, release_description) + CreateReleaseService.new(@project, @current_user) + .execute(tag_name, release_description) end success.merge(tag: new_tag) diff --git a/app/services/users/build_service.rb b/app/services/users/build_service.rb index 363135ef09b..ff234a3440f 100644 --- a/app/services/users/build_service.rb +++ b/app/services/users/build_service.rb @@ -1,5 +1,4 @@ module Users - # Service for building a new user. class BuildService < BaseService def initialize(current_user, params = {}) @current_user = current_user diff --git a/app/services/users/create_service.rb b/app/services/users/create_service.rb index e22f7225ae2..74abc017cea 100644 --- a/app/services/users/create_service.rb +++ b/app/services/users/create_service.rb @@ -1,5 +1,4 @@ module Users - # Service for creating a new user. class CreateService < BaseService def initialize(current_user, params = {}) @current_user = current_user diff --git a/app/services/users/update_service.rb b/app/services/users/update_service.rb new file mode 100644 index 00000000000..dfbd6016c3f --- /dev/null +++ b/app/services/users/update_service.rb @@ -0,0 +1,34 @@ +module Users + class UpdateService < BaseService + def initialize(user, params = {}) + @user = user + @params = params.dup + end + + def execute(validate: true, &block) + yield(@user) if block_given? + + assign_attributes(&block) + + if @user.save(validate: validate) + success + else + error(@user.errors.full_messages.uniq.join('. ')) + end + end + + def execute!(*args, &block) + result = execute(*args, &block) + + raise ActiveRecord::RecordInvalid.new(@user) unless result[:status] == :success + + true + end + + private + + def assign_attributes(&block) + @user.assign_attributes(params) if params.any? + end + end +end diff --git a/app/validators/dynamic_path_validator.rb b/app/validators/dynamic_path_validator.rb index 27ac60637fd..4688aabc2a8 100644 --- a/app/validators/dynamic_path_validator.rb +++ b/app/validators/dynamic_path_validator.rb @@ -26,7 +26,7 @@ class DynamicPathValidator < ActiveModel::EachValidator end def path_valid_for_record?(record, value) - full_path = record.respond_to?(:full_path) ? record.full_path : value + full_path = record.respond_to?(:build_full_path) ? record.build_full_path : value return true unless full_path diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index 95dffdafabe..b21d5665970 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -325,6 +325,10 @@ = f.label :prometheus_metrics_enabled do = f.check_box :prometheus_metrics_enabled Enable Prometheus Metrics + - unless Gitlab::Metrics.metrics_folder_present? + .help-block + %strong.cred WARNING: + Environment variable `prometheus_multiproc_dir` does not exist or is not pointing to a valid directory. %fieldset %legend Background Jobs diff --git a/app/views/admin/runners/index.html.haml b/app/views/admin/runners/index.html.haml index e242e851b4d..2da8f615470 100644 --- a/app/views/admin/runners/index.html.haml +++ b/app/views/admin/runners/index.html.haml @@ -58,20 +58,23 @@ %br - .table-holder - %table.table - %thead - %tr - %th Type - %th Runner token - %th Description - %th Version - %th Projects - %th Jobs - %th Tags - %th Last contact - %th + - if @runners.any? + .table-holder + %table.table + %thead + %tr + %th Type + %th Runner token + %th Description + %th Version + %th Projects + %th Jobs + %th Tags + %th Last contact + %th - - @runners.each do |runner| - = render "admin/runners/runner", runner: runner - = paginate @runners, theme: "gitlab" + - @runners.each do |runner| + = render "admin/runners/runner", runner: runner + = paginate @runners, theme: "gitlab" + - else + .nothing-here-block No runners found diff --git a/app/views/groups/_home_panel.html.haml b/app/views/groups/_home_panel.html.haml index 41f54f6bf42..181c7bee702 100644 --- a/app/views/groups/_home_panel.html.haml +++ b/app/views/groups/_home_panel.html.haml @@ -3,7 +3,7 @@ .avatar-container.s70.group-avatar = image_tag group_icon(@group), class: "avatar s70 avatar-tile" %h1.group-title - @#{@group.path} + = @group.name %span.visibility-icon.has-tooltip{ data: { container: 'body' }, title: visibility_icon_description(@group) } = visibility_level_icon(@group.visibility_level, fw: false) diff --git a/app/views/groups/merge_requests.html.haml b/app/views/groups/merge_requests.html.haml index 8fe0bd149f3..45e39252e16 100644 --- a/app/views/groups/merge_requests.html.haml +++ b/app/views/groups/merge_requests.html.haml @@ -18,5 +18,4 @@ - if current_user To see all merge requests you should visit #{link_to 'dashboard', merge_requests_dashboard_path} page. - .prepend-top-default - = render 'shared/merge_requests' + = render 'shared/merge_requests' diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index eea33b5966f..eabc9a3b01c 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -30,6 +30,10 @@ = stylesheet_link_tag "test", media: "all" if Rails.env.test? = stylesheet_link_tag 'peek' if peek_enabled? + - if show_new_nav? + = stylesheet_link_tag "new_nav", media: "all" + = stylesheet_link_tag "new_sidebar", media: "all" + = Gon::Base.render_data = webpack_bundle_tag "runtime" diff --git a/app/views/layouts/_page.html.haml b/app/views/layouts/_page.html.haml index b7df11681d3..62a76a1b00e 100644 --- a/app/views/layouts/_page.html.haml +++ b/app/views/layouts/_page.html.haml @@ -1,11 +1,15 @@ -.page-with-sidebar{ class: page_gutter_class } - - if defined?(nav) && nav - .layout-nav - .container-fluid - = render "layouts/nav/#{nav}" - - if content_for?(:sub_nav) - = yield :sub_nav - .content-wrapper{ class: layout_nav_class } +.page-with-sidebar{ class: "#{('page-with-new-sidebar' if defined?(@new_sidebar) && @new_sidebar)} #{page_gutter_class}" } + - if show_new_nav? + - if defined?(nav) && nav + = render "layouts/nav/#{nav}" + - else + - if defined?(nav) && nav + .layout-nav + .container-fluid + = render "layouts/nav/#{nav}" + - if content_for?(:sub_nav) + = yield :sub_nav + .content-wrapper{ class: "#{(layout_nav_class unless show_new_nav?)}" } .alert-wrapper = render "layouts/broadcast" = render "layouts/flash" diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 87064cc9b3f..ae9eee215e0 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -1,5 +1,9 @@ - page_title "Admin Area" - header_title "Admin Area", admin_root_path -- nav "admin" +- if show_new_nav? + - nav "new_admin_sidebar" + - @new_sidebar = true +- else + - nav "admin" = render template: "layouts/application" diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2b07273a0a8..d879df8fc82 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -4,7 +4,10 @@ %body{ class: @body_class, data: { page: body_data_page, project: "#{@project.path if @project}", group: "#{@group.path if @group}" } } = render "layouts/init_auto_complete" if @gfm_form = render 'peek/bar' - = render "layouts/header/default", title: header_title + - if show_new_nav? + = render "layouts/header/new" + - else + = render "layouts/header/default", title: header_title = render 'layouts/page', sidebar: sidebar, nav: nav = yield :scripts_body diff --git a/app/views/layouts/group.html.haml b/app/views/layouts/group.html.haml index f06acc98ca1..35abfa0e80c 100644 --- a/app/views/layouts/group.html.haml +++ b/app/views/layouts/group.html.haml @@ -1,6 +1,10 @@ - page_title @group.name - page_description @group.description unless page_description - header_title group_title(@group) unless header_title -- nav "group" +- if show_new_nav? + - nav "new_group_sidebar" + - @new_sidebar = true +- else + - nav "group" = render template: "layouts/application" diff --git a/app/views/layouts/header/_default.html.haml b/app/views/layouts/header/_default.html.haml index 249253f4906..f056c0af968 100644 --- a/app/views/layouts/header/_default.html.haml +++ b/app/views/layouts/header/_default.html.haml @@ -74,6 +74,9 @@ = link_to "Profile", current_user, class: 'profile-link', data: { user: current_user.username } %li = link_to "Settings", profile_path + - if can_toggle_new_nav? + %li + = link_to "Turn on new nav", profile_preferences_path(anchor: "new-navigation") %li.divider %li = link_to "Sign out", destroy_user_session_path, method: :delete, class: "sign-out-link" diff --git a/app/views/layouts/header/_new.html.haml b/app/views/layouts/header/_new.html.haml new file mode 100644 index 00000000000..c0833c64911 --- /dev/null +++ b/app/views/layouts/header/_new.html.haml @@ -0,0 +1,93 @@ +%header.navbar.navbar-gitlab.navbar-gitlab-new{ class: nav_header_class } + %a.sr-only.gl-accessibility{ href: "#content-body", tabindex: "1" } Skip to content + .container-fluid + .header-content + .title-container + %h1.title + = link_to root_path, title: 'Dashboard' do + = brand_header_logo + %span.hidden-xs + GitLab + + - if current_user + = render "layouts/nav/new_dashboard" + - else + = render "layouts/nav/new_explore" + + .navbar-collapse.collapse + %ul.nav.navbar-nav + %li.hidden-sm.hidden-xs + = render 'layouts/search' unless current_controller?(:search) + %li.visible-sm-inline-block.visible-xs-inline-block + = link_to search_path, title: 'Search', aria: { label: "Search" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do + = icon('search') + - if current_user + - if session[:impersonator_id] + %li.impersonation + = link_to admin_impersonation_path, method: :delete, title: "Stop impersonation", aria: { label: 'Stop impersonation' }, data: { toggle: 'tooltip', placement: 'bottom', container: 'body' } do + = icon('user-secret fw') + - if current_user.admin? + %li + = link_to admin_root_path, title: 'Admin area', aria: { label: "Admin area" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do + = icon('wrench fw') + = render 'layouts/header/new_dropdown' + - if Gitlab::Sherlock.enabled? + %li + = link_to sherlock_transactions_path, title: 'Sherlock Transactions', + data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do + = icon('tachometer fw') + %li + = link_to assigned_issues_dashboard_path, title: 'Issues', aria: { label: "Issues" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do + = icon('hashtag fw') + - issues_count = assigned_issuables_count(:issues) + %span.badge.issues-count{ class: ('hidden' if issues_count.zero?) } + = number_with_delimiter(issues_count) + %li + = link_to assigned_mrs_dashboard_path, title: 'Merge requests', aria: { label: "Merge requests" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do + = custom_icon('mr_bold') + - merge_requests_count = assigned_issuables_count(:merge_requests) + %span.badge.merge-requests-count{ class: ('hidden' if merge_requests_count.zero?) } + = number_with_delimiter(merge_requests_count) + %li + = link_to dashboard_todos_path, title: 'Todos', aria: { label: "Todos" }, class: 'shortcuts-todos', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do + = icon('check-circle fw') + %span.badge.todos-count{ class: ('hidden' if todos_pending_count.zero?) } + = todos_count_format(todos_pending_count) + %li.header-user.dropdown + = link_to current_user, class: "header-user-dropdown-toggle", data: { toggle: "dropdown" } do + = image_tag avatar_icon(current_user, 26), width: 26, height: 26, class: "header-user-avatar" + = icon('chevron-down') + .dropdown-menu-nav.dropdown-menu-align-right + %ul + %li.current-user + .user-name.bold + = current_user.name + @#{current_user.username} + %li.divider + %li + = link_to "Profile", current_user, class: 'profile-link', data: { user: current_user.username } + %li + = link_to "Settings", profile_path + %li + = link_to "Turn off new nav", profile_preferences_path(anchor: "new-navigation") + %li.divider + %li + = link_to "Sign out", destroy_user_session_path, method: :delete, class: "sign-out-link" + - else + %li + %div + = link_to "Sign in", new_session_path(:user, redirect_to_referer: 'yes'), class: 'btn btn-sign-in btn-success' + + %button.navbar-toggle.hidden-sm.hidden-md.hidden-lg{ type: 'button' } + %span.sr-only Toggle navigation + = icon('ellipsis-v', class: 'js-navbar-toggle-right') + = icon('times', class: 'js-navbar-toggle-left', style: 'display: none;') + + = yield :header_content + += render 'shared/outdated_browser' + +- if @project && !@project.empty_repo? + - if ref = @ref || @project.repository.root_ref + :javascript + var findFileURL = "#{namespace_project_find_file_path(@project.namespace, @project, ref)}"; diff --git a/app/views/layouts/header/_new_dropdown.haml b/app/views/layouts/header/_new_dropdown.haml index c7302414386..9ff1164f2ee 100644 --- a/app/views/layouts/header/_new_dropdown.haml +++ b/app/views/layouts/header/_new_dropdown.haml @@ -1,10 +1,14 @@ %li.header-new.dropdown = link_to new_project_path, class: "header-new-dropdown-toggle has-tooltip", title: "New...", ref: 'tooltip', aria: { label: "New..." }, data: { toggle: 'dropdown', placement: 'bottom', container: 'body' } do - = icon('plus fw') - = icon('caret-down') + - if show_new_nav? + = icon('plus') + = icon('chevron-down') + - else + = icon('plus fw') + = icon('caret-down') .dropdown-menu-nav.dropdown-menu-align-right %ul - - if @group + - if @group&.persisted? - create_group_project = can?(current_user, :create_projects, @group) - create_group_subgroup = can?(current_user, :create_subgroup, @group) - if create_group_project || create_group_subgroup @@ -18,7 +22,7 @@ %li.divider %li.dropdown-bold-header GitLab - - if @project && @project.persisted? + - if @project&.persisted? - create_project_issue = can?(current_user, :create_issue, @project) - merge_project = can?(current_user, :create_merge_request, @project) ? @project : (current_user && current_user.fork_of(@project)) - create_project_snippet = can?(current_user, :create_project_snippet, @project) diff --git a/app/views/layouts/nav/_new_admin_sidebar.html.haml b/app/views/layouts/nav/_new_admin_sidebar.html.haml new file mode 100644 index 00000000000..f995145917c --- /dev/null +++ b/app/views/layouts/nav/_new_admin_sidebar.html.haml @@ -0,0 +1,119 @@ +.nav-sidebar + %ul.sidebar-top-level-items + = nav_link(controller: %w(dashboard admin projects users groups builds runners cohorts), html_options: {class: 'home'}) do + = link_to admin_root_path, title: 'Overview', class: 'shortcuts-tree' do + %span + Overview + + %ul.sidebar-sub-level-items + = nav_link(controller: :dashboard, html_options: {class: 'home'}) do + = link_to admin_root_path, title: 'Overview' do + %span + Overview + = nav_link(controller: [:admin, :projects]) do + = link_to admin_projects_path, title: 'Projects' do + %span + Projects + = nav_link(controller: :users) do + = link_to admin_users_path, title: 'Users' do + %span + Users + = nav_link(controller: :groups) do + = link_to admin_groups_path, title: 'Groups' do + %span + Groups + = nav_link path: 'builds#index' do + = link_to admin_jobs_path, title: 'Jobs' do + %span + Jobs + = nav_link path: ['runners#index', 'runners#show'] do + = link_to admin_runners_path, title: 'Runners' do + %span + Runners + = nav_link path: 'cohorts#index' do + = link_to admin_cohorts_path, title: 'Cohorts' do + %span + Cohorts + + = nav_link(controller: %w(conversational_development_index system_info background_jobs logs health_check requests_profiles)) do + = link_to admin_conversational_development_index_path, title: 'Monitoring' do + %span + Monitoring + + %ul.sidebar-sub-level-items + = nav_link(controller: :conversational_development_index) do + = link_to admin_conversational_development_index_path, title: 'ConvDev Index' do + %span + ConvDev Index + = nav_link(controller: :system_info) do + = link_to admin_system_info_path, title: 'System Info' do + %span + System Info + = nav_link(controller: :background_jobs) do + = link_to admin_background_jobs_path, title: 'Background Jobs' do + %span + Background Jobs + = nav_link(controller: :logs) do + = link_to admin_logs_path, title: 'Logs' do + %span + Logs + = nav_link(controller: :health_check) do + = link_to admin_health_check_path, title: 'Health Check' do + %span + Health Check + = nav_link(controller: :requests_profiles) do + = link_to admin_requests_profiles_path, title: 'Requests Profiles' do + %span + Requests Profiles + + = nav_link(controller: :broadcast_messages) do + = link_to admin_broadcast_messages_path, title: 'Messages' do + %span + Messages + = nav_link(controller: [:hooks, :hook_logs]) do + = link_to admin_hooks_path, title: 'Hooks' do + %span + System Hooks + + = nav_link(controller: :applications) do + = link_to admin_applications_path, title: 'Applications' do + %span + Applications + + = nav_link(controller: :abuse_reports) do + = link_to admin_abuse_reports_path, title: "Abuse Reports" do + %span + Abuse Reports + %span.badge.count= number_with_delimiter(AbuseReport.count(:all)) + + - if akismet_enabled? + = nav_link(controller: :spam_logs) do + = link_to admin_spam_logs_path, title: "Spam Logs" do + %span + Spam Logs + + = nav_link(controller: :deploy_keys) do + = link_to admin_deploy_keys_path, title: 'Deploy Keys' do + %span + Deploy Keys + + = nav_link(controller: :services) do + = link_to admin_application_settings_services_path, title: 'Service Templates' do + %span + Service Templates + + = nav_link(controller: :labels) do + = link_to admin_labels_path, title: 'Labels' do + %span + Labels + + = nav_link(controller: :appearances) do + = link_to admin_appearances_path, title: 'Appearances' do + %span + Appearance + + %li.divider + = nav_link(controller: :application_settings) do + = link_to admin_application_settings_path, title: 'Settings' do + %span + Settings diff --git a/app/views/layouts/nav/_new_dashboard.html.haml b/app/views/layouts/nav/_new_dashboard.html.haml new file mode 100644 index 00000000000..7109baa4dad --- /dev/null +++ b/app/views/layouts/nav/_new_dashboard.html.haml @@ -0,0 +1,33 @@ +%ul.list-unstyled.navbar-sub-nav + = nav_link(path: ['root#index', 'projects#trending', 'projects#starred', 'dashboard/projects#index'], html_options: {class: "home"}) do + = link_to dashboard_projects_path, title: 'Projects', class: 'dashboard-shortcuts-projects' do + Projects + + = nav_link(controller: [:groups, 'groups/milestones', 'groups/group_members']) do + = link_to dashboard_groups_path, class: 'dashboard-shortcuts-groups', title: 'Groups' do + Groups + + = nav_link(path: 'dashboard#activity', html_options: { class: "hidden-xs hidden-sm" }) do + = link_to activity_dashboard_path, class: 'dashboard-shortcuts-activity', title: 'Activity' do + Activity + + %li.dropdown + %a{ href: "#", data: { toggle: "dropdown" } } + More + = icon("chevron-down", class: "dropdown-chevron") + .dropdown-menu + %ul + = nav_link(path: 'dashboard#activity', html_options: { class: "visible-xs visible-sm" }) do + = link_to activity_dashboard_path, title: 'Activity' do + Activity + + = nav_link(controller: 'dashboard/milestones') do + = link_to dashboard_milestones_path, class: 'dashboard-shortcuts-milestones', title: 'Milestones' do + Milestones + + = nav_link(controller: 'dashboard/snippets') do + = link_to dashboard_snippets_path, class: 'dashboard-shortcuts-snippets', title: 'Snippets' do + Snippets + %li.divider + %li + = link_to "Help", help_path, title: 'About GitLab CE' diff --git a/app/views/layouts/nav/_new_explore.html.haml b/app/views/layouts/nav/_new_explore.html.haml new file mode 100644 index 00000000000..40385f251e3 --- /dev/null +++ b/app/views/layouts/nav/_new_explore.html.haml @@ -0,0 +1,19 @@ +%ul.list-unstyled.navbar-sub-nav + = nav_link(path: ['dashboard#show', 'root#show', 'projects#trending', 'projects#starred', 'projects#index'], html_options: {class: 'home'}) do + = link_to explore_root_path, title: 'Projects', class: 'dashboard-shortcuts-projects' do + Projects + = nav_link(controller: [:groups, 'groups/milestones', 'groups/group_members']) do + = link_to explore_groups_path, title: 'Groups', class: 'dashboard-shortcuts-groups' do + Groups + %li.dropdown + %a{ href: "#", data: { toggle: "dropdown" } } + More + = icon("chevron-down", class: "dropdown-chevron") + .dropdown-menu + %ul + = nav_link(controller: :snippets) do + = link_to explore_snippets_path, title: 'Snippets', class: 'dashboard-shortcuts-snippets' do + Snippets + %li.divider + %li + = link_to "Help", help_path, title: 'About GitLab CE' diff --git a/app/views/layouts/nav/_new_group_sidebar.html.haml b/app/views/layouts/nav/_new_group_sidebar.html.haml new file mode 100644 index 00000000000..3b658e055b3 --- /dev/null +++ b/app/views/layouts/nav/_new_group_sidebar.html.haml @@ -0,0 +1,56 @@ +.nav-sidebar + %ul.sidebar-top-level-items + = nav_link(path: ['groups#show', 'groups#activity', 'groups#subgroups'], html_options: { class: 'home' }) do + = link_to group_path(@group), title: 'Home' do + %span + Group + + %ul.sidebar-sub-level-items + = nav_link(path: ['groups#show', 'groups#subgroups'], html_options: { class: 'home' }) do + = link_to group_path(@group), title: 'Group Home' do + %span + Home + + = nav_link(path: 'groups#activity') do + = link_to activity_group_path(@group), title: 'Activity' do + %span + Activity + + = nav_link(path: ['groups#issues', 'labels#index', 'milestones#index']) do + = link_to issues_group_path(@group), title: 'Issues' do + %span + Issues + - issues = IssuesFinder.new(current_user, group_id: @group.id, state: 'opened').execute + %span.badge.count= number_with_delimiter(issues.count) + + %ul.sidebar-sub-level-items + = nav_link(path: 'groups#issues', html_options: { class: 'home' }) do + = link_to issues_group_path(@group), title: 'List' do + %span + List + + = nav_link(path: 'labels#index') do + = link_to group_labels_path(@group), title: 'Labels' do + %span + Labels + + = nav_link(path: 'milestones#index') do + = link_to group_milestones_path(@group), title: 'Milestones' do + %span + Milestones + + = nav_link(path: 'groups#merge_requests') do + = link_to merge_requests_group_path(@group), title: 'Merge Requests' do + %span + Merge Requests + - merge_requests = MergeRequestsFinder.new(current_user, group_id: @group.id, state: 'opened', non_archived: true).execute + %span.badge.count= number_with_delimiter(merge_requests.count) + = nav_link(path: 'group_members#index') do + = link_to group_group_members_path(@group), title: 'Members' do + %span + Members + - if current_user && can?(current_user, :admin_group, @group) + = nav_link(path: %w[groups#projects groups#edit]) do + = link_to edit_group_path(@group), title: 'Settings' do + %span + Settings diff --git a/app/views/layouts/nav/_new_profile_sidebar.html.haml b/app/views/layouts/nav/_new_profile_sidebar.html.haml new file mode 100644 index 00000000000..37ffbbecca8 --- /dev/null +++ b/app/views/layouts/nav/_new_profile_sidebar.html.haml @@ -0,0 +1,49 @@ +.nav-sidebar + %ul.sidebar-top-level-items + = nav_link(path: 'profiles#show', html_options: {class: 'home'}) do + = link_to profile_path, title: 'Profile Settings' do + %span + Profile + = nav_link(controller: [:accounts, :two_factor_auths]) do + = link_to profile_account_path, title: 'Account' do + %span + Account + - if current_application_settings.user_oauth_applications? + = nav_link(controller: 'oauth/applications') do + = link_to applications_profile_path, title: 'Applications' do + %span + Applications + = nav_link(controller: :chat_names) do + = link_to profile_chat_names_path, title: 'Chat' do + %span + Chat + = nav_link(controller: :personal_access_tokens) do + = link_to profile_personal_access_tokens_path, title: 'Access Tokens' do + %span + Access Tokens + = nav_link(controller: :emails) do + = link_to profile_emails_path, title: 'Emails' do + %span + Emails + - unless current_user.ldap_user? + = nav_link(controller: :passwords) do + = link_to edit_profile_password_path, title: 'Password' do + %span + Password + = nav_link(controller: :notifications) do + = link_to profile_notifications_path, title: 'Notifications' do + %span + Notifications + + = nav_link(controller: :keys) do + = link_to profile_keys_path, title: 'SSH Keys' do + %span + SSH Keys + = nav_link(controller: :preferences) do + = link_to profile_preferences_path, title: 'Preferences' do + %span + Preferences + = nav_link(path: 'profiles#audit_log') do + = link_to audit_log_profile_path, title: 'Authentication log' do + %span + Authentication log diff --git a/app/views/layouts/nav/_new_project_sidebar.html.haml b/app/views/layouts/nav/_new_project_sidebar.html.haml new file mode 100644 index 00000000000..f85781737aa --- /dev/null +++ b/app/views/layouts/nav/_new_project_sidebar.html.haml @@ -0,0 +1,242 @@ +.nav-sidebar + - can_edit = can?(current_user, :admin_project, @project) + %ul.sidebar-top-level-items + = nav_link(path: ['projects#show', 'projects#activity', 'cycle_analytics#show'], html_options: { class: 'home' }) do + = link_to project_path(@project), title: 'Project', class: 'shortcuts-project' do + %span + Project + + %ul.sidebar-sub-level-items + = nav_link(path: 'projects#show') do + = link_to project_path(@project), title: _('Project home'), class: 'shortcuts-project' do + %span= _('Home') + + = nav_link(path: 'projects#activity') do + = link_to activity_project_path(@project), title: _('Activity'), class: 'shortcuts-project-activity' do + %span= _('Activity') + + - if can?(current_user, :read_cycle_analytics, @project) + = nav_link(path: 'cycle_analytics#show') do + = link_to project_cycle_analytics_path(@project), title: _('Cycle Analytics'), class: 'shortcuts-project-cycle-analytics' do + %span= _('Cycle Analytics') + + - if project_nav_tab? :files + = nav_link(controller: %w(tree blob blame edit_tree new_tree find_file commit commits compare projects/repositories tags branches releases graphs network)) do + = link_to project_files_path(@project), title: 'Repository', class: 'shortcuts-tree' do + %span + Repository + + %ul.sidebar-sub-level-items + = nav_link(controller: %w(tree blob blame edit_tree new_tree find_file)) do + = link_to project_files_path(@project) do + #{ _('Files') } + + = nav_link(controller: [:commit, :commits]) do + = link_to namespace_project_commits_path(@project.namespace, @project, current_ref) do + #{ _('Commits') } + + = nav_link(html_options: {class: branches_tab_class}) do + = link_to namespace_project_branches_path(@project.namespace, @project) do + #{ _('Branches') } + + = nav_link(controller: [:tags, :releases]) do + = link_to namespace_project_tags_path(@project.namespace, @project) do + #{ _('Tags') } + + = nav_link(path: 'graphs#show') do + = link_to namespace_project_graph_path(@project.namespace, @project, current_ref) do + #{ _('Contributors') } + + = nav_link(controller: %w(network)) do + = link_to namespace_project_network_path(@project.namespace, @project, current_ref) do + #{ s_('ProjectNetworkGraph|Graph') } + + = nav_link(controller: :compare) do + = link_to namespace_project_compare_index_path(@project.namespace, @project, from: @repository.root_ref, to: current_ref) do + #{ _('Compare') } + + = nav_link(path: 'graphs#charts') do + = link_to charts_namespace_project_graph_path(@project.namespace, @project, current_ref) do + #{ _('Charts') } + + - if project_nav_tab? :container_registry + = nav_link(controller: %w[projects/registry/repositories]) do + = link_to project_container_registry_path(@project), title: 'Container Registry', class: 'shortcuts-container-registry' do + %span + Registry + + - if project_nav_tab? :issues + = nav_link(controller: @project.default_issues_tracker? ? [:issues, :labels, :milestones, :boards] : :issues) do + = link_to namespace_project_issues_path(@project.namespace, @project), title: 'Issues', class: 'shortcuts-issues' do + %span + Issues + - if @project.default_issues_tracker? + %span.badge.count.issue_counter= number_with_delimiter(IssuesFinder.new(current_user, project_id: @project.id).execute.opened.count) + + %ul.sidebar-sub-level-items + - if project_nav_tab?(:issues) && !current_controller?(:merge_requests) + = nav_link(controller: :issues) do + = link_to namespace_project_issues_path(@project.namespace, @project), title: 'Issues' do + %span + List + + = nav_link(controller: :boards) do + = link_to namespace_project_boards_path(@project.namespace, @project), title: 'Board' do + %span + Board + + - if project_nav_tab?(:merge_requests) && current_controller?(:merge_requests) + = nav_link(controller: :merge_requests) do + = link_to namespace_project_merge_requests_path(@project.namespace, @project), title: 'Merge Requests' do + %span + Merge Requests + + - if project_nav_tab? :labels + = nav_link(controller: :labels) do + = link_to namespace_project_labels_path(@project.namespace, @project), title: 'Labels' do + %span + Labels + + - if project_nav_tab? :milestones + = nav_link(controller: :milestones) do + = link_to namespace_project_milestones_path(@project.namespace, @project), title: 'Milestones' do + %span + Milestones + + - if project_nav_tab? :merge_requests + = nav_link(controller: @project.default_issues_tracker? ? :merge_requests : [:merge_requests, :labels, :milestones]) do + = link_to namespace_project_merge_requests_path(@project.namespace, @project), title: 'Merge Requests', class: 'shortcuts-merge_requests' do + %span + Merge Requests + %span.badge.count.merge_counter.js-merge-counter= number_with_delimiter(MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened.count) + + - if project_nav_tab? :pipelines + = nav_link(controller: [:pipelines, :builds, :jobs, :pipeline_schedules, :environments, :artifacts]) do + = link_to project_pipelines_path(@project), title: 'Pipelines', class: 'shortcuts-pipelines' do + %span + Pipelines + + %ul.sidebar-sub-level-items + - if project_nav_tab? :pipelines + = nav_link(path: ['pipelines#index', 'pipelines#show']) do + = link_to project_pipelines_path(@project), title: 'Pipelines', class: 'shortcuts-pipelines' do + %span + Pipelines + + - if project_nav_tab? :builds + = nav_link(controller: [:jobs, :artifacts]) do + = link_to project_jobs_path(@project), title: 'Jobs', class: 'shortcuts-builds' do + %span + Jobs + + - if project_nav_tab? :pipelines + = nav_link(controller: :pipeline_schedules) do + = link_to pipeline_schedules_path(@project), title: 'Schedules', class: 'shortcuts-builds' do + %span + Schedules + + - if project_nav_tab? :environments + = nav_link(controller: :environments) do + = link_to project_environments_path(@project), title: 'Environments', class: 'shortcuts-environments' do + %span + Environments + + - if @project.feature_available?(:builds, current_user) && !@project.empty_repo? + = nav_link(path: 'pipelines#charts') do + = link_to charts_namespace_project_pipelines_path(@project.namespace, @project), title: 'Charts', class: 'shortcuts-pipelines-charts' do + %span + Charts + + - if project_nav_tab? :wiki + = nav_link(controller: :wikis) do + = link_to get_project_wiki_path(@project), title: 'Wiki', class: 'shortcuts-wiki' do + %span + Wiki + + - if project_nav_tab? :snippets + = nav_link(controller: :snippets) do + = link_to namespace_project_snippets_path(@project.namespace, @project), title: 'Snippets', class: 'shortcuts-snippets' do + %span + Snippets + + - if project_nav_tab? :settings + = nav_link(path: %w[projects#edit members#show integrations#show services#edit repository#show ci_cd#show pages#show]) do + = link_to edit_project_path(@project), title: 'Settings', class: 'shortcuts-tree' do + %span + Settings + + %ul.sidebar-sub-level-items + - can_edit = can?(current_user, :admin_project, @project) + - if can_edit + = nav_link(controller: :projects) do + = link_to edit_project_path(@project), title: 'General' do + %span + General + = nav_link(controller: :members) do + = link_to project_settings_members_path(@project), title: 'Members' do + %span + Members + - if can_edit + = nav_link(controller: [:integrations, :services, :hooks, :hook_logs]) do + = link_to project_settings_integrations_path(@project), title: 'Integrations' do + %span + Integrations + = nav_link(controller: :repository) do + = link_to namespace_project_settings_repository_path(@project.namespace, @project), title: 'Repository' do + %span + Repository + - if @project.feature_available?(:builds, current_user) + = nav_link(controller: :ci_cd) do + = link_to namespace_project_settings_ci_cd_path(@project.namespace, @project), title: 'Pipelines' do + %span + Pipelines + - if Gitlab.config.pages.enabled + = nav_link(controller: :pages) do + = link_to namespace_project_pages_path(@project.namespace, @project), title: 'Pages' do + %span + Pages + + - else + = nav_link(path: %w[members#show]) do + = link_to namespace_project_settings_members_path(@project.namespace, @project), title: 'Settings', class: 'shortcuts-tree' do + %span + Settings + + -# Shortcut to Project > Activity + %li.hidden + = link_to activity_project_path(@project), title: 'Activity', class: 'shortcuts-project-activity' do + %span + Activity + + -# Shortcut to Repository > Graph (formerly, Network) + - if project_nav_tab? :network + %li.hidden + = link_to namespace_project_network_path(@project.namespace, @project, current_ref), title: 'Network', class: 'shortcuts-network' do + Graph + + -# Shortcut to Repository > Charts (formerly, top-nav item "Graphs") + - unless @project.empty_repo? + %li.hidden + = link_to charts_namespace_project_graph_path(@project.namespace, @project, current_ref), title: 'Charts', class: 'shortcuts-repository-charts' do + Charts + + -# Shortcut to Issues > New Issue + %li.hidden + = link_to new_namespace_project_issue_path(@project.namespace, @project), class: 'shortcuts-new-issue' do + Create a new issue + + -# Shortcut to Pipelines > Jobs + - if project_nav_tab? :builds + %li.hidden + = link_to project_jobs_path(@project), title: 'Jobs', class: 'shortcuts-builds' do + Jobs + + -# Shortcut to commits page + - if project_nav_tab? :commits + %li.hidden + = link_to project_commits_path(@project), title: 'Commits', class: 'shortcuts-commits' do + Commits + + -# Shortcut to issue boards + %li.hidden + = link_to 'Issue Boards', namespace_project_boards_path(@project.namespace, @project), title: 'Issue Boards', class: 'shortcuts-issue-boards' diff --git a/app/views/layouts/profile.html.haml b/app/views/layouts/profile.html.haml index 0ee8a57dbd4..c365839e605 100644 --- a/app/views/layouts/profile.html.haml +++ b/app/views/layouts/profile.html.haml @@ -1,6 +1,10 @@ - page_title "User Settings" - header_title "User Settings", profile_path unless header_title - sidebar "dashboard" -- nav "profile" +- if show_new_nav? + - nav "new_profile_sidebar" + - @new_sidebar = true +- else + - nav "profile" = render template: "layouts/application" diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index 3f5b0c54e50..4458c3c2c23 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -1,7 +1,11 @@ - page_title @project.name_with_namespace - page_description @project.description unless page_description - header_title project_title(@project) unless header_title -- nav "project" +- if show_new_nav? + - nav "new_project_sidebar" + - @new_sidebar = true +- else + - nav "project" - content_for :project_javascripts do - project = @target_project || @project diff --git a/app/views/notify/pipeline_failed_email.html.haml b/app/views/notify/pipeline_failed_email.html.haml index a83faa839df..b7a60938132 100644 --- a/app/views/notify/pipeline_failed_email.html.haml +++ b/app/views/notify/pipeline_failed_email.html.haml @@ -60,7 +60,7 @@ %tbody %tr %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;" } - %img.avatar{ height: "24", src: avatar_icon(commit.author || commit.author_email, 24), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ + %img.avatar{ height: "24", src: avatar_icon(commit.author || commit.author_email, 24, only_path: false), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;" } - if commit.author %a.muted{ href: user_url(commit.author), style: "color:#333333;text-decoration:none;" } @@ -76,7 +76,7 @@ %tbody %tr %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;" } - %img.avatar{ height: "24", src: avatar_icon(commit.committer || commit.committer_email, 24), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ + %img.avatar{ height: "24", src: avatar_icon(commit.committer || commit.committer_email, 24, only_path: false), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;" } - if commit.committer %a.muted{ href: user_url(commit.committer), style: "color:#333333;text-decoration:none;" } @@ -100,7 +100,7 @@ triggered by - if @pipeline.user %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;padding-left:5px", width: "24" } - %img.avatar{ height: "24", src: avatar_icon(@pipeline.user, 24), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ + %img.avatar{ height: "24", src: avatar_icon(@pipeline.user, 24, only_path: false), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-weight:500;line-height:1.4;vertical-align:baseline;" } %a.muted{ href: user_url(@pipeline.user), style: "color:#333333;text-decoration:none;" } = @pipeline.user.name diff --git a/app/views/notify/pipeline_success_email.html.haml b/app/views/notify/pipeline_success_email.html.haml index 9c2e2a599b2..3f16885b8e3 100644 --- a/app/views/notify/pipeline_success_email.html.haml +++ b/app/views/notify/pipeline_success_email.html.haml @@ -60,7 +60,7 @@ %tbody %tr %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;" } - %img.avatar{ height: "24", src: avatar_icon(commit.author || commit.author_email, 24), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ + %img.avatar{ height: "24", src: avatar_icon(commit.author || commit.author_email, 24, only_path: false), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;" } - if commit.author %a.muted{ href: user_url(commit.author), style: "color:#333333;text-decoration:none;" } @@ -76,7 +76,7 @@ %tbody %tr %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;" } - %img.avatar{ height: "24", src: avatar_icon(commit.committer || commit.committer_email, 24), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ + %img.avatar{ height: "24", src: avatar_icon(commit.committer || commit.committer_email, 24, only_path: false), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;" } - if commit.committer %a.muted{ href: user_url(commit.committer), style: "color:#333333;text-decoration:none;" } @@ -100,7 +100,7 @@ triggered by - if @pipeline.user %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;padding-left:5px", width: "24" } - %img.avatar{ height: "24", src: avatar_icon(@pipeline.user, 24), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ + %img.avatar{ height: "24", src: avatar_icon(@pipeline.user, 24, only_path: false), style: "display:block;border-radius:12px;margin:-2px 0;", width: "24", alt: "Avatar" }/ %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-weight:500;line-height:1.4;vertical-align:baseline;" } %a.muted{ href: user_url(@pipeline.user), style: "color:#333333;text-decoration:none;" } = @pipeline.user.name diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml index 0ff19b3eab1..0b5995415e9 100644 --- a/app/views/profiles/preferences/show.html.haml +++ b/app/views/profiles/preferences/show.html.haml @@ -15,6 +15,25 @@ .preview= image_tag "#{scheme.css_class}-scheme-preview.png" = f.radio_button :color_scheme_id, scheme.id = scheme.name + - if can_toggle_new_nav? + .col-sm-12 + %hr + .col-lg-3.profile-settings-sidebar#new-navigation + %h4.prepend-top-0 + New Navigation + %p + This setting allows you to turn on or off the new upcoming navigation concept. + = succeed '.' do + = link_to 'Learn more', '', target: '_blank' + .col-lg-9.syntax-theme + = label_tag do + .preview= image_tag "old_nav.png" + %input.js-experiment-feature-toggle{ type: "radio", value: "false", name: "new_nav", checked: !show_new_nav? } + Old + = label_tag do + .preview= image_tag "new_nav.png" + %input.js-experiment-feature-toggle{ type: "radio", value: "true", name: "new_nav", checked: show_new_nav? } + New .col-sm-12 %hr .col-lg-3.profile-settings-sidebar diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 15672289c65..819c98946ab 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -1,6 +1,6 @@ = render 'profiles/head' -= form_for @user, url: profile_path, method: :put, html: { multipart: true, class: "edit-user prepend-top-default" }, authenticity_token: true do |f| += bootstrap_form_for @user, url: profile_path, method: :put, html: { multipart: true, class: 'edit-user prepend-top-default' }, authenticity_token: true do |f| = form_errors(@user) .row @@ -11,11 +11,11 @@ - if @user.avatar? You can change your avatar here - if gravatar_enabled? - or remove the current avatar to revert to #{link_to Gitlab.config.gravatar.host, "http://" + Gitlab.config.gravatar.host} + or remove the current avatar to revert to #{link_to Gitlab.config.gravatar.host, 'http://' + Gitlab.config.gravatar.host} - else You can upload an avatar here - if gravatar_enabled? - or change it at #{link_to Gitlab.config.gravatar.host, "http://" + Gitlab.config.gravatar.host} + or change it at #{link_to Gitlab.config.gravatar.host, 'http://' + Gitlab.config.gravatar.host} .col-lg-9 .clearfix.avatar-image.append-bottom-default = link_to avatar_icon(@user, 400), target: '_blank', rel: 'noopener noreferrer' do @@ -26,12 +26,12 @@ %a.btn.js-choose-user-avatar-button Browse file... %span.avatar-file-name.prepend-left-default.js-avatar-filename No file chosen - = f.file_field :avatar, class: "js-user-avatar-input hidden", accept: "image/*" + = f.file_field_without_bootstrap :avatar, class: 'js-user-avatar-input hidden', accept: 'image/*' .help-block The maximum file size allowed is 200KB. - if @user.avatar? %hr - = link_to 'Remove avatar', profile_avatar_path, data: { confirm: "Avatar will be removed. Are you sure?" }, method: :delete, class: "btn btn-gray" + = link_to 'Remove avatar', profile_avatar_path, data: { confirm: 'Avatar will be removed. Are you sure?' }, method: :delete, class: 'btn btn-gray' %hr .row .col-lg-3.profile-settings-sidebar @@ -43,91 +43,50 @@ Some options are unavailable for LDAP accounts .col-lg-9 .row - .form-group.col-md-9 - = f.label :name, class: "label-light" - = f.text_field :name, class: "form-control", required: true - %span.help-block Enter your name, so people you know can recognize you. + = f.text_field :name, required: true, wrapper: { class: 'col-md-9' }, + help: 'Enter your name, so people you know can recognize you.' + = f.text_field :id, readonly: true, label: 'User ID', wrapper: { class: 'col-md-3' } - .form-group.col-md-3 - = f.label :id, class: 'label-light' do - User ID - = f.text_field :id, class: 'form-control', readonly: true - - - .form-group - = f.label :email, class: "label-light" - - if @user.external_email? - = f.text_field :email, class: "form-control", required: true, readonly: true - %span.help-block.light - Your email address was automatically set based on your #{email_provider_label} account. - - else - - if @user.temp_oauth_email? - = f.text_field :email, class: "form-control", required: true, value: nil - - else - = f.text_field :email, class: "form-control", required: true - - if @user.unconfirmed_email.present? - %span.help-block - Please click the link in the confirmation email before continuing. It was sent to - = succeed "." do - %strong= @user.unconfirmed_email - %p - = link_to "Resend confirmation e-mail", user_confirmation_path(user: { email: @user.unconfirmed_email }), method: :post - - - else - %span.help-block We also use email for avatar detection if no avatar is uploaded. - .form-group - = f.label :public_email, class: "label-light" - = f.select :public_email, options_for_select(@user.all_emails, selected: @user.public_email), { include_blank: 'Do not show on profile' }, class: "select2" - %span.help-block This email will be displayed on your public profile. - .form-group - = f.label :preferred_language, class: "label-light" - = f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES.map { |value, label| [label, value] }, - {}, class: "select2" - %span.help-block This feature is experimental and translations are not complete yet. - .form-group - = f.label :skype, class: "label-light" - = f.text_field :skype, class: "form-control" - .form-group - = f.label :linkedin, class: "label-light" - = f.text_field :linkedin, class: "form-control" - .form-group - = f.label :twitter, class: "label-light" - = f.text_field :twitter, class: "form-control" - .form-group - = f.label :website_url, 'Website', class: "label-light" - = f.text_field :website_url, class: "form-control" - .form-group - = f.label :location, 'Location', class: "label-light" - = f.text_field :location, class: "form-control" - .form-group - = f.label :organization, 'Organization', class: "label-light" - = f.text_field :organization, class: "form-control" - .form-group - = f.label :bio, class: "label-light" - = f.text_area :bio, rows: 4, class: "form-control", maxlength: 250 - %span.help-block Tell us about yourself in fewer than 250 characters. + - if @user.external_email? + = f.text_field :email, required: true, readonly: true, help: "Your email address was automatically set based on your #{email_provider_label} account." + - else + = f.text_field :email, required: true, value: (@user.email unless @user.temp_oauth_email?), + help: user_email_help_text(@user) + = f.select :public_email, options_for_select(@user.all_emails, selected: @user.public_email), + { help: 'This email will be displayed on your public profile.', include_blank: 'Do not show on profile' }, + control_class: 'select2' + = f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES.map { |value, label| [label, value] }, + { help: 'This feature is experimental and translations are not complete yet.' }, + control_class: 'select2' + = f.text_field :skype + = f.text_field :linkedin + = f.text_field :twitter + = f.text_field :website_url, label: 'Website' + = f.text_field :location + = f.text_field :organization + = f.text_area :bio, rows: 4, maxlength: 250, help: 'Tell us about yourself in fewer than 250 characters.' .prepend-top-default.append-bottom-default - = f.submit 'Update profile settings', class: "btn btn-success" - = link_to "Cancel", user_path(current_user), class: "btn btn-cancel" + = f.submit 'Update profile settings', class: 'btn btn-success' + = link_to 'Cancel', user_path(current_user), class: 'btn btn-cancel' .modal.modal-profile-crop .modal-dialog .modal-content .modal-header - %button.close{ :type => "button", :'data-dismiss' => "modal" } + %button.close{ type: 'button', 'data-dismiss': 'modal' } %span × %h4.modal-title Position and size your new avatar .modal-body .profile-crop-image-container - %img.modal-profile-crop-image{ alt: "Avatar cropper" } + %img.modal-profile-crop-image{ alt: 'Avatar cropper' } .crop-controls .btn-group - %button.btn.btn-primary{ data: { method: "zoom", option: "0.1" } } + %button.btn.btn-primary{ data: { method: 'zoom', option: '0.1' } } %span.fa.fa-search-plus - %button.btn.btn-primary{ data: { method: "zoom", option: "-0.1" } } + %button.btn.btn-primary{ data: { method: 'zoom', option: '-0.1' } } %span.fa.fa-search-minus .modal-footer - %button.btn.btn-primary.js-upload-user-avatar{ :type => "button" } + %button.btn.btn-primary.js-upload-user-avatar{ type: 'button' } Set new profile picture diff --git a/app/views/projects/_find_file_link.html.haml b/app/views/projects/_find_file_link.html.haml index c748ccf65e6..cb4d2bbacf5 100644 --- a/app/views/projects/_find_file_link.html.haml +++ b/app/views/projects/_find_file_link.html.haml @@ -1,3 +1,3 @@ -= link_to namespace_project_find_file_path(@project.namespace, @project, @ref), class: 'btn btn-grouped shortcuts-find-file', rel: 'nofollow' do += link_to namespace_project_find_file_path(@project.namespace, @project, @ref), class: 'btn shortcuts-find-file', rel: 'nofollow' do = icon('search') %span= _('Find file') diff --git a/app/views/projects/_md_preview.html.haml b/app/views/projects/_md_preview.html.haml index 07445434cf3..d0698285f84 100644 --- a/app/views/projects/_md_preview.html.haml +++ b/app/views/projects/_md_preview.html.haml @@ -9,6 +9,12 @@ %li %a.js-md-preview-button{ href: "#md-preview-holder", tabindex: -1 } Preview + + - if defined?(@issue) && @issue.confidential? + %li.confidential-issue-warning + = icon('warning') + %span This is a confidential issue. Your comment will not be visible to the public. + %li.pull-right .toolbar-group = markdown_toolbar_button({ icon: "bold fw", data: { "md-tag" => "**" }, title: "Add bold text" }) diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml index ce937ee1842..3627f72f5e1 100644 --- a/app/views/projects/blame/show.html.haml +++ b/app/views/projects/blame/show.html.haml @@ -1,6 +1,6 @@ - @no_container = true - project_duration = age_map_duration(@blame_groups, @project) -- page_title "Annotate", @blob.path, @ref +- page_title "Blame", @blob.path, @ref = render "projects/commits/head" %div{ class: container_class } diff --git a/app/views/projects/blob/_breadcrumb.html.haml b/app/views/projects/blob/_breadcrumb.html.haml index 0ad9f258e48..2c944b516a4 100644 --- a/app/views/projects/blob/_breadcrumb.html.haml +++ b/app/views/projects/blob/_breadcrumb.html.haml @@ -1,16 +1,33 @@ - blame = local_assigns.fetch(:blame, false) .nav-block + .tree-ref-container + .tree-ref-holder + = render 'shared/ref_switcher', destination: 'blob', path: @path + + %ul.breadcrumb.repo-breadcrumb + %li + = link_to namespace_project_tree_path(@project.namespace, @project, @ref) do + = @project.path + - path_breadcrumbs do |title, path| + - title = truncate(title, length: 40) + %li + - if path == @path + = link_to namespace_project_blob_path(@project.namespace, @project, tree_join(@ref, path)) do + %strong= title + - else + = link_to title, namespace_project_tree_path(@project.namespace, @project, tree_join(@ref, path)) + .tree-controls = render 'projects/find_file_link' - .btn-group.prepend-left-10{ role: "group" }< + .btn-group{ role: "group" }< -# only show normal/blame view links for text files - if blob.readable_text? - if blame = link_to 'Normal view', namespace_project_blob_path(@project.namespace, @project, @id), class: 'btn' - else - = link_to 'Annotate', namespace_project_blame_path(@project.namespace, @project, @id), + = link_to 'Blame', namespace_project_blame_path(@project.namespace, @project, @id), class: 'btn js-blob-blame-link' unless blob.empty? = link_to 'History', namespace_project_commits_path(@project.namespace, @project, @id), @@ -18,19 +35,3 @@ = link_to 'Permalink', namespace_project_blob_path(@project.namespace, @project, tree_join(@commit.sha, @path)), class: 'btn js-data-file-blob-permalink-url' - - .tree-ref-holder - = render 'shared/ref_switcher', destination: 'blob', path: @path - - %ul.breadcrumb.repo-breadcrumb - %li - = link_to namespace_project_tree_path(@project.namespace, @project, @ref) do - = @project.path - - path_breadcrumbs do |title, path| - - title = truncate(title, length: 40) - %li - - if path == @path - = link_to namespace_project_blob_path(@project.namespace, @project, tree_join(@ref, path)) do - %strong= title - - else - = link_to title, namespace_project_tree_path(@project.namespace, @project, tree_join(@ref, path)) diff --git a/app/views/projects/blob/_upload.html.haml b/app/views/projects/blob/_upload.html.haml index 24314e03b46..32dbc1b3417 100644 --- a/app/views/projects/blob/_upload.html.haml +++ b/app/views/projects/blob/_upload.html.haml @@ -9,7 +9,7 @@ .dropzone .dropzone-previews.blob-upload-dropzone-previews %p.dz-message.light - - upload_link = link_to n_('UploadLink|click to upload'), '#', class: "markdown-selector" + - upload_link = link_to s_('UploadLink|click to upload'), '#', class: "markdown-selector" - dropzone_text = _('Attach a file by drag & drop or %{upload_link}') % { upload_link: upload_link } #{ dropzone_text.html_safe } diff --git a/app/views/projects/commit/_change.html.haml b/app/views/projects/commit/_change.html.haml index 208d4908721..2267f123e38 100644 --- a/app/views/projects/commit/_change.html.haml +++ b/app/views/projects/commit/_change.html.haml @@ -22,7 +22,7 @@ = label_tag 'start_branch', branch_label, class: 'control-label' .col-sm-10 = hidden_field_tag :start_branch, @project.default_branch, id: 'start_branch' - = dropdown_tag(@project.default_branch, options: { title: n_("BranchSwitcherTitle|Switch branch"), filter: true, placeholder: n_("BranchSwitcherPlaceholder|Search branches"), toggle_class: 'js-project-refs-dropdown dynamic', dropdown_class: 'dropdown-menu-selectable', data: { field_name: "start_branch", selected: @project.default_branch, start_branch: @project.default_branch, refs_url: namespace_project_branches_path(@project.namespace, @project), submit_form_on_click: false } }) + = dropdown_tag(@project.default_branch, options: { title: s_("BranchSwitcherTitle|Switch branch"), filter: true, placeholder: s_("BranchSwitcherPlaceholder|Search branches"), toggle_class: 'js-project-refs-dropdown dynamic', dropdown_class: 'dropdown-menu-selectable', data: { field_name: "start_branch", selected: @project.default_branch, start_branch: @project.default_branch, refs_url: namespace_project_branches_path(@project.namespace, @project), submit_form_on_click: false } }) - if can?(current_user, :push_code, @project) = render 'shared/new_merge_request_checkbox' diff --git a/app/views/projects/commit/show.html.haml b/app/views/projects/commit/show.html.haml index 3a1be3fa4b6..b778e8af121 100644 --- a/app/views/projects/commit/show.html.haml +++ b/app/views/projects/commit/show.html.haml @@ -1,6 +1,6 @@ - @no_container = true - container_class = !fluid_layout && diff_view == :inline ? 'container-limited' : '' -- limited_container_width = fluid_layout || diff_view == :inline ? '' : 'limit-container-width' +- limited_container_width = fluid_layout ? '' : 'limit-container-width' - page_title "#{@commit.title} (#{@commit.short_id})", "Commits" - page_description @commit.description = render "projects/commits/head" @@ -13,7 +13,8 @@ .block-connector = render "projects/diffs/diffs", diffs: @diffs, environment: @environment - = render "shared/notes/notes_with_form", :autocomplete => true - - if can_collaborate_with_project? - - %w(revert cherry-pick).each do |type| - = render "projects/commit/change", type: type, commit: @commit, title: @commit.title + .limited-width-notes + = render "shared/notes/notes_with_form", :autocomplete => true + - if can_collaborate_with_project? + - %w(revert cherry-pick).each do |type| + = render "projects/commit/change", type: type, commit: @commit, title: @commit.title diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index 11de6915961..8a4ef5a45b3 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -5,7 +5,7 @@ - notes = commit.notes - note_count = notes.user.count -- cache_key = [project.path_with_namespace, commit.id, current_application_settings, note_count] +- cache_key = [project.path_with_namespace, commit.id, current_application_settings, note_count, @path.presence, current_controller?(:commits)] - cache_key.push(commit.status(ref)) if commit.status(ref) = cache(cache_key, expires_in: 1.day) do diff --git a/app/views/projects/commits/_commits.html.haml b/app/views/projects/commits/_commits.html.haml index d3380c917e4..93fd0789c11 100644 --- a/app/views/projects/commits/_commits.html.haml +++ b/app/views/projects/commits/_commits.html.haml @@ -3,8 +3,8 @@ - commits.chunk { |c| c.committed_date.in_time_zone.to_date }.each do |day, commits| %li.commit-header.js-commit-header{ data: { day: day } } - %span.day= day.strftime('%d %b, %Y') - %span.commits-count= pluralize(commits.count, 'commit') + %span.day= l(day, format: '%d %b, %Y') + %span.commits-count= n_("%d commit", "%d commits", commits.count) % commits.count %li.commits-row{ data: { day: day } } %ul.content-list.commit-list @@ -12,4 +12,4 @@ - if hidden > 0 %li.alert.alert-warning - #{number_with_delimiter(hidden)} additional commits have been omitted to prevent performance issues. + = n_('%d additional commit has been omitted to prevent performance issues.', '%d additional commits have been omitted to prevent performance issues.', hidden) % number_with_delimiter(hidden) diff --git a/app/views/projects/commits/show.html.haml b/app/views/projects/commits/show.html.haml index c1c2fb3d299..fabd825aec8 100644 --- a/app/views/projects/commits/show.html.haml +++ b/app/views/projects/commits/show.html.haml @@ -1,6 +1,6 @@ - @no_container = true -- page_title "Commits", @ref +- page_title _("Commits"), @ref = content_for :meta_tags do = auto_discovery_link_tag(:atom, namespace_project_commits_url(@project.namespace, @project, @ref, rss_url_options), title: "#{@project.name}:#{@ref} commits") @@ -18,16 +18,16 @@ .block-controls.hidden-xs.hidden-sm - if @merge_request.present? .control - = link_to "View open merge request", namespace_project_merge_request_path(@project.namespace, @project, @merge_request), class: 'btn' + = link_to _("View open merge request"), namespace_project_merge_request_path(@project.namespace, @project, @merge_request), class: 'btn' - elsif create_mr_button?(@repository.root_ref, @ref) .control - = link_to "Create merge request", create_mr_path(@repository.root_ref, @ref), class: 'btn btn-success' + = link_to _("Create merge request"), create_mr_path(@repository.root_ref, @ref), class: 'btn btn-success' .control = form_tag(namespace_project_commits_path(@project.namespace, @project, @id), method: :get, class: 'commits-search-form') do - = search_field_tag :search, params[:search], { placeholder: 'Filter by commit message', id: 'commits-search', class: 'form-control search-text-input input-short', spellcheck: false } + = search_field_tag :search, params[:search], { placeholder: _('Filter by commit message'), id: 'commits-search', class: 'form-control search-text-input input-short', spellcheck: false } .control - = link_to namespace_project_commits_path(@project.namespace, @project, @ref, rss_url_options), title: "Commits feed", class: 'btn' do + = link_to namespace_project_commits_path(@project.namespace, @project, @ref, rss_url_options), title: _("Commits feed"), class: 'btn' do = icon("rss") %div{ id: dom_id(@project) } diff --git a/app/views/projects/deploy_keys/_index.html.haml b/app/views/projects/deploy_keys/_index.html.haml index 6e038ffd9c0..cb98ce04430 100644 --- a/app/views/projects/deploy_keys/_index.html.haml +++ b/app/views/projects/deploy_keys/_index.html.haml @@ -4,7 +4,7 @@ %h4 Deploy Keys %button.btn.js-settings-toggle - = expanded ? 'Close' : 'Expand' + = expanded ? 'Collapse' : 'Expand' %p Deploy keys allow read-only or read-write (if enabled) access to your repository. Deploy keys can be used for CI, staging or production servers. You can create a deploy key or add an existing one. .settings-content.no-animate{ class: ('expanded' if expanded) } diff --git a/app/views/projects/deployments/_deployment.html.haml b/app/views/projects/deployments/_deployment.html.haml index 9b2ec9ae41c..520696b01c6 100644 --- a/app/views/projects/deployments/_deployment.html.haml +++ b/app/views/projects/deployments/_deployment.html.haml @@ -3,24 +3,28 @@ .table-mobile-header{ role: 'rowheader' } ID %strong.table-mobile-content ##{deployment.iid} - .table-section.section-40{ role: 'gridcell' } + .table-section.section-30{ role: 'gridcell' } .table-mobile-header{ role: 'rowheader' } Commit = render 'projects/deployments/commit', deployment: deployment - .table-section.section-15.build-column{ role: 'gridcell' } + .table-section.section-25.build-column{ role: 'gridcell' } .table-mobile-header{ role: 'rowheader' } Job - if deployment.deployable - = link_to [@project.namespace.becomes(Namespace), @project, deployment.deployable], class: 'build-link table-mobile-content' do - #{deployment.deployable.name} (##{deployment.deployable.id}) - - if deployment.user - by - = user_avatar(user: deployment.user, size: 20) + .table-mobile-content + .flex-truncate-parent + .flex-truncate-child + = link_to [@project.namespace.becomes(Namespace), @project, deployment.deployable], class: 'build-link' do + #{deployment.deployable.name} (##{deployment.deployable.id}) + - if deployment.user + %div + by + = user_avatar(user: deployment.user, size: 20) .table-section.section-15{ role: 'gridcell' } .table-mobile-header{ role: 'rowheader' } Created %span.table-mobile-content= time_ago_with_tooltip(deployment.created_at) .table-section.section-20.table-button-footer{ role: 'gridcell' } - .btn-group.table-action-button + .btn-group.table-action-buttons = render 'projects/deployments/actions', deployment: deployment = render 'projects/deployments/rollback', deployment: deployment diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index 296e37e20e6..78057facde7 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -1,10 +1,12 @@ +- @content_class = "limit-container-width" unless fluid_layout + = render "projects/settings/head" .project-edit-container .row.prepend-top-default - .col-lg-3.profile-settings-sidebar + .col-lg-4.profile-settings-sidebar %h4.prepend-top-0 Project settings - .col-lg-9 + .col-lg-8 .project-edit-errors = form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "edit-project" }, authenticity_token: true do |f| %fieldset @@ -39,66 +41,66 @@ Sharing & Permissions .form_group.prepend-top-20.sharing-and-permissions .row.js-visibility-select - .col-md-9 + .col-md-8 .label-light = label_tag :project_visibility, 'Project Visibility', class: 'label-light', for: :project_visibility_level = link_to icon('question-circle'), help_page_path("public_access/public_access") %span.help-block - .col-md-3.visibility-select-container + .col-md-4.visibility-select-container = render('projects/visibility_select', model_method: :visibility_level, form: f, selected_level: @project.visibility_level) = f.fields_for :project_feature do |feature_fields| %fieldset.features .row - .col-md-9.project-feature + .col-md-8.project-feature = feature_fields.label :repository_access_level, "Repository", class: 'label-light' %span.help-block View and edit files in this project - .col-md-3.js-repo-access-level + .col-md-4.js-repo-access-level = project_feature_access_select(:repository_access_level) .row - .col-md-9.project-feature.nested + .col-md-8.project-feature.nested = feature_fields.label :merge_requests_access_level, "Merge requests", class: 'label-light' %span.help-block Submit changes to be merged upstream - .col-md-3 + .col-md-4 = project_feature_access_select(:merge_requests_access_level) .row - .col-md-9.project-feature.nested + .col-md-8.project-feature.nested = feature_fields.label :builds_access_level, "Pipelines", class: 'label-light' %span.help-block Build, test, and deploy your changes - .col-md-3 + .col-md-4 = project_feature_access_select(:builds_access_level) .row - .col-md-9.project-feature + .col-md-8.project-feature = feature_fields.label :snippets_access_level, "Snippets", class: 'label-light' %span.help-block Share code pastes with others out of Git repository - .col-md-3 + .col-md-4 = project_feature_access_select(:snippets_access_level) .row - .col-md-9.project-feature + .col-md-8.project-feature = feature_fields.label :issues_access_level, "Issues", class: 'label-light' %span.help-block Lightweight issue tracking system for this project - .col-md-3 + .col-md-4 = project_feature_access_select(:issues_access_level) .row - .col-md-9.project-feature + .col-md-8.project-feature = feature_fields.label :wiki_access_level, "Wiki", class: 'label-light' %span.help-block Pages for project documentation - .col-md-3 + .col-md-4 = project_feature_access_select(:wiki_access_level) .form-group = render 'shared/allow_request_access', form: f - if Gitlab.config.lfs.enabled && current_user.admin? .row.js-lfs-enabled - .col-md-9 + .col-md-8 = f.label :lfs_enabled, 'LFS', class: 'label-light' %span.help-block Git Large File Storage = link_to icon('question-circle'), help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs') - .col-md-3 + .col-md-4 .select-wrapper = f.select :lfs_enabled, [%w(Enabled true), %w(Disabled false)], {}, selected: @project.lfs_enabled?, class: 'pull-right form-control project-repo-select select-control', data: { field: 'lfs_enabled' } = icon('chevron-down') @@ -138,19 +140,19 @@ .row.prepend-top-default %hr .row.prepend-top-default - .col-lg-3 + .col-lg-4 %h4.prepend-top-0 Housekeeping %p.append-bottom-0 %p Runs a number of housekeeping tasks within the current repository, such as compressing file revisions and removing unreachable objects. - .col-lg-9 + .col-lg-8 = link_to 'Housekeeping', housekeeping_namespace_project_path(@project.namespace, @project), method: :post, class: "btn btn-default" %hr .row.prepend-top-default - .col-lg-3 + .col-lg-4 %h4.prepend-top-0 Export project %p.append-bottom-0 @@ -159,7 +161,7 @@ %p Once the exported file is ready, you will receive a notification email with a download link. - .col-lg-9 + .col-lg-8 - if @project.export_project_path = link_to 'Download export', download_export_namespace_project_path(@project.namespace, @project), @@ -190,7 +192,7 @@ - if can? current_user, :archive_project, @project %hr .row.prepend-top-default - .col-lg-3 + .col-lg-4 %h4.warning-title.prepend-top-0 - if @project.archived? Unarchive project @@ -201,7 +203,7 @@ Unarchiving the project will mark its repository as active. The project can be committed to. - else Archiving the project will mark its repository as read-only. It is hidden from the dashboard and doesn't show up in searches. - .col-lg-9 + .col-lg-8 - if @project.archived? %p %strong Once active this project shows up in the search and on the dashboard. @@ -216,10 +218,10 @@ method: :post, class: "btn btn-warning" %hr .row.prepend-top-default - .col-lg-3 + .col-lg-4 %h4.prepend-top-0.warning-title Rename repository - .col-lg-9 + .col-lg-8 = render 'projects/errors' = form_for([@project.namespace.becomes(Namespace), @project]) do |f| .form-group.project_name_holder @@ -244,12 +246,12 @@ - if can?(current_user, :change_namespace, @project) %hr .row.prepend-top-default - .col-lg-3 + .col-lg-4 %h4.prepend-top-0.danger-title Transfer project to new group %p.append-bottom-0 Please select the group you want to transfer this project to in the dropdown to the right. - .col-lg-9 + .col-lg-8 = form_for([@project.namespace.becomes(Namespace), @project], url: transfer_namespace_project_path(@project.namespace, @project), method: :put, remote: true, html: { class: 'js-project-transfer-form' } ) do |f| .form-group = label_tag :new_namespace_id, nil, class: 'label-light' do @@ -265,7 +267,7 @@ - if @project.forked? && can?(current_user, :remove_fork_project, @project) %hr .row.prepend-top-default.append-bottom-default - .col-lg-3 + .col-lg-4 %h4.prepend-top-0.danger-title Remove fork relationship %p.append-bottom-0 @@ -273,7 +275,7 @@ This will remove the fork relationship to source project = succeed "." do = link_to @project.forked_from_project.name_with_namespace, project_path(@project.forked_from_project) - .col-lg-9 + .col-lg-8 = form_for([@project.namespace.becomes(Namespace), @project], url: remove_fork_namespace_project_path(@project.namespace, @project), method: :delete, remote: true, html: { class: 'transfer-project' }) do |f| %p %strong Once removed, the fork relationship cannot be restored and you will no longer be able to send merge requests to the source. @@ -281,12 +283,12 @@ - if can?(current_user, :remove_project, @project) %hr .row.prepend-top-default.append-bottom-default - .col-lg-3 + .col-lg-4 %h4.prepend-top-0.danger-title Remove project %p.append-bottom-0 Removing the project will delete its repository and all related resources including issues, merge requests etc. - .col-lg-9 + .col-lg-8 = form_tag(namespace_project_path(@project.namespace, @project), method: :delete) do %p %strong Removed projects cannot be restored! diff --git a/app/views/projects/environments/show.html.haml b/app/views/projects/environments/show.html.haml index 23aa4c29e69..31e2bb11ce8 100644 --- a/app/views/projects/environments/show.html.haml +++ b/app/views/projects/environments/show.html.haml @@ -31,8 +31,8 @@ .ci-table.environments{ role: 'grid' } .gl-responsive-table-row.table-row-header{ role: 'row' } .table-section.section-10{ role: 'columnheader' } ID - .table-section.section-40{ role: 'columnheader' } Commit - .table-section.section-15{ role: 'columnheader' } Job + .table-section.section-30{ role: 'columnheader' } Commit + .table-section.section-25{ role: 'columnheader' } Job .table-section.section-15{ role: 'columnheader' } Created = render @deployments diff --git a/app/views/projects/hooks/_index.html.haml b/app/views/projects/hooks/_index.html.haml index 676b7c345bc..776681ea09a 100644 --- a/app/views/projects/hooks/_index.html.haml +++ b/app/views/projects/hooks/_index.html.haml @@ -1,12 +1,12 @@ .row.prepend-top-default - .col-lg-3 + .col-lg-4 %h4.prepend-top-0 = page_title %p #{link_to 'Webhooks', help_page_path('user/project/integrations/webhooks')} can be used for binding events when something is happening within the project. - .col-lg-9.append-bottom-default + .col-lg-8.append-bottom-default = form_for @hook, as: :hook, url: polymorphic_path([@project.namespace.becomes(Namespace), @project, :hooks]) do |f| = render partial: 'shared/web_hooks/form', locals: { form: f, hook: @hook } = f.submit 'Add webhook', class: 'btn btn-create' diff --git a/app/views/projects/issues/_merge_requests.html.haml b/app/views/projects/issues/_merge_requests.html.haml index d48923b422a..bda52fe461c 100644 --- a/app/views/projects/issues/_merge_requests.html.haml +++ b/app/views/projects/issues/_merge_requests.html.haml @@ -14,7 +14,7 @@ = merge_request.to_reference %span.merge-request-info %strong - = link_to_gfm merge_request.title, merge_request_path(merge_request), class: "row_title" + = link_to merge_request.title, merge_request_path(merge_request), class: "row_title" - unless @issue.project.id == merge_request.target_project.id in - project = merge_request.target_project diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index 5f92d020eef..d909b0bfbbd 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -5,13 +5,6 @@ - can_update_issue = can?(current_user, :update_issue, @issue) - can_report_spam = @issue.submittable_as_spam_by?(current_user) -- if defined?(@issue) && @issue.confidential? - .confidential-issue-warning{ data: { spy: 'affix' } } - %span.confidential-issue-text - #{confidential_icon(@issue)} This issue is confidential. - %a{ href: help_page_path('user/project/issues/confidential_issues'), target: '_blank' } - What are confidential issues? - .clearfix.detail-page-header .issuable-header .issuable-status-box.status-box.status-box-closed{ class: issue_button_visibility(@issue, false) } @@ -26,6 +19,7 @@ = icon('angle-double-left') .issuable-meta + = confidential_icon(@issue) = issuable_meta(@issue, @project, "Issue") .issuable-actions diff --git a/app/views/projects/notes/_more_actions_dropdown.html.haml b/app/views/projects/notes/_more_actions_dropdown.html.haml index e0d45054854..75a4687e1e3 100644 --- a/app/views/projects/notes/_more_actions_dropdown.html.haml +++ b/app/views/projects/notes/_more_actions_dropdown.html.haml @@ -1,14 +1,19 @@ -.dropdown.more-actions - = button_tag title: 'More actions', class: 'note-action-button more-actions-toggle has-tooltip btn btn-transparent', data: { toggle: 'dropdown', container: 'body' } do - = icon('ellipsis-v', class: 'icon') - %ul.dropdown-menu.more-actions-dropdown.dropdown-open-left - %li - = button_tag 'Edit comment', class: 'js-note-edit btn btn-transparent' - %li.divider - %li - = link_to new_abuse_report_path(user_id: note.author.id, ref_url: noteable_note_url(note)) do - Report as abuse - - if note_editable - %li - = link_to note_url(note), method: :delete, data: { confirm: 'Are you sure you want to delete this comment?' }, remote: true, class: 'js-note-delete' do - %span.text-danger Delete comment +- is_current_user = current_user == note.author + +- if note_editable || !is_current_user + .dropdown.more-actions + = button_tag title: 'More actions', class: 'note-action-button more-actions-toggle has-tooltip btn btn-transparent', data: { toggle: 'dropdown', container: 'body' } do + = icon('ellipsis-v', class: 'icon') + %ul.dropdown-menu.more-actions-dropdown.dropdown-open-left + - if note_editable + %li + = button_tag 'Edit comment', class: 'js-note-edit btn btn-transparent' + %li.divider + - unless is_current_user + %li + = link_to new_abuse_report_path(user_id: note.author.id, ref_url: noteable_note_url(note)) do + Report as abuse + - if note_editable + %li + = link_to note_url(note), method: :delete, data: { confirm: 'Are you sure you want to delete this comment?' }, remote: true, class: 'js-note-delete' do + %span.text-danger Delete comment diff --git a/app/views/projects/pipeline_schedules/_form.html.haml b/app/views/projects/pipeline_schedules/_form.html.haml index 467f8844e33..fc7fa5c1876 100644 --- a/app/views/projects/pipeline_schedules/_form.html.haml +++ b/app/views/projects/pipeline_schedules/_form.html.haml @@ -15,12 +15,12 @@ .form-group .col-md-9 = f.label :cron_timezone, _('Cron Timezone'), class: 'label-light' - = dropdown_tag(_("Select a timezone"), options: { toggle_class: 'btn js-timezone-dropdown', title: _("Select a timezone"), filter: true, placeholder: _("OfSearchInADropdown|Filter"), data: { data: timezone_data } } ) + = dropdown_tag(_("Select a timezone"), options: { toggle_class: 'btn js-timezone-dropdown', title: _("Select a timezone"), filter: true, placeholder: s_("OfSearchInADropdown|Filter"), data: { data: timezone_data } } ) = f.text_field :cron_timezone, value: @schedule.cron_timezone, id: 'schedule_cron_timezone', class: 'hidden', name: 'schedule[cron_timezone]', required: true .form-group .col-md-9 = f.label :ref, _('Target Branch'), class: 'label-light' - = dropdown_tag(_("Select target branch"), options: { toggle_class: 'btn js-target-branch-dropdown', dropdown_class: 'git-revision-dropdown', title: _("Select target branch"), filter: true, placeholder: _("OfSearchInADropdown|Filter"), data: { data: @project.repository.branch_names, default_branch: @project.default_branch } } ) + = dropdown_tag(_("Select target branch"), options: { toggle_class: 'btn js-target-branch-dropdown', dropdown_class: 'git-revision-dropdown', title: _("Select target branch"), filter: true, placeholder: s_("OfSearchInADropdown|Filter"), data: { data: @project.repository.branch_names, default_branch: @project.default_branch } } ) = f.text_field :ref, value: @schedule.ref, id: 'schedule_ref', class: 'hidden', name: 'schedule[ref]', required: true .form-group .col-md-9 diff --git a/app/views/projects/pipelines/charts.html.haml b/app/views/projects/pipelines/charts.html.haml index 4a5043aac3c..8ffddfe6154 100644 --- a/app/views/projects/pipelines/charts.html.haml +++ b/app/views/projects/pipelines/charts.html.haml @@ -15,7 +15,7 @@ .col-md-6 = render 'projects/pipelines/charts/overall' .col-md-6 - = render 'projects/pipelines/charts/build_times' + = render 'projects/pipelines/charts/pipeline_times' %hr - = render 'projects/pipelines/charts/builds' + = render 'projects/pipelines/charts/pipelines' diff --git a/app/views/projects/pipelines/charts/_overall.haml b/app/views/projects/pipelines/charts/_overall.haml index 0b7e3d22dd7..93083397d5b 100644 --- a/app/views/projects/pipelines/charts/_overall.haml +++ b/app/views/projects/pipelines/charts/_overall.haml @@ -2,18 +2,14 @@ %ul %li Total: - %strong= pluralize @project.builds.count(:all), 'job' + %strong= pluralize @counts[:total], 'pipeline' %li Successful: - %strong= pluralize @project.builds.success.count(:all), 'job' + %strong= pluralize @counts[:success], 'pipeline' %li Failed: - %strong= pluralize @project.builds.failed.count(:all), 'job' + %strong= pluralize @counts[:failed], 'pipeline' %li Success ratio: %strong - #{success_ratio(@project.builds.success, @project.builds.failed)}% - %li - Commits covered: - %strong - = @project.pipelines.count(:all) + #{success_ratio(@counts)}% diff --git a/app/views/projects/pipelines/charts/_build_times.haml b/app/views/projects/pipelines/charts/_pipeline_times.haml index bb0975a9535..aee7c5492aa 100644 --- a/app/views/projects/pipelines/charts/_build_times.haml +++ b/app/views/projects/pipelines/charts/_pipeline_times.haml @@ -6,7 +6,7 @@ :javascript var data = { - labels : #{@charts[:build_times].labels.to_json}, + labels : #{@charts[:pipeline_times].labels.to_json}, datasets : [ { fillColor : "rgba(220,220,220,0.5)", @@ -14,7 +14,7 @@ barStrokeWidth: 1, barValueSpacing: 1, barDatasetSpacing: 1, - data : #{@charts[:build_times].build_times.to_json} + data : #{@charts[:pipeline_times].pipeline_times.to_json} } ] } diff --git a/app/views/projects/pipelines/charts/_builds.haml b/app/views/projects/pipelines/charts/_pipelines.haml index b6f453b9736..b6f453b9736 100644 --- a/app/views/projects/pipelines/charts/_builds.haml +++ b/app/views/projects/pipelines/charts/_pipelines.haml diff --git a/app/views/projects/pipelines_settings/_badge.html.haml b/app/views/projects/pipelines_settings/_badge.html.haml index 43bbd735059..3de518c8b9a 100644 --- a/app/views/projects/pipelines_settings/_badge.html.haml +++ b/app/views/projects/pipelines_settings/_badge.html.haml @@ -1,8 +1,8 @@ %div{ class: badge.title.gsub(' ', '-') } - .col-lg-3.profile-settings-sidebar + .col-lg-4.profile-settings-sidebar %h4.prepend-top-0 = badge.title.capitalize - .col-lg-9 + .col-lg-8 .prepend-top-10 .panel.panel-default .panel-heading diff --git a/app/views/projects/pipelines_settings/_show.html.haml b/app/views/projects/pipelines_settings/_show.html.haml index 3b17daeb6da..580129ca809 100644 --- a/app/views/projects/pipelines_settings/_show.html.haml +++ b/app/views/projects/pipelines_settings/_show.html.haml @@ -1,8 +1,8 @@ .row.prepend-top-default - .col-lg-3.profile-settings-sidebar + .col-lg-4.profile-settings-sidebar %h4.prepend-top-0 Pipelines - .col-lg-9 + .col-lg-8 = form_for @project, url: namespace_project_pipelines_settings_path(@project.namespace.becomes(Namespace), @project) do |f| %fieldset.builds-feature - unless @repository.gitlab_ci_yml diff --git a/app/views/projects/project_members/_index.html.haml b/app/views/projects/project_members/_index.html.haml index cfae371e169..fa99610c0be 100644 --- a/app/views/projects/project_members/_index.html.haml +++ b/app/views/projects/project_members/_index.html.haml @@ -1,5 +1,5 @@ .row.prepend-top-default - .col-lg-3.settings-sidebar + .col-lg-4.settings-sidebar %h4.prepend-top-0 Project members - if can?(current_user, :admin_project_member, @project) @@ -13,7 +13,7 @@ %i Masters or %i Owners - .col-lg-9 + .col-lg-8 .light - if can?(current_user, :admin_project_member, @project) %ul.nav-links.project-member-tabs{ role: 'tablist' } diff --git a/app/views/projects/protected_branches/_index.html.haml b/app/views/projects/protected_branches/_index.html.haml index 9af67649741..5d2422bdf54 100644 --- a/app/views/projects/protected_branches/_index.html.haml +++ b/app/views/projects/protected_branches/_index.html.haml @@ -7,7 +7,7 @@ %h4 Protected Branches %button.btn.js-settings-toggle - = expanded ? 'Close' : 'Expand' + = expanded ? 'Collapse' : 'Expand' %p Keep stable branches secure and force developers to use merge requests. .settings-content.no-animate{ class: ('expanded' if expanded) } diff --git a/app/views/projects/protected_tags/_index.html.haml b/app/views/projects/protected_tags/_index.html.haml index 976e1d7e93f..8250f692a69 100644 --- a/app/views/projects/protected_tags/_index.html.haml +++ b/app/views/projects/protected_tags/_index.html.haml @@ -7,7 +7,7 @@ %h4 Protected Tags %button.btn.js-settings-toggle - = expanded ? 'Close' : 'Expand' + = expanded ? 'Collapse' : 'Expand' %p Limit access to creating and updating tags. .settings-content.no-animate{ class: ('expanded' if expanded) } diff --git a/app/views/projects/registry/repositories/_image.html.haml b/app/views/projects/registry/repositories/_image.html.haml index 8bc78f8d018..dcdc432b654 100644 --- a/app/views/projects/registry/repositories/_image.html.haml +++ b/app/views/projects/registry/repositories/_image.html.haml @@ -6,13 +6,14 @@ = clipboard_button(clipboard_text: "docker pull #{image.location}") - .controls.hidden-xs.pull-right - = link_to namespace_project_container_registry_path(@project.namespace, @project, image), - class: 'btn btn-remove has-tooltip', - title: 'Remove repository', - data: { confirm: 'Are you sure?' }, - method: :delete do - = icon('trash cred', 'aria-hidden': 'true') + - if can?(current_user, :update_container_image, @project) + .controls.hidden-xs.pull-right + = link_to namespace_project_container_registry_path(@project.namespace, @project, image), + class: 'btn btn-remove has-tooltip', + title: 'Remove repository', + data: { confirm: 'Are you sure?' }, + method: :delete do + = icon('trash cred', 'aria-hidden': 'true') .container-image-tags.js-toggle-content.hide - if image.has_tags? diff --git a/app/views/projects/services/_form.html.haml b/app/views/projects/services/_form.html.haml index 9167789a69d..6dffc026392 100644 --- a/app/views/projects/services/_form.html.haml +++ b/app/views/projects/services/_form.html.haml @@ -23,3 +23,7 @@ - disabled_title = @service.disabled_title = link_to 'Cancel', namespace_project_settings_integrations_path(@project.namespace, @project), class: 'btn btn-cancel' + +- if lookup_context.template_exists?('show', "projects/services/#{@service.to_param}", true) + %hr + = render "projects/services/#{@service.to_param}/show" diff --git a/app/views/projects/services/_index.html.haml b/app/views/projects/services/_index.html.haml index 86d5a0ec7b8..997b702da33 100644 --- a/app/views/projects/services/_index.html.haml +++ b/app/views/projects/services/_index.html.haml @@ -1,9 +1,9 @@ .row.prepend-top-default.append-bottom-default - .col-lg-3 + .col-lg-4 %h4.prepend-top-0 Project services %p Project services allow you to integrate GitLab with other applications - .col-lg-9 + .col-lg-8 %table.table %colgroup %col diff --git a/app/views/projects/services/prometheus/_show.html.haml b/app/views/projects/services/prometheus/_show.html.haml new file mode 100644 index 00000000000..c4ac384ca1a --- /dev/null +++ b/app/views/projects/services/prometheus/_show.html.haml @@ -0,0 +1,45 @@ +- content_for :page_specific_javascripts do + = webpack_bundle_tag('prometheus_metrics') + +.row.prepend-top-default.append-bottom-default.prometheus-metrics-monitoring.js-prometheus-metrics-monitoring + .col-lg-3 + %h4.prepend-top-0 + Metrics + %p + Metrics are automatically configured and monitored + based on a library of metrics from popular exporters. + = link_to 'More information', '#' + + .col-lg-9 + .panel.panel-default.js-panel-monitored-metrics{ data: { "active-metrics" => "#{namespace_project_prometheus_active_metrics_path(@project.namespace, @project, :json)}" } } + .panel-heading + %h3.panel-title + Monitored + %span.badge.js-monitored-count 0 + .panel-body + .loading-metrics.text-center.js-loading-metrics + = icon('spinner spin 3x', class: 'metrics-load-spinner') + %p Finding and configuring metrics... + .empty-metrics.text-center.hidden.js-empty-metrics + = custom_icon('icon_empty_metrics') + %p No metrics are being monitored. To start monitoring, deploy to an environment. + = link_to project_environments_path(@project), title: 'View environments', class: 'btn btn-success' do + View environments + %ul.list-unstyled.metrics-list.hidden.js-metrics-list + + .panel.panel-default.hidden.js-panel-missing-env-vars + .panel-heading + %h3.panel-title + = icon('caret-right lg fw', class: 'panel-toggle js-panel-toggle', 'aria-label' => 'Toggle panel') + Missing environment variable + %span.badge.js-env-var-count 0 + .panel-body.hidden + .flash-container + .flash-notice + .flash-text + To set up automatic monitoring, add the environment variable + %code + $CI_ENVIRONMENT_SLUG + to exporter’s queries. + = link_to 'More information', '#' + %ul.list-unstyled.metrics-list.js-missing-var-metrics-list diff --git a/app/views/projects/settings/ci_cd/show.html.haml b/app/views/projects/settings/ci_cd/show.html.haml index e8d2e91bd76..00ccc3ec41e 100644 --- a/app/views/projects/settings/ci_cd/show.html.haml +++ b/app/views/projects/settings/ci_cd/show.html.haml @@ -1,3 +1,4 @@ +- @content_class = "limit-container-width" unless fluid_layout - page_title "Pipelines" = render "projects/settings/head" diff --git a/app/views/projects/settings/integrations/show.html.haml b/app/views/projects/settings/integrations/show.html.haml index f69992566b5..1d1d0849289 100644 --- a/app/views/projects/settings/integrations/show.html.haml +++ b/app/views/projects/settings/integrations/show.html.haml @@ -1,3 +1,4 @@ +- @content_class = "limit-container-width" unless fluid_layout - page_title 'Integrations' = render "projects/settings/head" = render 'projects/hooks/index' diff --git a/app/views/projects/settings/members/show.html.haml b/app/views/projects/settings/members/show.html.haml index 343807b87cd..1e7695ac397 100644 --- a/app/views/projects/settings/members/show.html.haml +++ b/app/views/projects/settings/members/show.html.haml @@ -1,3 +1,5 @@ +- @content_class = "limit-container-width" unless fluid_layout + - page_title "Members" = render "projects/settings/head" diff --git a/app/views/projects/snippets/show.html.haml b/app/views/projects/snippets/show.html.haml index 847f3c2f348..d8e448dd2af 100644 --- a/app/views/projects/snippets/show.html.haml +++ b/app/views/projects/snippets/show.html.haml @@ -1,3 +1,4 @@ +- @content_class = "limit-container-width limited-inner-width-container" unless fluid_layout - page_title "#{@snippet.title} (#{@snippet.to_reference})", "Snippets" = render 'shared/snippets/header' @@ -9,4 +10,4 @@ .row-content-block.top-block.content-component-block = render 'award_emoji/awards_block', awardable: @snippet, inline: true - #notes= render "shared/notes/notes_with_form", :autocomplete => true + #notes.limited-width-notes= render "shared/notes/notes_with_form", :autocomplete => true diff --git a/app/views/projects/tree/_readme.html.haml b/app/views/projects/tree/_readme.html.haml index de57cd4ba00..f9147815427 100644 --- a/app/views/projects/tree/_readme.html.haml +++ b/app/views/projects/tree/_readme.html.haml @@ -1,5 +1,5 @@ - if readme.rich_viewer - %article.file-holder.readme-holder + %article.file-holder.readme-holder{ class: ("limited-width-container" unless fluid_layout) } .js-file-title.file-title = blob_icon readme.mode, readme.name = link_to namespace_project_blob_path(@project.namespace, @project, tree_join(@ref, readme.path)) do diff --git a/app/views/projects/tree/_tree_header.html.haml b/app/views/projects/tree/_tree_header.html.haml index abde2a48587..00da76349da 100644 --- a/app/views/projects/tree/_tree_header.html.haml +++ b/app/views/projects/tree/_tree_header.html.haml @@ -1,79 +1,81 @@ -.tree-controls - = render 'projects/find_file_link' - - = link_to s_('Commits|History'), namespace_project_commits_path(@project.namespace, @project, @id), class: 'btn btn-grouped' - - = render 'projects/buttons/download', project: @project, ref: @ref +.tree-ref-container + .tree-ref-holder + = render 'shared/ref_switcher', destination: 'tree', path: @path -.tree-ref-holder - = render 'shared/ref_switcher', destination: 'tree', path: @path - -%ul.breadcrumb.repo-breadcrumb - %li - = link_to namespace_project_tree_path(@project.namespace, @project, @ref) do - = @project.path - - path_breadcrumbs do |title, path| + %ul.breadcrumb.repo-breadcrumb %li - = link_to truncate(title, length: 40), namespace_project_tree_path(@project.namespace, @project, tree_join(@ref, path)) + = link_to namespace_project_tree_path(@project.namespace, @project, @ref) do + = @project.path + - path_breadcrumbs do |title, path| + %li + = link_to truncate(title, length: 40), namespace_project_tree_path(@project.namespace, @project, tree_join(@ref, path)) - - if current_user - %li - - if !on_top_of_branch? - %span.btn.add-to-tree.disabled.has-tooltip{ title: _("You can only add files when you are on a branch"), data: { container: 'body' } } - = icon('plus') - - else - %span.dropdown - %a.dropdown-toggle.btn.add-to-tree{ href: '#', "data-toggle" => "dropdown" } + - if current_user + %li + - if !on_top_of_branch? + %span.btn.add-to-tree.disabled.has-tooltip{ title: _("You can only add files when you are on a branch"), data: { container: 'body' } } = icon('plus') - %ul.dropdown-menu - - if can_edit_tree? - %li - = link_to namespace_project_new_blob_path(@project.namespace, @project, @id) do - = icon('pencil fw') - #{ _('New file') } - %li - = link_to '#modal-upload-blob', { 'data-target' => '#modal-upload-blob', 'data-toggle' => 'modal' } do - = icon('file fw') - #{ _('Upload file') } - %li - = link_to '#modal-create-new-dir', { 'data-target' => '#modal-create-new-dir', 'data-toggle' => 'modal' } do - = icon('folder fw') - #{ _('New directory') } - - elsif can?(current_user, :fork_project, @project) - %li - - continue_params = { to: namespace_project_new_blob_path(@project.namespace, @project, @id), - notice: edit_in_new_fork_notice, - notice_now: edit_in_new_fork_notice_now } - - fork_path = namespace_project_forks_path(@project.namespace, @project, namespace_key: current_user.namespace.id, - continue: continue_params) - = link_to fork_path, method: :post do - = icon('pencil fw') - #{ _('New file') } + - else + %span.dropdown + %a.dropdown-toggle.btn.add-to-tree{ href: '#', "data-toggle" => "dropdown", "data-target" => ".add-to-tree-dropdown" } + = icon('plus') + .add-to-tree-dropdown + %ul.dropdown-menu + - if can_edit_tree? + %li + = link_to namespace_project_new_blob_path(@project.namespace, @project, @id) do + = icon('pencil fw') + #{ _('New file') } + %li + = link_to '#modal-upload-blob', { 'data-target' => '#modal-upload-blob', 'data-toggle' => 'modal' } do + = icon('file fw') + #{ _('Upload file') } + %li + = link_to '#modal-create-new-dir', { 'data-target' => '#modal-create-new-dir', 'data-toggle' => 'modal' } do + = icon('folder fw') + #{ _('New directory') } + - elsif can?(current_user, :fork_project, @project) + %li + - continue_params = { to: namespace_project_new_blob_path(@project.namespace, @project, @id), + notice: edit_in_new_fork_notice, + notice_now: edit_in_new_fork_notice_now } + - fork_path = namespace_project_forks_path(@project.namespace, @project, namespace_key: current_user.namespace.id, + continue: continue_params) + = link_to fork_path, method: :post do + = icon('pencil fw') + #{ _('New file') } + %li + - continue_params = { to: request.fullpath, + notice: edit_in_new_fork_notice + " Try to upload a file again.", + notice_now: edit_in_new_fork_notice_now } + - fork_path = namespace_project_forks_path(@project.namespace, @project, namespace_key: current_user.namespace.id, + continue: continue_params) + = link_to fork_path, method: :post do + = icon('file fw') + #{ _('Upload file') } + %li + - continue_params = { to: request.fullpath, + notice: edit_in_new_fork_notice + " Try to create a new directory again.", + notice_now: edit_in_new_fork_notice_now } + - fork_path = namespace_project_forks_path(@project.namespace, @project, namespace_key: current_user.namespace.id, + continue: continue_params) + = link_to fork_path, method: :post do + = icon('folder fw') + #{ _('New directory') } + + %li.divider %li - - continue_params = { to: request.fullpath, - notice: edit_in_new_fork_notice + " Try to upload a file again.", - notice_now: edit_in_new_fork_notice_now } - - fork_path = namespace_project_forks_path(@project.namespace, @project, namespace_key: current_user.namespace.id, - continue: continue_params) - = link_to fork_path, method: :post do - = icon('file fw') - #{ _('Upload file') } + = link_to new_namespace_project_branch_path(@project.namespace, @project) do + = icon('code-fork fw') + #{ _('New branch') } %li - - continue_params = { to: request.fullpath, - notice: edit_in_new_fork_notice + " Try to create a new directory again.", - notice_now: edit_in_new_fork_notice_now } - - fork_path = namespace_project_forks_path(@project.namespace, @project, namespace_key: current_user.namespace.id, - continue: continue_params) - = link_to fork_path, method: :post do - = icon('folder fw') - #{ _('New directory') } + = link_to new_namespace_project_tag_path(@project.namespace, @project) do + = icon('tags fw') + #{ _('New tag') } + +.tree-controls + = render 'projects/find_file_link' - %li.divider - %li - = link_to new_namespace_project_branch_path(@project.namespace, @project) do - = icon('code-fork fw') - #{ _('New branch') } - %li - = link_to new_namespace_project_tag_path(@project.namespace, @project) do - = icon('tags fw') - #{ _('New tag') } + = link_to s_('Commits|History'), namespace_project_commits_path(@project.namespace, @project, @id), class: 'btn' + + = render 'projects/buttons/download', project: @project, ref: @ref diff --git a/app/views/projects/triggers/_index.html.haml b/app/views/projects/triggers/_index.html.haml index cc74e50a5e3..e9a2f803edd 100644 --- a/app/views/projects/triggers/_index.html.haml +++ b/app/views/projects/triggers/_index.html.haml @@ -1,7 +1,7 @@ .row.prepend-top-default.append-bottom-default.triggers-container - .col-lg-3 + .col-lg-4 = render "projects/triggers/content" - .col-lg-9 + .col-lg-8 .panel.panel-default .panel-heading %h4.panel-title diff --git a/app/views/projects/variables/_index.html.haml b/app/views/projects/variables/_index.html.haml index 1b852a9c5b3..5e6786f6698 100644 --- a/app/views/projects/variables/_index.html.haml +++ b/app/views/projects/variables/_index.html.haml @@ -1,7 +1,7 @@ .row.prepend-top-default.append-bottom-default - .col-lg-3 + .col-lg-4 = render "projects/variables/content" - .col-lg-9 + .col-lg-8 %h5.prepend-top-0 Add a variable = render "projects/variables/form", btn_text: "Add new variable" diff --git a/app/views/shared/_label.html.haml b/app/views/shared/_label.html.haml index c185e9b73ee..de0281e97c6 100644 --- a/app/views/shared/_label.html.haml +++ b/app/views/shared/_label.html.haml @@ -1,12 +1,13 @@ - label_css_id = dom_id(label) - status = label_subscription_status(label, @project).inquiry if current_user - subject = local_assigns[:subject] +- toggle_subscription_path = toggle_subscription_label_path(label, @project) if current_user %li{ id: label_css_id, data: { id: label.id } } = render "shared/label_row", label: label .visible-xs.visible-sm-inline-block.visible-md-inline-block.dropdown - %button.btn.btn-default.label-options-toggle{ data: { toggle: "dropdown" } } + %button.btn.btn-default.label-options-toggle{ type: 'button', data: { toggle: "dropdown" } } Options = icon('caret-down') .dropdown-menu.dropdown-menu-align-right @@ -17,18 +18,18 @@ %li = link_to_label(label, subject: subject) do view open issues - - if current_user && defined?(@project) + - if current_user %li.label-subscription - - if label.is_a?(ProjectLabel) - %a.js-subscribe-button.label-subscribe-button{ role: 'button', href: '#', data: { status: status, url: toggle_subscription_namespace_project_label_path(@project.namespace, @project, label) } } - %span= label_subscription_toggle_button_text(label, @project) - - else - %a.js-unsubscribe-button.label-subscribe-button{ role: 'button', href: '#', class: ('hidden' if status.unsubscribed?), data: { url: group_label_unsubscribe_path(label, @project) } } + - if can_subscribe_to_label_in_different_levels?(label) + %a.js-unsubscribe-button.label-subscribe-button{ role: 'button', href: '#', class: ('hidden' if status.unsubscribed?), data: { url: toggle_subscription_path } } %span Unsubscribe %a.js-subscribe-button.label-subscribe-button{ role: 'button', href: '#', class: ('hidden' unless status.unsubscribed?), data: { url: toggle_subscription_namespace_project_label_path(@project.namespace, @project, label) } } %span Subscribe at project level %a.js-subscribe-button.label-subscribe-button{ role: 'button', href: '#', class: ('hidden' unless status.unsubscribed?), data: { url: toggle_subscription_group_label_path(label.group, label) } } %span Subscribe at group level + - else + %a.js-subscribe-button.label-subscribe-button{ role: 'button', href: '#', data: { status: status, url: toggle_subscription_path } } + %span= label_subscription_toggle_button_text(label, @project) - if can?(current_user, :admin_label, label) %li @@ -42,14 +43,10 @@ = link_to_label(label, subject: subject, css_class: 'btn btn-transparent btn-action') do view open issues - - if current_user && defined?(@project) + - if current_user .label-subscription.inline - - if label.is_a?(ProjectLabel) - %button.js-subscribe-button.label-subscribe-button.btn.btn-default{ type: 'button', data: { status: status, url: toggle_subscription_namespace_project_label_path(@project.namespace, @project, label) } } - %span= label_subscription_toggle_button_text(label, @project) - = icon('spinner spin', class: 'label-subscribe-button-loading') - - else - %button.js-unsubscribe-button.label-subscribe-button.btn.btn-default{ type: 'button', class: ('hidden' if status.unsubscribed?), data: { url: group_label_unsubscribe_path(label, @project) } } + - if can_subscribe_to_label_in_different_levels?(label) + %button.js-unsubscribe-button.label-subscribe-button.btn.btn-default{ type: 'button', class: ('hidden' if status.unsubscribed?), data: { url: toggle_subscription_path } } %span Unsubscribe = icon('spinner spin', class: 'label-subscribe-button-loading') @@ -59,10 +56,14 @@ = icon('chevron-down') %ul.dropdown-menu %li - %a.js-subscribe-button{ data: { url: toggle_subscription_namespace_project_label_path(@project.namespace, @project, label) } } + %a.js-subscribe-button{ class: ('hidden' unless status.unsubscribed?), data: { url: toggle_subscription_namespace_project_label_path(@project.namespace, @project, label) } } Project level - %a.js-subscribe-button{ data: { url: toggle_subscription_group_label_path(label.group, label) } } + %a.js-subscribe-button{ class: ('hidden' unless status.unsubscribed?), data: { url: toggle_subscription_group_label_path(label.group, label) } } Group level + - else + %button.js-subscribe-button.label-subscribe-button.btn.btn-default{ type: 'button', data: { status: status, url: toggle_subscription_path } } + %span= label_subscription_toggle_button_text(label, @project) + = icon('spinner spin', class: 'label-subscribe-button-loading') - if label.is_a?(ProjectLabel) && label.project.group && can?(current_user, :admin_label, label.project.group) = link_to promote_namespace_project_label_path(label.project.namespace, label.project, label), title: "Promote to Group Label", class: 'btn btn-transparent btn-action', data: {confirm: "Promoting this label will make this label available to all projects inside this group. Existing project labels with the same name will be merged. Are you sure?", toggle: "tooltip"}, method: :post do @@ -76,10 +77,10 @@ %span.sr-only Delete = icon('trash-o') - - if current_user && defined?(@project) - - if label.is_a?(ProjectLabel) + - if current_user + - if can_subscribe_to_label_in_different_levels?(label) :javascript - new gl.ProjectLabelSubscription('##{dom_id(label)} .label-subscription'); + new gl.GroupLabelSubscription('##{dom_id(label)} .label-subscription'); - else :javascript - new gl.GroupLabelSubscription('##{dom_id(label)} .label-subscription'); + new gl.ProjectLabelSubscription('##{dom_id(label)} .label-subscription'); diff --git a/app/views/shared/_label_row.html.haml b/app/views/shared/_label_row.html.haml index d28f9421ecf..7b599dff0e3 100644 --- a/app/views/shared/_label_row.html.haml +++ b/app/views/shared/_label_row.html.haml @@ -4,9 +4,9 @@ = icon('bars') .js-toggle-priority.toggle-priority{ data: { url: remove_priority_namespace_project_label_path(@project.namespace, @project, label), dom_id: dom_id(label), type: label.type } } - %button.add-priority.btn.has-tooltip{ title: 'Prioritize', :'data-placement' => 'top' } + %button.add-priority.btn.has-tooltip{ title: 'Prioritize', type: 'button', :'data-placement' => 'top' } = icon('star-o') - %button.remove-priority.btn.has-tooltip{ title: 'Remove priority', :'data-placement' => 'top' } + %button.remove-priority.btn.has-tooltip{ title: 'Remove priority', type: 'button', :'data-placement' => 'top' } = icon('star') %span.label-name = link_to_label(label, subject: @project, tooltip: false) diff --git a/app/views/shared/_no_password.html.haml b/app/views/shared/_no_password.html.haml index b561e6dc248..9b1a467df6b 100644 --- a/app/views/shared/_no_password.html.haml +++ b/app/views/shared/_no_password.html.haml @@ -1,9 +1,8 @@ -- if cookies[:hide_no_password_message].blank? && !current_user.hide_no_password && current_user.require_password? +- if show_no_password_message? .no-password-message.alert.alert-warning - - set_password_link = link_to s_('SetPasswordToCloneLink|set a password'), edit_profile_password_path - - translation_params = { protocol: gitlab_config.protocol.upcase, set_password_link: set_password_link } + - translation_params = { protocol: gitlab_config.protocol.upcase, set_password_link: link_to_set_password } - set_password_message = _("You won't be able to pull or push project code via %{protocol} until you %{set_password_link} on your account") % translation_params - + = set_password_message.html_safe .alert-link-group = link_to _("Don't show again"), profile_path(user: {hide_no_password: true}), method: :put | diff --git a/app/views/shared/_no_ssh.html.haml b/app/views/shared/_no_ssh.html.haml index e7815e28017..17ef5327341 100644 --- a/app/views/shared/_no_ssh.html.haml +++ b/app/views/shared/_no_ssh.html.haml @@ -1,8 +1,8 @@ -- if cookies[:hide_no_ssh_message].blank? && !current_user.hide_no_ssh_key && current_user.require_ssh_key? +- if show_no_ssh_key_message? .no-ssh-key-message.alert.alert-warning - add_ssh_key_link = link_to s_('MissingSSHKeyWarningLink|add an SSH key'), profile_keys_path, class: 'alert-link' - ssh_message = _("You won't be able to pull or push project code via SSH until you %{add_ssh_key_link} to your profile") % { add_ssh_key_link: add_ssh_key_link } - #{ ssh_message.html_safe } + = ssh_message.html_safe .alert-link-group = link_to _("Don't show again"), profile_path(user: {hide_no_ssh_key: true}), method: :put, class: 'alert-link' | diff --git a/app/views/shared/icons/_icon_empty_metrics.svg b/app/views/shared/icons/_icon_empty_metrics.svg new file mode 100644 index 00000000000..24fa353f3ba --- /dev/null +++ b/app/views/shared/icons/_icon_empty_metrics.svg @@ -0,0 +1,5 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"> + <g fill="#E5E5E5"> + <path d="M32 64C30.8954305 64 30 63.1045695 30 62 30 60.8954305 30.8954305 60 32 60 33.8894444 60 35.7536611 59.8131396 37.574335 59.4454933 38.6570511 59.2268618 39.7120017 59.9273408 39.9306331 61.0100569 40.1492646 62.0927729 39.4487856 63.1477235 38.3660695 63.366355 36.285133 63.7865558 34.1557023 64 32 64zM49.2301062 58.9696428C51.0302775 57.8173242 52.7114504 56.4871355 54.247711 55.0008916 55.0415758 54.232873 55.0625283 52.9667164 54.2945097 52.1728516 53.5264912 51.3789869 52.2603346 51.3580344 51.4664698 52.1260529 50.1212672 53.4274592 48.6493395 54.5920875 47.0736141 55.6007347 46.1433158 56.1962335 45.8719072 57.4331365 46.4674061 58.3634348 47.0629049 59.2937331 48.2998079 59.5651416 49.2301062 58.9696428zM61.0426034 45.4531856C61.9412068 43.5163476 62.6441937 41.4911051 63.1388045 39.4034279 63.393449 38.3286117 62.7285685 37.2508708 61.6537523 36.9962262 60.5789361 36.7415816 59.5011952 37.4064621 59.2465506 38.4812784 58.8141946 40.3061875 58.1997219 42.0764286 57.4141077 43.7697311 56.9492346 44.7717126 57.3846469 45.9608331 58.3866284 46.4257062 59.3886098 46.8905793 60.5777303 46.455167 61.0426034 45.4531856zM63.7270657 27.8034151C63.4476841 25.6718707 62.9558906 23.5863203 62.2616468 21.5714028 61.9018246 20.527084 60.7635435 19.9721898 59.7192246 20.3320119 58.6749058 20.6918341 58.1200116 21.8301152 58.4798337 22.874434 59.0867105 24.6357842 59.5166381 26.45898 59.760988 28.3232492 59.9045362 29.4184513 60.9087418 30.1899192 62.0039439 30.046371 63.099146 29.9028228 63.8706139 28.8986173 63.7270657 27.8034151zM56.4699838 11.3781121C55.0919588 9.74451505 53.5537382 8.25140603 51.8798083 6.92273835 51.0146495 6.23602588 49.7566092 6.38068523 49.0698968 7.24584403 48.3831843 8.11100284 48.5278436 9.36904308 49.3930024 10.0557555 50.8587525 11.2191822 52.2058153 12.5267396 53.4125204 13.9572433 54.1247279 14.8015385 55.3865225 14.9086168 56.2308177 14.1964094 57.0751129 13.484202 57.1821912 12.2224073 56.4699838 11.3781121zM41.481294 1.42849704C39.4470333.798260231 37.3474846.371987025 35.2067823.158824109 34.1076485.0493765922 33.1278998.851675811 33.0184523 1.95080957 32.9090048 3.04994333 33.711304 4.02969203 34.8104377 4.13913955 36.6833634 4.32563829 38.5191483 4.69835932 40.297557 5.24933028 41.3526509 5.57621023 42.4729622 4.98587613 42.7998421 3.93078217 43.1267221 2.8756882 42.536388 1.75537699 41.481294 1.42849704zM23.6558195 1.0993008C21.5852929 1.6571259 19.5822296 2.42161363 17.6728876 3.37914679 16.6855233 3.874309 16.2865147 5.07613416 16.7816769 6.06349841 17.2768392 7.05086266 18.4786643 7.44987125 19.4660286 6.95470905 21.1354949 6.11747332 22.8864813 5.44919307 24.6963667 4.96158787 25.7629079 4.67424869 26.3945759 3.57671185 26.1072367 2.51017072 25.8198975 1.44362959 24.7223606.811961615 23.6558195 1.0993008zM8.36290105 10.4291871C6.92120358 12.00815 5.63985273 13.7275139 4.53998784 15.5610549 3.97179016 16.5082746 4.27904822 17.7367631 5.22626792 18.3049608 6.17348763 18.8731585 7.40197615 18.5659004 7.97017383 17.6186807 8.9327668 16.0139803 10.054503 14.5087932 11.3168098 13.126301 12.0615972 12.3106016 12.0041117 11.0455771 11.1884123 10.3007897 10.372713 9.55600224 9.10768848 9.61348772 8.36290105 10.4291871zM.450120287 26.6230259C.151304663 28.3883054 0 30.1850053 0 32 0 32.2974081.00406268322 32.594367.0121750297 32.8908218.0423897377 33.994978.96197903 34.8655796 2.0661352 34.8353649 3.17029137 34.8051502 4.04089294 33.8855609 4.01067824 32.7814047 4.00356366 32.521412 4 32.2609289 4 32 4 30.4089462 4.13249902 28.8355581 4.39401589 27.2906242 4.57836807 26.2015475 3.84494393 25.1692294 2.75586724 24.9848772 1.66679054 24.800525.634472466 25.5339492.450120287 26.6230259zM2.45830096 44.3202494C3.28286321 46.2952494 4.30407075 48.1806071 5.50459135 49.9494734 6.124886 50.8634254 7.36863868 51.1014818 8.28259072 50.4811871 9.19654276 49.8608925 9.43459912 48.6171398 8.81430448 47.7031878 7.76386025 46.1554464 6.87058107 44.5062706 6.14951581 42.7791677 5.72395784 41.7598668 4.55266835 41.2785432 3.53336751 41.7041011 2.51406668 42.1296591 2.03274299 43.3009486 2.45830096 44.3202494zM13.73374 58.2776222C15.4883094 59.4994144 17.3614388 60.5433005 19.3262717 61.39161 20.3403619 61.8294398 21.5173756 61.3622885 21.9552054 60.3481983 22.3930351 59.3341082 21.9258838 58.1570945 20.9117937 57.7192647 19.1934726 56.9773858 17.5548741 56.0642026 16.0195384 54.9950736 15.1130877 54.3638678 13.8665707 54.5869979 13.2353649 55.4934487 12.6041591 56.3998995 12.8272892 57.6464164 13.73374 58.2776222zM30.6955071 63.9738646C29.5918263 63.9295649 28.7330282 62.9989428 28.7773279 61.895262 28.8216276 60.7915812 29.7522497 59.9327832 30.8559305 59.9770829 31.2344492 59.9922759 31.6140624 59.9999282 31.9946308 59.9999995 33.0992003 60.0002065 33.994463 60.8958047 33.994256 62.0003742 33.9940491 63.1049437 33.0984508 64.0002064 31.9938814 63.9999994 31.5600677 63.9999181 31.1272192 63.9911927 30.6955071 63.9738646zM30.1721098 44.2840559C30.7941711 46.023825 33.2407935 46.0619159 33.9167124 44.3423547L38.9452693 31.5495297 41.1315797 35.2685507C41.4908522 35.8796908 42.1468005 36.2549751 42.8557214 36.2549751L51.1106965 36.2549751C52.215266 36.2549751 53.1106965 35.3595446 53.1106965 34.2549751 53.1106965 33.1504056 52.215266 32.2549751 51.1106965 32.2549751L43.9999712 32.2549751 40.3112064 25.9802055C39.465988 24.5424477 37.3358287 24.7099356 36.7257006 26.2621229L32.1439734 37.9181973 26.2115967 21.3266406C25.5807315 19.562249 23.0875908 19.5563214 22.4483429 21.3176933L18.4775633 32.2587065 13 32.2587065C11.8954305 32.2587065 11 33.154137 11 34.2587065 11 35.363276 11.8954305 36.2587065 13 36.2587065L19.8793532 36.2587065C20.720826 36.2587065 21.4722973 35.732004 21.7593685 34.9410132L24.314328 27.9011249 30.1721098 44.2840559z"/> + </g> +</svg> diff --git a/app/views/shared/issuable/_bulk_update_sidebar.html.haml b/app/views/shared/issuable/_bulk_update_sidebar.html.haml index a8a6d84128d..7cfdfb6e6ee 100644 --- a/app/views/shared/issuable/_bulk_update_sidebar.html.haml +++ b/app/views/shared/issuable/_bulk_update_sidebar.html.haml @@ -1,7 +1,7 @@ - type = local_assigns.fetch(:type) %aside.issues-bulk-update.js-right-sidebar.right-sidebar.affix-top{ data: { "offset-top" => "50", "spy" => "affix" }, "aria-live" => "polite" } - .issuable-sidebar + .issuable-sidebar.hidden = form_tag [:bulk_update, @project.namespace.becomes(Namespace), @project, type], method: :post, class: "bulk-update" do .block .filter-item.inline.update-issues-btn.pull-left diff --git a/app/views/shared/issuable/_nav.html.haml b/app/views/shared/issuable/_nav.html.haml index cf7ba52d840..3f03cc7a275 100644 --- a/app/views/shared/issuable/_nav.html.haml +++ b/app/views/shared/issuable/_nav.html.haml @@ -1,24 +1,25 @@ - type = local_assigns.fetch(:type, :issues) - page_context_word = type.to_s.humanize(capitalize: false) - issuables = @issues || @merge_requests -- closed_title = 'Filter by issues that are currently closed.' %ul.nav-links.issues-state-filters %li{ class: active_when(params[:state] == 'opened') }> - %button.btn.btn-link{ id: 'state-opened', title: "Filter by #{page_context_word} that are currently opened.", type: 'button', data: { state: 'opened' } } + = link_to page_filter_path(state: 'opened', label: true), id: 'state-opened', title: "Filter by #{page_context_word} that are currently opened.", data: { state: 'opened' } do #{issuables_state_counter_text(type, :opened)} - if type == :merge_requests %li{ class: active_when(params[:state] == 'merged') }> - %button.btn.btn-link{ id: 'state-merged', title: 'Filter by merge requests that are currently merged.', type: 'button', data: { state: 'merged' } } + = link_to page_filter_path(state: 'merged', label: true), id: 'state-merged', title: 'Filter by merge requests that are currently merged.', data: { state: 'merged' } do #{issuables_state_counter_text(type, :merged)} - - closed_title = 'Filter by merge requests that are currently closed and unmerged.' - - %li{ class: active_when(params[:state] == 'closed') }> - %button.btn.btn-link{ id: 'state-closed', title: closed_title, type: 'button', data: { state: 'closed' } } - #{issuables_state_counter_text(type, :closed)} + %li{ class: active_when(params[:state] == 'closed') }> + = link_to page_filter_path(state: 'closed', label: true), id: 'state-closed', title: 'Filter by merge requests that are currently closed and unmerged.', data: { state: 'closed' } do + #{issuables_state_counter_text(type, :closed)} + - else + %li{ class: active_when(params[:state] == 'closed') }> + = link_to page_filter_path(state: 'closed', label: true), id: 'state-closed', title: 'Filter by issues that are currently closed.', data: { state: 'closed' } do + #{issuables_state_counter_text(type, :closed)} %li{ class: active_when(params[:state] == 'all') }> - %button.btn.btn-link{ id: 'state-all', title: "Show all #{page_context_word}.", type: 'button', data: { state: 'all' } } + = link_to page_filter_path(state: 'all', label: true), id: 'state-all', title: "Show all #{page_context_word}.", data: { state: 'all' } do #{issuables_state_counter_text(type, :all)} diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index e49bd5ebb13..745f1ee62da 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -3,7 +3,7 @@ = page_specific_javascript_bundle_tag('common_vue') = page_specific_javascript_bundle_tag('sidebar') -%aside.right-sidebar.js-right-sidebar{ data: { "offset-top" => "50", "spy" => "affix" }, class: sidebar_gutter_collapsed_class, 'aria-live' => 'polite' } +%aside.right-sidebar.js-right-sidebar{ data: { "offset-top" => "50", "spy" => "affix", signed: { in: current_user.present? } }, class: sidebar_gutter_collapsed_class, 'aria-live' => 'polite' } .issuable-sidebar{ data: { endpoint: "#{issuable_json_path(issuable)}" } } - can_edit_issuable = can?(current_user, :"admin_#{issuable.to_ability_name}", @project) .block.issuable-sidebar-header @@ -20,7 +20,7 @@ .block.todo.hide-expanded = render "shared/issuable/sidebar_todo", todo: todo, issuable: issuable, is_collapsed: true .block.assignee - = render "shared/issuable/sidebar_assignees", issuable: issuable, can_edit_issuable: can_edit_issuable + = render "shared/issuable/sidebar_assignees", issuable: issuable, can_edit_issuable: can_edit_issuable, signed_in: current_user.present? .block.milestone .sidebar-collapsed-icon = icon('clock-o', 'aria-hidden': 'true') diff --git a/app/views/shared/issuable/_sidebar_assignees.html.haml b/app/views/shared/issuable/_sidebar_assignees.html.haml index bcfa1dc826e..2ea5eb960c0 100644 --- a/app/views/shared/issuable/_sidebar_assignees.html.haml +++ b/app/views/shared/issuable/_sidebar_assignees.html.haml @@ -1,5 +1,5 @@ - if issuable.is_a?(Issue) - #js-vue-sidebar-assignees{ data: { field: "#{issuable.to_ability_name}[assignee_ids]" } } + #js-vue-sidebar-assignees{ data: { field: "#{issuable.to_ability_name}[assignee_ids]", signed_in: signed_in } } .title.hide-collapsed Assignee = icon('spinner spin') @@ -14,6 +14,9 @@ = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true') - if can_edit_issuable = link_to 'Edit', '#', class: 'edit-link pull-right' + - if !signed_in + %a.gutter-toggle.pull-right.js-sidebar-toggle{ role: "button", href: "#", "aria-label" => "Toggle sidebar" } + = sidebar_gutter_toggle_icon .value.hide-collapsed - if issuable.assignee = link_to_member(@project, issuable.assignee, size: 32, extra_class: 'bold') do diff --git a/app/views/shared/milestones/_issuable.html.haml b/app/views/shared/milestones/_issuable.html.haml index 22547a30cdf..a7c67ac9980 100644 --- a/app/views/shared/milestones/_issuable.html.haml +++ b/app/views/shared/milestones/_issuable.html.haml @@ -16,7 +16,7 @@ %strong #{project.name_with_namespace} · - if issuable.is_a?(Issue) = confidential_icon(issuable) - = link_to_gfm issuable.title, issuable_url_args, title: issuable.title + = link_to issuable.title, issuable_url_args, title: issuable.title .issuable-detail = link_to [project.namespace.becomes(Namespace), project, issuable] do %span.issuable-number= issuable.to_reference diff --git a/app/views/shared/milestones/_milestone.html.haml b/app/views/shared/milestones/_milestone.html.haml index 9e6a76e1ddb..680e1f3a4ea 100644 --- a/app/views/shared/milestones/_milestone.html.haml +++ b/app/views/shared/milestones/_milestone.html.haml @@ -4,7 +4,7 @@ %li{ class: "milestone milestone-#{milestone.closed? ? 'closed' : 'open'}", id: custom_dom_id } .row .col-sm-6 - %strong= link_to_gfm truncate(milestone.title, length: 100), milestone_path + %strong= link_to truncate(milestone.title, length: 100), milestone_path .col-sm-6 .pull-right.light #{milestone.percent_complete(current_user)}% complete .row diff --git a/app/views/shared/notes/_notes_with_form.html.haml b/app/views/shared/notes/_notes_with_form.html.haml index 0cca8d875d2..f0fcc414756 100644 --- a/app/views/shared/notes/_notes_with_form.html.haml +++ b/app/views/shared/notes/_notes_with_form.html.haml @@ -6,13 +6,14 @@ - if can_create_note? %ul.notes.notes-form.timeline %li.timeline-entry - .flash-container.timeline-content + .timeline-entry-inner + .flash-container.timeline-content - .timeline-icon.hidden-xs.hidden-sm - %a.author_link{ href: user_path(current_user) } - = image_tag avatar_icon(current_user), alt: current_user.to_reference, class: 'avatar s40' - .timeline-content.timeline-content-form - = render "shared/notes/form", view: diff_view, supports_autocomplete: autocomplete + .timeline-icon.hidden-xs.hidden-sm + %a.author_link{ href: user_path(current_user) } + = image_tag avatar_icon(current_user), alt: current_user.to_reference, class: 'avatar s40' + .timeline-content.timeline-content-form + = render "shared/notes/form", view: diff_view, supports_autocomplete: autocomplete - elsif !current_user .disabled-comment.text-center.prepend-top-default Please diff --git a/app/views/shared/notifications/_custom_notifications.html.haml b/app/views/shared/notifications/_custom_notifications.html.haml index 752932e6045..9186c2ba9c9 100644 --- a/app/views/shared/notifications/_custom_notifications.html.haml +++ b/app/views/shared/notifications/_custom_notifications.html.haml @@ -3,7 +3,7 @@ .modal-content .modal-header %button.close{ type: "button", "aria-label": "close", data: { dismiss: "modal" } } - %span{ "aria-hidden": "true" } } × + %span{ "aria-hidden": "true" } × %h4#custom-notifications-title.modal-title #{ _('Custom notification events') } diff --git a/app/views/shared/projects/_project.html.haml b/app/views/shared/projects/_project.html.haml index fbc335f6176..8c3d6351ac2 100644 --- a/app/views/shared/projects/_project.html.haml +++ b/app/views/shared/projects/_project.html.haml @@ -7,7 +7,7 @@ - show_last_commit_as_description = false unless local_assigns[:show_last_commit_as_description] == true && project.commit - css_class += " no-description" if project.description.blank? && !show_last_commit_as_description - cache_key = project_list_cache_key(project) -- updated_tooltip = time_ago_with_tooltip(project.last_activity_at) +- updated_tooltip = time_ago_with_tooltip(project.last_activity_date) %li.project-row{ class: css_class } = cache(cache_key) do diff --git a/app/views/shared/snippets/_header.html.haml b/app/views/shared/snippets/_header.html.haml index 813d8d69d8d..17b34c5eeb3 100644 --- a/app/views/shared/snippets/_header.html.haml +++ b/app/views/shared/snippets/_header.html.haml @@ -16,7 +16,7 @@ - else = render "snippets/actions" -.snippet-header +.snippet-header.limited-header-width %h2.snippet-title.prepend-top-0.append-bottom-0 = markdown_field(@snippet, :title) diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml index 216184eb839..8818590362d 100644 --- a/app/views/snippets/show.html.haml +++ b/app/views/snippets/show.html.haml @@ -1,3 +1,4 @@ +- @content_class = "limit-container-width limited-inner-width-container" unless fluid_layout - page_title "#{@snippet.title} (#{@snippet.to_reference})", "Snippets" = render 'shared/snippets/header' @@ -9,4 +10,4 @@ .row-content-block.top-block.content-component-block = render 'award_emoji/awards_block', awardable: @snippet, inline: true - #notes= render "shared/notes/notes_with_form", :autocomplete => false + #notes.limited-width-notes= render "shared/notes/notes_with_form", :autocomplete => false diff --git a/app/workers/merge_worker.rb b/app/workers/merge_worker.rb index 79efca4f2f9..48e2da338f6 100644 --- a/app/workers/merge_worker.rb +++ b/app/workers/merge_worker.rb @@ -7,7 +7,7 @@ class MergeWorker current_user = User.find(current_user_id) merge_request = MergeRequest.find(merge_request_id) - MergeRequests::MergeService.new(merge_request.target_project, current_user, params). - execute(merge_request) + MergeRequests::MergeService.new(merge_request.target_project, current_user, params) + .execute(merge_request) end end diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb index fe6a49976e0..c0c03848a40 100644 --- a/app/workers/process_commit_worker.rb +++ b/app/workers/process_commit_worker.rb @@ -47,8 +47,8 @@ class ProcessCommitWorker # therefor we use IssueCollection here and skip the authorization check in # Issues::CloseService#execute. IssueCollection.new(issues).updatable_by_user(user).each do |issue| - Issues::CloseService.new(project, author). - close_issue(issue, commit: commit) + Issues::CloseService.new(project, author) + .close_issue(issue, commit: commit) end end @@ -57,8 +57,8 @@ class ProcessCommitWorker return if mentioned_issues.empty? - Issue::Metrics.where(issue_id: mentioned_issues.map(&:id), first_mentioned_in_commit_at: nil). - update_all(first_mentioned_in_commit_at: commit.committed_date) + Issue::Metrics.where(issue_id: mentioned_issues.map(&:id), first_mentioned_in_commit_at: nil) + .update_all(first_mentioned_in_commit_at: commit.committed_date) end def build_commit(project, hash) diff --git a/app/workers/project_cache_worker.rb b/app/workers/project_cache_worker.rb index 8ff9d07860f..505ff9e086e 100644 --- a/app/workers/project_cache_worker.rb +++ b/app/workers/project_cache_worker.rb @@ -32,8 +32,8 @@ class ProjectCacheWorker private def try_obtain_lease_for(project_id, section) - Gitlab::ExclusiveLease. - new("project_cache_worker:#{project_id}:#{section}", timeout: LEASE_TIMEOUT). - try_obtain + Gitlab::ExclusiveLease + .new("project_cache_worker:#{project_id}:#{section}", timeout: LEASE_TIMEOUT) + .try_obtain end end diff --git a/app/workers/propagate_service_template_worker.rb b/app/workers/propagate_service_template_worker.rb index 5ce0e0405d0..6b607451c7a 100644 --- a/app/workers/propagate_service_template_worker.rb +++ b/app/workers/propagate_service_template_worker.rb @@ -14,8 +14,8 @@ class PropagateServiceTemplateWorker private def try_obtain_lease_for(template_id) - Gitlab::ExclusiveLease. - new("propagate_service_template_worker:#{template_id}", timeout: LEASE_TIMEOUT). - try_obtain + Gitlab::ExclusiveLease + .new("propagate_service_template_worker:#{template_id}", timeout: LEASE_TIMEOUT) + .try_obtain end end diff --git a/app/workers/prune_old_events_worker.rb b/app/workers/prune_old_events_worker.rb index 392abb9c21b..2b43bb19ad1 100644 --- a/app/workers/prune_old_events_worker.rb +++ b/app/workers/prune_old_events_worker.rb @@ -10,9 +10,9 @@ class PruneOldEventsWorker '(id IN (SELECT id FROM (?) ids_to_remove))', Event.unscoped.where( 'created_at < ?', - (12.months + 1.day).ago). - select(:id). - limit(10_000)). - delete_all + (12.months + 1.day).ago) + .select(:id) + .limit(10_000)) + .delete_all end end diff --git a/app/workers/repository_check/batch_worker.rb b/app/workers/repository_check/batch_worker.rb index c3e7491ec4e..b94d83bd709 100644 --- a/app/workers/repository_check/batch_worker.rb +++ b/app/workers/repository_check/batch_worker.rb @@ -32,10 +32,10 @@ module RepositoryCheck # has to sit and wait for this query to finish. def project_ids limit = 10_000 - never_checked_projects = Project.where('last_repository_check_at IS NULL AND created_at < ?', 24.hours.ago). - limit(limit).pluck(:id) - old_check_projects = Project.where('last_repository_check_at < ?', 1.month.ago). - reorder('last_repository_check_at ASC').limit(limit).pluck(:id) + never_checked_projects = Project.where('last_repository_check_at IS NULL AND created_at < ?', 24.hours.ago) + .limit(limit).pluck(:id) + old_check_projects = Project.where('last_repository_check_at < ?', 1.month.ago) + .reorder('last_repository_check_at ASC').limit(limit).pluck(:id) never_checked_projects + old_check_projects end diff --git a/app/workers/update_user_activity_worker.rb b/app/workers/update_user_activity_worker.rb index b3c2f13aa33..31bbdb69edb 100644 --- a/app/workers/update_user_activity_worker.rb +++ b/app/workers/update_user_activity_worker.rb @@ -7,8 +7,8 @@ class UpdateUserActivityWorker ids = pairs.keys conditions = 'WHEN id = ? THEN ? ' * ids.length - User.where(id: ids). - update_all([ + User.where(id: ids) + .update_all([ "last_activity_on = CASE #{conditions} ELSE last_activity_on END", *pairs.to_a.flatten ]) diff --git a/bin/ci/upgrade.rb b/bin/ci/upgrade.rb deleted file mode 100755 index aab4f60ec60..00000000000 --- a/bin/ci/upgrade.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative "../lib/ci/upgrader" - -Ci::Upgrader.new.execute diff --git a/changelogs/unreleased/10378-promote-blameless-culture.yml b/changelogs/unreleased/10378-promote-blameless-culture.yml deleted file mode 100644 index 8cf64dfd793..00000000000 --- a/changelogs/unreleased/10378-promote-blameless-culture.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Changed Blame to Annotate in the UI to promote blameless culture -merge_request: 10378 -author: Ilya Vassilevsky diff --git a/changelogs/unreleased/12614-fix-long-message-from-mr.yml b/changelogs/unreleased/12614-fix-long-message-from-mr.yml deleted file mode 100644 index 30408ea4216..00000000000 --- a/changelogs/unreleased/12614-fix-long-message-from-mr.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Implement web hook logging -merge_request: 11027 -author: Alexander Randa diff --git a/changelogs/unreleased/12614-fix-long-message.yml b/changelogs/unreleased/12614-fix-long-message.yml deleted file mode 100644 index 94f8127c3c1..00000000000 --- a/changelogs/unreleased/12614-fix-long-message.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix long urls in the title of commit -merge_request: 10938 -author: Alexander Randa diff --git a/changelogs/unreleased/12910-snippets-description.yml b/changelogs/unreleased/12910-snippets-description.yml deleted file mode 100644 index ac3d754fee1..00000000000 --- a/changelogs/unreleased/12910-snippets-description.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Support descriptions for snippets -merge_request: -author: diff --git a/changelogs/unreleased/14707-allow-activity-feed-to-be-accessible-through-api.yml b/changelogs/unreleased/14707-allow-activity-feed-to-be-accessible-through-api.yml deleted file mode 100644 index 9c17c3b949c..00000000000 --- a/changelogs/unreleased/14707-allow-activity-feed-to-be-accessible-through-api.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Introduce an Events API -merge_request: 11755 -author: diff --git a/changelogs/unreleased/17489-hide-code-from-guests.yml b/changelogs/unreleased/17489-hide-code-from-guests.yml deleted file mode 100644 index eb6daffedfe..00000000000 --- a/changelogs/unreleased/17489-hide-code-from-guests.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Hide clone panel and file list when user is only a guest -merge_request: -author: James Clark diff --git a/changelogs/unreleased/18927-reorder-issue-action-buttons.yml b/changelogs/unreleased/18927-reorder-issue-action-buttons.yml deleted file mode 100644 index 793d6582940..00000000000 --- a/changelogs/unreleased/18927-reorder-issue-action-buttons.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Reorder Issue action buttons in order of usability -merge_request: 11642 -author: diff --git a/changelogs/unreleased/19107-404-when-creating-new-milestone-or-issue-for-project-that-has-issues-disabled.yml b/changelogs/unreleased/19107-404-when-creating-new-milestone-or-issue-for-project-that-has-issues-disabled.yml deleted file mode 100644 index bec9aa34761..00000000000 --- a/changelogs/unreleased/19107-404-when-creating-new-milestone-or-issue-for-project-that-has-issues-disabled.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: 'New issue'/'New merge request' dropdowns should show only projects with issues/merge requests feature enabled -merge_request: 19107 -author: blackst0ne diff --git a/changelogs/unreleased/20517-delete-projects-issuescontroller-redirect_old.yml b/changelogs/unreleased/20517-delete-projects-issuescontroller-redirect_old.yml deleted file mode 100644 index 1f3ab3a2c10..00000000000 --- a/changelogs/unreleased/20517-delete-projects-issuescontroller-redirect_old.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Remove redirect for old issue url containing id instead of iid -merge_request: 11135 -author: blackst0ne diff --git a/changelogs/unreleased/23036-replace-all-spinach-tests-with-rspec-feature-tests.yml b/changelogs/unreleased/23036-replace-all-spinach-tests-with-rspec-feature-tests.yml deleted file mode 100644 index b350b27d863..00000000000 --- a/changelogs/unreleased/23036-replace-all-spinach-tests-with-rspec-feature-tests.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Replace 'starred_projects.feature' spinach test with an rspec analog -merge_request: 11752 -author: blackst0ne diff --git a/changelogs/unreleased/23036-replace-dashboard-mr-spinach.yml b/changelogs/unreleased/23036-replace-dashboard-mr-spinach.yml new file mode 100644 index 00000000000..07c201de96e --- /dev/null +++ b/changelogs/unreleased/23036-replace-dashboard-mr-spinach.yml @@ -0,0 +1,4 @@ +--- +title: Replace 'dashboard/merge_requests' spinach with rspec +merge_request: 12440 +author: Alexander Randa (@randaalex) diff --git a/changelogs/unreleased/23036-replace-dashboard-todo-spinach.yml b/changelogs/unreleased/23036-replace-dashboard-todo-spinach.yml new file mode 100644 index 00000000000..65df9a836a5 --- /dev/null +++ b/changelogs/unreleased/23036-replace-dashboard-todo-spinach.yml @@ -0,0 +1,4 @@ +--- +title: Replace 'dashboard/todos' spinach with rspec +merge_request: 12453 +author: Alexander Randa (@randaalex) diff --git a/changelogs/unreleased/23603-add-extra-functionality-for-the-top-right-button.yml b/changelogs/unreleased/23603-add-extra-functionality-for-the-top-right-button.yml deleted file mode 100644 index 77f8e31e16e..00000000000 --- a/changelogs/unreleased/23603-add-extra-functionality-for-the-top-right-button.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add extra context-sensitive functionality for the top right menu button -merge_request: 11632 -author: diff --git a/changelogs/unreleased/24032-when-changing-project-visibility-setting-change-other-dropdowns-automatically.yml b/changelogs/unreleased/24032-when-changing-project-visibility-setting-change-other-dropdowns-automatically.yml deleted file mode 100644 index dbd8a538d51..00000000000 --- a/changelogs/unreleased/24032-when-changing-project-visibility-setting-change-other-dropdowns-automatically.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Automatically adjust project settings to match changes in project visibility -merge_request: 11831 -author: diff --git a/changelogs/unreleased/24196-protected-variables.yml b/changelogs/unreleased/24196-protected-variables.yml deleted file mode 100644 index 71567a9d794..00000000000 --- a/changelogs/unreleased/24196-protected-variables.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Add protected variables which would only be passed to protected branches or - protected tags -merge_request: 11688 -author: diff --git a/changelogs/unreleased/24373-warning-message-go-away.yml b/changelogs/unreleased/24373-warning-message-go-away.yml deleted file mode 100644 index c0f2fd260ba..00000000000 --- a/changelogs/unreleased/24373-warning-message-go-away.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: 'Notes: Warning message should go away once resolved' -merge_request: 10823 -author: Jacopo Beschi @jacopo-beschi diff --git a/changelogs/unreleased/25102-files-view-button.yml b/changelogs/unreleased/25102-files-view-button.yml new file mode 100644 index 00000000000..4ba815d9464 --- /dev/null +++ b/changelogs/unreleased/25102-files-view-button.yml @@ -0,0 +1,4 @@ +--- +title: Fix mobile view of files view buttons +merge_request: +author: diff --git a/changelogs/unreleased/25373-jira-links.yml b/changelogs/unreleased/25373-jira-links.yml deleted file mode 100644 index 09589d4b992..00000000000 --- a/changelogs/unreleased/25373-jira-links.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Don’t create comment on JIRA if it already exists for the entity -merge_request: -author: diff --git a/changelogs/unreleased/25426-group-dashboard-ui.yml b/changelogs/unreleased/25426-group-dashboard-ui.yml deleted file mode 100644 index cc2bf62d07b..00000000000 --- a/changelogs/unreleased/25426-group-dashboard-ui.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Update Dashboard Groups UI with better support for subgroups -merge_request: -author: diff --git a/changelogs/unreleased/25680-CI_ENVIRONMENT_URL.yml b/changelogs/unreleased/25680-CI_ENVIRONMENT_URL.yml deleted file mode 100644 index af9fe3b5041..00000000000 --- a/changelogs/unreleased/25680-CI_ENVIRONMENT_URL.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add $CI_ENVIRONMENT_URL to predefined variables for pipelines -merge_request: 11695 -author: diff --git a/changelogs/unreleased/26325-system-hooks.yml b/changelogs/unreleased/26325-system-hooks.yml deleted file mode 100644 index 62b8adaeccd..00000000000 --- a/changelogs/unreleased/26325-system-hooks.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: 'Backported new SystemHook event: `repository_update`' -merge_request: 11140 -author: diff --git a/changelogs/unreleased/27148-limit-bulk-create-memberships.yml b/changelogs/unreleased/27148-limit-bulk-create-memberships.yml deleted file mode 100644 index ac4aba2f4e0..00000000000 --- a/changelogs/unreleased/27148-limit-bulk-create-memberships.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Limit non-administrators to adding 100 members at a time to groups and projects -merge_request: 11940 -author: diff --git a/changelogs/unreleased/27439-memory-usage-info.yml b/changelogs/unreleased/27439-memory-usage-info.yml deleted file mode 100644 index dd212853f57..00000000000 --- a/changelogs/unreleased/27439-memory-usage-info.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add performance deltas between app deployments on Merge Request widget -merge_request: 11730 -author: diff --git a/changelogs/unreleased/27614-improve-instant-comments-exp.yml b/changelogs/unreleased/27614-improve-instant-comments-exp.yml deleted file mode 100644 index 4db676801f1..00000000000 --- a/changelogs/unreleased/27614-improve-instant-comments-exp.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Improve user experience around slash commands in instant comments -merge_request: 11612 -author: diff --git a/changelogs/unreleased/27645-html-email-brackets-bug.yml b/changelogs/unreleased/27645-html-email-brackets-bug.yml new file mode 100644 index 00000000000..e8004d03884 --- /dev/null +++ b/changelogs/unreleased/27645-html-email-brackets-bug.yml @@ -0,0 +1,4 @@ +--- +title: Fix an email parsing bug where brackets would be inserted in emails from some Outlook clients +merge_request: 9045 +author: jneen diff --git a/changelogs/unreleased/28080-system-checks.yml b/changelogs/unreleased/28080-system-checks.yml deleted file mode 100644 index 7d83014279a..00000000000 --- a/changelogs/unreleased/28080-system-checks.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Refactored gitlab:app:check into SystemCheck liberary and improve some checks -merge_request: 9173 -author: diff --git a/changelogs/unreleased/28607-forking-and-configuring-project-via-api-works-very-unreliable.yml b/changelogs/unreleased/28607-forking-and-configuring-project-via-api-works-very-unreliable.yml deleted file mode 100644 index 9cf8d745f92..00000000000 --- a/changelogs/unreleased/28607-forking-and-configuring-project-via-api-works-very-unreliable.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Confirm Project forking behaviour via the API -merge_request: -author: diff --git a/changelogs/unreleased/28694-hard-delete-user-from-admin-panel.yml b/changelogs/unreleased/28694-hard-delete-user-from-admin-panel.yml deleted file mode 100644 index 2308a528580..00000000000 --- a/changelogs/unreleased/28694-hard-delete-user-from-admin-panel.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow users to be hard-deleted from the admin panel -merge_request: 11874 -author: diff --git a/changelogs/unreleased/28694-hard-delete-user-from-api.yml b/changelogs/unreleased/28694-hard-delete-user-from-api.yml deleted file mode 100644 index ad46540495c..00000000000 --- a/changelogs/unreleased/28694-hard-delete-user-from-api.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow users to be hard-deleted from the API -merge_request: 11853 -author: diff --git a/changelogs/unreleased/28717-support-additional-prometheus-metrics.yml b/changelogs/unreleased/28717-support-additional-prometheus-metrics.yml new file mode 100644 index 00000000000..720a79b8e1c --- /dev/null +++ b/changelogs/unreleased/28717-support-additional-prometheus-metrics.yml @@ -0,0 +1,4 @@ +--- +title: Additional Prometheus metrics support +merge_request: 11712 +author: diff --git a/changelogs/unreleased/29010-perf-bar.yml b/changelogs/unreleased/29010-perf-bar.yml deleted file mode 100644 index f4167e5562f..00000000000 --- a/changelogs/unreleased/29010-perf-bar.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add an optional performance bar to view performance metrics for the current page -merge_request: 11439 -author: diff --git a/changelogs/unreleased/29118-add-prometheus-instrumenting-to-gitlab-webapp.yml b/changelogs/unreleased/29118-add-prometheus-instrumenting-to-gitlab-webapp.yml deleted file mode 100644 index 99c55f128e3..00000000000 --- a/changelogs/unreleased/29118-add-prometheus-instrumenting-to-gitlab-webapp.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add prometheus based metrics collection to gitlab webapp -merge_request: -author: diff --git a/changelogs/unreleased/29690-rotate-otp-key-base.yml b/changelogs/unreleased/29690-rotate-otp-key-base.yml deleted file mode 100644 index 94d73a24758..00000000000 --- a/changelogs/unreleased/29690-rotate-otp-key-base.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add a Rake task to aid in rotating otp_key_base -merge_request: 11881 -author: diff --git a/changelogs/unreleased/29852-latex-formatting.yml b/changelogs/unreleased/29852-latex-formatting.yml deleted file mode 100644 index e96cda1d6b3..00000000000 --- a/changelogs/unreleased/29852-latex-formatting.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix LaTeX formatting for AsciiDoc wiki -merge_request: 11212 -author: diff --git a/changelogs/unreleased/30213-project-transfer-move-rollback.yml b/changelogs/unreleased/30213-project-transfer-move-rollback.yml new file mode 100644 index 00000000000..3eb1e399c54 --- /dev/null +++ b/changelogs/unreleased/30213-project-transfer-move-rollback.yml @@ -0,0 +1,4 @@ +--- +title: Rollback project repo move if there is an error in Projects::TransferService +merge_request: 11877 +author: diff --git a/changelogs/unreleased/30378-simplified-repository-settings-page.yml b/changelogs/unreleased/30378-simplified-repository-settings-page.yml deleted file mode 100644 index e8b87c8bb33..00000000000 --- a/changelogs/unreleased/30378-simplified-repository-settings-page.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Simplify project repository settings page -merge_request: 11698 -author: diff --git a/changelogs/unreleased/30410-revert-9347-and-10079.yml b/changelogs/unreleased/30410-revert-9347-and-10079.yml deleted file mode 100644 index 0149209caf2..00000000000 --- a/changelogs/unreleased/30410-revert-9347-and-10079.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Revert the feature that would include the current user's username in the HTTP - clone URL -merge_request: 11792 -author: diff --git a/changelogs/unreleased/30469-convdev-index.yml b/changelogs/unreleased/30469-convdev-index.yml deleted file mode 100644 index 0bdd9c4a699..00000000000 --- a/changelogs/unreleased/30469-convdev-index.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add ConvDev Index page to admin area -merge_request: 11377 -author: diff --git a/changelogs/unreleased/30651-improve-container-registry-description.yml b/changelogs/unreleased/30651-improve-container-registry-description.yml deleted file mode 100644 index 0157c9885bc..00000000000 --- a/changelogs/unreleased/30651-improve-container-registry-description.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add changelog for improved Registry description -merge_request: 11816 -author: diff --git a/changelogs/unreleased/30827-changes-to-audit-log.yml b/changelogs/unreleased/30827-changes-to-audit-log.yml deleted file mode 100644 index 32db3bf8e95..00000000000 --- a/changelogs/unreleased/30827-changes-to-audit-log.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Renamed users 'Audit Log'' to 'Authentication Log' -merge_request: 11400 -author: diff --git a/changelogs/unreleased/30892-add-api-support-for-pipeline-schedule.yml b/changelogs/unreleased/30892-add-api-support-for-pipeline-schedule.yml deleted file mode 100644 index 26ce84697d0..00000000000 --- a/changelogs/unreleased/30892-add-api-support-for-pipeline-schedule.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add API support for pipeline schedule -merge_request: 11307 -author: dosuken123 diff --git a/changelogs/unreleased/30917-wiki-is-not-searchable-with-guest-permissions.yml b/changelogs/unreleased/30917-wiki-is-not-searchable-with-guest-permissions.yml deleted file mode 100644 index c9bd2dc465e..00000000000 --- a/changelogs/unreleased/30917-wiki-is-not-searchable-with-guest-permissions.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: 'Fix: Wiki is not searchable with Guest permissions' -merge_request: -author: diff --git a/changelogs/unreleased/30949-empty-states.yml b/changelogs/unreleased/30949-empty-states.yml deleted file mode 100644 index bef87a954b7..00000000000 --- a/changelogs/unreleased/30949-empty-states.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Center all empty states -merge_request: -author: diff --git a/changelogs/unreleased/31061-26135-ci-project-slug-enviroment-variables.yml b/changelogs/unreleased/31061-26135-ci-project-slug-enviroment-variables.yml deleted file mode 100644 index e71910dbd67..00000000000 --- a/changelogs/unreleased/31061-26135-ci-project-slug-enviroment-variables.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add slugify project path to CI enviroment variables -merge_request: 11838 -author: Ivan Chernov diff --git a/changelogs/unreleased/31384-new-issue-button-on-no-results-page-after-search-doesn-t-go-to-correct-form.yml b/changelogs/unreleased/31384-new-issue-button-on-no-results-page-after-search-doesn-t-go-to-correct-form.yml deleted file mode 100644 index 8d586616e07..00000000000 --- a/changelogs/unreleased/31384-new-issue-button-on-no-results-page-after-search-doesn-t-go-to-correct-form.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Remove 'New issue' button when issues search returns no results. -merge_request: !11263 -author: diff --git a/changelogs/unreleased/31448-jira-urls.yml b/changelogs/unreleased/31448-jira-urls.yml deleted file mode 100644 index d0e39f61b55..00000000000 --- a/changelogs/unreleased/31448-jira-urls.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add API URL to JIRA settings -merge_request: -author: diff --git a/changelogs/unreleased/31474-issue-boards-sidebar-milestone-dropdown-should-not-be-multi-select.yml b/changelogs/unreleased/31474-issue-boards-sidebar-milestone-dropdown-should-not-be-multi-select.yml deleted file mode 100644 index 88e79e3b6ea..00000000000 --- a/changelogs/unreleased/31474-issue-boards-sidebar-milestone-dropdown-should-not-be-multi-select.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Disallow multiple selections for Milestone dropdown -merge_request: 11084 -author: diff --git a/changelogs/unreleased/31483-ordered-task-list.yml b/changelogs/unreleased/31483-ordered-task-list.yml deleted file mode 100644 index c43915b3268..00000000000 --- a/changelogs/unreleased/31483-ordered-task-list.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix Ordered Task List Items -merge_request: 31483 -author: Jared Deckard <jared.deckard@gmail.com> diff --git a/changelogs/unreleased/31510-mask-password-field-edit.yml b/changelogs/unreleased/31510-mask-password-field-edit.yml deleted file mode 100644 index 0ef37be328d..00000000000 --- a/changelogs/unreleased/31510-mask-password-field-edit.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Update password field label while editing service settings -merge_request: 11431 -author: diff --git a/changelogs/unreleased/31511-jira-settings.yml b/changelogs/unreleased/31511-jira-settings.yml deleted file mode 100644 index 4f9ddb13ef6..00000000000 --- a/changelogs/unreleased/31511-jira-settings.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Simplify testing and saving service integrations -merge_request: 11599 -author: diff --git a/changelogs/unreleased/31554-update-rufus-scheduler-and-sidekiq.yml b/changelogs/unreleased/31554-update-rufus-scheduler-and-sidekiq.yml deleted file mode 100644 index 0a36b52d561..00000000000 --- a/changelogs/unreleased/31554-update-rufus-scheduler-and-sidekiq.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Update gem sidekiq-cron from 0.4.4 to 0.6.0 and rufus-scheduler from 3.1.10 - to 3.4.0 -merge_request: 10976 -author: dosuken123 diff --git a/changelogs/unreleased/31602-display-whether-shared-runner-is-enabled-in-the-admin-dashboard.yml b/changelogs/unreleased/31602-display-whether-shared-runner-is-enabled-in-the-admin-dashboard.yml deleted file mode 100644 index 00957f7e4f7..00000000000 --- a/changelogs/unreleased/31602-display-whether-shared-runner-is-enabled-in-the-admin-dashboard.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Display Shared Runner status in Admin Dashboard -merge_request: 11783 -author: Ivan Chernov diff --git a/changelogs/unreleased/31616-add-uptime-of-gitlab-instance-in-admin-area.yml b/changelogs/unreleased/31616-add-uptime-of-gitlab-instance-in-admin-area.yml deleted file mode 100644 index 6dc48d6b2d8..00000000000 --- a/changelogs/unreleased/31616-add-uptime-of-gitlab-instance-in-admin-area.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add server uptime to System Info page in admin dashboard -merge_request: 11590 -author: Justin Boltz diff --git a/changelogs/unreleased/31625-tag-editor-loses-all-inputs-when-you-try-to-add-a-tag-that-already-exists.yml b/changelogs/unreleased/31625-tag-editor-loses-all-inputs-when-you-try-to-add-a-tag-that-already-exists.yml deleted file mode 100644 index aae760b0ef5..00000000000 --- a/changelogs/unreleased/31625-tag-editor-loses-all-inputs-when-you-try-to-add-a-tag-that-already-exists.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Keep input data after creating a tag that already exists -merge_request: 11155 -author: diff --git a/changelogs/unreleased/31633-animate-issue.yml b/changelogs/unreleased/31633-animate-issue.yml deleted file mode 100644 index 6df4135b09c..00000000000 --- a/changelogs/unreleased/31633-animate-issue.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: animate adding issue to boards -merge_request: -author: diff --git a/changelogs/unreleased/31644-make-cookie-sessions-unique.yml b/changelogs/unreleased/31644-make-cookie-sessions-unique.yml deleted file mode 100644 index e9a6a32cf70..00000000000 --- a/changelogs/unreleased/31644-make-cookie-sessions-unique.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Update session cookie key name to be unique to instance in development -merge_request: -author: diff --git a/changelogs/unreleased/31757-single-click-on-filter-in-search-bar-to-activate-dropdown.yml b/changelogs/unreleased/31757-single-click-on-filter-in-search-bar-to-activate-dropdown.yml deleted file mode 100644 index 48b8a8507ec..00000000000 --- a/changelogs/unreleased/31757-single-click-on-filter-in-search-bar-to-activate-dropdown.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Single click on filter to open filtered search dropdown -merge_request: -author: diff --git a/changelogs/unreleased/31781-print-rendered-files-not-possible.yml b/changelogs/unreleased/31781-print-rendered-files-not-possible.yml deleted file mode 100644 index 14915823ff7..00000000000 --- a/changelogs/unreleased/31781-print-rendered-files-not-possible.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Include the blob content when printing a blob page -merge_request: 11247 -author: diff --git a/changelogs/unreleased/31840-add-a-rubocop-that-forbids-redirect_to-inside-a-controller-destroy-action-without-an-explicit-status.yml b/changelogs/unreleased/31840-add-a-rubocop-that-forbids-redirect_to-inside-a-controller-destroy-action-without-an-explicit-status.yml deleted file mode 100644 index 52bfe771e2b..00000000000 --- a/changelogs/unreleased/31840-add-a-rubocop-that-forbids-redirect_to-inside-a-controller-destroy-action-without-an-explicit-status.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add a rubocop rule to check if a method 'redirect_to' is used without explicitly set 'status' in 'destroy' actions of controllers -merge_request: 11749 -author: @blackst0ne diff --git a/changelogs/unreleased/31849-pipeline-real-time-header.yml b/changelogs/unreleased/31849-pipeline-real-time-header.yml deleted file mode 100644 index 2bb7af897ff..00000000000 --- a/changelogs/unreleased/31849-pipeline-real-time-header.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Makes header information of pipeline show page realtine -merge_request: -author: diff --git a/changelogs/unreleased/31849-pipeline-show-view-realtime.yml b/changelogs/unreleased/31849-pipeline-show-view-realtime.yml deleted file mode 100644 index 838a769a26e..00000000000 --- a/changelogs/unreleased/31849-pipeline-show-view-realtime.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Creates a mediator for pipeline details vue in order to mount several vue apps - with the same data -merge_request: -author: diff --git a/changelogs/unreleased/31902-namespace-recent-searches-to-project.yml b/changelogs/unreleased/31902-namespace-recent-searches-to-project.yml deleted file mode 100644 index e00eb6d8f72..00000000000 --- a/changelogs/unreleased/31902-namespace-recent-searches-to-project.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Scope issue/merge request recent searches to project -merge_request: -author: diff --git a/changelogs/unreleased/3191-deploy-keys-update.yml b/changelogs/unreleased/3191-deploy-keys-update.yml deleted file mode 100644 index 4100163e94f..00000000000 --- a/changelogs/unreleased/3191-deploy-keys-update.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Implement ability to update deploy keys -merge_request: 10383 -author: Alexander Randa diff --git a/changelogs/unreleased/31943-document-go-183.yml b/changelogs/unreleased/31943-document-go-183.yml deleted file mode 100644 index 201cd48f1ab..00000000000 --- a/changelogs/unreleased/31943-document-go-183.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -title: Upgrade dependency to Go 1.8.3 -merge_request: 31943 diff --git a/changelogs/unreleased/31983-increase-merge-request-diff-file-size-limit-for-default-toggle-opening.yml b/changelogs/unreleased/31983-increase-merge-request-diff-file-size-limit-for-default-toggle-opening.yml deleted file mode 100644 index f61aa0a6b6e..00000000000 --- a/changelogs/unreleased/31983-increase-merge-request-diff-file-size-limit-for-default-toggle-opening.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Increase individual diff collapse limit to 100 KB, and render limit to 200 KB -merge_request: -author: diff --git a/changelogs/unreleased/31998-pipelines-empty-state.yml b/changelogs/unreleased/31998-pipelines-empty-state.yml deleted file mode 100644 index 78ae222255e..00000000000 --- a/changelogs/unreleased/31998-pipelines-empty-state.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix Pipelines table empty state - only render empty state if we receive 0 pipelines -merge_request: -author: diff --git a/changelogs/unreleased/32086-atwho-is-still-enabled-for-personal-snippet-comments-form.yml b/changelogs/unreleased/32086-atwho-is-still-enabled-for-personal-snippet-comments-form.yml deleted file mode 100644 index 0fd248e0400..00000000000 --- a/changelogs/unreleased/32086-atwho-is-still-enabled-for-personal-snippet-comments-form.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Disable reference prefixes in notes for Snippets -merge_request: 11278 -author: diff --git a/changelogs/unreleased/32118-new-environment-btn-copy.yml b/changelogs/unreleased/32118-new-environment-btn-copy.yml deleted file mode 100644 index 16a51c3db6a..00000000000 --- a/changelogs/unreleased/32118-new-environment-btn-copy.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Make New environment empty state btn lowercase -merge_request: -author: diff --git a/changelogs/unreleased/32219-speed-up-yarn-install-in-ci-by-utilizing-inter-pipeline-cache.yml b/changelogs/unreleased/32219-speed-up-yarn-install-in-ci-by-utilizing-inter-pipeline-cache.yml deleted file mode 100644 index 7fb3cb3a30b..00000000000 --- a/changelogs/unreleased/32219-speed-up-yarn-install-in-ci-by-utilizing-inter-pipeline-cache.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Cache npm modules between pipelines with yarn to speed up setup-test-env -merge_request: 11343 -author: diff --git a/changelogs/unreleased/32301-filter-archive-project-on-param-present.yml b/changelogs/unreleased/32301-filter-archive-project-on-param-present.yml new file mode 100644 index 00000000000..d6534ed4e1a --- /dev/null +++ b/changelogs/unreleased/32301-filter-archive-project-on-param-present.yml @@ -0,0 +1,4 @@ +--- +title: Filter archived project in API v3 only if param present +merge_request: 12245 +author: Ivan Chernov diff --git a/changelogs/unreleased/32395-duplicate-string-in-https-docs-gitlab-com-ce-administration-environment_variables-html.yml b/changelogs/unreleased/32395-duplicate-string-in-https-docs-gitlab-com-ce-administration-environment_variables-html.yml deleted file mode 100644 index d2be3d6cc4b..00000000000 --- a/changelogs/unreleased/32395-duplicate-string-in-https-docs-gitlab-com-ce-administration-environment_variables-html.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Removes duplicate environment variable in documentation -merge_request: -author: diff --git a/changelogs/unreleased/32418-make-link-to-self-less-obvious.yml b/changelogs/unreleased/32418-make-link-to-self-less-obvious.yml deleted file mode 100644 index aabe87dac0f..00000000000 --- a/changelogs/unreleased/32418-make-link-to-self-less-obvious.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Change links in issuable meta to black -merge_request: -author: diff --git a/changelogs/unreleased/32570-project-activity-tab-border.yml b/changelogs/unreleased/32570-project-activity-tab-border.yml deleted file mode 100644 index 100a3e6a74d..00000000000 --- a/changelogs/unreleased/32570-project-activity-tab-border.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix border-bottom for project activity tab -merge_request: -author: diff --git a/changelogs/unreleased/32598-avoid-resource-intensive-login-checks-if-password-is-not-provided-for-git-http.yml b/changelogs/unreleased/32598-avoid-resource-intensive-login-checks-if-password-is-not-provided-for-git-http.yml deleted file mode 100644 index 6da7491bbda..00000000000 --- a/changelogs/unreleased/32598-avoid-resource-intensive-login-checks-if-password-is-not-provided-for-git-http.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Avoid resource intensive login checks if password is not provided. -merge_request: 11537 -author: Horatiu Eugen Vlad diff --git a/changelogs/unreleased/32642_last_commit_id_in_file_api.yml b/changelogs/unreleased/32642_last_commit_id_in_file_api.yml deleted file mode 100644 index 80435352e10..00000000000 --- a/changelogs/unreleased/32642_last_commit_id_in_file_api.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: 'Introduce optimistic locking support via optional parameter last_commit_sha on File Update API' -merge_request: 11694 -author: electroma diff --git a/changelogs/unreleased/32682-skipped-ci-icon.yml b/changelogs/unreleased/32682-skipped-ci-icon.yml deleted file mode 100644 index ad498b51900..00000000000 --- a/changelogs/unreleased/32682-skipped-ci-icon.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Adds new icon for CI skipped status -merge_request: -author: diff --git a/changelogs/unreleased/32720-emoji-spacing.yml b/changelogs/unreleased/32720-emoji-spacing.yml deleted file mode 100644 index da3df0f9093..00000000000 --- a/changelogs/unreleased/32720-emoji-spacing.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Create equal padding for emoji -merge_request: -author: diff --git a/changelogs/unreleased/32799-remove-no_turbolink-attribute-from-haml.yml b/changelogs/unreleased/32799-remove-no_turbolink-attribute-from-haml.yml deleted file mode 100644 index 9c1c1fe77f2..00000000000 --- a/changelogs/unreleased/32799-remove-no_turbolink-attribute-from-haml.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Remove redundant data-turbolink attributes from links -merge_request: 11672 -author: blackst0ne diff --git a/changelogs/unreleased/32807-company-icon.yml b/changelogs/unreleased/32807-company-icon.yml deleted file mode 100644 index 718108d3733..00000000000 --- a/changelogs/unreleased/32807-company-icon.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Use briefcase icon for company in profile page -merge_request: -author: diff --git a/changelogs/unreleased/32832-confidential-issue-overflow.yml b/changelogs/unreleased/32832-confidential-issue-overflow.yml deleted file mode 100644 index 7d3d3bfed2e..00000000000 --- a/changelogs/unreleased/32832-confidential-issue-overflow.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Remove overflow from comment form for confidential issues and vertically aligns - confidential issue icon -merge_request: -author: diff --git a/changelogs/unreleased/32851-postgres-min-version.yml b/changelogs/unreleased/32851-postgres-min-version.yml deleted file mode 100644 index 139307d65c6..00000000000 --- a/changelogs/unreleased/32851-postgres-min-version.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Minimum postgresql version is now 9.2 -merge_request: 11677 -author: diff --git a/changelogs/unreleased/32955-special-keywords.yml b/changelogs/unreleased/32955-special-keywords.yml deleted file mode 100644 index 0f9939ced8c..00000000000 --- a/changelogs/unreleased/32955-special-keywords.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add all pipeline sources as special keywords to 'only' and 'except' -merge_request: 11844 -author: Filip Krakowski diff --git a/changelogs/unreleased/32983-merge-conflict-resolution-removed-the-newline-in-the-end-of-file.yml b/changelogs/unreleased/32983-merge-conflict-resolution-removed-the-newline-in-the-end-of-file.yml deleted file mode 100644 index eca42176501..00000000000 --- a/changelogs/unreleased/32983-merge-conflict-resolution-removed-the-newline-in-the-end-of-file.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Keep trailing newline when resolving conflicts by picking sides -merge_request: -author: diff --git a/changelogs/unreleased/32992-consider-using-zopfli-over-standard-gzip-compression-for-webpack-assets.yml b/changelogs/unreleased/32992-consider-using-zopfli-over-standard-gzip-compression-for-webpack-assets.yml deleted file mode 100644 index 93037d6181e..00000000000 --- a/changelogs/unreleased/32992-consider-using-zopfli-over-standard-gzip-compression-for-webpack-assets.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Use zopfli compression for frontend assets -merge_request: 11798 -author: diff --git a/changelogs/unreleased/33000-tag-list-in-project-create-api.yml b/changelogs/unreleased/33000-tag-list-in-project-create-api.yml deleted file mode 100644 index b0d0d3cbeba..00000000000 --- a/changelogs/unreleased/33000-tag-list-in-project-create-api.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add tag_list param to project api -merge_request: 11799 -author: Ivan Chernov diff --git a/changelogs/unreleased/33032-invalid-you-directly-addressed-yourself-todo-when-using-unsubscribe.yml b/changelogs/unreleased/33032-invalid-you-directly-addressed-yourself-todo-when-using-unsubscribe.yml deleted file mode 100644 index 1eaa0d0124e..00000000000 --- a/changelogs/unreleased/33032-invalid-you-directly-addressed-yourself-todo-when-using-unsubscribe.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Fix /unsubscribe slash command creating extra todos when you were already mentioned - in an issue -merge_request: -author: diff --git a/changelogs/unreleased/33154-permissions-for-project-labels-and-group-labels.yml b/changelogs/unreleased/33154-permissions-for-project-labels-and-group-labels.yml deleted file mode 100644 index 3b98525167d..00000000000 --- a/changelogs/unreleased/33154-permissions-for-project-labels-and-group-labels.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow group reporters to manage group labels -merge_request: -author: diff --git a/changelogs/unreleased/33207-show-delete-option-in-admin-users-page.yml b/changelogs/unreleased/33207-show-delete-option-in-admin-users-page.yml deleted file mode 100644 index 5eb4e15e311..00000000000 --- a/changelogs/unreleased/33207-show-delete-option-in-admin-users-page.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow admins to delete users from the admin users page -merge_request: 11852 -author: diff --git a/changelogs/unreleased/33215-fix-hard-delete-of-users.yml b/changelogs/unreleased/33215-fix-hard-delete-of-users.yml deleted file mode 100644 index 29699ff745a..00000000000 --- a/changelogs/unreleased/33215-fix-hard-delete-of-users.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix hard-deleting users when they have authored issues -merge_request: 11855 -author: diff --git a/changelogs/unreleased/33242-create-project-for-user-api-ignores-path-parameter.yml b/changelogs/unreleased/33242-create-project-for-user-api-ignores-path-parameter.yml deleted file mode 100644 index c33278998ee..00000000000 --- a/changelogs/unreleased/33242-create-project-for-user-api-ignores-path-parameter.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix missing optional path parameter in "Create project for user" API -merge_request: 11868 -author: diff --git a/changelogs/unreleased/33245-chinese_translation_of_cycle_analytics_page.yml b/changelogs/unreleased/33245-chinese_translation_of_cycle_analytics_page.yml deleted file mode 100644 index 07dd0872d3b..00000000000 --- a/changelogs/unreleased/33245-chinese_translation_of_cycle_analytics_page.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add Chinese translation of Cycle Analytics Page to I18N -merge_request: 11644 -author:Huang Tao diff --git a/changelogs/unreleased/33308-use-pre-wrap-for-commit-messages.yml b/changelogs/unreleased/33308-use-pre-wrap-for-commit-messages.yml deleted file mode 100644 index 43e8f242947..00000000000 --- a/changelogs/unreleased/33308-use-pre-wrap-for-commit-messages.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Use pre-wrap for commit messages to keep lists indented -merge_request: -author: diff --git a/changelogs/unreleased/33334-portuguese_brazil_translation_of_cycle_analytics_page.yml b/changelogs/unreleased/33334-portuguese_brazil_translation_of_cycle_analytics_page.yml deleted file mode 100644 index a0e0458da16..00000000000 --- a/changelogs/unreleased/33334-portuguese_brazil_translation_of_cycle_analytics_page.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add Portuguese Brazil of Cycle Analytics Page to I18N -merge_request: 11920 -author:Huang Tao diff --git a/changelogs/unreleased/33383-bulgarian_translation_of_cycle_analytics_page.yml b/changelogs/unreleased/33383-bulgarian_translation_of_cycle_analytics_page.yml deleted file mode 100644 index 71bd5505be7..00000000000 --- a/changelogs/unreleased/33383-bulgarian_translation_of_cycle_analytics_page.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: add bulgarian translation of cycle analytics page to I18N -merge_request: 11958 -author: Lyubomir Vasilev diff --git a/changelogs/unreleased/33441-supplement_simplified_chinese_translation_of_i18n.yml b/changelogs/unreleased/33441-supplement_simplified_chinese_translation_of_i18n.yml new file mode 100644 index 00000000000..a7d8ac9054b --- /dev/null +++ b/changelogs/unreleased/33441-supplement_simplified_chinese_translation_of_i18n.yml @@ -0,0 +1,4 @@ +--- +title: Supplement Simplified Chinese translation of Project Page & Repository Page +merge_request: 11994 +author: Huang Tao diff --git a/changelogs/unreleased/33442-supplement_traditional_chinese_in_hong_kong_translation_of_i18n.yml b/changelogs/unreleased/33442-supplement_traditional_chinese_in_hong_kong_translation_of_i18n.yml new file mode 100644 index 00000000000..e383bab23d6 --- /dev/null +++ b/changelogs/unreleased/33442-supplement_traditional_chinese_in_hong_kong_translation_of_i18n.yml @@ -0,0 +1,4 @@ +--- +title: Supplement Traditional Chinese in Hong Kong translation of Project Page & Repository Page +merge_request: 11995 +author: Huang Tao diff --git a/changelogs/unreleased/33538-update-ci-dockerfile-now-that-chrome-headless-no-longer-in-beta.yml b/changelogs/unreleased/33538-update-ci-dockerfile-now-that-chrome-headless-no-longer-in-beta.yml new file mode 100644 index 00000000000..590472c0990 --- /dev/null +++ b/changelogs/unreleased/33538-update-ci-dockerfile-now-that-chrome-headless-no-longer-in-beta.yml @@ -0,0 +1,4 @@ +--- +title: Update QA Dockerfile to lock Chrome browser version +merge_request: 12071 +author: diff --git a/changelogs/unreleased/33561-supplement_bulgarian_translation_of_i18n.yml b/changelogs/unreleased/33561-supplement_bulgarian_translation_of_i18n.yml new file mode 100644 index 00000000000..4f2ba2e1de3 --- /dev/null +++ b/changelogs/unreleased/33561-supplement_bulgarian_translation_of_i18n.yml @@ -0,0 +1,4 @@ +--- +title: Supplement Bulgarian translation of Project Page & Repository Page +merge_request: 12083 +author: Lyubomir Vasilev diff --git a/changelogs/unreleased/33837-remove-trash-on-registry-image.yml b/changelogs/unreleased/33837-remove-trash-on-registry-image.yml new file mode 100644 index 00000000000..2d337f5e6e4 --- /dev/null +++ b/changelogs/unreleased/33837-remove-trash-on-registry-image.yml @@ -0,0 +1,4 @@ +--- +title: Remove registry image delete button if user cant delete it +merge_request: 12317 +author: Ivan Chernov diff --git a/changelogs/unreleased/33846-no-runner-for-admin.yml b/changelogs/unreleased/33846-no-runner-for-admin.yml new file mode 100644 index 00000000000..a2d46802c61 --- /dev/null +++ b/changelogs/unreleased/33846-no-runner-for-admin.yml @@ -0,0 +1,4 @@ +--- +title: Add explicit message when no runners on admin +merge_request: 12266 +author: Takuya Noguchi diff --git a/changelogs/unreleased/34052-store-mr-ref-fetched-in-database.yml b/changelogs/unreleased/34052-store-mr-ref-fetched-in-database.yml new file mode 100644 index 00000000000..4bacfca7551 --- /dev/null +++ b/changelogs/unreleased/34052-store-mr-ref-fetched-in-database.yml @@ -0,0 +1,4 @@ +--- +title: Store merge request ref_fetched status in the database +merge_request: 12424 +author: diff --git a/changelogs/unreleased/34207-remove-bin-ci-upgrade-rb.yml b/changelogs/unreleased/34207-remove-bin-ci-upgrade-rb.yml new file mode 100644 index 00000000000..4fa385c3c27 --- /dev/null +++ b/changelogs/unreleased/34207-remove-bin-ci-upgrade-rb.yml @@ -0,0 +1,4 @@ +--- +title: Remove bin/ci/upgrade.rb as not working all +merge_request: 12414 +author: Takuya Noguchi diff --git a/changelogs/unreleased/34286-add-esperanto-translations-for-cycle-analytics-and-project-and-repository-pages.yml b/changelogs/unreleased/34286-add-esperanto-translations-for-cycle-analytics-and-project-and-repository-pages.yml new file mode 100644 index 00000000000..af743f3e506 --- /dev/null +++ b/changelogs/unreleased/34286-add-esperanto-translations-for-cycle-analytics-and-project-and-repository-pages.yml @@ -0,0 +1,4 @@ +--- +title: Add Esperanto translations for Cycle Analytics, Project, and Repository pages +merge_request: 12442 +author: Huang Tao diff --git a/changelogs/unreleased/34289-drop-gfm-on-milestone-issuable-title.yml b/changelogs/unreleased/34289-drop-gfm-on-milestone-issuable-title.yml new file mode 100644 index 00000000000..42e906d24c6 --- /dev/null +++ b/changelogs/unreleased/34289-drop-gfm-on-milestone-issuable-title.yml @@ -0,0 +1,4 @@ +--- +title: Drop GFM support for issuable title on milestone for consistency and performance +merge_request: +author: Takuya Noguchi diff --git a/changelogs/unreleased/34309-drop-gfm-mr-ms.yml b/changelogs/unreleased/34309-drop-gfm-mr-ms.yml new file mode 100644 index 00000000000..07fe79e90ee --- /dev/null +++ b/changelogs/unreleased/34309-drop-gfm-mr-ms.yml @@ -0,0 +1,4 @@ +--- +title: Drop GFM support for the title of Milestone/MergeRequest in template +merge_request: 12451 +author: Takuya Noguchi diff --git a/changelogs/unreleased/UI-improvements-for-count-badges-and-permission-badges.yml b/changelogs/unreleased/UI-improvements-for-count-badges-and-permission-badges.yml deleted file mode 100644 index 374f643faa7..00000000000 --- a/changelogs/unreleased/UI-improvements-for-count-badges-and-permission-badges.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Count badges depend on translucent color to better adjust to different background - colors and permission badges now feature a pill shaped design similar to labels -merge_request: -author: diff --git a/changelogs/unreleased/adam-influxdb-hostname.yml b/changelogs/unreleased/adam-influxdb-hostname.yml deleted file mode 100644 index ab201ae7894..00000000000 --- a/changelogs/unreleased/adam-influxdb-hostname.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow GitLab instance to start when InfluxDB hostname cannot be resolved -merge_request: 11356 -author: diff --git a/changelogs/unreleased/add-index-for-auto_canceled_by_id-mysql.yml b/changelogs/unreleased/add-index-for-auto_canceled_by_id-mysql.yml deleted file mode 100644 index eac78e9ee1f..00000000000 --- a/changelogs/unreleased/add-index-for-auto_canceled_by_id-mysql.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add indices for auto_canceled_by_id for ci_pipelines and ci_builds on PostgreSQL -merge_request: 11034 -author: diff --git a/changelogs/unreleased/add-unicode-trace-feature-test.yml b/changelogs/unreleased/add-unicode-trace-feature-test.yml deleted file mode 100644 index 90c6a9afefc..00000000000 --- a/changelogs/unreleased/add-unicode-trace-feature-test.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add a feature test for Unicode trace -merge_request: 10736 -author: dosuken123 diff --git a/changelogs/unreleased/add_ability_to_cancel_attaching_file_and_redesign_attaching_files_ui.yml b/changelogs/unreleased/add_ability_to_cancel_attaching_file_and_redesign_attaching_files_ui.yml deleted file mode 100644 index fcf4efa2846..00000000000 --- a/changelogs/unreleased/add_ability_to_cancel_attaching_file_and_redesign_attaching_files_ui.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add an ability to cancel attaching file and redesign attaching files UI -merge_request: 9431 -author: blackst0ne diff --git a/changelogs/unreleased/aliyun-backup-provider.yml b/changelogs/unreleased/aliyun-backup-provider.yml deleted file mode 100644 index e7505e44a59..00000000000 --- a/changelogs/unreleased/aliyun-backup-provider.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add Aliyun OSS as the backup storage provider -merge_request: 9721 -author: Yuanfei Zhu diff --git a/changelogs/unreleased/allow-reporters-to-promote-group-labels.yml b/changelogs/unreleased/allow-reporters-to-promote-group-labels.yml deleted file mode 100644 index 2364ce6d068..00000000000 --- a/changelogs/unreleased/allow-reporters-to-promote-group-labels.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow reporters to promote project labels to group labels -merge_request: -author: diff --git a/changelogs/unreleased/allow_numeric_pages_domain.yml b/changelogs/unreleased/allow_numeric_pages_domain.yml deleted file mode 100644 index 10d9f26f88d..00000000000 --- a/changelogs/unreleased/allow_numeric_pages_domain.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow numeric pages domain -merge_request: 11550 -author: diff --git a/changelogs/unreleased/allow_numeric_values_in_gitlab_ci_yml.yml b/changelogs/unreleased/allow_numeric_values_in_gitlab_ci_yml.yml deleted file mode 100644 index 8c7fa53a18b..00000000000 --- a/changelogs/unreleased/allow_numeric_values_in_gitlab_ci_yml.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow numeric values in gitlab-ci.yml -merge_request: 10607 -author: blackst0ne diff --git a/changelogs/unreleased/artifacts-keyboard-shortcuts.yml b/changelogs/unreleased/artifacts-keyboard-shortcuts.yml deleted file mode 100644 index 69569504c4f..00000000000 --- a/changelogs/unreleased/artifacts-keyboard-shortcuts.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Enabled keyboard shortcuts on artifacts pages -merge_request: -author: diff --git a/changelogs/unreleased/auto-search-when-state-changed.yml b/changelogs/unreleased/auto-search-when-state-changed.yml deleted file mode 100644 index 2723beb8600..00000000000 --- a/changelogs/unreleased/auto-search-when-state-changed.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Perform filtered search when state tab is changed -merge_request: -author: diff --git a/changelogs/unreleased/bugfix-v3-deploy_keys-can_push.yml b/changelogs/unreleased/bugfix-v3-deploy_keys-can_push.yml deleted file mode 100644 index 0306663ac8d..00000000000 --- a/changelogs/unreleased/bugfix-v3-deploy_keys-can_push.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: "Fixed handling of the `can_push` attribute in the v3 deploy_keys api" -merge_request: 11607 -author: Richard Clamp diff --git a/changelogs/unreleased/bvl-rename-build-events-to-job-events.yml b/changelogs/unreleased/bvl-rename-build-events-to-job-events.yml deleted file mode 100644 index 2ce01a71361..00000000000 --- a/changelogs/unreleased/bvl-rename-build-events-to-job-events.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Rename build_events to job_events -merge_request: 11287 -author: diff --git a/changelogs/unreleased/bvl-translate-project-pages.yml b/changelogs/unreleased/bvl-translate-project-pages.yml deleted file mode 100644 index fb90aba08b4..00000000000 --- a/changelogs/unreleased/bvl-translate-project-pages.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Translate backend for Project & Repository pages -merge_request: 11183 -author: diff --git a/changelogs/unreleased/ce-31853-projects-shared-groups.yml b/changelogs/unreleased/ce-31853-projects-shared-groups.yml deleted file mode 100644 index ffa3aed682d..00000000000 --- a/changelogs/unreleased/ce-31853-projects-shared-groups.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Remove duplication for sharing projects with groups in project settings -merge_request: -author: diff --git a/changelogs/unreleased/ce-32623-browser-tooltip-commits-branch-list.yml b/changelogs/unreleased/ce-32623-browser-tooltip-commits-branch-list.yml deleted file mode 100644 index 93edafed699..00000000000 --- a/changelogs/unreleased/ce-32623-browser-tooltip-commits-branch-list.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Change order of commits ahead and behind on divergence graph for branch list - view -merge_request: -author: diff --git a/changelogs/unreleased/ci-build-pipeline-header-vue.yml b/changelogs/unreleased/ci-build-pipeline-header-vue.yml deleted file mode 100644 index 2bbff2fdd16..00000000000 --- a/changelogs/unreleased/ci-build-pipeline-header-vue.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Creates CI Header component for Pipelines and Jobs details pages -merge_request: -author: diff --git a/changelogs/unreleased/commit-comments-limited-width.yml b/changelogs/unreleased/commit-comments-limited-width.yml new file mode 100644 index 00000000000..97f50105495 --- /dev/null +++ b/changelogs/unreleased/commit-comments-limited-width.yml @@ -0,0 +1,4 @@ +--- +title: Limit commit & snippets comments width +merge_request: +author: diff --git a/changelogs/unreleased/disable-blocked-manual-actions.yml b/changelogs/unreleased/disable-blocked-manual-actions.yml deleted file mode 100644 index a640f61a7dd..00000000000 --- a/changelogs/unreleased/disable-blocked-manual-actions.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: disable blocked manual actions -merge_request: -author: diff --git a/changelogs/unreleased/dm-async-tree-readme.yml b/changelogs/unreleased/dm-async-tree-readme.yml deleted file mode 100644 index fb1cfeb210a..00000000000 --- a/changelogs/unreleased/dm-async-tree-readme.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Load tree readme asynchronously -merge_request: -author: diff --git a/changelogs/unreleased/dm-auxiliary-viewers.yml b/changelogs/unreleased/dm-auxiliary-viewers.yml deleted file mode 100644 index ba73a499115..00000000000 --- a/changelogs/unreleased/dm-auxiliary-viewers.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Display extra info about files on .gitlab-ci.yml, .gitlab/route-map.yml and - LICENSE blob pages -merge_request: -author: diff --git a/changelogs/unreleased/dm-comment-on-mr-commit-discussion.yml b/changelogs/unreleased/dm-comment-on-mr-commit-discussion.yml deleted file mode 100644 index 50db66c89ba..00000000000 --- a/changelogs/unreleased/dm-comment-on-mr-commit-discussion.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix replying to a commit discussion displayed in the context of an MR -merge_request: -author: diff --git a/changelogs/unreleased/dm-commit-row-browse-button.yml b/changelogs/unreleased/dm-commit-row-browse-button.yml new file mode 100644 index 00000000000..4240a7de5de --- /dev/null +++ b/changelogs/unreleased/dm-commit-row-browse-button.yml @@ -0,0 +1,4 @@ +--- +title: Fix inconsistent display of the "Browse files" button in the commit list +merge_request: +author: diff --git a/changelogs/unreleased/dm-consistent-commit-sha-style.yml b/changelogs/unreleased/dm-consistent-commit-sha-style.yml deleted file mode 100644 index b6dace34d9b..00000000000 --- a/changelogs/unreleased/dm-consistent-commit-sha-style.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Consistently use monospace font for commit SHAs and branch and tag names -merge_request: -author: diff --git a/changelogs/unreleased/dm-consistent-last-push-event.yml b/changelogs/unreleased/dm-consistent-last-push-event.yml deleted file mode 100644 index acc17cb4523..00000000000 --- a/changelogs/unreleased/dm-consistent-last-push-event.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Consistently display last push event widget -merge_request: -author: diff --git a/changelogs/unreleased/dm-copy-as-gfm-without-empty-elements.yml b/changelogs/unreleased/dm-copy-as-gfm-without-empty-elements.yml deleted file mode 100644 index 45a61320ff2..00000000000 --- a/changelogs/unreleased/dm-copy-as-gfm-without-empty-elements.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Don't copy empty elements that were not selected on purpose as GFM -merge_request: -author: diff --git a/changelogs/unreleased/dm-copy-gfm-when-parts-of-other-elements-are-selected.yml b/changelogs/unreleased/dm-copy-gfm-when-parts-of-other-elements-are-selected.yml deleted file mode 100644 index ae916c30ff8..00000000000 --- a/changelogs/unreleased/dm-copy-gfm-when-parts-of-other-elements-are-selected.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Copy as GFM even when parts of other elements are selected -merge_request: -author: diff --git a/changelogs/unreleased/dm-dependency-linker-gemfile.yml b/changelogs/unreleased/dm-dependency-linker-gemfile.yml deleted file mode 100644 index 2d4167a1be5..00000000000 --- a/changelogs/unreleased/dm-dependency-linker-gemfile.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Autolink package names in Gemfile -merge_request: -author: diff --git a/changelogs/unreleased/dm-discussions-n-plus-1.yml b/changelogs/unreleased/dm-discussions-n-plus-1.yml deleted file mode 100644 index b97e4344248..00000000000 --- a/changelogs/unreleased/dm-discussions-n-plus-1.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Resolve N+1 query issue with discussions -merge_request: -author: diff --git a/changelogs/unreleased/dm-emails-are-not-user-references.yml b/changelogs/unreleased/dm-emails-are-not-user-references.yml deleted file mode 100644 index fe55a75a88f..00000000000 --- a/changelogs/unreleased/dm-emails-are-not-user-references.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Don't match email addresses or foo@bar as user references -merge_request: -author: diff --git a/changelogs/unreleased/dm-fix-jump-button.yml b/changelogs/unreleased/dm-fix-jump-button.yml deleted file mode 100644 index 4cde354fa28..00000000000 --- a/changelogs/unreleased/dm-fix-jump-button.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix title of discussion jump button at top of page -merge_request: -author: diff --git a/changelogs/unreleased/dm-fix-parser-cache.yml b/changelogs/unreleased/dm-fix-parser-cache.yml deleted file mode 100644 index 31c163b7272..00000000000 --- a/changelogs/unreleased/dm-fix-parser-cache.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Don't return nil for missing objects from parser cache -merge_request: -author: diff --git a/changelogs/unreleased/dm-gitmodules-parsing.yml b/changelogs/unreleased/dm-gitmodules-parsing.yml deleted file mode 100644 index a7d755d6c4d..00000000000 --- a/changelogs/unreleased/dm-gitmodules-parsing.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Make .gitmodules parsing more resilient to syntax errors -merge_request: -author: diff --git a/changelogs/unreleased/dm-gravatar-username.yml b/changelogs/unreleased/dm-gravatar-username.yml deleted file mode 100644 index d50455061ec..00000000000 --- a/changelogs/unreleased/dm-gravatar-username.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add username parameter to gravatar URL -merge_request: -author: diff --git a/changelogs/unreleased/dm-group-page-name.yml b/changelogs/unreleased/dm-group-page-name.yml new file mode 100644 index 00000000000..233879364e3 --- /dev/null +++ b/changelogs/unreleased/dm-group-page-name.yml @@ -0,0 +1,4 @@ +--- +title: Show group name instead of path on group page +merge_request: +author: diff --git a/changelogs/unreleased/dm-more-dependency-linkers.yml b/changelogs/unreleased/dm-more-dependency-linkers.yml deleted file mode 100644 index 12d45e71e85..00000000000 --- a/changelogs/unreleased/dm-more-dependency-linkers.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Autolink package names in more dependency files -merge_request: -author: diff --git a/changelogs/unreleased/dm-oauth-config-for.yml b/changelogs/unreleased/dm-oauth-config-for.yml deleted file mode 100644 index 8fbbd45bb57..00000000000 --- a/changelogs/unreleased/dm-oauth-config-for.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Return nil when looking up config for unknown LDAP provider -merge_request: -author: diff --git a/changelogs/unreleased/dm-outdated-system-note.yml b/changelogs/unreleased/dm-outdated-system-note.yml deleted file mode 100644 index a1038a1051b..00000000000 --- a/changelogs/unreleased/dm-outdated-system-note.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add system note with link to diff comparison when MR discussion becomes outdated -merge_request: -author: diff --git a/changelogs/unreleased/dm-paste-code-inside-gfm-code.yml b/changelogs/unreleased/dm-paste-code-inside-gfm-code.yml deleted file mode 100644 index d078ca449a5..00000000000 --- a/changelogs/unreleased/dm-paste-code-inside-gfm-code.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Don't wrap pasted code when it's already inside code tags -merge_request: -author: diff --git a/changelogs/unreleased/dm-revert-mr-8427.yml b/changelogs/unreleased/dm-revert-mr-8427.yml deleted file mode 100644 index a91cff2e9cd..00000000000 --- a/changelogs/unreleased/dm-revert-mr-8427.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Revert 'New file from interface on existing branch' -merge_request: -author: diff --git a/changelogs/unreleased/dm-tree-last-commit.yml b/changelogs/unreleased/dm-tree-last-commit.yml deleted file mode 100644 index 50619fd6ef2..00000000000 --- a/changelogs/unreleased/dm-tree-last-commit.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Show last commit for current tree on tree page -merge_request: -author: diff --git a/changelogs/unreleased/dm-unnecessary-top-padding.yml b/changelogs/unreleased/dm-unnecessary-top-padding.yml new file mode 100644 index 00000000000..4557c06f8e7 --- /dev/null +++ b/changelogs/unreleased/dm-unnecessary-top-padding.yml @@ -0,0 +1,4 @@ +--- +title: Remove unnecessary top padding on group MR index +merge_request: +author: diff --git a/changelogs/unreleased/doc-gitaly-network.yml b/changelogs/unreleased/doc-gitaly-network.yml new file mode 100644 index 00000000000..5376d8d5096 --- /dev/null +++ b/changelogs/unreleased/doc-gitaly-network.yml @@ -0,0 +1,4 @@ +--- +title: Add option to run Gitaly on a remote server +merge_request: 12381 +author: diff --git a/changelogs/unreleased/document-foreign-keys.yml b/changelogs/unreleased/document-foreign-keys.yml deleted file mode 100644 index faa467e8185..00000000000 --- a/changelogs/unreleased/document-foreign-keys.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add documentation about adding foreign keys -merge_request: -author: diff --git a/changelogs/unreleased/dt-printing-to-api.yml b/changelogs/unreleased/dt-printing-to-api.yml new file mode 100644 index 00000000000..5253b57f21a --- /dev/null +++ b/changelogs/unreleased/dt-printing-to-api.yml @@ -0,0 +1,4 @@ +--- +title: Added printing_merge_requst_link_enabled to the API +merge_request: +author: David Turner <dturner@twosigma.com> diff --git a/changelogs/unreleased/dturner-username.yml b/changelogs/unreleased/dturner-username.yml deleted file mode 100644 index 09ba822ee65..00000000000 --- a/changelogs/unreleased/dturner-username.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: add username field to push webhook -merge_request: -author: David Turner diff --git a/changelogs/unreleased/dz-fix-submodule-subgroup.yml b/changelogs/unreleased/dz-fix-submodule-subgroup.yml deleted file mode 100644 index 20c7c9ce657..00000000000 --- a/changelogs/unreleased/dz-fix-submodule-subgroup.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix submodule link to then project under subgroup -merge_request: 11906 -author: diff --git a/changelogs/unreleased/dz-project-list-cache-key.yml b/changelogs/unreleased/dz-project-list-cache-key.yml deleted file mode 100644 index 9e4826e686a..00000000000 --- a/changelogs/unreleased/dz-project-list-cache-key.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Use route.cache_key for project list cache key -merge_request: 11325 -author: diff --git a/changelogs/unreleased/dz-rename-pipelines-settings-tab.yml b/changelogs/unreleased/dz-rename-pipelines-settings-tab.yml deleted file mode 100644 index 6a1232523bb..00000000000 --- a/changelogs/unreleased/dz-rename-pipelines-settings-tab.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Rename CI/CD Pipelines to Pipelines in the project settings -merge_request: -author: diff --git a/changelogs/unreleased/enable-auto-cancelling-by-default.yml b/changelogs/unreleased/enable-auto-cancelling-by-default.yml deleted file mode 100644 index 8b1659bf38b..00000000000 --- a/changelogs/unreleased/enable-auto-cancelling-by-default.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Enable cancelling non-HEAD pending pipelines by default for all projects -merge_request: 11023 -author: diff --git a/changelogs/unreleased/environment-detail-view.yml b/changelogs/unreleased/environment-detail-view.yml deleted file mode 100644 index c74f70ea86d..00000000000 --- a/changelogs/unreleased/environment-detail-view.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Make environment tables responsive -merge_request: -author: diff --git a/changelogs/unreleased/expand-backlog-closed-lists-issue-boards.yml b/changelogs/unreleased/expand-backlog-closed-lists-issue-boards.yml deleted file mode 100644 index 4796f8e918b..00000000000 --- a/changelogs/unreleased/expand-backlog-closed-lists-issue-boards.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Expand/collapse backlog & closed lists in issue boards -merge_request: -author: diff --git a/changelogs/unreleased/feature-flags-flipper.yml b/changelogs/unreleased/feature-flags-flipper.yml deleted file mode 100644 index 5be5c44166d..00000000000 --- a/changelogs/unreleased/feature-flags-flipper.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add feature toggles and API endpoints for admins -merge_request: 11747 -author: diff --git a/changelogs/unreleased/feature-gb-persist-pipeline-stages.yml b/changelogs/unreleased/feature-gb-persist-pipeline-stages.yml deleted file mode 100644 index 1404b342359..00000000000 --- a/changelogs/unreleased/feature-gb-persist-pipeline-stages.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Persist pipeline stages in the database -merge_request: 11790 -author: diff --git a/changelogs/unreleased/feature-print-go-version-in-env-info.yml b/changelogs/unreleased/feature-print-go-version-in-env-info.yml deleted file mode 100644 index 34c19b06eda..00000000000 --- a/changelogs/unreleased/feature-print-go-version-in-env-info.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Print Go version in rake gitlab:env:info -merge_request: 11241 -author: diff --git a/changelogs/unreleased/feature-rss-scoped-token.yml b/changelogs/unreleased/feature-rss-scoped-token.yml deleted file mode 100644 index 740d8778be2..00000000000 --- a/changelogs/unreleased/feature-rss-scoped-token.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Expose atom links with an RSS token instead of using the private token -merge_request: 11647 -author: Alexis Reigel diff --git a/changelogs/unreleased/fix-33991.yml b/changelogs/unreleased/fix-33991.yml new file mode 100644 index 00000000000..39732611b6e --- /dev/null +++ b/changelogs/unreleased/fix-33991.yml @@ -0,0 +1,4 @@ +--- +title: Users can subscribe to group labels on the group labels page +merge_request: +author: diff --git a/changelogs/unreleased/fix-counter-cache-for-acts-as-taggable.yml b/changelogs/unreleased/fix-counter-cache-for-acts-as-taggable.yml deleted file mode 100644 index e40668546c0..00000000000 --- a/changelogs/unreleased/fix-counter-cache-for-acts-as-taggable.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix counter cache for acts as taggable -merge_request: -author: diff --git a/changelogs/unreleased/fix-encoding-binary-issue.yml b/changelogs/unreleased/fix-encoding-binary-issue.yml deleted file mode 100644 index ac9aff64a88..00000000000 --- a/changelogs/unreleased/fix-encoding-binary-issue.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix binary encoding error on MR diffs -merge_request: 11929 -author: diff --git a/changelogs/unreleased/fix-gb-exclude-manual-actions-from-cancelable-jobs.yml b/changelogs/unreleased/fix-gb-exclude-manual-actions-from-cancelable-jobs.yml deleted file mode 100644 index a16fc775b5e..00000000000 --- a/changelogs/unreleased/fix-gb-exclude-manual-actions-from-cancelable-jobs.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Exclude manual actions when checking if pipeline can be canceled -merge_request: 11562 -author: diff --git a/changelogs/unreleased/fix-gb-fix-skipped-pipeline-with-allowed-to-fail-jobs.yml b/changelogs/unreleased/fix-gb-fix-skipped-pipeline-with-allowed-to-fail-jobs.yml new file mode 100644 index 00000000000..f59c6ecd90c --- /dev/null +++ b/changelogs/unreleased/fix-gb-fix-skipped-pipeline-with-allowed-to-fail-jobs.yml @@ -0,0 +1,4 @@ +--- +title: Fix CI/CD status in case there are only allowed to failed jobs in the pipeline +merge_request: 11166 +author: diff --git a/changelogs/unreleased/fix-github-clone-wiki.yml b/changelogs/unreleased/fix-github-clone-wiki.yml deleted file mode 100644 index eadd90e1390..00000000000 --- a/changelogs/unreleased/fix-github-clone-wiki.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Github - Fix token interpolation when cloning wiki repository -merge_request: -author: diff --git a/changelogs/unreleased/fix-github-import.yml b/changelogs/unreleased/fix-github-import.yml deleted file mode 100644 index 3a57152f7a8..00000000000 --- a/changelogs/unreleased/fix-github-import.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix token interpolation when setting the Github remote -merge_request: -author: diff --git a/changelogs/unreleased/fix-head-pipeline-for-commit-status.yml b/changelogs/unreleased/fix-head-pipeline-for-commit-status.yml new file mode 100644 index 00000000000..f12e7b53790 --- /dev/null +++ b/changelogs/unreleased/fix-head-pipeline-for-commit-status.yml @@ -0,0 +1,4 @@ +--- +title: Fix head pipeline stored in merge request for external pipelines +merge_request: 12478 +author: diff --git a/changelogs/unreleased/fix-missing-function-dropzone-input.yml b/changelogs/unreleased/fix-missing-function-dropzone-input.yml deleted file mode 100644 index d9dfc76faaf..00000000000 --- a/changelogs/unreleased/fix-missing-function-dropzone-input.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix for cut & pasted images not working -merge_request: -author: diff --git a/changelogs/unreleased/fix-n-plus-one-queries-for-user-access.yml b/changelogs/unreleased/fix-n-plus-one-queries-for-user-access.yml deleted file mode 100644 index c2671a96b83..00000000000 --- a/changelogs/unreleased/fix-n-plus-one-queries-for-user-access.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix N+1 queries for non-members in comment threads -merge_request: -author: diff --git a/changelogs/unreleased/fix-support-for-external-ci-services.yml b/changelogs/unreleased/fix-support-for-external-ci-services.yml deleted file mode 100644 index eecb4519259..00000000000 --- a/changelogs/unreleased/fix-support-for-external-ci-services.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix support for external CI services -merge_request: 11176 -author: diff --git a/changelogs/unreleased/fix_commits_page.yml b/changelogs/unreleased/fix_commits_page.yml deleted file mode 100644 index a2afaf6e626..00000000000 --- a/changelogs/unreleased/fix_commits_page.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix duplication of commits header on commits page -merge_request: 11006 -author: @blackst0ne diff --git a/changelogs/unreleased/fix_diff_line_comments.yml b/changelogs/unreleased/fix_diff_line_comments.yml deleted file mode 100644 index bdb0539b49d..00000000000 --- a/changelogs/unreleased/fix_diff_line_comments.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: 'Fix: A diff comment on a change at last line of a file shows as two comments - in discussion' -merge_request: -author: diff --git a/changelogs/unreleased/fixed-confidential-issue-bar.yml b/changelogs/unreleased/fixed-confidential-issue-bar.yml deleted file mode 100644 index 6a41590d0af..00000000000 --- a/changelogs/unreleased/fixed-confidential-issue-bar.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Make confidential issues more obviously confidential -merge_request: -author: diff --git a/changelogs/unreleased/gitaly-local-branches.yml b/changelogs/unreleased/gitaly-local-branches.yml deleted file mode 100644 index adcc0fa6280..00000000000 --- a/changelogs/unreleased/gitaly-local-branches.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add suport for find_local_branches GRPC from Gitaly -merge_request: 10059 -author: diff --git a/changelogs/unreleased/gitaly-opt-out.yml b/changelogs/unreleased/gitaly-opt-out.yml deleted file mode 100644 index 2f89e0bfc9a..00000000000 --- a/changelogs/unreleased/gitaly-opt-out.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Enable Gitaly by default in installations from source -merge_request: 11796 -author: diff --git a/changelogs/unreleased/instrument-merge-request-diff-load-commits.yml b/changelogs/unreleased/instrument-merge-request-diff-load-commits.yml deleted file mode 100644 index 916b182a48b..00000000000 --- a/changelogs/unreleased/instrument-merge-request-diff-load-commits.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Instrument MergeRequestDiff#load_commits -merge_request: -author: diff --git a/changelogs/unreleased/introduce-source-to-pipelines.yml b/changelogs/unreleased/introduce-source-to-pipelines.yml deleted file mode 100644 index 7898bd31b39..00000000000 --- a/changelogs/unreleased/introduce-source-to-pipelines.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Introduce source to Pipeline entity -merge_request: -author: diff --git a/changelogs/unreleased/issuable-form-create-label-sub-groups.yml b/changelogs/unreleased/issuable-form-create-label-sub-groups.yml deleted file mode 100644 index 54b818d6d5e..00000000000 --- a/changelogs/unreleased/issuable-form-create-label-sub-groups.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fixed create new label form in issue form not working for sub-group projects -merge_request: -author: diff --git a/changelogs/unreleased/issue-23254.yml b/changelogs/unreleased/issue-23254.yml deleted file mode 100644 index 568a7a41c30..00000000000 --- a/changelogs/unreleased/issue-23254.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fixed style on unsubscribe page -merge_request: -author: Gustav Ernberg diff --git a/changelogs/unreleased/issue-edit-inline.yml b/changelogs/unreleased/issue-edit-inline.yml deleted file mode 100644 index db03d1bdac4..00000000000 --- a/changelogs/unreleased/issue-edit-inline.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Enables inline editing for an issues title & description -merge_request: -author: diff --git a/changelogs/unreleased/issue-form-multiple-line-markdown.yml b/changelogs/unreleased/issue-form-multiple-line-markdown.yml new file mode 100644 index 00000000000..23128f346bc --- /dev/null +++ b/changelogs/unreleased/issue-form-multiple-line-markdown.yml @@ -0,0 +1,4 @@ +--- +title: Fixed multi-line markdown tooltip buttons in issue edit form +merge_request: +author: diff --git a/changelogs/unreleased/issue-template-reproduce-in-example-project.yml b/changelogs/unreleased/issue-template-reproduce-in-example-project.yml deleted file mode 100644 index 8116007b459..00000000000 --- a/changelogs/unreleased/issue-template-reproduce-in-example-project.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Ask for an example project for bug reports -merge_request: -author: diff --git a/changelogs/unreleased/issue-templates-summary-lines.yml b/changelogs/unreleased/issue-templates-summary-lines.yml deleted file mode 100644 index 0c8c3d884ce..00000000000 --- a/changelogs/unreleased/issue-templates-summary-lines.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add summary lines for collapsed details in the bug report template -merge_request: -author: diff --git a/changelogs/unreleased/issue_19262.yml b/changelogs/unreleased/issue_19262.yml deleted file mode 100644 index 7bcbc647fcb..00000000000 --- a/changelogs/unreleased/issue_19262.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Prevent commits from upstream repositories to be re-processed by forks -merge_request: -author: diff --git a/changelogs/unreleased/issue_27166_2.yml b/changelogs/unreleased/issue_27166_2.yml deleted file mode 100644 index 9b9906e03dd..00000000000 --- a/changelogs/unreleased/issue_27166_2.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Avoid repeated queries for pipeline builds on merge requests -merge_request: -author: diff --git a/changelogs/unreleased/issue_27168_2.yml b/changelogs/unreleased/issue_27168_2.yml deleted file mode 100644 index c67692493e0..00000000000 --- a/changelogs/unreleased/issue_27168_2.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Preloads head pipeline for merge request collection -merge_request: -author: diff --git a/changelogs/unreleased/issue_32225_2.yml b/changelogs/unreleased/issue_32225_2.yml deleted file mode 100644 index 320b9fe00b8..00000000000 --- a/changelogs/unreleased/issue_32225_2.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Handle head pipeline when creating merge requests -merge_request: -author: diff --git a/changelogs/unreleased/jouve-gitlab-ce-admin_keys.yml b/changelogs/unreleased/jouve-gitlab-ce-admin_keys.yml deleted file mode 100644 index df4de9f4e21..00000000000 --- a/changelogs/unreleased/jouve-gitlab-ce-admin_keys.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Redirect to user's keys index instead of user's index after a key is deleted - in the admin -merge_request: 10227 -author: Cyril Jouve diff --git a/changelogs/unreleased/mabes-gitlab-ce-bypass-auto-login.yml b/changelogs/unreleased/mabes-gitlab-ce-bypass-auto-login.yml deleted file mode 100644 index a321ed9d7d8..00000000000 --- a/changelogs/unreleased/mabes-gitlab-ce-bypass-auto-login.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow manual bypass of auto_sign_in_with_provider with a new param -merge_request: 10187 -author: Maxime Besson diff --git a/changelogs/unreleased/migrate-artifacts-to-a-new-path.yml b/changelogs/unreleased/migrate-artifacts-to-a-new-path.yml deleted file mode 100644 index bd022a3a91b..00000000000 --- a/changelogs/unreleased/migrate-artifacts-to-a-new-path.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Migrate artifacts to a new path -merge_request: -author: diff --git a/changelogs/unreleased/mk-fix-git-over-http-rejections.yml b/changelogs/unreleased/mk-fix-git-over-http-rejections.yml deleted file mode 100644 index e75740e913f..00000000000 --- a/changelogs/unreleased/mk-fix-git-over-http-rejections.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix Git-over-HTTP error statuses and improve error messages -merge_request: 11398 -author: diff --git a/changelogs/unreleased/mrchrisw-catch-openssl.yml b/changelogs/unreleased/mrchrisw-catch-openssl.yml deleted file mode 100644 index a8b433fb0cd..00000000000 --- a/changelogs/unreleased/mrchrisw-catch-openssl.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Rescue OpenSSL::SSL::SSLError in JiraService & IssueTrackerService -merge_request: -author: diff --git a/changelogs/unreleased/omega-submodules.yml b/changelogs/unreleased/omega-submodules.yml deleted file mode 100644 index 1488eb72174..00000000000 --- a/changelogs/unreleased/omega-submodules.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: 'Repository browser: handle in-repository submodule urls' -merge_request: -author: David Turner diff --git a/changelogs/unreleased/pat-alert-when-signin-disabled.yml b/changelogs/unreleased/pat-alert-when-signin-disabled.yml new file mode 100644 index 00000000000..dca3670aeb7 --- /dev/null +++ b/changelogs/unreleased/pat-alert-when-signin-disabled.yml @@ -0,0 +1,4 @@ +--- +title: Provide hint to create a personal access token for Git over HTTP +merge_request: 12105 +author: Robin Bobbitt diff --git a/changelogs/unreleased/polish-sidebar-toggle.yml b/changelogs/unreleased/polish-sidebar-toggle.yml new file mode 100644 index 00000000000..41ec567fc52 --- /dev/null +++ b/changelogs/unreleased/polish-sidebar-toggle.yml @@ -0,0 +1,4 @@ +--- +title: Remove unused space in sidebar todo toggle when not signed in +merge_request: +author: diff --git a/changelogs/unreleased/prevent-project-transfer.yml b/changelogs/unreleased/prevent-project-transfer.yml deleted file mode 100644 index a5c74676aab..00000000000 --- a/changelogs/unreleased/prevent-project-transfer.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Prevent project transfers if a new group is not selected -merge_request: -author: diff --git a/changelogs/unreleased/project-readme-limited-width.yml b/changelogs/unreleased/project-readme-limited-width.yml new file mode 100644 index 00000000000..17d87a5691e --- /dev/null +++ b/changelogs/unreleased/project-readme-limited-width.yml @@ -0,0 +1,4 @@ +--- +title: Limit the width of the projects README text +merge_request: +author: diff --git a/changelogs/unreleased/projects-api-import-status.yml b/changelogs/unreleased/projects-api-import-status.yml deleted file mode 100644 index 06603c0adec..00000000000 --- a/changelogs/unreleased/projects-api-import-status.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Expose import_status in Projects API -merge_request: 11851 -author: Robin Bobbitt diff --git a/changelogs/unreleased/protected-branches-no-one-merge.yml b/changelogs/unreleased/protected-branches-no-one-merge.yml deleted file mode 100644 index 52d93793f3d..00000000000 --- a/changelogs/unreleased/protected-branches-no-one-merge.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow 'no one' as an option for allowed to merge on a procted branch -merge_request: -author: diff --git a/changelogs/unreleased/reduce-sidekiq-wait-timings.yml b/changelogs/unreleased/reduce-sidekiq-wait-timings.yml deleted file mode 100644 index 4d23accc82e..00000000000 --- a/changelogs/unreleased/reduce-sidekiq-wait-timings.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Reduce time spent waiting for certain Sidekiq jobs to complete -merge_request: -author: diff --git a/changelogs/unreleased/remove-old-isobject.yml b/changelogs/unreleased/remove-old-isobject.yml deleted file mode 100644 index 67b18642253..00000000000 --- a/changelogs/unreleased/remove-old-isobject.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Remove unused code and uses underscore -merge_request: -author: diff --git a/changelogs/unreleased/rename-builds-controller.yml b/changelogs/unreleased/rename-builds-controller.yml deleted file mode 100644 index 7f6872ccf95..00000000000 --- a/changelogs/unreleased/rename-builds-controller.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Change /builds in the URL to /-/jobs. Backward URLs were also added -merge_request: 11407 -author: diff --git a/changelogs/unreleased/replace_spinach_spec_profile_notifications-feature.yml b/changelogs/unreleased/replace_spinach_spec_profile_notifications-feature.yml new file mode 100644 index 00000000000..38227ebfa7a --- /dev/null +++ b/changelogs/unreleased/replace_spinach_spec_profile_notifications-feature.yml @@ -0,0 +1,4 @@ +--- +title: Replace 'profile/notifications.feature' spinach test with an rspec analog +merge_request: 12345 +author: @blackst0ne diff --git a/changelogs/unreleased/replase_spinach_spec_create-feature.yml b/changelogs/unreleased/replase_spinach_spec_create-feature.yml new file mode 100644 index 00000000000..0613d195d56 --- /dev/null +++ b/changelogs/unreleased/replase_spinach_spec_create-feature.yml @@ -0,0 +1,4 @@ +--- +title: Replace 'create.feature' spinach test with an rspec analog +merge_request: 12343 +author: @blackst0ne diff --git a/changelogs/unreleased/rework-authorizations-performance.yml b/changelogs/unreleased/rework-authorizations-performance.yml deleted file mode 100644 index f64257a6f56..00000000000 --- a/changelogs/unreleased/rework-authorizations-performance.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: > - Project authorizations are calculated much faster when using PostgreSQL, and - nested groups support for MySQL has been removed -merge_request: 10885 -author: diff --git a/changelogs/unreleased/search-restrict-projects-to-group.yml b/changelogs/unreleased/search-restrict-projects-to-group.yml deleted file mode 100644 index ac134bc5bce..00000000000 --- a/changelogs/unreleased/search-restrict-projects-to-group.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Restricts search projects dropdown to group projects when group is selected -merge_request: -author: diff --git a/changelogs/unreleased/sh-fix-container-registry-s3-redirects.yml b/changelogs/unreleased/sh-fix-container-registry-s3-redirects.yml deleted file mode 100644 index 1e783811b66..00000000000 --- a/changelogs/unreleased/sh-fix-container-registry-s3-redirects.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Properly handle container registry redirects to fix metadata stored on a S3 backend -merge_request: -author: diff --git a/changelogs/unreleased/sh-fix-refactor-uploader-work-dir.yml b/changelogs/unreleased/sh-fix-refactor-uploader-work-dir.yml deleted file mode 100644 index 255608bd89a..00000000000 --- a/changelogs/unreleased/sh-fix-refactor-uploader-work-dir.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Set artifact working directory to be in the destination store to prevent unnecessary I/O -merge_request: -author: diff --git a/changelogs/unreleased/sync-email-from-omniauth.yml b/changelogs/unreleased/sync-email-from-omniauth.yml deleted file mode 100644 index ed14a95a5f1..00000000000 --- a/changelogs/unreleased/sync-email-from-omniauth.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Sync email address from specified omniauth provider -merge_request: 11268 -author: Robin Bobbitt diff --git a/changelogs/unreleased/task-list-2.yml b/changelogs/unreleased/task-list-2.yml deleted file mode 100644 index cbae8178081..00000000000 --- a/changelogs/unreleased/task-list-2.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Update task_list to version 2.0.0 -merge_request: 11525 -author: Jared Deckard <jared.deckard@gmail.com> diff --git a/changelogs/unreleased/tc-cache-trackable-attributes.yml b/changelogs/unreleased/tc-cache-trackable-attributes.yml deleted file mode 100644 index 4a2cf50893a..00000000000 --- a/changelogs/unreleased/tc-cache-trackable-attributes.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: "Limit User's trackable attributes, like `current_sign_in_at`, to update at most once/hour" -merge_request: 11053 -author: diff --git a/changelogs/unreleased/tc-clean-pending-delete-projects.yml b/changelogs/unreleased/tc-clean-pending-delete-projects.yml deleted file mode 100644 index 31b43999c31..00000000000 --- a/changelogs/unreleased/tc-clean-pending-delete-projects.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add post-deploy migration to clean up projects in `pending_delete` state -merge_request: 11044 -author: diff --git a/changelogs/unreleased/tc-improve-project-api-perf.yml b/changelogs/unreleased/tc-improve-project-api-perf.yml deleted file mode 100644 index 7e88466c058..00000000000 --- a/changelogs/unreleased/tc-improve-project-api-perf.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Improve performance of ProjectFinder used in /projects API endpoint -merge_request: 11666 -author: diff --git a/changelogs/unreleased/tc-refactor-projects-finder-init-collection.yml b/changelogs/unreleased/tc-refactor-projects-finder-init-collection.yml new file mode 100644 index 00000000000..7bcbd6468c7 --- /dev/null +++ b/changelogs/unreleased/tc-refactor-projects-finder-init-collection.yml @@ -0,0 +1,4 @@ +--- +title: Add User#full_private_access? to check if user has access to all private groups & projects +merge_request: 12373 +author: diff --git a/changelogs/unreleased/up-arrow-focus-discussion-comment.yml b/changelogs/unreleased/up-arrow-focus-discussion-comment.yml deleted file mode 100644 index 5457dab6d3d..00000000000 --- a/changelogs/unreleased/up-arrow-focus-discussion-comment.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix up arrow not editing last discussion comment -merge_request: -author: diff --git a/changelogs/unreleased/update-admin-health-page.yml b/changelogs/unreleased/update-admin-health-page.yml deleted file mode 100644 index 51aa6682b49..00000000000 --- a/changelogs/unreleased/update-admin-health-page.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Added application readiness endpoints to the monitoring health check admin - view -merge_request: -author: diff --git a/changelogs/unreleased/update_bootsnap_1-1-1.yml b/changelogs/unreleased/update_bootsnap_1-1-1.yml new file mode 100644 index 00000000000..9ecfe4b60c8 --- /dev/null +++ b/changelogs/unreleased/update_bootsnap_1-1-1.yml @@ -0,0 +1,4 @@ +--- +title: Bump bootsnap to 1.1.1 +merge_request: 12425 +author: @blackst0ne diff --git a/changelogs/unreleased/use_relative_path_for_project_avatars.yml b/changelogs/unreleased/use_relative_path_for_project_avatars.yml deleted file mode 100644 index e3d0c0e1187..00000000000 --- a/changelogs/unreleased/use_relative_path_for_project_avatars.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Use relative paths for group/project/user avatars -merge_request: 11001 -author: blackst0ne diff --git a/changelogs/unreleased/wait-for-ajax-handling-all-js-requests.yml b/changelogs/unreleased/wait-for-ajax-handling-all-js-requests.yml deleted file mode 100644 index 14aebe792c2..00000000000 --- a/changelogs/unreleased/wait-for-ajax-handling-all-js-requests.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Use wait_for_requests for both ajax and Vue requests -merge_request: -author: diff --git a/changelogs/unreleased/winh-current-user-filter.yml b/changelogs/unreleased/winh-current-user-filter.yml deleted file mode 100644 index e5409827b31..00000000000 --- a/changelogs/unreleased/winh-current-user-filter.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Show current user immediately in issuable filters -merge_request: 11630 -author: diff --git a/changelogs/unreleased/winh-pipeline-author-link.yml b/changelogs/unreleased/winh-pipeline-author-link.yml deleted file mode 100644 index 1b903d1e357..00000000000 --- a/changelogs/unreleased/winh-pipeline-author-link.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Link to commit author user page from pipelines -merge_request: 11100 -author: diff --git a/changelogs/unreleased/winh-styled-people-search-bar.yml b/changelogs/unreleased/winh-styled-people-search-bar.yml deleted file mode 100644 index a088af37d8d..00000000000 --- a/changelogs/unreleased/winh-styled-people-search-bar.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Style people in issuable search bar -merge_request: 11402 -author: diff --git a/changelogs/unreleased/zj-clean-up-ci-variables-table.yml b/changelogs/unreleased/zj-clean-up-ci-variables-table.yml deleted file mode 100644 index ea2db40d590..00000000000 --- a/changelogs/unreleased/zj-clean-up-ci-variables-table.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Cleanup ci_variables schema and table -merge_request: -author: diff --git a/changelogs/unreleased/zj-faster-charts-page.yml b/changelogs/unreleased/zj-faster-charts-page.yml new file mode 100644 index 00000000000..9afcf111328 --- /dev/null +++ b/changelogs/unreleased/zj-faster-charts-page.yml @@ -0,0 +1,4 @@ +--- +title: Improve performance of the pipeline charts page +merge_request: 12378 +author: diff --git a/changelogs/unreleased/zj-i18n-pipeline-schedules.yml b/changelogs/unreleased/zj-i18n-pipeline-schedules.yml deleted file mode 100644 index 51c82a16359..00000000000 --- a/changelogs/unreleased/zj-i18n-pipeline-schedules.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow translation of Pipeline Schedules -merge_request: -author: diff --git a/changelogs/unreleased/zj-job-view-goes-real-time.yml b/changelogs/unreleased/zj-job-view-goes-real-time.yml deleted file mode 100644 index 376c9dfa65f..00000000000 --- a/changelogs/unreleased/zj-job-view-goes-real-time.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Job details page update real time -merge_request: 11651 -author: diff --git a/changelogs/unreleased/zj-pipeline-schedule-owner.yml b/changelogs/unreleased/zj-pipeline-schedule-owner.yml deleted file mode 100644 index be704e173ab..00000000000 --- a/changelogs/unreleased/zj-pipeline-schedule-owner.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add foreign key for pipeline schedule owner -merge_request: 11233 -author: diff --git a/changelogs/unreleased/zj-prom-pipeline-count.yml b/changelogs/unreleased/zj-prom-pipeline-count.yml deleted file mode 100644 index 191e4f2f949..00000000000 --- a/changelogs/unreleased/zj-prom-pipeline-count.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add prometheus metrics on pipeline creation -merge_request: -author: diff --git a/changelogs/unreleased/zj-raise-etag-route-regex-miss.yml b/changelogs/unreleased/zj-raise-etag-route-regex-miss.yml deleted file mode 100644 index 57a5f4e44c0..00000000000 --- a/changelogs/unreleased/zj-raise-etag-route-regex-miss.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Fix etag route not being a match for environments -merge_request: -author: diff --git a/changelogs/unreleased/zj-read-registry-pat.yml b/changelogs/unreleased/zj-read-registry-pat.yml deleted file mode 100644 index d36159bbdf5..00000000000 --- a/changelogs/unreleased/zj-read-registry-pat.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Allow pulling of container images using personal access tokens -merge_request: 11845 -author: diff --git a/changelogs/unreleased/zj-realtime-env-list.yml b/changelogs/unreleased/zj-realtime-env-list.yml deleted file mode 100644 index 6460d17edc9..00000000000 --- a/changelogs/unreleased/zj-realtime-env-list.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Make environment table realtime -merge_request: 11333 -author: diff --git a/changelogs/unreleased/zj-review-apps-usage-data.yml b/changelogs/unreleased/zj-review-apps-usage-data.yml new file mode 100644 index 00000000000..7d224d0fc32 --- /dev/null +++ b/changelogs/unreleased/zj-review-apps-usage-data.yml @@ -0,0 +1,4 @@ +--- +title: Add review apps to usage metrics +merge_request: 12185 +author: diff --git a/changelogs/unreleased/zj-sort-env-folders.yml b/changelogs/unreleased/zj-sort-env-folders.yml deleted file mode 100644 index b3ca97aef94..00000000000 --- a/changelogs/unreleased/zj-sort-env-folders.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Sort folder for environments -merge_request: -author: diff --git a/config/application.rb b/config/application.rb index 8bbecf3ed0f..3f39170a123 100644 --- a/config/application.rb +++ b/config/application.rb @@ -109,6 +109,8 @@ module Gitlab config.assets.precompile << "lib/ace.js" config.assets.precompile << "vendor/assets/fonts/*" config.assets.precompile << "test.css" + config.assets.precompile << "new_nav.css" + config.assets.precompile << "new_sidebar.css" # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' diff --git a/config/boot.rb b/config/boot.rb index db5ab918021..02baeab29ab 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -5,17 +5,13 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) -# set default directory for multiproces metrics gathering -ENV['prometheus_multiproc_dir'] ||= 'tmp/prometheus_multiproc_dir' +begin + require 'bootsnap/setup' +rescue SystemCallError => exception + $stderr.puts "WARNING: Bootsnap failed to setup: #{exception.message}" +end -# Default Bootsnap configuration from https://github.com/Shopify/bootsnap#usage -require 'bootsnap' -Bootsnap.setup( - cache_dir: 'tmp/cache', - development_mode: ENV['RAILS_ENV'] == 'development', - load_path_cache: true, - autoload_paths_cache: true, - disable_trace: false, - compile_cache_iseq: true, - compile_cache_yaml: true -) +# set default directory for multiproces metrics gathering +if ENV['RAILS_ENV'] == 'development' || ENV['RAILS_ENV'] == 'test' + ENV['prometheus_multiproc_dir'] ||= 'tmp/prometheus_multiproc_dir' +end diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 0b33783869b..43a8c0078ca 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -454,6 +454,10 @@ production: &base # introduced in 9.0). Eventually Gitaly use will become mandatory and # this option will disappear. enabled: true + # Default Gitaly authentication token. Can be overriden per storage. Can + # be left blank when Gitaly is running locally on a Unix socket, which + # is the normal way to deploy Gitaly. + token: # # 4. Advanced settings @@ -469,6 +473,7 @@ production: &base default: path: /home/git/repositories/ gitaly_address: unix:/home/git/gitlab/tmp/sockets/private/gitaly.socket # TCP connections are supported too (e.g. tcp://host:port) + # gitaly_token: 'special token' # Optional: override global gitaly.token for this storage. ## Backup settings backup: @@ -594,6 +599,7 @@ test: gitaly_address: unix:tmp/tests/gitaly/gitaly.socket gitaly: enabled: true + token: secret backup: path: tmp/tests/backups gitlab_shell: diff --git a/config/initializers/8_metrics.rb b/config/initializers/8_metrics.rb index 508b886d6a0..a0a63ddf8f0 100644 --- a/config/initializers/8_metrics.rb +++ b/config/initializers/8_metrics.rb @@ -154,8 +154,8 @@ if Gitlab::Metrics.enabled? ActiveRecord::Querying.public_instance_methods(false).map(&:to_s) ) - Gitlab::Metrics::Instrumentation. - instrument_class_hierarchy(ActiveRecord::Base) do |klass, method| + Gitlab::Metrics::Instrumentation + .instrument_class_hierarchy(ActiveRecord::Base) do |klass, method| # Instrumenting the ApplicationSetting class can lead to an infinite # loop. Since the data is cached any way we don't really need to # instrument it. diff --git a/config/initializers/active_record_data_types.rb b/config/initializers/active_record_data_types.rb index beb97c6fce0..fef591c397d 100644 --- a/config/initializers/active_record_data_types.rb +++ b/config/initializers/active_record_data_types.rb @@ -4,21 +4,78 @@ if Gitlab::Database.postgresql? require 'active_record/connection_adapters/postgresql_adapter' - module ActiveRecord - module ConnectionAdapters - class PostgreSQLAdapter - NATIVE_DATABASE_TYPES.merge!(datetime_with_timezone: { name: 'timestamptz' }) + module ActiveRecord::ConnectionAdapters::PostgreSQL::OID + # Add the class `DateTimeWithTimeZone` so we can map `timestamptz` to it. + class DateTimeWithTimeZone < DateTime + def type + :datetime_with_timezone end end end + + module RegisterDateTimeWithTimeZone + # Run original `initialize_type_map` and then register `timestamptz` as a + # `DateTimeWithTimeZone`. + # + # Apparently it does not matter that the original `initialize_type_map` + # aliases `timestamptz` to `timestamp`. + # + # When schema dumping, `timestamptz` columns will be output as + # `t.datetime_with_timezone`. + def initialize_type_map(mapping) + super mapping + + mapping.register_type 'timestamptz' do |_, _, sql_type| + precision = extract_precision(sql_type) + ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::DateTimeWithTimeZone.new(precision: precision) + end + end + end + + class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter + prepend RegisterDateTimeWithTimeZone + + # Add column type `datetime_with_timezone` so we can do this in + # migrations: + # + # add_column(:users, :datetime_with_timezone) + # + NATIVE_DATABASE_TYPES[:datetime_with_timezone] = { name: 'timestamptz' } + end elsif Gitlab::Database.mysql? require 'active_record/connection_adapters/mysql2_adapter' - module ActiveRecord - module ConnectionAdapters - class AbstractMysqlAdapter - NATIVE_DATABASE_TYPES.merge!(datetime_with_timezone: { name: 'timestamp' }) + module RegisterDateTimeWithTimeZone + # Run original `initialize_type_map` and then register `timestamp` as a + # `MysqlDateTimeWithTimeZone`. + # + # When schema dumping, `timestamp` columns will be output as + # `t.datetime_with_timezone`. + def initialize_type_map(mapping) + super mapping + + mapping.register_type(%r(timestamp)i) do |sql_type| + precision = extract_precision(sql_type) + ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::MysqlDateTimeWithTimeZone.new(precision: precision) end end end + + class ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter + prepend RegisterDateTimeWithTimeZone + + # Add the class `DateTimeWithTimeZone` so we can map `timestamp` to it. + class MysqlDateTimeWithTimeZone < MysqlDateTime + def type + :datetime_with_timezone + end + end + + # Add column type `datetime_with_timezone` so we can do this in + # migrations: + # + # add_column(:users, :datetime_with_timezone) + # + NATIVE_DATABASE_TYPES[:datetime_with_timezone] = { name: 'timestamp' } + end end diff --git a/config/initializers/active_record_table_definition.rb b/config/initializers/active_record_table_definition.rb index 4f59e35f4da..8e3a1c7a62f 100644 --- a/config/initializers/active_record_table_definition.rb +++ b/config/initializers/active_record_table_definition.rb @@ -3,15 +3,15 @@ require 'active_record/connection_adapters/abstract/schema_definitions' -# Appends columns `created_at` and `updated_at` to a table. -# -# It is used in table creation like: -# create_table 'users' do |t| -# t.timestamps_with_timezone -# end module ActiveRecord module ConnectionAdapters class TableDefinition + # Appends columns `created_at` and `updated_at` to a table. + # + # It is used in table creation like: + # create_table 'users' do |t| + # t.timestamps_with_timezone + # end def timestamps_with_timezone(**options) options[:null] = false if options[:null].nil? @@ -19,6 +19,16 @@ module ActiveRecord column(column_name, :datetime_with_timezone, options) end end + + # Adds specified column with appropriate timestamp type + # + # It is used in table creation like: + # create_table 'users' do |t| + # t.datetime_with_timezone :did_something_at + # end + def datetime_with_timezone(column_name, **options) + column(column_name, :datetime_with_timezone, options) + end end end end diff --git a/config/initializers/bootstrap_form.rb b/config/initializers/bootstrap_form.rb new file mode 100644 index 00000000000..11171b38a85 --- /dev/null +++ b/config/initializers/bootstrap_form.rb @@ -0,0 +1,7 @@ +module BootstrapFormBuilderCustomization + def label_class + "label-light" + end +end + +BootstrapForm::FormBuilder.prepend(BootstrapFormBuilderCustomization) diff --git a/config/initializers/flipper.rb b/config/initializers/flipper.rb new file mode 100644 index 00000000000..0fee832788d --- /dev/null +++ b/config/initializers/flipper.rb @@ -0,0 +1,4 @@ +require 'flipper/middleware/memoizer' + +Rails.application.config.middleware.use Flipper::Middleware::Memoizer, + lambda { Feature.flipper } diff --git a/config/karma.config.js b/config/karma.config.js index 5911a9a7e10..2f571978e08 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -66,5 +66,14 @@ module.exports = function(config) { karmaConfig.customLaunchers.ChromeHeadlessCustom.flags.push('--enable-logging', '--v=1'); } + if (process.env.DEBUG) { + karmaConfig.logLevel = config.LOG_DEBUG; + process.env.CHROME_LOG_FILE = process.env.CHROME_LOG_FILE || 'chrome_debug.log'; + } + + if (process.env.CHROME_LOG_FILE) { + karmaConfig.customLaunchers.ChromeHeadlessCustom.flags.push('--enable-logging', '--v=1'); + } + config.set(karmaConfig); }; diff --git a/config/prometheus/additional_metrics.yml b/config/prometheus/additional_metrics.yml new file mode 100644 index 00000000000..daecde49570 --- /dev/null +++ b/config/prometheus/additional_metrics.yml @@ -0,0 +1,32 @@ +- group: Kubernetes + priority: 1 + metrics: + - title: "Memory usage" + y_label: "Values" + required_metrics: + - container_memory_usage_bytes + weight: 1 + queries: + - query_range: 'avg(container_memory_usage_bytes{%{environment_filter}}) / 2^20' + label: Container memory + unit: MiB + - title: "Current memory usage" + required_metrics: + - container_memory_usage_bytes + weight: 1 + queries: + - query: 'avg(container_memory_usage_bytes{%{environment_filter}}) / 2^20' + display_empty: false + unit: MiB + - title: "CPU usage" + required_metrics: + - container_cpu_usage_seconds_total + weight: 1 + queries: + - query_range: 'avg(rate(container_cpu_usage_seconds_total{%{environment_filter}}[2m])) * 100' + - title: "Current CPU usage" + required_metrics: + - container_cpu_usage_seconds_total + weight: 1 + queries: + - query: 'avg(rate(container_cpu_usage_seconds_total{%{environment_filter}}[2m])) * 100' diff --git a/config/routes/project.rb b/config/routes/project.rb index f95cc3101d3..19e18c733b1 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -73,6 +73,10 @@ constraints(ProjectUrlConstrainer.new) do resource :mattermost, only: [:new, :create] + namespace :prometheus do + get :active_metrics + end + resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :new, :create, :edit, :update] do member do put :enable @@ -153,6 +157,7 @@ constraints(ProjectUrlConstrainer.new) do post :stop get :terminal get :metrics + get :additional_metrics get '/terminal.ws/authorize', to: 'environments#terminal_websocket_authorize', constraints: { format: nil } end @@ -163,6 +168,7 @@ constraints(ProjectUrlConstrainer.new) do resources :deployments, only: [:index] do member do get :metrics + get :additional_metrics end end end diff --git a/config/webpack.config.js b/config/webpack.config.js index fb91ffef7e7..2e8c94655c1 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -55,6 +55,7 @@ var config = { pipelines: './pipelines/pipelines_bundle.js', pipelines_details: './pipelines/pipeline_details_bundle.js', profile: './profile/profile_bundle.js', + prometheus_metrics: './prometheus_metrics', protected_branches: './protected_branches/protected_branches_bundle.js', protected_tags: './protected_tags', sidebar: './sidebar/sidebar_bundle.js', @@ -240,6 +241,7 @@ if (IS_DEV_SERVER) { port: DEV_SERVER_PORT, headers: { 'Access-Control-Allow-Origin': '*' }, stats: 'errors-only', + hot: DEV_SERVER_LIVERELOAD, inline: DEV_SERVER_LIVERELOAD }; config.output.publicPath = '//' + DEV_SERVER_HOST + ':' + DEV_SERVER_PORT + config.output.publicPath; @@ -247,6 +249,9 @@ if (IS_DEV_SERVER) { // watch node_modules for changes if we encounter a missing module compile error new WatchMissingNodeModulesPlugin(path.join(ROOT_PATH, 'node_modules')) ); + if (DEV_SERVER_LIVERELOAD) { + config.plugins.push(new webpack.HotModuleReplacementPlugin()); + } } if (WEBPACK_REPORT) { diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb index 93214b9d3e7..c1bbc9af6d6 100644 --- a/db/fixtures/development/19_environments.rb +++ b/db/fixtures/development/19_environments.rb @@ -33,7 +33,7 @@ class Gitlab::Seeder::Environments create_deployment!( merge_request.source_project, - "review/#{merge_request.source_branch}", + "review/#{merge_request.source_branch.gsub(/[^a-zA-Z0-9]/, '')}", merge_request.source_branch, merge_request.diff_head_sha ) diff --git a/db/migrate/20160615191922_set_missing_stage_on_ci_builds.rb b/db/migrate/20160615191922_set_missing_stage_on_ci_builds.rb index 4d6a61bd614..5336b036bca 100644 --- a/db/migrate/20160615191922_set_missing_stage_on_ci_builds.rb +++ b/db/migrate/20160615191922_set_missing_stage_on_ci_builds.rb @@ -2,6 +2,8 @@ class SetMissingStageOnCiBuilds < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + def up update_column_in_batches(:ci_builds, :stage, :test) do |table, query| query.where(table[:stage].eq(nil)) diff --git a/db/migrate/20160721081015_drop_and_readd_has_external_wiki_in_projects.rb b/db/migrate/20160721081015_drop_and_readd_has_external_wiki_in_projects.rb index b2a2ce41391..abe8e701e23 100644 --- a/db/migrate/20160721081015_drop_and_readd_has_external_wiki_in_projects.rb +++ b/db/migrate/20160721081015_drop_and_readd_has_external_wiki_in_projects.rb @@ -5,6 +5,8 @@ class DropAndReaddHasExternalWikiInProjects < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false + disable_ddl_transaction! + def up update_column_in_batches(:projects, :has_external_wiki, nil) do |table, query| query.where(table[:has_external_wiki].not_eq(nil)) diff --git a/db/migrate/20160901141443_set_confidential_issues_events_on_webhooks.rb b/db/migrate/20160901141443_set_confidential_issues_events_on_webhooks.rb index febd2c0e65e..f8486e3e1a6 100644 --- a/db/migrate/20160901141443_set_confidential_issues_events_on_webhooks.rb +++ b/db/migrate/20160901141443_set_confidential_issues_events_on_webhooks.rb @@ -4,6 +4,8 @@ class SetConfidentialIssuesEventsOnWebhooks < ActiveRecord::Migration DOWNTIME = false + disable_ddl_transaction! + def up update_column_in_batches(:web_hooks, :confidential_issues_events, true) do |table, query| query.where(table[:issues_events].eq(true)) diff --git a/db/migrate/20160919144305_add_type_to_labels.rb b/db/migrate/20160919144305_add_type_to_labels.rb index 2d2725ccf59..d08b339cd27 100644 --- a/db/migrate/20160919144305_add_type_to_labels.rb +++ b/db/migrate/20160919144305_add_type_to_labels.rb @@ -5,6 +5,8 @@ class AddTypeToLabels < ActiveRecord::Migration DOWNTIME = true DOWNTIME_REASON = 'Labels will not work as expected until this migration is complete.' + disable_ddl_transaction! + def change add_column :labels, :type, :string diff --git a/db/migrate/20161018124658_make_project_owners_masters.rb b/db/migrate/20161018124658_make_project_owners_masters.rb index fe11699c196..cb93b449067 100644 --- a/db/migrate/20161018124658_make_project_owners_masters.rb +++ b/db/migrate/20161018124658_make_project_owners_masters.rb @@ -4,6 +4,8 @@ class MakeProjectOwnersMasters < ActiveRecord::Migration DOWNTIME = false + disable_ddl_transaction! + def up update_column_in_batches(:members, :access_level, 40) do |table, query| query.where(table[:access_level].eq(50).and(table[:source_type].eq('Project'))) diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index e5292cfba07..c0cb9d78748 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -6,9 +6,9 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration class Project < ActiveRecord::Base def self.find_including_path(id) - select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace"). - joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id'). - find_by(id: id) + select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace") + .joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id') + .find_by(id: id) end def repository_storage_path diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb index a20a903a752..f73e4f6c99b 100644 --- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb +++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb @@ -8,11 +8,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration environments = Arel::Table.new(:environments) # Get all [project_id, name] pairs that occur more than once - finder_sql = environments. - group(environments[:project_id], environments[:name]). - having(Arel.sql("COUNT(1)").gt(1)). - project(environments[:project_id], environments[:name]). - to_sql + finder_sql = environments + .group(environments[:project_id], environments[:name]) + .having(Arel.sql("COUNT(1)").gt(1)) + .project(environments[:project_id], environments[:name]) + .to_sql conflicting = connection.exec_query(finder_sql) @@ -28,12 +28,12 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration # Rename conflicting environments by appending "-#{id}" to all but the first def fix_duplicates(project_id, name) environments = Arel::Table.new(:environments) - finder_sql = environments. - where(environments[:project_id].eq(project_id)). - where(environments[:name].eq(name)). - order(environments[:id].asc). - project(environments[:id], environments[:name]). - to_sql + finder_sql = environments + .where(environments[:project_id].eq(project_id)) + .where(environments[:name].eq(name)) + .order(environments[:id].asc) + .project(environments[:id], environments[:name]) + .to_sql # Now we have the data for all the conflicting rows conflicts = connection.exec_query(finder_sql).rows @@ -41,11 +41,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration conflicts.each do |id, name| update_sql = - Arel::UpdateManager.new(ActiveRecord::Base). - table(environments). - set(environments[:name] => name + "-" + id.to_s). - where(environments[:id].eq(id)). - to_sql + Arel::UpdateManager.new(ActiveRecord::Base) + .table(environments) + .set(environments[:name] => name + "-" + id.to_s) + .where(environments[:id].eq(id)) + .to_sql connection.exec_update(update_sql, self.class.name, []) end diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb index 8e98ee5b9ba..83cdd484c4c 100644 --- a/db/migrate/20161207231626_add_environment_slug.rb +++ b/db/migrate/20161207231626_add_environment_slug.rb @@ -19,10 +19,10 @@ class AddEnvironmentSlug < ActiveRecord::Migration finder = environments.project(:id, :name) connection.exec_query(finder.to_sql).rows.each do |id, name| - updater = Arel::UpdateManager.new(ActiveRecord::Base). - table(environments). - set(environments[:slug] => generate_slug(name)). - where(environments[:id].eq(id)) + updater = Arel::UpdateManager.new(ActiveRecord::Base) + .table(environments) + .set(environments[:slug] => generate_slug(name)) + .where(environments[:id].eq(id)) connection.exec_update(updater.to_sql, self.class.name, []) end diff --git a/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb b/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb index c7cada6dfc5..6b15e5caccf 100644 --- a/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb +++ b/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb @@ -4,6 +4,8 @@ class RenameSlackAndMattermostNotificationServices < ActiveRecord::Migration DOWNTIME = false + disable_ddl_transaction! + def up update_column_in_batches(:services, :type, 'SlackService') do |table, query| query.where(table[:type].eq('SlackNotificationService')) diff --git a/db/migrate/20170316163800_rename_system_namespaces.rb b/db/migrate/20170316163800_rename_system_namespaces.rb index b5408fbf112..9e9fb5ac225 100644 --- a/db/migrate/20170316163800_rename_system_namespaces.rb +++ b/db/migrate/20170316163800_rename_system_namespaces.rb @@ -159,9 +159,9 @@ class RenameSystemNamespaces < ActiveRecord::Migration end def system_namespace - @system_namespace ||= Namespace.where(parent_id: nil). - where(arel_table[:path].matches(system_namespace_path)). - first + @system_namespace ||= Namespace.where(parent_id: nil) + .where(arel_table[:path].matches(system_namespace_path)) + .first end def system_namespace_path @@ -209,8 +209,8 @@ class RenameSystemNamespaces < ActiveRecord::Migration end def repo_paths_for_namespace(namespace) - projects_for_namespace(namespace).distinct. - select(:repository_storage).map(&:repository_storage_path) + projects_for_namespace(namespace).distinct + .select(:repository_storage).map(&:repository_storage_path) end def uploads_dir diff --git a/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb b/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb index c67690642c9..33908ae1156 100644 --- a/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb +++ b/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb @@ -87,8 +87,8 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration while current&.parent_id # We're using find_by(id: ...) here to deal with cases where the # parent_id may point to a missing row. - current = Namespace.unscoped.select([:id, :parent_id]). - find_by(id: current.parent_id) + current = Namespace.unscoped.select([:id, :parent_id]) + .find_by(id: current.parent_id) ancestors << current.id if current end @@ -99,11 +99,11 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration # Returns a relation containing all the members that have access to any of # the current namespace's parent namespaces. def all_members_for(namespace) - Member. - unscoped. - select(['user_id', 'MAX(access_level) AS access_level']). - where(source_type: 'Namespace', source_id: ancestors_for(namespace)). - group(:user_id) + Member + .unscoped + .select(['user_id', 'MAX(access_level) AS access_level']) + .where(source_type: 'Namespace', source_id: ancestors_for(namespace)) + .group(:user_id) end def bulk_insert_members(rows) diff --git a/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb b/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb index d5675d5828b..d27cba76d81 100644 --- a/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb +++ b/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb @@ -3,19 +3,11 @@ class AddStageIdToCiBuilds < ActiveRecord::Migration DOWNTIME = false - disable_ddl_transaction! - def up add_column :ci_builds, :stage_id, :integer - - add_concurrent_foreign_key :ci_builds, :ci_stages, column: :stage_id, on_delete: :cascade - add_concurrent_index :ci_builds, :stage_id end def down - remove_foreign_key :ci_builds, column: :stage_id - remove_concurrent_index :ci_builds, :stage_id - remove_column :ci_builds, :stage_id, :integer end end diff --git a/db/migrate/20170619144837_add_index_for_head_pipeline_merge_request.rb b/db/migrate/20170619144837_add_index_for_head_pipeline_merge_request.rb new file mode 100644 index 00000000000..02863bee082 --- /dev/null +++ b/db/migrate/20170619144837_add_index_for_head_pipeline_merge_request.rb @@ -0,0 +1,15 @@ +class AddIndexForHeadPipelineMergeRequest < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :merge_requests, :head_pipeline_id + end + + def down + remove_concurrent_index :merge_requests, :head_pipeline_id if index_exists?(:merge_requests, :head_pipeline_id) + end +end diff --git a/db/migrate/20170622162730_add_ref_fetched_to_merge_request.rb b/db/migrate/20170622162730_add_ref_fetched_to_merge_request.rb new file mode 100644 index 00000000000..62aa1a4b4f0 --- /dev/null +++ b/db/migrate/20170622162730_add_ref_fetched_to_merge_request.rb @@ -0,0 +1,9 @@ +class AddRefFetchedToMergeRequest < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :merge_requests, :ref_fetched, :boolean + end +end diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb index 14b5ef476f0..69007b8e8ed 100644 --- a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb +++ b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb @@ -13,13 +13,13 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration namespaces = Arel::Table.new(:namespaces) finder_sql = - projects. - join(namespaces, Arel::Nodes::InnerJoin). - on(projects[:namespace_id].eq(namespaces[:id])). - where(projects[:visibility_level].gt(namespaces[:visibility_level])). - project(projects[:id], namespaces[:visibility_level]). - take(BATCH_SIZE). - to_sql + projects + .join(namespaces, Arel::Nodes::InnerJoin) + .on(projects[:namespace_id].eq(namespaces[:id])) + .where(projects[:visibility_level].gt(namespaces[:visibility_level])) + .project(projects[:id], namespaces[:visibility_level]) + .take(BATCH_SIZE) + .to_sql # Update matching rows in batches. Each batch can cause up to 3 UPDATE # statements, in addition to the SELECT: one per visibility_level @@ -33,10 +33,10 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration end updates.each do |visibility_level, project_ids| - updater = Arel::UpdateManager.new(ActiveRecord::Base). - table(projects). - set(projects[:visibility_level] => visibility_level). - where(projects[:id].in(project_ids)) + updater = Arel::UpdateManager.new(ActiveRecord::Base) + .table(projects) + .set(projects[:visibility_level] => visibility_level) + .where(projects[:id].in(project_ids)) ActiveRecord::Base.connection.exec_update(updater.to_sql, self.class.name, []) end diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb index 49a6bc884a8..d322844e2fd 100644 --- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb +++ b/db/post_migrate/20161221153951_rename_reserved_project_names.rb @@ -79,17 +79,17 @@ class RenameReservedProjectNames < ActiveRecord::Migration private def reserved_projects - Project.unscoped. - includes(:namespace). - where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)'). - where('projects.path' => KNOWN_PATHS) + Project.unscoped + .includes(:namespace) + .where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)') + .where('projects.path' => KNOWN_PATHS) end def route_exists?(full_path) quoted_path = ActiveRecord::Base.connection.quote_string(full_path) - ActiveRecord::Base.connection. - select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? + ActiveRecord::Base.connection + .select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? end # Adds number to the end of the path that is not taken by other route diff --git a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb index f399950bd5e..d7be004d47f 100644 --- a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb +++ b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb @@ -39,11 +39,11 @@ class RequeuePendingDeleteProjects < ActiveRecord::Migration def find_batch projects = Arel::Table.new(:projects) - projects.project(projects[:id]). - where(projects[:pending_delete].eq(true)). - where(projects[:namespace_id].not_eq(nil)). - skip(@offset * BATCH_SIZE). - take(BATCH_SIZE). - to_sql + projects.project(projects[:id]) + .where(projects[:pending_delete].eq(true)) + .where(projects[:namespace_id].not_eq(nil)) + .skip(@offset * BATCH_SIZE) + .take(BATCH_SIZE) + .to_sql end end diff --git a/db/post_migrate/20170106142508_fill_authorized_projects.rb b/db/post_migrate/20170106142508_fill_authorized_projects.rb index 314c8440c8b..0ca20587981 100644 --- a/db/post_migrate/20170106142508_fill_authorized_projects.rb +++ b/db/post_migrate/20170106142508_fill_authorized_projects.rb @@ -15,8 +15,8 @@ class FillAuthorizedProjects < ActiveRecord::Migration disable_ddl_transaction! def up - relation = User.select(:id). - where('authorized_projects_populated IS NOT TRUE') + relation = User.select(:id) + .where('authorized_projects_populated IS NOT TRUE') relation.find_in_batches(batch_size: 1_000) do |rows| args = rows.map { |row| [row.id] } diff --git a/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb b/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb index b1c9eed1148..01fff680183 100644 --- a/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb +++ b/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb @@ -4,6 +4,8 @@ class ResetRelativePositionForIssue < ActiveRecord::Migration DOWNTIME = false + disable_ddl_transaction! + def up update_column_in_batches(:issues, :relative_position, nil) do |table, query| query.where(table[:relative_position].not_eq(nil)) @@ -11,5 +13,6 @@ class ResetRelativePositionForIssue < ActiveRecord::Migration end def down + # noop end end diff --git a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb index 44c688fa134..6a49450cc50 100644 --- a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb +++ b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb @@ -21,17 +21,17 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration private def reserved_projects - Project.unscoped. - includes(:namespace). - where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)'). - where('projects.path' => KNOWN_PATHS) + Project.unscoped + .includes(:namespace) + .where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)') + .where('projects.path' => KNOWN_PATHS) end def route_exists?(full_path) quoted_path = ActiveRecord::Base.connection.quote_string(full_path) - ActiveRecord::Base.connection. - select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? + ActiveRecord::Base.connection + .select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? end # Adds number to the end of the path that is not taken by other route diff --git a/db/post_migrate/20170317162059_update_upload_paths_to_system.rb b/db/post_migrate/20170317162059_update_upload_paths_to_system.rb index 9a77b0bbdfb..ca2912f8dce 100644 --- a/db/post_migrate/20170317162059_update_upload_paths_to_system.rb +++ b/db/post_migrate/20170317162059_update_upload_paths_to_system.rb @@ -7,6 +7,8 @@ class UpdateUploadPathsToSystem < ActiveRecord::Migration DOWNTIME = false AFFECTED_MODELS = %w(User Project Note Namespace Appearance) + disable_ddl_transaction! + def up update_column_in_batches(:uploads, :path, replace_sql(arel_table[:path], base_directory, new_upload_dir)) do |_table, query| query.where(uploads_to_switch_to_new_path) diff --git a/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb b/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb index 9ad36482c8a..397a9a2d28e 100644 --- a/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb +++ b/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb @@ -38,11 +38,11 @@ class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration activities = activities(day.at_beginning_of_day, day.at_end_of_day, page: page) update_sql = - Arel::UpdateManager.new(ActiveRecord::Base). - table(users_table). - set(users_table[:last_activity_on] => day.to_date). - where(users_table[:username].in(activities.map(&:first))). - to_sql + Arel::UpdateManager.new(ActiveRecord::Base) + .table(users_table) + .set(users_table[:last_activity_on] => day.to_date) + .where(users_table[:username].in(activities.map(&:first))) + .to_sql connection.exec_update(update_sql, self.class.name, []) diff --git a/db/post_migrate/20170406142253_migrate_user_project_view.rb b/db/post_migrate/20170406142253_migrate_user_project_view.rb index 22f0f2ac200..c4e910b3b44 100644 --- a/db/post_migrate/20170406142253_migrate_user_project_view.rb +++ b/db/post_migrate/20170406142253_migrate_user_project_view.rb @@ -7,6 +7,8 @@ class MigrateUserProjectView < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false + disable_ddl_transaction! + def up update_column_in_batches(:users, :project_view, 2) do |table, query| query.where(table[:project_view].eq(0)) diff --git a/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb b/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb index 3c13a3d2518..765daa0a347 100644 --- a/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb +++ b/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb @@ -7,6 +7,8 @@ class EnableAutoCancelPendingPipelinesForAll < ActiveRecord::Migration DOWNTIME = false def up + disable_statement_timeout + update_column_in_batches(:projects, :auto_cancel_pending_pipelines, 1) end diff --git a/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb b/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb index ce52de91cdd..c1e64f20109 100644 --- a/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb +++ b/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb @@ -37,11 +37,11 @@ class CleanupNamespacelessPendingDeleteProjects < ActiveRecord::Migration def find_batch projects = Arel::Table.new(:projects) - projects.project(projects[:id]). - where(projects[:pending_delete].eq(true)). - where(projects[:namespace_id].eq(nil)). - skip(@offset * BATCH_SIZE). - take(BATCH_SIZE). - to_sql + projects.project(projects[:id]) + .where(projects[:pending_delete].eq(true)) + .where(projects[:namespace_id].eq(nil)) + .skip(@offset * BATCH_SIZE) + .take(BATCH_SIZE) + .to_sql end end diff --git a/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb b/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb index bc3850c0c23..f77078ddd70 100644 --- a/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb +++ b/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb @@ -3,17 +3,19 @@ class AddHeadPipelineForEachMergeRequest < ActiveRecord::Migration DOWNTIME = false + disable_ddl_transaction! + def up disable_statement_timeout pipelines = Arel::Table.new(:ci_pipelines) merge_requests = Arel::Table.new(:merge_requests) - head_id = pipelines. - project(Arel::Nodes::NamedFunction.new('max', [pipelines[:id]])). - from(pipelines). - where(pipelines[:ref].eq(merge_requests[:source_branch])). - where(pipelines[:project_id].eq(merge_requests[:source_project_id])) + head_id = pipelines + .project(Arel::Nodes::NamedFunction.new('max', [pipelines[:id]])) + .from(pipelines) + .where(pipelines[:ref].eq(merge_requests[:source_branch])) + .where(pipelines[:project_id].eq(merge_requests[:source_project_id])) sub_query = Arel::Nodes::SqlLiteral.new(Arel::Nodes::Grouping.new(head_id).to_sql) diff --git a/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb b/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb new file mode 100644 index 00000000000..3879cf9133b --- /dev/null +++ b/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb @@ -0,0 +1,18 @@ +class RemoveStageIdIndexFromBuilds < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + if index_exists?(:ci_builds, :stage_id) + remove_foreign_key(:ci_builds, column: :stage_id) + remove_concurrent_index(:ci_builds, :stage_id) + end + end + + def down + # noop + end +end diff --git a/db/post_migrate/20170526185921_migrate_build_stage_reference.rb b/db/post_migrate/20170526185921_migrate_build_stage_reference.rb index 797e106cae4..98c32d8284c 100644 --- a/db/post_migrate/20170526185921_migrate_build_stage_reference.rb +++ b/db/post_migrate/20170526185921_migrate_build_stage_reference.rb @@ -3,23 +3,17 @@ class MigrateBuildStageReference < ActiveRecord::Migration DOWNTIME = false - def up - disable_statement_timeout - - stage_id = Arel.sql <<-SQL.strip_heredoc - (SELECT id FROM ci_stages - WHERE ci_stages.pipeline_id = ci_builds.commit_id - AND ci_stages.name = ci_builds.stage) - SQL + ## + # This is an empty migration, content has been moved to a new one: + # post migrate 20170526190000 MigrateBuildStageReferenceAgain + # + # See gitlab-org/gitlab-ce!12337 for more details. - update_column_in_batches(:ci_builds, :stage_id, stage_id) do |table, query| - query.where(table[:stage_id].eq(nil)) - end + def up + # noop end def down - disable_statement_timeout - - update_column_in_batches(:ci_builds, :stage_id, nil) + # noop end end diff --git a/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb b/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb new file mode 100644 index 00000000000..97cb242415d --- /dev/null +++ b/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb @@ -0,0 +1,27 @@ +class MigrateBuildStageReferenceAgain < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + disable_statement_timeout + + stage_id = Arel.sql <<-SQL.strip_heredoc + (SELECT id FROM ci_stages + WHERE ci_stages.pipeline_id = ci_builds.commit_id + AND ci_stages.name = ci_builds.stage) + SQL + + update_column_in_batches(:ci_builds, :stage_id, stage_id) do |table, query| + query.where(table[:stage_id].eq(nil)) + end + end + + def down + disable_statement_timeout + + update_column_in_batches(:ci_builds, :stage_id, nil) + end +end diff --git a/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb b/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb new file mode 100644 index 00000000000..7d6609b18bf --- /dev/null +++ b/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb @@ -0,0 +1,21 @@ +class AddStageIdIndexToBuilds < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless index_exists?(:ci_builds, :stage_id) + add_concurrent_foreign_key(:ci_builds, :ci_stages, column: :stage_id, on_delete: :cascade) + add_concurrent_index(:ci_builds, :stage_id) + end + end + + def down + if index_exists?(:ci_builds, :stage_id) + remove_foreign_key(:ci_builds, column: :stage_id) + remove_concurrent_index(:ci_builds, :stage_id) + end + end +end diff --git a/db/schema.rb b/db/schema.rb index f42827991aa..8c7440ee610 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170614115405) do +ActiveRecord::Schema.define(version: 20170622162730) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -770,6 +770,7 @@ ActiveRecord::Schema.define(version: 20170614115405) do t.datetime "last_edited_at" t.integer "last_edited_by_id" t.integer "head_pipeline_id" + t.boolean "ref_fetched" end add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree @@ -777,6 +778,7 @@ ActiveRecord::Schema.define(version: 20170614115405) do add_index "merge_requests", ["created_at"], name: "index_merge_requests_on_created_at", using: :btree add_index "merge_requests", ["deleted_at"], name: "index_merge_requests_on_deleted_at", using: :btree add_index "merge_requests", ["description"], name: "index_merge_requests_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"} + add_index "merge_requests", ["head_pipeline_id"], name: "index_merge_requests_on_head_pipeline_id", using: :btree add_index "merge_requests", ["milestone_id"], name: "index_merge_requests_on_milestone_id", using: :btree add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree add_index "merge_requests", ["source_project_id"], name: "index_merge_requests_on_source_project_id", using: :btree diff --git a/doc/README.md b/doc/README.md index ab8ea192a26..fa755852304 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,12 +1,24 @@ -# GitLab Community Edition +# GitLab Documentation -[GitLab](https://about.gitlab.com/) is a Git-based fully featured platform -for software development. +Welcome to [GitLab](https://about.gitlab.com/), a Git-based fully featured +platform for software development! -**GitLab Community Edition (CE)** is an opensource product, self-hosted, free to use. -All [GitLab products](https://about.gitlab.com/products/) contain the features -available in GitLab CE. Premium features are available in -[GitLab Enterprise Edition (EE)](https://about.gitlab.com/gitlab-ee/). +We offer four different products for you and your company: + +- **GitLab Community Edition (CE)** is an [opensource product](https://gitlab.com/gitlab-org/gitlab-ce/), +self-hosted, free to use. Every feature available in GitLab CE is also available on GitLab Enterprise Edition (Starter and Premium) and GitLab.com. +- **GitLab Enterprise Edition (EE)** is an [opencore product](https://gitlab.com/gitlab-org/gitlab-ee/), +self-hosted, fully featured solution of GitLab, available under distinct [subscriptions](https://about.gitlab.com/products/): **GitLab Enterprise Edition Starter (EES)** and **GitLab Enterprise Edition Premium (EEP)**. +- **GitLab.com**: SaaS GitLab solution, with [free and paid subscriptions](https://about.gitlab.com/gitlab-com/). GitLab.com is hosted by GitLab, Inc., and administrated by GitLab (users don't have access to admin settings). + +**GitLab EE** contains all features available in **GitLab CE**, +plus premium features available in each version: **Enterprise Edition Starter** +(**EES**) and **Enterprise Edition Premium** (**EEP**). Everything available in +**EES** is also available in **EEP**. + +**Note:** _We are unifying the documentation for CE and EE. To check if certain feature is +available in CE or EE, look for a note right below the page title containing the GitLab +version which introduced that feature._ ---- @@ -125,7 +137,7 @@ have access to GitLab administration tools and settings. - [Access restrictions](user/admin_area/settings/visibility_and_access_controls.md#enabled-git-access-protocols): Define which Git access protocols can be used to talk to GitLab - [Authentication/Authorization](topics/authentication/index.md#gitlab-administrators): Enforce 2FA, configure external authentication with LDAP, SAML, CAS and additional Omniauth providers. -### GitLab admins' superpowers +### Features - [Container Registry](administration/container_registry.md): Configure Docker Registry with GitLab. - [Custom Git hooks](administration/custom_hooks.md): Custom Git hooks (on the filesystem) for when webhooks aren't enough. diff --git a/doc/administration/gitaly/index.md b/doc/administration/gitaly/index.md index 48929910a9c..332457cb384 100644 --- a/doc/administration/gitaly/index.md +++ b/doc/administration/gitaly/index.md @@ -33,6 +33,145 @@ prometheus_listen_addr = "localhost:9236" Changes to `/home/git/gitaly/config.toml` are applied when you run `service gitlab restart`. +## Running Gitaly on its own server + +> This is an optional way to deploy Gitaly which can benefit GitLab +installations that are larger than a single machine. Most +installations will be better served with the default configuration +used by Omnibus and the GitLab source installation guide. + +Starting with GitLab 9.4 it is possible to run Gitaly on a different +server from the rest of the application. This can improve performance +when running GitLab with its repositories stored on an NFS server. + +At the moment (GitLab 9.4) Gitaly is not yet a replacement for NFS +because some parts of GitLab still bypass Gitaly when accessing Git +repositories. If you choose to deploy Gitaly on your NFS server you +must still also mount your Git shares on your GitLab application +servers. + +Gitaly network traffic is unencrypted so you should use a firewall to +restrict access to your Gitaly server. + +Below we describe how to configure a Gitaly server at address +`gitaly.internal:9999` with secret token `abc123secret`. We assume +your GitLab installation has two repository storages, `default` and +`storage1`. + +### Client side token configuration + +Start by configuring a token on the client side. + +Omnibus installations: + +```ruby +# /etc/gitlab/gitlab.rb +gitlab_rails['gitaly_token'] = 'abc123secret' +``` + +Source installations: + +```yaml +# /home/git/gitlab/config/gitlab.yml +gitlab: + gitaly: + token: 'abc123secret' +``` + +You need to reconfigure (Omnibus) or restart (source) for these +changes to be picked up. + +### Gitaly server configuration + +Next, on the Gitaly server, we need to configure storage paths, enable +the network listener and configure the token. + +Note: if you want to reduce the risk of downtime when you enable +authentication you can temporarily disable enforcement, see [the +documentation on configuring Gitaly +authentication](https://gitlab.com/gitlab-org/gitaly/blob/master/doc/configuration/README.md#authentication) +. + +In most or all cases the storage paths below end in `/repositories`. Check the +directory layout on your Gitaly server to be sure. + +Omnibus installations: + +```ruby +# /etc/gitlab/gitlab.rb +gitaly['listen_addr'] = '0.0.0.0:9999' +gitaly['auth_token'] = 'abc123secret' +gitaly['storage'] = [ + { 'name' => 'default', 'path' => '/path/to/default/repositories' }, + { 'name' => 'storage1', 'path' => '/path/to/storage1/repositories' }, +] +``` + +Source installations: + +```toml +# /home/git/gitaly/config.toml +listen_addr = '0.0.0.0:9999' + +[auth] +token = 'abc123secret' + +[[storage] +name = 'default' +path = '/path/to/default/repositories' + +[[storage]] +name = 'storage1' +path = '/path/to/storage1/repositories' +``` + +Again, reconfigure (Omnibus) or restart (source). + +### Converting clients to use the Gitaly server + +Now as the final step update the client machines to switch from using +their local Gitaly service to the new Gitaly server you just +configured. This is a risky step because if there is any sort of +network, firewall, or name resolution problem preventing your GitLab +server from reaching the Gitaly server then all Gitaly requests will +fail. + +We assume that your Gitaly server can be reached at +`gitaly.internal:9999` from your GitLab server, and that your GitLab +NFS shares are mounted at `/mnt/gitlab/default` and +`/mnt/gitlab/storage1` respectively. + +Omnibus installations: + +```ruby +# /etc/gitlab/gitlab.rb +git_data_dirs({ + { 'default' => { 'path' => '/mnt/gitlab/default', 'gitaly_address' => 'tcp://gitlab.internal:9999' } }, + { 'storage1' => { 'path' => '/mnt/gitlab/storage1', 'gitaly_address' => 'tcp://gitlab.internal:9999' } }, +}) +``` + +Source installations: + +```yaml +# /home/git/gitlab/config/gitlab.yml +gitlab: + repositories: + storages: + default: + path: /mnt/gitlab/default/repositories + gitaly_address: tcp://gitlab.internal:9999 + storage1: + path: /mnt/gitlab/storage1/repositories + gitaly_address: tcp://gitlab.internal:9999 +``` + +Now reconfigure (Omnibus) or restart (source). When you tail the +Gitaly logs on your Gitaly server (`sudo gitlab-ctl tail gitaly` or +`tail -f /home/git/gitlab/log/gitaly.log`) you should see requests +coming in. One sure way to trigger a Gitaly request is to clone a +repository from your GitLab server over HTTP. + ## Configuring GitLab to not use Gitaly Gitaly is still an optional component in GitLab 9.3. This means you diff --git a/doc/administration/high_availability/nfs.md b/doc/administration/high_availability/nfs.md index d8e76d6ab94..bd6b7327aed 100644 --- a/doc/administration/high_availability/nfs.md +++ b/doc/administration/high_availability/nfs.md @@ -1,12 +1,35 @@ # NFS -## Required NFS Server features +You can view information and options set for each of the mounted NFS file +systems by running `sudo nfsstat -m`. + +## NFS Server features + +### Required features **File locking**: GitLab **requires** advisory file locking, which is only supported natively in NFS version 4. NFSv3 also supports locking as long as Linux Kernel 2.6.5+ is used. We recommend using version 4 and do not specifically test NFSv3. +### Recommended options + +When you define your NFS exports, we recommend you also add the following +options: + +- `no_root_squash` - NFS normally changes the `root` user to `nobody`. This is + a good security measure when NFS shares will be accessed by many different + users. However, in this case only GitLab will use the NFS share so it + is safe. GitLab recommends the `no_root_squash` setting because we need to + manage file permissions automatically. Without the setting you may receive + errors when the Omnibus package tries to alter permissions. Note that GitLab + and other bundled components do **not** run as `root` but as non-privileged + users. The recommendation for `no_root_squash` is to allow the Omnibus package + to set ownership and permissions on files, as needed. +- `sync` - Force synchronous behavior. Default is asynchronous and under certain + circumstances it could lead to data loss if a failure occurs before data has + synced. + ## AWS Elastic File System GitLab does not recommend using AWS Elastic File System (EFS). @@ -26,27 +49,10 @@ GitLab does not recommend using EFS with GitLab. For more details on another person's experience with EFS, see [Amazon's Elastic File System: Burst Credits](https://www.rawkode.io/2017/04/amazons-elastic-file-system-burst-credits/) -### Recommended options - -When you define your NFS exports, we recommend you also add the following -options: - -- `no_root_squash` - NFS normally changes the `root` user to `nobody`. This is - a good security measure when NFS shares will be accessed by many different - users. However, in this case only GitLab will use the NFS share so it - is safe. GitLab recommends the `no_root_squash` setting because we need to - manage file permissions automatically. Without the setting you may receive - errors when the Omnibus package tries to alter permissions. Note that GitLab - and other bundled components do **not** run as `root` but as non-privileged - users. The recommendation for `no_root_squash` is to allow the Omnibus package - to set ownership and permissions on files, as needed. -- `sync` - Force synchronous behavior. Default is asynchronous and under certain - circumstances it could lead to data loss if a failure occurs before data has - synced. - ## NFS Client mount options -Below is an example of an NFS mount point we use on GitLab.com: +Below is an example of an NFS mount point defined in `/etc/fstab` we use on +GitLab.com: ``` 10.1.1.1:/var/opt/gitlab/git-data /var/opt/gitlab/git-data nfs4 defaults,soft,rsize=1048576,wsize=1048576,noatime,nobootwait,lookupcache=positive 0 2 diff --git a/doc/administration/high_availability/redis_source.md b/doc/administration/high_availability/redis_source.md index 3629772b8af..fe982ea83c2 100644 --- a/doc/administration/high_availability/redis_source.md +++ b/doc/administration/high_availability/redis_source.md @@ -364,3 +364,4 @@ When in doubt, please read [Redis Sentinel documentation](http://redis.io/topics [downloads]: https://about.gitlab.com/downloads [restart]: ../restart_gitlab.md#installations-from-source [it]: https://gitlab.com/gitlab-org/gitlab-ce/uploads/c4cc8cd353604bd80315f9384035ff9e/The_Internet_IT_Crowd.png +[resque]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/resque.yml.example diff --git a/doc/administration/monitoring/prometheus/gitlab_metrics.md b/doc/administration/monitoring/prometheus/gitlab_metrics.md new file mode 100644 index 00000000000..07c05b5a6fb --- /dev/null +++ b/doc/administration/monitoring/prometheus/gitlab_metrics.md @@ -0,0 +1,47 @@ +# GitLab Prometheus metrics + +>**Note:** +Available since [Omnibus GitLab 9.3][29118]. Currently experimental. For installations from source +you'll have to configure it yourself. + +GitLab monitors its own internal service metrics, and makes them available at the `/-/metrics` endpoint. Unlike other [Prometheus] exporters, this endpoint requires authentication as it is available on the same URL and port as user traffic. + +To enable the GitLab Prometheus metrics: + +1. Log into GitLab as an administrator, and go to the Admin area. +1. Click on the gear, then click on Settings. +1. Find the `Metrics - Prometheus` section, and click `Enable Prometheus Metrics` +1. [Restart GitLab][restart] for the changes to take effect + +## Collecting the metrics + +Since the metrics endpoint is available on the same host and port as other traffic, it requires authentication. The token and URL to access is displayed on the [Health Check][health-check] page. + +Currently the embedded Prometheus server is not automatically configured to collect metrics from this endpoint. We recommend setting up another Prometheus server, because the embedded server configuration is overwritten one every reconfigure of GitLab. In the future this will not be required. + +## Metrics available + +In this experimental phase, only a few metrics are available: + +| Metric | Type | Description | +| ------ | ---- | ----------- | +| db_ping_timeout | Gauge | Whether or not the last database ping timed out | +| db_ping_success | Gauge | Whether or not the last database ping succeeded | +| db_ping_latency | Gauge | Round trip time of the database ping | +| redis_ping_timeout | Gauge | Whether or not the last redis ping timed out | +| redis_ping_success | Gauge | Whether or not the last redis ping succeeded | +| redis_ping_latency | Gauge | Round trip time of the redis ping | +| filesystem_access_latency | gauge | Latency in accessing a specific filesystem | +| filesystem_accessible | gauge | Whether or not a specific filesystem is accessible | +| filesystem_write_latency | gauge | Write latency of a specific filesystem | +| filesystem_writable | gauge | Whether or not the filesystem is writable | +| filesystem_read_latency | gauge | Read latency of a specific filesystem | +| filesystem_readable | gauge | Whether or not the filesystem is readable | +| user_sessions_logins | Counter | Counter of how many users have logged in | + +[← Back to the main Prometheus page](index.md) + +[29118]: https://gitlab.com/gitlab-org/gitlab-ce/issues/29118 +[Prometheus]: https://prometheus.io +[restart]: ../../restart_gitlab.md#omnibus-gitlab-restart +[health-check]: ../../../user/admin_area/monitoring/health_check.md diff --git a/doc/administration/monitoring/prometheus/gitlab_monitor_exporter.md b/doc/administration/monitoring/prometheus/gitlab_monitor_exporter.md index edb9c911aac..f68b03d1ade 100644 --- a/doc/administration/monitoring/prometheus/gitlab_monitor_exporter.md +++ b/doc/administration/monitoring/prometheus/gitlab_monitor_exporter.md @@ -4,7 +4,7 @@ Available since [Omnibus GitLab 8.17][1132]. For installations from source you'll have to install and configure it yourself. -The [GitLab monitor exporter] allows you to measure various GitLab metrics. +The [GitLab monitor exporter] allows you to measure various GitLab metrics, pulled from Redis and the database. To enable the GitLab monitor exporter: diff --git a/doc/administration/monitoring/prometheus/index.md b/doc/administration/monitoring/prometheus/index.md index b2445d1c0e5..695fdf09a87 100644 --- a/doc/administration/monitoring/prometheus/index.md +++ b/doc/administration/monitoring/prometheus/index.md @@ -110,6 +110,14 @@ To disable the monitoring of Kubernetes: 1. Save the file and [reconfigure GitLab][reconfigure] for the changes to take effect +## GitLab Prometheus metrics + +> Introduced as an experimental feature in GitLab 9.3. + +GitLab monitors its own internal service metrics, and makes them available at the `/-/metrics` endpoint. Unlike other exporters, this endpoint requires authentication as it is available on the same URL and port as user traffic. + +[➔ Read more about the GitLab Metrics.](gitlab_metrics.md) + ## Prometheus exporters There are a number of libraries and servers which help in exporting existing @@ -143,7 +151,7 @@ The Postgres exporter allows you to measure various PostgreSQL metrics. ### GitLab monitor exporter -The GitLab monitor exporter allows you to measure various GitLab metrics. +The GitLab monitor exporter allows you to measure various GitLab metrics, pulled from Redis and the database. [➔ Read more about the GitLab monitor exporter.](gitlab_monitor_exporter.md) diff --git a/doc/api/README.md b/doc/api/README.md index 4f189c16673..b7f6ee69193 100644 --- a/doc/api/README.md +++ b/doc/api/README.md @@ -29,10 +29,10 @@ following locations: - [Labels](labels.md) - [Merge Requests](merge_requests.md) - [Milestones](milestones.md) -- [Open source license templates](templates/licenses.md) - [Namespaces](namespaces.md) - [Notes](notes.md) (comments) - [Notification settings](notification_settings.md) +- [Open source license templates](templates/licenses.md) - [Pipelines](pipelines.md) - [Pipeline Triggers](pipeline_triggers.md) - [Pipeline Schedules](pipeline_schedules.md) diff --git a/doc/api/projects.md b/doc/api/projects.md index 58f18105e21..cc1bb3911c8 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -261,6 +261,7 @@ Parameters: ], "only_allow_merge_if_pipeline_succeeds": false, "only_allow_merge_if_all_discussions_are_resolved": false, + "printing_merge_requests_link_enabled": true, "request_access_enabled": false, "statistics": { "commit_count": 37, @@ -344,6 +345,7 @@ Parameters: | `request_access_enabled` | boolean | no | Allow users to request member access | | `tag_list` | array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project | | `avatar` | mixed | no | Image file for avatar of the project | +| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line | ### Create project for user @@ -379,6 +381,7 @@ Parameters: | `request_access_enabled` | boolean | no | Allow users to request member access | | `tag_list` | array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project | | `avatar` | mixed | no | Image file for avatar of the project | +| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line | ### Edit project diff --git a/doc/api/users.md b/doc/api/users.md index b1ebd7b0c47..cf09b8f44aa 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -62,6 +62,7 @@ GET /users "avatar_url": "http://localhost:3000/uploads/user/avatar/1/index.jpg", "web_url": "http://localhost:3000/john_smith", "created_at": "2012-05-23T08:00:58Z", + "is_admin": false, "bio": null, "location": null, "skype": "", @@ -94,6 +95,7 @@ GET /users "avatar_url": "http://localhost:3000/uploads/user/avatar/2/index.jpg", "web_url": "http://localhost:3000/jack_smith", "created_at": "2012-05-23T08:01:01Z", + "is_admin": false, "bio": null, "location": null, "skype": "", @@ -197,6 +199,7 @@ Parameters: "avatar_url": "http://localhost:3000/uploads/user/avatar/1/index.jpg", "web_url": "http://localhost:3000/john_smith", "created_at": "2012-05-23T08:00:58Z", + "is_admin": false, "bio": null, "location": null, "skype": "", diff --git a/doc/ci/examples/deployment/composer-npm-deploy.md b/doc/ci/examples/deployment/composer-npm-deploy.md index 8b0d8a003fd..b9f0485290e 100644 --- a/doc/ci/examples/deployment/composer-npm-deploy.md +++ b/doc/ci/examples/deployment/composer-npm-deploy.md @@ -20,12 +20,12 @@ before_script: - php -r "unlink('composer-setup.php');" ``` -This will make sure we have all requirements ready. Next, we want to run `composer update` to fetch all PHP dependencies and `npm install` to load node packages, then run the `npm` script. We need to append them into `before_script` section: +This will make sure we have all requirements ready. Next, we want to run `composer install` to fetch all PHP dependencies and `npm install` to load node packages, then run the `npm` script. We need to append them into `before_script` section: ```yaml before_script: # ... - - php composer.phar update + - php composer.phar install - npm install - npm run deploy ``` @@ -133,7 +133,7 @@ before_script: - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - php composer-setup.php - php -r "unlink('composer-setup.php');" - - php composer.phar update + - php composer.phar install - npm install - npm run deploy - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' diff --git a/doc/ci/quick_start/README.md b/doc/ci/quick_start/README.md index 41cae58782d..88e53ff40e8 100644 --- a/doc/ci/quick_start/README.md +++ b/doc/ci/quick_start/README.md @@ -155,7 +155,7 @@ Find more information about different Runners in the [Runners](../runners/README.md) documentation. You can find whether any Runners are assigned to your project by going to -**Settings ➔ CI/CD Pipelines**. Setting up a Runner is easy and straightforward. The +**Settings ➔ Pipelines**. Setting up a Runner is easy and straightforward. The official Runner supported by GitLab is written in Go and its documentation can be found at <https://docs.gitlab.com/runner/>. @@ -168,7 +168,7 @@ Follow the links above to set up your own Runner or use a Shared Runner as described in the next section. Once the Runner has been set up, you should see it on the Runners page of your -project, following **Settings ➔ CI/CD Pipelines**. +project, following **Settings ➔ Pipelines**. ![Activated runners](img/runners_activated.png) @@ -181,7 +181,7 @@ These are special virtual machines that run on GitLab's infrastructure and can build any project. To enable the **Shared Runners** you have to go to your project's -**Settings ➔ CI/CD Pipelines** and click **Enable shared runners**. +**Settings ➔ Pipelines** and click **Enable shared runners**. [Read more on Shared Runners](../runners/README.md). diff --git a/doc/development/architecture.md b/doc/development/architecture.md index acd5e3c2093..54029e00507 100644 --- a/doc/development/architecture.md +++ b/doc/development/architecture.md @@ -194,3 +194,7 @@ bundle exec rake gitlab:check RAILS_ENV=production ``` Note: It is recommended to log into the `git` user using `sudo -i -u git` or `sudo su - git`. While the sudo commands provided by gitlabhq work in Ubuntu they do not always work in RHEL. + +## GitLab.com + +We've also detailed [our architecture of GitLab.com](https://about.gitlab.com/handbook/infrastructure/production-architecture/) but this is probably over the top unless you have millions of users. diff --git a/doc/development/fe_guide/style_guide_js.md b/doc/development/fe_guide/style_guide_js.md index d2d89517241..ae844fa1051 100644 --- a/doc/development/fe_guide/style_guide_js.md +++ b/doc/development/fe_guide/style_guide_js.md @@ -463,20 +463,24 @@ A forEach will cause side effects, it will be mutating the array being iterated. 1. `destroyed` #### Vue and Boostrap -1. Tooltips: Do not rely on `has-tooltip` class name for vue components +1. Tooltips: Do not rely on `has-tooltip` class name for Vue components ```javascript // bad - <span class="has-tooltip"> + <span + class="has-tooltip" + title="Some tooltip text"> Text </span> // good - <span data-toggle="tooltip"> + <span + v-tooltip + title="Some tooltip text"> Text </span> ``` -1. Tooltips: When using a tooltip, include the tooltip mixin +1. Tooltips: When using a tooltip, include the tooltip directive, `./app/assets/javascripts/vue_shared/directives/tooltip.js` 1. Don't change `data-original-title`. ```javascript diff --git a/doc/install/requirements.md b/doc/install/requirements.md index 197a92905c8..a3d676433e6 100644 --- a/doc/install/requirements.md +++ b/doc/install/requirements.md @@ -86,56 +86,32 @@ if your available memory changes. Notice: The 25 workers of Sidekiq will show up as separate processes in your process overview (such as top or htop) but they share the same RAM allocation since Sidekiq is a multithreaded application. Please see the section below about Unicorn workers for information about many you need of those. -## GitLab Runner - -We strongly advise against installing GitLab Runner on the same machine you plan -to install GitLab on. Depending on how you decide to configure GitLab Runner and -what tools you use to exercise your application in the CI environment, GitLab -Runner can consume significant amount of available memory. - -Memory consumption calculations, that are available above, will not be valid if -you decide to run GitLab Runner and the GitLab Rails application on the same -machine. - -It is also not safe to install everything on a single machine, because of the -[security reasons] - especially when you plan to use shell executor with GitLab -Runner. - -We recommend using a separate machine for each GitLab Runner, if you plan to -use the CI features. - -[security reasons]: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/security/index.md - -## Unicorn Workers - -It's possible to increase the amount of unicorn workers and this will usually help to reduce the response time of the applications and increase the ability to handle parallel requests. - -For most instances we recommend using: CPU cores + 1 = unicorn workers. -So for a machine with 2 cores, 3 unicorn workers is ideal. +## Database -For all machines that have 2GB and up we recommend a minimum of three unicorn workers. -If you have a 1GB machine we recommend to configure only two Unicorn workers to prevent excessive swapping. +The server running the database should have _at least_ 5-10 GB of storage +available, though the exact requirements depend on the size of the GitLab +installation (e.g. the number of users, projects, etc). -To change the Unicorn workers when you have the Omnibus package please see [the Unicorn settings in the Omnibus GitLab documentation](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/unicorn.md#unicorn-settings). +We currently support the following databases: -## Database +- PostgreSQL (highly recommended) +- MySQL/MariaDB (strongly discouraged, not all GitLab features are supported, no support for [MySQL/MariaDB GTID](https://mariadb.com/kb/en/mariadb/gtid/)) -We currently support the following databases: +We highly recommend the use of PostgreSQL instead of MySQL/MariaDB as not all +features of GitLab work with MySQL/MariaDB: -- PostgreSQL -- MySQL/MariaDB +1. MySQL support for subgroups was [dropped with GitLab 9.3][post]. + See [issue #30472][30472] for more information. +1. GitLab Geo does [not support MySQL](https://docs.gitlab.com/ee/gitlab-geo/database.html#mysql-replication). +1. [Zero downtime migrations][zero] do not work with MySQL +1. We expect this list to grow over time. -We _highly_ recommend the use of PostgreSQL instead of MySQL/MariaDB as not all -features of GitLab may work with MySQL/MariaDB. For example, MySQL does not have -the right features to support nested groups in an efficient manner; see -<https://gitlab.com/gitlab-org/gitlab-ce/issues/30472> for more information -about this. GitLab Geo also does [not support MySQL](https://docs.gitlab.com/ee/gitlab-geo/database.html#mysql-replication). Existing users using GitLab with MySQL/MariaDB are advised to -migrate to PostgreSQL instead. +[migrate to PostgreSQL](../update/mysql_to_postgresql.md) instead. -The server running the database should have _at least_ 5-10 GB of storage -available, though the exact requirements depend on the size of the GitLab -installation (e.g. the number of users, projects, etc). +[30472]: https://gitlab.com/gitlab-org/gitlab-ce/issues/30472 +[zero]: ../update/README.md#upgrading-without-downtime +[post]: https://about.gitlab.com/2017/06/22/gitlab-9-3-released/#dropping-support-for-subgroups-in-mysql ### PostgreSQL Requirements @@ -154,6 +130,18 @@ CREATE EXTENSION pg_trgm; On some systems you may need to install an additional package (e.g. `postgresql-contrib`) for this extension to become available. +## Unicorn Workers + +It's possible to increase the amount of unicorn workers and this will usually help to reduce the response time of the applications and increase the ability to handle parallel requests. + +For most instances we recommend using: CPU cores + 1 = unicorn workers. +So for a machine with 2 cores, 3 unicorn workers is ideal. + +For all machines that have 2GB and up we recommend a minimum of three unicorn workers. +If you have a 1GB machine we recommend to configure only two Unicorn workers to prevent excessive swapping. + +To change the Unicorn workers when you have the Omnibus package please see [the Unicorn settings in the Omnibus GitLab documentation](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/unicorn.md#unicorn-settings). + ## Redis and Sidekiq Redis stores all user sessions and the background task queue. @@ -172,6 +160,26 @@ default settings. If you would like to disable Prometheus and it's exporters or read more information about it, check the [Prometheus documentation](../administration/monitoring/prometheus/index.md). +## GitLab Runner + +We strongly advise against installing GitLab Runner on the same machine you plan +to install GitLab on. Depending on how you decide to configure GitLab Runner and +what tools you use to exercise your application in the CI environment, GitLab +Runner can consume significant amount of available memory. + +Memory consumption calculations, that are available above, will not be valid if +you decide to run GitLab Runner and the GitLab Rails application on the same +machine. + +It is also not safe to install everything on a single machine, because of the +[security reasons] - especially when you plan to use shell executor with GitLab +Runner. + +We recommend using a separate machine for each GitLab Runner, if you plan to +use the CI features. + +[security reasons]: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/security/index.md + ## Supported web browsers We support the current and the previous major release of Firefox, Chrome/Chromium, Safari and Microsoft browsers (Microsoft Edge and Internet Explorer 11). diff --git a/doc/update/9.2-to-9.3.md b/doc/update/9.2-to-9.3.md index 0c32e4db53f..8fbcc892fd5 100644 --- a/doc/update/9.2-to-9.3.md +++ b/doc/update/9.2-to-9.3.md @@ -117,7 +117,7 @@ cd /home/git/gitlab sudo -u git -H git checkout 9-3-stable-ee ``` -### 5. Update gitlab-shell +### 7. Update gitlab-shell ```bash cd /home/git/gitlab-shell @@ -127,7 +127,7 @@ sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_SHELL_VERSION) sudo -u git -H bin/compile ``` -### 6. Update gitlab-workhorse +### 8. Update gitlab-workhorse Install and compile gitlab-workhorse. This requires [Go 1.5](https://golang.org/dl) which should already be on your system from @@ -143,7 +143,7 @@ sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_WORKHORSE_VERSION) sudo -u git -H make ``` -### 7. Update Gitaly +### 9. Update Gitaly If you have not yet set up Gitaly then follow [Gitaly section of the installation guide](../install/installation.md#install-gitaly). diff --git a/doc/update/README.md b/doc/update/README.md index d024a809f24..22dbc7c750f 100644 --- a/doc/update/README.md +++ b/doc/update/README.md @@ -11,22 +11,6 @@ There are currently 3 official ways to install GitLab: Based on your installation, choose a section below that fits your needs. ---- - -<!-- START doctoc generated TOC please keep comment here to allow auto update --> -<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> -**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* - -- [Omnibus Packages](#omnibus-packages) -- [Installation from source](#installation-from-source) -- [Installation using Docker](#installation-using-docker) -- [Upgrading between editions](#upgrading-between-editions) - - [Community to Enterprise Edition](#community-to-enterprise-edition) - - [Enterprise to Community Edition](#enterprise-to-community-edition) -- [Miscellaneous](#miscellaneous) - -<!-- END doctoc generated TOC please keep comment here to allow auto update --> - ## Omnibus Packages - The [Omnibus update guide](http://docs.gitlab.com/omnibus/update/README.html) diff --git a/doc/user/group/subgroups/index.md b/doc/user/group/subgroups/index.md index c4921c74a17..5724dcfab48 100644 --- a/doc/user/group/subgroups/index.md +++ b/doc/user/group/subgroups/index.md @@ -1,6 +1,9 @@ # Subgroups -> [Introduced][ce-2772] in GitLab 9.0. +>**Notes:** +- [Introduced][ce-2772] in GitLab 9.0. +- Not available when using MySQL as external database (support removed in + GitLab 9.3 [due to performance reasons][issue]). With subgroups (aka nested groups or hierarchical groups) you can have up to 20 levels of nested groups, which among other things can help you to: @@ -173,3 +176,4 @@ Here's a list of what you can't do with subgroups: [ce-2772]: https://gitlab.com/gitlab-org/gitlab-ce/issues/2772 [permissions]: ../../permissions.md#group [reserved]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/path_regex.rb +[issue]: https://gitlab.com/gitlab-org/gitlab-ce/issues/30472#note_27747600 diff --git a/doc/user/project/integrations/webhooks.md b/doc/user/project/integrations/webhooks.md index 0517ed3ec18..023c6932e41 100644 --- a/doc/user/project/integrations/webhooks.md +++ b/doc/user/project/integrations/webhooks.md @@ -736,7 +736,7 @@ X-Gitlab-Event: Merge Request Hook ### Wiki Page events -Triggered when a wiki page is created, edited or deleted. +Triggered when a wiki page is created, updated or deleted. **Request Header**: diff --git a/doc/user/project/issues/confidential_issues.md b/doc/user/project/issues/confidential_issues.md index 208be7d0ed5..1760b182114 100644 --- a/doc/user/project/issues/confidential_issues.md +++ b/doc/user/project/issues/confidential_issues.md @@ -43,8 +43,9 @@ next to the issues that are marked as confidential. --- -While inside the issue, you can see a persistent dark banner at the top of the -screen. +Likewise, while inside the issue, you can see the eye-slash icon right next to +the issue number, but there is also an indicator in the comment area that the +issue you are commenting on is confidential. ![Confidential issue page](img/confidential_issues_issue_page.png) diff --git a/doc/user/project/issues/img/confidential_issues_issue_page.png b/doc/user/project/issues/img/confidential_issues_issue_page.png Binary files differindex 91f7cc8d3ca..f04ec8ff32b 100755 --- a/doc/user/project/issues/img/confidential_issues_issue_page.png +++ b/doc/user/project/issues/img/confidential_issues_issue_page.png diff --git a/doc/user/project/pipelines/settings.md b/doc/user/project/pipelines/settings.md index 1d2eba4f74b..a992a348c0f 100644 --- a/doc/user/project/pipelines/settings.md +++ b/doc/user/project/pipelines/settings.md @@ -1,7 +1,7 @@ # Pipelines settings To reach the pipelines settings navigate to your project's -**Settings ➔ CI/CD Pipelines**. +**Settings ➔ Pipelines**. The following settings can be configured per project. diff --git a/features/dashboard/merge_requests.feature b/features/dashboard/merge_requests.feature deleted file mode 100644 index 4a2c997d707..00000000000 --- a/features/dashboard/merge_requests.feature +++ /dev/null @@ -1,21 +0,0 @@ -@dashboard -Feature: Dashboard Merge Requests - Background: - Given I sign in as a user - And I have authored merge requests - And I have assigned merge requests - And I have other merge requests - And I visit dashboard merge requests page - - Scenario: I should see assigned merge_requests - Then I should see merge requests assigned to me - - @javascript - Scenario: I should see authored merge_requests - When I click "Authored by me" link - Then I should see merge requests authored by me - - @javascript - Scenario: I should see all merge_requests - When I click "All" link - Then I should see all merge requests diff --git a/features/dashboard/todos.feature b/features/dashboard/todos.feature deleted file mode 100644 index 0b23bbb7951..00000000000 --- a/features/dashboard/todos.feature +++ /dev/null @@ -1,28 +0,0 @@ -@dashboard -Feature: Dashboard Todos - Background: - Given I sign in as a user - And I own project "Shop" - And "John Doe" is a developer of project "Shop" - And "Mary Jane" is a developer of project "Shop" - And "Mary Jane" owns private project "Enterprise" - And I am a developer of project "Enterprise" - And I have todos - And I visit dashboard todos page - - @javascript - Scenario: I mark todos as done - Then I should see todos assigned to me - And I mark the todo as done - Then I should see the todo marked as done - - @javascript - Scenario: I mark all todos as done - Then I should see todos assigned to me - And I mark all todos as done - Then I should see all todos marked as done - - @javascript - Scenario: I click on a todo row - Given I click on the todo - Then I should be directed to the corresponding page diff --git a/features/group/members.feature b/features/group/members.feature index e539f6a1273..49a44f57cbb 100644 --- a/features/group/members.feature +++ b/features/group/members.feature @@ -4,65 +4,6 @@ Feature: Group Members And "John Doe" is owner of group "Owned" And "John Doe" is guest of group "Guest" - # Leave - - @javascript - Scenario: Owner should be able to remove himself from group if he is not the last owner - Given "Mary Jane" is owner of group "Owned" - When I visit group "Owned" members page - Then I should see user "John Doe" in team list - Then I should see user "Mary Jane" in team list - When I click on the "Remove User From Group" button for "John Doe" - And I visit group "Owned" members page - Then I should not see user "John Doe" in team list - Then I should see user "Mary Jane" in team list - - @javascript - Scenario: Owner should not be able to remove himself from group if he is the last owner - Given "Mary Jane" is guest of group "Owned" - When I visit group "Owned" members page - Then I should see user "John Doe" in team list - Then I should see user "Mary Jane" in team list - Then I should not see the "Remove User From Group" button for "John Doe" - - @javascript - Scenario: Guest should be able to remove himself from group - Given "Mary Jane" is guest of group "Guest" - When I visit group "Guest" members page - Then I should see user "John Doe" in team list - Then I should see user "Mary Jane" in team list - When I click on the "Remove User From Group" button for "John Doe" - When I visit group "Guest" members page - Then I should not see user "John Doe" in team list - Then I should see user "Mary Jane" in team list - - @javascript - Scenario: Guest should be able to remove himself from group even if he is the only user in the group - When I visit group "Guest" members page - Then I should see user "John Doe" in team list - When I click on the "Remove User From Group" button for "John Doe" - When I visit group "Guest" members page - Then I should not see user "John Doe" in team list - - # Remove others - - Scenario: Owner should be able to remove other users from group - Given "Mary Jane" is owner of group "Owned" - When I visit group "Owned" members page - Then I should see user "John Doe" in team list - Then I should see user "Mary Jane" in team list - When I click on the "Remove User From Group" button for "Mary Jane" - When I visit group "Owned" members page - Then I should see user "John Doe" in team list - Then I should not see user "Mary Jane" in team list - - Scenario: Guest should not be able to remove other users from group - Given "Mary Jane" is guest of group "Guest" - When I visit group "Guest" members page - Then I should see user "John Doe" in team list - Then I should see user "Mary Jane" in team list - Then I should not see the "Remove User From Group" button for "Mary Jane" - Scenario: Search member by name Given "Mary Jane" is guest of group "Guest" And I visit group "Guest" members page diff --git a/features/profile/notifications.feature b/features/profile/notifications.feature deleted file mode 100644 index ef8743932f5..00000000000 --- a/features/profile/notifications.feature +++ /dev/null @@ -1,15 +0,0 @@ -@profile -Feature: Profile Notifications - Background: - Given I sign in as a user - And I own project "Shop" - - Scenario: I visit notifications tab - When I visit profile notifications page - Then I should see global notifications settings - - @javascript - Scenario: I edit Project Notifications - Given I visit profile notifications page - When I select Mention setting from dropdown - Then I should see Notification saved message diff --git a/features/project/create.feature b/features/project/create.feature deleted file mode 100644 index 67336d73bf7..00000000000 --- a/features/project/create.feature +++ /dev/null @@ -1,14 +0,0 @@ -@project-create -Feature: Project Create - In order to get access to project sections - A user with ability to create a project - Should be able to create a new one - - @javascript - Scenario: User create a project - Given I sign in as a user - And I have an ssh key - When I visit new project page - And fill project form with valid data - Then I should see project page - And I should see empty project instructions diff --git a/features/steps/dashboard/merge_requests.rb b/features/steps/dashboard/merge_requests.rb deleted file mode 100644 index 909ffec3646..00000000000 --- a/features/steps/dashboard/merge_requests.rb +++ /dev/null @@ -1,121 +0,0 @@ -class Spinach::Features::DashboardMergeRequests < Spinach::FeatureSteps - include SharedAuthentication - include SharedPaths - include Select2Helper - - step 'I should see merge requests assigned to me' do - should_see(assigned_merge_request) - should_see(assigned_merge_request_from_fork) - should_not_see(authored_merge_request) - should_not_see(authored_merge_request_from_fork) - should_not_see(other_merge_request) - end - - step 'I should see merge requests authored by me' do - should_see(authored_merge_request) - should_see(authored_merge_request_from_fork) - should_not_see(assigned_merge_request) - should_not_see(assigned_merge_request_from_fork) - should_not_see(other_merge_request) - end - - step 'I should see all merge requests' do - should_see(authored_merge_request) - should_see(assigned_merge_request) - should_see(other_merge_request) - end - - step 'I have authored merge requests' do - authored_merge_request - authored_merge_request_from_fork - end - - step 'I have assigned merge requests' do - assigned_merge_request - assigned_merge_request_from_fork - end - - step 'I have other merge requests' do - other_merge_request - end - - step 'I click "Authored by me" link' do - find("#assignee_id").set("") - find(".js-author-search", match: :first).click - find(".dropdown-menu-author li a", match: :first, text: current_user.to_reference).click - end - - step 'I click "All" link' do - find(".js-author-search").click - expect(page).to have_selector(".dropdown-menu-author li a") - find(".dropdown-menu-author li a", match: :first).click - expect(page).not_to have_selector(".dropdown-menu-author li a") - - find(".js-assignee-search").click - expect(page).to have_selector(".dropdown-menu-assignee li a") - find(".dropdown-menu-assignee li a", match: :first).click - expect(page).not_to have_selector(".dropdown-menu-assignee li a") - end - - def should_see(merge_request) - expect(page).to have_content(merge_request.title[0..10]) - end - - def should_not_see(merge_request) - expect(page).not_to have_content(merge_request.title[0..10]) - end - - def assigned_merge_request - @assigned_merge_request ||= create :merge_request, - assignee: current_user, - target_project: project, - source_project: project - end - - def authored_merge_request - @authored_merge_request ||= create :merge_request, - source_branch: 'markdown', - author: current_user, - target_project: project, - source_project: project - end - - def other_merge_request - @other_merge_request ||= create :merge_request, - source_branch: 'fix', - target_project: project, - source_project: project - end - - def authored_merge_request_from_fork - @authored_merge_request_from_fork ||= create :merge_request, - source_branch: 'feature_conflict', - author: current_user, - target_project: public_project, - source_project: forked_project - end - - def assigned_merge_request_from_fork - @assigned_merge_request_from_fork ||= create :merge_request, - source_branch: 'markdown', - assignee: current_user, - target_project: public_project, - source_project: forked_project - end - - def project - @project ||= begin - project = create(:project, :repository) - project.team << [current_user, :master] - project - end - end - - def public_project - @public_project ||= create(:project, :public, :repository) - end - - def forked_project - @forked_project ||= Projects::ForkService.new(public_project, current_user).execute - end -end diff --git a/features/steps/dashboard/todos.rb b/features/steps/dashboard/todos.rb deleted file mode 100644 index 4a33babe3bd..00000000000 --- a/features/steps/dashboard/todos.rb +++ /dev/null @@ -1,191 +0,0 @@ -class Spinach::Features::DashboardTodos < Spinach::FeatureSteps - include SharedAuthentication - include SharedPaths - include SharedProject - include SharedUser - include WaitForRequests - - step '"John Doe" is a developer of project "Shop"' do - project.team << [john_doe, :developer] - end - - step 'I am a developer of project "Enterprise"' do - enterprise.team << [current_user, :developer] - end - - step '"Mary Jane" is a developer of project "Shop"' do - project.team << [john_doe, :developer] - end - - step 'I have todos' do - create(:todo, user: current_user, project: project, author: mary_jane, target: issue, action: Todo::MENTIONED) - create(:todo, user: current_user, project: project, author: john_doe, target: issue, action: Todo::ASSIGNED) - note = create(:note, author: john_doe, noteable: issue, note: "#{current_user.to_reference} Wdyt?", project: project) - create(:todo, user: current_user, project: project, author: john_doe, target: issue, action: Todo::MENTIONED, note: note) - create(:todo, user: current_user, project: project, author: john_doe, target: merge_request, action: Todo::ASSIGNED) - end - - step 'I should see todos assigned to me' do - merge_request_reference = merge_request.to_reference(full: true) - issue_reference = issue.to_reference(full: true) - - page.within('.todos-count') { expect(page).to have_content '4' } - expect(page).to have_content 'To do 4' - expect(page).to have_content 'Done 0' - - expect(page).to have_link project.name_with_namespace - should_see_todo(1, "John Doe assigned you merge request #{merge_request_reference}", merge_request.title) - should_see_todo(2, "John Doe mentioned you on issue #{issue_reference}", "#{current_user.to_reference} Wdyt?") - should_see_todo(3, "John Doe assigned you issue #{issue_reference}", issue.title) - should_see_todo(4, "Mary Jane mentioned you on issue #{issue_reference}", issue.title) - end - - step 'I mark the todo as done' do - page.within('.todo:nth-child(1)') do - click_link 'Done' - end - - page.within('.todos-count') { expect(page).to have_content '3' } - expect(page).to have_content 'To do 3' - expect(page).to have_content 'Done 1' - should_see_todo(1, "John Doe assigned you merge request #{merge_request.to_reference(full: true)}", merge_request.title, state: :done_reversible) - end - - step 'I mark all todos as done' do - merge_request_reference = merge_request.to_reference(full: true) - issue_reference = issue.to_reference(full: true) - - find('.js-todos-mark-all').trigger('click') - - page.within('.todos-count') { expect(page).to have_content '0' } - expect(page).to have_content 'To do 0' - expect(page).to have_content 'Done 4' - expect(page).to have_content "You're all done!" - expect('.prepend-top-default').not_to have_link project.name_with_namespace - should_not_see_todo "John Doe assigned you merge request #{merge_request_reference}" - should_not_see_todo "John Doe mentioned you on issue #{issue_reference}" - should_not_see_todo "John Doe assigned you issue #{issue_reference}" - should_not_see_todo "Mary Jane mentioned you on issue #{issue_reference}" - end - - step 'I should see the todo marked as done' do - find('.todos-done a').trigger('click') - - expect(page).to have_link project.name_with_namespace - should_see_todo(1, "John Doe assigned you merge request #{merge_request.to_reference(full: true)}", merge_request.title, state: :done_irreversible) - end - - step 'I should see all todos marked as done' do - merge_request_reference = merge_request.to_reference(full: true) - issue_reference = issue.to_reference(full: true) - - find('.todos-done a').trigger('click') - - expect(page).to have_link project.name_with_namespace - should_see_todo(1, "John Doe assigned you merge request #{merge_request_reference}", merge_request.title, state: :done_irreversible) - should_see_todo(2, "John Doe mentioned you on issue #{issue_reference}", "#{current_user.to_reference} Wdyt?", state: :done_irreversible) - should_see_todo(3, "John Doe assigned you issue #{issue_reference}", issue.title, state: :done_irreversible) - should_see_todo(4, "Mary Jane mentioned you on issue #{issue_reference}", issue.title, state: :done_irreversible) - end - - step 'I filter by "Enterprise"' do - click_button 'Project' - page.within '.dropdown-menu-project' do - click_link enterprise.name_with_namespace - end - end - - step 'I filter by "John Doe"' do - click_button 'Author' - page.within '.dropdown-menu-author' do - click_link john_doe.username - end - end - - step 'I filter by "Issue"' do - click_button 'Type' - page.within '.dropdown-menu-type' do - click_link 'Issue' - end - end - - step 'I filter by "Mentioned"' do - click_button 'Action' - page.within '.dropdown-menu-action' do - click_link 'Mentioned' - end - end - - step 'I should not see todos' do - expect(page).to have_content "You're all done!" - end - - step 'I should not see todos related to "Mary Jane" in the list' do - should_not_see_todo "Mary Jane mentioned you on issue #{issue.to_reference(full: true)}" - end - - step 'I should not see todos related to "Merge Requests" in the list' do - should_not_see_todo "John Doe assigned you merge request #{merge_request.to_reference(full: true)}" - end - - step 'I should not see todos related to "Assignments" in the list' do - should_not_see_todo "John Doe assigned you merge request #{merge_request.to_reference(full: true)}" - should_not_see_todo "John Doe assigned you issue #{issue.to_reference(full: true)}" - end - - step 'I click on the todo' do - find('.todo:nth-child(1)').click - end - - step 'I should be directed to the corresponding page' do - page.should have_css('.identifier', text: 'Merge request !1') - # Merge request page loads and issues a number of Ajax requests - wait_for_requests - end - - def should_see_todo(position, title, body, state: :pending) - page.within(".todo:nth-child(#{position})") do - expect(page).to have_content title - expect(page).to have_content body - - if state == :pending - expect(page).to have_link 'Done' - elsif state == :done_reversible - expect(page).to have_link 'Undo' - elsif state == :done_irreversible - expect(page).not_to have_link 'Undo' - expect(page).not_to have_link 'Done' - else - raise 'Invalid state given, valid states: :pending, :done_reversible, :done_irreversible' - end - end - end - - def should_not_see_todo(title) - expect(page).not_to have_visible_content title - end - - def have_visible_content(text) - have_css('*', text: text, visible: true) - end - - def john_doe - @john_doe ||= user_exists("John Doe", { username: "john_doe" }) - end - - def mary_jane - @mary_jane ||= user_exists("Mary Jane", { username: "mary_jane" }) - end - - def enterprise - @enterprise ||= Project.find_by(name: 'Enterprise') - end - - def issue - @issue ||= create(:issue, assignees: [current_user], project: project) - end - - def merge_request - @merge_request ||= create(:merge_request, assignee: current_user, source_project: project) - end -end diff --git a/features/steps/groups.rb b/features/steps/groups.rb index 25bb374b868..0aedc422563 100644 --- a/features/steps/groups.rb +++ b/features/steps/groups.rb @@ -5,7 +5,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps include SharedUser step 'I should see group "Owned"' do - expect(page).to have_content '@owned' + expect(page).to have_content 'Owned' end step 'I am a signed out user' do diff --git a/features/steps/project/source/browse_files.rb b/features/steps/project/source/browse_files.rb index 80aa3a047a0..9ed4f8ea1f9 100644 --- a/features/steps/project/source/browse_files.rb +++ b/features/steps/project/source/browse_files.rb @@ -369,7 +369,6 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps expect(page).to have_content 'Permalink' expect(page).not_to have_content 'Edit' expect(page).not_to have_content 'Blame' - expect(page).not_to have_content 'Annotate' expect(page).to have_content 'Delete' expect(page).to have_content 'Replace' end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index f0e751b820a..8a5b4112ffe 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -112,10 +112,6 @@ module SharedPaths visit dashboard_groups_path end - step 'I visit dashboard todos page' do - visit dashboard_todos_path - end - step 'I should be redirected to the dashboard groups page' do expect(current_path).to eq dashboard_groups_path end diff --git a/lib/api/access_requests.rb b/lib/api/access_requests.rb index a5c9f0b509c..c9b5f58c557 100644 --- a/lib/api/access_requests.rb +++ b/lib/api/access_requests.rb @@ -68,8 +68,8 @@ module API delete ":id/access_requests/:user_id" do source = find_source(source_type, params[:id]) - ::Members::DestroyService.new(source, current_user, params). - execute(:requesters) + ::Members::DestroyService.new(source, current_user, params) + .execute(:requesters) end end end diff --git a/lib/api/branches.rb b/lib/api/branches.rb index f35084a582a..3d816f8771d 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -102,8 +102,8 @@ module API post ":id/repository/branches" do authorize_push_project - result = CreateBranchService.new(user_project, current_user). - execute(params[:branch], params[:ref]) + result = CreateBranchService.new(user_project, current_user) + .execute(params[:branch], params[:ref]) if result[:status] == :success present result[:branch], @@ -121,8 +121,8 @@ module API delete ":id/repository/branches/:branch", requirements: { branch: /.+/ } do authorize_push_project - result = DeleteBranchService.new(user_project, current_user). - execute(params[:branch]) + result = DeleteBranchService.new(user_project, current_user) + .execute(params[:branch]) if result[:status] != :success render_api_error!(result[:message], result[:return_code]) diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb index 10f2d5ef6a3..485b680cd5f 100644 --- a/lib/api/commit_statuses.rb +++ b/lib/api/commit_statuses.rb @@ -108,6 +108,9 @@ module API render_api_error!('invalid state', 400) end + MergeRequest.where(source_project: @project, source_branch: ref) + .update_all(head_pipeline_id: pipeline) if pipeline.latest? + present status, with: Entities::CommitStatus rescue StateMachines::InvalidTransition => e render_api_error!(e.message, 400) diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 7cdee8aced7..d5c2f3d5094 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -86,7 +86,7 @@ module API at_least_one_of :title, :can_push end put ":id/deploy_keys/:key_id" do - key = user_project.deploy_keys.find(params.delete(:key_id)) + key = DeployKey.find(params.delete(:key_id)) authorize!(:update_deploy_key, key) diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 412443a2405..aa91451c9f4 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -43,11 +43,14 @@ module API expose :external end - class UserWithPrivateDetails < UserPublic - expose :private_token + class UserWithAdmin < UserPublic expose :admin?, as: :is_admin end + class UserWithPrivateDetails < UserWithAdmin + expose :private_token + end + class Email < Grape::Entity expose :id, :email end @@ -115,6 +118,7 @@ module API expose :only_allow_merge_if_pipeline_succeeds expose :request_access_enabled expose :only_allow_merge_if_all_discussions_are_resolved + expose :printing_merge_request_link_enabled expose :statistics, using: 'API::Entities::ProjectStatistics', if: :statistics end @@ -480,9 +484,9 @@ module API expose :job_events # Expose serialized properties expose :properties do |service, options| - field_names = service.fields. - select { |field| options[:include_passwords] || field[:type] != 'password' }. - map { |field| field[:name] } + field_names = service.fields + .select { |field| options[:include_passwords] || field[:type] != 'password' } + .map { |field| field[:name] } service.properties.slice(*field_names) end end diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 9ec418edea4..f1c79970ba4 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -71,11 +71,16 @@ module API end # - # Discover user by ssh key + # Discover user by ssh key or user id # get "/discover" do - key = Key.find(params[:key_id]) - present key.user, with: Entities::UserSafe + if params[:key_id] + key = Key.find(params[:key_id]) + user = key.user + elsif params[:user_id] + user = User.find_by(id: params[:user_id]) + end + present user, with: Entities::UserSafe end get "/check" do @@ -127,8 +132,11 @@ module API return { success: false, message: 'Two-factor authentication is not enabled for this user' } end - codes = user.generate_otp_backup_codes! - user.save! + codes = nil + + ::Users::UpdateService.new(user).execute! do |user| + codes = user.generate_otp_backup_codes! + end { success: true, recovery_codes: codes } end diff --git a/lib/api/notes.rb b/lib/api/notes.rb index e281e3230fd..01ca62b593f 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -33,8 +33,8 @@ module API # paginate() only works with a relation. This could lead to a # mismatch between the pagination headers info and the actual notes # array returned, but this is really a edge-case. - paginate(noteable.notes). - reject { |n| n.cross_reference_not_visible_for?(current_user) } + paginate(noteable.notes) + .reject { |n| n.cross_reference_not_visible_for?(current_user) } present notes, with: Entities::Note else not_found!("Notes") diff --git a/lib/api/notification_settings.rb b/lib/api/notification_settings.rb index 992ea5dc24d..5d113c94b22 100644 --- a/lib/api/notification_settings.rb +++ b/lib/api/notification_settings.rb @@ -34,7 +34,10 @@ module API notification_setting.transaction do new_notification_email = params.delete(:notification_email) - current_user.update(notification_email: new_notification_email) if new_notification_email + if new_notification_email + ::Users::UpdateService.new(current_user, notification_email: new_notification_email).execute + end + notification_setting.update(declared_params(include_missing: false)) end rescue ArgumentError => e # catch level enum error diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 50d34e8a738..c5df45b7902 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -23,6 +23,7 @@ module API optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved' optional :tag_list, type: Array[String], desc: 'The list of tags for a project' optional :avatar, type: File, desc: 'Avatar image for project' + optional :printing_merge_request_link_enabled, type: Boolean, desc: 'Show link to create/view merge request when pushing from the command line' end params :optional_params do @@ -218,6 +219,7 @@ module API :only_allow_merge_if_all_discussions_are_resolved, :only_allow_merge_if_pipeline_succeeds, :path, + :printing_merge_request_link_enabled, :public_builds, :request_access_enabled, :shared_runners_enabled, diff --git a/lib/api/tags.rb b/lib/api/tags.rb index c7b1efe0bfa..633a858f8c7 100644 --- a/lib/api/tags.rb +++ b/lib/api/tags.rb @@ -44,8 +44,8 @@ module API post ':id/repository/tags' do authorize_push_project - result = ::Tags::CreateService.new(user_project, current_user). - execute(params[:tag_name], params[:ref], params[:message], params[:release_description]) + result = ::Tags::CreateService.new(user_project, current_user) + .execute(params[:tag_name], params[:ref], params[:message], params[:release_description]) if result[:status] == :success present result[:tag], @@ -63,8 +63,8 @@ module API delete ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do authorize_push_project - result = ::Tags::DestroyService.new(user_project, current_user). - execute(params[:tag_name]) + result = ::Tags::DestroyService.new(user_project, current_user) + .execute(params[:tag_name]) if result[:status] != :success render_api_error!(result[:message], result[:return_code]) @@ -81,8 +81,8 @@ module API post ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.+/ } do authorize_push_project - result = CreateReleaseService.new(user_project, current_user). - execute(params[:tag_name], params[:description]) + result = CreateReleaseService.new(user_project, current_user) + .execute(params[:tag_name], params[:description]) if result[:status] == :success present result[:release], with: Entities::Release @@ -101,8 +101,8 @@ module API put ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.+/ } do authorize_push_project - result = UpdateReleaseService.new(user_project, current_user). - execute(params[:tag_name], params[:description]) + result = UpdateReleaseService.new(user_project, current_user) + .execute(params[:tag_name], params[:description]) if result[:status] == :success present result[:release], with: Entities::Release diff --git a/lib/api/users.rb b/lib/api/users.rb index 7257ecb5b67..f9555842daf 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -59,7 +59,7 @@ module API users = UsersFinder.new(current_user, params).execute - entity = current_user.admin? ? Entities::UserPublic : Entities::UserBasic + entity = current_user.admin? ? Entities::UserWithAdmin : Entities::UserBasic present paginate(users), with: entity end @@ -98,18 +98,18 @@ module API authenticated_as_admin! params = declared_params(include_missing: false) - user = ::Users::CreateService.new(current_user, params).execute + user = ::Users::CreateService.new(current_user, params).execute(skip_authorization: true) if user.persisted? present user, with: Entities::UserPublic else - conflict!('Email has already been taken') if User. - where(email: user.email). - count > 0 + conflict!('Email has already been taken') if User + .where(email: user.email) + .count > 0 - conflict!('Username has already been taken') if User. - where(username: user.username). - count > 0 + conflict!('Username has already been taken') if User + .where(username: user.username) + .count > 0 render_validation_error!(user) end @@ -133,12 +133,12 @@ module API not_found!('User') unless user conflict!('Email has already been taken') if params[:email] && - User.where(email: params[:email]). - where.not(id: user.id).count > 0 + User.where(email: params[:email]) + .where.not(id: user.id).count > 0 conflict!('Username has already been taken') if params[:username] && - User.where(username: params[:username]). - where.not(id: user.id).count > 0 + User.where(username: params[:username]) + .where.not(id: user.id).count > 0 user_params = declared_params(include_missing: false) identity_attrs = user_params.slice(:provider, :extern_uid) @@ -156,7 +156,9 @@ module API user_params[:password_expires_at] = Time.now if user_params[:password].present? - if user.update_attributes(user_params.except(:extern_uid, :provider)) + result = ::Users::UpdateService.new(user, user_params.except(:extern_uid, :provider)).execute + + if result[:status] == :success present user, with: Entities::UserPublic else render_validation_error!(user) @@ -234,9 +236,9 @@ module API user = User.find_by(id: params.delete(:id)) not_found!('User') unless user - email = user.emails.new(declared_params(include_missing: false)) + email = Emails::CreateService.new(user, declared_params(include_missing: false)).execute - if email.save + if email.errors.blank? NotificationService.new.new_email(email) present email, with: Entities::Email else @@ -274,8 +276,7 @@ module API email = user.emails.find_by(id: params[:email_id]) not_found!('Email') unless email - email.destroy - user.update_secondary_emails! + Emails::DestroyService.new(user, email: email.email).execute end desc 'Delete a user. Available only for admins.' do @@ -487,9 +488,9 @@ module API requires :email, type: String, desc: 'The new email' end post "emails" do - email = current_user.emails.new(declared_params) + email = Emails::CreateService.new(current_user, declared_params).execute - if email.save + if email.errors.blank? NotificationService.new.new_email(email) present email, with: Entities::Email else @@ -505,8 +506,7 @@ module API email = current_user.emails.find_by(id: params[:email_id]) not_found!('Email') unless email - email.destroy - current_user.update_secondary_emails! + Emails::DestroyService.new(current_user, email: email.email).execute end desc 'Get a list of user activities' @@ -517,9 +517,9 @@ module API get "activities" do authenticated_as_admin! - activities = User. - where(User.arel_table[:last_activity_on].gteq(params[:from])). - reorder(last_activity_on: :asc) + activities = User + .where(User.arel_table[:last_activity_on].gteq(params[:from])) + .reorder(last_activity_on: :asc) present paginate(activities), with: Entities::UserActivity end diff --git a/lib/api/v3/branches.rb b/lib/api/v3/branches.rb index 0a877b960f6..81b13249892 100644 --- a/lib/api/v3/branches.rb +++ b/lib/api/v3/branches.rb @@ -26,8 +26,8 @@ module API delete ":id/repository/branches/:branch", requirements: { branch: /.+/ } do authorize_push_project - result = DeleteBranchService.new(user_project, current_user). - execute(params[:branch]) + result = DeleteBranchService.new(user_project, current_user) + .execute(params[:branch]) if result[:status] == :success status(200) @@ -55,8 +55,8 @@ module API end post ":id/repository/branches" do authorize_push_project - result = CreateBranchService.new(user_project, current_user). - execute(params[:branch_name], params[:ref]) + result = CreateBranchService.new(user_project, current_user) + .execute(params[:branch_name], params[:ref]) if result[:status] == :success present result[:branch], diff --git a/lib/api/v3/entities.rb b/lib/api/v3/entities.rb index 7c5065dee90..c848f52723b 100644 --- a/lib/api/v3/entities.rb +++ b/lib/api/v3/entities.rb @@ -245,9 +245,9 @@ module API expose :job_events, as: :build_events # Expose serialized properties expose :properties do |service, options| - field_names = service.fields. - select { |field| options[:include_passwords] || field[:type] != 'password' }. - map { |field| field[:name] } + field_names = service.fields + .select { |field| options[:include_passwords] || field[:type] != 'password' } + .map { |field| field[:name] } service.properties.slice(*field_names) end end diff --git a/lib/api/v3/helpers.rb b/lib/api/v3/helpers.rb index d9e76560d03..4e63aa01c1a 100644 --- a/lib/api/v3/helpers.rb +++ b/lib/api/v3/helpers.rb @@ -38,7 +38,10 @@ module API projects = projects.where(visibility_level: Gitlab::VisibilityLevel.level_value(params[:visibility])) end - projects = projects.where(archived: params[:archived]) + unless params[:archived].nil? + projects = projects.where(archived: to_boolean(params[:archived])) + end + projects.reorder(params[:order_by] => params[:sort]) end end diff --git a/lib/api/v3/notes.rb b/lib/api/v3/notes.rb index 009ec5c6bbd..23fe95e42e4 100644 --- a/lib/api/v3/notes.rb +++ b/lib/api/v3/notes.rb @@ -34,8 +34,8 @@ module API # paginate() only works with a relation. This could lead to a # mismatch between the pagination headers info and the actual notes # array returned, but this is really a edge-case. - paginate(noteable.notes). - reject { |n| n.cross_reference_not_visible_for?(current_user) } + paginate(noteable.notes) + .reject { |n| n.cross_reference_not_visible_for?(current_user) } present notes, with: ::API::V3::Entities::Note else not_found!("Notes") diff --git a/lib/api/v3/projects.rb b/lib/api/v3/projects.rb index 20976b9dd08..eb090453b48 100644 --- a/lib/api/v3/projects.rb +++ b/lib/api/v3/projects.rb @@ -69,7 +69,7 @@ module API end params :filter_params do - optional :archived, type: Boolean, default: false, desc: 'Limit by archived status' + optional :archived, type: Boolean, default: nil, desc: 'Limit by archived status' optional :visibility, type: String, values: %w[public internal private], desc: 'Limit by visibility' optional :search, type: String, desc: 'Return list of authorized projects matching the search criteria' diff --git a/lib/api/v3/tags.rb b/lib/api/v3/tags.rb index c2541de2f50..7e5875cd030 100644 --- a/lib/api/v3/tags.rb +++ b/lib/api/v3/tags.rb @@ -22,8 +22,8 @@ module API delete ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do authorize_push_project - result = ::Tags::DestroyService.new(user_project, current_user). - execute(params[:tag_name]) + result = ::Tags::DestroyService.new(user_project, current_user) + .execute(params[:tag_name]) if result[:status] == :success status(200) diff --git a/lib/api/v3/users.rb b/lib/api/v3/users.rb index f4cda3b2eba..37020019e07 100644 --- a/lib/api/v3/users.rb +++ b/lib/api/v3/users.rb @@ -50,13 +50,13 @@ module API if user.persisted? present user, with: ::API::Entities::UserPublic else - conflict!('Email has already been taken') if User. - where(email: user.email). - count > 0 + conflict!('Email has already been taken') if User + .where(email: user.email) + .count > 0 - conflict!('Username has already been taken') if User. - where(username: user.username). - count > 0 + conflict!('Username has already been taken') if User + .where(username: user.username) + .count > 0 render_validation_error!(user) end @@ -137,11 +137,11 @@ module API user = User.find_by(id: params[:id]) not_found!('User') unless user - events = user.events. - merge(ProjectsFinder.new(current_user: current_user).execute). - references(:project). - with_associations. - recent + events = user.events + .merge(ProjectsFinder.new(current_user: current_user).execute) + .references(:project) + .with_associations + .recent present paginate(events), with: ::API::V3::Entities::Event end diff --git a/lib/api/variables.rb b/lib/api/variables.rb index 381c4ef50b0..10374995497 100644 --- a/lib/api/variables.rb +++ b/lib/api/variables.rb @@ -45,7 +45,7 @@ module API optional :protected, type: String, desc: 'Whether the variable is protected' end post ':id/variables' do - variable = user_project.variables.create(declared(params, include_parent_namespaces: false).to_h) + variable = user_project.variables.create(declared_params(include_missing: false)) if variable.valid? present variable, with: Entities::Variable diff --git a/lib/banzai/reference_extractor.rb b/lib/banzai/reference_extractor.rb index 8e3b0c4db79..7e6357f8a00 100644 --- a/lib/banzai/reference_extractor.rb +++ b/lib/banzai/reference_extractor.rb @@ -10,8 +10,8 @@ module Banzai end def references(type, project, current_user = nil) - processor = Banzai::ReferenceParser[type]. - new(project, current_user) + processor = Banzai::ReferenceParser[type] + .new(project, current_user) processor.process(html_documents) end diff --git a/lib/banzai/reference_parser/issue_parser.rb b/lib/banzai/reference_parser/issue_parser.rb index 89ec715ddf6..9fd4bd68d43 100644 --- a/lib/banzai/reference_parser/issue_parser.rb +++ b/lib/banzai/reference_parser/issue_parser.rb @@ -9,8 +9,8 @@ module Banzai issues = issues_for_nodes(nodes) - readable_issues = Ability. - issues_readable_by_user(issues.values, user).to_set + readable_issues = Ability + .issues_readable_by_user(issues.values, user).to_set nodes.select do |node| readable_issues.include?(issues[node]) diff --git a/lib/banzai/reference_parser/user_parser.rb b/lib/banzai/reference_parser/user_parser.rb index 3efbd2fd631..4d336068861 100644 --- a/lib/banzai/reference_parser/user_parser.rb +++ b/lib/banzai/reference_parser/user_parser.rb @@ -99,8 +99,8 @@ module Banzai def find_users_for_projects(ids) return [] if ids.empty? - collection_objects_for_ids(Project, ids). - flat_map { |p| p.team.members.to_a } + collection_objects_for_ids(Project, ids) + .flat_map { |p| p.team.members.to_a } end def can_read_reference?(user, ref_project, node) diff --git a/lib/ci/charts.rb b/lib/ci/charts.rb index 3decc3b1a26..872e418c788 100644 --- a/lib/ci/charts.rb +++ b/lib/ci/charts.rb @@ -2,10 +2,10 @@ module Ci module Charts module DailyInterval def grouped_count(query) - query. - group("DATE(#{Ci::Build.table_name}.created_at)"). - count(:created_at). - transform_keys { |date| date.strftime(@format) } + query + .group("DATE(#{Ci::Pipeline.table_name}.created_at)") + .count(:created_at) + .transform_keys { |date| date.strftime(@format) } end def interval_step @@ -16,14 +16,14 @@ module Ci module MonthlyInterval def grouped_count(query) if Gitlab::Database.postgresql? - query. - group("to_char(#{Ci::Build.table_name}.created_at, '01 Month YYYY')"). - count(:created_at). - transform_keys(&:squish) + query + .group("to_char(#{Ci::Pipeline.table_name}.created_at, '01 Month YYYY')") + .count(:created_at) + .transform_keys(&:squish) else - query. - group("DATE_FORMAT(#{Ci::Build.table_name}.created_at, '01 %M %Y')"). - count(:created_at) + query + .group("DATE_FORMAT(#{Ci::Pipeline.table_name}.created_at, '01 %M %Y')") + .count(:created_at) end end @@ -33,21 +33,21 @@ module Ci end class Chart - attr_reader :labels, :total, :success, :project, :build_times + attr_reader :labels, :total, :success, :project, :pipeline_times def initialize(project) @labels = [] @total = [] @success = [] - @build_times = [] + @pipeline_times = [] @project = project collect end def collect - query = project.builds. - where("? > #{Ci::Build.table_name}.created_at AND #{Ci::Build.table_name}.created_at > ?", @to, @from) + query = project.pipelines + .where("? > #{Ci::Pipeline.table_name}.created_at AND #{Ci::Pipeline.table_name}.created_at > ?", @to, @from) totals_count = grouped_count(query) success_count = grouped_count(query.success) @@ -101,14 +101,14 @@ module Ci end end - class BuildTime < Chart + class PipelineTime < Chart def collect commits = project.pipelines.last(30) commits.each do |commit| @labels << commit.short_sha duration = commit.duration || 0 - @build_times << (duration / 60) + @pipeline_times << (duration / 60) end end end diff --git a/lib/feature.rb b/lib/feature.rb index 5650a1c1334..d3d972564af 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -39,8 +39,6 @@ class Feature get(key).disable end - private - def flipper @flipper ||= begin adapter = Flipper::Adapters::ActiveRecord.new( diff --git a/lib/github/import.rb b/lib/github/import.rb index b20614b3060..ff5d7db2705 100644 --- a/lib/github/import.rb +++ b/lib/github/import.rb @@ -172,7 +172,7 @@ module Github next unless merge_request.new_record? && pull_request.valid? begin - restore_branches(pull_request) + pull_request.restore_branches! author_id = user_id(pull_request.author, project.creator_id) description = format_description(pull_request.description, pull_request.author) @@ -208,7 +208,7 @@ module Github rescue => e error(:pull_request, pull_request.url, e.message) ensure - clean_up_restored_branches(pull_request) + pull_request.remove_restored_branches! end end @@ -325,32 +325,6 @@ module Github end end - def restore_branches(pull_request) - restore_source_branch(pull_request) unless pull_request.source_branch_exists? - restore_target_branch(pull_request) unless pull_request.target_branch_exists? - end - - def restore_source_branch(pull_request) - repository.create_branch(pull_request.source_branch_name, pull_request.source_branch_sha) - end - - def restore_target_branch(pull_request) - repository.create_branch(pull_request.target_branch_name, pull_request.target_branch_sha) - end - - def remove_branch(name) - repository.delete_branch(name) - rescue Rugged::ReferenceError - errors << { type: :branch, url: nil, error: "Could not clean up restored branch: #{name}" } - end - - def clean_up_restored_branches(pull_request) - return if pull_request.opened? - - remove_branch(pull_request.source_branch_name) unless pull_request.source_branch_exists? - remove_branch(pull_request.target_branch_name) unless pull_request.target_branch_exists? - end - def label_ids(labels) labels.map { |attrs| cached[:label_ids][attrs.fetch('name')] }.compact end diff --git a/lib/github/representation/branch.rb b/lib/github/representation/branch.rb index d1dac6944f0..c6fa928d565 100644 --- a/lib/github/representation/branch.rb +++ b/lib/github/representation/branch.rb @@ -26,13 +26,25 @@ module Github end def exists? - branch_exists? && commit_exists? + @exists ||= branch_exists? && commit_exists? end def valid? sha.present? && ref.present? end + def restore!(name) + repository.create_branch(name, sha) + rescue Gitlab::Git::Repository::InvalidRef => e + Rails.logger.error("#{self.class.name}: Could not restore branch #{name}: #{e}") + end + + def remove!(name) + repository.delete_branch(name) + rescue Rugged::ReferenceError => e + Rails.logger.error("#{self.class.name}: Could not remove branch #{name}: #{e}") + end + private def branch_exists? diff --git a/lib/github/representation/pull_request.rb b/lib/github/representation/pull_request.rb index ac9c8283b4b..55461097e8a 100644 --- a/lib/github/representation/pull_request.rb +++ b/lib/github/representation/pull_request.rb @@ -1,8 +1,6 @@ module Github module Representation class PullRequest < Representation::Issuable - attr_reader :project - delegate :user, :repo, :ref, :sha, to: :source_branch, prefix: true delegate :user, :exists?, :repo, :ref, :sha, :short_sha, to: :target_branch, prefix: true @@ -10,10 +8,6 @@ module Github project end - def source_branch_exists? - !cross_project? && source_branch.exists? - end - def source_branch_name @source_branch_name ||= if cross_project? || !source_branch_exists? @@ -23,6 +17,12 @@ module Github end end + def source_branch_exists? + return @source_branch_exists if defined?(@source_branch_exists) + + @source_branch_exists = !cross_project? && source_branch.exists? + end + def target_project project end @@ -31,6 +31,10 @@ module Github @target_branch_name ||= target_branch_exists? ? target_branch_ref : target_branch_name_prefixed end + def target_branch_exists? + @target_branch_exists ||= target_branch.exists? + end + def state return 'merged' if raw['state'] == 'closed' && raw['merged_at'].present? return 'closed' if raw['state'] == 'closed' @@ -46,6 +50,18 @@ module Github source_branch.valid? && target_branch.valid? end + def restore_branches! + restore_source_branch! + restore_target_branch! + end + + def remove_restored_branches! + return if opened? + + remove_source_branch! + remove_target_branch! + end + private def project @@ -73,6 +89,32 @@ module Github source_branch_repo.id != target_branch_repo.id end + + def restore_source_branch! + return if source_branch_exists? + + source_branch.restore!(source_branch_name) + end + + def restore_target_branch! + return if target_branch_exists? + + target_branch.restore!(target_branch_name) + end + + def remove_source_branch! + # We should remove the source/target branches only if they were + # restored. Otherwise, we'll remove branches like 'master' that + # target_branch_exists? returns true. In other words, we need + # to clean up only the restored branches that (source|target)_branch_exists? + # returns false for the first time it has been called, because of + # this that is important to memoize these values. + source_branch.remove!(source_branch_name) unless source_branch_exists? + end + + def remove_target_branch! + target_branch.remove!(target_branch_name) unless target_branch_exists? + end end end end diff --git a/lib/gitlab/background_migration.rb b/lib/gitlab/background_migration.rb index 914a3b72abd..d95ecd7b291 100644 --- a/lib/gitlab/background_migration.rb +++ b/lib/gitlab/background_migration.rb @@ -5,8 +5,8 @@ module Gitlab # # steal_class - The name of the class for which to steal jobs. def self.steal(steal_class) - queue = Sidekiq::Queue. - new(BackgroundMigrationWorker.sidekiq_options['queue']) + queue = Sidekiq::Queue + .new(BackgroundMigrationWorker.sidekiq_options['queue']) queue.each do |job| migration_class, migration_args = job.args diff --git a/lib/gitlab/cache/ci/project_pipeline_status.rb b/lib/gitlab/cache/ci/project_pipeline_status.rb index 4fc9a075edc..9c2e09943b0 100644 --- a/lib/gitlab/cache/ci/project_pipeline_status.rb +++ b/lib/gitlab/cache/ci/project_pipeline_status.rb @@ -50,8 +50,8 @@ module Gitlab ref: pipeline.ref } - new(pipeline.project, pipeline_info: pipeline_info). - store_in_cache_if_needed + new(pipeline.project, pipeline_info: pipeline_info) + .store_in_cache_if_needed end def initialize(project, pipeline_info: {}, loaded_from_cache: nil) diff --git a/lib/gitlab/ci/pipeline_duration.rb b/lib/gitlab/ci/pipeline_duration.rb index a210e76acaa..3208cc2bef6 100644 --- a/lib/gitlab/ci/pipeline_duration.rb +++ b/lib/gitlab/ci/pipeline_duration.rb @@ -87,8 +87,8 @@ module Gitlab def from_pipeline(pipeline) status = %w[success failed running canceled] - builds = pipeline.builds.latest. - where(status: status).where.not(started_at: nil).order(:started_at) + builds = pipeline.builds.latest + .where(status: status).where.not(started_at: nil).order(:started_at) from_builds(builds) end diff --git a/lib/gitlab/conflict/file_collection.rb b/lib/gitlab/conflict/file_collection.rb index 6e73361cad1..1611eba31da 100644 --- a/lib/gitlab/conflict/file_collection.rb +++ b/lib/gitlab/conflict/file_collection.rb @@ -16,9 +16,9 @@ module Gitlab project = merge_request.source_project new(merge_request, project).tap do |file_collection| - project. - repository. - with_repo_branch_commit(merge_request.target_project.repository, merge_request.target_branch) do + project + .repository + .with_repo_branch_commit(merge_request.target_project.repository, merge_request.target_branch) do yield file_collection end diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb index 060e013183f..bf557103cfd 100644 --- a/lib/gitlab/contributions_calendar.rb +++ b/lib/gitlab/contributions_calendar.rb @@ -16,14 +16,14 @@ module Gitlab # Can't use Event.contributions here because we need to check 3 different # project_features for the (currently) 3 different contribution types date_from = 1.year.ago - repo_events = event_counts(date_from, :repository). - having(action: Event::PUSHED) - issue_events = event_counts(date_from, :issues). - having(action: [Event::CREATED, Event::CLOSED], target_type: "Issue") - mr_events = event_counts(date_from, :merge_requests). - having(action: [Event::MERGED, Event::CREATED, Event::CLOSED], target_type: "MergeRequest") - note_events = event_counts(date_from, :merge_requests). - having(action: [Event::COMMENTED], target_type: "Note") + repo_events = event_counts(date_from, :repository) + .having(action: Event::PUSHED) + issue_events = event_counts(date_from, :issues) + .having(action: [Event::CREATED, Event::CLOSED], target_type: "Issue") + mr_events = event_counts(date_from, :merge_requests) + .having(action: [Event::MERGED, Event::CREATED, Event::CLOSED], target_type: "MergeRequest") + note_events = event_counts(date_from, :merge_requests) + .having(action: [Event::COMMENTED], target_type: "Note") union = Gitlab::SQL::Union.new([repo_events, issue_events, mr_events, note_events]) events = Event.find_by_sql(union.to_sql).map(&:attributes) @@ -34,9 +34,9 @@ module Gitlab end def events_by_date(date) - events = Event.contributions.where(author_id: contributor.id). - where(created_at: date.beginning_of_day..date.end_of_day). - where(project_id: projects) + events = Event.contributions.where(author_id: contributor.id) + .where(created_at: date.beginning_of_day..date.end_of_day) + .where(project_id: projects) # Use visible_to_user? instead of the complicated logic in activity_dates # because we're only viewing the events for a single day. @@ -60,20 +60,20 @@ module Gitlab # use IN(project_ids...) instead. It's the intersection of two users so # the list will be (relatively) short @contributed_project_ids ||= projects.uniq.pluck(:id) - authed_projects = Project.where(id: @contributed_project_ids). - with_feature_available_for_user(feature, current_user). - reorder(nil). - select(:id) + authed_projects = Project.where(id: @contributed_project_ids) + .with_feature_available_for_user(feature, current_user) + .reorder(nil) + .select(:id) - conditions = t[:created_at].gteq(date_from.beginning_of_day). - and(t[:created_at].lteq(Date.today.end_of_day)). - and(t[:author_id].eq(contributor.id)) + conditions = t[:created_at].gteq(date_from.beginning_of_day) + .and(t[:created_at].lteq(Date.today.end_of_day)) + .and(t[:author_id].eq(contributor.id)) - Event.reorder(nil). - select(t[:project_id], t[:target_type], t[:action], 'date(created_at) AS date', 'count(id) as total_amount'). - group(t[:project_id], t[:target_type], t[:action], 'date(created_at)'). - where(conditions). - having(t[:project_id].in(Arel::Nodes::SqlLiteral.new(authed_projects.to_sql))) + Event.reorder(nil) + .select(t[:project_id], t[:target_type], t[:action], 'date(created_at) AS date', 'count(id) as total_amount') + .group(t[:project_id], t[:target_type], t[:action], 'date(created_at)') + .where(conditions) + .having(t[:project_id].in(Arel::Nodes::SqlLiteral.new(authed_projects.to_sql))) end end end diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 284e6ad55a5..818b3d9c46b 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -10,7 +10,7 @@ module Gitlab delegate :sidekiq_throttling_enabled?, to: :current_application_settings - def fake_application_settings(defaults = ApplicationSetting.defaults) + def fake_application_settings(defaults = ::ApplicationSetting.defaults) FakeApplicationSettings.new(defaults) end @@ -24,7 +24,7 @@ module Gitlab def cached_application_settings begin - ApplicationSetting.cached + ::ApplicationSetting.cached rescue ::Redis::BaseError, ::Errno::ENOENT # In case Redis isn't running or the Redis UNIX socket file is not available end @@ -35,7 +35,7 @@ module Gitlab # This loads from the database into the cache, so handle Redis errors begin - db_settings = ApplicationSetting.current + db_settings = ::ApplicationSetting.current rescue ::Redis::BaseError, ::Errno::ENOENT # In case Redis isn't running or the Redis UNIX socket file is not available end @@ -45,14 +45,14 @@ module Gitlab # and other callers from failing, use any loaded settings and return # defaults for missing columns. if ActiveRecord::Migrator.needs_migration? - defaults = ApplicationSetting.defaults + defaults = ::ApplicationSetting.defaults defaults.merge!(db_settings.attributes.symbolize_keys) if db_settings.present? return fake_application_settings(defaults) end return db_settings if db_settings.present? - ApplicationSetting.create_from_defaults || in_memory_application_settings + ::ApplicationSetting.create_from_defaults || in_memory_application_settings end def in_memory_application_settings diff --git a/lib/gitlab/cycle_analytics/base_query.rb b/lib/gitlab/cycle_analytics/base_query.rb index d560dca45c8..58729d3ced8 100644 --- a/lib/gitlab/cycle_analytics/base_query.rb +++ b/lib/gitlab/cycle_analytics/base_query.rb @@ -12,17 +12,17 @@ module Gitlab end def stage_query - query = mr_closing_issues_table.join(issue_table).on(issue_table[:id].eq(mr_closing_issues_table[:issue_id])). - join(issue_metrics_table).on(issue_table[:id].eq(issue_metrics_table[:issue_id])). - where(issue_table[:project_id].eq(@project.id)). - where(issue_table[:deleted_at].eq(nil)). - where(issue_table[:created_at].gteq(@options[:from])) + query = mr_closing_issues_table.join(issue_table).on(issue_table[:id].eq(mr_closing_issues_table[:issue_id])) + .join(issue_metrics_table).on(issue_table[:id].eq(issue_metrics_table[:issue_id])) + .where(issue_table[:project_id].eq(@project.id)) + .where(issue_table[:deleted_at].eq(nil)) + .where(issue_table[:created_at].gteq(@options[:from])) # Load merge_requests - query = query.join(mr_table, Arel::Nodes::OuterJoin). - on(mr_table[:id].eq(mr_closing_issues_table[:merge_request_id])). - join(mr_metrics_table). - on(mr_table[:id].eq(mr_metrics_table[:merge_request_id])) + query = query.join(mr_table, Arel::Nodes::OuterJoin) + .on(mr_table[:id].eq(mr_closing_issues_table[:merge_request_id])) + .join(mr_metrics_table) + .on(mr_table[:id].eq(mr_metrics_table[:merge_request_id])) query end diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index 0d5a7cf0694..d7dab584a44 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -93,7 +93,7 @@ module Gitlab row.values_at(*keys).map { |value| connection.quote(value) } end - connection.execute <<-EOF.strip_heredoc + connection.execute <<-EOF INSERT INTO #{table} (#{columns.join(', ')}) VALUES #{tuples.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')} EOF diff --git a/lib/gitlab/database/median.rb b/lib/gitlab/database/median.rb index 23890e5f493..059054ac9ff 100644 --- a/lib/gitlab/database/median.rb +++ b/lib/gitlab/database/median.rb @@ -29,10 +29,10 @@ module Gitlab end def mysql_median_datetime_sql(arel_table, query_so_far, column_sym) - query = arel_table. - from(arel_table.project(Arel.sql('*')).order(arel_table[column_sym]).as(arel_table.table_name)). - project(average([arel_table[column_sym]], 'median')). - where( + query = arel_table + .from(arel_table.project(Arel.sql('*')).order(arel_table[column_sym]).as(arel_table.table_name)) + .project(average([arel_table[column_sym]], 'median')) + .where( Arel::Nodes::Between.new( Arel.sql("(select @row_id := @row_id + 1)"), Arel::Nodes::And.new( @@ -67,8 +67,8 @@ module Gitlab cte_table = Arel::Table.new("ordered_records") cte = Arel::Nodes::As.new( cte_table, - arel_table. - project( + arel_table + .project( arel_table[column_sym].as(column_sym.to_s), Arel::Nodes::Over.new(Arel::Nodes::NamedFunction.new("row_number", []), Arel::Nodes::Window.new.order(arel_table[column_sym])).as('row_id'), @@ -79,8 +79,8 @@ module Gitlab # From the CTE, select either the middle row or the middle two rows (this is accomplished # by 'where cte.row_id between cte.ct / 2.0 AND cte.ct / 2.0 + 1'). Find the average of the # selected rows, and this is the median value. - cte_table.project(average([extract_epoch(cte_table[column_sym])], "median")). - where( + cte_table.project(average([extract_epoch(cte_table[column_sym])], "median")) + .where( Arel::Nodes::Between.new( cte_table[:row_id], Arel::Nodes::And.new( @@ -88,9 +88,9 @@ module Gitlab (cte_table[:ct] / Arel.sql('2.0') + 1)] ) ) - ). - with(query_so_far, cte). - to_sql + ) + .with(query_so_far, cte) + .to_sql end private diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index 9181202a091..0643c56db9b 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -222,6 +222,12 @@ module Gitlab # # rubocop: disable Metrics/AbcSize def update_column_in_batches(table, column, value) + if transaction_open? + raise 'update_column_in_batches can not be run inside a transaction, ' \ + 'you can disable transactions by calling disable_ddl_transaction! ' \ + 'in the body of your migration class' + end + table = Arel::Table.new(table) count_arel = table.project(Arel.star.count.as('count')) @@ -245,19 +251,19 @@ module Gitlab start_id = exec_query(start_arel.to_sql).to_hash.first['id'].to_i loop do - stop_arel = table.project(table[:id]). - where(table[:id].gteq(start_id)). - order(table[:id].asc). - take(1). - skip(batch_size) + stop_arel = table.project(table[:id]) + .where(table[:id].gteq(start_id)) + .order(table[:id].asc) + .take(1) + .skip(batch_size) stop_arel = yield table, stop_arel if block_given? stop_row = exec_query(stop_arel.to_sql).to_hash.first - update_arel = Arel::UpdateManager.new(ActiveRecord::Base). - table(table). - set([[table[column], value]]). - where(table[:id].gteq(start_id)) + update_arel = Arel::UpdateManager.new(ActiveRecord::Base) + .table(table) + .set([[table[column], value]]) + .where(table[:id].gteq(start_id)) if stop_row stop_id = stop_row['id'].to_i @@ -586,15 +592,15 @@ module Gitlab quoted_replacement = Arel::Nodes::Quoted.new(replacement.to_s) if Database.mysql? - locate = Arel::Nodes::NamedFunction. - new('locate', [quoted_pattern, column]) - insert_in_place = Arel::Nodes::NamedFunction. - new('insert', [column, locate, pattern.size, quoted_replacement]) + locate = Arel::Nodes::NamedFunction + .new('locate', [quoted_pattern, column]) + insert_in_place = Arel::Nodes::NamedFunction + .new('insert', [column, locate, pattern.size, quoted_replacement]) Arel::Nodes::SqlLiteral.new(insert_in_place.to_sql) else - replace = Arel::Nodes::NamedFunction. - new("regexp_replace", [column, quoted_pattern, quoted_replacement]) + replace = Arel::Nodes::NamedFunction + .new("regexp_replace", [column, quoted_pattern, quoted_replacement]) Arel::Nodes::SqlLiteral.new(replace.to_sql) end end diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb index d60fd4bb551..d8163d7da11 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb @@ -27,8 +27,8 @@ module Gitlab new_full_path = join_routable_path(namespace_path, new_path) # skips callbacks & validations - routable.class.where(id: routable). - update_all(path: new_path) + routable.class.where(id: routable) + .update_all(path: new_path) rename_routes(old_full_path, new_full_path) diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb index 2958ad4b8e5..da7e2cb2e85 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb @@ -18,8 +18,8 @@ module Gitlab when :top_level MigrationClasses::Namespace.where(parent_id: nil) end - with_paths = MigrationClasses::Route.arel_table[:path]. - matches_any(path_patterns) + with_paths = MigrationClasses::Route.arel_table[:path] + .matches_any(path_patterns) namespaces.joins(:route).where(with_paths) end @@ -52,15 +52,15 @@ module Gitlab end def repo_paths_for_namespace(namespace) - projects_for_namespace(namespace).distinct.select(:repository_storage). - map(&:repository_storage_path) + projects_for_namespace(namespace).distinct.select(:repository_storage) + .map(&:repository_storage_path) end def projects_for_namespace(namespace) namespace_ids = child_ids_for_parent(namespace, ids: [namespace.id]) - namespace_or_children = MigrationClasses::Project. - arel_table[:namespace_id]. - in(namespace_ids) + namespace_or_children = MigrationClasses::Project + .arel_table[:namespace_id] + .in(namespace_ids) MigrationClasses::Project.where(namespace_or_children) end diff --git a/lib/gitlab/dependency_linker/requirements_txt_linker.rb b/lib/gitlab/dependency_linker/requirements_txt_linker.rb index 2e197e5cd94..9c9620bc36a 100644 --- a/lib/gitlab/dependency_linker/requirements_txt_linker.rb +++ b/lib/gitlab/dependency_linker/requirements_txt_linker.rb @@ -6,7 +6,7 @@ module Gitlab private def link_dependencies - link_regex(/^(?<name>(?![a-z+]+:)[^#.-][^ ><=;\[]+)/) do |name| + link_regex(/^(?<name>(?![a-z+]+:)[^#.-][^ ><=~!;\[]+)/) do |name| "https://pypi.python.org/pypi/#{name}" end diff --git a/lib/gitlab/downtime_check.rb b/lib/gitlab/downtime_check.rb index ab9537ed7d7..941244694e2 100644 --- a/lib/gitlab/downtime_check.rb +++ b/lib/gitlab/downtime_check.rb @@ -50,8 +50,8 @@ module Gitlab # Returns the class for the given migration file path. def class_for_migration_file(path) - File.basename(path, File.extname(path)).split('_', 2).last.camelize. - constantize + File.basename(path, File.extname(path)).split('_', 2).last.camelize + .constantize end # Returns true if the given migration can be performed without downtime. diff --git a/lib/gitlab/ee_compat_check.rb b/lib/gitlab/ee_compat_check.rb index 6d326ee213a..1a5887dab7e 100644 --- a/lib/gitlab/ee_compat_check.rb +++ b/lib/gitlab/ee_compat_check.rb @@ -76,9 +76,13 @@ module Gitlab step( "Generating the patch against origin/master in #{patch_path}", - %W[git diff --binary origin/master > #{patch_path}] + %w[git diff --binary origin/master...HEAD] ) do |output, status| - throw(:halt_check, :ko) unless status.zero? && File.exist?(patch_path) + throw(:halt_check, :ko) unless status.zero? + + File.write(patch_path, output) + + throw(:halt_check, :ko) unless File.exist?(patch_path) end end @@ -130,7 +134,15 @@ module Gitlab step("Fetching CE/#{ce_branch}", %W[git fetch #{CE_REPO} #{ce_branch}]) step( "Checking if #{patch_path} applies cleanly to EE/master", - %W[git apply --check --3way #{patch_path}] + # Don't use --check here because it can result in a 0-exit status even + # though the patch doesn't apply cleanly, e.g.: + # > git apply --check --3way foo.patch + # error: patch failed: lib/gitlab/ee_compat_check.rb:74 + # Falling back to three-way merge... + # Applied patch to 'lib/gitlab/ee_compat_check.rb' with conflicts. + # > echo $? + # 0 + %W[git apply --3way #{patch_path}] ) do |output, status| puts output unless status.zero? @@ -145,6 +157,7 @@ module Gitlab status = 0 if failed_files.empty? end + command(%w[git reset --hard]) status end end @@ -292,7 +305,7 @@ module Gitlab # In the CE repo $ git fetch origin master - $ git diff --binary origin/master > #{ce_branch}.patch + $ git diff --binary origin/master...HEAD -- > #{ce_branch}.patch # In the EE repo $ git fetch origin master diff --git a/lib/gitlab/email/html_parser.rb b/lib/gitlab/email/html_parser.rb index a4ca62bfc41..50559a48973 100644 --- a/lib/gitlab/email/html_parser.rb +++ b/lib/gitlab/email/html_parser.rb @@ -17,6 +17,13 @@ module Gitlab def filter_replies! document.xpath('//blockquote').each(&:remove) document.xpath('//table').each(&:remove) + + # bogus links with no href are sometimes added by outlook, + # and can result in Html2Text adding extra square brackets + # to the text, so we unwrap them here. + document.xpath('//a[not(@href)]').each do |link| + link.replace(link.children) + end end def filtered_html diff --git a/lib/gitlab/exclusive_lease.rb b/lib/gitlab/exclusive_lease.rb index 62ddd45785d..a0f46594eb1 100644 --- a/lib/gitlab/exclusive_lease.rb +++ b/lib/gitlab/exclusive_lease.rb @@ -10,13 +10,21 @@ module Gitlab # ExclusiveLease. # class ExclusiveLease - LUA_CANCEL_SCRIPT = <<-EOS.freeze + LUA_CANCEL_SCRIPT = <<~EOS.freeze local key, uuid = KEYS[1], ARGV[1] if redis.call("get", key) == uuid then redis.call("del", key) end EOS + LUA_RENEW_SCRIPT = <<~EOS.freeze + local key, uuid, ttl = KEYS[1], ARGV[1], ARGV[2] + if redis.call("get", key) == uuid then + redis.call("expire", key, ttl) + return uuid + end + EOS + def self.cancel(key, uuid) Gitlab::Redis.with do |redis| redis.eval(LUA_CANCEL_SCRIPT, keys: [redis_key(key)], argv: [uuid]) @@ -42,6 +50,15 @@ module Gitlab end end + # Try to renew an existing lease. Return lease UUID on success, + # false if the lease is taken by a different UUID or inexistent. + def renew + Gitlab::Redis.with do |redis| + result = redis.eval(LUA_RENEW_SCRIPT, keys: [@redis_key], argv: [@uuid, @timeout]) + result == @uuid + end + end + # Returns true if the key for this lease is set. def exists? Gitlab::Redis.with do |redis| diff --git a/lib/gitlab/git/blob.rb b/lib/gitlab/git/blob.rb index 33a7624e303..a7aceab4c14 100644 --- a/lib/gitlab/git/blob.rb +++ b/lib/gitlab/git/blob.rb @@ -14,6 +14,51 @@ module Gitlab class << self def find(repository, sha, path) + Gitlab::GitalyClient.migrate(:project_raw_show) do |is_enabled| + if is_enabled + find_by_gitaly(repository, sha, path) + else + find_by_rugged(repository, sha, path) + end + end + end + + def find_by_gitaly(repository, sha, path) + path = path.sub(/\A\/*/, '') + path = '/' if path.empty? + name = File.basename(path) + entry = Gitlab::GitalyClient::Commit.new(repository).tree_entry(sha, path, MAX_DATA_DISPLAY_SIZE) + return unless entry + + case entry.type + when :COMMIT + new( + id: entry.oid, + name: name, + size: 0, + data: '', + path: path, + commit_id: sha + ) + when :BLOB + # EncodingDetector checks the first 1024 * 1024 bytes for NUL byte, libgit2 checks + # only the first 8000 (https://github.com/libgit2/libgit2/blob/2ed855a9e8f9af211e7274021c2264e600c0f86b/src/filter.h#L15), + # which is what we use below to keep a consistent behavior. + detect = CharlockHolmes::EncodingDetector.new(8000).detect(entry.data) + new( + id: entry.oid, + name: name, + size: entry.size, + data: entry.data.dup, + mode: entry.mode.to_s(8), + path: path, + commit_id: sha, + binary: detect && detect[:type] == :binary + ) + end + end + + def find_by_rugged(repository, sha, path) commit = repository.lookup(sha) root_tree = commit.tree diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index bb04731f08c..9c0606d780a 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -4,7 +4,7 @@ module Gitlab class Commit include Gitlab::EncodingHelper - attr_accessor :raw_commit, :head, :refs + attr_accessor :raw_commit, :head SERIALIZE_KEYS = [ :id, :message, :parent_ids, @@ -104,9 +104,63 @@ module Gitlab [] end - # Delegate Repository#find_commits + # Returns commits collection + # + # Ex. + # Commit.find_all( + # repo, + # ref: 'master', + # max_count: 10, + # skip: 5, + # order: :date + # ) + # + # +options+ is a Hash of optional arguments to git + # :ref is the ref from which to begin (SHA1 or name) + # :max_count is the maximum number of commits to fetch + # :skip is the number of commits to skip + # :order is the commits order and allowed value is :none (default), :date, + # :topo, or any combination of them (in an array). Commit ordering types + # are documented here: + # http://www.rubydoc.info/github/libgit2/rugged/Rugged#SORT_NONE-constant) + # def find_all(repo, options = {}) - repo.find_commits(options) + actual_options = options.dup + + allowed_options = [:ref, :max_count, :skip, :order] + + actual_options.keep_if do |key| + allowed_options.include?(key) + end + + default_options = { skip: 0 } + actual_options = default_options.merge(actual_options) + + rugged = repo.rugged + walker = Rugged::Walker.new(rugged) + + if actual_options[:ref] + walker.push(rugged.rev_parse_oid(actual_options[:ref])) + else + rugged.references.each("refs/heads/*") do |ref| + walker.push(ref.target_id) + end + end + + walker.sorting(rugged_sort_type(actual_options[:order])) + + commits = [] + offset = actual_options[:skip] + limit = actual_options[:max_count] + walker.each(offset: offset, limit: limit) do |commit| + commits.push(decorate(commit)) + end + + walker.reset + + commits + rescue Rugged::OdbError + [] end def decorate(commit, ref = nil) @@ -131,6 +185,20 @@ module Gitlab diff.find_similar!(break_rewrites: break_rewrites) diff end + + # Returns the `Rugged` sorting type constant for one or more given + # sort types. Valid keys are `:none`, `:topo`, and `:date`, or an array + # containing more than one of them. `:date` uses a combination of date and + # topological sorting to closer mimic git's native ordering. + def rugged_sort_type(sort_type) + @rugged_sort_types ||= { + none: Rugged::SORT_NONE, + topo: Rugged::SORT_TOPO, + date: Rugged::SORT_DATE | Rugged::SORT_TOPO + } + + @rugged_sort_types.fetch(sort_type, Rugged::SORT_NONE) + end end def initialize(raw_commit, head = nil) @@ -175,8 +243,8 @@ module Gitlab # Shows the diff between the commit's parent and the commit. # # Cuts out the header and stats from #to_patch and returns only the diff. - def to_diff(options = {}) - diff_from_parent(options).patch + def to_diff + diff_from_parent.patch end # Returns a diff object for the changes from this commit's first parent. diff --git a/lib/gitlab/git/diff.rb b/lib/gitlab/git/diff.rb index f825568f194..cf7829a583b 100644 --- a/lib/gitlab/git/diff.rb +++ b/lib/gitlab/git/diff.rb @@ -318,7 +318,7 @@ module Gitlab end def init_from_gitaly(diff) - @diff = diff.patch if diff.respond_to?(:patch) + @diff = encode!(diff.patch) if diff.respond_to?(:patch) @new_path = encode!(diff.to_path.dup) @old_path = encode!(diff.from_path.dup) @a_mode = diff.old_mode.to_s(8) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index c1f942f931a..dd296983491 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -494,70 +494,6 @@ module Gitlab end end - # Returns commits collection - # - # Ex. - # repo.find_commits( - # ref: 'master', - # max_count: 10, - # skip: 5, - # order: :date - # ) - # - # +options+ is a Hash of optional arguments to git - # :ref is the ref from which to begin (SHA1 or name) - # :contains is the commit contained by the refs from which to begin (SHA1 or name) - # :max_count is the maximum number of commits to fetch - # :skip is the number of commits to skip - # :order is the commits order and allowed value is :none (default), :date, - # :topo, or any combination of them (in an array). Commit ordering types - # are documented here: - # http://www.rubydoc.info/github/libgit2/rugged/Rugged#SORT_NONE-constant) - # - def find_commits(options = {}) - actual_options = options.dup - - allowed_options = [:ref, :max_count, :skip, :contains, :order] - - actual_options.keep_if do |key| - allowed_options.include?(key) - end - - default_options = { skip: 0 } - actual_options = default_options.merge(actual_options) - - walker = Rugged::Walker.new(rugged) - - if actual_options[:ref] - walker.push(rugged.rev_parse_oid(actual_options[:ref])) - elsif actual_options[:contains] - branches_contains(actual_options[:contains]).each do |branch| - walker.push(branch.target_id) - end - else - rugged.references.each("refs/heads/*") do |ref| - walker.push(ref.target_id) - end - end - - sort_type = rugged_sort_type(actual_options[:order]) - walker.sorting(sort_type) - - commits = [] - offset = actual_options[:skip] - limit = actual_options[:max_count] - walker.each(offset: offset, limit: limit) do |commit| - gitlab_commit = Gitlab::Git::Commit.decorate(commit) - commits.push(gitlab_commit) - end - - walker.reset - - commits - rescue Rugged::OdbError - [] - end - # Returns branch names collection that contains the special commit(SHA1 # or name) # @@ -613,32 +549,20 @@ module Gitlab rugged.rev_parse(oid_or_ref_name) end - # Return hash with submodules info for this repository + # Returns url for submodule # # Ex. - # { - # "current_path/rack" => { - # "name" => "original_path/rack", - # "id" => "c67be4624545b4263184c4a0e8f887efd0a66320", - # "url" => "git://github.com/chneukirchen/rack.git" - # }, - # "encoding" => { - # "id" => .... - # } - # } + # @repository.submodule_url_for('master', 'rack') + # # => git@localhost:rack.git # - def submodules(ref) - commit = rev_parse_target(ref) - return {} unless commit + def submodule_url_for(ref, path) + if submodules(ref).any? + submodule = submodules(ref)[path] - begin - content = blob_content(commit, ".gitmodules") - rescue InvalidBlobName - return {} + if submodule + submodule['url'] + end end - - parser = GitmodulesParser.new(content) - fill_submodule_ids(commit, parser.parse) end # Return total commits count accessible from passed ref @@ -976,6 +900,23 @@ module Gitlab private + # We are trying to deprecate this method because it does a lot of work + # but it seems to be used only to look up submodule URL's. + # https://gitlab.com/gitlab-org/gitaly/issues/329 + def submodules(ref) + commit = rev_parse_target(ref) + return {} unless commit + + begin + content = blob_content(commit, ".gitmodules") + rescue InvalidBlobName + return {} + end + + parser = GitmodulesParser.new(content) + fill_submodule_ids(commit, parser.parse) + end + def alternate_object_directories Gitlab::Git::Env.all.values_at(*ALLOWED_OBJECT_DIRECTORIES_VARIABLES).compact end @@ -1228,20 +1169,6 @@ module Gitlab rescue GRPC::BadStatus => e raise CommandError.new(e) end - - # Returns the `Rugged` sorting type constant for one or more given - # sort types. Valid keys are `:none`, `:topo`, and `:date`, or an array - # containing more than one of them. `:date` uses a combination of date and - # topological sorting to closer mimic git's native ordering. - def rugged_sort_type(sort_type) - @rugged_sort_types ||= { - none: Rugged::SORT_NONE, - topo: Rugged::SORT_TOPO, - date: Rugged::SORT_DATE | Rugged::SORT_TOPO - } - - @rugged_sort_types.fetch(sort_type, Rugged::SORT_NONE) - end end end end diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index 2343446bf22..f605c06dfc3 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -1,3 +1,5 @@ +require 'base64' + require 'gitaly' module Gitlab @@ -48,6 +50,26 @@ module Gitlab address end + # All Gitaly RPC call sites should use GitalyClient.call. This method + # makes sure that per-request authentication headers are set. + def self.call(storage, service, rpc, request) + metadata = request_metadata(storage) + metadata = yield(metadata) if block_given? + stub(service, storage).send(rpc, request, metadata) + end + + def self.request_metadata(storage) + encoded_token = Base64.strict_encode64(token(storage).to_s) + { metadata: { 'authorization' => "Bearer #{encoded_token}" } } + end + + def self.token(storage) + params = Gitlab.config.repositories.storages[storage] + raise "storage not found: #{storage.inspect}" if params.nil? + + params['gitaly_token'].presence || Gitlab.config.gitaly['token'] + end + def self.enabled? Gitlab.config.gitaly.enabled end diff --git a/lib/gitlab/gitaly_client/commit.rb b/lib/gitlab/gitaly_client/commit.rb index ba3da781dad..b8877619797 100644 --- a/lib/gitlab/gitaly_client/commit.rb +++ b/lib/gitlab/gitaly_client/commit.rb @@ -11,33 +11,51 @@ module Gitlab end def is_ancestor(ancestor_id, child_id) - stub = GitalyClient.stub(:commit, @repository.storage) request = Gitaly::CommitIsAncestorRequest.new( repository: @gitaly_repo, ancestor_id: ancestor_id, child_id: child_id ) - stub.commit_is_ancestor(request).value + GitalyClient.call(@repository.storage, :commit, :commit_is_ancestor, request).value end def diff_from_parent(commit, options = {}) request_params = commit_diff_request_params(commit, options) request_params[:ignore_whitespace_change] = options.fetch(:ignore_whitespace_change, false) - - response = diff_service_stub.commit_diff(Gitaly::CommitDiffRequest.new(request_params)) + request = Gitaly::CommitDiffRequest.new(request_params) + response = GitalyClient.call(@repository.storage, :diff, :commit_diff, request) Gitlab::Git::DiffCollection.new(GitalyClient::DiffStitcher.new(response), options) end def commit_deltas(commit) - request_params = commit_diff_request_params(commit) - - response = diff_service_stub.commit_delta(Gitaly::CommitDeltaRequest.new(request_params)) + request = Gitaly::CommitDeltaRequest.new(commit_diff_request_params(commit)) + response = GitalyClient.call(@repository.storage, :diff, :commit_delta, request) response.flat_map do |msg| msg.deltas.map { |d| Gitlab::Git::Diff.new(d) } end end + def tree_entry(ref, path, limit = nil) + request = Gitaly::TreeEntryRequest.new( + repository: @gitaly_repo, + revision: ref, + path: path.dup.force_encoding(Encoding::ASCII_8BIT), + limit: limit.to_i + ) + + response = GitalyClient.call(@repository.storage, :commit, :tree_entry, request) + entry = response.first + return unless entry.oid.present? + + if entry.type == :BLOB + rest_of_data = response.reduce("") { |memo, msg| memo << msg.data } + entry.data += rest_of_data + end + + entry + end + private def commit_diff_request_params(commit, options = {}) @@ -50,10 +68,6 @@ module Gitlab paths: options.fetch(:paths, []) } end - - def diff_service_stub - GitalyClient.stub(:diff, @repository.storage) - end end end end diff --git a/lib/gitlab/gitaly_client/diff_stitcher.rb b/lib/gitlab/gitaly_client/diff_stitcher.rb index d84e8d752dc..65d81dc5d46 100644 --- a/lib/gitlab/gitaly_client/diff_stitcher.rb +++ b/lib/gitlab/gitaly_client/diff_stitcher.rb @@ -13,7 +13,10 @@ module Gitlab @rpc_response.each do |diff_msg| if current_diff.nil? diff_params = diff_msg.to_h.slice(*GitalyClient::Diff::FIELDS) - diff_params[:patch] = diff_msg.raw_patch_data + # gRPC uses frozen strings by default, and we need to have an unfrozen string as it + # gets processed further down the line. So we unfreeze the first chunk of the patch + # in case it's the only chunk we receive for this diff. + diff_params[:patch] = diff_msg.raw_patch_data.dup current_diff = GitalyClient::Diff.new(diff_params) else diff --git a/lib/gitlab/gitaly_client/notifications.rb b/lib/gitlab/gitaly_client/notifications.rb index 719554eac52..78ed433e6b8 100644 --- a/lib/gitlab/gitaly_client/notifications.rb +++ b/lib/gitlab/gitaly_client/notifications.rb @@ -1,17 +1,19 @@ module Gitlab module GitalyClient class Notifications - attr_accessor :stub - # 'repository' is a Gitlab::Git::Repository def initialize(repository) @gitaly_repo = repository.gitaly_repository - @stub = GitalyClient.stub(:notifications, repository.storage) + @storage = repository.storage end def post_receive - request = Gitaly::PostReceiveRequest.new(repository: @gitaly_repo) - @stub.post_receive(request) + GitalyClient.call( + @storage, + :notifications, + :post_receive, + Gitaly::PostReceiveRequest.new(repository: @gitaly_repo) + ) end end end diff --git a/lib/gitlab/gitaly_client/ref.rb b/lib/gitlab/gitaly_client/ref.rb index 227fe45642e..6d5f54dd959 100644 --- a/lib/gitlab/gitaly_client/ref.rb +++ b/lib/gitlab/gitaly_client/ref.rb @@ -1,29 +1,28 @@ module Gitlab module GitalyClient class Ref - attr_accessor :stub - # 'repository' is a Gitlab::Git::Repository def initialize(repository) @gitaly_repo = repository.gitaly_repository - @stub = GitalyClient.stub(:ref, repository.storage) + @storage = repository.storage end def default_branch_name request = Gitaly::FindDefaultBranchNameRequest.new(repository: @gitaly_repo) - branch_name = stub.find_default_branch_name(request).name - - Gitlab::Git.branch_name(branch_name) + response = GitalyClient.call(@storage, :ref, :find_default_branch_name, request) + Gitlab::Git.branch_name(response.name) end def branch_names request = Gitaly::FindAllBranchNamesRequest.new(repository: @gitaly_repo) - consume_refs_response(stub.find_all_branch_names(request), prefix: 'refs/heads/') + response = GitalyClient.call(@storage, :ref, :find_all_branch_names, request) + consume_refs_response(response, prefix: 'refs/heads/') end def tag_names request = Gitaly::FindAllTagNamesRequest.new(repository: @gitaly_repo) - consume_refs_response(stub.find_all_tag_names(request), prefix: 'refs/tags/') + response = GitalyClient.call(@storage, :ref, :find_all_tag_names, request) + consume_refs_response(response, prefix: 'refs/tags/') end def find_ref_name(commit_id, ref_prefix) @@ -32,8 +31,7 @@ module Gitlab commit_id: commit_id, prefix: ref_prefix ) - - stub.find_ref_name(request).name + GitalyClient.call(@storage, :ref, :find_ref_name, request).name end def count_tag_names @@ -47,7 +45,8 @@ module Gitlab def local_branches(sort_by: nil) request = Gitaly::FindLocalBranchesRequest.new(repository: @gitaly_repo) request.sort_by = sort_by_param(sort_by) if sort_by - consume_branches_response(stub.find_local_branches(request)) + response = GitalyClient.call(@storage, :ref, :find_local_branches, request) + consume_branches_response(response) end private diff --git a/lib/gitlab/group_hierarchy.rb b/lib/gitlab/group_hierarchy.rb index 357c076e874..5a31e56cb30 100644 --- a/lib/gitlab/group_hierarchy.rb +++ b/lib/gitlab/group_hierarchy.rb @@ -67,11 +67,11 @@ module Gitlab union = SQL::Union.new([model.unscoped.from(ancestors_table), model.unscoped.from(descendants_table)]) - model. - unscoped. - with. - recursive(ancestors.to_arel, descendants.to_arel). - from("(#{union.to_sql}) #{model.table_name}") + model + .unscoped + .with + .recursive(ancestors.to_arel, descendants.to_arel) + .from("(#{union.to_sql}) #{model.table_name}") end private @@ -82,10 +82,10 @@ module Gitlab cte << ancestors_base.except(:order) # Recursively get all the ancestors of the base set. - cte << model. - from([groups_table, cte.table]). - where(groups_table[:id].eq(cte.table[:parent_id])). - except(:order) + cte << model + .from([groups_table, cte.table]) + .where(groups_table[:id].eq(cte.table[:parent_id])) + .except(:order) cte end @@ -96,10 +96,10 @@ module Gitlab cte << descendants_base.except(:order) # Recursively get all the descendants of the base set. - cte << model. - from([groups_table, cte.table]). - where(groups_table[:parent_id].eq(cte.table[:id])). - except(:order) + cte << model + .from([groups_table, cte.table]) + .where(groups_table[:parent_id].eq(cte.table[:id])) + .except(:order) cte end diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb index 6b24da030df..5408a1a6838 100644 --- a/lib/gitlab/highlight.rb +++ b/lib/gitlab/highlight.rb @@ -1,8 +1,8 @@ module Gitlab class Highlight def self.highlight(blob_name, blob_content, repository: nil, plain: false) - new(blob_name, blob_content, repository: repository). - highlight(blob_content, continue: false, plain: plain) + new(blob_name, blob_content, repository: repository) + .highlight(blob_content, continue: false, plain: plain) end attr_reader :blob_name diff --git a/lib/gitlab/i18n.rb b/lib/gitlab/i18n.rb index a5ad2f952d3..db7cdf4b5c7 100644 --- a/lib/gitlab/i18n.rb +++ b/lib/gitlab/i18n.rb @@ -11,7 +11,8 @@ module Gitlab 'zh_CN' => '简体中文', 'zh_HK' => '繁體中文(香港)', 'zh_TW' => '繁體中文(臺灣)', - 'bg' => 'български' + 'bg' => 'български', + 'eo' => 'Esperanto' }.freeze def available_locales diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index 72183e8aad4..1860352c96d 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -99,6 +99,7 @@ excluded_attributes: - :milestone_id merge_requests: - :milestone_id + - :ref_fetched award_emoji: - :awardable_id statuses: diff --git a/lib/gitlab/ldap/access.rb b/lib/gitlab/ldap/access.rb index 54a5b1d31cd..8779577258b 100644 --- a/lib/gitlab/ldap/access.rb +++ b/lib/gitlab/ldap/access.rb @@ -16,8 +16,8 @@ module Gitlab def self.allowed?(user) self.open(user) do |access| if access.allowed? - user.last_credential_check_at = Time.now - user.save + Users::UpdateService.new(user, last_credential_check_a: Time.now).execute + true else false diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index 5e299e26c54..39180dc17d9 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -10,9 +10,9 @@ module Gitlab class << self def find_by_uid_and_provider(uid, provider) # LDAP distinguished name is case-insensitive - identity = ::Identity. - where(provider: provider). - iwhere(extern_uid: uid).last + identity = ::Identity + .where(provider: provider) + .iwhere(extern_uid: uid).last identity && identity.user end end diff --git a/lib/gitlab/metrics/influx_db.rb b/lib/gitlab/metrics/influx_db.rb index 3a39791edbf..d7c56463aac 100644 --- a/lib/gitlab/metrics/influx_db.rb +++ b/lib/gitlab/metrics/influx_db.rb @@ -157,8 +157,8 @@ module Gitlab host = settings[:host] port = settings[:port] - InfluxDB::Client. - new(udp: { host: host, port: port }) + InfluxDB::Client + .new(udp: { host: host, port: port }) end end end diff --git a/lib/gitlab/metrics/prometheus.rb b/lib/gitlab/metrics/prometheus.rb index 60686509332..9d314a56e58 100644 --- a/lib/gitlab/metrics/prometheus.rb +++ b/lib/gitlab/metrics/prometheus.rb @@ -5,8 +5,16 @@ module Gitlab module Prometheus include Gitlab::CurrentSettings + def metrics_folder_present? + ENV.has_key?('prometheus_multiproc_dir') && + ::Dir.exist?(ENV['prometheus_multiproc_dir']) && + ::File.writable?(ENV['prometheus_multiproc_dir']) + end + def prometheus_metrics_enabled? - @prometheus_metrics_enabled ||= current_application_settings[:prometheus_metrics_enabled] || false + return @prometheus_metrics_enabled if defined?(@prometheus_metrics_enabled) + + @prometheus_metrics_enabled = prometheus_metrics_enabled_unmemoized end def registry @@ -36,6 +44,12 @@ module Gitlab NullMetric.new end end + + private + + def prometheus_metrics_enabled_unmemoized + metrics_folder_present? && current_application_settings[:prometheus_metrics_enabled] || false + end end end end diff --git a/lib/gitlab/metrics/system.rb b/lib/gitlab/metrics/system.rb index 3aaebb3e9c3..aba3e0df382 100644 --- a/lib/gitlab/metrics/system.rb +++ b/lib/gitlab/metrics/system.rb @@ -34,13 +34,13 @@ module Gitlab # THREAD_CPUTIME is not supported on OS X if Process.const_defined?(:CLOCK_THREAD_CPUTIME_ID) def self.cpu_time - Process. - clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :millisecond) + Process + .clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :millisecond) end else def self.cpu_time - Process. - clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :millisecond) + Process + .clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :millisecond) end end diff --git a/lib/gitlab/o_auth/user.rb b/lib/gitlab/o_auth/user.rb index 7307f8c2c87..b3f453e506d 100644 --- a/lib/gitlab/o_auth/user.rb +++ b/lib/gitlab/o_auth/user.rb @@ -32,7 +32,7 @@ module Gitlab block_after_save = needs_blocking? - gl_user.save! + Users::UpdateService.new(gl_user).execute! gl_user.block if block_after_save diff --git a/lib/gitlab/other_markup.rb b/lib/gitlab/other_markup.rb index 31a24460f0f..fc3f21233dd 100644 --- a/lib/gitlab/other_markup.rb +++ b/lib/gitlab/other_markup.rb @@ -6,8 +6,8 @@ module Gitlab # input - the source text in a markup format # def self.render(file_name, input, context) - html = GitHub::Markup.render(file_name, input). - force_encoding(input.encoding) + html = GitHub::Markup.render(file_name, input) + .force_encoding(input.encoding) context[:pipeline] = :markup html = Banzai.render(html, context) diff --git a/lib/gitlab/performance_bar/peek_query_tracker.rb b/lib/gitlab/performance_bar/peek_query_tracker.rb index 7ab80f5ee0f..574ae8731a5 100644 --- a/lib/gitlab/performance_bar/peek_query_tracker.rb +++ b/lib/gitlab/performance_bar/peek_query_tracker.rb @@ -3,8 +3,8 @@ module Gitlab module PerformanceBar module PeekQueryTracker def sorted_queries - PEEK_DB_CLIENT.query_details. - sort { |a, b| b[:duration] <=> a[:duration] } + PEEK_DB_CLIENT.query_details + .sort { |a, b| b[:duration] <=> a[:duration] } end def results diff --git a/lib/gitlab/project_authorizations/with_nested_groups.rb b/lib/gitlab/project_authorizations/with_nested_groups.rb index bb0df1e3dad..15b8beacf60 100644 --- a/lib/gitlab/project_authorizations/with_nested_groups.rb +++ b/lib/gitlab/project_authorizations/with_nested_groups.rb @@ -28,34 +28,34 @@ module Gitlab # Projects that belong directly to any of the groups the user has # access to. - Namespace. - unscoped. - select([alias_as_column(projects[:id], 'project_id'), - cte_alias[:access_level]]). - from(cte_alias). - joins(:projects), + Namespace + .unscoped + .select([alias_as_column(projects[:id], 'project_id'), + cte_alias[:access_level]]) + .from(cte_alias) + .joins(:projects), # Projects shared with any of the namespaces the user has access to. - Namespace. - unscoped. - select([links[:project_id], - least(cte_alias[:access_level], - links[:group_access], - 'access_level')]). - from(cte_alias). - joins('INNER JOIN project_group_links ON project_group_links.group_id = namespaces.id'). - joins('INNER JOIN projects ON projects.id = project_group_links.project_id'). - joins('INNER JOIN namespaces p_ns ON p_ns.id = projects.namespace_id'). - where('p_ns.share_with_group_lock IS FALSE') + Namespace + .unscoped + .select([links[:project_id], + least(cte_alias[:access_level], + links[:group_access], + 'access_level')]) + .from(cte_alias) + .joins('INNER JOIN project_group_links ON project_group_links.group_id = namespaces.id') + .joins('INNER JOIN projects ON projects.id = project_group_links.project_id') + .joins('INNER JOIN namespaces p_ns ON p_ns.id = projects.namespace_id') + .where('p_ns.share_with_group_lock IS FALSE') ] union = Gitlab::SQL::Union.new(relations) - ProjectAuthorization. - unscoped. - with. - recursive(cte.to_arel). - select_from_union(union) + ProjectAuthorization + .unscoped + .with + .recursive(cte.to_arel) + .select_from_union(union) end private @@ -68,17 +68,17 @@ module Gitlab namespaces = Namespace.arel_table # Namespaces the user is a member of. - cte << user.groups. - select([namespaces[:id], members[:access_level]]). - except(:order) + cte << user.groups + .select([namespaces[:id], members[:access_level]]) + .except(:order) # Sub groups of any groups the user is a member of. cte << Group.select([namespaces[:id], greatest(members[:access_level], - cte.table[:access_level], 'access_level')]). - joins(join_cte(cte)). - joins(join_members). - except(:order) + cte.table[:access_level], 'access_level')]) + .joins(join_cte(cte)) + .joins(join_members) + .except(:order) cte end @@ -88,11 +88,11 @@ module Gitlab members = Member.arel_table namespaces = Namespace.arel_table - cond = members[:source_id]. - eq(namespaces[:id]). - and(members[:source_type].eq('Namespace')). - and(members[:requested_at].eq(nil)). - and(members[:user_id].eq(user.id)) + cond = members[:source_id] + .eq(namespaces[:id]) + .and(members[:source_type].eq('Namespace')) + .and(members[:requested_at].eq(nil)) + .and(members[:user_id].eq(user.id)) Arel::Nodes::OuterJoin.new(members, Arel::Nodes::On.new(cond)) end diff --git a/lib/gitlab/project_authorizations/without_nested_groups.rb b/lib/gitlab/project_authorizations/without_nested_groups.rb index 627e8c5fba2..ad87540e6c2 100644 --- a/lib/gitlab/project_authorizations/without_nested_groups.rb +++ b/lib/gitlab/project_authorizations/without_nested_groups.rb @@ -26,9 +26,9 @@ module Gitlab union = Gitlab::SQL::Union.new(relations) - ProjectAuthorization. - unscoped. - select_from_union(union) + ProjectAuthorization + .unscoped + .select_from_union(union) end end end diff --git a/lib/gitlab/prometheus/additional_metrics_parser.rb b/lib/gitlab/prometheus/additional_metrics_parser.rb new file mode 100644 index 00000000000..cb95daf2260 --- /dev/null +++ b/lib/gitlab/prometheus/additional_metrics_parser.rb @@ -0,0 +1,34 @@ +module Gitlab + module Prometheus + module AdditionalMetricsParser + extend self + + def load_groups_from_yaml + additional_metrics_raw.map(&method(:group_from_entry)) + end + + private + + def validate!(obj) + raise ParsingError.new(obj.errors.full_messages.join('\n')) unless obj.valid? + end + + def group_from_entry(entry) + entry[:name] = entry.delete(:group) + entry[:metrics]&.map! do |entry| + Metric.new(entry).tap(&method(:validate!)) + end + + MetricGroup.new(entry).tap(&method(:validate!)) + end + + def additional_metrics_raw + load_yaml_file&.map(&:deep_symbolize_keys).freeze + end + + def load_yaml_file + @loaded_yaml_file ||= YAML.load_file(Rails.root.join('config/prometheus/additional_metrics.yml')) + end + end + end +end diff --git a/lib/gitlab/prometheus/metric.rb b/lib/gitlab/prometheus/metric.rb new file mode 100644 index 00000000000..f54b2c6aaff --- /dev/null +++ b/lib/gitlab/prometheus/metric.rb @@ -0,0 +1,16 @@ +module Gitlab + module Prometheus + class Metric + include ActiveModel::Model + + attr_accessor :title, :required_metrics, :weight, :y_label, :queries + + validates :title, :required_metrics, :weight, :y_label, :queries, presence: true + + def initialize(params = {}) + super(params) + @y_label ||= 'Values' + end + end + end +end diff --git a/lib/gitlab/prometheus/metric_group.rb b/lib/gitlab/prometheus/metric_group.rb new file mode 100644 index 00000000000..729fef34b35 --- /dev/null +++ b/lib/gitlab/prometheus/metric_group.rb @@ -0,0 +1,14 @@ +module Gitlab + module Prometheus + class MetricGroup + include ActiveModel::Model + + attr_accessor :name, :priority, :metrics + validates :name, :priority, :metrics, presence: true + + def self.all + AdditionalMetricsParser.load_groups_from_yaml + end + end + end +end diff --git a/lib/gitlab/prometheus/parsing_error.rb b/lib/gitlab/prometheus/parsing_error.rb new file mode 100644 index 00000000000..49cc0e16080 --- /dev/null +++ b/lib/gitlab/prometheus/parsing_error.rb @@ -0,0 +1,5 @@ +module Gitlab + module Prometheus + ParsingError = Class.new(StandardError) + end +end diff --git a/lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb b/lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb new file mode 100644 index 00000000000..67c69d9ccf3 --- /dev/null +++ b/lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb @@ -0,0 +1,22 @@ +module Gitlab + module Prometheus + module Queries + class AdditionalMetricsDeploymentQuery < BaseQuery + include QueryAdditionalMetrics + + def query(deployment_id) + Deployment.find_by(id: deployment_id).try do |deployment| + query_context = { + environment_slug: deployment.environment.slug, + environment_filter: %{container_name!="POD",environment="#{deployment.environment.slug}"}, + timeframe_start: (deployment.created_at - 30.minutes).to_f, + timeframe_end: (deployment.created_at + 30.minutes).to_f + } + + query_metrics(query_context) + end + end + end + end + end +end diff --git a/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb b/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb new file mode 100644 index 00000000000..b5a679ddd79 --- /dev/null +++ b/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb @@ -0,0 +1,22 @@ +module Gitlab + module Prometheus + module Queries + class AdditionalMetricsEnvironmentQuery < BaseQuery + include QueryAdditionalMetrics + + def query(environment_id) + Environment.find_by(id: environment_id).try do |environment| + query_context = { + environment_slug: environment.slug, + environment_filter: %{container_name!="POD",environment="#{environment.slug}"}, + timeframe_start: 8.hours.ago.to_f, + timeframe_end: Time.now.to_f + } + + query_metrics(query_context) + end + end + end + end + end +end diff --git a/lib/gitlab/prometheus/queries/base_query.rb b/lib/gitlab/prometheus/queries/base_query.rb index 2a2eb4ae57f..c60828165bd 100644 --- a/lib/gitlab/prometheus/queries/base_query.rb +++ b/lib/gitlab/prometheus/queries/base_query.rb @@ -3,7 +3,7 @@ module Gitlab module Queries class BaseQuery attr_accessor :client - delegate :query_range, :query, to: :client, prefix: true + delegate :query_range, :query, :label_values, :series, to: :client, prefix: true def raw_memory_usage_query(environment_slug) %{avg(container_memory_usage_bytes{container_name!="POD",environment="#{environment_slug}"}) / 2^20} diff --git a/lib/gitlab/prometheus/queries/deployment_query.rb b/lib/gitlab/prometheus/queries/deployment_query.rb index 2cc08731f8d..170f483540e 100644 --- a/lib/gitlab/prometheus/queries/deployment_query.rb +++ b/lib/gitlab/prometheus/queries/deployment_query.rb @@ -1,26 +1,31 @@ -module Gitlab::Prometheus::Queries - class DeploymentQuery < BaseQuery - def query(deployment_id) - deployment = Deployment.find_by(id: deployment_id) - environment_slug = deployment.environment.slug +module Gitlab + module Prometheus + module Queries + class DeploymentQuery < BaseQuery + def query(deployment_id) + Deployment.find_by(id: deployment_id).try do |deployment| + environment_slug = deployment.environment.slug - memory_query = raw_memory_usage_query(environment_slug) - memory_avg_query = %{avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="#{environment_slug}"}[30m]))} - cpu_query = raw_cpu_usage_query(environment_slug) - cpu_avg_query = %{avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="#{environment_slug}"}[30m])) * 100} + memory_query = raw_memory_usage_query(environment_slug) + memory_avg_query = %{avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="#{environment_slug}"}[30m]))} + cpu_query = raw_cpu_usage_query(environment_slug) + cpu_avg_query = %{avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="#{environment_slug}"}[30m])) * 100} - timeframe_start = (deployment.created_at - 30.minutes).to_f - timeframe_end = (deployment.created_at + 30.minutes).to_f + timeframe_start = (deployment.created_at - 30.minutes).to_f + timeframe_end = (deployment.created_at + 30.minutes).to_f - { - memory_values: client_query_range(memory_query, start: timeframe_start, stop: timeframe_end), - memory_before: client_query(memory_avg_query, time: deployment.created_at.to_f), - memory_after: client_query(memory_avg_query, time: timeframe_end), + { + memory_values: client_query_range(memory_query, start: timeframe_start, stop: timeframe_end), + memory_before: client_query(memory_avg_query, time: deployment.created_at.to_f), + memory_after: client_query(memory_avg_query, time: timeframe_end), - cpu_values: client_query_range(cpu_query, start: timeframe_start, stop: timeframe_end), - cpu_before: client_query(cpu_avg_query, time: deployment.created_at.to_f), - cpu_after: client_query(cpu_avg_query, time: timeframe_end) - } + cpu_values: client_query_range(cpu_query, start: timeframe_start, stop: timeframe_end), + cpu_before: client_query(cpu_avg_query, time: deployment.created_at.to_f), + cpu_after: client_query(cpu_avg_query, time: timeframe_end) + } + end + end + end end end end diff --git a/lib/gitlab/prometheus/queries/environment_query.rb b/lib/gitlab/prometheus/queries/environment_query.rb index 01d756d7284..66f29d95177 100644 --- a/lib/gitlab/prometheus/queries/environment_query.rb +++ b/lib/gitlab/prometheus/queries/environment_query.rb @@ -1,20 +1,25 @@ -module Gitlab::Prometheus::Queries - class EnvironmentQuery < BaseQuery - def query(environment_id) - environment = Environment.find_by(id: environment_id) - environment_slug = environment.slug - timeframe_start = 8.hours.ago.to_f - timeframe_end = Time.now.to_f +module Gitlab + module Prometheus + module Queries + class EnvironmentQuery < BaseQuery + def query(environment_id) + Environment.find_by(id: environment_id).try do |environment| + environment_slug = environment.slug + timeframe_start = 8.hours.ago.to_f + timeframe_end = Time.now.to_f - memory_query = raw_memory_usage_query(environment_slug) - cpu_query = raw_cpu_usage_query(environment_slug) + memory_query = raw_memory_usage_query(environment_slug) + cpu_query = raw_cpu_usage_query(environment_slug) - { - memory_values: client_query_range(memory_query, start: timeframe_start, stop: timeframe_end), - memory_current: client_query(memory_query, time: timeframe_end), - cpu_values: client_query_range(cpu_query, start: timeframe_start, stop: timeframe_end), - cpu_current: client_query(cpu_query, time: timeframe_end) - } + { + memory_values: client_query_range(memory_query, start: timeframe_start, stop: timeframe_end), + memory_current: client_query(memory_query, time: timeframe_end), + cpu_values: client_query_range(cpu_query, start: timeframe_start, stop: timeframe_end), + cpu_current: client_query(cpu_query, time: timeframe_end) + } + end + end + end end end end diff --git a/lib/gitlab/prometheus/queries/matched_metrics_query.rb b/lib/gitlab/prometheus/queries/matched_metrics_query.rb new file mode 100644 index 00000000000..d4894c87f8d --- /dev/null +++ b/lib/gitlab/prometheus/queries/matched_metrics_query.rb @@ -0,0 +1,80 @@ +module Gitlab + module Prometheus + module Queries + class MatchedMetricsQuery < BaseQuery + MAX_QUERY_ITEMS = 40.freeze + + def query + groups_data.map do |group, data| + { + group: group.name, + priority: group.priority, + active_metrics: data[:active_metrics], + metrics_missing_requirements: data[:metrics_missing_requirements] + } + end + end + + private + + def groups_data + metrics_groups = groups_with_active_metrics(Gitlab::Prometheus::MetricGroup.all) + lookup = active_series_lookup(metrics_groups) + + groups = {} + + metrics_groups.each do |group| + groups[group] ||= { active_metrics: 0, metrics_missing_requirements: 0 } + active_metrics = group.metrics.count { |metric| metric.required_metrics.all?(&lookup.method(:has_key?)) } + + groups[group][:active_metrics] += active_metrics + groups[group][:metrics_missing_requirements] += group.metrics.count - active_metrics + end + + groups + end + + def active_series_lookup(metric_groups) + timeframe_start = 8.hours.ago + timeframe_end = Time.now + + series = metric_groups.flat_map(&:metrics).flat_map(&:required_metrics).uniq + + lookup = series.each_slice(MAX_QUERY_ITEMS).flat_map do |batched_series| + client_series(*batched_series, start: timeframe_start, stop: timeframe_end) + .select(&method(:has_matching_label)) + .map { |series_info| [series_info['__name__'], true] } + end + lookup.to_h + end + + def has_matching_label(series_info) + series_info.key?('environment') + end + + def available_metrics + @available_metrics ||= client_label_values || [] + end + + def filter_active_metrics(metric_group) + metric_group.metrics.select! do |metric| + metric.required_metrics.all?(&available_metrics.method(:include?)) + end + metric_group + end + + def groups_with_active_metrics(metric_groups) + metric_groups.map(&method(:filter_active_metrics)).select { |group| group.metrics.any? } + end + + def metrics_with_required_series(metric_groups) + metric_groups.flat_map do |group| + group.metrics.select do |metric| + metric.required_metrics.all?(&available_metrics.method(:include?)) + end + end + end + end + end + end +end diff --git a/lib/gitlab/prometheus/queries/query_additional_metrics.rb b/lib/gitlab/prometheus/queries/query_additional_metrics.rb new file mode 100644 index 00000000000..e44be770544 --- /dev/null +++ b/lib/gitlab/prometheus/queries/query_additional_metrics.rb @@ -0,0 +1,73 @@ +module Gitlab + module Prometheus + module Queries + module QueryAdditionalMetrics + def query_metrics(query_context) + query_processor = method(:process_query).curry[query_context] + + groups = matched_metrics.map do |group| + metrics = group.metrics.map do |metric| + { + title: metric.title, + weight: metric.weight, + y_label: metric.y_label, + queries: metric.queries.map(&query_processor).select(&method(:query_with_result)) + } + end + + { + group: group.name, + priority: group.priority, + metrics: metrics.select(&method(:metric_with_any_queries)) + } + end + + groups.select(&method(:group_with_any_metrics)) + end + + private + + def metric_with_any_queries(metric) + metric[:queries]&.count&.> 0 + end + + def group_with_any_metrics(group) + group[:metrics]&.count&.> 0 + end + + def query_with_result(query) + query[:result]&.any? do |item| + item&.[](:values)&.any? || item&.[](:value)&.any? + end + end + + def process_query(context, query) + query_with_result = query.dup + result = + if query.key?(:query_range) + client_query_range(query[:query_range] % context, start: context[:timeframe_start], stop: context[:timeframe_end]) + else + client_query(query[:query] % context, time: context[:timeframe_end]) + end + query_with_result[:result] = result&.map(&:deep_symbolize_keys) + query_with_result + end + + def available_metrics + @available_metrics ||= client_label_values || [] + end + + def matched_metrics + result = Gitlab::Prometheus::MetricGroup.all.map do |group| + group.metrics.select! do |metric| + metric.required_metrics.all?(&available_metrics.method(:include?)) + end + group + end + + result.select { |group| group.metrics.any? } + end + end + end + end +end diff --git a/lib/gitlab/prometheus_client.rb b/lib/gitlab/prometheus_client.rb index 5b51a1779dd..aa94614bf18 100644 --- a/lib/gitlab/prometheus_client.rb +++ b/lib/gitlab/prometheus_client.rb @@ -29,6 +29,14 @@ module Gitlab end end + def label_values(name = '__name__') + json_api_get("label/#{name}/values") + end + + def series(*matches, start: 8.hours.ago, stop: Time.now) + json_api_get('series', 'match': matches, start: start.to_f, end: stop.to_f) + end + private def json_api_get(type, args = {}) diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index e4d2a992470..b706434217d 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -43,7 +43,7 @@ module Gitlab end def environment_name_regex_message - "can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.' and spaces" + "can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.', and spaces" end def kubernetes_namespace_regex diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index b1d6ea665b7..22554236c38 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -30,8 +30,8 @@ module Gitlab end def version_required - @version_required ||= File.read(Rails.root. - join('GITLAB_SHELL_VERSION')).strip + @version_required ||= File.read(Rails.root + .join('GITLAB_SHELL_VERSION')).strip end def strip_key(key) diff --git a/lib/gitlab/sherlock/line_profiler.rb b/lib/gitlab/sherlock/line_profiler.rb index aa1468bff6b..b5f9d040047 100644 --- a/lib/gitlab/sherlock/line_profiler.rb +++ b/lib/gitlab/sherlock/line_profiler.rb @@ -77,8 +77,8 @@ module Gitlab line_samples << LineSample.new(duration, events) end - samples << FileSample. - new(file, line_samples, total_duration, total_events) + samples << FileSample + .new(file, line_samples, total_duration, total_events) end samples diff --git a/lib/gitlab/sherlock/query.rb b/lib/gitlab/sherlock/query.rb index 99e56e923eb..948bf5e6528 100644 --- a/lib/gitlab/sherlock/query.rb +++ b/lib/gitlab/sherlock/query.rb @@ -105,10 +105,10 @@ module Gitlab end def format_sql(query) - query.each_line. - map { |line| line.strip }. - join("\n"). - gsub(PREFIX_NEWLINE) { "\n#{$1} " } + query.each_line + .map { |line| line.strip } + .join("\n") + .gsub(PREFIX_NEWLINE) { "\n#{$1} " } end end end diff --git a/lib/gitlab/sql/recursive_cte.rb b/lib/gitlab/sql/recursive_cte.rb index 5b1b03820a3..16ec002f139 100644 --- a/lib/gitlab/sql/recursive_cte.rb +++ b/lib/gitlab/sql/recursive_cte.rb @@ -52,10 +52,10 @@ module Gitlab # Applies the CTE to the given relation, returning a new one that will # query from it. def apply_to(relation) - relation.except(:where). - with. - recursive(to_arel). - from(alias_to(relation.model.arel_table)) + relation.except(:where) + .with + .recursive(to_arel) + .from(alias_to(relation.model.arel_table)) end end end diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index bcba2e3e1b6..38dc82493cf 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -27,6 +27,7 @@ module Gitlab deploy_keys: DeployKey.count, deployments: Deployment.count, environments: Environment.count, + in_review_folder: Environment.in_review_folder.count, groups: Group.count, issues: Issue.count, keys: Key.count, diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb index 2b53798e70f..48f3d950779 100644 --- a/lib/gitlab/visibility_level.rb +++ b/lib/gitlab/visibility_level.rb @@ -13,18 +13,8 @@ module Gitlab scope :public_and_internal_only, -> { where(visibility_level: [PUBLIC, INTERNAL] ) } scope :non_public_only, -> { where.not(visibility_level: PUBLIC) } - scope :public_to_user, -> (user) do - if user - if user.admin? - all - elsif !user.external? - public_and_internal_only - else - public_only - end - else - public_only - end + scope :public_to_user, -> (user = nil) do + where(visibility_level: VisibilityLevel.levels_for_user(user)) end end @@ -35,6 +25,18 @@ module Gitlab class << self delegate :values, to: :options + def levels_for_user(user = nil) + return [PUBLIC] unless user + + if user.full_private_access? + [PRIVATE, INTERNAL, PUBLIC] + elsif user.external? + [PUBLIC] + else + [INTERNAL, PUBLIC] + end + end + def string_values string_options.keys end diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb index 7f27317775c..f96ee69096d 100644 --- a/lib/gitlab/workhorse.rb +++ b/lib/gitlab/workhorse.rb @@ -26,7 +26,10 @@ module Gitlab } if Gitlab.config.gitaly.enabled - address = Gitlab::GitalyClient.address(project.repository_storage) + server = { + address: Gitlab::GitalyClient.address(project.repository_storage), + token: Gitlab::GitalyClient.token(project.repository_storage) + } params[:Repository] = repository.gitaly_repository.to_h feature_enabled = case action.to_s @@ -39,8 +42,10 @@ module Gitlab else raise "Unsupported action: #{action}" end - - params[:GitalyAddress] = address if feature_enabled + if feature_enabled + params[:GitalyAddress] = server[:address] # This field will be deprecated + params[:GitalyServer] = server + end end params diff --git a/lib/system_check/simple_executor.rb b/lib/system_check/simple_executor.rb index dc2d4643a01..e5986612908 100644 --- a/lib/system_check/simple_executor.rb +++ b/lib/system_check/simple_executor.rb @@ -75,6 +75,8 @@ module SystemCheck check.show_error end + rescue StandardError => e + $stdout.puts "Exception: #{e.message}".color(:red) end private diff --git a/lib/tasks/gitlab/gitaly.rake b/lib/tasks/gitlab/gitaly.rake index e88111c3725..a8db5701d0b 100644 --- a/lib/tasks/gitlab/gitaly.rake +++ b/lib/tasks/gitlab/gitaly.rake @@ -58,8 +58,9 @@ namespace :gitlab do storages << { name: key, path: val['path'] } end - - TOML.dump(socket_path: address.sub(%r{\Aunix:}, ''), storage: storages) + config = { socket_path: address.sub(%r{\Aunix:}, ''), storage: storages } + config[:auth] = { token: 'secret' } if Rails.env.test? + TOML.dump(config) end def create_gitaly_configuration diff --git a/locale/bg/gitlab.po b/locale/bg/gitlab.po index 43a5de65c43..370aca1f1d9 100644 --- a/locale/bg/gitlab.po +++ b/locale/bg/gitlab.po @@ -3,25 +3,245 @@ msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-05-04 19:24-0500\n" +"POT-Creation-Date: 2017-06-12 19:29-0500\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2017-06-05 09:40-0400\n" +"PO-Revision-Date: 2017-06-13 04:23-0400\n" "Last-Translator: Lyubomir Vasilev <lyubomirv@abv.bg>\n" -"Language-Team: Bulgarian\n" +"Language-Team: Bulgarian (https://translate.zanata.org/project/view/GitLab)\n" "Language: bg\n" "X-Generator: Zanata 3.9.6\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" +msgid "%{commit_author_link} committed %{commit_timeago}" +msgstr "%{commit_author_link} подаде %{commit_timeago}" + +msgid "About auto deploy" +msgstr "Относно автоматичното внедряване" + +msgid "Active" +msgstr "Активно" + +msgid "Activity" +msgstr "Дейност" + +msgid "Add Changelog" +msgstr "Добавяне на списък с промени" + +msgid "Add Contribution guide" +msgstr "Добавяне на ръководство за сътрудничество" + +msgid "Add License" +msgstr "Добавяне на лиценз" + +msgid "Add an SSH key to your profile to pull or push via SSH." +msgstr "" +"Добавете SSH ключ в профила си, за да можете да изтегляте или изпращате " +"промени чрез SSH." + +msgid "Add new directory" +msgstr "Добавяне на нова папка" + +msgid "Archived project! Repository is read-only" +msgstr "Архивиран проект! Хранилището е само за четене" + +msgid "Are you sure you want to delete this pipeline schedule?" +msgstr "Наистина ли искате да изтриете този план за схема?" + +msgid "Attach a file by drag & drop or %{upload_link}" +msgstr "Прикачете файл чрез влачене и пускане или %{upload_link}" + +msgid "Branch" +msgid_plural "Branches" +msgstr[0] "Клон" +msgstr[1] "Клонове" + +msgid "" +"Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, " +"choose a GitLab CI Yaml template and commit your changes. " +"%{link_to_autodeploy_doc}" +msgstr "" +"Клонът <strong>%{branch_name}</strong> беше създаден. За да настроите " +"автоматичното внедряване, изберете Yaml шаблон за GitLab CI и подайте " +"промените си. %{link_to_autodeploy_doc}" + +msgid "Branches" +msgstr "Клонове" + +msgid "Browse files" +msgstr "Разглеждане на файловете" + msgid "ByAuthor|by" msgstr "от" +msgid "CI configuration" +msgstr "Конфигурация на непрекъсната интеграция" + +msgid "Cancel" +msgstr "Отказ" + +msgid "ChangeTypeActionLabel|Pick into branch" +msgstr "Избиране в клона" + +msgid "ChangeTypeActionLabel|Revert in branch" +msgstr "Отмяна в клона" + +msgid "ChangeTypeAction|Cherry-pick" +msgstr "Подбиране" + +msgid "ChangeType|commit" +msgstr "подаване" + +msgid "ChangeType|merge request" +msgstr "заявка за сливане" + +msgid "Changelog" +msgstr "Списък с промени" + +msgid "Charts" +msgstr "Графики" + +msgid "Cherry-pick this commit" +msgstr "Подбиране на това подаване" + +msgid "Cherry-pick this merge-request" +msgstr "Подбиране на тази заявка за сливане" + +msgid "CiStatusLabel|canceled" +msgstr "отказано" + +msgid "CiStatusLabel|created" +msgstr "създадено" + +msgid "CiStatusLabel|failed" +msgstr "неуспешно" + +msgid "CiStatusLabel|manual action" +msgstr "ръчно действие" + +msgid "CiStatusLabel|passed" +msgstr "успешно" + +msgid "CiStatusLabel|passed with warnings" +msgstr "успешно, с предупреждения" + +msgid "CiStatusLabel|pending" +msgstr "на изчакване" + +msgid "CiStatusLabel|skipped" +msgstr "пропуснато" + +msgid "CiStatusLabel|waiting for manual action" +msgstr "чакане за ръчно действие" + +msgid "CiStatusText|blocked" +msgstr "блокирано" + +msgid "CiStatusText|canceled" +msgstr "отказано" + +msgid "CiStatusText|created" +msgstr "създадено" + +msgid "CiStatusText|failed" +msgstr "неуспешно" + +msgid "CiStatusText|manual" +msgstr "ръчно" + +msgid "CiStatusText|passed" +msgstr "успешно" + +msgid "CiStatusText|pending" +msgstr "на изчакване" + +msgid "CiStatusText|skipped" +msgstr "пропуснато" + +msgid "CiStatus|running" +msgstr "протича в момента" + msgid "Commit" msgid_plural "Commits" msgstr[0] "Подаване" msgstr[1] "Подавания" +msgid "Commit message" +msgstr "Съобщение за подаването" + +msgid "CommitMessage|Add %{file_name}" +msgstr "Добавяне на „%{file_name}“" + +msgid "Commits" +msgstr "Подавания" + +msgid "Commits|History" +msgstr "История" + +msgid "Committed by" +msgstr "Подадено от" + +msgid "Compare" +msgstr "Сравнение" + +msgid "Contribution guide" +msgstr "Ръководство за сътрудничество" + +msgid "Contributors" +msgstr "Сътрудници" + +msgid "Copy URL to clipboard" +msgstr "Копиране на адреса в буфера за обмен" + +msgid "Copy commit SHA to clipboard" +msgstr "Копиране на идентификатора на подаването в буфера за обмен" + +msgid "Create New Directory" +msgstr "Създаване на нова папка" + +msgid "Create directory" +msgstr "Създаване на папка" + +msgid "Create empty bare repository" +msgstr "Създаване на празно хранилище" + +msgid "Create merge request" +msgstr "Създаване на заявка за сливане" + +msgid "Create new..." +msgstr "Създаване на нов…" + +msgid "CreateNewFork|Fork" +msgstr "Разклоняване" + +msgid "CreateTag|Tag" +msgstr "Етикет" + +msgid "Cron Timezone" +msgstr "Часова зона за „Cron“" + +msgid "Cron syntax" +msgstr "Синтаксис на „Cron“" + +msgid "Custom" +msgstr "Персонализиран" + +msgid "Custom notification events" +msgstr "Персонализирани събития за известяване" + +msgid "" +"Custom notification levels are the same as participating levels. With custom " +"notification levels you will also receive notifications for select events. " +"To find out more, check out %{notification_link}." +msgstr "" +"Персонализираните нива на известяване са същите като нивата за участие. С " +"персонализираните нива на известяване ще можете да получавате и известия за " +"избрани събития. За да научите повече, прегледайте %{notification_link}." + +msgid "Cycle Analytics" +msgstr "Анализ на циклите" + msgid "" "Cycle Analytics gives an overview of how much time it takes to go from idea " "to production in your project." @@ -50,17 +270,97 @@ msgstr "Подготовка за издаване" msgid "CycleAnalyticsStage|Test" msgstr "Тестване" +msgid "Define a custom pattern with cron syntax" +msgstr "Задайте потребителски шаблон, използвайки синтаксиса на „Cron“" + +msgid "Delete" +msgstr "Изтриване" + msgid "Deploy" msgid_plural "Deploys" msgstr[0] "Внедряване" msgstr[1] "Внедрявания" +msgid "Description" +msgstr "Описание" + +msgid "Directory name" +msgstr "Име на папката" + +msgid "Don't show again" +msgstr "Да не се показва повече" + +msgid "Download" +msgstr "Сваляне" + +msgid "Download tar" +msgstr "Сваляне във формат „tar“" + +msgid "Download tar.bz2" +msgstr "Сваляне във формат „tar.bz2“" + +msgid "Download tar.gz" +msgstr "Сваляне във формат „tar.gz“" + +msgid "Download zip" +msgstr "Сваляне във формат „zip“" + +msgid "DownloadArtifacts|Download" +msgstr "Сваляне" + +msgid "DownloadCommit|Email Patches" +msgstr "Изпращане на кръпките по е-поща" + +msgid "DownloadCommit|Plain Diff" +msgstr "Обикновен файл с разлики" + +msgid "DownloadSource|Download" +msgstr "Сваляне" + +msgid "Edit" +msgstr "Редактиране" + +msgid "Edit Pipeline Schedule %{id}" +msgstr "Редактиране на плана %{id} за схема" + +msgid "Every day (at 4:00am)" +msgstr "Всеки ден (в 4 ч. сутринта)" + +msgid "Every month (on the 1st at 4:00am)" +msgstr "Всеки месец (на 1-во число, в 4 ч. сутринта)" + +msgid "Every week (Sundays at 4:00am)" +msgstr "Всяка седмица (в неделя, в 4 ч. сутринта)" + +msgid "Failed to change the owner" +msgstr "Собственикът не може да бъде променен" + +msgid "Failed to remove the pipeline schedule" +msgstr "Планът за схема не може да бъде премахнат" + +msgid "Files" +msgstr "Файлове" + +msgid "Find by path" +msgstr "Търсене по път" + +msgid "Find file" +msgstr "Търсене на файл" + msgid "FirstPushedBy|First" msgstr "Първо" msgid "FirstPushedBy|pushed by" msgstr "изпращане на промени от" +msgid "Fork" +msgid_plural "Forks" +msgstr[0] "Разклонение" +msgstr[1] "Разклонения" + +msgid "ForkedFromProjectPath|Forked from" +msgstr "Разклонение на" + msgid "From issue creation until deploy to production" msgstr "От създаването на проблема до внедряването в крайната версия" @@ -68,50 +368,290 @@ msgid "From merge request merge until deploy to production" msgstr "" "От прилагането на заявката за сливане до внедряването в крайната версия" +msgid "Go to your fork" +msgstr "Към Вашето разклонение" + +msgid "GoToYourFork|Fork" +msgstr "Разклонение" + +msgid "Home" +msgstr "Начало" + +msgid "Housekeeping successfully started" +msgstr "Освежаването започна успешно" + +msgid "Import repository" +msgstr "Внасяне на хранилище" + +msgid "Interval Pattern" +msgstr "Шаблон за интервала" + msgid "Introducing Cycle Analytics" -msgstr "Представяме Ви анализът на циклите" +msgstr "Представяме Ви анализа на циклите" + +msgid "LFSStatus|Disabled" +msgstr "Изключено" + +msgid "LFSStatus|Enabled" +msgstr "Включено" msgid "Last %d day" msgid_plural "Last %d days" msgstr[0] "Последния %d ден" msgstr[1] "Последните %d дни" +msgid "Last Pipeline" +msgstr "Последна схема" + +msgid "Last Update" +msgstr "Последна промяна" + +msgid "Last commit" +msgstr "Последно подаване" + +msgid "Learn more in the" +msgstr "Научете повече в" + +msgid "Leave group" +msgstr "Напускане на групата" + +msgid "Leave project" +msgstr "Напускане на проекта" + msgid "Limited to showing %d event at most" msgid_plural "Limited to showing %d events at most" -msgstr[0] "Ограничено до показване на последното %d събитие" -msgstr[1] "Ограничено до показване на последните %d събития" +msgstr[0] "Ограничено до показване на най-много %d събитие" +msgstr[1] "Ограничено до показване на най-много %d събития" msgid "Median" msgstr "Медиана" +msgid "MissingSSHKeyWarningLink|add an SSH key" +msgstr "добавите SSH ключ" + msgid "New Issue" msgid_plural "New Issues" msgstr[0] "Нов проблем" msgstr[1] "Нови проблема" +msgid "New Pipeline Schedule" +msgstr "Нов план за схема" + +msgid "New branch" +msgstr "Нов клон" + +msgid "New directory" +msgstr "Нова папка" + +msgid "New file" +msgstr "Нов файл" + +msgid "New issue" +msgstr "Нов проблем" + +msgid "New merge request" +msgstr "Нова заявка за сливане" + +msgid "New schedule" +msgstr "Нов план" + +msgid "New snippet" +msgstr "Нов отрязък" + +msgid "New tag" +msgstr "Нов етикет" + +msgid "No repository" +msgstr "Няма хранилище" + +msgid "No schedules" +msgstr "Няма планове" + msgid "Not available" msgstr "Не е налично" msgid "Not enough data" msgstr "Няма достатъчно данни" +msgid "Notification events" +msgstr "Събития за известяване" + +msgid "NotificationEvent|Close issue" +msgstr "Затваряне на проблем" + +msgid "NotificationEvent|Close merge request" +msgstr "Затваряне на заявка за сливане" + +msgid "NotificationEvent|Failed pipeline" +msgstr "Неуспешно изпълнение на схема" + +msgid "NotificationEvent|Merge merge request" +msgstr "Прилагане на заявка за сливане" + +msgid "NotificationEvent|New issue" +msgstr "Нов проблем" + +msgid "NotificationEvent|New merge request" +msgstr "Нова заявка за сливане" + +msgid "NotificationEvent|New note" +msgstr "Нова бележка" + +msgid "NotificationEvent|Reassign issue" +msgstr "Преназначаване на проблем" + +msgid "NotificationEvent|Reassign merge request" +msgstr "Преназначаване на заявка за сливане" + +msgid "NotificationEvent|Reopen issue" +msgstr "Повторно отваряне на проблем" + +msgid "NotificationEvent|Successful pipeline" +msgstr "Успешно изпълнение на схема" + +msgid "NotificationLevel|Custom" +msgstr "Персонализирани" + +msgid "NotificationLevel|Disabled" +msgstr "Изключени" + +msgid "NotificationLevel|Global" +msgstr "Глобални" + +msgid "NotificationLevel|On mention" +msgstr "При споменаване" + +msgid "NotificationLevel|Participate" +msgstr "Участие" + +msgid "NotificationLevel|Watch" +msgstr "Наблюдение" + +msgid "OfSearchInADropdown|Filter" +msgstr "Филтър" + msgid "OpenedNDaysAgo|Opened" msgstr "Отворен" +msgid "Options" +msgstr "Опции" + +msgid "Owner" +msgstr "Собственик" + +msgid "Pipeline" +msgstr "Схема" + msgid "Pipeline Health" msgstr "Състояние" +msgid "Pipeline Schedule" +msgstr "План за схема" + +msgid "Pipeline Schedules" +msgstr "Планове за схема" + +msgid "PipelineSchedules|Activated" +msgstr "Включено" + +msgid "PipelineSchedules|Active" +msgstr "Активно" + +msgid "PipelineSchedules|All" +msgstr "Всички" + +msgid "PipelineSchedules|Inactive" +msgstr "Неактивно" + +msgid "PipelineSchedules|Next Run" +msgstr "Следващо изпълнение" + +msgid "PipelineSchedules|None" +msgstr "Нищо" + +msgid "PipelineSchedules|Provide a short description for this pipeline" +msgstr "Въведете кратко описание за тази схема" + +msgid "PipelineSchedules|Take ownership" +msgstr "Поемане на собствеността" + +msgid "PipelineSchedules|Target" +msgstr "Цел" + +msgid "Project '%{project_name}' queued for deletion." +msgstr "Проектът „%{project_name}“ е добавен в опашката за изтриване." + +msgid "Project '%{project_name}' was successfully created." +msgstr "Проектът „%{project_name}“ беше създаден успешно." + +msgid "Project '%{project_name}' was successfully updated." +msgstr "Проектът „%{project_name}“ беше обновен успешно." + +msgid "Project '%{project_name}' will be deleted." +msgstr "Проектът „%{project_name}“ ще бъде изтрит." + +msgid "Project access must be granted explicitly to each user." +msgstr "" +"Достъпът до проекта трябва да бъде даван поотделно на всеки потребител." + +msgid "Project export could not be deleted." +msgstr "Изнесените данни на проекта не могат да бъдат изтрити." + +msgid "Project export has been deleted." +msgstr "Изнесените данни на проекта бяха изтрити." + +msgid "" +"Project export link has expired. Please generate a new export from your " +"project settings." +msgstr "" +"Връзката към изнесените данни на проекта изгуби давност. Моля, създайте нова " +"от настройките на проекта." + +msgid "Project export started. A download link will be sent by email." +msgstr "" +"Изнасянето на проекта започна. Ще получите връзка към данните по е-поща." + +msgid "Project home" +msgstr "Начална страница на проекта" + +msgid "ProjectFeature|Disabled" +msgstr "Изключено" + +msgid "ProjectFeature|Everyone with access" +msgstr "Всеки с достъп" + +msgid "ProjectFeature|Only team members" +msgstr "Само членовете на екипа" + +msgid "ProjectFileTree|Name" +msgstr "Име" + +msgid "ProjectLastActivity|Never" +msgstr "Никога" + msgid "ProjectLifecycle|Stage" msgstr "Етап" +msgid "ProjectNetworkGraph|Graph" +msgstr "Графика" + msgid "Read more" msgstr "Прочетете повече" +msgid "Readme" +msgstr "ПрочетиМе" + +msgid "RefSwitcher|Branches" +msgstr "Клонове" + +msgid "RefSwitcher|Tags" +msgstr "Етикети" + msgid "Related Commits" msgstr "Свързани подавания" msgid "Related Deployed Jobs" -msgstr "Свързани задачи за внедряване" +msgstr "Свързани внедрени задачи" msgid "Related Issues" msgstr "Свързани проблеми" @@ -125,11 +665,87 @@ msgstr "Свързани заявки за сливане" msgid "Related Merged Requests" msgstr "Свързани приложени заявки за сливане" +msgid "Remind later" +msgstr "Напомняне по-късно" + +msgid "Remove project" +msgstr "Премахване на проекта" + +msgid "Request Access" +msgstr "Заявка за достъп" + +msgid "Revert this commit" +msgstr "Отмяна на това подаване" + +msgid "Revert this merge-request" +msgstr "Отмяна на тази заявка за сливане" + +msgid "Save pipeline schedule" +msgstr "Запазване на плана за схема" + +msgid "Schedule a new pipeline" +msgstr "Създаване на нов план за схема" + +msgid "Scheduling Pipelines" +msgstr "Планиране на схемите" + +msgid "Search branches and tags" +msgstr "Търсене в клоновете и етикетите" + +msgid "Select Archive Format" +msgstr "Изберете формата на архива" + +msgid "Select a timezone" +msgstr "Изберете часова зона" + +msgid "Select target branch" +msgstr "Изберете целеви клон" + +msgid "Set a password on your account to pull or push via %{protocol}" +msgstr "" +"Задайте парола на профила си, за да можете да изтегляте и изпращате промени " +"чрез %{protocol}" + +msgid "Set up CI" +msgstr "Настройка на НИ" + +msgid "Set up Koding" +msgstr "Настройка на „Koding“" + +msgid "Set up auto deploy" +msgstr "Настройка на авт. внедряване" + +msgid "SetPasswordToCloneLink|set a password" +msgstr "зададете парола" + msgid "Showing %d event" msgid_plural "Showing %d events" msgstr[0] "Показване на %d събитие" msgstr[1] "Показване на %d събития" +msgid "Source code" +msgstr "Изходен код" + +msgid "StarProject|Star" +msgstr "Звезда" + +msgid "Start a <strong>new merge request</strong> with these changes" +msgstr "Създайте <strong>нова заявка за сливане</strong> с тези промени" + +msgid "Switch branch/tag" +msgstr "Преминаване към клон/етикет" + +msgid "Tag" +msgid_plural "Tags" +msgstr[0] "Етикет" +msgstr[1] "Етикети" + +msgid "Tags" +msgstr "Етикети" + +msgid "Target Branch" +msgstr "Целеви клон" + msgid "" "The coding stage shows the time from the first commit to creating the merge " "request. The data will automatically be added here once you create your " @@ -142,6 +758,9 @@ msgstr "" msgid "The collection of events added to the data gathered for that stage." msgstr "Съвкупността от събития добавени към данните събрани за този етап." +msgid "The fork relationship has been removed." +msgstr "Връзката на разклонение беше премахната." + msgid "" "The issue stage shows the time it takes from creating an issue to assigning " "the issue to a milestone, or add the issue to a list on your Issue Board. " @@ -156,6 +775,15 @@ msgid "The phase of the development lifecycle." msgstr "Етапът от цикъла на разработка" msgid "" +"The pipelines schedule runs pipelines in the future, repeatedly, for " +"specific branches or tags. Those scheduled pipelines will inherit limited " +"project access based on their associated user." +msgstr "" +"Този план за схема ще изпълнява схемите в бъдеще, периодично, за определени " +"клонове или етикети. Тези планирани схеми ще наследят ограниченията на " +"достъпа до проекта на свързания с тях потребител." + +msgid "" "The planning stage shows the time from the previous step to pushing your " "first commit. This time will be added automatically once you push your first " "commit." @@ -170,7 +798,18 @@ msgid "" "once you have completed the full idea to production cycle." msgstr "" "Етапът на издаване показва общото време, което е нужно от създаването на " -"проблем до внедряването на кода в крайната версия." +"проблем до внедряването на кода в крайната версия. Данните ще бъдат добавени " +"автоматично след като завършите един пълен цикъл и превърнете първата си " +"идея в реалност." + +msgid "The project can be accessed by any logged in user." +msgstr "Всеки вписан потребител има достъп до проекта." + +msgid "The project can be accessed without any authentication." +msgstr "Всеки може да има достъп до проекта, без нужда от удостоверяване." + +msgid "The repository for this project does not exist." +msgstr "Хранилището за този проект не съществува." msgid "" "The review stage shows the time from creating the merge request to merging " @@ -197,8 +836,8 @@ msgid "" "first pipeline finishes running." msgstr "" "Етапът на тестване показва времето, което е нужно на „Gitlab CI“ да изпълни " -"всички задачи за свързаната заявка за сливане. Данните ще бъдат добавени " -"автоматично след като приключи изпълнените на първата Ви такава задача." +"всяка схема от задачи за свързаната заявка за сливане. Данните ще бъдат " +"добавени автоматично след като приключи изпълнението на първата Ви схема." msgid "The time taken by each data entry gathered by that stage." msgstr "Времето, което отнема всеки запис от данни за съответния етап." @@ -212,6 +851,13 @@ msgstr "" "данни. Например: медианата на 3, 5 и 9 е 5, а медианата на 3, 5, 7 и 8 е " "(5+7)/2 = 6." +msgid "" +"This means you can not push code until you create an empty repository or " +"import existing one." +msgstr "" +"Това означава, че няма да можете да изпращате код, докато не създадете " +"празно хранилище или не внесете съществуващо такова." + msgid "Time before an issue gets scheduled" msgstr "Време преди един проблем да бъде планиран за работа" @@ -225,6 +871,129 @@ msgstr "" msgid "Time until first merge request" msgstr "Време преди първата заявка за сливане" +msgid "Timeago|%s days ago" +msgstr "преди %s дни" + +msgid "Timeago|%s days remaining" +msgstr "остават %s дни" + +msgid "Timeago|%s hours remaining" +msgstr "остават %s часа" + +msgid "Timeago|%s minutes ago" +msgstr "преди %s минути" + +msgid "Timeago|%s minutes remaining" +msgstr "остават %s минути" + +msgid "Timeago|%s months ago" +msgstr "преди %s месеца" + +msgid "Timeago|%s months remaining" +msgstr "остават %s месеца" + +msgid "Timeago|%s seconds remaining" +msgstr "остават %s секунди" + +msgid "Timeago|%s weeks ago" +msgstr "преди %s седмици" + +msgid "Timeago|%s weeks remaining" +msgstr "остават %s седмици" + +msgid "Timeago|%s years ago" +msgstr "преди %s години" + +msgid "Timeago|%s years remaining" +msgstr "остават %s години" + +msgid "Timeago|1 day remaining" +msgstr "остава 1 ден" + +msgid "Timeago|1 hour remaining" +msgstr "остава 1 час" + +msgid "Timeago|1 minute remaining" +msgstr "остава 1 минута" + +msgid "Timeago|1 month remaining" +msgstr "остава 1 месец" + +msgid "Timeago|1 week remaining" +msgstr "остава 1 седмица" + +msgid "Timeago|1 year remaining" +msgstr "остава 1 година" + +msgid "Timeago|Past due" +msgstr "Просрочено" + +msgid "Timeago|a day ago" +msgstr "преди един ден" + +msgid "Timeago|a month ago" +msgstr "преди един месец" + +msgid "Timeago|a week ago" +msgstr "преди една седмица" + +msgid "Timeago|a while" +msgstr "преди известно време" + +msgid "Timeago|a year ago" +msgstr "преди една година" + +msgid "Timeago|about %s hours ago" +msgstr "преди около %s часа" + +msgid "Timeago|about a minute ago" +msgstr "преди около една минута" + +msgid "Timeago|about an hour ago" +msgstr "преди около един час" + +msgid "Timeago|in %s days" +msgstr "след %s дни" + +msgid "Timeago|in %s hours" +msgstr "след %s часа" + +msgid "Timeago|in %s minutes" +msgstr "след %s минути" + +msgid "Timeago|in %s months" +msgstr "след %s месеца" + +msgid "Timeago|in %s seconds" +msgstr "след %s секунди" + +msgid "Timeago|in %s weeks" +msgstr "след %s седмици" + +msgid "Timeago|in %s years" +msgstr "след %s години" + +msgid "Timeago|in 1 day" +msgstr "след 1 ден" + +msgid "Timeago|in 1 hour" +msgstr "след 1 час" + +msgid "Timeago|in 1 minute" +msgstr "след 1 минута" + +msgid "Timeago|in 1 month" +msgstr "след 1 месец" + +msgid "Timeago|in 1 week" +msgstr "след 1 седмица" + +msgid "Timeago|in 1 year" +msgstr "след 1 година" + +msgid "Timeago|less than a minute ago" +msgstr "преди по-малко от минута" + msgid "Time|hr" msgid_plural "Time|hrs" msgstr[0] "час" @@ -244,20 +1013,121 @@ msgstr "Общо време" msgid "Total test time for all commits/merges" msgstr "Общо време за тестване на всички подавания/сливания" +msgid "Unstar" +msgstr "Без звезда" + +msgid "Upload New File" +msgstr "Качване на нов файл" + +msgid "Upload file" +msgstr "Качване на файл" + +msgid "Use your global notification setting" +msgstr "Използване на глобалната Ви настройка за известията" + +msgid "VisibilityLevel|Internal" +msgstr "Вътрешен" + +msgid "VisibilityLevel|Private" +msgstr "Частен" + +msgid "VisibilityLevel|Public" +msgstr "Публичен" + msgid "Want to see the data? Please ask an administrator for access." msgstr "Искате ли да видите данните? Помолете администратор за достъп." msgid "We don't have enough data to show this stage." msgstr "Няма достатъчно данни за този етап." -msgid "You have reached your project limit" +msgid "Withdraw Access Request" +msgstr "Оттегляне на заявката за достъп" + +msgid "" +"You are going to remove %{project_name_with_namespace}.\n" +"Removed project CANNOT be restored!\n" +"Are you ABSOLUTELY sure?" msgstr "" +"На път сте да премахнете „%{project_name_with_namespace}“.\n" +"Ако го премахнете, той НЕ може да бъде възстановен!\n" +"НАИСТИНА ли искате това?" + +msgid "" +"You are going to remove the fork relationship to source project " +"%{forked_from_project}. Are you ABSOLUTELY sure?" +msgstr "" +"На път сте да премахнете връзката на разклонението към оригиналния проект, " +"„%{forked_from_project}“. НАИСТИНА ли искате това?" + +msgid "" +"You are going to transfer %{project_name_with_namespace} to another owner. " +"Are you ABSOLUTELY sure?" +msgstr "" +"На път сте да прехвърлите „%{project_name_with_namespace}“ към друг " +"собственик. НАИСТИНА ли искате това?" + +msgid "You can only add files when you are on a branch" +msgstr "Можете да добавяте файлове само когато се намирате в клон" + +msgid "You must sign in to star a project" +msgstr "Трябва да се впишете, за да отбележите проект със звезда" msgid "You need permission." msgstr "Нуждаете се от разрешение." +msgid "You will not get any notifications via email" +msgstr "Няма да получавате никакви известия по е-поща" + +msgid "You will only receive notifications for the events you choose" +msgstr "Ще получавате известия само за събитията, за които желаете" + +msgid "" +"You will only receive notifications for threads you have participated in" +msgstr "Ще получавате известия само за нещата, в които участвате" + +msgid "You will receive notifications for any activity" +msgstr "Ще получавате известия за всяка дейност" + +msgid "" +"You will receive notifications only for comments in which you were " +"@mentioned" +msgstr "Ще получавате известия само за коментари, в които Ви @споменават" + +msgid "" +"You won't be able to pull or push project code via %{protocol} until you " +"%{set_password_link} on your account" +msgstr "" +"Няма да можете да изтегляте или изпращате код в проекта чрез %{protocol}, " +"докато не %{set_password_link} за профила си" + +msgid "" +"You won't be able to pull or push project code via SSH until you " +"%{add_ssh_key_link} to your profile" +msgstr "" +"Няма да можете да изтегляте или изпращате код в проекта чрез SSH, докато не " +"%{add_ssh_key_link} в профила си" + +msgid "Your name" +msgstr "Вашето име" + msgid "day" msgid_plural "days" msgstr[0] "ден" msgstr[1] "дни" +msgid "notification emails" +msgstr "известия по е-поща" + +msgid "parent" +msgid_plural "parents" +msgstr[0] "родител" +msgstr[1] "родители" + +msgid "pipeline schedules documentation" +msgstr "документацията за планирането на схеми" + +msgid "with stage" +msgid_plural "with stages" +msgstr[0] "с етап" +msgstr[1] "с етапи" + diff --git a/locale/eo/gitlab.po b/locale/eo/gitlab.po new file mode 100644 index 00000000000..3ef9e19067d --- /dev/null +++ b/locale/eo/gitlab.po @@ -0,0 +1,1143 @@ +# Huang Tao <htve@outlook.com>, 2017. #zanata +# Lyubomir Vasilev <lyubomirv@abv.bg>, 2017. #zanata +msgid "" +msgstr "" +"Project-Id-Version: gitlab 1.0.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-15 21:59-0500\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"PO-Revision-Date: 2017-06-20 06:24-0400\n" +"Last-Translator: Lyubomir Vasilev <lyubomirv@abv.bg>\n" +"Language-Team: Esperanto (https://translate.zanata.org/project/view/GitLab)\n" +"Language: eo\n" +"X-Generator: Zanata 3.9.6\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" + +msgid "%{commit_author_link} committed %{commit_timeago}" +msgstr "%{commit_author_link} enmetis %{commit_timeago}" + +msgid "About auto deploy" +msgstr "Pri la aŭtomata disponigado" + +msgid "Active" +msgstr "Aktiva" + +msgid "Activity" +msgstr "Aktiveco" + +msgid "Add Changelog" +msgstr "Aldoni liston de ŝanĝoj" + +msgid "Add Contribution guide" +msgstr "Aldoni gvidliniojn por kontribuado" + +msgid "Add License" +msgstr "Aldoni rajtigilon" + +msgid "Add an SSH key to your profile to pull or push via SSH." +msgstr "" +"Aldonu SSH-ŝlosilon al via profilo por ebligi al vi eltiri kaj alpuŝi per " +"SSH." + +msgid "Add new directory" +msgstr "Aldoni novan dosierujon" + +msgid "Archived project! Repository is read-only" +msgstr "Arkivita projekto! La deponejo permesas nur legadon" + +msgid "Are you sure you want to delete this pipeline schedule?" +msgstr "Ĉu vi certe volas forigi ĉi tiun ĉenstablan planon?" + +msgid "Attach a file by drag & drop or %{upload_link}" +msgstr "Alkroĉu dosieron per ŝovmetado aŭ %{upload_link}" + +msgid "Branch" +msgid_plural "Branches" +msgstr[0] "Branĉo" +msgstr[1] "Branĉoj" + +msgid "" +"Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, " +"choose a GitLab CI Yaml template and commit your changes. " +"%{link_to_autodeploy_doc}" +msgstr "" +"La branĉo <strong>%{branch_name}</strong> estis kreita. Por agordi aŭtomatan " +"disponigadon, bonvolu elekti Yaml-ŝablonon por GitLab CI kaj enmeti viajn " +"ŝanĝojn. %{link_to_autodeploy_doc}" + +msgid "Branches" +msgstr "Branĉoj" + +msgid "Browse files" +msgstr "Elekti dosierojn" + +msgid "ByAuthor|by" +msgstr "de" + +msgid "CI configuration" +msgstr "Agordoj de seninterrompa integrado" + +msgid "Cancel" +msgstr "Nuligi" + +msgid "ChangeTypeActionLabel|Pick into branch" +msgstr "Elekti en branĉon" + +msgid "ChangeTypeActionLabel|Revert in branch" +msgstr "Malfari en branĉo" + +msgid "ChangeTypeAction|Cherry-pick" +msgstr "Precize elekti" + +msgid "ChangeTypeAction|Revert" +msgstr "Malfari" + +msgid "Changelog" +msgstr "Listo de ŝanĝoj" + +msgid "Charts" +msgstr "Diagramoj" + +msgid "Cherry-pick this commit" +msgstr "Precize elekti ĉi tiun kunmetadon" + +msgid "Cherry-pick this merge request" +msgstr "Precize elekti ĉi tiun peton pri kunfando" + +msgid "CiStatusLabel|canceled" +msgstr "nuligita" + +msgid "CiStatusLabel|created" +msgstr "kreita" + +msgid "CiStatusLabel|failed" +msgstr "malsukcesa" + +msgid "CiStatusLabel|manual action" +msgstr "mana ago" + +msgid "CiStatusLabel|passed" +msgstr "sukcesa" + +msgid "CiStatusLabel|passed with warnings" +msgstr "sukcesa, kun avertoj" + +msgid "CiStatusLabel|pending" +msgstr "okazonta" + +msgid "CiStatusLabel|skipped" +msgstr "transsaltita" + +msgid "CiStatusLabel|waiting for manual action" +msgstr "atendanta manan agon" + +msgid "CiStatusText|blocked" +msgstr "blokita" + +msgid "CiStatusText|canceled" +msgstr "nuligita" + +msgid "CiStatusText|created" +msgstr "kreita" + +msgid "CiStatusText|failed" +msgstr "malsukcesa" + +msgid "CiStatusText|manual" +msgstr "mana" + +msgid "CiStatusText|passed" +msgstr "sukcesa" + +msgid "CiStatusText|pending" +msgstr "okazonta" + +msgid "CiStatusText|skipped" +msgstr "transsaltita" + +msgid "CiStatus|running" +msgstr "plenumiĝanta" + +msgid "Commit" +msgid_plural "Commits" +msgstr[0] "Enmetado" +msgstr[1] "Enmetadoj" + +msgid "Commit message" +msgstr "Mesaĝo pri la enmetado" + +msgid "CommitBoxTitle|Commit" +msgstr "Enmeti" + +msgid "CommitMessage|Add %{file_name}" +msgstr "Aldoni „%{file_name}“" + +msgid "Commits" +msgstr "Enmetadoj" + +msgid "Commits|History" +msgstr "Historio" + +msgid "Committed by" +msgstr "Enmetita de" + +msgid "Compare" +msgstr "Kompari" + +msgid "Contribution guide" +msgstr "Gvidlinioj por kontribuado" + +msgid "Contributors" +msgstr "Kontribuantoj" + +msgid "Copy URL to clipboard" +msgstr "Kopii la adreson en la kopibufron" + +msgid "Copy commit SHA to clipboard" +msgstr "Kopii la identigilon de la enmetado" + +msgid "Create New Directory" +msgstr "Krei novan dosierujon" + +msgid "Create directory" +msgstr "Krei dosierujon" + +msgid "Create empty bare repository" +msgstr "Krei malplenan deponejon" + +msgid "Create merge request" +msgstr "Krei peton pri kunfando" + +msgid "Create new..." +msgstr "Krei novan…" + +msgid "CreateNewFork|Fork" +msgstr "Disbranĉigi" + +msgid "CreateTag|Tag" +msgstr "Etikedo" + +msgid "Cron Timezone" +msgstr "Horzono por Cron" + +msgid "Cron syntax" +msgstr "La sintakso de Cron" + +msgid "Custom notification events" +msgstr "Propraj sciigaj eventoj" + +msgid "" +"Custom notification levels are the same as participating levels. With custom " +"notification levels you will also receive notifications for select events. " +"To find out more, check out %{notification_link}." +msgstr "" +"La propraj sciigaj niveloj estas la samaj kiel la niveloj de partoprenado. " +"Uzante la proprajn sciigajn nivelojn, vi ricevos ankaŭ sciigojn por " +"elektitaj de vi eventoj. Por lerni pli, bonvolu vidi %{notification_link}." + +msgid "Cycle Analytics" +msgstr "Cikla analizo" + +msgid "" +"Cycle Analytics gives an overview of how much time it takes to go from idea " +"to production in your project." +msgstr "" +"La cikla analizo esploras kiom da tempo necesas por disvolvi ideon ĝis ĝi " +"fariĝos realaĵo." + +msgid "CycleAnalyticsStage|Code" +msgstr "Programado" + +msgid "CycleAnalyticsStage|Issue" +msgstr "Problemo" + +msgid "CycleAnalyticsStage|Plan" +msgstr "Plano" + +msgid "CycleAnalyticsStage|Production" +msgstr "Eldonado" + +msgid "CycleAnalyticsStage|Review" +msgstr "Kontrolo" + +msgid "CycleAnalyticsStage|Staging" +msgstr "Preparo por eldono" + +msgid "CycleAnalyticsStage|Test" +msgstr "Testado" + +msgid "Define a custom pattern with cron syntax" +msgstr "Difini propran ŝablonon, uzante la sintakson de Cron" + +msgid "Delete" +msgstr "Forigi" + +msgid "Deploy" +msgid_plural "Deploys" +msgstr[0] "Disponigado" +msgstr[1] "Disponigadoj" + +msgid "Description" +msgstr "Priskribo" + +msgid "Directory name" +msgstr "Nomo de dosierujo" + +msgid "Don't show again" +msgstr "Ne montru denove" + +msgid "Download" +msgstr "Elŝuti" + +msgid "Download tar" +msgstr "Elŝuti en formato „tar“" + +msgid "Download tar.bz2" +msgstr "Elŝuti en formato „tar.bz2“" + +msgid "Download tar.gz" +msgstr "Elŝuti en formato „tar.gz“" + +msgid "Download zip" +msgstr "Elŝuti en formato „zip“" + +msgid "DownloadArtifacts|Download" +msgstr "Elŝuti" + +msgid "DownloadCommit|Email Patches" +msgstr "Sendi flikaĵojn per retpoŝto" + +msgid "DownloadCommit|Plain Diff" +msgstr "Normala dosiero kun diferencoj" + +msgid "DownloadSource|Download" +msgstr "Elŝuti" + +msgid "Edit" +msgstr "Redakti" + +msgid "Edit Pipeline Schedule %{id}" +msgstr "Redakti ĉenstablan planon %{id}" + +msgid "Every day (at 4:00am)" +msgstr "Ĉiutage (je 4:00)" + +msgid "Every month (on the 1st at 4:00am)" +msgstr "Ĉiumonate (en la 1a de la monato, je 4:00)" + +msgid "Every week (Sundays at 4:00am)" +msgstr "Ĉiusemajne (en dimanĉo, je 4:00)" + +msgid "Failed to change the owner" +msgstr "Ne eblas ŝanĝi la posedanton" + +msgid "Failed to remove the pipeline schedule" +msgstr "Ne eblas forigi la ĉenstablan planon" + +msgid "Files" +msgstr "Dosieroj" + +msgid "Find by path" +msgstr "Trovi per dosierindiko" + +msgid "Find file" +msgstr "Trovi dosieron" + +msgid "FirstPushedBy|First" +msgstr "Unue" + +msgid "FirstPushedBy|pushed by" +msgstr "alpuŝita de" + +msgid "Fork" +msgid_plural "Forks" +msgstr[0] "Disbranĉigo" +msgstr[1] "Disbranĉigoj" + +msgid "ForkedFromProjectPath|Forked from" +msgstr "Disbranĉigita el" + +msgid "From issue creation until deploy to production" +msgstr "De la kreado de la problemo ĝis la disponigado en la publika versio" + +msgid "From merge request merge until deploy to production" +msgstr "" +"De la kunfandado de la peto pri kunfando ĝis la disponigado en la publika " +"versio" + +msgid "Go to your fork" +msgstr "Al via disbranĉigo" + +msgid "GoToYourFork|Fork" +msgstr "Disbranĉigo" + +msgid "Home" +msgstr "Hejmo" + +msgid "Housekeeping successfully started" +msgstr "La refreŝigo komenciĝis sukcese" + +msgid "Import repository" +msgstr "Enporti deponejon" + +msgid "Interval Pattern" +msgstr "Intervala ŝablono" + +msgid "Introducing Cycle Analytics" +msgstr "Ni prezentas al vi la ciklan analizon" + +msgid "LFSStatus|Disabled" +msgstr "Malŝaltita" + +msgid "LFSStatus|Enabled" +msgstr "Ŝaltita" + +msgid "Last %d day" +msgid_plural "Last %d days" +msgstr[0] "La lasta %d tago" +msgstr[1] "La lastaj %d tagoj" + +msgid "Last Pipeline" +msgstr "Lasta ĉenstablo" + +msgid "Last Update" +msgstr "Lasta ĝisdatigo" + +msgid "Last commit" +msgstr "Lasta enmetado" + +msgid "Learn more in the" +msgstr "Lernu pli en la" + +msgid "Learn more in the|pipeline schedules documentation" +msgstr "dokumentado pri ĉenstablaj planoj" + +msgid "Leave group" +msgstr "Forlasi la grupon" + +msgid "Leave project" +msgstr "Forlasi la projekton" + +msgid "Limited to showing %d event at most" +msgid_plural "Limited to showing %d events at most" +msgstr[0] "Limigita al montrado de ne pli ol %d evento" +msgstr[1] "Limigita al montrado de ne pli ol %d eventoj" + +msgid "Median" +msgstr "Mediano" + +msgid "MissingSSHKeyWarningLink|add an SSH key" +msgstr "aldonos SSH-ŝlosilon" + +msgid "New Issue" +msgid_plural "New Issues" +msgstr[0] "Nova problemo" +msgstr[1] "Novaj problemoj" + +msgid "New Pipeline Schedule" +msgstr "Nova ĉenstabla plano" + +msgid "New branch" +msgstr "Nova branĉo" + +msgid "New directory" +msgstr "Nova dosierujo" + +msgid "New file" +msgstr "Nova dosiero" + +msgid "New issue" +msgstr "Nova problemo" + +msgid "New merge request" +msgstr "Nova peto pri kunfando" + +msgid "New schedule" +msgstr "Nova plano" + +msgid "New snippet" +msgstr "Nova kodaĵo" + +msgid "New tag" +msgstr "Nova etikedo" + +msgid "No repository" +msgstr "Ne estas deponejo" + +msgid "No schedules" +msgstr "Ne estas planoj" + +msgid "Not available" +msgstr "Ne disponebla" + +msgid "Not enough data" +msgstr "Ne estas sufiĉe da datenoj" + +msgid "Notification events" +msgstr "Sciigaj eventoj" + +msgid "NotificationEvent|Close issue" +msgstr "Fermi problemon" + +msgid "NotificationEvent|Close merge request" +msgstr "Fermi peton pri kunfando" + +msgid "NotificationEvent|Failed pipeline" +msgstr "Malsukcesa ĉenstablo" + +msgid "NotificationEvent|Merge merge request" +msgstr "Apliki peton pri kunfando" + +msgid "NotificationEvent|New issue" +msgstr "Nova problemo" + +msgid "NotificationEvent|New merge request" +msgstr "Nova peto pri kunfando" + +msgid "NotificationEvent|New note" +msgstr "Nova noto" + +msgid "NotificationEvent|Reassign issue" +msgstr "Reatribui problemon" + +msgid "NotificationEvent|Reassign merge request" +msgstr "Reatribui peton pri kunfando" + +msgid "NotificationEvent|Reopen issue" +msgstr "Remalfermi problemon" + +msgid "NotificationEvent|Successful pipeline" +msgstr "Sukcesa ĉenstablo" + +msgid "NotificationLevel|Custom" +msgstr "Propraj" + +msgid "NotificationLevel|Disabled" +msgstr "Malŝaltitaj" + +msgid "NotificationLevel|Global" +msgstr "Ĝeneralaj" + +msgid "NotificationLevel|On mention" +msgstr "Ĉe mencio" + +msgid "NotificationLevel|Participate" +msgstr "Partoprenado" + +msgid "NotificationLevel|Watch" +msgstr "Rigardado" + +msgid "OfSearchInADropdown|Filter" +msgstr "Filtrilo" + +msgid "OpenedNDaysAgo|Opened" +msgstr "Malfermita" + +msgid "Options" +msgstr "Opcioj" + +msgid "Owner" +msgstr "Posedanto" + +msgid "Pipeline" +msgstr "Ĉenstablo" + +msgid "Pipeline Health" +msgstr "Stato" + +msgid "Pipeline Schedule" +msgstr "Ĉenstabla plano" + +msgid "Pipeline Schedules" +msgstr "Ĉenstablaj planoj" + +msgid "PipelineSchedules|Activated" +msgstr "Ŝaltita" + +msgid "PipelineSchedules|Active" +msgstr "Ŝaltitaj" + +msgid "PipelineSchedules|All" +msgstr "Ĉiuj" + +msgid "PipelineSchedules|Inactive" +msgstr "Malŝaltitaj" + +msgid "PipelineSchedules|Next Run" +msgstr "Sekvanta plenumo" + +msgid "PipelineSchedules|None" +msgstr "Nenio" + +msgid "PipelineSchedules|Provide a short description for this pipeline" +msgstr "Entajpu mallongan priskribon pri ĉi tiu ĉenstablo" + +msgid "PipelineSchedules|Take ownership" +msgstr "Akiri posedon" + +msgid "PipelineSchedules|Target" +msgstr "Celo" + +msgid "PipelineSheduleIntervalPattern|Custom" +msgstr "Propra" + +msgid "Pipeline|with stage" +msgstr "kun etapo" + +msgid "Pipeline|with stages" +msgstr "kun etapoj" + +msgid "Project '%{project_name}' queued for deletion." +msgstr "La projekto „%{project_name}“ estis alvicigita por forigado." + +msgid "Project '%{project_name}' was successfully created." +msgstr "La projekto „%{project_name}“ estis sukcese kreita." + +msgid "Project '%{project_name}' was successfully updated." +msgstr "La projekto „%{project_name}“ estis sukcese ĝisdatigita." + +msgid "Project '%{project_name}' will be deleted." +msgstr "La projekto „%{project_name}“ estos forigita." + +msgid "Project access must be granted explicitly to each user." +msgstr "Ĉiu uzanto devas akiri propran atingon al la projekto." + +msgid "Project export could not be deleted." +msgstr "Ne eblas forigi la projektan elporton." + +msgid "Project export has been deleted." +msgstr "La projekta elporto estis forigita." + +msgid "" +"Project export link has expired. Please generate a new export from your " +"project settings." +msgstr "" +"La ligilo por la projekta elporto eksvalidiĝis. Bonvolu krei novan elporton " +"en la agordoj de la projekto." + +msgid "Project export started. A download link will be sent by email." +msgstr "" +"La elporto de la projekto komenciĝis. Vi ricevos ligilon per retpoŝto por " +"elŝuti la datenoj." + +msgid "Project home" +msgstr "Hejmo de la projekto" + +msgid "ProjectFeature|Disabled" +msgstr "Malŝaltita" + +msgid "ProjectFeature|Everyone with access" +msgstr "Ĉiu, kiu havas atingon" + +msgid "ProjectFeature|Only team members" +msgstr "Nur skipanoj" + +msgid "ProjectFileTree|Name" +msgstr "Nomo" + +msgid "ProjectLastActivity|Never" +msgstr "Neniam" + +msgid "ProjectLifecycle|Stage" +msgstr "Etapo" + +msgid "ProjectNetworkGraph|Graph" +msgstr "Grafeo" + +msgid "Read more" +msgstr "Legu pli" + +msgid "Readme" +msgstr "LeguMin" + +msgid "RefSwitcher|Branches" +msgstr "Branĉoj" + +msgid "RefSwitcher|Tags" +msgstr "Etikedoj" + +msgid "Related Commits" +msgstr "Rilataj enmetadoj" + +msgid "Related Deployed Jobs" +msgstr "Rilataj disponigitaj taskoj" + +msgid "Related Issues" +msgstr "Rilataj problemoj" + +msgid "Related Jobs" +msgstr "Rilataj taskoj" + +msgid "Related Merge Requests" +msgstr "Rilataj petoj pri kunfando" + +msgid "Related Merged Requests" +msgstr "Rilataj aplikitaj petoj pri kunfando" + +msgid "Remind later" +msgstr "Rememorigu denove" + +msgid "Remove project" +msgstr "Forigi la projekton" + +msgid "Request Access" +msgstr "Peti atingeblon" + +msgid "Revert this commit" +msgstr "Malfari ĉi tiun enmetadon" + +msgid "Revert this merge request" +msgstr "Malfari ĉi tiun peton pri kunfando" + +msgid "Save pipeline schedule" +msgstr "Konservi ĉenstablan planon" + +msgid "Schedule a new pipeline" +msgstr "Plani novan ĉenstablon" + +msgid "Scheduling Pipelines" +msgstr "Planado de la ĉenstabloj" + +msgid "Search branches and tags" +msgstr "Serĉu branĉon aŭ etikedon" + +msgid "Select Archive Format" +msgstr "Elektu formaton de arkivo" + +msgid "Select a timezone" +msgstr "Elektu horzonon" + +msgid "Select target branch" +msgstr "Elektu celan branĉon" + +msgid "Set a password on your account to pull or push via %{protocol}" +msgstr "" +"Kreu pasvorton por via konto por ebligi al vi eltiri kaj alpuŝi per " +"%{protocol}" + +msgid "Set up CI" +msgstr "Agordi SI" + +msgid "Set up Koding" +msgstr "Agordi „Koding“" + +msgid "Set up auto deploy" +msgstr "Agordi aŭtomatan disponigadon" + +msgid "SetPasswordToCloneLink|set a password" +msgstr "kreos pasvorton" + +msgid "Showing %d event" +msgid_plural "Showing %d events" +msgstr[0] "Estas montrata %d evento" +msgstr[1] "Estas montrataj %d eventoj" + +msgid "Source code" +msgstr "Kodo" + +msgid "StarProject|Star" +msgstr "Steligi" + +msgid "Start a %{new_merge_request} with these changes" +msgstr "Kreu %{new_merge_request} kun ĉi tiuj ŝanĝoj" + +msgid "Switch branch/tag" +msgstr "Iri al branĉo/etikedo" + +msgid "Tag" +msgid_plural "Tags" +msgstr[0] "Etikedo" +msgstr[1] "Etikedoj" + +msgid "Tags" +msgstr "Etikedoj" + +msgid "Target Branch" +msgstr "Cela branĉo" + +msgid "" +"The coding stage shows the time from the first commit to creating the merge " +"request. The data will automatically be added here once you create your " +"first merge request." +msgstr "" +"La etapo de programado montras la tempon de la unua enmetado ĝis la kreado " +"de la peto pri kunfando. La datenoj aldoniĝos aŭtomate ĉi tie post kiam vi " +"kreas la unuan peton pri kunfando." + +msgid "The collection of events added to the data gathered for that stage." +msgstr "" +"La aro da eventoj, kiuj estas aldonitaj al la datenoj kolektitaj por la " +"etapo." + +msgid "The fork relationship has been removed." +msgstr "La rilato de disbranĉigo estis forigita." + +msgid "" +"The issue stage shows the time it takes from creating an issue to assigning " +"the issue to a milestone, or add the issue to a list on your Issue Board. " +"Begin creating issues to see data for this stage." +msgstr "" +"La etapo de la problemo montras kiom la tempo pasas de la kreado de problemo " +"ĝis la atribuado de la problemo al cela etapo de la projekto, aŭ al listo " +"sur la problemtabulo. Komencu krei problemojn por vidi la datenojn por ĉi " +"tiu etapo." + +msgid "The phase of the development lifecycle." +msgstr "La etapo de la disvolva ciklo." + +msgid "" +"The pipelines schedule runs pipelines in the future, repeatedly, for " +"specific branches or tags. Those scheduled pipelines will inherit limited " +"project access based on their associated user." +msgstr "" +"La ĉenstabla plano plenumas ĉenstablojn en la estonteco, ripete, por " +"difinitaj branĉoj aŭ etikedoj. Tiuj planitaj ĉenstabloj heredos la limigitan " +"atingon al la projekto de la rilata uzanto." + +msgid "" +"The planning stage shows the time from the previous step to pushing your " +"first commit. This time will be added automatically once you push your first " +"commit." +msgstr "" +"La etapo de la plano montras la tempon de la antaŭa ŝtupo ĝis la alpuŝado de " +"via unua enmetado. Ĉi tiu tempo aldoniĝos aŭtomate post kiam vi alpuŝas la " +"unuan enmetadon." + +msgid "" +"The production stage shows the total time it takes between creating an issue " +"and deploying the code to production. The data will be automatically added " +"once you have completed the full idea to production cycle." +msgstr "" +"La etapo de eldonado montras la tutan tempon de la kreado de problemo ĝis la " +"disponigado en la publika versio. La datenoj aldoniĝos aŭtomate post kiam vi " +"kompletigos plenan ciklon de ideo ĝis realaĵo." + +msgid "The project can be accessed by any logged in user." +msgstr "Ĉiu ensalutita uzanto havas atingon al la projekto" + +msgid "The project can be accessed without any authentication." +msgstr "Ĉiu povas havi atingon al la projekto, sen ensaluti" + +msgid "The repository for this project does not exist." +msgstr "La deponejo por ĉi tiu projekto ne ekzistas." + +msgid "" +"The review stage shows the time from creating the merge request to merging " +"it. The data will automatically be added after you merge your first merge " +"request." +msgstr "" +"La etapo de la kontrolo montras la tempon de la kreado de la peto pri " +"kunfando ĝis ĝia aplikado. La datenoj aldoniĝos aŭtomate post kiam vi " +"aplikos la unuan peton pri kunfando." + +msgid "" +"The staging stage shows the time between merging the MR and deploying code " +"to the production environment. The data will be automatically added once you " +"deploy to production for the first time." +msgstr "" +"La etapo de preparo por eldono montras la tempon inter la aplikado de la " +"peto pri kunfando kaj la disponigado de la kodo en la publika versio. La " +"datenoj aldoniĝos aŭtomate post kiam vi faros la unuan disponigadon en la " +"publika versio." + +msgid "" +"The testing stage shows the time GitLab CI takes to run every pipeline for " +"the related merge request. The data will automatically be added after your " +"first pipeline finishes running." +msgstr "" +"La etapo de testado montras kiom da tempo necesas al „GitLab CI“ por plenumi " +"ĉiujn ĉenstablojn por la rilata peto pri kunfando. La datenoj aldoniĝos " +"aŭtomate post kiam via unua ĉenstablo finiĝos." + +msgid "The time taken by each data entry gathered by that stage." +msgstr "La tempo, kiu estas necesa por ĉiu dateno kolektita de la etapo." + +msgid "" +"The value lying at the midpoint of a series of observed values. E.g., " +"between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 =" +" 6." +msgstr "" +"La valoro, kiu troviĝas en la mezo de aro da rigardataj valoroj. Ekzemple: " +"inter 3, 5 kaj 9, la mediano estas 5. Inter 3, 5, 7 kaj 8, la mediano estas " +"(5+7)/2 = 6." + +msgid "" +"This means you can not push code until you create an empty repository or " +"import existing one." +msgstr "" +"Ĉi tiu signifas, ke vi ne povos alpuŝi kodon, antaŭ ol vi kreos malplenan " +"deponejon aŭ enportos jam ekzistantan." + +msgid "Time before an issue gets scheduled" +msgstr "Tempo antaŭ problemo estas planita por ellabori" + +msgid "Time before an issue starts implementation" +msgstr "Tempo antaŭ la komenco de laboro super problemo" + +msgid "Time between merge request creation and merge/close" +msgstr "Tempo inter la kreado de poeto pri kunfando kaj ĝia aplikado/fermado" + +msgid "Time until first merge request" +msgstr "Tempo ĝis la unua peto pri kunfando" + +msgid "Timeago|%s days ago" +msgstr "antaŭ %s tagoj" + +msgid "Timeago|%s days remaining" +msgstr "restas %s tagoj" + +msgid "Timeago|%s hours remaining" +msgstr "restas %s horoj" + +msgid "Timeago|%s minutes ago" +msgstr "antaŭ %s minutoj" + +msgid "Timeago|%s minutes remaining" +msgstr "restas %s minutoj" + +msgid "Timeago|%s months ago" +msgstr "antaŭ %s monatoj" + +msgid "Timeago|%s months remaining" +msgstr "restas %s monatoj" + +msgid "Timeago|%s seconds remaining" +msgstr "restas %s sekundoj" + +msgid "Timeago|%s weeks ago" +msgstr "antaŭ %s semajnoj" + +msgid "Timeago|%s weeks remaining" +msgstr "restas %s semajnoj" + +msgid "Timeago|%s years ago" +msgstr "antaŭ %s jaroj" + +msgid "Timeago|%s years remaining" +msgstr "restas %s jaroj" + +msgid "Timeago|1 day remaining" +msgstr "restas 1 tago" + +msgid "Timeago|1 hour remaining" +msgstr "restas 1 horo" + +msgid "Timeago|1 minute remaining" +msgstr "restas 1 minuto" + +msgid "Timeago|1 month remaining" +msgstr "restas 1 monato" + +msgid "Timeago|1 week remaining" +msgstr "restas 1 semajno" + +msgid "Timeago|1 year remaining" +msgstr "restas 1 jaro" + +msgid "Timeago|Past due" +msgstr "Malfruiĝis" + +msgid "Timeago|a day ago" +msgstr "antaŭ unu tago" + +msgid "Timeago|a month ago" +msgstr "antaŭ unu monato" + +msgid "Timeago|a week ago" +msgstr "antaŭ unu semajno" + +msgid "Timeago|a while" +msgstr "antaŭ iom da tempo" + +msgid "Timeago|a year ago" +msgstr "antaŭ unu jaro" + +msgid "Timeago|about %s hours ago" +msgstr "antaŭ ĉirkaŭ %s horoj" + +msgid "Timeago|about a minute ago" +msgstr "antaŭ ĉirkaŭ unu minuto" + +msgid "Timeago|about an hour ago" +msgstr "antaŭ ĉirkaŭ unu horo" + +msgid "Timeago|in %s days" +msgstr "post %s tagoj" + +msgid "Timeago|in %s hours" +msgstr "post %s horoj" + +msgid "Timeago|in %s minutes" +msgstr "post %s minutoj" + +msgid "Timeago|in %s months" +msgstr "post %s monatoj" + +msgid "Timeago|in %s seconds" +msgstr "post %s sekundoj" + +msgid "Timeago|in %s weeks" +msgstr "post %s semajnoj" + +msgid "Timeago|in %s years" +msgstr "post %s jaroj" + +msgid "Timeago|in 1 day" +msgstr "post 1 tago" + +msgid "Timeago|in 1 hour" +msgstr "post 1 horo" + +msgid "Timeago|in 1 minute" +msgstr "post 1 minuto" + +msgid "Timeago|in 1 month" +msgstr "post 1 monato" + +msgid "Timeago|in 1 week" +msgstr "post 1 semajno" + +msgid "Timeago|in 1 year" +msgstr "post 1 jaro" + +msgid "Timeago|less than a minute ago" +msgstr "antaŭ malpli ol minuto" + +msgid "Time|hr" +msgid_plural "Time|hrs" +msgstr[0] "h" +msgstr[1] "h" + +msgid "Time|min" +msgid_plural "Time|mins" +msgstr[0] "min" +msgstr[1] "min" + +msgid "Time|s" +msgstr "s" + +msgid "Total Time" +msgstr "Totala tempo" + +msgid "Total test time for all commits/merges" +msgstr "Totala tempo por la testado de ĉiuj enmetadoj/kunfandoj" + +msgid "Unstar" +msgstr "Malsteligi" + +msgid "Upload New File" +msgstr "Alŝuti novan dosieron" + +msgid "Upload file" +msgstr "Alŝuti dosieron" + +msgid "Use your global notification setting" +msgstr "Uzi vian ĝeneralan agordon pri la sciigoj" + +msgid "VisibilityLevel|Internal" +msgstr "Interna" + +msgid "VisibilityLevel|Private" +msgstr "Privata" + +msgid "VisibilityLevel|Public" +msgstr "Publika" + +msgid "Want to see the data? Please ask an administrator for access." +msgstr "" +"Ĉu vi volas vidi la datenojn? Bonvolu peti atingeblon de administranto." + +msgid "We don't have enough data to show this stage." +msgstr "Ne estas sufiĉe da datenoj por montri ĉi tiun etapon." + +msgid "Withdraw Access Request" +msgstr "Nuligi la peton pri atingeblo" + +msgid "" +"You are going to remove %{project_name_with_namespace}.\n" +"Removed project CANNOT be restored!\n" +"Are you ABSOLUTELY sure?" +msgstr "" +"Vi forigos „%{project_name_with_namespace}“.\n" +"Oni NE POVAS malfari la forigon de projekto!\n" +"Ĉu vi estas ABSOLUTE certa?" + +msgid "" +"You are going to remove the fork relationship to source project " +"%{forked_from_project}. Are you ABSOLUTELY sure?" +msgstr "" +"Vi forigos la rilaton de la disbranĉigo al la originala projekto, " +"„%{forked_from_project}“. Ĉu vi estas ABSOLUTE certa?" + +msgid "" +"You are going to transfer %{project_name_with_namespace} to another owner. " +"Are you ABSOLUTELY sure?" +msgstr "" +"Vi transigos „%{project_name_with_namespace}“ al alia posedanto. Ĉu vi estas " +"ABSOLUTE certa?" + +msgid "You can only add files when you are on a branch" +msgstr "Oni povas aldoni dosierojn nur kiam oni estas en branĉo" + +msgid "You have reached your project limit" +msgstr "Vi ne povas krei pliajn projektojn" + +msgid "You must sign in to star a project" +msgstr "Oni devas ensaluti por steligi projekton" + +msgid "You need permission." +msgstr "VI bezonas permeson." + +msgid "You will not get any notifications via email" +msgstr "VI ne ricevos sciigojn per retpoŝto" + +msgid "You will only receive notifications for the events you choose" +msgstr "Vi ricevos sciigojn nur por la eventoj elektitaj de vi" + +msgid "" +"You will only receive notifications for threads you have participated in" +msgstr "Vi ricevos sciigojn nur por la fadenoj, en kiuj vi partoprenis" + +msgid "You will receive notifications for any activity" +msgstr "Vi ricevos sciigojn por ĉiu ago" + +msgid "" +"You will receive notifications only for comments in which you were " +"@mentioned" +msgstr "Vi ricevos sciigojn nur por komentoj, en kiuj vi estas @menciita" + +msgid "" +"You won't be able to pull or push project code via %{protocol} until you " +"%{set_password_link} on your account" +msgstr "" +"Vi ne povos eltiri aŭ alpuŝi kodon per %{protocol} antaŭ ol vi " +"%{set_password_link} por via konto" + +msgid "" +"You won't be able to pull or push project code via SSH until you " +"%{add_ssh_key_link} to your profile" +msgstr "" +"Vi ne povos eltiri aŭ alpuŝi kodon per SSH antaŭ ol vi %{add_ssh_key_link} " +"al via profilo" + +msgid "Your name" +msgstr "Via nomo" + +msgid "day" +msgid_plural "days" +msgstr[0] "tago" +msgstr[1] "tagoj" + +msgid "new merge request" +msgstr "novan peton pri kunfando" + +msgid "notification emails" +msgstr "sciigoj per retpoŝto" + +msgid "parent" +msgid_plural "parents" +msgstr[0] "patro" +msgstr[1] "patroj" + diff --git a/locale/eo/gitlab.po.time_stamp b/locale/eo/gitlab.po.time_stamp new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/locale/eo/gitlab.po.time_stamp diff --git a/locale/es/gitlab.po b/locale/es/gitlab.po index 6946a256308..cc44a06cbc5 100644 --- a/locale/es/gitlab.po +++ b/locale/es/gitlab.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2017-06-15 21:59-0500\n" +"PO-Revision-Date: 2017-06-21 12:09-0500\n" "Language-Team: Spanish\n" "Language: es\n" "MIME-Version: 1.0\n" @@ -17,6 +17,16 @@ msgstr "" "Last-Translator: Bob Van Landuyt <bob@gitlab.com>\n" "X-Generator: Poedit 2.0.2\n" +msgid "%d additional commit has been omitted to prevent performance issues." +msgid_plural "%d additional commits have been omitted to prevent performance issues." +msgstr[0] "%d cambio adicional ha sido omitido para evitar problemas de rendimiento." +msgstr[1] "%d cambios adicionales han sido omitidos para evitar problemas de rendimiento." + +msgid "%d commit" +msgid_plural "%d commits" +msgstr[0] "%d cambio" +msgstr[1] "%d cambios" + msgid "%{commit_author_link} committed %{commit_timeago}" msgstr "%{commit_author_link} cambió %{commit_timeago}" @@ -61,11 +71,26 @@ msgstr[1] "Ramas" msgid "Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, choose a GitLab CI Yaml template and commit your changes. %{link_to_autodeploy_doc}" msgstr "La rama <strong>%{branch_name}</strong> fue creada. Para configurar el auto despliegue, escoge una plantilla Yaml para GitLab CI y envía tus cambios. %{link_to_autodeploy_doc}" +msgid "BranchSwitcherPlaceholder|Search branches" +msgstr "Buscar ramas" + +msgid "BranchSwitcherTitle|Switch branch" +msgstr "Cambiar rama" + msgid "Branches" msgstr "Ramas" +msgid "Browse Directory" +msgstr "Examinar directorio" + +msgid "Browse File" +msgstr "Examinar archivo" + +msgid "Browse Files" +msgstr "Examinar archivos" + msgid "Browse files" -msgstr "Examinar los archivos" +msgstr "Examinar archivos" msgid "ByAuthor|by" msgstr "por" @@ -171,6 +196,9 @@ msgstr "Agregar %{file_name}" msgid "Commits" msgstr "Cambios" +msgid "Commits feed" +msgstr "Feed de cambios" + msgid "Commits|History" msgstr "Historial" @@ -323,6 +351,9 @@ msgstr "Error al eliminar la programación del pipeline" msgid "Files" msgstr "Archivos" +msgid "Filter by commit message" +msgstr "Filtrar por mensaje del cambio" + msgid "Find by path" msgstr "Buscar por ruta" @@ -945,9 +976,15 @@ msgstr "Subir nuevo archivo" msgid "Upload file" msgstr "Subir archivo" +msgid "UploadLink|click to upload" +msgstr "Hacer clic para subir" + msgid "Use your global notification setting" msgstr "Utiliza tu configuración de notificación global" +msgid "View open merge request" +msgstr "Ver solicitud de fusión abierta" + msgid "VisibilityLevel|Internal" msgstr "Interno" @@ -984,12 +1021,12 @@ msgstr "Vas a transferir %{project_name_with_namespace} a otro propietario. ¿Es msgid "You can only add files when you are on a branch" msgstr "Solo puedes agregar archivos cuando estás en una rama" +msgid "You have reached your project limit" +msgstr "Has alcanzado el límite de tu proyecto" + msgid "You must sign in to star a project" msgstr "Debes iniciar sesión para destacar un proyecto" -msgid "You have reached your project limit" -msgstr "" - msgid "You need permission." msgstr "Necesitas permisos." diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 2d8076f5567..07f9efeb495 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-06-15 21:59-0500\n" -"PO-Revision-Date: 2017-06-15 21:59-0500\n" +"POT-Creation-Date: 2017-06-19 15:50-0500\n" +"PO-Revision-Date: 2017-06-19 15:50-0500\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "Language: \n" @@ -18,6 +18,16 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" +msgid "%d additional commit have been omitted to prevent performance issues." +msgid_plural "%d additional commits have been omitted to prevent performance issues." +msgstr[0] "" +msgstr[1] "" + +msgid "%d commit" +msgid_plural "%d commits" +msgstr[0] "" +msgstr[1] "" + msgid "%{commit_author_link} committed %{commit_timeago}" msgstr "" @@ -62,9 +72,24 @@ msgstr[1] "" msgid "Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, choose a GitLab CI Yaml template and commit your changes. %{link_to_autodeploy_doc}" msgstr "" +msgid "BranchSwitcherPlaceholder|Search branches" +msgstr "" + +msgid "BranchSwitcherTitle|Switch branch" +msgstr "" + msgid "Branches" msgstr "" +msgid "Browse Directory" +msgstr "" + +msgid "Browse File" +msgstr "" + +msgid "Browse Files" +msgstr "" + msgid "Browse files" msgstr "" @@ -172,6 +197,9 @@ msgstr "" msgid "Commits" msgstr "" +msgid "Commits feed" +msgstr "" + msgid "Commits|History" msgstr "" @@ -324,6 +352,9 @@ msgstr "" msgid "Files" msgstr "" +msgid "Filter by commit message" +msgstr "" + msgid "Find by path" msgstr "" @@ -946,9 +977,15 @@ msgstr "" msgid "Upload file" msgstr "" +msgid "UploadLink|click to upload" +msgstr "" + msgid "Use your global notification setting" msgstr "" +msgid "View open merge request" +msgstr "" + msgid "VisibilityLevel|Internal" msgstr "" diff --git a/locale/zh_CN/gitlab.po b/locale/zh_CN/gitlab.po index 8d994ff3c4f..8ba95093b82 100644 --- a/locale/zh_CN/gitlab.po +++ b/locale/zh_CN/gitlab.po @@ -1,39 +1,241 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the gitlab package. -# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. -# +# Huang Tao <htve@outlook.com>, 2017. #zanata +# Xiaogang Wen <xiaogang@gitlab.com>, 2017. msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2017-05-04 19:24-0500\n" -"Last-Translator: HuangTao <htve@outlook.com>, 2017\n" -"Language-Team: Chinese (China) (https://www.transifex.com/gitlab-zh/teams/7517" -"7/zh_CN/)\n" +"POT-Creation-Date: 2017-06-15 21:59-0500\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: zh_CN\n" -"Plural-Forms: nplurals=1; plural=0;\n" +"PO-Revision-Date: 2017-06-19 09:57-0400\n" +"Last-Translator: Huang Tao <htve@outlook.com>\n" +"Language-Team: Chinese (China) (https://translate.zanata.org/project/view/GitLab)\n" +"Language: zh-CN\n" +"X-Generator: Zanata 3.9.6\n" +"Plural-Forms: nplurals=1; plural=0\n" + +msgid "%{commit_author_link} committed %{commit_timeago}" +msgstr "由 %{commit_author_link} 提交于 %{commit_timeago}" + +msgid "About auto deploy" +msgstr "关于自动部署" + +msgid "Active" +msgstr "启用" + +msgid "Activity" +msgstr "活动" + +msgid "Add Changelog" +msgstr "添加更新日志" + +msgid "Add Contribution guide" +msgstr "添加贡献指南" + +msgid "Add License" +msgstr "添加许可证" + +msgid "Add an SSH key to your profile to pull or push via SSH." +msgstr "新建一个用于推送或拉取的 SSH 秘钥到账号中。" + +msgid "Add new directory" +msgstr "添加目录" + +msgid "Archived project! Repository is read-only" +msgstr "项目已归档!存储库为只读状态" msgid "Are you sure you want to delete this pipeline schedule?" +msgstr "确定要删除此流水线计划吗?" + +msgid "Attach a file by drag & drop or %{upload_link}" +msgstr "拖放文件到此处或者 %{upload_link}" + +msgid "Branch" +msgid_plural "Branches" +msgstr[0] "分支" + +msgid "" +"Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, " +"choose a GitLab CI Yaml template and commit your changes. " +"%{link_to_autodeploy_doc}" msgstr "" +"已创建分支 <strong>%{branch_name}</strong> 。如需设置自动部署, 请选择合适的 GitLab CI Yaml " +"模板并提交更改。%{link_to_autodeploy_doc}" + +msgid "Branches" +msgstr "分支" + +msgid "Browse files" +msgstr "浏览文件" msgid "ByAuthor|by" msgstr "作者:" +msgid "CI configuration" +msgstr "CI 配置" + msgid "Cancel" -msgstr "" +msgstr "取消" + +msgid "ChangeTypeActionLabel|Pick into branch" +msgstr "选择分支" + +msgid "ChangeTypeActionLabel|Revert in branch" +msgstr "还原分支" + +msgid "ChangeTypeAction|Cherry-pick" +msgstr "优选" + +msgid "ChangeTypeAction|Revert" +msgstr "还原" + +msgid "Changelog" +msgstr "更新日志" + +msgid "Charts" +msgstr "统计图" + +msgid "Cherry-pick this commit" +msgstr "优选此提交" + +msgid "Cherry-pick this merge request" +msgstr "优选此合并请求" + +msgid "CiStatusLabel|canceled" +msgstr "已取消" + +msgid "CiStatusLabel|created" +msgstr "已创建" + +msgid "CiStatusLabel|failed" +msgstr "已失败" + +msgid "CiStatusLabel|manual action" +msgstr "手动操作" + +msgid "CiStatusLabel|passed" +msgstr "已通过" + +msgid "CiStatusLabel|passed with warnings" +msgstr "已通过但有警告" + +msgid "CiStatusLabel|pending" +msgstr "等待中" + +msgid "CiStatusLabel|skipped" +msgstr "已跳过" + +msgid "CiStatusLabel|waiting for manual action" +msgstr "等待手动操作" + +msgid "CiStatusText|blocked" +msgstr "已阻塞" + +msgid "CiStatusText|canceled" +msgstr "已取消" + +msgid "CiStatusText|created" +msgstr "已创建" + +msgid "CiStatusText|failed" +msgstr "已失败" + +msgid "CiStatusText|manual" +msgstr "手动操作" + +msgid "CiStatusText|passed" +msgstr "已通过" + +msgid "CiStatusText|pending" +msgstr "等待中" + +msgid "CiStatusText|skipped" +msgstr "已跳过" + +msgid "CiStatus|running" +msgstr "运行中" msgid "Commit" msgid_plural "Commits" msgstr[0] "提交" +msgid "Commit message" +msgstr "提交信息" + +msgid "CommitBoxTitle|Commit" +msgstr "提交" + +msgid "CommitMessage|Add %{file_name}" +msgstr "添加 %{file_name}" + +msgid "Commits" +msgstr "提交" + +msgid "Commits|History" +msgstr "历史" + +msgid "Committed by" +msgstr "提交者:" + +msgid "Compare" +msgstr "比较" + +msgid "Contribution guide" +msgstr "贡献指南" + +msgid "Contributors" +msgstr "贡献者" + +msgid "Copy URL to clipboard" +msgstr "复制 URL 到剪贴板" + +msgid "Copy commit SHA to clipboard" +msgstr "复制提交 SHA 的值到剪贴板" + +msgid "Create New Directory" +msgstr "创建新目录" + +msgid "Create directory" +msgstr "创建目录" + +msgid "Create empty bare repository" +msgstr "创建空的存储库" + +msgid "Create merge request" +msgstr "创建合并请求" + +msgid "Create new..." +msgstr "创建..." + +msgid "CreateNewFork|Fork" +msgstr "派生" + +msgid "CreateTag|Tag" +msgstr "标签" + msgid "Cron Timezone" +msgstr "Cron 时区" + +msgid "Cron syntax" +msgstr "Cron 语法" + +msgid "Custom notification events" +msgstr "自定义通知事件" + +msgid "" +"Custom notification levels are the same as participating levels. With custom " +"notification levels you will also receive notifications for select events. " +"To find out more, check out %{notification_link}." msgstr "" +"自定义通知级别继承自参与级别。使用自定义通知级别,您会收到参与级别及选定事件的通知。想了解更多信息,请查看 %{notification_link}." + +msgid "Cycle Analytics" +msgstr "周期分析" -msgid "Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project." +msgid "" +"Cycle Analytics gives an overview of how much time it takes to go from idea " +"to production in your project." msgstr "周期分析概述了项目从想法到产品实现的各阶段所需的时间。" msgid "CycleAnalyticsStage|Code" @@ -57,30 +259,81 @@ msgstr "预发布" msgid "CycleAnalyticsStage|Test" msgstr "测试" +msgid "Define a custom pattern with cron syntax" +msgstr "使用 Cron 语法定义自定义模式" + msgid "Delete" -msgstr "" +msgstr "删除" msgid "Deploy" msgid_plural "Deploys" msgstr[0] "部署" msgid "Description" -msgstr "" +msgstr "描述" + +msgid "Directory name" +msgstr "目录名称" + +msgid "Don't show again" +msgstr "不再显示" + +msgid "Download" +msgstr "下载" + +msgid "Download tar" +msgstr "下载 tar" + +msgid "Download tar.bz2" +msgstr "下载 tar.bz2" + +msgid "Download tar.gz" +msgstr "下载 tar.gz" + +msgid "Download zip" +msgstr "下载 zip" + +msgid "DownloadArtifacts|Download" +msgstr "下载" + +msgid "DownloadCommit|Email Patches" +msgstr "电子邮件补丁" + +msgid "DownloadCommit|Plain Diff" +msgstr "差异文件" + +msgid "DownloadSource|Download" +msgstr "下载" msgid "Edit" -msgstr "" +msgstr "编辑" msgid "Edit Pipeline Schedule %{id}" -msgstr "" +msgstr "编辑 %{id} 流水线计划" + +msgid "Every day (at 4:00am)" +msgstr "每日执行(凌晨 4 点)" + +msgid "Every month (on the 1st at 4:00am)" +msgstr "每月执行(每月 1 日凌晨 4 点)" + +msgid "Every week (Sundays at 4:00am)" +msgstr "每周执行(周日凌晨 4 点)" msgid "Failed to change the owner" -msgstr "" +msgstr "无法变更所有者" msgid "Failed to remove the pipeline schedule" -msgstr "" +msgstr "无法删除流水线计划" -msgid "Filter" -msgstr "" +msgid "Files" +msgstr "文件" + +msgid "Find by path" +msgstr "按路径查找" + +msgid "Find file" +msgstr "查找文件" msgid "FirstPushedBy|First" msgstr "首次推送" @@ -88,24 +341,70 @@ msgstr "首次推送" msgid "FirstPushedBy|pushed by" msgstr "推送者:" +msgid "Fork" +msgid_plural "Forks" +msgstr[0] "派生" + +msgid "ForkedFromProjectPath|Forked from" +msgstr "派生自" + msgid "From issue creation until deploy to production" msgstr "从创建议题到部署至生产环境" msgid "From merge request merge until deploy to production" msgstr "从合并请求被合并后到部署至生产环境" +msgid "Go to your fork" +msgstr "跳转到派生项目" + +msgid "GoToYourFork|Fork" +msgstr "跳转到派生项目" + +msgid "Home" +msgstr "首页" + +msgid "Housekeeping successfully started" +msgstr "已开始维护" + +msgid "Import repository" +msgstr "导入存储库" + msgid "Interval Pattern" -msgstr "" +msgstr "循环周期" msgid "Introducing Cycle Analytics" msgstr "周期分析简介" +msgid "LFSStatus|Disabled" +msgstr "停用" + +msgid "LFSStatus|Enabled" +msgstr "启用" + msgid "Last %d day" msgid_plural "Last %d days" -msgstr[0] "最后 %d 天" +msgstr[0] "最近 %d 天" msgid "Last Pipeline" -msgstr "" +msgstr "最新流水线" + +msgid "Last Update" +msgstr "最后更新" + +msgid "Last commit" +msgstr "最后提交" + +msgid "Learn more in the" +msgstr "了解更多" + +msgid "Learn more in the|pipeline schedules documentation" +msgstr "流水线计划文档" + +msgid "Leave group" +msgstr "退出群组" + +msgid "Leave project" +msgstr "退出项目" msgid "Limited to showing %d event at most" msgid_plural "Limited to showing %d events at most" @@ -114,15 +413,45 @@ msgstr[0] "最多显示 %d 个事件" msgid "Median" msgstr "中位数" +msgid "MissingSSHKeyWarningLink|add an SSH key" +msgstr "新建 SSH 公钥" + msgid "New Issue" msgid_plural "New Issues" -msgstr[0] "新议题" +msgstr[0] "新建议题" msgid "New Pipeline Schedule" -msgstr "" +msgstr "创建流水线计划" + +msgid "New branch" +msgstr "新建分支" + +msgid "New directory" +msgstr "新建目录" + +msgid "New file" +msgstr "新建文件" + +msgid "New issue" +msgstr "新建议题" + +msgid "New merge request" +msgstr "新建合并请求" + +msgid "New schedule" +msgstr "新建计划" + +msgid "New snippet" +msgstr "新建代码片段" + +msgid "New tag" +msgstr "新建标签" + +msgid "No repository" +msgstr "没有存储库" msgid "No schedules" -msgstr "" +msgstr "没有计划" msgid "Not available" msgstr "数据不足" @@ -130,54 +459,185 @@ msgstr "数据不足" msgid "Not enough data" msgstr "数据不足" +msgid "Notification events" +msgstr "通知事件" + +msgid "NotificationEvent|Close issue" +msgstr "关闭议题" + +msgid "NotificationEvent|Close merge request" +msgstr "关闭合并请求" + +msgid "NotificationEvent|Failed pipeline" +msgstr "流水线失败" + +msgid "NotificationEvent|Merge merge request" +msgstr "合并请求被合并" + +msgid "NotificationEvent|New issue" +msgstr "新建议题" + +msgid "NotificationEvent|New merge request" +msgstr "新建合并请求" + +msgid "NotificationEvent|New note" +msgstr "新建评论" + +msgid "NotificationEvent|Reassign issue" +msgstr "重新指派议题" + +msgid "NotificationEvent|Reassign merge request" +msgstr "重新指派合并请求" + +msgid "NotificationEvent|Reopen issue" +msgstr "重启议题" + +msgid "NotificationEvent|Successful pipeline" +msgstr "流水线成功完成" + +msgid "NotificationLevel|Custom" +msgstr "自定义" + +msgid "NotificationLevel|Disabled" +msgstr "停用" + +msgid "NotificationLevel|Global" +msgstr "全局" + +msgid "NotificationLevel|On mention" +msgstr "提及" + +msgid "NotificationLevel|Participate" +msgstr "参与" + +msgid "NotificationLevel|Watch" +msgstr "关注" + +msgid "OfSearchInADropdown|Filter" +msgstr "筛选" + msgid "OpenedNDaysAgo|Opened" msgstr "开始于" +msgid "Options" +msgstr "操作" + msgid "Owner" -msgstr "" +msgstr "所有者" + +msgid "Pipeline" +msgstr "流水线" msgid "Pipeline Health" msgstr "流水线健康指标" msgid "Pipeline Schedule" -msgstr "" +msgstr "流水线计划" msgid "Pipeline Schedules" -msgstr "" +msgstr "流水线计划" msgid "PipelineSchedules|Activated" -msgstr "" +msgstr "是否启用" msgid "PipelineSchedules|Active" -msgstr "" +msgstr "已启用" msgid "PipelineSchedules|All" -msgstr "" +msgstr "所有" msgid "PipelineSchedules|Inactive" -msgstr "" +msgstr "未启用" msgid "PipelineSchedules|Next Run" -msgstr "" +msgstr "下次运行时间" msgid "PipelineSchedules|None" -msgstr "" +msgstr "无" msgid "PipelineSchedules|Provide a short description for this pipeline" -msgstr "" +msgstr "为此流水线提供简短描述" msgid "PipelineSchedules|Take ownership" -msgstr "" +msgstr "取得所有者" msgid "PipelineSchedules|Target" -msgstr "" +msgstr "目标" + +msgid "PipelineSheduleIntervalPattern|Custom" +msgstr "自定义" + +msgid "Pipeline|with stage" +msgstr "于阶段" + +msgid "Pipeline|with stages" +msgstr "于阶段" + +msgid "Project '%{project_name}' queued for deletion." +msgstr "项目 '%{project_name}' 已进入删除队列。" + +msgid "Project '%{project_name}' was successfully created." +msgstr "项目 '%{project_name}' 已创建成功。" + +msgid "Project '%{project_name}' was successfully updated." +msgstr "项目 '%{project_name}' 已更新完成。" + +msgid "Project '%{project_name}' will be deleted." +msgstr "项目 '%{project_name}' 将被删除。" + +msgid "Project access must be granted explicitly to each user." +msgstr "项目访问权限必须明确授权给每个用户。" + +msgid "Project export could not be deleted." +msgstr "无法删除项目导出。" + +msgid "Project export has been deleted." +msgstr "项目导出已被删除。" + +msgid "" +"Project export link has expired. Please generate a new export from your " +"project settings." +msgstr "项目导出链接已过期。请从项目设置中重新生成项目导出。" + +msgid "Project export started. A download link will be sent by email." +msgstr "项目导出已开始。下载链接将通过电子邮件发送。" + +msgid "Project home" +msgstr "项目首页" + +msgid "ProjectFeature|Disabled" +msgstr "停用" + +msgid "ProjectFeature|Everyone with access" +msgstr "任何对项目有访问权的人" + +msgid "ProjectFeature|Only team members" +msgstr "只限团队成员" + +msgid "ProjectFileTree|Name" +msgstr "名称" + +msgid "ProjectLastActivity|Never" +msgstr "从未" msgid "ProjectLifecycle|Stage" -msgstr "项目生命周期" +msgstr "阶段" + +msgid "ProjectNetworkGraph|Graph" +msgstr "分支图" msgid "Read more" msgstr "了解更多" +msgid "Readme" +msgstr "自述文件" + +msgid "RefSwitcher|Branches" +msgstr "分支" + +msgid "RefSwitcher|Tags" +msgstr "标签" + msgid "Related Commits" msgstr "相关的提交" @@ -196,58 +656,163 @@ msgstr "相关的合并请求" msgid "Related Merged Requests" msgstr "相关已合并的合并请求" +msgid "Remind later" +msgstr "稍后提醒" + +msgid "Remove project" +msgstr "删除项目" + +msgid "Request Access" +msgstr "申请权限" + +msgid "Revert this commit" +msgstr "还原此提交" + +msgid "Revert this merge request" +msgstr "还原此合并请求" + msgid "Save pipeline schedule" -msgstr "" +msgstr "保存流水线计划" msgid "Schedule a new pipeline" -msgstr "" +msgstr "新建流水线计划" + +msgid "Scheduling Pipelines" +msgstr "流水线计划" + +msgid "Search branches and tags" +msgstr "搜索分支和标签" + +msgid "Select Archive Format" +msgstr "选择下载格式" msgid "Select a timezone" -msgstr "" +msgstr "选择时区" msgid "Select target branch" -msgstr "" +msgstr "选择目标分支" + +msgid "Set a password on your account to pull or push via %{protocol}" +msgstr "为账号创建一个用于推送或拉取的 %{protocol} 密码。" + +msgid "Set up CI" +msgstr "设置 CI" + +msgid "Set up Koding" +msgstr "设置 Koding" + +msgid "Set up auto deploy" +msgstr "设置自动部署" + +msgid "SetPasswordToCloneLink|set a password" +msgstr "设置密码" msgid "Showing %d event" msgid_plural "Showing %d events" msgstr[0] "显示 %d 个事件" +msgid "Source code" +msgstr "源代码" + +msgid "StarProject|Star" +msgstr "星标" + +msgid "Start a %{new_merge_request} with these changes" +msgstr "由此更改 %{new_merge_request}" + +msgid "Switch branch/tag" +msgstr "切换分支/标签" + +msgid "Tag" +msgid_plural "Tags" +msgstr[0] "标签" + +msgid "Tags" +msgstr "标签" + msgid "Target Branch" -msgstr "" +msgstr "目标分支" -msgid "The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request." +msgid "" +"The coding stage shows the time from the first commit to creating the merge " +"request. The data will automatically be added here once you create your " +"first merge request." msgstr "编码阶段概述了从第一次提交到创建合并请求的时间。创建第一个合并请求后,数据将自动添加到此处。" msgid "The collection of events added to the data gathered for that stage." -msgstr "与该阶段相关的事件。" +msgstr "与该阶段相关的事件集合。" -msgid "The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage." -msgstr "议题阶段概述了从创建议题到将议题设置里程碑或将议题添加到议题看板的时间。开始创建议题以查看此阶段的数据。" +msgid "The fork relationship has been removed." +msgstr "派生关系已被删除。" + +msgid "" +"The issue stage shows the time it takes from creating an issue to assigning " +"the issue to a milestone, or add the issue to a list on your Issue Board. " +"Begin creating issues to see data for this stage." +msgstr "议题阶段概述了从创建议题到将议题添加到里程碑或议题看板所花费的时间。创建第一个议题后,数据将自动添加到此处.。" msgid "The phase of the development lifecycle." msgstr "项目生命周期中的各个阶段。" -msgid "The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit." -msgstr "计划阶段概述了从议题添加到日程后到推送首次提交的时间。当首次推送提交后,数据将自动添加到此处。" +msgid "" +"The pipelines schedule runs pipelines in the future, repeatedly, for " +"specific branches or tags. Those scheduled pipelines will inherit limited " +"project access based on their associated user." +msgstr "流水线计划会周期性重复运行指定分支或标签的流水线。这些流水线将根据其关联用户继承有限的项目访问权限。" -msgid "The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle." +msgid "" +"The planning stage shows the time from the previous step to pushing your " +"first commit. This time will be added automatically once you push your first " +"commit." +msgstr "计划阶段概述了从议题添加到日程到推送首次提交的时间。当首次推送提交后,数据将自动添加到此处。" + +msgid "" +"The production stage shows the total time it takes between creating an issue " +"and deploying the code to production. The data will be automatically added " +"once you have completed the full idea to production cycle." msgstr "生产阶段概述了从创建一个议题到将代码部署到生产环境的总时间。当完成想法到部署生产的循环,数据将自动添加到此处。" -msgid "The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request." +msgid "The project can be accessed by any logged in user." +msgstr "该项目允许已登录的用户访问。" + +msgid "The project can be accessed without any authentication." +msgstr "该项目允许任何人访问。" + +msgid "The repository for this project does not exist." +msgstr "此项目的存储库不存在。" + +msgid "" +"The review stage shows the time from creating the merge request to merging " +"it. The data will automatically be added after you merge your first merge " +"request." msgstr "评审阶段概述了从创建合并请求到被合并的时间。当创建第一个合并请求后,数据将自动添加到此处。" -msgid "The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time." +msgid "" +"The staging stage shows the time between merging the MR and deploying code " +"to the production environment. The data will be automatically added once you " +"deploy to production for the first time." msgstr "预发布阶段概述了从合并请求被合并到部署至生产环境的总时间。首次部署到生产环境后,数据将自动添加到此处。" -msgid "The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running." -msgstr "测试阶段概述了GitLab CI为相关合并请求运行每个流水线所需的时间。当第一个流水线运行完成后,数据将自动添加到此处。" +msgid "" +"The testing stage shows the time GitLab CI takes to run every pipeline for " +"the related merge request. The data will automatically be added after your " +"first pipeline finishes running." +msgstr "测试阶段概述了 GitLab CI 为相关合并请求运行每个流水线所需的时间。当第一个流水线运行完成后,数据将自动添加到此处。" msgid "The time taken by each data entry gathered by that stage." msgstr "该阶段每条数据所花的时间" -msgid "The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6." +msgid "" +"The value lying at the midpoint of a series of observed values. E.g., " +"between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 =" +" 6." msgstr "中位数是一个数列中最中间的值。例如在 3、5、9 之间,中位数是 5。在 3、5、7、8 之间,中位数是 (5 + 7)/ 2 = 6。" +msgid "" +"This means you can not push code until you create an empty repository or " +"import existing one." +msgstr "在创建一个空的存储库或导入现有存储库之前,将无法推送代码。" + msgid "Time before an issue gets scheduled" msgstr "议题被列入日程表的时间" @@ -260,6 +825,129 @@ msgstr "从创建合并请求到被合并或关闭的时间" msgid "Time until first merge request" msgstr "创建第一个合并请求之前的时间" +msgid "Timeago|%s days ago" +msgstr " %s 天前" + +msgid "Timeago|%s days remaining" +msgstr "剩余 %s 天" + +msgid "Timeago|%s hours remaining" +msgstr "剩余 %s 小时" + +msgid "Timeago|%s minutes ago" +msgstr " %s 分钟前" + +msgid "Timeago|%s minutes remaining" +msgstr "剩余 %s 分钟" + +msgid "Timeago|%s months ago" +msgstr " %s 个月前" + +msgid "Timeago|%s months remaining" +msgstr "剩余 %s 月" + +msgid "Timeago|%s seconds remaining" +msgstr "剩余 %s 秒" + +msgid "Timeago|%s weeks ago" +msgstr " %s 星期前" + +msgid "Timeago|%s weeks remaining" +msgstr "剩余 %s 星期" + +msgid "Timeago|%s years ago" +msgstr " %s 年前" + +msgid "Timeago|%s years remaining" +msgstr "剩余 %s 年" + +msgid "Timeago|1 day remaining" +msgstr "剩余 1 天" + +msgid "Timeago|1 hour remaining" +msgstr "剩余 1 小时" + +msgid "Timeago|1 minute remaining" +msgstr "剩余 1 分钟" + +msgid "Timeago|1 month remaining" +msgstr "剩余 1 个月" + +msgid "Timeago|1 week remaining" +msgstr "剩余 1 星期" + +msgid "Timeago|1 year remaining" +msgstr "剩余 1 年" + +msgid "Timeago|Past due" +msgstr "逾期" + +msgid "Timeago|a day ago" +msgstr " 1 天前" + +msgid "Timeago|a month ago" +msgstr " 1 个月前" + +msgid "Timeago|a week ago" +msgstr " 1 星期前" + +msgid "Timeago|a while" +msgstr "刚刚" + +msgid "Timeago|a year ago" +msgstr " 1 年前" + +msgid "Timeago|about %s hours ago" +msgstr "约 %s 小时前" + +msgid "Timeago|about a minute ago" +msgstr "约 1 分钟前" + +msgid "Timeago|about an hour ago" +msgstr "约 1 小时前" + +msgid "Timeago|in %s days" +msgstr " %s 天后" + +msgid "Timeago|in %s hours" +msgstr " %s 小时后" + +msgid "Timeago|in %s minutes" +msgstr " %s 分钟后" + +msgid "Timeago|in %s months" +msgstr " %s 个月后" + +msgid "Timeago|in %s seconds" +msgstr " %s 秒后" + +msgid "Timeago|in %s weeks" +msgstr " %s 星期后" + +msgid "Timeago|in %s years" +msgstr " %s 年后" + +msgid "Timeago|in 1 day" +msgstr " 1 天后" + +msgid "Timeago|in 1 hour" +msgstr " 1 小时后" + +msgid "Timeago|in 1 minute" +msgstr " 1 分钟后" + +msgid "Timeago|in 1 month" +msgstr " 1 月后" + +msgid "Timeago|in 1 week" +msgstr " 1 星期后" + +msgid "Timeago|in 1 year" +msgstr " 1 年后" + +msgid "Timeago|less than a minute ago" +msgstr "不到 1 分钟前" + msgid "Time|hr" msgid_plural "Time|hrs" msgstr[0] "小时" @@ -277,18 +965,108 @@ msgstr "总时间" msgid "Total test time for all commits/merges" msgstr "所有提交和合并的总测试时间" +msgid "Unstar" +msgstr "取消星标" + +msgid "Upload New File" +msgstr "上传新文件" + +msgid "Upload file" +msgstr "上传文件" + +msgid "Use your global notification setting" +msgstr "使用全局通知设置" + +msgid "VisibilityLevel|Internal" +msgstr "内部" + +msgid "VisibilityLevel|Private" +msgstr "私有" + +msgid "VisibilityLevel|Public" +msgstr "公开" + msgid "Want to see the data? Please ask an administrator for access." msgstr "权限不足。如需查看相关数据,请向管理员申请权限。" msgid "We don't have enough data to show this stage." msgstr "该阶段的数据不足,无法显示。" +msgid "Withdraw Access Request" +msgstr "取消权限申请" + +msgid "" +"You are going to remove %{project_name_with_namespace}.\n" +"Removed project CANNOT be restored!\n" +"Are you ABSOLUTELY sure?" +msgstr "即将要删除 %{project_name_with_namespace}。\n" +"已删除的项目无法恢复!\n" +"确定继续吗?" + +msgid "" +"You are going to remove the fork relationship to source project " +"%{forked_from_project}. Are you ABSOLUTELY sure?" +msgstr "即将删除与源项目 %{forked_from_project} 的派生关系。确定继续吗?" + +msgid "" +"You are going to transfer %{project_name_with_namespace} to another owner. " +"Are you ABSOLUTELY sure?" +msgstr "即将 %{project_name_with_namespace} 转移给另一个所有者。确定继续吗?" + +msgid "You can only add files when you are on a branch" +msgstr "只能在分支上添加文件" + msgid "You have reached your project limit" -msgstr "" +msgstr "您已达到项目数量限制" + +msgid "You must sign in to star a project" +msgstr "必须登录才能对项目加星标" msgid "You need permission." -msgstr "您需要相关的权限。" +msgstr "需要相关的权限。" + +msgid "You will not get any notifications via email" +msgstr "不会收到任何通知邮件" + +msgid "You will only receive notifications for the events you choose" +msgstr "只接收选择的事件通知" + +msgid "" +"You will only receive notifications for threads you have participated in" +msgstr "只接收参与的主题的通知" + +msgid "You will receive notifications for any activity" +msgstr "接收所有活动的通知" + +msgid "" +"You will receive notifications only for comments in which you were " +"@mentioned" +msgstr "只接收评论中提及(@)您的通知" + +msgid "" +"You won't be able to pull or push project code via %{protocol} until you " +"%{set_password_link} on your account" +msgstr "在账号中 %{set_password_link} 之前将无法通过 %{protocol} 拉取或推送代码。" + +msgid "" +"You won't be able to pull or push project code via SSH until you " +"%{add_ssh_key_link} to your profile" +msgstr "在账号中 %{add_ssh_key_link} 之前将无法通过 SSH 拉取或推送代码。" + +msgid "Your name" +msgstr "您的名字" msgid "day" msgid_plural "days" msgstr[0] "天" + +msgid "new merge request" +msgstr "新建合并请求" + +msgid "notification emails" +msgstr "通知邮件" + +msgid "parent" +msgid_plural "parents" +msgstr[0] "父级" + diff --git a/locale/zh_HK/gitlab.po b/locale/zh_HK/gitlab.po index f0a9e44daf3..4d545d27185 100644 --- a/locale/zh_HK/gitlab.po +++ b/locale/zh_HK/gitlab.po @@ -1,39 +1,242 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the gitlab package. -# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. -# +# Huang Tao <htve@outlook.com>, 2017. #zanata +# Victor Wu <anonymous@domain.com>, 2017. +# Hazel Yang <anonymous@domain.com>, 2017. msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2017-05-04 19:24-0500\n" -"Last-Translator: HuangTao <htve@outlook.com>, 2017\n" -"Language-Team: Chinese (Hong Kong) (https://www.transifex.com/gitlab-zh/teams/" -"75177/zh_HK/)\n" +"POT-Creation-Date: 2017-06-15 21:59-0500\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: zh_HK\n" -"Plural-Forms: nplurals=1; plural=0;\n" +"PO-Revision-Date: 2017-06-19 09:57-0400\n" +"Last-Translator: Huang Tao <htve@outlook.com>\n" +"Language-Team: Chinese (Hong Kong) (https://translate.zanata.org/project/view/GitLab)\n" +"Language: zh-HK\n" +"X-Generator: Zanata 3.9.6\n" +"Plural-Forms: nplurals=1; plural=0\n" + +msgid "%{commit_author_link} committed %{commit_timeago}" +msgstr "由 %{commit_author_link} 提交於 %{commit_timeago}" + +msgid "About auto deploy" +msgstr "關於自動部署" + +msgid "Active" +msgstr "啟用" + +msgid "Activity" +msgstr "活動" + +msgid "Add Changelog" +msgstr "添加更新日誌" + +msgid "Add Contribution guide" +msgstr "添加貢獻指南" + +msgid "Add License" +msgstr "添加許可證" + +msgid "Add an SSH key to your profile to pull or push via SSH." +msgstr "新增壹個用於推送或拉取的 SSH 秘鑰到賬號中。" + +msgid "Add new directory" +msgstr "添加新目錄" + +msgid "Archived project! Repository is read-only" +msgstr "歸檔項目!存儲庫為只讀" msgid "Are you sure you want to delete this pipeline schedule?" +msgstr "確定要刪除此流水線計劃嗎?" + +msgid "Attach a file by drag & drop or %{upload_link}" +msgstr "拖放文件到此處或者 %{upload_link}" + +msgid "Branch" +msgid_plural "Branches" +msgstr[0] "分支" + +msgid "" +"Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, " +"choose a GitLab CI Yaml template and commit your changes. " +"%{link_to_autodeploy_doc}" msgstr "" +"分支 <strong>%{branch_name}</strong> 已創建。如需設置自動部署, 請選擇合適的 GitLab CI Yaml " +"模板併提交更改。%{link_to_autodeploy_doc}" + +msgid "Branches" +msgstr "分支" + +msgid "Browse files" +msgstr "瀏覽文件" msgid "ByAuthor|by" msgstr "作者:" +msgid "CI configuration" +msgstr "CI 配置" + msgid "Cancel" -msgstr "" +msgstr "取消" + +msgid "ChangeTypeActionLabel|Pick into branch" +msgstr "挑選到分支" + +msgid "ChangeTypeActionLabel|Revert in branch" +msgstr "還原分支" + +msgid "ChangeTypeAction|Cherry-pick" +msgstr "優選" + +msgid "ChangeTypeAction|Revert" +msgstr "還原" + +msgid "Changelog" +msgstr "更新日誌" + +msgid "Charts" +msgstr "統計圖" + +msgid "Cherry-pick this commit" +msgstr "優選此提交" + +msgid "Cherry-pick this merge request" +msgstr "優選此合併請求" + +msgid "CiStatusLabel|canceled" +msgstr "已取消" + +msgid "CiStatusLabel|created" +msgstr "已創建" + +msgid "CiStatusLabel|failed" +msgstr "已失敗" + +msgid "CiStatusLabel|manual action" +msgstr "手動操作" + +msgid "CiStatusLabel|passed" +msgstr "已通過" + +msgid "CiStatusLabel|passed with warnings" +msgstr "已通過但有警告" + +msgid "CiStatusLabel|pending" +msgstr "等待中" + +msgid "CiStatusLabel|skipped" +msgstr "已跳過" + +msgid "CiStatusLabel|waiting for manual action" +msgstr "等待手動操作" + +msgid "CiStatusText|blocked" +msgstr "已阻塞" + +msgid "CiStatusText|canceled" +msgstr "已取消" + +msgid "CiStatusText|created" +msgstr "已創建" + +msgid "CiStatusText|failed" +msgstr "已失敗" + +msgid "CiStatusText|manual" +msgstr "待手動" + +msgid "CiStatusText|passed" +msgstr "已通過" + +msgid "CiStatusText|pending" +msgstr "等待中" + +msgid "CiStatusText|skipped" +msgstr "已跳過" + +msgid "CiStatus|running" +msgstr "運行中" msgid "Commit" msgid_plural "Commits" msgstr[0] "提交" +msgid "Commit message" +msgstr "提交信息" + +msgid "CommitBoxTitle|Commit" +msgstr "提交" + +msgid "CommitMessage|Add %{file_name}" +msgstr "添加 %{file_name}" + +msgid "Commits" +msgstr "提交" + +msgid "Commits|History" +msgstr "歷史" + +msgid "Committed by" +msgstr "提交者:" + +msgid "Compare" +msgstr "比較" + +msgid "Contribution guide" +msgstr "貢獻指南" + +msgid "Contributors" +msgstr "貢獻者" + +msgid "Copy URL to clipboard" +msgstr "複製URL到剪貼板" + +msgid "Copy commit SHA to clipboard" +msgstr "複製提交 SHA 到剪貼板" + +msgid "Create New Directory" +msgstr "創建新目錄" + +msgid "Create directory" +msgstr "創建目錄" + +msgid "Create empty bare repository" +msgstr "創建空的存儲庫" + +msgid "Create merge request" +msgstr "創建合併請求" + +msgid "Create new..." +msgstr "創建..." + +msgid "CreateNewFork|Fork" +msgstr "派生" + +msgid "CreateTag|Tag" +msgstr "標籤" + msgid "Cron Timezone" +msgstr "Cron 時區" + +msgid "Cron syntax" +msgstr "Cron 語法" + +msgid "Custom notification events" +msgstr "自定義通知事件" + +msgid "" +"Custom notification levels are the same as participating levels. With custom " +"notification levels you will also receive notifications for select events. " +"To find out more, check out %{notification_link}." msgstr "" +"自定義通知級別繼承自參與級別。使用自定義通知級別,您會收到參與級別及選定事件的通知。想了解更多信息,請查看 %{notification_link}." + +msgid "Cycle Analytics" +msgstr "週期分析" -msgid "Cycle Analytics gives an overview of how much time it takes to go from idea to production in your project." +msgid "" +"Cycle Analytics gives an overview of how much time it takes to go from idea " +"to production in your project." msgstr "週期分析概述了項目從想法到產品實現的各階段所需的時間。" msgid "CycleAnalyticsStage|Code" @@ -57,30 +260,81 @@ msgstr "預發布" msgid "CycleAnalyticsStage|Test" msgstr "測試" +msgid "Define a custom pattern with cron syntax" +msgstr "使用 Cron 語法定義自定義模式" + msgid "Delete" -msgstr "" +msgstr "刪除" msgid "Deploy" msgid_plural "Deploys" msgstr[0] "部署" msgid "Description" -msgstr "" +msgstr "描述" + +msgid "Directory name" +msgstr "目錄名稱" + +msgid "Don't show again" +msgstr "不再顯示" + +msgid "Download" +msgstr "下載" + +msgid "Download tar" +msgstr "下載 tar" + +msgid "Download tar.bz2" +msgstr "下載 tar.bz2" + +msgid "Download tar.gz" +msgstr "下載 tar.gz" + +msgid "Download zip" +msgstr "下載 zip" + +msgid "DownloadArtifacts|Download" +msgstr "下載" + +msgid "DownloadCommit|Email Patches" +msgstr "電子郵件補丁" + +msgid "DownloadCommit|Plain Diff" +msgstr "差異文件" + +msgid "DownloadSource|Download" +msgstr "下載" msgid "Edit" -msgstr "" +msgstr "編輯" msgid "Edit Pipeline Schedule %{id}" -msgstr "" +msgstr "編輯 %{id} 流水線計劃" + +msgid "Every day (at 4:00am)" +msgstr "每日執行(淩晨 4 點)" + +msgid "Every month (on the 1st at 4:00am)" +msgstr "每月執行(每月 1 日淩晨 4 點)" + +msgid "Every week (Sundays at 4:00am)" +msgstr "每週執行(周日淩晨 4 點)" msgid "Failed to change the owner" -msgstr "" +msgstr "無法變更所有者" msgid "Failed to remove the pipeline schedule" -msgstr "" +msgstr "無法刪除流水線計劃" -msgid "Filter" -msgstr "" +msgid "Files" +msgstr "文件" + +msgid "Find by path" +msgstr "按路徑查找" + +msgid "Find file" +msgstr "查找文件" msgid "FirstPushedBy|First" msgstr "首次推送" @@ -88,24 +342,70 @@ msgstr "首次推送" msgid "FirstPushedBy|pushed by" msgstr "推送者:" +msgid "Fork" +msgid_plural "Forks" +msgstr[0] "派生" + +msgid "ForkedFromProjectPath|Forked from" +msgstr "派生自" + msgid "From issue creation until deploy to production" msgstr "從創建議題到部署到生產環境" msgid "From merge request merge until deploy to production" msgstr "從合併請求的合併到部署至生產環境" +msgid "Go to your fork" +msgstr "跳轉到派生項目" + +msgid "GoToYourFork|Fork" +msgstr "跳轉到派生項目" + +msgid "Home" +msgstr "首頁" + +msgid "Housekeeping successfully started" +msgstr "已開始維護" + +msgid "Import repository" +msgstr "導入存儲庫" + msgid "Interval Pattern" -msgstr "" +msgstr "循環週期" msgid "Introducing Cycle Analytics" msgstr "週期分析簡介" +msgid "LFSStatus|Disabled" +msgstr "停用" + +msgid "LFSStatus|Enabled" +msgstr "啟用" + msgid "Last %d day" msgid_plural "Last %d days" -msgstr[0] "最後 %d 天" +msgstr[0] "最近 %d 天" msgid "Last Pipeline" -msgstr "" +msgstr "最新流水線" + +msgid "Last Update" +msgstr "最後更新" + +msgid "Last commit" +msgstr "最後提交" + +msgid "Learn more in the" +msgstr "了解更多" + +msgid "Learn more in the|pipeline schedules documentation" +msgstr "流水線計劃文檔" + +msgid "Leave group" +msgstr "退出群組" + +msgid "Leave project" +msgstr "退出項目" msgid "Limited to showing %d event at most" msgid_plural "Limited to showing %d events at most" @@ -114,15 +414,45 @@ msgstr[0] "最多顯示 %d 個事件" msgid "Median" msgstr "中位數" +msgid "MissingSSHKeyWarningLink|add an SSH key" +msgstr "添加壹個 SSH 公鑰" + msgid "New Issue" msgid_plural "New Issues" -msgstr[0] "新議題" +msgstr[0] "新建議題" msgid "New Pipeline Schedule" -msgstr "" +msgstr "創建流水線計劃" + +msgid "New branch" +msgstr "新增分支" + +msgid "New directory" +msgstr "新增目錄" + +msgid "New file" +msgstr "新增文件" + +msgid "New issue" +msgstr "新議題" + +msgid "New merge request" +msgstr "新增合併請求" + +msgid "New schedule" +msgstr "新增计划" + +msgid "New snippet" +msgstr "新代碼片段" + +msgid "New tag" +msgstr "新增標籤" + +msgid "No repository" +msgstr "沒有存儲庫" msgid "No schedules" -msgstr "" +msgstr "沒有計劃" msgid "Not available" msgstr "不可用" @@ -130,54 +460,185 @@ msgstr "不可用" msgid "Not enough data" msgstr "數據不足" +msgid "Notification events" +msgstr "通知事件" + +msgid "NotificationEvent|Close issue" +msgstr "關閉議題" + +msgid "NotificationEvent|Close merge request" +msgstr "關閉合併請求" + +msgid "NotificationEvent|Failed pipeline" +msgstr "流水線失敗" + +msgid "NotificationEvent|Merge merge request" +msgstr "合併請求被合併" + +msgid "NotificationEvent|New issue" +msgstr "新增議題" + +msgid "NotificationEvent|New merge request" +msgstr "新合併請求" + +msgid "NotificationEvent|New note" +msgstr "新增評論" + +msgid "NotificationEvent|Reassign issue" +msgstr "重新指派議題" + +msgid "NotificationEvent|Reassign merge request" +msgstr "重新指派合併請求" + +msgid "NotificationEvent|Reopen issue" +msgstr "重啟議題" + +msgid "NotificationEvent|Successful pipeline" +msgstr "流水線成功完成" + +msgid "NotificationLevel|Custom" +msgstr "自定義" + +msgid "NotificationLevel|Disabled" +msgstr "停用" + +msgid "NotificationLevel|Global" +msgstr "全局" + +msgid "NotificationLevel|On mention" +msgstr "提及" + +msgid "NotificationLevel|Participate" +msgstr "參與" + +msgid "NotificationLevel|Watch" +msgstr "關注" + +msgid "OfSearchInADropdown|Filter" +msgstr "篩選" + msgid "OpenedNDaysAgo|Opened" msgstr "開始於" +msgid "Options" +msgstr "操作" + msgid "Owner" -msgstr "" +msgstr "所有者" + +msgid "Pipeline" +msgstr "流水線" msgid "Pipeline Health" msgstr "流水線健康指標" msgid "Pipeline Schedule" -msgstr "" +msgstr "流水線計劃" msgid "Pipeline Schedules" -msgstr "" +msgstr "流水線計劃" msgid "PipelineSchedules|Activated" -msgstr "" +msgstr "是否啟用" msgid "PipelineSchedules|Active" -msgstr "" +msgstr "已啟用" msgid "PipelineSchedules|All" -msgstr "" +msgstr "所有" msgid "PipelineSchedules|Inactive" -msgstr "" +msgstr "未啟用" msgid "PipelineSchedules|Next Run" -msgstr "" +msgstr "下次運行時間" msgid "PipelineSchedules|None" -msgstr "" +msgstr "無" msgid "PipelineSchedules|Provide a short description for this pipeline" -msgstr "" +msgstr "為此流水線提供簡短描述" msgid "PipelineSchedules|Take ownership" -msgstr "" +msgstr "取得所有者" msgid "PipelineSchedules|Target" -msgstr "" +msgstr "目標" + +msgid "PipelineSheduleIntervalPattern|Custom" +msgstr "自定義" + +msgid "Pipeline|with stage" +msgstr "於階段" + +msgid "Pipeline|with stages" +msgstr "於階段" + +msgid "Project '%{project_name}' queued for deletion." +msgstr "項目 '%{project_name}' 已進入刪除隊列。" + +msgid "Project '%{project_name}' was successfully created." +msgstr "項目 '%{project_name}' 已創建成功。" + +msgid "Project '%{project_name}' was successfully updated." +msgstr "項目 '%{project_name}' 已更新完成。" + +msgid "Project '%{project_name}' will be deleted." +msgstr "項目 '%{project_name}' 將被刪除。" + +msgid "Project access must be granted explicitly to each user." +msgstr "項目訪問權限必須明確授權給每個用戶。" + +msgid "Project export could not be deleted." +msgstr "無法刪除項目導出。" + +msgid "Project export has been deleted." +msgstr "項目導出已被刪除。" + +msgid "" +"Project export link has expired. Please generate a new export from your " +"project settings." +msgstr "項目導出鏈接已過期。請從項目設置中重新生成項目導出。" + +msgid "Project export started. A download link will be sent by email." +msgstr "項目導出已開始。下載鏈接將通過電子郵件發送。" + +msgid "Project home" +msgstr "項目首頁" + +msgid "ProjectFeature|Disabled" +msgstr "停用" + +msgid "ProjectFeature|Everyone with access" +msgstr "任何人都可訪問" + +msgid "ProjectFeature|Only team members" +msgstr "只限團隊成員" + +msgid "ProjectFileTree|Name" +msgstr "名稱" + +msgid "ProjectLastActivity|Never" +msgstr "從未" msgid "ProjectLifecycle|Stage" -msgstr "項目生命週期" +msgstr "階段" + +msgid "ProjectNetworkGraph|Graph" +msgstr "分支圖" msgid "Read more" msgstr "了解更多" +msgid "Readme" +msgstr "自述文件" + +msgid "RefSwitcher|Branches" +msgstr "分支" + +msgid "RefSwitcher|Tags" +msgstr "標籤" + msgid "Related Commits" msgstr "相關的提交" @@ -194,59 +655,164 @@ msgid "Related Merge Requests" msgstr "相關的合併請求" msgid "Related Merged Requests" -msgstr "相關已合併的合並請求" +msgstr "相關已合併的合併請求" + +msgid "Remind later" +msgstr "稍後提醒" + +msgid "Remove project" +msgstr "刪除項目" + +msgid "Request Access" +msgstr "申請權限" + +msgid "Revert this commit" +msgstr "還原此提交" + +msgid "Revert this merge request" +msgstr "還原此合併請求" msgid "Save pipeline schedule" -msgstr "" +msgstr "保存流水線計劃" msgid "Schedule a new pipeline" -msgstr "" +msgstr "新建流水線計劃" + +msgid "Scheduling Pipelines" +msgstr "流水線計劃" + +msgid "Search branches and tags" +msgstr "搜索分支和標籤" + +msgid "Select Archive Format" +msgstr "選擇下載格式" msgid "Select a timezone" -msgstr "" +msgstr "選擇時區" msgid "Select target branch" -msgstr "" +msgstr "選擇目標分支" + +msgid "Set a password on your account to pull or push via %{protocol}" +msgstr "為賬號添加壹個用於推送或拉取的 %{protocol} 密碼。" + +msgid "Set up CI" +msgstr "設置 CI" + +msgid "Set up Koding" +msgstr "設置 Koding" + +msgid "Set up auto deploy" +msgstr "設置自動部署" + +msgid "SetPasswordToCloneLink|set a password" +msgstr "設置密碼" msgid "Showing %d event" msgid_plural "Showing %d events" msgstr[0] "顯示 %d 個事件" +msgid "Source code" +msgstr "源代碼" + +msgid "StarProject|Star" +msgstr "星標" + +msgid "Start a %{new_merge_request} with these changes" +msgstr "由此更改 %{new_merge_request}" + +msgid "Switch branch/tag" +msgstr "切換分支/標籤" + +msgid "Tag" +msgid_plural "Tags" +msgstr[0] "標籤" + +msgid "Tags" +msgstr "標籤" + msgid "Target Branch" -msgstr "" +msgstr "目標分支" -msgid "The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request." -msgstr "編碼階段概述了從第一次提交到創建合併請求的時間。創建第壹個合並請求後,數據將自動添加到此處。" +msgid "" +"The coding stage shows the time from the first commit to creating the merge " +"request. The data will automatically be added here once you create your " +"first merge request." +msgstr "編碼階段概述了從第壹次提交到創建合併請求的時間。創建第壹個合併請求後,數據將自動添加到此處。" msgid "The collection of events added to the data gathered for that stage." msgstr "與該階段相關的事件。" -msgid "The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage." -msgstr "議題階段概述了從創建議題到將議題設置裏程碑或將議題添加到議題看板的時間。創建一個議題後,數據將自動添加到此處。" +msgid "The fork relationship has been removed." +msgstr "派生關係已被刪除。" + +msgid "" +"The issue stage shows the time it takes from creating an issue to assigning " +"the issue to a milestone, or add the issue to a list on your Issue Board. " +"Begin creating issues to see data for this stage." +msgstr "議題階段概述了從創建議題到將議題添加到裏程碑或議題看板所花費的時間。創建第壹個議題後,數據將自動添加到此處.。" msgid "The phase of the development lifecycle." msgstr "項目生命週期中的各個階段。" -msgid "The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit." -msgstr "計劃階段概述了從議題添加到日程後到推送首次提交的時間。當首次推送提交後,數據將自動添加到此處。" +msgid "" +"The pipelines schedule runs pipelines in the future, repeatedly, for " +"specific branches or tags. Those scheduled pipelines will inherit limited " +"project access based on their associated user." +msgstr "流水線計劃會週期性重複運行指定分支或標籤的流水線。這些流水線將根據其關聯用戶繼承有限的項目訪問權限。" -msgid "The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle." +msgid "" +"The planning stage shows the time from the previous step to pushing your " +"first commit. This time will be added automatically once you push your first " +"commit." +msgstr "計劃階段概述了從議題添加到日程到推送首次提交的時間。當首次推送提交後,數據將自動添加到此處。" + +msgid "" +"The production stage shows the total time it takes between creating an issue " +"and deploying the code to production. The data will be automatically added " +"once you have completed the full idea to production cycle." msgstr "生產階段概述了從創建議題到將代碼部署到生產環境的時間。當完成完整的想法到部署生產,數據將自動添加到此處。" -msgid "The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request." -msgstr "評審階段概述了從創建合並請求到合併的時間。當創建第壹個合並請求後,數據將自動添加到此處。" +msgid "The project can be accessed by any logged in user." +msgstr "該項目允許已登錄的用戶訪問。" + +msgid "The project can be accessed without any authentication." +msgstr "該項目允許任何人訪問。" -msgid "The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time." -msgstr "預發布階段概述了合並請求的合併到部署代碼到生產環境的總時間。當首次部署到生產環境後,數據將自動添加到此處。" +msgid "The repository for this project does not exist." +msgstr "此項目的存儲庫不存在。" -msgid "The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running." -msgstr "測試階段概述了GitLab CI為相關合併請求運行每個流水線所需的時間。當第壹個流水線運行完成後,數據將自動添加到此處。" +msgid "" +"The review stage shows the time from creating the merge request to merging " +"it. The data will automatically be added after you merge your first merge " +"request." +msgstr "評審階段概述了從創建合併請求到合併的時間。當創建第壹個合併請求後,數據將自動添加到此處。" + +msgid "" +"The staging stage shows the time between merging the MR and deploying code " +"to the production environment. The data will be automatically added once you " +"deploy to production for the first time." +msgstr "預發布階段概述了合併請求的合併到部署代碼到生產環境的總時間。當首次部署到生產環境後,數據將自動添加到此處。" + +msgid "" +"The testing stage shows the time GitLab CI takes to run every pipeline for " +"the related merge request. The data will automatically be added after your " +"first pipeline finishes running." +msgstr "測試階段概述了 GitLab CI 為相關合併請求運行每個流水線所需的時間。當第壹個流水線運行完成後,數據將自動添加到此處。" msgid "The time taken by each data entry gathered by that stage." msgstr "該階段每條數據所花的時間" -msgid "The value lying at the midpoint of a series of observed values. E.g., between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 = 6." -msgstr "中位數是一個數列中最中間的值。例如在 3、5、9 之間,中位數是 5。在 3、5、7、8 之間,中位數是 (5 + 7)/ 2 = 6。" +msgid "" +"The value lying at the midpoint of a series of observed values. E.g., " +"between 3, 5, 9, the median is 5. Between 3, 5, 7, 8, the median is (5+7)/2 =" +" 6." +msgstr "中位數是壹個數列中最中間的值。例如在 3、5、9 之間,中位數是 5。在 3、5、7、8 之間,中位數是 (5 + 7)/ 2 = 6。" + +msgid "" +"This means you can not push code until you create an empty repository or " +"import existing one." +msgstr "在創建壹個空的存儲庫或導入現有存儲庫之前,您將無法推送代碼。" msgid "Time before an issue gets scheduled" msgstr "議題被列入日程表的時間" @@ -255,11 +821,134 @@ msgid "Time before an issue starts implementation" msgstr "開始進行編碼前的時間" msgid "Time between merge request creation and merge/close" -msgstr "從創建合併請求到被合並或關閉的時間" +msgstr "從創建合併請求到被合併或關閉的時間" msgid "Time until first merge request" msgstr "創建第壹個合併請求之前的時間" +msgid "Timeago|%s days ago" +msgstr " %s 天前" + +msgid "Timeago|%s days remaining" +msgstr "剩餘 %s 天" + +msgid "Timeago|%s hours remaining" +msgstr "剩餘 %s 小時" + +msgid "Timeago|%s minutes ago" +msgstr " %s 分鐘前" + +msgid "Timeago|%s minutes remaining" +msgstr "剩餘 %s 分鐘" + +msgid "Timeago|%s months ago" +msgstr " %s 個月前" + +msgid "Timeago|%s months remaining" +msgstr "剩餘 %s 月" + +msgid "Timeago|%s seconds remaining" +msgstr "剩餘 %s 秒" + +msgid "Timeago|%s weeks ago" +msgstr " %s 星期前" + +msgid "Timeago|%s weeks remaining" +msgstr "剩餘 %s 星期" + +msgid "Timeago|%s years ago" +msgstr " %s 年前" + +msgid "Timeago|%s years remaining" +msgstr "剩餘 %s 年" + +msgid "Timeago|1 day remaining" +msgstr "剩餘 1 天" + +msgid "Timeago|1 hour remaining" +msgstr "剩餘 1 小時" + +msgid "Timeago|1 minute remaining" +msgstr "剩餘 1 分鐘" + +msgid "Timeago|1 month remaining" +msgstr "剩餘 1 個月" + +msgid "Timeago|1 week remaining" +msgstr "剩餘 1 星期" + +msgid "Timeago|1 year remaining" +msgstr "剩餘 1 年" + +msgid "Timeago|Past due" +msgstr "逾期" + +msgid "Timeago|a day ago" +msgstr " 1 天前" + +msgid "Timeago|a month ago" +msgstr " 1 個月前" + +msgid "Timeago|a week ago" +msgstr " 1 星期前" + +msgid "Timeago|a while" +msgstr " 剛剛" + +msgid "Timeago|a year ago" +msgstr " 1 年前" + +msgid "Timeago|about %s hours ago" +msgstr "約 %s 小時前" + +msgid "Timeago|about a minute ago" +msgstr "約 1 分鐘前" + +msgid "Timeago|about an hour ago" +msgstr "約 1 小時前" + +msgid "Timeago|in %s days" +msgstr " %s 天後" + +msgid "Timeago|in %s hours" +msgstr " %s 小時後" + +msgid "Timeago|in %s minutes" +msgstr " %s 分鐘後" + +msgid "Timeago|in %s months" +msgstr " %s 個月後" + +msgid "Timeago|in %s seconds" +msgstr " %s 秒後" + +msgid "Timeago|in %s weeks" +msgstr " %s 星期後" + +msgid "Timeago|in %s years" +msgstr " %s 年後" + +msgid "Timeago|in 1 day" +msgstr " 1 天後" + +msgid "Timeago|in 1 hour" +msgstr " 1 小時後" + +msgid "Timeago|in 1 minute" +msgstr " 1 分鐘後" + +msgid "Timeago|in 1 month" +msgstr " 1 月後" + +msgid "Timeago|in 1 week" +msgstr " 1 星期後" + +msgid "Timeago|in 1 year" +msgstr " 1 年後" + +msgid "Timeago|less than a minute ago" +msgstr "不到 1 分鐘前" + msgid "Time|hr" msgid_plural "Time|hrs" msgstr[0] "小時" @@ -277,18 +966,108 @@ msgstr "總時間" msgid "Total test time for all commits/merges" msgstr "所有提交和合併的總測試時間" +msgid "Unstar" +msgstr "取消星標" + +msgid "Upload New File" +msgstr "上傳新文件" + +msgid "Upload file" +msgstr "上傳文件" + +msgid "Use your global notification setting" +msgstr "使用全局通知設置" + +msgid "VisibilityLevel|Internal" +msgstr "內部" + +msgid "VisibilityLevel|Private" +msgstr "私有" + +msgid "VisibilityLevel|Public" +msgstr "公開" + msgid "Want to see the data? Please ask an administrator for access." msgstr "權限不足。如需查看相關數據,請向管理員申請權限。" msgid "We don't have enough data to show this stage." msgstr "該階段的數據不足,無法顯示。" +msgid "Withdraw Access Request" +msgstr "取消權限申请" + +msgid "" +"You are going to remove %{project_name_with_namespace}.\n" +"Removed project CANNOT be restored!\n" +"Are you ABSOLUTELY sure?" +msgstr "即將要刪除 %{project_name_with_namespace}。\n" +"已刪除的項目無法恢複!\n" +"確定繼續嗎?" + +msgid "" +"You are going to remove the fork relationship to source project " +"%{forked_from_project}. Are you ABSOLUTELY sure?" +msgstr "即將刪除與源項目 %{forked_from_project} 的派生關系。確定繼續嗎?" + +msgid "" +"You are going to transfer %{project_name_with_namespace} to another owner. " +"Are you ABSOLUTELY sure?" +msgstr "即將 %{project_name_with_namespace} 轉義給另壹個所有者。確定繼續嗎?" + +msgid "You can only add files when you are on a branch" +msgstr "只能在分支上添加文件" + msgid "You have reached your project limit" -msgstr "" +msgstr "您已達到項目數量限制" + +msgid "You must sign in to star a project" +msgstr "必須登錄才能對項目加星標" msgid "You need permission." -msgstr "您需要相關的權限。" +msgstr "需要相關的權限。" + +msgid "You will not get any notifications via email" +msgstr "不會收到任何通知郵件" + +msgid "You will only receive notifications for the events you choose" +msgstr "只接收您選擇的事件通知" + +msgid "" +"You will only receive notifications for threads you have participated in" +msgstr "只接收您參與的主題的通知" + +msgid "You will receive notifications for any activity" +msgstr "接收所有活動的通知" + +msgid "" +"You will receive notifications only for comments in which you were " +"@mentioned" +msgstr "只接收評論中提及(@)您的通知" + +msgid "" +"You won't be able to pull or push project code via %{protocol} until you " +"%{set_password_link} on your account" +msgstr "在賬號上 %{set_password_link} 之前將無法通過 %{protocol} 拉取或推送代碼。" + +msgid "" +"You won't be able to pull or push project code via SSH until you " +"%{add_ssh_key_link} to your profile" +msgstr "在賬號中 %{add_ssh_key_link} 之前將無法通過 SSH 拉取或推送代碼。" + +msgid "Your name" +msgstr "您的名字" msgid "day" msgid_plural "days" msgstr[0] "天" + +msgid "new merge request" +msgstr "新建合併請求" + +msgid "notification emails" +msgstr "通知郵件" + +msgid "parent" +msgid_plural "parents" +msgstr[0] "父級" + diff --git a/qa/Dockerfile b/qa/Dockerfile index 9e2a74ef991..f3a81a7e355 100644 --- a/qa/Dockerfile +++ b/qa/Dockerfile @@ -1,5 +1,6 @@ FROM ruby:2.3 LABEL maintainer "Grzegorz Bizon <grzegorz@gitlab.com>" +ENV DEBIAN_FRONTEND noninteractive ## # Update APT sources and install some dependencies @@ -8,25 +9,21 @@ RUN sed -i "s/httpredir.debian.org/ftp.us.debian.org/" /etc/apt/sources.list RUN apt-get update && apt-get install -y wget git unzip xvfb ## -# At this point Google Chrome Beta is 59 - first version with headless support +# Install Google Chrome version with headless support # -RUN wget -q https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb -RUN dpkg -i google-chrome-beta_current_amd64.deb; apt-get -fy install +RUN curl -sS -L https://dl.google.com/linux/linux_signing_key.pub | apt-key add - +RUN echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list +RUN apt-get update -q && apt-get install -y google-chrome-stable && apt-get clean ## # Install chromedriver to make it work with Selenium # -RUN wget -q https://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip +RUN wget -q https://chromedriver.storage.googleapis.com/$(wget -q -O - https://chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip RUN unzip chromedriver_linux64.zip -d /usr/local/bin -RUN apt-get clean - WORKDIR /home/qa - COPY ./Gemfile* ./ - RUN bundle install - COPY ./ ./ ENTRYPOINT ["bin/test"] diff --git a/qa/qa/specs/config.rb b/qa/qa/specs/config.rb index 78a93828d36..b341aa3094a 100644 --- a/qa/qa/specs/config.rb +++ b/qa/qa/specs/config.rb @@ -55,7 +55,7 @@ module QA Capybara.register_driver :chrome do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( 'chromeOptions' => { - 'binary' => '/opt/google/chrome-beta/google-chrome-beta', + 'binary' => '/usr/bin/google-chrome-stable', 'args' => %w[headless no-sandbox disable-gpu] } ) diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 7d6c317482f..69928a906c6 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -116,8 +116,8 @@ describe Admin::UsersController do it 'displays an alert' do go - expect(flash[:notice]). - to eq 'Two-factor Authentication has been disabled for this user' + expect(flash[:notice]) + .to eq 'Two-factor Authentication has been disabled for this user' end def go diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 3f99e2ff596..a2720c9b81e 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -99,6 +99,36 @@ describe ApplicationController do end end + describe 'response format' do + controller(described_class) do + def index + respond_to do |format| + format.json do + head :ok + end + end + end + end + + context 'when format is handled' do + let(:requested_format) { :json } + + it 'returns 200 response' do + get :index, private_token: user.private_token, format: requested_format + + expect(response).to have_http_status 200 + end + end + + context 'when format is not handled' do + it 'returns 404 response' do + get :index, private_token: user.private_token + + expect(response).to have_http_status 404 + end + end + end + describe '#authenticate_user_from_rss_token' do describe "authenticating a user from an RSS token" do controller(described_class) do diff --git a/spec/controllers/import/bitbucket_controller_spec.rb b/spec/controllers/import/bitbucket_controller_spec.rb index 0be7bc6a045..8ef10dabd4c 100644 --- a/spec/controllers/import/bitbucket_controller_spec.rb +++ b/spec/controllers/import/bitbucket_controller_spec.rb @@ -31,8 +31,8 @@ describe Import::BitbucketController do expires_at: expires_at, expires_in: expires_in, refresh_token: refresh_token) - allow_any_instance_of(OAuth2::Client). - to receive(:get_token).and_return(access_token) + allow_any_instance_of(OAuth2::Client) + .to receive(:get_token).and_return(access_token) stub_omniauth_provider('bitbucket') get :callback @@ -93,9 +93,9 @@ describe Import::BitbucketController do context "when the repository owner is the Bitbucket user" do context "when the Bitbucket user and GitLab user's usernames match" do it "takes the current user's namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params). - and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params) + .and_return(double(execute: true)) post :create, format: :js end @@ -105,9 +105,9 @@ describe Import::BitbucketController do let(:bitbucket_username) { "someone_else" } it "takes the current user's namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params). - and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params) + .and_return(double(execute: true)) post :create, format: :js end @@ -141,9 +141,9 @@ describe Import::BitbucketController do end it "takes the existing namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, bitbucket_repo.name, existing_namespace, user, access_params). - and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, existing_namespace, user, access_params) + .and_return(double(execute: true)) post :create, format: :js end @@ -151,8 +151,8 @@ describe Import::BitbucketController do context "when the namespace is not owned by the GitLab user" do it "doesn't create a project" do - expect(Gitlab::BitbucketImport::ProjectCreator). - not_to receive(:new) + expect(Gitlab::BitbucketImport::ProjectCreator) + .not_to receive(:new) post :create, format: :js end @@ -162,16 +162,16 @@ describe Import::BitbucketController do context "when a namespace with the Bitbucket user's username doesn't exist" do context "when current user can create namespaces" do it "creates the namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).and_return(double(execute: true)) expect { post :create, format: :js }.to change(Namespace, :count).by(1) end it "takes the new namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, bitbucket_repo.name, an_instance_of(Group), user, access_params). - and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, an_instance_of(Group), user, access_params) + .and_return(double(execute: true)) post :create, format: :js end @@ -183,16 +183,16 @@ describe Import::BitbucketController do end it "doesn't create the namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).and_return(double(execute: true)) expect { post :create, format: :js }.not_to change(Namespace, :count) end it "takes the current user's namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params). - and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params) + .and_return(double(execute: true)) post :create, format: :js end @@ -210,9 +210,9 @@ describe Import::BitbucketController do end it 'takes the selected namespace and name' do - expect(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, test_name, nested_namespace, user, access_params). - and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, test_name, nested_namespace, user, access_params) + .and_return(double(execute: true)) post :create, { target_namespace: nested_namespace.full_path, new_name: test_name, format: :js } end @@ -222,26 +222,26 @@ describe Import::BitbucketController do let(:test_name) { 'test_name' } it 'takes the selected namespace and name' do - expect(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params). - and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params) + .and_return(double(execute: true)) post :create, { target_namespace: 'foo/bar', new_name: test_name, format: :js } end it 'creates the namespaces' do - allow(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params). - and_return(double(execute: true)) + allow(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params) + .and_return(double(execute: true)) expect { post :create, { target_namespace: 'foo/bar', new_name: test_name, format: :js } } .to change { Namespace.count }.by(2) end it 'new namespace has the right parent' do - allow(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params). - and_return(double(execute: true)) + allow(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params) + .and_return(double(execute: true)) post :create, { target_namespace: 'foo/bar', new_name: test_name, format: :js } @@ -254,17 +254,17 @@ describe Import::BitbucketController do let!(:parent_namespace) { create(:group, name: 'foo', owner: user) } it 'takes the selected namespace and name' do - expect(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params). - and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params) + .and_return(double(execute: true)) post :create, { target_namespace: 'foo/foobar/bar', new_name: test_name, format: :js } end it 'creates the namespaces' do - allow(Gitlab::BitbucketImport::ProjectCreator). - to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params). - and_return(double(execute: true)) + allow(Gitlab::BitbucketImport::ProjectCreator) + .to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params) + .and_return(double(execute: true)) expect { post :create, { target_namespace: 'foo/foobar/bar', new_name: test_name, format: :js } } .to change { Namespace.count }.by(2) diff --git a/spec/controllers/import/github_controller_spec.rb b/spec/controllers/import/github_controller_spec.rb index 95696e14b6c..45c3fa075ef 100644 --- a/spec/controllers/import/github_controller_spec.rb +++ b/spec/controllers/import/github_controller_spec.rb @@ -21,10 +21,10 @@ describe Import::GithubController do describe "GET callback" do it "updates access token" do token = "asdasd12345" - allow_any_instance_of(Gitlab::GithubImport::Client). - to receive(:get_token).and_return(token) - allow_any_instance_of(Gitlab::GithubImport::Client). - to receive(:github_options).and_return({}) + allow_any_instance_of(Gitlab::GithubImport::Client) + .to receive(:get_token).and_return(token) + allow_any_instance_of(Gitlab::GithubImport::Client) + .to receive(:github_options).and_return({}) stub_omniauth_provider('github') get :callback diff --git a/spec/controllers/import/gitlab_controller_spec.rb b/spec/controllers/import/gitlab_controller_spec.rb index 3afd09063d7..997107dadea 100644 --- a/spec/controllers/import/gitlab_controller_spec.rb +++ b/spec/controllers/import/gitlab_controller_spec.rb @@ -18,8 +18,8 @@ describe Import::GitlabController do describe "GET callback" do it "updates access token" do - allow_any_instance_of(Gitlab::GitlabImport::Client). - to receive(:get_token).and_return(token) + allow_any_instance_of(Gitlab::GitlabImport::Client) + .to receive(:get_token).and_return(token) stub_omniauth_provider('gitlab') get :callback @@ -78,9 +78,9 @@ describe Import::GitlabController do context "when the repository owner is the GitLab.com user" do context "when the GitLab.com user and GitLab server user's usernames match" do it "takes the current user's namespace" do - expect(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, user.namespace, user, access_params). - and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, user.namespace, user, access_params) + .and_return(double(execute: true)) post :create, format: :js end @@ -90,9 +90,9 @@ describe Import::GitlabController do let(:gitlab_username) { "someone_else" } it "takes the current user's namespace" do - expect(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, user.namespace, user, access_params). - and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, user.namespace, user, access_params) + .and_return(double(execute: true)) post :create, format: :js end @@ -116,9 +116,9 @@ describe Import::GitlabController do end it "takes the existing namespace" do - expect(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, existing_namespace, user, access_params). - and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, existing_namespace, user, access_params) + .and_return(double(execute: true)) post :create, format: :js end @@ -126,8 +126,8 @@ describe Import::GitlabController do context "when the namespace is not owned by the GitLab server user" do it "doesn't create a project" do - expect(Gitlab::GitlabImport::ProjectCreator). - not_to receive(:new) + expect(Gitlab::GitlabImport::ProjectCreator) + .not_to receive(:new) post :create, format: :js end @@ -137,16 +137,16 @@ describe Import::GitlabController do context "when a namespace with the GitLab.com user's username doesn't exist" do context "when current user can create namespaces" do it "creates the namespace" do - expect(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).and_return(double(execute: true)) expect { post :create, format: :js }.to change(Namespace, :count).by(1) end it "takes the new namespace" do - expect(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, an_instance_of(Group), user, access_params). - and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, an_instance_of(Group), user, access_params) + .and_return(double(execute: true)) post :create, format: :js end @@ -158,16 +158,16 @@ describe Import::GitlabController do end it "doesn't create the namespace" do - expect(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).and_return(double(execute: true)) expect { post :create, format: :js }.not_to change(Namespace, :count) end it "takes the current user's namespace" do - expect(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, user.namespace, user, access_params). - and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, user.namespace, user, access_params) + .and_return(double(execute: true)) post :create, format: :js end @@ -183,9 +183,9 @@ describe Import::GitlabController do end it 'takes the selected namespace and name' do - expect(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, nested_namespace, user, access_params). - and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, nested_namespace, user, access_params) + .and_return(double(execute: true)) post :create, { target_namespace: nested_namespace.full_path, format: :js } end @@ -195,26 +195,26 @@ describe Import::GitlabController do let(:test_name) { 'test_name' } it 'takes the selected namespace and name' do - expect(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params). - and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params) + .and_return(double(execute: true)) post :create, { target_namespace: 'foo/bar', format: :js } end it 'creates the namespaces' do - allow(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params). - and_return(double(execute: true)) + allow(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params) + .and_return(double(execute: true)) expect { post :create, { target_namespace: 'foo/bar', format: :js } } .to change { Namespace.count }.by(2) end it 'new namespace has the right parent' do - allow(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params). - and_return(double(execute: true)) + allow(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params) + .and_return(double(execute: true)) post :create, { target_namespace: 'foo/bar', format: :js } @@ -227,17 +227,17 @@ describe Import::GitlabController do let!(:parent_namespace) { create(:group, name: 'foo', owner: user) } it 'takes the selected namespace and name' do - expect(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params). - and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params) + .and_return(double(execute: true)) post :create, { target_namespace: 'foo/foobar/bar', format: :js } end it 'creates the namespaces' do - allow(Gitlab::GitlabImport::ProjectCreator). - to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params). - and_return(double(execute: true)) + allow(Gitlab::GitlabImport::ProjectCreator) + .to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params) + .and_return(double(execute: true)) expect { post :create, { target_namespace: 'foo/foobar/bar', format: :js } } .to change { Namespace.count }.by(2) diff --git a/spec/controllers/profiles/preferences_controller_spec.rb b/spec/controllers/profiles/preferences_controller_spec.rb index 7b3aa0491c7..a5f544b4f92 100644 --- a/spec/controllers/profiles/preferences_controller_spec.rb +++ b/spec/controllers/profiles/preferences_controller_spec.rb @@ -43,7 +43,8 @@ describe Profiles::PreferencesController do dashboard: 'stars' }.with_indifferent_access - expect(user).to receive(:update_attributes).with(prefs) + expect(user).to receive(:assign_attributes).with(prefs) + expect(user).to receive(:save) go params: prefs end @@ -51,7 +52,7 @@ describe Profiles::PreferencesController do context 'on failed update' do it 'sets the flash' do - expect(user).to receive(:update_attributes).and_return(false) + expect(user).to receive(:save).and_return(false) go diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index 3b3caa9d3e6..c20cf6a4291 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -47,8 +47,8 @@ describe Projects::BlobController do context 'redirect to tree' do let(:id) { 'markdown/doc' } it 'redirects' do - expect(subject). - to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") + expect(subject) + .to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") end end end diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index f9e21f9d8f6..14426b09c73 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -32,8 +32,8 @@ describe Projects::BranchesController do let(:branch) { "merge_branch" } let(:ref) { "master" } it 'redirects' do - expect(subject). - to redirect_to("/#{project.path_with_namespace}/tree/merge_branch") + expect(subject) + .to redirect_to("/#{project.path_with_namespace}/tree/merge_branch") end end @@ -41,8 +41,8 @@ describe Projects::BranchesController do let(:branch) { "<script>alert('merge');</script>" } let(:ref) { "master" } it 'redirects' do - expect(subject). - to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');") + expect(subject) + .to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');") end end @@ -81,8 +81,8 @@ describe Projects::BranchesController do branch_name: branch, issue_iid: issue.iid - expect(subject). - to redirect_to("/#{project.path_with_namespace}/tree/1-feature-branch") + expect(subject) + .to redirect_to("/#{project.path_with_namespace}/tree/1-feature-branch") end it 'posts a system note' do diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index 7fb08df1950..e10da40eaab 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -66,8 +66,8 @@ describe Projects::CommitController do end it "does not escape Html" do - allow_any_instance_of(Commit).to receive(:"to_#{format}"). - and_return('HTML entities &<>" ') + allow_any_instance_of(Commit).to receive(:"to_#{format}") + .and_return('HTML entities &<>" ') go(id: commit.id, format: format) diff --git a/spec/controllers/projects/deployments_controller_spec.rb b/spec/controllers/projects/deployments_controller_spec.rb index 4c69443314d..0dbfcf97f6f 100644 --- a/spec/controllers/projects/deployments_controller_spec.rb +++ b/spec/controllers/projects/deployments_controller_spec.rb @@ -42,6 +42,7 @@ describe Projects::DeploymentsController do before do allow(controller).to receive(:deployment).and_return(deployment) end + context 'when metrics are disabled' do before do allow(deployment).to receive(:has_metrics?).and_return false @@ -108,6 +109,69 @@ describe Projects::DeploymentsController do end end + describe 'GET #additional_metrics' do + let(:deployment) { create(:deployment, project: project, environment: environment) } + + before do + allow(controller).to receive(:deployment).and_return(deployment) + end + + context 'when metrics are disabled' do + before do + allow(deployment).to receive(:has_metrics?).and_return false + end + + it 'responds with not found' do + get :metrics, deployment_params(id: deployment.id) + + expect(response).to be_not_found + end + end + + context 'when metrics are enabled' do + let(:prometheus_service) { double('prometheus_service') } + + before do + allow(deployment.project).to receive(:prometheus_service).and_return(prometheus_service) + end + + context 'when environment has no metrics' do + before do + expect(deployment).to receive(:additional_metrics).and_return({}) + end + + it 'returns a empty response 204 response' do + get :additional_metrics, deployment_params(id: deployment.id, format: :json) + expect(response).to have_http_status(204) + expect(response.body).to eq('') + end + end + + context 'when environment has some metrics' do + let(:empty_metrics) do + { + success: true, + metrics: {}, + last_update: 42 + } + end + + before do + expect(deployment).to receive(:additional_metrics).and_return(empty_metrics) + end + + it 'returns a metrics JSON document' do + get :additional_metrics, deployment_params(id: deployment.id, format: :json) + + expect(response).to be_ok + expect(json_response['success']).to be(true) + expect(json_response['metrics']).to eq({}) + expect(json_response['last_update']).to eq(42) + end + end + end + end + def deployment_params(opts = {}) opts.reverse_merge(namespace_id: project.namespace, project_id: project, diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index f6840578145..ad0b046742d 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -58,9 +58,11 @@ describe Projects::EnvironmentsController do expect(json_response['stopped_count']).to eq 1 end - it 'sets the polling interval header' do + it 'does not set the polling interval header' do + # TODO, this is a temporary fix, see follow up issue: + # https://gitlab.com/gitlab-org/gitlab-ee/issues/2677 expect(response).to have_http_status(:ok) - expect(response.headers['Poll-Interval']).to eq("3000") + expect(response.headers['Poll-Interval']).to be_nil end end @@ -233,14 +235,14 @@ describe Projects::EnvironmentsController do context 'and valid id' do it 'returns the first terminal for the environment' do - expect_any_instance_of(Environment). - to receive(:terminals). - and_return([:fake_terminal]) + expect_any_instance_of(Environment) + .to receive(:terminals) + .and_return([:fake_terminal]) - expect(Gitlab::Workhorse). - to receive(:terminal_websocket). - with(:fake_terminal). - and_return(workhorse: :response) + expect(Gitlab::Workhorse) + .to receive(:terminal_websocket) + .with(:fake_terminal) + .and_return(workhorse: :response) get :terminal_websocket_authorize, environment_params @@ -316,6 +318,48 @@ describe Projects::EnvironmentsController do end end + describe 'GET #additional_metrics' do + before do + allow(controller).to receive(:environment).and_return(environment) + end + + context 'when environment has no metrics' do + before do + expect(environment).to receive(:additional_metrics).and_return(nil) + end + + context 'when requesting metrics as JSON' do + it 'returns a metrics JSON document' do + get :additional_metrics, environment_params(format: :json) + + expect(response).to have_http_status(204) + expect(json_response).to eq({}) + end + end + end + + context 'when environment has some metrics' do + before do + expect(environment) + .to receive(:additional_metrics) + .and_return({ + success: true, + data: {}, + last_update: 42 + }) + end + + it 'returns a metrics JSON document' do + get :additional_metrics, environment_params(format: :json) + + expect(response).to be_ok + expect(json_response['success']).to be(true) + expect(json_response['data']).to eq({}) + expect(json_response['last_update']).to eq(42) + end + end + end + def environment_params(opts = {}) opts.reverse_merge(namespace_id: project.namespace, project_id: project, diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index eed3c3a9098..9f98427a86b 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -328,8 +328,8 @@ describe Projects::IssuesController do it 'redirect to issue page' do update_verified_issue - expect(response). - to redirect_to(namespace_project_issue_path(project.namespace, project, issue)) + expect(response) + .to redirect_to(namespace_project_issue_path(project.namespace, project, issue)) end it 'accepts an issue after recaptcha is verified' do @@ -343,8 +343,8 @@ describe Projects::IssuesController do it 'does not mark spam log as recaptcha_verified when it does not belong to current_user' do spam_log = create(:spam_log) - expect { update_issue(spam_log_id: spam_log.id, recaptcha_verification: true) }. - not_to change { SpamLog.last.recaptcha_verified } + expect { update_issue(spam_log_id: spam_log.id, recaptcha_verification: true) } + .not_to change { SpamLog.last.recaptcha_verified } end end end @@ -685,8 +685,8 @@ describe Projects::IssuesController do it 'does not mark spam log as recaptcha_verified when it does not belong to current_user' do spam_log = create(:spam_log) - expect { post_new_issue({}, { spam_log_id: spam_log.id, recaptcha_verification: true } ) }. - not_to change { SpamLog.last.recaptcha_verified } + expect { post_new_issue({}, { spam_log_id: spam_log.id, recaptcha_verification: true } ) } + .not_to change { SpamLog.last.recaptcha_verified } end end end diff --git a/spec/controllers/projects/mattermosts_controller_spec.rb b/spec/controllers/projects/mattermosts_controller_spec.rb index c5abf11cfa5..422a8b6fac0 100644 --- a/spec/controllers/projects/mattermosts_controller_spec.rb +++ b/spec/controllers/projects/mattermosts_controller_spec.rb @@ -11,8 +11,8 @@ describe Projects::MattermostsController do describe 'GET #new' do before do - allow_any_instance_of(MattermostSlashCommandsService). - to receive(:list_teams).and_return([]) + allow_any_instance_of(MattermostSlashCommandsService) + .to receive(:list_teams).and_return([]) end it 'accepts the request' do diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index d8a3a510f97..6817c2652fd 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -783,8 +783,8 @@ describe Projects::MergeRequestsController do describe 'GET conflicts' do context 'when the conflicts cannot be resolved in the UI' do before do - allow_any_instance_of(Gitlab::Conflict::Parser). - to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile) + allow_any_instance_of(Gitlab::Conflict::Parser) + .to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile) get :conflicts, namespace_id: merge_request_with_conflicts.project.namespace.to_param, @@ -926,8 +926,8 @@ describe Projects::MergeRequestsController do context 'when the conflicts cannot be resolved in the UI' do before do - allow_any_instance_of(Gitlab::Conflict::Parser). - to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile) + allow_any_instance_of(Gitlab::Conflict::Parser) + .to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile) conflict_for_path('files/ruby/regex.rb') end @@ -959,9 +959,9 @@ describe Projects::MergeRequestsController do end it 'returns the file in JSON format' do - content = MergeRequests::Conflicts::ListService.new(merge_request_with_conflicts). - file_for_path(path, path). - content + content = MergeRequests::Conflicts::ListService.new(merge_request_with_conflicts) + .file_for_path(path, path) + .content expect(json_response).to include('old_path' => path, 'new_path' => path, @@ -1085,9 +1085,9 @@ describe Projects::MergeRequestsController do context 'when a file has identical content to the conflict' do before do - content = MergeRequests::Conflicts::ListService.new(merge_request_with_conflicts). - file_for_path('files/ruby/popen.rb', 'files/ruby/popen.rb'). - content + content = MergeRequests::Conflicts::ListService.new(merge_request_with_conflicts) + .file_for_path('files/ruby/popen.rb', 'files/ruby/popen.rb') + .content resolved_files = [ { @@ -1153,9 +1153,9 @@ describe Projects::MergeRequestsController do end it 'calls MergeRequests::AssignIssuesService' do - expect(MergeRequests::AssignIssuesService).to receive(:new). - with(project, user, merge_request: merge_request). - and_return(double(execute: { count: 1 })) + expect(MergeRequests::AssignIssuesService).to receive(:new) + .with(project, user, merge_request: merge_request) + .and_return(double(execute: { count: 1 })) post_assign_issues end diff --git a/spec/controllers/projects/prometheus_controller_spec.rb b/spec/controllers/projects/prometheus_controller_spec.rb new file mode 100644 index 00000000000..eddf7275975 --- /dev/null +++ b/spec/controllers/projects/prometheus_controller_spec.rb @@ -0,0 +1,59 @@ +require('spec_helper') + +describe Projects::PrometheusController do + let(:user) { create(:user) } + let!(:project) { create(:empty_project) } + + let(:prometheus_service) { double('prometheus_service') } + + before do + allow(controller).to receive(:project).and_return(project) + allow(project).to receive(:prometheus_service).and_return(prometheus_service) + + project.add_master(user) + sign_in(user) + end + + describe 'GET #active_metrics' do + context 'when prometheus metrics are enabled' do + context 'when data is not present' do + before do + allow(prometheus_service).to receive(:matched_metrics).and_return({}) + end + + it 'returns no content response' do + get :active_metrics, project_params(format: :json) + + expect(response).to have_http_status(204) + end + end + + context 'when data is available' do + let(:sample_response) { { some_data: 1 } } + + before do + allow(prometheus_service).to receive(:matched_metrics).and_return(sample_response) + end + + it 'returns no content response' do + get :active_metrics, project_params(format: :json) + + expect(response).to have_http_status(200) + expect(json_response).to eq(sample_response.deep_stringify_keys) + end + end + + context 'when requesting non json response' do + it 'returns not found response' do + get :active_metrics, project_params + + expect(response).to have_http_status(404) + end + end + end + end + + def project_params(opts = {}) + opts.reverse_merge(namespace_id: project.namespace, project_id: project) + end +end diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb index 952071af57f..b4eaab29fed 100644 --- a/spec/controllers/projects/raw_controller_spec.rb +++ b/spec/controllers/projects/raw_controller_spec.rb @@ -15,8 +15,8 @@ describe Projects::RawController do expect(response).to have_http_status(200) expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8') - expect(response.header['Content-Disposition']). - to eq('inline') + expect(response.header['Content-Disposition']) + .to eq('inline') expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:') end end @@ -88,8 +88,8 @@ describe Projects::RawController do expect(response).to have_http_status(200) expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8') - expect(response.header['Content-Disposition']). - to eq('inline') + expect(response.header['Content-Disposition']) + .to eq('inline') expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:') end end diff --git a/spec/controllers/projects/services_controller_spec.rb b/spec/controllers/projects/services_controller_spec.rb index 23b463c0082..4dc227a36d4 100644 --- a/spec/controllers/projects/services_controller_spec.rb +++ b/spec/controllers/projects/services_controller_spec.rb @@ -67,8 +67,8 @@ describe Projects::ServicesController do put :test, namespace_id: project.namespace.id, project_id: project.id, id: service.id, service: service_params expect(response.status).to eq(200) - expect(JSON.parse(response.body)). - to eq('error' => true, 'message' => 'Test failed.', 'service_response' => 'Bad test') + expect(JSON.parse(response.body)) + .to eq('error' => true, 'message' => 'Test failed.', 'service_response' => 'Bad test') end end end diff --git a/spec/controllers/projects/snippets_controller_spec.rb b/spec/controllers/projects/snippets_controller_spec.rb index 2434f822c6f..ec0b7f8c967 100644 --- a/spec/controllers/projects/snippets_controller_spec.rb +++ b/spec/controllers/projects/snippets_controller_spec.rb @@ -103,21 +103,21 @@ describe Projects::SnippetsController do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(project, visibility_level: Snippet::PRIVATE) }. - to change { Snippet.count }.by(1) + expect { create_snippet(project, visibility_level: Snippet::PRIVATE) } + .to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the shippet' do - expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }. - not_to change { Snippet.count } + expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } + .not_to change { Snippet.count } expect(response).to render_template(:new) end it 'creates a spam log' do - expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }. - to change { SpamLog.count }.by(1) + expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } + .to change { SpamLog.count }.by(1) end it 'renders :new with recaptcha disabled' do @@ -183,8 +183,8 @@ describe Projects::SnippetsController do let(:visibility_level) { Snippet::PRIVATE } it 'updates the snippet' do - expect { update_snippet(title: 'Foo') }. - to change { snippet.reload.title }.to('Foo') + expect { update_snippet(title: 'Foo') } + .to change { snippet.reload.title }.to('Foo') end end @@ -192,13 +192,13 @@ describe Projects::SnippetsController do let(:visibility_level) { Snippet::PUBLIC } it 'rejects the shippet' do - expect { update_snippet(title: 'Foo') }. - not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo') } + .not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo') }. - to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo') } + .to change { SpamLog.count }.by(1) end it 'renders :edit with recaptcha disabled' do @@ -237,13 +237,13 @@ describe Projects::SnippetsController do let(:visibility_level) { Snippet::PRIVATE } it 'rejects the shippet' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. - not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } + .not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. - to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } + .to change { SpamLog.count }.by(1) end it 'renders :edit with recaptcha disabled' do diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb index a43dad5756d..16cd2e076e5 100644 --- a/spec/controllers/projects/tree_controller_spec.rb +++ b/spec/controllers/projects/tree_controller_spec.rb @@ -82,8 +82,8 @@ describe Projects::TreeController do let(:id) { 'master/README.md' } it 'redirects' do redirect_url = "/#{project.path_with_namespace}/blob/master/README.md" - expect(subject). - to redirect_to(redirect_url) + expect(subject) + .to redirect_to(redirect_url) end end end @@ -106,8 +106,8 @@ describe Projects::TreeController do let(:branch_name) { 'master-test'} it 'redirects to the new directory' do - expect(subject). - to redirect_to("/#{project.path_with_namespace}/tree/#{branch_name}/#{path}") + expect(subject) + .to redirect_to("/#{project.path_with_namespace}/tree/#{branch_name}/#{path}") expect(flash[:notice]).to eq('The directory has been successfully created.') end end @@ -117,8 +117,8 @@ describe Projects::TreeController do let(:branch_name) { 'master'} it 'does not allow overwriting of existing files' do - expect(subject). - to redirect_to("/#{project.path_with_namespace}/tree/master") + expect(subject) + .to redirect_to("/#{project.path_with_namespace}/tree/master") expect(flash[:alert]).to eq('A file with this name already exists') end end diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb index 0cc8a3b68eb..917bd44c91b 100644 --- a/spec/controllers/sent_notifications_controller_spec.rb +++ b/spec/controllers/sent_notifications_controller_spec.rb @@ -87,8 +87,8 @@ describe SentNotificationsController, type: :controller do end it 'redirects to the issue page' do - expect(response). - to redirect_to(namespace_project_issue_path(project.namespace, project, issue)) + expect(response) + .to redirect_to(namespace_project_issue_path(project.namespace, project, issue)) end end @@ -113,8 +113,8 @@ describe SentNotificationsController, type: :controller do end it 'redirects to the merge request page' do - expect(response). - to redirect_to(namespace_project_merge_request_path(project.namespace, project, merge_request)) + expect(response) + .to redirect_to(namespace_project_merge_request_path(project.namespace, project, merge_request)) end end end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 03f4b0ba343..bf922260b2f 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -9,8 +9,8 @@ describe SessionsController do context 'when auto sign-in is enabled' do before do stub_omniauth_setting(auto_sign_in_with_provider: :saml) - allow(controller).to receive(:omniauth_authorize_path).with(:user, :saml). - and_return('/saml') + allow(controller).to receive(:omniauth_authorize_path).with(:user, :saml) + .and_return('/saml') end context 'and no auto_sign_in param is passed' do @@ -89,8 +89,8 @@ describe SessionsController do context 'remember_me field' do it 'sets a remember_user_token cookie when enabled' do allow(controller).to receive(:find_user).and_return(user) - expect(controller). - to receive(:remember_me).with(user).and_call_original + expect(controller) + .to receive(:remember_me).with(user).and_call_original authenticate_2fa(remember_me: '1', otp_attempt: user.current_otp) @@ -228,8 +228,8 @@ describe SessionsController do it 'sets a remember_user_token cookie when enabled' do allow(U2fRegistration).to receive(:authenticate).and_return(true) allow(controller).to receive(:find_user).and_return(user) - expect(controller). - to receive(:remember_me).with(user).and_call_original + expect(controller) + .to receive(:remember_me).with(user).and_call_original authenticate_2fa_u2f(remember_me: '1', login: user.username, device_response: "{}") @@ -262,8 +262,8 @@ describe SessionsController do it 'redirects correctly for referer on same host with params' do search_path = '/search?search=seed_project' - allow(controller.request).to receive(:referer). - and_return('http://%{host}%{path}' % { host: Gitlab.config.gitlab.host, path: search_path }) + allow(controller.request).to receive(:referer) + .and_return('http://%{host}%{path}' % { host: Gitlab.config.gitlab.host, path: search_path }) get(:new, redirect_to_referer: :yes) diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index b1339b2a185..430d1208cd1 100644 --- a/spec/controllers/snippets_controller_spec.rb +++ b/spec/controllers/snippets_controller_spec.rb @@ -222,20 +222,20 @@ describe SnippetsController do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(visibility_level: Snippet::PRIVATE) }. - to change { Snippet.count }.by(1) + expect { create_snippet(visibility_level: Snippet::PRIVATE) } + .to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the shippet' do - expect { create_snippet(visibility_level: Snippet::PUBLIC) }. - not_to change { Snippet.count } + expect { create_snippet(visibility_level: Snippet::PUBLIC) } + .not_to change { Snippet.count } end it 'creates a spam log' do - expect { create_snippet(visibility_level: Snippet::PUBLIC) }. - to change { SpamLog.count }.by(1) + expect { create_snippet(visibility_level: Snippet::PUBLIC) } + .to change { SpamLog.count }.by(1) end it 'renders :new with recaptcha disabled' do @@ -296,8 +296,8 @@ describe SnippetsController do let(:visibility_level) { Snippet::PRIVATE } it 'updates the snippet' do - expect { update_snippet(title: 'Foo') }. - to change { snippet.reload.title }.to('Foo') + expect { update_snippet(title: 'Foo') } + .to change { snippet.reload.title }.to('Foo') end end @@ -305,13 +305,13 @@ describe SnippetsController do let(:visibility_level) { Snippet::PRIVATE } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. - not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } + .not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. - to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } + .to change { SpamLog.count }.by(1) end it 'renders :edit with recaptcha disabled' do @@ -350,13 +350,13 @@ describe SnippetsController do let(:visibility_level) { Snippet::PUBLIC } it 'rejects the shippet' do - expect { update_snippet(title: 'Foo') }. - not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo') } + .not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo') }. - to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo') } + .to change { SpamLog.count }.by(1) end it 'renders :edit with recaptcha disabled' do diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index e17e50db143..aef1c17a239 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -118,8 +118,8 @@ FactoryGirl.define do builds_access_level = [evaluator.builds_access_level, evaluator.repository_access_level].min merge_requests_access_level = [evaluator.merge_requests_access_level, evaluator.repository_access_level].min - project.project_feature. - update_attributes!( + project.project_feature + .update_attributes!( wiki_access_level: evaluator.wiki_access_level, builds_access_level: builds_access_level, snippets_access_level: evaluator.snippets_access_level, diff --git a/spec/factories/services.rb b/spec/factories/services.rb index e7366a7fd1c..30bc25cf88a 100644 --- a/spec/factories/services.rb +++ b/spec/factories/services.rb @@ -25,6 +25,14 @@ FactoryGirl.define do }) end + factory :prometheus_service do + project factory: :empty_project + active true + properties({ + api_url: 'https://prometheus.example.com/' + }) + end + factory :jira_service do project factory: :empty_project active true diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb index ad8f1d496f2..a4ce3e1d5ee 100644 --- a/spec/features/admin/admin_projects_spec.rb +++ b/spec/features/admin/admin_projects_spec.rb @@ -57,8 +57,8 @@ describe "Admin::Projects", feature: true do before do create(:group, name: 'Web') - allow_any_instance_of(Projects::TransferService). - to receive(:move_uploads_to_new_namespace).and_return(true) + allow_any_instance_of(Projects::TransferService) + .to receive(:move_uploads_to_new_namespace).and_return(true) end it 'transfers project to group web', js: true do diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index 5b3323fed13..6ad2d456b93 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -9,31 +9,54 @@ describe "Admin Runners" do end describe "Runners page" do - before do - runner = FactoryGirl.create(:ci_runner, contacted_at: Time.now) - pipeline = FactoryGirl.create(:ci_pipeline) - FactoryGirl.create(:ci_build, pipeline: pipeline, runner_id: runner.id) - visit admin_runners_path - end + let(:pipeline) { create(:ci_pipeline) } + + context "when there are runners" do + before do + runner = FactoryGirl.create(:ci_runner, contacted_at: Time.now) + FactoryGirl.create(:ci_build, pipeline: pipeline, runner_id: runner.id) + visit admin_runners_path + end + + it 'has all necessary texts' do + expect(page).to have_text "To register a new Runner" + expect(page).to have_text "Runners with last contact more than a minute ago: 1" + end + + describe 'search' do + before do + FactoryGirl.create :ci_runner, description: 'runner-foo' + FactoryGirl.create :ci_runner, description: 'runner-bar' + end + + it 'shows correct runner when description matches' do + search_form = find('#runners-search') + search_form.fill_in 'search', with: 'runner-foo' + search_form.click_button 'Search' + + expect(page).to have_content("runner-foo") + expect(page).not_to have_content("runner-bar") + end + + it 'shows no runner when description does not match' do + search_form = find('#runners-search') + search_form.fill_in 'search', with: 'runner-baz' + search_form.click_button 'Search' - it 'has all necessary texts' do - expect(page).to have_text "To register a new Runner" - expect(page).to have_text "Runners with last contact more than a minute ago: 1" + expect(page).to have_text 'No runners found' + end + end end - describe 'search' do + context "when there are no runners" do before do - FactoryGirl.create :ci_runner, description: 'runner-foo' - FactoryGirl.create :ci_runner, description: 'runner-bar' - - search_form = find('#runners-search') - search_form.fill_in 'search', with: 'runner-foo' - search_form.click_button 'Search' + visit admin_runners_path end - it 'shows correct runner' do - expect(page).to have_content("runner-foo") - expect(page).not_to have_content("runner-bar") + it 'has all necessary texts including no runner message' do + expect(page).to have_text "To register a new Runner" + expect(page).to have_text "Runners with last contact more than a minute ago: 0" + expect(page).to have_text 'No runners found' end end end diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 2d5f0987ea2..6dbc697642f 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -78,10 +78,10 @@ describe "Admin::Users", feature: true do it "applies defaults to user" do click_button "Create user" user = User.find_by(username: 'bang') - expect(user.projects_limit). - to eq(Gitlab.config.gitlab.default_projects_limit) - expect(user.can_create_group). - to eq(Gitlab.config.gitlab.default_can_create_group) + expect(user.projects_limit) + .to eq(Gitlab.config.gitlab.default_projects_limit) + expect(user.can_create_group) + .to eq(Gitlab.config.gitlab.default_can_create_group) end it "creates user with valid data" do diff --git a/spec/features/atom/dashboard_spec.rb b/spec/features/atom/dashboard_spec.rb index 1df058b023c..2f4bb45d74b 100644 --- a/spec/features/atom/dashboard_spec.rb +++ b/spec/features/atom/dashboard_spec.rb @@ -35,8 +35,8 @@ describe "Dashboard Feed", feature: true do end it "has issue comment event" do - expect(body). - to have_content("#{user.name} commented on issue ##{issue.iid}") + expect(body) + .to have_content("#{user.name} commented on issue ##{issue.iid}") end end end diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb index c8ef4533b98..b94ad973fed 100644 --- a/spec/features/atom/issues_spec.rb +++ b/spec/features/atom/issues_spec.rb @@ -18,8 +18,8 @@ describe 'Issues Feed', feature: true do gitlab_sign_in user visit namespace_project_issues_path(project.namespace, project, :atom) - expect(response_headers['Content-Type']). - to have_content('application/atom+xml') + expect(response_headers['Content-Type']) + .to have_content('application/atom+xml') expect(body).to have_selector('title', text: "#{project.name} issues") expect(body).to have_selector('author email', text: issue.author_public_email) expect(body).to have_selector('assignees assignee email', text: issue.assignees.first.public_email) @@ -33,8 +33,8 @@ describe 'Issues Feed', feature: true do visit namespace_project_issues_path(project.namespace, project, :atom, private_token: user.private_token) - expect(response_headers['Content-Type']). - to have_content('application/atom+xml') + expect(response_headers['Content-Type']) + .to have_content('application/atom+xml') expect(body).to have_selector('title', text: "#{project.name} issues") expect(body).to have_selector('author email', text: issue.author_public_email) expect(body).to have_selector('assignees assignee email', text: issue.assignees.first.public_email) @@ -48,8 +48,8 @@ describe 'Issues Feed', feature: true do visit namespace_project_issues_path(project.namespace, project, :atom, rss_token: user.rss_token) - expect(response_headers['Content-Type']). - to have_content('application/atom+xml') + expect(response_headers['Content-Type']) + .to have_content('application/atom+xml') expect(body).to have_selector('title', text: "#{project.name} issues") expect(body).to have_selector('author email', text: issue.author_public_email) expect(body).to have_selector('assignees assignee email', text: issue.assignees.first.public_email) diff --git a/spec/features/atom/users_spec.rb b/spec/features/atom/users_spec.rb index fae5aaa52bd..44ae7204bcf 100644 --- a/spec/features/atom/users_spec.rb +++ b/spec/features/atom/users_spec.rb @@ -55,8 +55,8 @@ describe "User Feed", feature: true do end it 'has issue comment event' do - expect(body). - to have_content("#{safe_name} commented on issue ##{issue.iid}") + expect(body) + .to have_content("#{safe_name} commented on issue ##{issue.iid}") end it 'has XHTML summaries in issue descriptions' do diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index 6f21cfd322d..a57962abbda 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -59,6 +59,11 @@ RSpec.describe 'Dashboard Issues', feature: true do expect(page).to have_content(other_issue.title) end + it 'state filter tabs work' do + find('#state-closed').click + expect(page).to have_current_path(issues_dashboard_url(assignee_id: current_user.id, scope: 'all', state: 'closed'), url: true) + end + it_behaves_like "it has an RSS button with current_user's RSS token" it_behaves_like "an autodiscoverable RSS feed with current_user's RSS token" end diff --git a/spec/features/dashboard/merge_requests_spec.rb b/spec/features/dashboard/merge_requests_spec.rb index 69d5500848e..bb1fb5b3feb 100644 --- a/spec/features/dashboard/merge_requests_spec.rb +++ b/spec/features/dashboard/merge_requests_spec.rb @@ -1,18 +1,24 @@ require 'spec_helper' -describe 'Dashboard Merge Requests' do +feature 'Dashboard Merge Requests' do + include FilterItemSelectHelper + let(:current_user) { create :user } let(:project) { create(:empty_project) } - let(:project_with_merge_requests_disabled) { create(:empty_project, :merge_requests_disabled) } - before do - [project, project_with_merge_requests_disabled].each { |project| project.team << [current_user, :master] } + let(:public_project) { create(:empty_project, :public, :repository) } + let(:forked_project) { Projects::ForkService.new(public_project, current_user).execute } - gitlab_sign_in(current_user) + before do + project.add_master(current_user) + sign_in(current_user) end - describe 'new merge request dropdown' do + context 'new merge request dropdown' do + let(:project_with_disabled_merge_requests) { create(:empty_project, :merge_requests_disabled) } + before do + project_with_disabled_merge_requests.add_master(current_user) visit merge_requests_dashboard_path end @@ -21,26 +27,87 @@ describe 'Dashboard Merge Requests' do page.within('.select2-results') do expect(page).to have_content(project.name_with_namespace) - expect(page).not_to have_content(project_with_merge_requests_disabled.name_with_namespace) + expect(page).not_to have_content(project_with_disabled_merge_requests.name_with_namespace) end end end - it 'should show an empty state' do - visit merge_requests_dashboard_path(assignee_id: current_user.id) + context 'no merge requests exist' do + it 'shows an empty state' do + visit merge_requests_dashboard_path(assignee_id: current_user.id) - expect(page).to have_selector('.empty-state') + expect(page).to have_selector('.empty-state') + end end - context 'if there are merge requests' do - before do - create(:merge_request, assignee: current_user, source_project: project) + context 'merge requests exist' do + let!(:assigned_merge_request) do + create(:merge_request, assignee: current_user, target_project: project, source_project: project) + end + + let!(:assigned_merge_request_from_fork) do + create(:merge_request, + source_branch: 'markdown', assignee: current_user, + target_project: public_project, source_project: forked_project + ) + end + let!(:authored_merge_request) do + create(:merge_request, + source_branch: 'markdown', author: current_user, + target_project: project, source_project: project + ) + end + + let!(:authored_merge_request_from_fork) do + create(:merge_request, + source_branch: 'feature_conflict', + author: current_user, + target_project: public_project, source_project: forked_project + ) + end + + let!(:other_merge_request) do + create(:merge_request, + source_branch: 'fix', + target_project: project, source_project: project + ) + end + + before do visit merge_requests_dashboard_path(assignee_id: current_user.id) end - it 'should not show an empty state' do - expect(page).not_to have_selector('.empty-state') + it 'shows assigned merge requests' do + expect(page).to have_content(assigned_merge_request.title) + expect(page).to have_content(assigned_merge_request_from_fork.title) + + expect(page).not_to have_content(authored_merge_request.title) + expect(page).not_to have_content(authored_merge_request_from_fork.title) + expect(page).not_to have_content(other_merge_request.title) + end + + it 'shows authored merge requests', js: true do + filter_item_select('Any Assignee', '.js-assignee-search') + filter_item_select(current_user.to_reference, '.js-author-search') + + expect(page).to have_content(authored_merge_request.title) + expect(page).to have_content(authored_merge_request_from_fork.title) + + expect(page).not_to have_content(assigned_merge_request.title) + expect(page).not_to have_content(assigned_merge_request_from_fork.title) + expect(page).not_to have_content(other_merge_request.title) + end + + it 'shows all merge requests', js: true do + filter_item_select('Any Assignee', '.js-assignee-search') + filter_item_select('Any Author', '.js-author-search') + + expect(page).to have_content(authored_merge_request.title) + expect(page).to have_content(authored_merge_request_from_fork.title) + expect(page).to have_content(assigned_merge_request.title) + expect(page).to have_content(assigned_merge_request_from_fork.title) + expect(page).to have_content(other_merge_request.title) end end end diff --git a/spec/features/dashboard/milestone_filter_spec.rb b/spec/features/dashboard/milestone_filter_spec.rb index 295262980a6..b0e4036f27c 100644 --- a/spec/features/dashboard/milestone_filter_spec.rb +++ b/spec/features/dashboard/milestone_filter_spec.rb @@ -1,10 +1,12 @@ require 'spec_helper' -describe 'Dashboard > milestone filter', :feature, :js do +feature 'Dashboard > milestone filter', :feature, :js do + include FilterItemSelectHelper + let(:user) { create(:user) } let(:project) { create(:project, name: 'test', namespace: user.namespace) } - let(:milestone) { create(:milestone, title: "v1.0", project: project) } - let(:milestone2) { create(:milestone, title: "v2.0", project: project) } + let(:milestone) { create(:milestone, title: 'v1.0', project: project) } + let(:milestone2) { create(:milestone, title: 'v2.0', project: project) } let!(:issue) { create :issue, author: user, project: project, milestone: milestone } let!(:issue2) { create :issue, author: user, project: project, milestone: milestone2 } @@ -22,17 +24,11 @@ describe 'Dashboard > milestone filter', :feature, :js do end context 'filtering by milestone' do - milestone_select = '.js-milestone-select' + milestone_select_selector = '.js-milestone-select' before do - find(milestone_select).click - wait_for_requests - - page.within('.dropdown-content') do - click_link 'v1.0' - end - - find(milestone_select).click + filter_item_select('v1.0', milestone_select_selector) + find(milestone_select_selector).click wait_for_requests end @@ -49,7 +45,7 @@ describe 'Dashboard > milestone filter', :feature, :js do expect(find('.milestone-filter')).not_to have_selector('.dropdown.open') - find(milestone_select).click + find(milestone_select_selector).click expect(find('.dropdown-content')).to have_selector('a.is-active', count: 1) expect(find('.dropdown-content a.is-active')).to have_content('v1.0') diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 2a8185ca669..f29186f368d 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -15,13 +15,25 @@ RSpec.describe 'Dashboard Projects', feature: true do expect(page).to have_content('awesome stuff') end - it 'shows the last_activity_at attribute as the update date' do - now = Time.now - project.update_column(:last_activity_at, now) + context 'when last_repository_updated_at, last_activity_at and update_at are present' do + it 'shows the last_repository_updated_at attribute as the update date' do + project.update_attributes!(last_repository_updated_at: Time.now, last_activity_at: 1.hour.ago) - visit dashboard_projects_path + visit dashboard_projects_path + + expect(page).to have_xpath("//time[@datetime='#{project.last_repository_updated_at.getutc.iso8601}']") + end + end - expect(page).to have_xpath("//time[@datetime='#{now.getutc.iso8601}']") + context 'when last_repository_updated_at and last_activity_at are missing' do + it 'shows the updated_at attribute as the update date' do + project.update_attributes!(last_repository_updated_at: nil, last_activity_at: nil) + project.touch + + visit dashboard_projects_path + + expect(page).to have_xpath("//time[@datetime='#{project.updated_at.getutc.iso8601}']") + end end context 'when on Starred projects tab' do diff --git a/spec/features/todos/target_state_spec.rb b/spec/features/dashboard/todos/target_state_spec.rb index 99b70b3d3a1..030a86d1c01 100644 --- a/spec/features/todos/target_state_spec.rb +++ b/spec/features/dashboard/todos/target_state_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature 'Todo target states', feature: true do +feature 'Dashboard > Todo target states' do let(:user) { create(:user) } let(:author) { create(:user) } - let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let(:project) { create(:project, :public) } before do - gitlab_sign_in user + sign_in(user) end scenario 'on a closed issue todo has closed label' do @@ -30,7 +30,7 @@ feature 'Todo target states', feature: true do end scenario 'on a merged merge request todo has merged label' do - mr_merged = create(:merge_request, :simple, author: user, state: 'merged') + mr_merged = create(:merge_request, :simple, :merged, author: user) create_todo mr_merged visit dashboard_todos_path @@ -40,7 +40,7 @@ feature 'Todo target states', feature: true do end scenario 'on a closed merge request todo has closed label' do - mr_closed = create(:merge_request, :simple, author: user, state: 'closed') + mr_closed = create(:merge_request, :simple, :closed, author: user) create_todo mr_closed visit dashboard_todos_path diff --git a/spec/features/todos/todos_filtering_spec.rb b/spec/features/dashboard/todos/todos_filtering_spec.rb index 032fb479076..0a363259fe7 100644 --- a/spec/features/todos/todos_filtering_spec.rb +++ b/spec/features/dashboard/todos/todos_filtering_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Dashboard > User filters todos', feature: true, js: true do +feature 'Dashboard > User filters todos', js: true do let(:user_1) { create(:user, username: 'user_1', name: 'user_1') } let(:user_2) { create(:user, username: 'user_2', name: 'user_2') } @@ -17,7 +17,7 @@ describe 'Dashboard > User filters todos', feature: true, js: true do project_1.team << [user_1, :developer] project_2.team << [user_1, :developer] - gitlab_sign_in(user_1) + sign_in(user_1) visit dashboard_todos_path end @@ -34,7 +34,7 @@ describe 'Dashboard > User filters todos', feature: true, js: true do expect(page).not_to have_content project_2.name_with_namespace end - context "Author filter" do + context 'Author filter' do it 'filters by author' do click_button 'Author' @@ -49,18 +49,18 @@ describe 'Dashboard > User filters todos', feature: true, js: true do expect(find('.todos-list')).not_to have_content 'issue' end - it "shows only authors of existing todos" do + it 'shows only authors of existing todos' do click_button 'Author' within '.dropdown-menu-author' do - # It should contain two users + "Any Author" + # It should contain two users + 'Any Author' expect(page).to have_selector('.dropdown-menu-user-link', count: 3) expect(page).to have_content(user_1.name) expect(page).to have_content(user_2.name) end end - it "shows only authors of existing done todos" do + it 'shows only authors of existing done todos' do user_3 = create :user user_4 = create :user create(:todo, user: user_1, author: user_3, project: project_1, target: issue, action: 1, state: :done) @@ -74,7 +74,7 @@ describe 'Dashboard > User filters todos', feature: true, js: true do click_button 'Author' within '.dropdown-menu-author' do - # It should contain two users + "Any Author" + # It should contain two users + 'Any Author' expect(page).to have_selector('.dropdown-menu-user-link', count: 3) expect(page).to have_content(user_3.name) expect(page).to have_content(user_4.name) diff --git a/spec/features/todos/todos_sorting_spec.rb b/spec/features/dashboard/todos/todos_sorting_spec.rb index 498bbac6d14..5858f4aa101 100644 --- a/spec/features/todos/todos_sorting_spec.rb +++ b/spec/features/dashboard/todos/todos_sorting_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Dashboard > User sorts todos", feature: true do +feature 'Dashboard > User sorts todos' do let(:user) { create(:user) } let(:project) { create(:empty_project) } @@ -18,7 +18,7 @@ describe "Dashboard > User sorts todos", feature: true do let(:issue_3) { create(:issue, title: 'issue_3', project: project) } let(:issue_4) { create(:issue, title: 'issue_4', project: project) } - let!(:merge_request_1) { create(:merge_request, source_project: project, title: "merge_request_1") } + let!(:merge_request_1) { create(:merge_request, source_project: project, title: 'merge_request_1') } before do create(:todo, user: user, project: project, target: issue_4, created_at: 5.hours.ago) @@ -32,41 +32,41 @@ describe "Dashboard > User sorts todos", feature: true do issue_2.labels << label_3 issue_1.labels << label_2 - gitlab_sign_in(user) + sign_in(user) visit dashboard_todos_path end - it "sorts with oldest created todos first" do - click_link "Last created" + it 'sorts with oldest created todos first' do + click_link 'Last created' results_list = page.find('.todos-list') - expect(results_list.all('p')[0]).to have_content("merge_request_1") - expect(results_list.all('p')[1]).to have_content("issue_1") - expect(results_list.all('p')[2]).to have_content("issue_3") - expect(results_list.all('p')[3]).to have_content("issue_2") - expect(results_list.all('p')[4]).to have_content("issue_4") + expect(results_list.all('p')[0]).to have_content('merge_request_1') + expect(results_list.all('p')[1]).to have_content('issue_1') + expect(results_list.all('p')[2]).to have_content('issue_3') + expect(results_list.all('p')[3]).to have_content('issue_2') + expect(results_list.all('p')[4]).to have_content('issue_4') end - it "sorts with newest created todos first" do - click_link "Oldest created" + it 'sorts with newest created todos first' do + click_link 'Oldest created' results_list = page.find('.todos-list') - expect(results_list.all('p')[0]).to have_content("issue_4") - expect(results_list.all('p')[1]).to have_content("issue_2") - expect(results_list.all('p')[2]).to have_content("issue_3") - expect(results_list.all('p')[3]).to have_content("issue_1") - expect(results_list.all('p')[4]).to have_content("merge_request_1") + expect(results_list.all('p')[0]).to have_content('issue_4') + expect(results_list.all('p')[1]).to have_content('issue_2') + expect(results_list.all('p')[2]).to have_content('issue_3') + expect(results_list.all('p')[3]).to have_content('issue_1') + expect(results_list.all('p')[4]).to have_content('merge_request_1') end - it "sorts by label priority" do - click_link "Label priority" + it 'sorts by label priority' do + click_link 'Label priority' results_list = page.find('.todos-list') - expect(results_list.all('p')[0]).to have_content("issue_3") - expect(results_list.all('p')[1]).to have_content("merge_request_1") - expect(results_list.all('p')[2]).to have_content("issue_1") - expect(results_list.all('p')[3]).to have_content("issue_2") - expect(results_list.all('p')[4]).to have_content("issue_4") + expect(results_list.all('p')[0]).to have_content('issue_3') + expect(results_list.all('p')[1]).to have_content('merge_request_1') + expect(results_list.all('p')[2]).to have_content('issue_1') + expect(results_list.all('p')[3]).to have_content('issue_2') + expect(results_list.all('p')[4]).to have_content('issue_4') end end @@ -88,12 +88,12 @@ describe "Dashboard > User sorts todos", feature: true do end it "doesn't mix issues and merge requests label priorities" do - click_link "Label priority" + click_link 'Label priority' results_list = page.find('.todos-list') - expect(results_list.all('p')[0]).to have_content("issue_1") - expect(results_list.all('p')[1]).to have_content("issue_2") - expect(results_list.all('p')[2]).to have_content("merge_request_1") + expect(results_list.all('p')[0]).to have_content('issue_1') + expect(results_list.all('p')[1]).to have_content('issue_2') + expect(results_list.all('p')[2]).to have_content('merge_request_1') end end end diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb new file mode 100644 index 00000000000..24da5db305f --- /dev/null +++ b/spec/features/dashboard/todos/todos_spec.rb @@ -0,0 +1,355 @@ +require 'spec_helper' + +feature 'Dashboard Todos' do + let(:user) { create(:user) } + let(:author) { create(:user) } + let(:project) { create(:project, :public) } + let(:issue) { create(:issue, due_date: Date.today) } + + context 'User does not have todos' do + before do + sign_in(user) + visit dashboard_todos_path + end + + it 'shows "All done" message' do + expect(page).to have_content 'Todos let you see what you should do next.' + end + end + + context 'User has a todo', js: true do + before do + create(:todo, :mentioned, user: user, project: project, target: issue, author: author) + sign_in(user) + + visit dashboard_todos_path + end + + it 'has todo present' do + expect(page).to have_selector('.todos-list .todo', count: 1) + end + + it 'shows due date as today' do + within first('.todo') do + expect(page).to have_content 'Due today' + end + end + + shared_examples 'deleting the todo' do + before do + within first('.todo') do + click_link 'Done' + end + end + + it 'is marked as done-reversible in the list' do + expect(page).to have_selector('.todos-list .todo.todo-pending.done-reversible') + end + + it 'shows Undo button' do + expect(page).to have_selector('.js-undo-todo', visible: true) + expect(page).to have_selector('.js-done-todo', visible: false) + end + + it 'updates todo count' do + expect(page).to have_content 'To do 0' + expect(page).to have_content 'Done 1' + end + + it 'has not "All done" message' do + expect(page).not_to have_selector('.todos-all-done') + end + end + + shared_examples 'deleting and restoring the todo' do + before do + within first('.todo') do + click_link 'Done' + wait_for_requests + click_link 'Undo' + end + end + + it 'is marked back as pending in the list' do + expect(page).not_to have_selector('.todos-list .todo.todo-pending.done-reversible') + expect(page).to have_selector('.todos-list .todo.todo-pending') + end + + it 'shows Done button' do + expect(page).to have_selector('.js-undo-todo', visible: false) + expect(page).to have_selector('.js-done-todo', visible: true) + end + + it 'updates todo count' do + expect(page).to have_content 'To do 1' + expect(page).to have_content 'Done 0' + end + end + + it_behaves_like 'deleting the todo' + it_behaves_like 'deleting and restoring the todo' + + context 'todo is stale on the page' do + before do + todos = TodosFinder.new(user, state: :pending).execute + TodoService.new.mark_todos_as_done(todos, user) + end + + it_behaves_like 'deleting the todo' + it_behaves_like 'deleting and restoring the todo' + end + end + + context 'User created todos for themself' do + before do + sign_in(user) + end + + context 'issue assigned todo' do + before do + create(:todo, :assigned, user: user, project: project, target: issue, author: user) + visit dashboard_todos_path + end + + it 'shows issue assigned to yourself message' do + page.within('.js-todos-all') do + expect(page).to have_content("You assigned issue #{issue.to_reference(full: true)} to yourself") + end + end + end + + context 'marked todo' do + before do + create(:todo, :marked, user: user, project: project, target: issue, author: user) + visit dashboard_todos_path + end + + it 'shows you added a todo message' do + page.within('.js-todos-all') do + expect(page).to have_content("You added a todo for issue #{issue.to_reference(full: true)}") + expect(page).not_to have_content('to yourself') + end + end + end + + context 'mentioned todo' do + before do + create(:todo, :mentioned, user: user, project: project, target: issue, author: user) + visit dashboard_todos_path + end + + it 'shows you mentioned yourself message' do + page.within('.js-todos-all') do + expect(page).to have_content("You mentioned yourself on issue #{issue.to_reference(full: true)}") + expect(page).not_to have_content('to yourself') + end + end + end + + context 'directly_addressed todo' do + before do + create(:todo, :directly_addressed, user: user, project: project, target: issue, author: user) + visit dashboard_todos_path + end + + it 'shows you directly addressed yourself message' do + page.within('.js-todos-all') do + expect(page).to have_content("You directly addressed yourself on issue #{issue.to_reference(full: true)}") + expect(page).not_to have_content('to yourself') + end + end + end + + context 'approval todo' do + let(:merge_request) { create(:merge_request) } + + before do + create(:todo, :approval_required, user: user, project: project, target: merge_request, author: user) + visit dashboard_todos_path + end + + it 'shows you set yourself as an approver message' do + page.within('.js-todos-all') do + expect(page).to have_content("You set yourself as an approver for merge request #{merge_request.to_reference(full: true)}") + expect(page).not_to have_content('to yourself') + end + end + end + end + + context 'User has done todos', js: true do + before do + create(:todo, :mentioned, :done, user: user, project: project, target: issue, author: author) + sign_in(user) + visit dashboard_todos_path(state: :done) + end + + it 'has the done todo present' do + expect(page).to have_selector('.todos-list .todo.todo-done', count: 1) + end + + describe 'restoring the todo' do + before do + within first('.todo') do + click_link 'Add todo' + end + end + + it 'is removed from the list' do + expect(page).not_to have_selector('.todos-list .todo.todo-done') + end + + it 'updates todo count' do + expect(page).to have_content 'To do 1' + expect(page).to have_content 'Done 0' + end + end + end + + context 'User has Todos with labels spanning multiple projects' do + before do + label1 = create(:label, project: project) + note1 = create(:note_on_issue, note: "Hello #{label1.to_reference(format: :name)}", noteable_id: issue.id, noteable_type: 'Issue', project: issue.project) + create(:todo, :mentioned, project: project, target: issue, user: user, note_id: note1.id) + + project2 = create(:project, :public) + label2 = create(:label, project: project2) + issue2 = create(:issue, project: project2) + note2 = create(:note_on_issue, note: "Test #{label2.to_reference(format: :name)}", noteable_id: issue2.id, noteable_type: 'Issue', project: project2) + create(:todo, :mentioned, project: project2, target: issue2, user: user, note_id: note2.id) + + gitlab_sign_in(user) + visit dashboard_todos_path + end + + it 'shows page with two Todos' do + expect(page).to have_selector('.todos-list .todo', count: 2) + end + end + + context 'User has multiple pages of Todos' do + before do + allow(Todo).to receive(:default_per_page).and_return(1) + + # Create just enough records to cause us to paginate + create_list(:todo, 2, :mentioned, user: user, project: project, target: issue, author: author) + + sign_in(user) + end + + it 'is paginated' do + visit dashboard_todos_path + + expect(page).to have_selector('.gl-pagination') + end + + it 'is has the right number of pages' do + visit dashboard_todos_path + + expect(page).to have_selector('.gl-pagination .page', count: 2) + end + + describe 'mark all as done', js: true do + before do + visit dashboard_todos_path + find('.js-todos-mark-all').trigger('click') + end + + it 'shows "All done" message!' do + expect(page).to have_content 'To do 0' + expect(page).to have_content "You're all done!" + expect(page).not_to have_selector('.gl-pagination') + end + + it 'shows "Undo mark all as done" button' do + expect(page).to have_selector('.js-todos-mark-all', visible: false) + expect(page).to have_selector('.js-todos-undo-all', visible: true) + end + end + + describe 'undo mark all as done', js: true do + before do + visit dashboard_todos_path + end + + it 'shows the restored todo list' do + mark_all_and_undo + + expect(page).to have_selector('.todos-list .todo', count: 1) + expect(page).to have_selector('.gl-pagination') + expect(page).not_to have_content "You're all done!" + end + + it 'updates todo count' do + mark_all_and_undo + + expect(page).to have_content 'To do 2' + expect(page).to have_content 'Done 0' + end + + it 'shows "Mark all as done" button' do + mark_all_and_undo + + expect(page).to have_selector('.js-todos-mark-all', visible: true) + expect(page).to have_selector('.js-todos-undo-all', visible: false) + end + + context 'User has deleted a todo' do + before do + within first('.todo') do + click_link 'Done' + end + end + + it 'shows the restored todo list with the deleted todo' do + mark_all_and_undo + + expect(page).to have_selector('.todos-list .todo.todo-pending', count: 1) + end + end + + def mark_all_and_undo + find('.js-todos-mark-all').trigger('click') + wait_for_requests + find('.js-todos-undo-all').trigger('click') + wait_for_requests + end + end + end + + context 'User has a Todo in a project pending deletion' do + before do + deleted_project = create(:project, :public, pending_delete: true) + create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author) + create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author, state: :done) + sign_in(user) + visit dashboard_todos_path + end + + it 'shows "All done" message' do + within('.todos-count') { expect(page).to have_content '0' } + expect(page).to have_content 'To do 0' + expect(page).to have_content 'Done 0' + expect(page).to have_selector('.todos-all-done', count: 1) + end + end + + context 'User has a Build Failed todo' do + let!(:todo) { create(:todo, :build_failed, user: user, project: project, author: author) } + + before do + sign_in(user) + visit dashboard_todos_path + end + + it 'shows the todo' do + expect(page).to have_content 'The build failed for merge request' + end + + it 'links to the pipelines for the merge request' do + href = pipelines_namespace_project_merge_request_path(project.namespace, project, todo.target) + + expect(page).to have_link "merge request #{todo.target.to_reference(full: true)}", href + end + end +end diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb index 1da88d3b1d2..2d13af2a52a 100644 --- a/spec/features/gitlab_flavored_markdown_spec.rb +++ b/spec/features/gitlab_flavored_markdown_spec.rb @@ -20,8 +20,8 @@ describe "GitLab Flavored Markdown", feature: true do let(:commit) { project.commit } before do - allow_any_instance_of(Commit).to receive(:title). - and_return("fix #{issue.to_reference}\n\nask #{fred.to_reference} for details") + allow_any_instance_of(Commit).to receive(:title) + .and_return("fix #{issue.to_reference}\n\nask #{fred.to_reference} for details") end it "renders title in commits#index" do diff --git a/spec/features/groups/group_settings_spec.rb b/spec/features/groups/group_settings_spec.rb index 5ad777248ec..56e163ec4d0 100644 --- a/spec/features/groups/group_settings_spec.rb +++ b/spec/features/groups/group_settings_spec.rb @@ -18,14 +18,14 @@ feature 'Edit group settings', feature: true do update_path(new_group_path) visit new_group_full_path expect(current_path).to eq(new_group_full_path) - expect(find('h1.group-title')).to have_content(new_group_path) + expect(find('h1.group-title')).to have_content(group.name) end scenario 'the old group path redirects to the new path' do update_path(new_group_path) visit old_group_full_path expect(current_path).to eq(new_group_full_path) - expect(find('h1.group-title')).to have_content(new_group_path) + expect(find('h1.group-title')).to have_content(group.name) end context 'with a subgroup' do @@ -37,14 +37,14 @@ feature 'Edit group settings', feature: true do update_path(new_group_path) visit new_subgroup_full_path expect(current_path).to eq(new_subgroup_full_path) - expect(find('h1.group-title')).to have_content(subgroup.path) + expect(find('h1.group-title')).to have_content(subgroup.name) end scenario 'the old subgroup path redirects to the new path' do update_path(new_group_path) visit old_subgroup_full_path expect(current_path).to eq(new_subgroup_full_path) - expect(find('h1.group-title')).to have_content(subgroup.path) + expect(find('h1.group-title')).to have_content(subgroup.name) end end diff --git a/spec/features/groups/labels/subscription_spec.rb b/spec/features/groups/labels/subscription_spec.rb new file mode 100644 index 00000000000..8b891c52d08 --- /dev/null +++ b/spec/features/groups/labels/subscription_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +feature 'Labels subscription', feature: true do + let(:user) { create(:user) } + let(:group) { create(:group) } + let!(:feature) { create(:group_label, group: group, title: 'feature') } + + context 'when signed in' do + before do + group.add_developer(user) + gitlab_sign_in user + end + + scenario 'users can subscribe/unsubscribe to group labels', js: true do + visit group_labels_path(group) + + expect(page).to have_content('feature') + + within "#group_label_#{feature.id}" do + expect(page).not_to have_button 'Unsubscribe' + + click_button 'Subscribe' + + expect(page).not_to have_button 'Subscribe' + expect(page).to have_button 'Unsubscribe' + + click_button 'Unsubscribe' + + expect(page).to have_button 'Subscribe' + expect(page).not_to have_button 'Unsubscribe' + end + end + end + + context 'when not signed in' do + it 'users can not subscribe/unsubscribe to labels' do + visit group_labels_path(group) + + expect(page).to have_content 'feature' + expect(page).not_to have_button('Subscribe') + end + end + + def click_link_on_dropdown(text) + find('.dropdown-group-label').click + + page.within('.dropdown-group-label') do + find('a.js-subscribe-button', text: text).click + end + end +end diff --git a/spec/features/groups/members/last_owner_cannot_leave_group_spec.rb b/spec/features/groups/members/last_owner_cannot_leave_group_spec.rb deleted file mode 100644 index 5af94e4069b..00000000000 --- a/spec/features/groups/members/last_owner_cannot_leave_group_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'spec_helper' - -feature 'Groups > Members > Last owner cannot leave group', feature: true do - let(:owner) { create(:user) } - let(:group) { create(:group) } - - background do - group.add_owner(owner) - gitlab_sign_in(owner) - visit group_path(group) - end - - scenario 'user does not see a "Leave group" link' do - expect(page).not_to have_content 'Leave group' - end -end diff --git a/spec/features/groups/members/leave_group_spec.rb b/spec/features/groups/members/leave_group_spec.rb new file mode 100644 index 00000000000..b438f57753c --- /dev/null +++ b/spec/features/groups/members/leave_group_spec.rb @@ -0,0 +1,62 @@ +require 'spec_helper' + +feature 'Groups > Members > Leave group', feature: true do + let(:user) { create(:user) } + let(:other_user) { create(:user) } + let(:group) { create(:group) } + + background do + gitlab_sign_in(user) + end + + scenario 'guest leaves the group' do + group.add_guest(user) + group.add_owner(other_user) + + visit group_path(group) + click_link 'Leave group' + + expect(current_path).to eq(dashboard_groups_path) + expect(page).to have_content left_group_message(group) + expect(group.users).not_to include(user) + end + + scenario 'guest leaves the group as last member' do + group.add_guest(user) + + visit group_path(group) + click_link 'Leave group' + + expect(current_path).to eq(dashboard_groups_path) + expect(page).to have_content left_group_message(group) + expect(group.users).not_to include(user) + end + + scenario 'owner leaves the group if they is not the last owner' do + group.add_owner(user) + group.add_owner(other_user) + + visit group_path(group) + click_link 'Leave group' + + expect(current_path).to eq(dashboard_groups_path) + expect(page).to have_content left_group_message(group) + expect(group.users).not_to include(user) + end + + scenario 'owner can not leave the group if they is a last owner' do + group.add_owner(user) + + visit group_path(group) + + expect(page).not_to have_content 'Leave group' + + visit group_group_members_path(group) + + expect(find(:css, '.project-members-page li', text: user.name)).not_to have_selector(:css, 'a.btn-remove') + end + + def left_group_message(group) + "You left the \"#{group.name}\"" + end +end diff --git a/spec/features/groups/members/list_members_spec.rb b/spec/features/groups/members/list_members_spec.rb new file mode 100644 index 00000000000..f6493c4c50e --- /dev/null +++ b/spec/features/groups/members/list_members_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +feature 'Groups > Members > List members', feature: true do + include Select2Helper + + let(:user1) { create(:user, name: 'John Doe') } + let(:user2) { create(:user, name: 'Mary Jane') } + let(:group) { create(:group) } + let(:nested_group) { create(:group, parent: group) } + + background do + gitlab_sign_in(user1) + end + + scenario 'show members from current group and parent', :nested_groups do + group.add_developer(user1) + nested_group.add_developer(user2) + + visit group_group_members_path(nested_group) + + expect(first_row.text).to include(user1.name) + expect(second_row.text).to include(user2.name) + end + + scenario 'show user once if member of both current group and parent', :nested_groups do + group.add_developer(user1) + nested_group.add_developer(user1) + + visit group_group_members_path(nested_group) + + expect(first_row.text).to include(user1.name) + expect(second_row).to be_blank + end + + def first_row + page.all('ul.content-list > li')[0] + end + + def second_row + page.all('ul.content-list > li')[1] + end +end diff --git a/spec/features/groups/members/owner_manages_access_requests_spec.rb b/spec/features/groups/members/manage_access_requests_spec.rb index 4e4cf12e8af..f84d8594c65 100644 --- a/spec/features/groups/members/owner_manages_access_requests_spec.rb +++ b/spec/features/groups/members/manage_access_requests_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Groups > Members > Owner manages access requests', feature: true do +feature 'Groups > Members > Manage access requests', feature: true do let(:user) { create(:user) } let(:owner) { create(:user) } let(:group) { create(:group, :public, :access_requestable) } @@ -17,7 +17,7 @@ feature 'Groups > Members > Owner manages access requests', feature: true do expect_visible_access_request(group, user) end - scenario 'master can grant access' do + scenario 'owner can grant access' do visit group_group_members_path(group) expect_visible_access_request(group, user) @@ -28,7 +28,7 @@ feature 'Groups > Members > Owner manages access requests', feature: true do expect(ActionMailer::Base.deliveries.last.subject).to match "Access to the #{group.name} group was granted" end - scenario 'master can deny access' do + scenario 'owner can deny access' do visit group_group_members_path(group) expect_visible_access_request(group, user) diff --git a/spec/features/groups/members/list_spec.rb b/spec/features/groups/members/manage_members.rb index 5d00ed30c83..a9a654b20e2 100644 --- a/spec/features/groups/members/list_spec.rb +++ b/spec/features/groups/members/manage_members.rb @@ -1,37 +1,16 @@ require 'spec_helper' -feature 'Groups members list', feature: true do +feature 'Groups > Members > Manage members', feature: true do include Select2Helper let(:user1) { create(:user, name: 'John Doe') } let(:user2) { create(:user, name: 'Mary Jane') } let(:group) { create(:group) } - let(:nested_group) { create(:group, parent: group) } background do gitlab_sign_in(user1) end - scenario 'show members from current group and parent', :nested_groups do - group.add_developer(user1) - nested_group.add_developer(user2) - - visit group_group_members_path(nested_group) - - expect(first_row.text).to include(user1.name) - expect(second_row.text).to include(user2.name) - end - - scenario 'show user once if member of both current group and parent', :nested_groups do - group.add_developer(user1) - nested_group.add_developer(user1) - - visit group_group_members_path(nested_group) - - expect(first_row.text).to include(user1.name) - expect(second_row).to be_blank - end - scenario 'update user to owner level', :js do group.add_owner(user1) group.add_developer(user2) @@ -59,6 +38,18 @@ feature 'Groups members list', feature: true do end end + scenario 'remove user from group', :js do + group.add_owner(user1) + group.add_developer(user2) + + visit group_group_members_path(group) + + find(:css, '.project-members-page li', text: user2.name).find(:css, 'a.btn-remove').click + + expect(page).not_to have_content(user2.name) + expect(group.users).not_to include(user2) + end + scenario 'add yourself to group when already an owner', :js do group.add_owner(user1) @@ -86,6 +77,23 @@ feature 'Groups members list', feature: true do end end + scenario 'guest can not manage other users' do + group.add_guest(user1) + group.add_developer(user2) + + visit group_group_members_path(group) + + expect(page).not_to have_button 'Add to group' + + page.within(second_row) do + # Can not modify user2 role + expect(page).not_to have_button 'Developer' + + # Can not remove user2 + expect(page).not_to have_css('a.btn-remove') + end + end + def first_row page.all('ul.content-list > li')[0] end diff --git a/spec/features/groups/members/member_cannot_request_access_to_his_project_spec.rb b/spec/features/groups/members/member_cannot_request_access_to_his_project_spec.rb deleted file mode 100644 index 135bb3572bc..00000000000 --- a/spec/features/groups/members/member_cannot_request_access_to_his_project_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'spec_helper' - -feature 'Groups > Members > Member cannot request access to his project', feature: true do - let(:member) { create(:user) } - let(:group) { create(:group) } - - background do - group.add_developer(member) - gitlab_sign_in(member) - visit group_path(group) - end - - scenario 'member does not see the request access button' do - expect(page).not_to have_content 'Request Access' - end -end diff --git a/spec/features/groups/members/member_leaves_group_spec.rb b/spec/features/groups/members/member_leaves_group_spec.rb deleted file mode 100644 index 40f3b166e74..00000000000 --- a/spec/features/groups/members/member_leaves_group_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -feature 'Groups > Members > Member leaves group', feature: true do - let(:user) { create(:user) } - let(:owner) { create(:user) } - let(:group) { create(:group, :public) } - - background do - group.add_owner(owner) - group.add_developer(user) - gitlab_sign_in(user) - visit group_path(group) - end - - scenario 'user leaves group' do - click_link 'Leave group' - - expect(current_path).to eq(dashboard_groups_path) - expect(group.users.exists?(user.id)).to be_falsey - end -end diff --git a/spec/features/groups/members/user_requests_access_spec.rb b/spec/features/groups/members/request_access_spec.rb index 3813308c237..41c31b62e18 100644 --- a/spec/features/groups/members/user_requests_access_spec.rb +++ b/spec/features/groups/members/request_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Groups > Members > User requests access', feature: true do +feature 'Groups > Members > Request access', feature: true do let(:user) { create(:user) } let(:owner) { create(:user) } let(:group) { create(:group, :public, :access_requestable) } @@ -68,4 +68,11 @@ feature 'Groups > Members > User requests access', feature: true do expect(group.requesters.exists?(user_id: user)).to be_falsey expect(page).to have_content 'Your access request to the group has been withdrawn.' end + + scenario 'member does not see the request access button' do + group.add_owner(user) + visit group_path(group) + + expect(page).not_to have_content 'Request Access' + end end diff --git a/spec/features/groups/members/sorting_spec.rb b/spec/features/groups/members/sort_members_spec.rb index 719fa0b40b8..8ee61953844 100644 --- a/spec/features/groups/members/sorting_spec.rb +++ b/spec/features/groups/members/sort_members_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Groups > Members > Sorting', feature: true do +feature 'Groups > Members > Sort members', feature: true do let(:owner) { create(:user, name: 'John Doe') } let(:developer) { create(:user, name: 'Mary Jane', last_sign_in_at: 5.days.ago) } let(:group) { create(:group) } diff --git a/spec/features/issues/bulk_assignment_labels_spec.rb b/spec/features/issues/bulk_assignment_labels_spec.rb index 2eb04df3cb3..a99c19cb787 100644 --- a/spec/features/issues/bulk_assignment_labels_spec.rb +++ b/spec/features/issues/bulk_assignment_labels_spec.rb @@ -16,6 +16,21 @@ feature 'Issues > Labels bulk assignment', feature: true do gitlab_sign_in user end + context 'sidebar' do + before do + enable_bulk_update + end + + it 'is present when bulk edit is enabled' do + expect(page).to have_css('.issuable-sidebar') + end + + it 'is not present when bulk edit is disabled' do + disable_bulk_update + expect(page).not_to have_css('.issuable-sidebar') + end + end + context 'can bulk assign' do before do enable_bulk_update @@ -398,4 +413,8 @@ feature 'Issues > Labels bulk assignment', feature: true do visit namespace_project_issues_path(project.namespace, project) click_button 'Edit Issues' end + + def disable_bulk_update + click_button 'Cancel' + end end diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb index b43e6a06a07..a8055b21cee 100644 --- a/spec/features/login_spec.rb +++ b/spec/features/login_spec.rb @@ -122,8 +122,8 @@ feature 'Login', feature: true do end it 'invalidates the used code' do - expect { enter_code(codes.sample) }. - to change { user.reload.otp_backup_codes.size }.by(-1) + expect { enter_code(codes.sample) } + .to change { user.reload.otp_backup_codes.size }.by(-1) end end @@ -143,29 +143,8 @@ feature 'Login', feature: true do end context 'logging in via OAuth' do - def saml_config - OpenStruct.new(name: 'saml', label: 'saml', args: { - assertion_consumer_service_url: 'https://localhost:3443/users/auth/saml/callback', - idp_cert_fingerprint: '26:43:2C:47:AF:F0:6B:D0:07:9C:AD:A3:74:FE:5D:94:5F:4E:9E:52', - idp_sso_target_url: 'https://idp.example.com/sso/saml', - issuer: 'https://localhost:3443/', - name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient' - }) - end - - def stub_omniauth_config(messages) - Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] - Rails.application.routes.disable_clear_and_finalize = true - Rails.application.routes.draw do - post '/users/auth/saml' => 'omniauth_callbacks#saml' - end - allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: saml_config) - allow(Gitlab.config.omniauth).to receive_messages(messages) - expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') - end - it 'shows 2FA prompt after OAuth login' do - stub_omniauth_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [saml_config]) + stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [mock_saml_config]) user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: 'saml') gitlab_sign_in_via('saml', user, 'my-uid') diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index ba930de937d..534be3ab5a7 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -58,8 +58,8 @@ describe 'GitLab Markdown', feature: true do end it 'allows Markdown in tables' do - expect(doc.at_css('td:contains("Baz")').children.to_html). - to eq '<strong>Baz</strong>' + expect(doc.at_css('td:contains("Baz")').children.to_html) + .to eq '<strong>Baz</strong>' end it 'parses fenced code blocks' do @@ -158,14 +158,14 @@ describe 'GitLab Markdown', feature: true do describe 'Edge Cases' do it 'allows markup inside link elements' do aggregate_failures do - expect(doc.at_css('a[href="#link-emphasis"]').to_html). - to eq %{<a href="#link-emphasis"><em>text</em></a>} + expect(doc.at_css('a[href="#link-emphasis"]').to_html) + .to eq %{<a href="#link-emphasis"><em>text</em></a>} - expect(doc.at_css('a[href="#link-strong"]').to_html). - to eq %{<a href="#link-strong"><strong>text</strong></a>} + expect(doc.at_css('a[href="#link-strong"]').to_html) + .to eq %{<a href="#link-strong"><strong>text</strong></a>} - expect(doc.at_css('a[href="#link-code"]').to_html). - to eq %{<a href="#link-code"><code>text</code></a>} + expect(doc.at_css('a[href="#link-code"]').to_html) + .to eq %{<a href="#link-code"><code>text</code></a>} end end end diff --git a/spec/features/merge_requests/closes_issues_spec.rb b/spec/features/merge_requests/closes_issues_spec.rb index 371aa2bdaa7..365b2555c35 100644 --- a/spec/features/merge_requests/closes_issues_spec.rb +++ b/spec/features/merge_requests/closes_issues_spec.rb @@ -36,7 +36,7 @@ feature 'Merge Request closing issues message', feature: true, js: true do let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" } it 'does not display closing issue message' do - expect(page).to have_content("Closed issues #{issue_1.to_reference} and #{issue_2.to_reference}") + expect(page).to have_content("Closes issues #{issue_1.to_reference} and #{issue_2.to_reference}") end end @@ -44,7 +44,7 @@ feature 'Merge Request closing issues message', feature: true, js: true do let(:merge_request_description) { "Description\n\nRefers to #{issue_1.to_reference} and #{issue_2.to_reference}" } it 'does not display closing issue message' do - expect(page).to have_content("Issues #{issue_1.to_reference} and #{issue_2.to_reference} are mentioned but were not closed") + expect(page).to have_content("Issues #{issue_1.to_reference} and #{issue_2.to_reference} are mentioned but will not be closed.") end end @@ -52,8 +52,8 @@ feature 'Merge Request closing issues message', feature: true, js: true do let(:merge_request_title) { "closes #{issue_1.to_reference}\n\n refers to #{issue_2.to_reference}" } it 'does not display closing issue message' do - expect(page).to have_content("Closed issue #{issue_1.to_reference}") - expect(page).to have_content("Issue #{issue_2.to_reference} is mentioned but was not closed") + expect(page).to have_content("Closes issue #{issue_1.to_reference}.") + expect(page).to have_content("Issue #{issue_2.to_reference} is mentioned but will not be closed.") end end @@ -61,7 +61,7 @@ feature 'Merge Request closing issues message', feature: true, js: true do let(:merge_request_title) { "closing #{issue_1.to_reference}, #{issue_2.to_reference}" } it 'does not display closing issue message' do - expect(page).to have_content("Closed issues #{issue_1.to_reference} and #{issue_2.to_reference}") + expect(page).to have_content("Closes issues #{issue_1.to_reference} and #{issue_2.to_reference}") end end @@ -69,7 +69,7 @@ feature 'Merge Request closing issues message', feature: true, js: true do let(:merge_request_title) { "Refers to #{issue_1.to_reference} and #{issue_2.to_reference}" } it 'does not display closing issue message' do - expect(page).to have_content("Issues #{issue_1.to_reference} and #{issue_2.to_reference} are mentioned but were not closed") + expect(page).to have_content("Issues #{issue_1.to_reference} and #{issue_2.to_reference} are mentioned but will not be closed.") end end @@ -77,8 +77,8 @@ feature 'Merge Request closing issues message', feature: true, js: true do let(:merge_request_title) { "closes #{issue_1.to_reference}\n\n refers to #{issue_2.to_reference}" } it 'does not display closing issue message' do - expect(page).to have_content("Closed issue #{issue_1.to_reference}") - expect(page).to have_content("Issue #{issue_2.to_reference} is mentioned but was not closed") + expect(page).to have_content("Closes issue #{issue_1.to_reference}. Issue #{issue_2.to_reference} is mentioned but will not be closed.") + expect(page).to have_content("Issue #{issue_2.to_reference} is mentioned but will not be closed.") end end end diff --git a/spec/features/merge_requests/user_posts_notes_spec.rb b/spec/features/merge_requests/user_posts_notes_spec.rb index 70652fcce8c..12f987e12ea 100644 --- a/spec/features/merge_requests/user_posts_notes_spec.rb +++ b/spec/features/merge_requests/user_posts_notes_spec.rb @@ -22,8 +22,8 @@ describe 'Merge requests > User posts notes', :js do describe 'the note form' do it 'is valid' do is_expected.to have_css('.js-main-target-form', visible: true, count: 1) - expect(find('.js-main-target-form .js-comment-button').value). - to eq('Comment') + expect(find('.js-main-target-form .js-comment-button').value) + .to eq('Comment') page.within('.js-main-target-form') do expect(page).not_to have_link('Cancel') end @@ -123,8 +123,8 @@ describe 'Merge requests > User posts notes', :js do page.within("#note_#{note.id}") do is_expected.to have_css('.note_edited_ago') - expect(find('.note_edited_ago').text). - to match(/less than a minute ago/) + expect(find('.note_edited_ago').text) + .to match(/less than a minute ago/) end end end diff --git a/spec/features/profiles/password_spec.rb b/spec/features/profiles/password_spec.rb index 2d36f3d020f..86c9df5ff86 100644 --- a/spec/features/profiles/password_spec.rb +++ b/spec/features/profiles/password_spec.rb @@ -25,7 +25,7 @@ describe 'Profile > Password', feature: true do end end - it 'does not contains the current password field after an error' do + it 'does not contain the current password field after an error' do fill_passwords('mypassword', 'mypassword2') expect(page).to have_no_field('user[current_password]') diff --git a/spec/features/profiles/user_visits_notifications_tab_spec.rb b/spec/features/profiles/user_visits_notifications_tab_spec.rb new file mode 100644 index 00000000000..e98cec79d87 --- /dev/null +++ b/spec/features/profiles/user_visits_notifications_tab_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +feature 'User visits the notifications tab', js: true do + let(:project) { create(:empty_project) } + let(:user) { create(:user) } + + before do + project.team << [user, :master] + sign_in(user) + visit(profile_notifications_path) + end + + it 'changes the project notifications setting' do + expect(page).to have_content('Notifications') + + first('#notifications-button').trigger('click') + click_link('On mention') + + expect(page).to have_content('On mention') + end +end diff --git a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb index 53c5a52ce3a..d94204230f6 100644 --- a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb +++ b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb @@ -55,7 +55,7 @@ feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', feature: true, end end - describe 'Click "Annotate" button' do + describe 'Click "Blame" button' do it 'works with no initial line number fragment hash' do visit_blob diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index 83883dba0ba..cf4d996a32d 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -151,7 +151,7 @@ feature 'Environments page', :feature, :js do find('.js-dropdown-play-icon-container').click expect(page).to have_content(action.name.humanize) - expect { find('.js-manual-action-link').click } + expect { find('.js-manual-action-link').trigger('click') } .not_to change { Ci::Pipeline.count } end diff --git a/spec/features/projects/files/browse_files_spec.rb b/spec/features/projects/files/browse_files_spec.rb index 2a82c3ac179..34aef958ec6 100644 --- a/spec/features/projects/files/browse_files_spec.rb +++ b/spec/features/projects/files/browse_files_spec.rb @@ -12,7 +12,7 @@ feature 'user browses project', feature: true, js: true do scenario "can see blame of '.gitignore'" do click_link ".gitignore" - click_link 'Annotate' + click_link 'Blame' expect(page).to have_content "*.rb" expect(page).to have_content "Dmitriy Zaporozhets" diff --git a/spec/features/projects/no_password_spec.rb b/spec/features/projects/no_password_spec.rb new file mode 100644 index 00000000000..30a16e38e3c --- /dev/null +++ b/spec/features/projects/no_password_spec.rb @@ -0,0 +1,69 @@ +require 'spec_helper' + +feature 'No Password Alert' do + let(:project) { create(:project, namespace: user.namespace) } + + context 'with internal auth enabled' do + before do + sign_in(user) + visit namespace_project_path(project.namespace, project) + end + + context 'when user has a password' do + let(:user) { create(:user) } + + it 'shows no alert' do + expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you set a password on your account" + end + end + + context 'when user has password automatically set' do + let(:user) { create(:user, password_automatically_set: true) } + + it 'shows a password alert' do + expect(page).to have_content "You won't be able to pull or push project code via HTTP until you set a password on your account" + end + end + end + + context 'with internal auth disabled' do + let(:user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'saml') } + + before do + stub_application_setting(signin_enabled?: false) + stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [mock_saml_config]) + end + + context 'when user has no personal access tokens' do + it 'has a personal access token alert' do + gitlab_sign_in_via('saml', user, 'my-uid') + visit namespace_project_path(project.namespace, project) + + expect(page).to have_content "You won't be able to pull or push project code via HTTP until you create a personal access token on your account" + end + end + + context 'when user has a personal access token' do + it 'shows no alert' do + create(:personal_access_token, user: user) + gitlab_sign_in_via('saml', user, 'my-uid') + visit namespace_project_path(project.namespace, project) + + expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you create a personal access token on your account" + end + end + end + + context 'when user is ldap user' do + let(:user) { create(:omniauth_user, password_automatically_set: true) } + + before do + sign_in(user) + visit namespace_project_path(project.namespace, project) + end + + it 'shows no alert' do + expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you" + end + end +end diff --git a/spec/features/projects/services/jira_service_spec.rb b/spec/features/projects/services/jira_service_spec.rb index 2ea50e8f672..8cd216c8fdb 100644 --- a/spec/features/projects/services/jira_service_spec.rb +++ b/spec/features/projects/services/jira_service_spec.rb @@ -6,7 +6,11 @@ feature 'Setup Jira service', :feature, :js do let(:service) { project.create_jira_service } let(:url) { 'http://jira.example.com' } - let(:project_url) { 'http://username:password@jira.example.com/rest/api/2/project/GitLabProject' } + + def stub_project_url + WebMock.stub_request(:get, 'http://jira.example.com/rest/api/2/project/GitLabProject') + .with(basic_auth: %w(username password)) + end def fill_form(active = true) check 'Active' if active @@ -28,7 +32,7 @@ feature 'Setup Jira service', :feature, :js do describe 'user sets and activates Jira Service' do context 'when Jira connection test succeeds' do before do - WebMock.stub_request(:get, project_url) + stub_project_url end it 'activates the JIRA service' do @@ -44,7 +48,7 @@ feature 'Setup Jira service', :feature, :js do context 'when Jira connection test fails' do before do - WebMock.stub_request(:get, project_url).to_return(status: 401) + stub_project_url.to_return(status: 401) end it 'shows errors when some required fields are not filled in' do diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index 2956ef73746..35cd0d6e832 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -65,6 +65,23 @@ feature 'Repository settings', feature: true do expect(page).to have_content('Write access allowed') end + scenario 'edit a deploy key from projects user has access to' do + project2 = create(:project_empty_repo) + project2.team << [user, role] + project2.deploy_keys << private_deploy_key + + visit namespace_project_settings_repository_path(project.namespace, project) + + find('li', text: private_deploy_key.title).click_link('Edit') + + fill_in 'deploy_key_title', with: 'updated_deploy_key' + check 'deploy_key_can_push' + click_button 'Save changes' + + expect(page).to have_content('updated_deploy_key') + expect(page).to have_content('Write access allowed') + end + scenario 'remove an existing deploy key' do project.deploy_keys << private_deploy_key visit namespace_project_settings_repository_path(project.namespace, project) diff --git a/spec/features/projects/user_creates_project_spec.rb b/spec/features/projects/user_creates_project_spec.rb new file mode 100644 index 00000000000..29f1eb8d73e --- /dev/null +++ b/spec/features/projects/user_creates_project_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +feature 'User creates a project', js: true do + let(:user) { create(:user) } + + before do + sign_in(user) + create(:personal_key, user: user) + visit(new_project_path) + end + + it 'creates a new project' do + fill_in(:project_path, with: 'Empty') + + page.within('#content-body') do + click_button('Create project') + end + + project = Project.last + + expect(current_path).to eq(namespace_project_path(project.namespace, project)) + expect(page).to have_content('Empty') + expect(page).to have_content('git init') + expect(page).to have_content('git remote') + expect(page).to have_content(project.url_to_repo) + end +end diff --git a/spec/features/reportable_note/snippets_spec.rb b/spec/features/reportable_note/snippets_spec.rb index a88990eada0..5bee4a31379 100644 --- a/spec/features/reportable_note/snippets_spec.rb +++ b/spec/features/reportable_note/snippets_spec.rb @@ -19,15 +19,4 @@ describe 'Reportable note on snippets', :feature, :js do it_behaves_like 'reportable note' end - - describe 'on personal snippet' do - let(:snippet) { create(:personal_snippet, :public, author: user) } - let!(:note) { create(:note_on_personal_snippet, noteable: snippet, author: user) } - - before do - visit snippet_path(snippet) - end - - it_behaves_like 'reportable note' - end end diff --git a/spec/features/snippets/notes_on_personal_snippets_spec.rb b/spec/features/snippets/notes_on_personal_snippets_spec.rb index 6f7e6f543b2..c7e2e3d8a34 100644 --- a/spec/features/snippets/notes_on_personal_snippets_spec.rb +++ b/spec/features/snippets/notes_on_personal_snippets_spec.rb @@ -33,6 +33,7 @@ describe 'Comments on personal snippets', :js, feature: true do expect(page).to have_selector('.note-emoji-button') end + find('body').click # close dropdown open_more_actions_dropdown(snippet_notes[1]) page.within("#notes-list li#note_#{snippet_notes[1].id}") do @@ -46,8 +47,8 @@ describe 'Comments on personal snippets', :js, feature: true do context 'when submitting a note' do it 'shows a valid form' do is_expected.to have_css('.js-main-target-form', visible: true, count: 1) - expect(find('.js-main-target-form .js-comment-button').value). - to eq('Comment') + expect(find('.js-main-target-form .js-comment-button').value) + .to eq('Comment') page.within('.js-main-target-form') do expect(page).not_to have_link('Cancel') diff --git a/spec/features/todos/todos_spec.rb b/spec/features/todos/todos_spec.rb deleted file mode 100644 index 41b32bdedc3..00000000000 --- a/spec/features/todos/todos_spec.rb +++ /dev/null @@ -1,355 +0,0 @@ -require 'spec_helper' - -describe 'Dashboard Todos', feature: true do - let(:user) { create(:user) } - let(:author) { create(:user) } - let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let(:issue) { create(:issue, due_date: Date.today) } - - describe 'GET /dashboard/todos' do - context 'User does not have todos' do - before do - gitlab_sign_in(user) - visit dashboard_todos_path - end - it 'shows "All done" message' do - expect(page).to have_content "Todos let you see what you should do next." - end - end - - context 'User has a todo', js: true do - before do - create(:todo, :mentioned, user: user, project: project, target: issue, author: author) - gitlab_sign_in(user) - visit dashboard_todos_path - end - - it 'has todo present' do - expect(page).to have_selector('.todos-list .todo', count: 1) - end - - it 'shows due date as today' do - within first('.todo') do - expect(page).to have_content 'Due today' - end - end - - shared_examples 'deleting the todo' do - before do - within first('.todo') do - click_link 'Done' - end - end - - it 'is marked as done-reversible in the list' do - expect(page).to have_selector('.todos-list .todo.todo-pending.done-reversible') - end - - it 'shows Undo button' do - expect(page).to have_selector('.js-undo-todo', visible: true) - expect(page).to have_selector('.js-done-todo', visible: false) - end - - it 'updates todo count' do - expect(page).to have_content 'To do 0' - expect(page).to have_content 'Done 1' - end - - it 'has not "All done" message' do - expect(page).not_to have_selector('.todos-all-done') - end - end - - shared_examples 'deleting and restoring the todo' do - before do - within first('.todo') do - click_link 'Done' - wait_for_requests - click_link 'Undo' - end - end - - it 'is marked back as pending in the list' do - expect(page).not_to have_selector('.todos-list .todo.todo-pending.done-reversible') - expect(page).to have_selector('.todos-list .todo.todo-pending') - end - - it 'shows Done button' do - expect(page).to have_selector('.js-undo-todo', visible: false) - expect(page).to have_selector('.js-done-todo', visible: true) - end - - it 'updates todo count' do - expect(page).to have_content 'To do 1' - expect(page).to have_content 'Done 0' - end - end - - it_behaves_like 'deleting the todo' - it_behaves_like 'deleting and restoring the todo' - - context 'todo is stale on the page' do - before do - todos = TodosFinder.new(user, state: :pending).execute - TodoService.new.mark_todos_as_done(todos, user) - end - - it_behaves_like 'deleting the todo' - it_behaves_like 'deleting and restoring the todo' - end - end - - context 'User created todos for themself' do - before do - gitlab_sign_in(user) - end - - context 'issue assigned todo' do - before do - create(:todo, :assigned, user: user, project: project, target: issue, author: user) - visit dashboard_todos_path - end - - it 'shows issue assigned to yourself message' do - page.within('.js-todos-all') do - expect(page).to have_content("You assigned issue #{issue.to_reference(full: true)} to yourself") - end - end - end - - context 'marked todo' do - before do - create(:todo, :marked, user: user, project: project, target: issue, author: user) - visit dashboard_todos_path - end - - it 'shows you added a todo message' do - page.within('.js-todos-all') do - expect(page).to have_content("You added a todo for issue #{issue.to_reference(full: true)}") - expect(page).not_to have_content('to yourself') - end - end - end - - context 'mentioned todo' do - before do - create(:todo, :mentioned, user: user, project: project, target: issue, author: user) - visit dashboard_todos_path - end - - it 'shows you mentioned yourself message' do - page.within('.js-todos-all') do - expect(page).to have_content("You mentioned yourself on issue #{issue.to_reference(full: true)}") - expect(page).not_to have_content('to yourself') - end - end - end - - context 'directly_addressed todo' do - before do - create(:todo, :directly_addressed, user: user, project: project, target: issue, author: user) - visit dashboard_todos_path - end - - it 'shows you directly addressed yourself message' do - page.within('.js-todos-all') do - expect(page).to have_content("You directly addressed yourself on issue #{issue.to_reference(full: true)}") - expect(page).not_to have_content('to yourself') - end - end - end - - context 'approval todo' do - let(:merge_request) { create(:merge_request) } - - before do - create(:todo, :approval_required, user: user, project: project, target: merge_request, author: user) - visit dashboard_todos_path - end - - it 'shows you set yourself as an approver message' do - page.within('.js-todos-all') do - expect(page).to have_content("You set yourself as an approver for merge request #{merge_request.to_reference(full: true)}") - expect(page).not_to have_content('to yourself') - end - end - end - end - - context 'User has done todos', js: true do - before do - create(:todo, :mentioned, :done, user: user, project: project, target: issue, author: author) - gitlab_sign_in(user) - visit dashboard_todos_path(state: :done) - end - - it 'has the done todo present' do - expect(page).to have_selector('.todos-list .todo.todo-done', count: 1) - end - - describe 'restoring the todo' do - before do - within first('.todo') do - click_link 'Add todo' - end - end - - it 'is removed from the list' do - expect(page).not_to have_selector('.todos-list .todo.todo-done') - end - - it 'updates todo count' do - expect(page).to have_content 'To do 1' - expect(page).to have_content 'Done 0' - end - end - end - - context 'User has Todos with labels spanning multiple projects' do - before do - label1 = create(:label, project: project) - note1 = create(:note_on_issue, note: "Hello #{label1.to_reference(format: :name)}", noteable_id: issue.id, noteable_type: 'Issue', project: issue.project) - create(:todo, :mentioned, project: project, target: issue, user: user, note_id: note1.id) - - project2 = create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) - label2 = create(:label, project: project2) - issue2 = create(:issue, project: project2) - note2 = create(:note_on_issue, note: "Test #{label2.to_reference(format: :name)}", noteable_id: issue2.id, noteable_type: 'Issue', project: project2) - create(:todo, :mentioned, project: project2, target: issue2, user: user, note_id: note2.id) - - gitlab_sign_in(user) - visit dashboard_todos_path - end - - it 'shows page with two Todos' do - expect(page).to have_selector('.todos-list .todo', count: 2) - end - end - - context 'User has multiple pages of Todos' do - before do - allow(Todo).to receive(:default_per_page).and_return(1) - - # Create just enough records to cause us to paginate - create_list(:todo, 2, :mentioned, user: user, project: project, target: issue, author: author) - - gitlab_sign_in(user) - end - - it 'is paginated' do - visit dashboard_todos_path - - expect(page).to have_selector('.gl-pagination') - end - - it 'is has the right number of pages' do - visit dashboard_todos_path - - expect(page).to have_selector('.gl-pagination .page', count: 2) - end - - describe 'mark all as done', js: true do - before do - visit dashboard_todos_path - find('.js-todos-mark-all').trigger('click') - end - - it 'shows "All done" message!' do - expect(page).to have_content 'To do 0' - expect(page).to have_content "You're all done!" - expect(page).not_to have_selector('.gl-pagination') - end - - it 'shows "Undo mark all as done" button' do - expect(page).to have_selector('.js-todos-mark-all', visible: false) - expect(page).to have_selector('.js-todos-undo-all', visible: true) - end - end - - describe 'undo mark all as done', js: true do - before do - visit dashboard_todos_path - end - - it 'shows the restored todo list' do - mark_all_and_undo - - expect(page).to have_selector('.todos-list .todo', count: 1) - expect(page).to have_selector('.gl-pagination') - expect(page).not_to have_content "You're all done!" - end - - it 'updates todo count' do - mark_all_and_undo - - expect(page).to have_content 'To do 2' - expect(page).to have_content 'Done 0' - end - - it 'shows "Mark all as done" button' do - mark_all_and_undo - - expect(page).to have_selector('.js-todos-mark-all', visible: true) - expect(page).to have_selector('.js-todos-undo-all', visible: false) - end - - context 'User has deleted a todo' do - before do - within first('.todo') do - click_link 'Done' - end - end - - it 'shows the restored todo list with the deleted todo' do - mark_all_and_undo - - expect(page).to have_selector('.todos-list .todo.todo-pending', count: 1) - end - end - - def mark_all_and_undo - find('.js-todos-mark-all').trigger('click') - wait_for_requests - find('.js-todos-undo-all').trigger('click') - wait_for_requests - end - end - end - - context 'User has a Todo in a project pending deletion' do - before do - deleted_project = create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC, pending_delete: true) - create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author) - create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author, state: :done) - gitlab_sign_in(user) - visit dashboard_todos_path - end - - it 'shows "All done" message' do - within('.todos-count') { expect(page).to have_content '0' } - expect(page).to have_content 'To do 0' - expect(page).to have_content 'Done 0' - expect(page).to have_selector('.todos-all-done', count: 1) - end - end - - context 'User has a Build Failed todo' do - let!(:todo) { create(:todo, :build_failed, user: user, project: project, author: author) } - - before do - gitlab_sign_in user - visit dashboard_todos_path - end - - it 'shows the todo' do - expect(page).to have_content 'The build failed for merge request' - end - - it 'links to the pipelines for the merge request' do - href = pipelines_namespace_project_merge_request_path(project.namespace, project, todo.target) - - expect(page).to have_link "merge request #{todo.target.to_reference(full: true)}", href - end - end - end -end diff --git a/spec/fixtures/api/schemas/prometheus/additional_metrics_query_result.json b/spec/fixtures/api/schemas/prometheus/additional_metrics_query_result.json new file mode 100644 index 00000000000..47b5d283b8c --- /dev/null +++ b/spec/fixtures/api/schemas/prometheus/additional_metrics_query_result.json @@ -0,0 +1,58 @@ +{ + "items": { + "properties": { + "group": { + "type": "string" + }, + "metrics": { + "items": { + "properties": { + "queries": { + "items": { + "properties": { + "query_range": { + "type": "string" + }, + "query": { + "type": "string" + }, + "result": { + "type": "any" + } + }, + "type": "object" + }, + "type": "array" + }, + "title": { + "type": "string" + }, + "weight": { + "type": "integer" + }, + "y_label": { + "type": "string" + } + }, + "type": "object" + }, + "required": [ + "metrics", + "title", + "weight" + ], + "type": "array" + }, + "priority": { + "type": "integer" + } + }, + "type": "object" + }, + "required": [ + "group", + "priority", + "metrics" + ], + "type": "array" +}
\ No newline at end of file diff --git a/spec/fixtures/emails/html_empty_link.eml b/spec/fixtures/emails/html_empty_link.eml new file mode 100644 index 00000000000..1672b98b925 --- /dev/null +++ b/spec/fixtures/emails/html_empty_link.eml @@ -0,0 +1,26 @@ + +MIME-Version: 1.0 +Received: by 10.25.161.144 with HTTP; Tue, 7 Oct 2014 22:17:17 -0700 (PDT) +X-Originating-IP: [117.207.85.84] +In-Reply-To: <5434c8b52bb3a_623ff09fec70f049749@discourse-app.mail> +References: <topic/35@discourse.techapj.com> + <5434c8b52bb3a_623ff09fec70f049749@discourse-app.mail> +Date: Wed, 8 Oct 2014 10:47:17 +0530 +Delivered-To: arpit@techapj.com +Message-ID: <CAOJeqne=SJ_LwN4sb-0Y95ejc2OpreVhdmcPn0TnmwSvTCYzzQ@mail.gmail.com> +Subject: Re: [Discourse] [Meta] Welcome to techAPJ's Discourse! +From: Arpit Jalan <arpit@techapj.com> +To: Discourse <mail+e1c7f2a380e33840aeb654f075490bad@arpitjalan.com>Accept-Language: en-US +Content-Language: en-US +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +x-originating-ip: [134.68.31.227] +Content-Type: multipart/alternative; + boundary="_000_B0DFE1BEB3739743BC9B639D0E6BC8FF217A6341IUMSSGMBX104ads_" +MIME-Version: 1.0 + +--_000_B0DFE1BEB3739743BC9B639D0E6BC8FF217A6341IUMSSGMBX104ads_ +Content-Type: text/html; charset="utf-8" + +<a name="_MailEndCompose">no brackets!</a> +--_000_B0DFE1BEB3739743BC9B639D0E6BC8FF217A6341IUMSSGMBX104ads_-- diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index cc7f889b927..56daeffde27 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -61,14 +61,14 @@ describe ApplicationHelper do project = create(:empty_project, avatar: File.open(uploaded_image_temp_path)) avatar_url = "/uploads/system/project/avatar/#{project.id}/banana_sample.gif" - expect(helper.project_icon(project.full_path).to_s). - to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />" + expect(helper.project_icon(project.full_path).to_s) + .to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />" allow(ActionController::Base).to receive(:asset_host).and_return(gitlab_host) avatar_url = "#{gitlab_host}/uploads/system/project/avatar/#{project.id}/banana_sample.gif" - expect(helper.project_icon(project.full_path).to_s). - to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />" + expect(helper.project_icon(project.full_path).to_s) + .to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />" end it 'gives uploaded icon when present' do @@ -82,42 +82,71 @@ describe ApplicationHelper do end describe 'avatar_icon' do - it 'returns an url for the avatar' do - user = create(:user, avatar: File.open(uploaded_image_temp_path)) - - avatar_url = "/uploads/system/user/avatar/#{user.id}/banana_sample.gif" - - expect(helper.avatar_icon(user.email).to_s).to match(avatar_url) - - allow(ActionController::Base).to receive(:asset_host).and_return(gitlab_host) - avatar_url = "#{gitlab_host}/uploads/system/user/avatar/#{user.id}/banana_sample.gif" - - expect(helper.avatar_icon(user.email).to_s).to match(avatar_url) - end - - it 'returns an url for the avatar with relative url' do - stub_config_setting(relative_url_root: '/gitlab') - # Must be stubbed after the stub above, and separately - stub_config_setting(url: Settings.send(:build_gitlab_url)) - - user = create(:user, avatar: File.open(uploaded_image_temp_path)) - - expect(helper.avatar_icon(user.email).to_s). - to match("/gitlab/uploads/system/user/avatar/#{user.id}/banana_sample.gif") - end + let(:user) { create(:user, avatar: File.open(uploaded_image_temp_path)) } + + context 'using an email' do + context 'when there is a matching user' do + it 'returns a relative URL for the avatar' do + expect(helper.avatar_icon(user.email).to_s) + .to eq("/uploads/system/user/avatar/#{user.id}/banana_sample.gif") + end + + context 'when an asset_host is set in the config' do + let(:asset_host) { 'http://assets' } + + before do + allow(ActionController::Base).to receive(:asset_host).and_return(asset_host) + end + + it 'returns an absolute URL on that asset host' do + expect(helper.avatar_icon(user.email, only_path: false).to_s) + .to eq("#{asset_host}/uploads/system/user/avatar/#{user.id}/banana_sample.gif") + end + end + + context 'when only_path is set to false' do + it 'returns an absolute URL for the avatar' do + expect(helper.avatar_icon(user.email, only_path: false).to_s) + .to eq("#{gitlab_host}/uploads/system/user/avatar/#{user.id}/banana_sample.gif") + end + end + + context 'when the GitLab instance is at a relative URL' do + before do + stub_config_setting(relative_url_root: '/gitlab') + # Must be stubbed after the stub above, and separately + stub_config_setting(url: Settings.send(:build_gitlab_url)) + end + + it 'returns a relative URL with the correct prefix' do + expect(helper.avatar_icon(user.email).to_s) + .to eq("/gitlab/uploads/system/user/avatar/#{user.id}/banana_sample.gif") + end + end + end - it 'calls gravatar_icon when no User exists with the given email' do - expect(helper).to receive(:gravatar_icon).with('foo@example.com', 20, 2) + context 'when no user exists for the email' do + it 'calls gravatar_icon' do + expect(helper).to receive(:gravatar_icon).with('foo@example.com', 20, 2) - helper.avatar_icon('foo@example.com', 20, 2) + helper.avatar_icon('foo@example.com', 20, 2) + end + end end - describe 'using a User' do - it 'returns an URL for the avatar' do - user = create(:user, avatar: File.open(uploaded_image_temp_path)) + describe 'using a user' do + context 'when only_path is true' do + it 'returns a relative URL for the avatar' do + expect(helper.avatar_icon(user, only_path: true).to_s) + .to eq("/uploads/system/user/avatar/#{user.id}/banana_sample.gif") + end + end - expect(helper.avatar_icon(user).to_s). - to match("/uploads/system/user/avatar/#{user.id}/banana_sample.gif") + context 'when only_path is false' do + it 'returns an absolute URL for the avatar' do + expect(helper.avatar_icon(user, only_path: false).to_s) + .to eq("#{gitlab_host}/uploads/system/user/avatar/#{user.id}/banana_sample.gif") + end end end end @@ -147,22 +176,22 @@ describe ApplicationHelper do it 'returns a valid Gravatar URL' do stub_config_setting(https: false) - expect(helper.gravatar_icon(user_email)). - to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118') + expect(helper.gravatar_icon(user_email)) + .to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118') end it 'uses HTTPs when configured' do stub_config_setting(https: true) - expect(helper.gravatar_icon(user_email)). - to match('https://secure.gravatar.com') + expect(helper.gravatar_icon(user_email)) + .to match('https://secure.gravatar.com') end it 'returns custom gravatar path when gravatar_url is set' do stub_gravatar_setting(plain_url: 'http://example.local/?s=%{size}&hash=%{hash}') - expect(gravatar_icon(user_email, 20)). - to eq('http://example.local/?s=40&hash=b58c6f14d292556214bd64909bcdb118') + expect(gravatar_icon(user_email, 20)) + .to eq('http://example.local/?s=40&hash=b58c6f14d292556214bd64909bcdb118') end it 'accepts a custom size argument' do @@ -234,8 +263,8 @@ describe ApplicationHelper do end it 'accepts a custom html_class' do - expect(element(html_class: 'custom_class').attr('class')). - to eq 'js-timeago custom_class' + expect(element(html_class: 'custom_class').attr('class')) + .to eq 'js-timeago custom_class' end it 'accepts a custom tooltip placement' do diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb index c6e3c5c2368..9bec0f9f432 100644 --- a/spec/helpers/broadcast_messages_helper_spec.rb +++ b/spec/helpers/broadcast_messages_helper_spec.rb @@ -33,8 +33,8 @@ describe BroadcastMessagesHelper do it 'allows custom style' do broadcast_message = double(color: '#f2dede', font: '#b94a48') - expect(helper.broadcast_message_style(broadcast_message)). - to match('background-color: #f2dede; color: #b94a48') + expect(helper.broadcast_message_style(broadcast_message)) + .to match('background-color: #f2dede; color: #b94a48') end end diff --git a/spec/helpers/button_helper_spec.rb b/spec/helpers/button_helper_spec.rb new file mode 100644 index 00000000000..661327d4432 --- /dev/null +++ b/spec/helpers/button_helper_spec.rb @@ -0,0 +1,65 @@ +require 'spec_helper' + +describe ButtonHelper do + describe 'http_clone_button' do + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:has_tooltip_class) { 'has-tooltip' } + + def element + element = helper.http_clone_button(project) + + Nokogiri::HTML::DocumentFragment.parse(element).first_element_child + end + + before do + allow(helper).to receive(:current_user).and_return(user) + end + + context 'with internal auth enabled' do + context 'when user has a password' do + it 'shows no tooltip' do + expect(element.attr('class')).not_to include(has_tooltip_class) + end + end + + context 'when user has password automatically set' do + let(:user) { create(:user, password_automatically_set: true) } + + it 'shows a password tooltip' do + expect(element.attr('class')).to include(has_tooltip_class) + expect(element.attr('data-title')).to eq('Set a password on your account to pull or push via HTTP.') + end + end + end + + context 'with internal auth disabled' do + before do + stub_application_setting(signin_enabled?: false) + end + + context 'when user has no personal access tokens' do + it 'has a personal access token tooltip ' do + expect(element.attr('class')).to include(has_tooltip_class) + expect(element.attr('data-title')).to eq('Create a personal access token on your account to pull or push via HTTP.') + end + end + + context 'when user has a personal access token' do + it 'shows no tooltip' do + create(:personal_access_token, user: user) + + expect(element.attr('class')).not_to include(has_tooltip_class) + end + end + end + + context 'when user is ldap user' do + let(:user) { create(:omniauth_user, password_automatically_set: true) } + + it 'shows no tooltip' do + expect(element.attr('class')).not_to include(has_tooltip_class) + end + end + end +end diff --git a/spec/helpers/commits_helper_spec.rb b/spec/helpers/commits_helper_spec.rb index a2c008790f9..c245bb439db 100644 --- a/spec/helpers/commits_helper_spec.rb +++ b/spec/helpers/commits_helper_spec.rb @@ -9,8 +9,8 @@ describe CommitsHelper do author_email: 'my@email.com" onmouseover="alert(1)' ) - expect(helper.commit_author_link(commit)). - not_to include('onmouseover="alert(1)"') + expect(helper.commit_author_link(commit)) + .not_to include('onmouseover="alert(1)"') end end @@ -22,8 +22,8 @@ describe CommitsHelper do committer_email: 'my@email.com" onmouseover="alert(1)' ) - expect(helper.commit_committer_link(commit)). - not_to include('onmouseover="alert(1)"') + expect(helper.commit_committer_link(commit)) + .not_to include('onmouseover="alert(1)"') end end diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb index b20373a96fb..18cf0031d5f 100644 --- a/spec/helpers/form_helper_spec.rb +++ b/spec/helpers/form_helper_spec.rb @@ -11,18 +11,18 @@ describe FormHelper do it 'renders an alert div' do model = double(errors: errors_stub('Error 1')) - expect(helper.form_errors(model)). - to include('<div class="alert alert-danger" id="error_explanation">') + expect(helper.form_errors(model)) + .to include('<div class="alert alert-danger" id="error_explanation">') end it 'contains a summary message' do single_error = double(errors: errors_stub('A')) multi_errors = double(errors: errors_stub('A', 'B', 'C')) - expect(helper.form_errors(single_error)). - to include('<h4>The form contains the following error:') - expect(helper.form_errors(multi_errors)). - to include('<h4>The form contains the following errors:') + expect(helper.form_errors(single_error)) + .to include('<h4>The form contains the following error:') + expect(helper.form_errors(multi_errors)) + .to include('<h4>The form contains the following errors:') end it 'renders each message' do diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index 0337afa4452..8da22dc78fa 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe GroupsHelper do + include ApplicationHelper + describe 'group_icon' do avatar_file_path = File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif') @@ -8,8 +10,8 @@ describe GroupsHelper do group = create(:group) group.avatar = fixture_file_upload(avatar_file_path) group.save! - expect(group_icon(group.path).to_s). - to match("/uploads/system/group/avatar/#{group.id}/banana_sample.gif") + expect(group_icon(group.path).to_s) + .to match("/uploads/system/group/avatar/#{group.id}/banana_sample.gif") end it 'gives default avatar_icon when no avatar is present' do @@ -81,4 +83,15 @@ describe GroupsHelper do end end end + + describe 'group_title', :nested_groups do + let(:group) { create(:group) } + let(:nested_group) { create(:group, parent: group) } + let(:deep_nested_group) { create(:group, parent: nested_group) } + let!(:very_deep_nested_group) { create(:group, parent: deep_nested_group) } + + it 'outputs the groups in the correct order' do + expect(group_title(very_deep_nested_group)).to match(/>#{group.name}<\/a>.*>#{nested_group.name}<\/a>.*>#{deep_nested_group.name}<\/a>/) + end + end end diff --git a/spec/helpers/import_helper_spec.rb b/spec/helpers/import_helper_spec.rb index 10f293cddf5..9afff47f4e9 100644 --- a/spec/helpers/import_helper_spec.rb +++ b/spec/helpers/import_helper_spec.rb @@ -29,21 +29,21 @@ describe ImportHelper do context 'when provider is "github"' do context 'when provider does not specify a custom URL' do it 'uses default GitHub URL' do - allow(Gitlab.config.omniauth).to receive(:providers). - and_return([Settingslogic.new('name' => 'github')]) + allow(Gitlab.config.omniauth).to receive(:providers) + .and_return([Settingslogic.new('name' => 'github')]) - expect(helper.provider_project_link('github', 'octocat/Hello-World')). - to include('href="https://github.com/octocat/Hello-World"') + expect(helper.provider_project_link('github', 'octocat/Hello-World')) + .to include('href="https://github.com/octocat/Hello-World"') end end context 'when provider specify a custom URL' do it 'uses custom URL' do - allow(Gitlab.config.omniauth).to receive(:providers). - and_return([Settingslogic.new('name' => 'github', 'url' => 'https://github.company.com')]) + allow(Gitlab.config.omniauth).to receive(:providers) + .and_return([Settingslogic.new('name' => 'github', 'url' => 'https://github.company.com')]) - expect(helper.provider_project_link('github', 'octocat/Hello-World')). - to include('href="https://github.company.com/octocat/Hello-World"') + expect(helper.provider_project_link('github', 'octocat/Hello-World')) + .to include('href="https://github.company.com/octocat/Hello-World"') end end end @@ -54,8 +54,8 @@ describe ImportHelper do end it 'uses given host' do - expect(helper.provider_project_link('gitea', 'octocat/Hello-World')). - to include('href="https://try.gitea.io/octocat/Hello-World"') + expect(helper.provider_project_link('gitea', 'octocat/Hello-World')) + .to include('href="https://try.gitea.io/octocat/Hello-World"') end end end diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb index 8fcf7f5fa15..15cb620199d 100644 --- a/spec/helpers/issuables_helper_spec.rb +++ b/spec/helpers/issuables_helper_spec.rb @@ -40,23 +40,23 @@ describe IssuablesHelper do end it 'returns "Open" when state is :opened' do - expect(helper.issuables_state_counter_text(:issues, :opened)). - to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)) + .to eq('<span>Open</span> <span class="badge">42</span>') end it 'returns "Closed" when state is :closed' do - expect(helper.issuables_state_counter_text(:issues, :closed)). - to eq('<span>Closed</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :closed)) + .to eq('<span>Closed</span> <span class="badge">42</span>') end it 'returns "Merged" when state is :merged' do - expect(helper.issuables_state_counter_text(:merge_requests, :merged)). - to eq('<span>Merged</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:merge_requests, :merged)) + .to eq('<span>Merged</span> <span class="badge">42</span>') end it 'returns "All" when state is :all' do - expect(helper.issuables_state_counter_text(:merge_requests, :all)). - to eq('<span>All</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:merge_requests, :all)) + .to eq('<span>All</span> <span class="badge">42</span>') end end @@ -81,13 +81,13 @@ describe IssuablesHelper do expect(helper).to receive(:params).twice.and_return(params) expect(helper).to receive(:issuables_count_for_state).with(:issues, :opened).and_return(42) - expect(helper.issuables_state_counter_text(:issues, :opened)). - to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)) + .to eq('<span>Open</span> <span class="badge">42</span>') expect(helper).not_to receive(:issuables_count_for_state) - expect(helper.issuables_state_counter_text(:issues, :opened)). - to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)) + .to eq('<span>Open</span> <span class="badge">42</span>') end it 'does not take some keys into account in the cache key' do @@ -100,8 +100,8 @@ describe IssuablesHelper do }.with_indifferent_access) expect(helper).to receive(:issuables_count_for_state).with(:issues, :opened).and_return(42) - expect(helper.issuables_state_counter_text(:issues, :opened)). - to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)) + .to eq('<span>Open</span> <span class="badge">42</span>') expect(helper).to receive(:params).and_return({ author_id: '11', @@ -112,22 +112,22 @@ describe IssuablesHelper do }.with_indifferent_access) expect(helper).not_to receive(:issuables_count_for_state) - expect(helper.issuables_state_counter_text(:issues, :opened)). - to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)) + .to eq('<span>Open</span> <span class="badge">42</span>') end it 'does not take params order into account in the cache key' do expect(helper).to receive(:params).and_return('author_id' => '11', 'state' => 'opened') expect(helper).to receive(:issuables_count_for_state).with(:issues, :opened).and_return(42) - expect(helper.issuables_state_counter_text(:issues, :opened)). - to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)) + .to eq('<span>Open</span> <span class="badge">42</span>') expect(helper).to receive(:params).and_return('state' => 'opened', 'author_id' => '11') expect(helper).not_to receive(:issuables_count_for_state) - expect(helper.issuables_state_counter_text(:issues, :opened)). - to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)) + .to eq('<span>Open</span> <span class="badge">42</span>') end end end diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 540cb0ab1e0..00db98fd9d2 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -93,8 +93,8 @@ describe IssuesHelper do award = build_stubbed(:award_emoji, user: build_stubbed(:user, name: 'Jane')) awards = Array.new(5, award).push(my_award) - expect(award_user_list(awards, current_user, limit: 2)). - to eq("You, Jane, and 4 more.") + expect(award_user_list(awards, current_user, limit: 2)) + .to eq("You, Jane, and 4 more.") end end diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb index 7cf535fadae..a8d6044fda7 100644 --- a/spec/helpers/labels_helper_spec.rb +++ b/spec/helpers/labels_helper_spec.rb @@ -55,8 +55,8 @@ describe LabelsHelper do context 'without block' do it 'uses render_colored_label as the link content' do - expect(self).to receive(:render_colored_label). - with(label, tooltip: true).and_return('Foo') + expect(self).to receive(:render_colored_label) + .with(label, tooltip: true).and_return('Foo') expect(link_to_label(label)).to match('Foo') end end diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb index 2a0de0b0656..b4226f96a04 100644 --- a/spec/helpers/markup_helper_spec.rb +++ b/spec/helpers/markup_helper_spec.rb @@ -68,8 +68,8 @@ describe MarkupHelper do expect(doc.css('a')[0].text).to eq 'This should finally fix ' # First issue link - expect(doc.css('a')[1].attr('href')). - to eq namespace_project_issue_path(project.namespace, project, issues[0]) + expect(doc.css('a')[1].attr('href')) + .to eq namespace_project_issue_path(project.namespace, project, issues[0]) expect(doc.css('a')[1].text).to eq issues[0].to_reference # Internal commit link @@ -77,8 +77,8 @@ describe MarkupHelper do expect(doc.css('a')[2].text).to eq ' and ' # Second issue link - expect(doc.css('a')[3].attr('href')). - to eq namespace_project_issue_path(project.namespace, project, issues[1]) + expect(doc.css('a')[3].attr('href')) + .to eq namespace_project_issue_path(project.namespace, project, issues[1]) expect(doc.css('a')[3].text).to eq issues[1].to_reference # Trailing commit link @@ -98,8 +98,8 @@ describe MarkupHelper do it "escapes HTML passed in as the body" do actual = "This is a <h1>test</h1> - see #{issues[0].to_reference}" - expect(helper.link_to_gfm(actual, link)). - to match('<h1>test</h1>') + expect(helper.link_to_gfm(actual, link)) + .to match('<h1>test</h1>') end it 'ignores reference links when they are the entire body' do @@ -110,8 +110,8 @@ describe MarkupHelper do it 'replaces commit message with emoji to link' do actual = link_to_gfm(':book: Book', '/foo') - expect(actual). - to eq '<gl-emoji title="open book" data-name="book" data-unicode-version="6.0">📖</gl-emoji><a href="/foo"> Book</a>' + expect(actual) + .to eq '<gl-emoji title="open book" data-name="book" data-unicode-version="6.0">📖</gl-emoji><a href="/foo"> Book</a>' end end diff --git a/spec/helpers/merge_requests_helper_spec.rb b/spec/helpers/merge_requests_helper_spec.rb index f2c9d927388..493a4ff9a93 100644 --- a/spec/helpers/merge_requests_helper_spec.rb +++ b/spec/helpers/merge_requests_helper_spec.rb @@ -15,8 +15,8 @@ describe MergeRequestsHelper do end it 'does not include api credentials in a link' do - allow(ci_service). - to receive(:build_page).and_return("http://secretuser:secretpass@jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c") + allow(ci_service) + .to receive(:build_page).and_return("http://secretuser:secretpass@jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c") expect(helper.ci_build_details_path(merge_request)).not_to match("secret") end end diff --git a/spec/helpers/page_layout_helper_spec.rb b/spec/helpers/page_layout_helper_spec.rb index dff2784f21f..95b4032616e 100644 --- a/spec/helpers/page_layout_helper_spec.rb +++ b/spec/helpers/page_layout_helper_spec.rb @@ -86,8 +86,8 @@ describe PageLayoutHelper do it 'raises ArgumentError when given more than two attributes' do map = { foo: 'foo', bar: 'bar', baz: 'baz' } - expect { helper.page_card_attributes(map) }. - to raise_error(ArgumentError, /more than two attributes/) + expect { helper.page_card_attributes(map) } + .to raise_error(ArgumentError, /more than two attributes/) end it 'rejects blank values' do diff --git a/spec/helpers/preferences_helper_spec.rb b/spec/helpers/preferences_helper_spec.rb index 2c0e9975f73..a04c87b08eb 100644 --- a/spec/helpers/preferences_helper_spec.rb +++ b/spec/helpers/preferences_helper_spec.rb @@ -29,15 +29,15 @@ describe PreferencesHelper do describe 'user_color_scheme' do context 'with a user' do it "returns user's scheme's css_class" do - allow(helper).to receive(:current_user). - and_return(double(color_scheme_id: 3)) + allow(helper).to receive(:current_user) + .and_return(double(color_scheme_id: 3)) expect(helper.user_color_scheme).to eq 'solarized-light' end it 'returns the default when id is invalid' do - allow(helper).to receive(:current_user). - and_return(double(color_scheme_id: Gitlab::ColorSchemes.count + 5)) + allow(helper).to receive(:current_user) + .and_return(double(color_scheme_id: Gitlab::ColorSchemes.count + 5)) end end @@ -45,8 +45,8 @@ describe PreferencesHelper do it 'returns the default theme' do stub_user - expect(helper.user_color_scheme). - to eq Gitlab::ColorSchemes.default.css_class + expect(helper.user_color_scheme) + .to eq Gitlab::ColorSchemes.default.css_class end end end @@ -55,8 +55,8 @@ describe PreferencesHelper do if messages.empty? allow(helper).to receive(:current_user).and_return(nil) else - allow(helper).to receive(:current_user). - and_return(double('user', messages)) + allow(helper).to receive(:current_user) + .and_return(double('user', messages)) end end diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 9a4086725d2..487d9800707 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -115,6 +115,82 @@ describe ProjectsHelper do end end + describe '#show_no_ssh_key_message?' do + let(:user) { create(:user) } + + before do + allow(helper).to receive(:current_user).and_return(user) + end + + context 'user has no keys' do + it 'returns true' do + expect(helper.show_no_ssh_key_message?).to be_truthy + end + end + + context 'user has an ssh key' do + it 'returns false' do + create(:personal_key, user: user) + + expect(helper.show_no_ssh_key_message?).to be_falsey + end + end + end + + describe '#show_no_password_message?' do + let(:user) { create(:user) } + + before do + allow(helper).to receive(:current_user).and_return(user) + end + + context 'user has password set' do + it 'returns false' do + expect(helper.show_no_password_message?).to be_falsey + end + end + + context 'user requires a password' do + let(:user) { create(:user, password_automatically_set: true) } + + it 'returns true' do + expect(helper.show_no_password_message?).to be_truthy + end + end + + context 'user requires a personal access token' do + it 'returns true' do + stub_application_setting(signin_enabled?: false) + + expect(helper.show_no_password_message?).to be_truthy + end + end + end + + describe '#link_to_set_password' do + before do + allow(helper).to receive(:current_user).and_return(user) + end + + context 'user requires a password' do + let(:user) { create(:user, password_automatically_set: true) } + + it 'returns link to set a password' do + expect(helper.link_to_set_password).to match %r{<a href="#{edit_profile_password_path}">set a password</a>} + end + end + + context 'user requires a personal access token' do + let(:user) { create(:user) } + + it 'returns link to create a personal access token' do + stub_application_setting(signin_enabled?: false) + + expect(helper.link_to_set_password).to match %r{<a href="#{profile_personal_access_tokens_path}">create a personal access token</a>} + end + end + end + describe 'link_to_member' do let(:group) { create(:group) } let(:project) { create(:empty_project, group: group) } diff --git a/spec/javascripts/behaviors/gl_emoji/unicode_support_map_spec.js b/spec/javascripts/behaviors/gl_emoji/unicode_support_map_spec.js index 1ed96a67478..ec2c549e032 100644 --- a/spec/javascripts/behaviors/gl_emoji/unicode_support_map_spec.js +++ b/spec/javascripts/behaviors/gl_emoji/unicode_support_map_spec.js @@ -1,4 +1,4 @@ -import { getUnicodeSupportMap } from '~/behaviors/gl_emoji/unicode_support_map'; +import getUnicodeSupportMap from '~/emoji/support/unicode_support_map'; import AccessorUtilities from '~/lib/utils/accessor'; describe('Unicode Support Map', () => { diff --git a/spec/javascripts/behaviors/quick_submit_spec.js b/spec/javascripts/behaviors/quick_submit_spec.js index f56b99f8a16..6dc48f9a293 100644 --- a/spec/javascripts/behaviors/quick_submit_spec.js +++ b/spec/javascripts/behaviors/quick_submit_spec.js @@ -40,16 +40,29 @@ import '~/behaviors/quick_submit'; it('disables input of type submit', function() { const submitButton = $('.js-quick-submit input[type=submit]'); this.textarea.trigger(keydownEvent()); + expect(submitButton).toBeDisabled(); }); it('disables button of type submit', function() { - // button doesn't exist in fixture, add it manually - const submitButton = $('<button type="submit">Submit it</button>'); - submitButton.insertAfter(this.textarea); - + const submitButton = $('.js-quick-submit input[type=submit]'); this.textarea.trigger(keydownEvent()); + expect(submitButton).toBeDisabled(); }); + it('only clicks one submit', function() { + const existingSubmit = $('.js-quick-submit input[type=submit]'); + // Add an extra submit button + const newSubmit = $('<button type="submit">Submit it</button>'); + newSubmit.insertAfter(this.textarea); + + const oldClick = spyOnEvent(existingSubmit, 'click'); + const newClick = spyOnEvent(newSubmit, 'click'); + + this.textarea.trigger(keydownEvent()); + + expect(oldClick).not.toHaveBeenTriggered(); + expect(newClick).toHaveBeenTriggered(); + }); // We cannot stub `navigator.userAgent` for CI's `rake karma` task, so we'll // only run the tests that apply to the current platform if (navigator.userAgent.match(/Macintosh/)) { diff --git a/spec/javascripts/boards/board_new_issue_spec.js b/spec/javascripts/boards/board_new_issue_spec.js index 832877de71c..c0a7323a505 100644 --- a/spec/javascripts/boards/board_new_issue_spec.js +++ b/spec/javascripts/boards/board_new_issue_spec.js @@ -12,6 +12,7 @@ import './mock_data'; describe('Issue boards new issue form', () => { let vm; let list; + let newIssueMock; const promiseReturn = { json() { return { @@ -21,7 +22,11 @@ describe('Issue boards new issue form', () => { }; const submitIssue = () => { - vm.$el.querySelector('.btn-success').click(); + const dummySubmitEvent = { + preventDefault() {}, + }; + vm.$refs.submitButton = vm.$el.querySelector('.btn-success'); + return vm.submit(dummySubmitEvent); }; beforeEach((done) => { @@ -32,29 +37,35 @@ describe('Issue boards new issue form', () => { gl.issueBoards.BoardsStore.create(); gl.IssueBoardsApp = new Vue(); - setTimeout(() => { - list = new List(listObj); - - spyOn(gl.boardService, 'newIssue').and.callFake(() => new Promise((resolve, reject) => { - if (vm.title === 'error') { - reject(); - } else { - resolve(promiseReturn); - } - })); - - vm = new BoardNewIssueComp({ - propsData: { - list, - }, - }).$mount(); - - done(); - }, 0); + list = new List(listObj); + + newIssueMock = Promise.resolve(promiseReturn); + spyOn(list, 'newIssue').and.callFake(() => newIssueMock); + + vm = new BoardNewIssueComp({ + propsData: { + list, + }, + }).$mount(); + + Vue.nextTick() + .then(done) + .catch(done.fail); }); - afterEach(() => { - Vue.http.interceptors = _.without(Vue.http.interceptors, boardsMockInterceptor); + it('calls submit if submit button is clicked', (done) => { + spyOn(vm, 'submit'); + vm.title = 'Testing Title'; + + Vue.nextTick() + .then(() => { + vm.$el.querySelector('.btn-success').click(); + + expect(vm.submit.calls.count()).toBe(1); + expect(vm.$refs['submit-button']).toBe(vm.$el.querySelector('.btn-success')); + }) + .then(done) + .catch(done.fail); }); it('disables submit button if title is empty', () => { @@ -64,136 +75,122 @@ describe('Issue boards new issue form', () => { it('enables submit button if title is not empty', (done) => { vm.title = 'Testing Title'; - setTimeout(() => { - expect(vm.$el.querySelector('.form-control').value).toBe('Testing Title'); - expect(vm.$el.querySelector('.btn-success').disabled).not.toBe(true); - - done(); - }, 0); + Vue.nextTick() + .then(() => { + expect(vm.$el.querySelector('.form-control').value).toBe('Testing Title'); + expect(vm.$el.querySelector('.btn-success').disabled).not.toBe(true); + }) + .then(done) + .catch(done.fail); }); it('clears title after clicking cancel', (done) => { vm.$el.querySelector('.btn-default').click(); - setTimeout(() => { - expect(vm.title).toBe(''); - done(); - }, 0); + Vue.nextTick() + .then(() => { + expect(vm.title).toBe(''); + }) + .then(done) + .catch(done.fail); }); it('does not create new issue if title is empty', (done) => { - submitIssue(); - - setTimeout(() => { - expect(gl.boardService.newIssue).not.toHaveBeenCalled(); - done(); - }, 0); + submitIssue() + .then(() => { + expect(list.newIssue).not.toHaveBeenCalled(); + }) + .then(done) + .catch(done.fail); }); describe('submit success', () => { it('creates new issue', (done) => { vm.title = 'submit title'; - setTimeout(() => { - submitIssue(); - - expect(gl.boardService.newIssue).toHaveBeenCalled(); - done(); - }, 0); + Vue.nextTick() + .then(submitIssue) + .then(() => { + expect(list.newIssue).toHaveBeenCalled(); + }) + .then(done) + .catch(done.fail); }); it('enables button after submit', (done) => { vm.title = 'submit issue'; - setTimeout(() => { - submitIssue(); - - expect(vm.$el.querySelector('.btn-success').disabled).toBe(false); - done(); - }, 0); + Vue.nextTick() + .then(submitIssue) + .then(() => { + expect(vm.$el.querySelector('.btn-success').disabled).toBe(false); + }) + .then(done) + .catch(done.fail); }); it('clears title after submit', (done) => { vm.title = 'submit issue'; - Vue.nextTick(() => { - submitIssue(); - - setTimeout(() => { + Vue.nextTick() + .then(submitIssue) + .then(() => { expect(vm.title).toBe(''); - done(); - }, 0); - }); - }); - - it('adds new issue to top of list after submit request', (done) => { - vm.title = 'submit issue'; - - setTimeout(() => { - submitIssue(); - - setTimeout(() => { - expect(list.issues.length).toBe(2); - expect(list.issues[0].title).toBe('submit issue'); - expect(list.issues[0].subscribed).toBe(true); - done(); - }, 0); - }, 0); + }) + .then(done) + .catch(done.fail); }); it('sets detail issue after submit', (done) => { expect(gl.issueBoards.BoardsStore.detail.issue.title).toBe(undefined); vm.title = 'submit issue'; - setTimeout(() => { - submitIssue(); - - setTimeout(() => { + Vue.nextTick() + .then(submitIssue) + .then(() => { expect(gl.issueBoards.BoardsStore.detail.issue.title).toBe('submit issue'); - done(); - }, 0); - }, 0); + }) + .then(done) + .catch(done.fail); }); it('sets detail list after submit', (done) => { vm.title = 'submit issue'; - setTimeout(() => { - submitIssue(); - - setTimeout(() => { + Vue.nextTick() + .then(submitIssue) + .then(() => { expect(gl.issueBoards.BoardsStore.detail.list.id).toBe(list.id); - done(); - }, 0); - }, 0); + }) + .then(done) + .catch(done.fail); }); }); describe('submit error', () => { - it('removes issue', (done) => { + beforeEach(() => { + newIssueMock = Promise.reject(new Error('My hovercraft is full of eels!')); vm.title = 'error'; + }); - setTimeout(() => { - submitIssue(); - - setTimeout(() => { + it('removes issue', (done) => { + Vue.nextTick() + .then(submitIssue) + .then(() => { expect(list.issues.length).toBe(1); - done(); - }, 0); - }, 0); + }) + .then(done) + .catch(done.fail); }); it('shows error', (done) => { - vm.title = 'error'; - - setTimeout(() => { - submitIssue(); - - setTimeout(() => { + Vue.nextTick() + .then(submitIssue) + .then(() => { expect(vm.error).toBe(true); - done(); - }, 0); - }, 0); + }) + .then(done) + .catch(done.fail); }); }); }); diff --git a/spec/javascripts/boards/list_spec.js b/spec/javascripts/boards/list_spec.js index 8e3d9fd77a0..db50829a276 100644 --- a/spec/javascripts/boards/list_spec.js +++ b/spec/javascripts/boards/list_spec.js @@ -150,4 +150,41 @@ describe('List model', () => { expect(list.getIssues).toHaveBeenCalled(); }); }); + + describe('newIssue', () => { + beforeEach(() => { + spyOn(gl.boardService, 'newIssue').and.returnValue(Promise.resolve({ + json() { + return { + iid: 42, + }; + }, + })); + }); + + it('adds new issue to top of list', (done) => { + list.issues.push(new ListIssue({ + title: 'Testing', + iid: _.random(10000), + confidential: false, + labels: [list.label], + assignees: [], + })); + const dummyIssue = new ListIssue({ + title: 'new issue', + iid: _.random(10000), + confidential: false, + labels: [list.label], + assignees: [], + }); + + list.newIssue(dummyIssue) + .then(() => { + expect(list.issues.length).toBe(2); + expect(list.issues[0]).toBe(dummyIssue); + }) + .then(done) + .catch(done.fail); + }); + }); }); diff --git a/spec/javascripts/commit/pipelines/pipelines_spec.js b/spec/javascripts/commit/pipelines/pipelines_spec.js index ebfd60198b2..694f94efcff 100644 --- a/spec/javascripts/commit/pipelines/pipelines_spec.js +++ b/spec/javascripts/commit/pipelines/pipelines_spec.js @@ -1,15 +1,15 @@ import Vue from 'vue'; -import PipelinesTable from '~/commit/pipelines/pipelines_table'; +import pipelinesTable from '~/commit/pipelines/pipelines_table.vue'; describe('Pipelines table in Commits and Merge requests', () => { const jsonFixtureName = 'pipelines/pipelines.json'; let pipeline; + let PipelinesTable; - preloadFixtures('static/pipelines_table.html.raw'); preloadFixtures(jsonFixtureName); beforeEach(() => { - loadFixtures('static/pipelines_table.html.raw'); + PipelinesTable = Vue.extend(pipelinesTable); const pipelines = getJSONFixture(jsonFixtureName).pipelines; pipeline = pipelines.find(p => p.id === 1); }); @@ -26,8 +26,11 @@ describe('Pipelines table in Commits and Merge requests', () => { Vue.http.interceptors.push(pipelinesEmptyResponse); this.component = new PipelinesTable({ - el: document.querySelector('#commit-pipeline-table-view'), - }); + propsData: { + endpoint: 'endpoint', + helpPagePath: 'foo', + }, + }).$mount(); }); afterEach(function () { @@ -58,8 +61,11 @@ describe('Pipelines table in Commits and Merge requests', () => { Vue.http.interceptors.push(pipelinesResponse); this.component = new PipelinesTable({ - el: document.querySelector('#commit-pipeline-table-view'), - }); + propsData: { + endpoint: 'endpoint', + helpPagePath: 'foo', + }, + }).$mount(); }); afterEach(() => { @@ -92,8 +98,11 @@ describe('Pipelines table in Commits and Merge requests', () => { Vue.http.interceptors.push(pipelinesErrorResponse); this.component = new PipelinesTable({ - el: document.querySelector('#commit-pipeline-table-view'), - }); + propsData: { + endpoint: 'endpoint', + helpPagePath: 'foo', + }, + }).$mount(); }); afterEach(function () { diff --git a/spec/javascripts/datetime_utility_spec.js b/spec/javascripts/datetime_utility_spec.js index e54ea11b08c..3391cade541 100644 --- a/spec/javascripts/datetime_utility_spec.js +++ b/spec/javascripts/datetime_utility_spec.js @@ -16,6 +16,10 @@ import { timeIntervalInWords } from '~/lib/utils/datetime_utility'; const date = new Date(); date.setFullYear(date.getFullYear() + 1); + // Add a day to prevent a transient error. If date is even 1 second + // short of a full year, timeFor will return '11 months remaining' + date.setDate(date.getDate() + 1); + expect( gl.utils.timeFor(date), ).toBe('1 year remaining'); diff --git a/spec/javascripts/deploy_keys/components/key_spec.js b/spec/javascripts/deploy_keys/components/key_spec.js index a4b98f6140d..5b64cbb2dfc 100644 --- a/spec/javascripts/deploy_keys/components/key_spec.js +++ b/spec/javascripts/deploy_keys/components/key_spec.js @@ -14,6 +14,7 @@ describe('Deploy keys key', () => { propsData: { deployKey, store, + endpoint: 'https://test.host/dummy/endpoint', }, }).$mount(); }; diff --git a/spec/javascripts/deploy_keys/components/keys_panel_spec.js b/spec/javascripts/deploy_keys/components/keys_panel_spec.js index a69b39c35c4..08357d2b547 100644 --- a/spec/javascripts/deploy_keys/components/keys_panel_spec.js +++ b/spec/javascripts/deploy_keys/components/keys_panel_spec.js @@ -17,6 +17,7 @@ describe('Deploy keys panel', () => { keys: data.enabled_keys, showHelpBox: true, store, + endpoint: 'https://test.host/dummy/endpoint', }, }).$mount(); diff --git a/spec/javascripts/gl_emoji_spec.js b/spec/javascripts/emoji_spec.js index a09e0072fa8..fa11c602ec3 100644 --- a/spec/javascripts/gl_emoji_spec.js +++ b/spec/javascripts/emoji_spec.js @@ -1,12 +1,11 @@ -import { glEmojiTag } from '~/behaviors/gl_emoji'; -import { - isEmojiUnicodeSupported, +import { glEmojiTag } from '~/emoji'; +import isEmojiUnicodeSupported, { isFlagEmoji, isKeycapEmoji, isSkinToneComboEmoji, isHorceRacingSkinToneComboEmoji, isPersonZwjEmoji, -} from '~/behaviors/gl_emoji/is_emoji_unicode_supported'; +} from '~/emoji/support/is_emoji_unicode_supported'; const emptySupportMap = { personZwj: false, diff --git a/spec/javascripts/environments/environment_actions_spec.js b/spec/javascripts/environments/environment_actions_spec.js index 596d812c724..ea40a1fcd4b 100644 --- a/spec/javascripts/environments/environment_actions_spec.js +++ b/spec/javascripts/environments/environment_actions_spec.js @@ -32,9 +32,16 @@ describe('Actions Component', () => { }).$mount(); }); + describe('computed', () => { + it('title', () => { + expect(component.title).toEqual('Deploy to...'); + }); + }); + it('should render a dropdown button with icon and title attribute', () => { expect(component.$el.querySelector('.fa-caret-down')).toBeDefined(); - expect(component.$el.querySelector('.dropdown-new').getAttribute('title')).toEqual('Deploy to...'); + expect(component.$el.querySelector('.dropdown-new').getAttribute('data-original-title')).toEqual('Deploy to...'); + expect(component.$el.querySelector('.dropdown-new').getAttribute('aria-label')).toEqual('Deploy to...'); }); it('should render a dropdown with the provided list of actions', () => { diff --git a/spec/javascripts/environments/environment_monitoring_spec.js b/spec/javascripts/environments/environment_monitoring_spec.js index 0f3dba66230..f8d8223967a 100644 --- a/spec/javascripts/environments/environment_monitoring_spec.js +++ b/spec/javascripts/environments/environment_monitoring_spec.js @@ -3,21 +3,30 @@ import monitoringComp from '~/environments/components/environment_monitoring.vue describe('Monitoring Component', () => { let MonitoringComponent; + let component; + + const monitoringUrl = 'https://gitlab.com'; beforeEach(() => { MonitoringComponent = Vue.extend(monitoringComp); - }); - it('should render a link to environment monitoring page', () => { - const monitoringUrl = 'https://gitlab.com'; - const component = new MonitoringComponent({ + component = new MonitoringComponent({ propsData: { monitoringUrl, }, }).$mount(); + }); + describe('computed', () => { + it('title', () => { + expect(component.title).toEqual('Monitoring'); + }); + }); + + it('should render a link to environment monitoring page', () => { expect(component.$el.getAttribute('href')).toEqual(monitoringUrl); expect(component.$el.querySelector('.fa-area-chart')).toBeDefined(); - expect(component.$el.getAttribute('title')).toEqual('Monitoring'); + expect(component.$el.getAttribute('data-original-title')).toEqual('Monitoring'); + expect(component.$el.getAttribute('aria-label')).toEqual('Monitoring'); }); }); diff --git a/spec/javascripts/environments/environment_stop_spec.js b/spec/javascripts/environments/environment_stop_spec.js index 8131f1e5b11..3f95faf466a 100644 --- a/spec/javascripts/environments/environment_stop_spec.js +++ b/spec/javascripts/environments/environment_stop_spec.js @@ -17,8 +17,15 @@ describe('Stop Component', () => { }).$mount(); }); + describe('computed', () => { + it('title', () => { + expect(component.title).toEqual('Stop'); + }); + }); + it('should render a button to stop the environment', () => { expect(component.$el.tagName).toEqual('BUTTON'); - expect(component.$el.getAttribute('title')).toEqual('Stop'); + expect(component.$el.getAttribute('data-original-title')).toEqual('Stop'); + expect(component.$el.getAttribute('aria-label')).toEqual('Stop'); }); }); diff --git a/spec/javascripts/environments/environment_terminal_button_spec.js b/spec/javascripts/environments/environment_terminal_button_spec.js index 858472af4b6..f1576b19d1b 100644 --- a/spec/javascripts/environments/environment_terminal_button_spec.js +++ b/spec/javascripts/environments/environment_terminal_button_spec.js @@ -16,9 +16,16 @@ describe('Stop Component', () => { }).$mount(); }); + describe('computed', () => { + it('title', () => { + expect(component.title).toEqual('Terminal'); + }); + }); + it('should render a link to open a web terminal with the provided path', () => { expect(component.$el.tagName).toEqual('A'); - expect(component.$el.getAttribute('title')).toEqual('Terminal'); + expect(component.$el.getAttribute('data-original-title')).toEqual('Terminal'); + expect(component.$el.getAttribute('aria-label')).toEqual('Terminal'); expect(component.$el.getAttribute('href')).toEqual(terminalPath); }); }); diff --git a/spec/javascripts/filtered_search/filtered_search_dropdown_manager_spec.js b/spec/javascripts/filtered_search/filtered_search_dropdown_manager_spec.js index c92a147b937..9e2076dc383 100644 --- a/spec/javascripts/filtered_search/filtered_search_dropdown_manager_spec.js +++ b/spec/javascripts/filtered_search/filtered_search_dropdown_manager_spec.js @@ -4,6 +4,10 @@ import '~/filtered_search/filtered_search_tokenizer'; import '~/filtered_search/filtered_search_dropdown_manager'; describe('Filtered Search Dropdown Manager', () => { + beforeEach(() => { + spyOn(jQuery, 'ajax'); + }); + describe('addWordToInput', () => { function getInputValue() { return document.querySelector('.filtered-search').value; diff --git a/spec/javascripts/filtered_search/filtered_search_manager_spec.js b/spec/javascripts/filtered_search/filtered_search_manager_spec.js index 6d00d71f145..16ae649ee60 100644 --- a/spec/javascripts/filtered_search/filtered_search_manager_spec.js +++ b/spec/javascripts/filtered_search/filtered_search_manager_spec.js @@ -1,6 +1,7 @@ import * as recentSearchesStoreSrc from '~/filtered_search/stores/recent_searches_store'; import RecentSearchesService from '~/filtered_search/services/recent_searches_service'; import RecentSearchesServiceError from '~/filtered_search/services/recent_searches_service_error'; +import RecentSearchesRoot from '~/filtered_search/recent_searches_root'; import '~/lib/utils/url_utility'; import '~/lib/utils/common_utils'; import '~/filtered_search/filtered_search_token_keys'; @@ -47,18 +48,23 @@ describe('Filtered Search Manager', () => { </div> `); + spyOn(gl.FilteredSearchDropdownManager.prototype, 'setDropdown').and.callFake(() => {}); + }); + + const initializeManager = () => { + /* eslint-disable jasmine/no-unsafe-spy */ spyOn(gl.FilteredSearchManager.prototype, 'loadSearchParamsFromURL').and.callFake(() => {}); spyOn(gl.FilteredSearchManager.prototype, 'tokenChange').and.callFake(() => {}); - spyOn(gl.FilteredSearchDropdownManager.prototype, 'setDropdown').and.callFake(() => {}); spyOn(gl.FilteredSearchDropdownManager.prototype, 'updateDropdownOffset').and.callFake(() => {}); spyOn(gl.utils, 'getParameterByName').and.returnValue(null); spyOn(gl.FilteredSearchVisualTokens, 'unselectTokens').and.callThrough(); + /* eslint-enable jasmine/no-unsafe-spy */ input = document.querySelector('.filtered-search'); tokensContainer = document.querySelector('.tokens-container'); manager = new gl.FilteredSearchManager(); manager.setup(); - }); + }; afterEach(() => { manager.cleanup(); @@ -66,32 +72,34 @@ describe('Filtered Search Manager', () => { describe('class constructor', () => { const isLocalStorageAvailable = 'isLocalStorageAvailable'; - let filteredSearchManager; beforeEach(() => { spyOn(RecentSearchesService, 'isAvailable').and.returnValue(isLocalStorageAvailable); spyOn(recentSearchesStoreSrc, 'default'); - - filteredSearchManager = new gl.FilteredSearchManager(); - filteredSearchManager.setup(); - - return filteredSearchManager; + spyOn(RecentSearchesRoot.prototype, 'render'); }); it('should instantiate RecentSearchesStore with isLocalStorageAvailable', () => { + manager = new gl.FilteredSearchManager(); + expect(RecentSearchesService.isAvailable).toHaveBeenCalled(); expect(recentSearchesStoreSrc.default).toHaveBeenCalledWith({ isLocalStorageAvailable, allowedKeys: gl.FilteredSearchTokenKeys.getKeys(), }); }); + }); + + describe('setup', () => { + beforeEach(() => { + manager = new gl.FilteredSearchManager(); + }); it('should not instantiate Flash if an RecentSearchesServiceError is caught', () => { spyOn(RecentSearchesService.prototype, 'fetch').and.callFake(() => Promise.reject(new RecentSearchesServiceError())); spyOn(window, 'Flash'); - filteredSearchManager = new gl.FilteredSearchManager(); - filteredSearchManager.setup(); + manager.setup(); expect(window.Flash).not.toHaveBeenCalled(); }); @@ -100,10 +108,12 @@ describe('Filtered Search Manager', () => { describe('searchState', () => { beforeEach(() => { spyOn(gl.FilteredSearchManager.prototype, 'search').and.callFake(() => {}); + initializeManager(); }); it('should blur button', () => { const e = { + preventDefault: () => {}, currentTarget: { blur: () => {}, }, @@ -116,6 +126,7 @@ describe('Filtered Search Manager', () => { it('should not call search if there is no state', () => { const e = { + preventDefault: () => {}, currentTarget: { blur: () => {}, }, @@ -127,6 +138,7 @@ describe('Filtered Search Manager', () => { it('should call search when there is state', () => { const e = { + preventDefault: () => {}, currentTarget: { blur: () => {}, dataset: { @@ -143,6 +155,10 @@ describe('Filtered Search Manager', () => { describe('search', () => { const defaultParams = '?scope=all&utf8=%E2%9C%93&state=opened'; + beforeEach(() => { + initializeManager(); + }); + it('should search with a single word', (done) => { input.value = 'searchTerm'; @@ -192,6 +208,10 @@ describe('Filtered Search Manager', () => { }); describe('handleInputPlaceholder', () => { + beforeEach(() => { + initializeManager(); + }); + it('should render placeholder when there is no input', () => { expect(input.placeholder).toEqual(placeholder); }); @@ -218,6 +238,10 @@ describe('Filtered Search Manager', () => { }); describe('checkForBackspace', () => { + beforeEach(() => { + initializeManager(); + }); + describe('tokens and no input', () => { beforeEach(() => { tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML( @@ -255,6 +279,10 @@ describe('Filtered Search Manager', () => { }); describe('removeToken', () => { + beforeEach(() => { + initializeManager(); + }); + it('removes token even when it is already selected', () => { tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML( FilteredSearchSpecHelper.createFilterVisualTokenHTML('milestone', 'none', true), @@ -286,6 +314,7 @@ describe('Filtered Search Manager', () => { describe('removeSelectedTokenKeydown', () => { beforeEach(() => { + initializeManager(); tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML( FilteredSearchSpecHelper.createFilterVisualTokenHTML('milestone', 'none', true), ); @@ -339,27 +368,39 @@ describe('Filtered Search Manager', () => { spyOn(gl.FilteredSearchVisualTokens, 'removeSelectedToken').and.callThrough(); spyOn(gl.FilteredSearchManager.prototype, 'handleInputPlaceholder').and.callThrough(); spyOn(gl.FilteredSearchManager.prototype, 'toggleClearSearchButton').and.callThrough(); - manager.removeSelectedToken(); + initializeManager(); }); it('calls FilteredSearchVisualTokens.removeSelectedToken', () => { + manager.removeSelectedToken(); + expect(gl.FilteredSearchVisualTokens.removeSelectedToken).toHaveBeenCalled(); }); it('calls handleInputPlaceholder', () => { + manager.removeSelectedToken(); + expect(manager.handleInputPlaceholder).toHaveBeenCalled(); }); it('calls toggleClearSearchButton', () => { + manager.removeSelectedToken(); + expect(manager.toggleClearSearchButton).toHaveBeenCalled(); }); it('calls update dropdown offset', () => { + manager.removeSelectedToken(); + expect(manager.dropdownManager.updateDropdownOffset).toHaveBeenCalled(); }); }); describe('toggleInputContainerFocus', () => { + beforeEach(() => { + initializeManager(); + }); + it('toggles on focus', () => { input.focus(); expect(document.querySelector('.filtered-search-box').classList.contains('focus')).toEqual(true); diff --git a/spec/javascripts/fixtures/merge_requests.rb b/spec/javascripts/fixtures/merge_requests.rb index a746a776548..daaddd8f390 100644 --- a/spec/javascripts/fixtures/merge_requests.rb +++ b/spec/javascripts/fixtures/merge_requests.rb @@ -55,13 +55,27 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont render_merge_request(example.description, merge_request) end + it 'merge_requests/inline_changes_tab_with_comments.json' do |example| + create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) + create(:note_on_merge_request, author: admin, project: project, noteable: merge_request) + render_merge_request(example.description, merge_request, action: :diffs, format: :json) + end + + it 'merge_requests/parallel_changes_tab_with_comments.json' do |example| + create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) + create(:note_on_merge_request, author: admin, project: project, noteable: merge_request) + render_merge_request(example.description, merge_request, action: :diffs, format: :json, view: 'parallel') + end + private - def render_merge_request(fixture_file_name, merge_request) - get :show, + def render_merge_request(fixture_file_name, merge_request, action: :show, format: :html, view: 'inline') + get action, namespace_id: project.namespace.to_param, project_id: project, - id: merge_request.to_param + id: merge_request.to_param, + format: format, + view: view expect(response).to be_success store_frontend_fixture(response, fixture_file_name) diff --git a/spec/javascripts/fixtures/pipelines_table.html.haml b/spec/javascripts/fixtures/pipelines_table.html.haml deleted file mode 100644 index ad1682704bb..00000000000 --- a/spec/javascripts/fixtures/pipelines_table.html.haml +++ /dev/null @@ -1 +0,0 @@ -#commit-pipeline-table-view{ data: { endpoint: "endpoint", "help-page-path": "foo" } } diff --git a/spec/javascripts/fixtures/prometheus_service.rb b/spec/javascripts/fixtures/prometheus_service.rb new file mode 100644 index 00000000000..3200577b326 --- /dev/null +++ b/spec/javascripts/fixtures/prometheus_service.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe Projects::ServicesController, '(JavaScript fixtures)', type: :controller do + include JavaScriptFixturesHelpers + + let(:admin) { create(:admin) } + let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} + let(:project) { create(:project_empty_repo, namespace: namespace, path: 'services-project') } + let!(:service) { create(:prometheus_service, project: project) } + + render_views + + before(:all) do + clean_frontend_fixtures('services/prometheus') + end + + before(:each) do + sign_in(admin) + end + + it 'services/prometheus/prometheus_service.html.raw' do |example| + get :edit, + namespace_id: namespace, + project_id: project, + id: service.to_param + + expect(response).to be_success + store_frontend_fixture(response, example.description) + end +end diff --git a/spec/javascripts/groups/groups_spec.js b/spec/javascripts/groups/groups_spec.js index 2a77f7259da..aaffb56fa94 100644 --- a/spec/javascripts/groups/groups_spec.js +++ b/spec/javascripts/groups/groups_spec.js @@ -1,4 +1,5 @@ import Vue from 'vue'; +import eventHub from '~/groups/event_hub'; import groupFolderComponent from '~/groups/components/group_folder.vue'; import groupItemComponent from '~/groups/components/group_item.vue'; import groupsComponent from '~/groups/components/groups.vue'; @@ -46,6 +47,12 @@ describe('Groups Component', () => { expect(component.$el.querySelector('#group-1120')).toBeDefined(); }); + it('should respect the order of groups', () => { + const wrap = component.$el.querySelector('.groups-list-tree-container > .group-list-tree'); + expect(wrap.querySelector('.group-row:nth-child(1)').id).toBe('group-12'); + expect(wrap.querySelector('.group-row:nth-child(2)').id).toBe('group-1119'); + }); + it('should render group and its subgroup', () => { const lists = component.$el.querySelectorAll('.group-list-tree'); @@ -54,11 +61,26 @@ describe('Groups Component', () => { expect(lists[0].querySelector('#group-1119').classList.contains('is-open')).toBe(true); expect(lists[0].querySelector('#group-1119').classList.contains('has-subgroups')).toBe(true); - expect(lists[2].querySelector('#group-1120').textContent).toContain(groups[1119].subGroups[1120].name); + expect(lists[2].querySelector('#group-1120').textContent).toContain(groups.id1119.subGroups.id1120.name); }); it('should remove prefix of parent group', () => { expect(component.$el.querySelector('#group-12 #group-1128 .title').textContent).toContain('level2 / level3 / level4'); }); + + it('should remove the group after leaving the group', (done) => { + spyOn(window, 'confirm').and.returnValue(true); + + eventHub.$on('leaveGroup', (group, collection) => { + store.removeGroup(group, collection); + }); + + component.$el.querySelector('#group-12 .leave-group').click(); + + Vue.nextTick(() => { + expect(component.$el.querySelector('#group-12')).toBeNull(); + done(); + }); + }); }); }); diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js index 2ccc4f16192..9df92318864 100644 --- a/spec/javascripts/issue_show/components/app_spec.js +++ b/spec/javascripts/issue_show/components/app_spec.js @@ -3,17 +3,9 @@ import '~/render_math'; import '~/render_gfm'; import issuableApp from '~/issue_show/components/app.vue'; import eventHub from '~/issue_show/event_hub'; +import Poll from '~/lib/utils/poll'; import issueShowData from '../mock_data'; -const issueShowInterceptor = data => (request, next) => { - next(request.respondWith(JSON.stringify(data), { - status: 200, - headers: { - 'POLL-INTERVAL': 1, - }, - })); -}; - function formatText(text) { return text.trim().replace(/\s\s+/g, ' '); } @@ -24,10 +16,10 @@ describe('Issuable output', () => { let vm; beforeEach(() => { - const IssuableDescriptionComponent = Vue.extend(issuableApp); - Vue.http.interceptors.push(issueShowInterceptor(issueShowData.initialRequest)); - spyOn(eventHub, '$emit'); + spyOn(Poll.prototype, 'makeRequest'); + + const IssuableDescriptionComponent = Vue.extend(issuableApp); vm = new IssuableDescriptionComponent({ propsData: { @@ -51,13 +43,21 @@ describe('Issuable output', () => { }); afterEach(() => { - Vue.http.interceptors = _.without(Vue.http.interceptors, issueShowInterceptor); }); it('should render a title/description/edited and update title/description/edited on update', (done) => { - setTimeout(() => { - const editedText = vm.$el.querySelector('.edited-text'); + vm.poll.options.successCallback({ + json() { + return issueShowData.initialRequest; + }, + }); + let editedText; + Vue.nextTick() + .then(() => { + editedText = vm.$el.querySelector('.edited-text'); + }) + .then(() => { expect(document.querySelector('title').innerText).toContain('this is a title (#1)'); expect(vm.$el.querySelector('.title').innerHTML).toContain('<p>this is a title</p>'); expect(vm.$el.querySelector('.wiki').innerHTML).toContain('<p>this is a description!</p>'); @@ -65,22 +65,27 @@ describe('Issuable output', () => { expect(formatText(editedText.innerText)).toMatch(/Edited[\s\S]+?by Some User/); expect(editedText.querySelector('.author_link').href).toMatch(/\/some_user$/); expect(editedText.querySelector('time')).toBeTruthy(); - - Vue.http.interceptors.push(issueShowInterceptor(issueShowData.secondRequest)); - - setTimeout(() => { - expect(document.querySelector('title').innerText).toContain('2 (#1)'); - expect(vm.$el.querySelector('.title').innerHTML).toContain('<p>2</p>'); - expect(vm.$el.querySelector('.wiki').innerHTML).toContain('<p>42</p>'); - expect(vm.$el.querySelector('.js-task-list-field').value).toContain('42'); - expect(vm.$el.querySelector('.edited-text')).toBeTruthy(); - expect(formatText(vm.$el.querySelector('.edited-text').innerText)).toMatch(/Edited[\s\S]+?by Other User/); - expect(editedText.querySelector('.author_link').href).toMatch(/\/other_user$/); - expect(editedText.querySelector('time')).toBeTruthy(); - - done(); + }) + .then(() => { + vm.poll.options.successCallback({ + json() { + return issueShowData.secondRequest; + }, }); - }); + }) + .then(Vue.nextTick) + .then(() => { + expect(document.querySelector('title').innerText).toContain('2 (#1)'); + expect(vm.$el.querySelector('.title').innerHTML).toContain('<p>2</p>'); + expect(vm.$el.querySelector('.wiki').innerHTML).toContain('<p>42</p>'); + expect(vm.$el.querySelector('.js-task-list-field').value).toContain('42'); + expect(vm.$el.querySelector('.edited-text')).toBeTruthy(); + expect(formatText(vm.$el.querySelector('.edited-text').innerText)).toMatch(/Edited[\s\S]+?by Other User/); + expect(editedText.querySelector('.author_link').href).toMatch(/\/other_user$/); + expect(editedText.querySelector('time')).toBeTruthy(); + }) + .then(done) + .catch(done.fail); }); it('shows actions if permissions are correct', (done) => { @@ -345,21 +350,23 @@ describe('Issuable output', () => { describe('open form', () => { it('shows locked warning if form is open & data is different', (done) => { - Vue.http.interceptors.push(issueShowInterceptor(issueShowData.initialRequest)); + vm.poll.options.successCallback({ + json() { + return issueShowData.initialRequest; + }, + }); Vue.nextTick() - .then(() => new Promise((resolve) => { - setTimeout(resolve); - })) .then(() => { vm.openForm(); - Vue.http.interceptors.push(issueShowInterceptor(issueShowData.secondRequest)); - - return new Promise((resolve) => { - setTimeout(resolve); + vm.poll.options.successCallback({ + json() { + return issueShowData.secondRequest; + }, }); }) + .then(Vue.nextTick) .then(() => { expect( vm.formState.lockedWarningVisible, @@ -368,9 +375,8 @@ describe('Issuable output', () => { expect( vm.$el.querySelector('.alert'), ).not.toBeNull(); - - done(); }) + .then(done) .catch(done.fail); }); }); diff --git a/spec/javascripts/issue_show/components/description_spec.js b/spec/javascripts/issue_show/components/description_spec.js index 886462c4b9a..f3fdbff01a6 100644 --- a/spec/javascripts/issue_show/components/description_spec.js +++ b/spec/javascripts/issue_show/components/description_spec.js @@ -95,6 +95,18 @@ describe('Description component', () => { done(); }); }); + + it('clears task status text when no tasks are present', (done) => { + vm.taskStatus = '0 of 0'; + + setTimeout(() => { + expect( + document.querySelector('.issuable-meta #task_status').textContent.trim(), + ).toBe(''); + + done(); + }); + }); }); it('applies syntax highlighting and math when description changed', (done) => { diff --git a/spec/javascripts/issue_show/components/fields/description_spec.js b/spec/javascripts/issue_show/components/fields/description_spec.js index f5b35b1e8b0..df8189d9290 100644 --- a/spec/javascripts/issue_show/components/fields/description_spec.js +++ b/spec/javascripts/issue_show/components/fields/description_spec.js @@ -1,6 +1,8 @@ import Vue from 'vue'; +import eventHub from '~/issue_show/event_hub'; import Store from '~/issue_show/stores'; import descriptionField from '~/issue_show/components/fields/description.vue'; +import { keyboardDownEvent } from '../../helpers'; describe('Description field component', () => { let vm; @@ -18,6 +20,8 @@ describe('Description field component', () => { document.body.appendChild(el); + spyOn(eventHub, '$emit'); + vm = new Component({ el, propsData: { @@ -53,4 +57,20 @@ describe('Description field component', () => { document.activeElement, ).toBe(vm.$refs.textarea); }); + + it('triggers update with meta+enter', () => { + vm.$el.querySelector('.md-area textarea').dispatchEvent(keyboardDownEvent(13, true)); + + expect( + eventHub.$emit, + ).toHaveBeenCalled(); + }); + + it('triggers update with ctrl+enter', () => { + vm.$el.querySelector('.md-area textarea').dispatchEvent(keyboardDownEvent(13, false, true)); + + expect( + eventHub.$emit, + ).toHaveBeenCalled(); + }); }); diff --git a/spec/javascripts/issue_show/components/fields/title_spec.js b/spec/javascripts/issue_show/components/fields/title_spec.js index 53ae038a6a2..a03b462689f 100644 --- a/spec/javascripts/issue_show/components/fields/title_spec.js +++ b/spec/javascripts/issue_show/components/fields/title_spec.js @@ -1,6 +1,8 @@ import Vue from 'vue'; +import eventHub from '~/issue_show/event_hub'; import Store from '~/issue_show/stores'; import titleField from '~/issue_show/components/fields/title.vue'; +import { keyboardDownEvent } from '../../helpers'; describe('Title field component', () => { let vm; @@ -15,6 +17,8 @@ describe('Title field component', () => { }); store.formState.title = 'test'; + spyOn(eventHub, '$emit'); + vm = new Component({ propsData: { formState: store.formState, @@ -27,4 +31,20 @@ describe('Title field component', () => { vm.$el.querySelector('.form-control').value, ).toBe('test'); }); + + it('triggers update with meta+enter', () => { + vm.$el.querySelector('.form-control').dispatchEvent(keyboardDownEvent(13, true)); + + expect( + eventHub.$emit, + ).toHaveBeenCalled(); + }); + + it('triggers update with ctrl+enter', () => { + vm.$el.querySelector('.form-control').dispatchEvent(keyboardDownEvent(13, false, true)); + + expect( + eventHub.$emit, + ).toHaveBeenCalled(); + }); }); diff --git a/spec/javascripts/issue_show/helpers.js b/spec/javascripts/issue_show/helpers.js new file mode 100644 index 00000000000..5d2ced98ae4 --- /dev/null +++ b/spec/javascripts/issue_show/helpers.js @@ -0,0 +1,10 @@ +// eslint-disable-next-line import/prefer-default-export +export const keyboardDownEvent = (code, metaKey = false, ctrlKey = false) => { + const e = new CustomEvent('keydown'); + + e.keyCode = code; + e.metaKey = metaKey; + e.ctrlKey = ctrlKey; + + return e; +}; diff --git a/spec/javascripts/merge_request_notes_spec.js b/spec/javascripts/merge_request_notes_spec.js index e54acfa8e44..9e9eb17d439 100644 --- a/spec/javascripts/merge_request_notes_spec.js +++ b/spec/javascripts/merge_request_notes_spec.js @@ -7,54 +7,92 @@ import '~/render_gfm'; import '~/render_math'; import '~/notes'; +const upArrowKeyCode = 38; + describe('Merge request notes', () => { window.gon = window.gon || {}; window.gl = window.gl || {}; gl.utils = gl.utils || {}; - const fixture = 'merge_requests/diff_comment.html.raw'; - preloadFixtures(fixture); + const discussionTabFixture = 'merge_requests/diff_comment.html.raw'; + const changesTabJsonFixture = 'merge_requests/inline_changes_tab_with_comments.json'; + preloadFixtures(discussionTabFixture, changesTabJsonFixture); - beforeEach(() => { - loadFixtures(fixture); - gl.utils.disableButtonIfEmptyField = _.noop; - window.project_uploads_path = 'http://test.host/uploads'; - $('body').data('page', 'projects:merge_requests:show'); - window.gon.current_user_id = $('.note:last').data('author-id'); + describe('Discussion tab with diff comments', () => { + beforeEach(() => { + loadFixtures(discussionTabFixture); + gl.utils.disableButtonIfEmptyField = _.noop; + window.project_uploads_path = 'http://test.host/uploads'; + $('body').data('page', 'projects:merge_requests:show'); + window.gon.current_user_id = $('.note:last').data('author-id'); - return new Notes('', []); - }); + return new Notes('', []); + }); + + describe('up arrow', () => { + it('edits last comment when triggered in main form', () => { + const upArrowEvent = $.Event('keydown'); + upArrowEvent.which = upArrowKeyCode; + + spyOnEvent('.note:last .js-note-edit', 'click'); + + $('.js-note-text').trigger(upArrowEvent); + + expect('click').toHaveBeenTriggeredOn('.note:last .js-note-edit'); + }); + + it('edits last comment in discussion when triggered in discussion form', (done) => { + const upArrowEvent = $.Event('keydown'); + upArrowEvent.which = upArrowKeyCode; + + spyOnEvent('.note-discussion .js-note-edit', 'click'); + + $('.js-discussion-reply-button').click(); - describe('up arrow', () => { - it('edits last comment when triggered in main form', () => { - const upArrowEvent = $.Event('keydown'); - upArrowEvent.which = 38; + setTimeout(() => { + expect( + $('.note-discussion .js-note-text'), + ).toExist(); - spyOnEvent('.note:last .js-note-edit', 'click'); + $('.note-discussion .js-note-text').trigger(upArrowEvent); - $('.js-note-text').trigger(upArrowEvent); + expect('click').toHaveBeenTriggeredOn('.note-discussion .js-note-edit'); - expect('click').toHaveBeenTriggeredOn('.note:last .js-note-edit'); + done(); + }); + }); }); + }); - it('edits last comment in discussion when triggered in discussion form', (done) => { - const upArrowEvent = $.Event('keydown'); - upArrowEvent.which = 38; + describe('Changes tab with diff comments', () => { + beforeEach(() => { + const diffsResponse = getJSONFixture(changesTabJsonFixture); + const noteFormHtml = `<form class="js-new-note-form"> + <textarea class="js-note-text"></textarea> + </form>`; + setFixtures(diffsResponse.html + noteFormHtml); + $('body').data('page', 'projects:merge_requests:show'); + window.gon.current_user_id = $('.note:last').data('author-id'); + + return new Notes('', []); + }); - spyOnEvent('.note-discussion .js-note-edit', 'click'); + describe('up arrow', () => { + it('edits last comment in discussion when triggered in discussion form', (done) => { + const upArrowEvent = $.Event('keydown'); + upArrowEvent.which = upArrowKeyCode; - $('.js-discussion-reply-button').click(); + spyOnEvent('.note:last .js-note-edit', 'click'); - setTimeout(() => { - expect( - $('.note-discussion .js-note-text'), - ).toExist(); + $('.js-discussion-reply-button').trigger('click'); - $('.note-discussion .js-note-text').trigger(upArrowEvent); + setTimeout(() => { + $('.js-note-text').trigger(upArrowEvent); - expect('click').toHaveBeenTriggeredOn('.note-discussion .js-note-edit'); + expect('click').toHaveBeenTriggeredOn('.note:last .js-note-edit'); - done(); + done(); + }); }); }); }); diff --git a/spec/javascripts/merge_request_tabs_spec.js b/spec/javascripts/merge_request_tabs_spec.js index 9916d2c1e21..bb6b5d852d3 100644 --- a/spec/javascripts/merge_request_tabs_spec.js +++ b/spec/javascripts/merge_request_tabs_spec.js @@ -22,7 +22,15 @@ import 'vendor/jquery.scrollTo'; }; $.extend(stubLocation, defaults, stubs || {}); }; - preloadFixtures('merge_requests/merge_request_with_task_list.html.raw', 'merge_requests/diff_comment.html.raw'); + + const inlineChangesTabJsonFixture = 'merge_requests/inline_changes_tab_with_comments.json'; + const parallelChangesTabJsonFixture = 'merge_requests/parallel_changes_tab_with_comments.json'; + preloadFixtures( + 'merge_requests/merge_request_with_task_list.html.raw', + 'merge_requests/diff_comment.html.raw', + inlineChangesTabJsonFixture, + parallelChangesTabJsonFixture + ); beforeEach(function () { this.class = new gl.MergeRequestTabs({ stubLocation: stubLocation }); @@ -271,6 +279,19 @@ import 'vendor/jquery.scrollTo'; }); describe('loadDiff', function () { + beforeEach(() => { + loadFixtures('merge_requests/diff_comment.html.raw'); + spyOn(window.gl.utils, 'getPagePath').and.returnValue('merge_requests'); + window.gl.ImageFile = () => {}; + window.notes = new Notes('', []); + spyOn(window.notes, 'toggleDiffNote').and.callThrough(); + }); + + afterEach(() => { + delete window.gl.ImageFile; + delete window.notes; + }); + it('requires an absolute pathname', function () { spyOn($, 'ajax').and.callFake(function (options) { expect(options.url).toEqual('/foo/bar/merge_requests/1/diffs.json'); @@ -279,43 +300,112 @@ import 'vendor/jquery.scrollTo'; this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); }); - describe('with note fragment hash', () => { + describe('with inline diff', () => { + let noteId; + let noteLineNumId; + beforeEach(() => { - loadFixtures('merge_requests/diff_comment.html.raw'); - spyOn(window.gl.utils, 'getPagePath').and.returnValue('merge_requests'); - window.notes = new Notes('', []); - spyOn(window.notes, 'toggleDiffNote').and.callThrough(); - }); + const diffsResponse = getJSONFixture(inlineChangesTabJsonFixture); + + const $html = $(diffsResponse.html); + noteId = $html.find('.note').attr('id'); + noteLineNumId = $html + .find('.note') + .closest('.notes_holder') + .prev('.line_holder') + .find('a[data-linenumber]') + .attr('href') + .replace('#', ''); - afterEach(() => { - delete window.notes; + spyOn($, 'ajax').and.callFake(function (options) { + options.success(diffsResponse); + }); }); - it('should expand and scroll to linked fragment hash #note_xxx', function () { - const noteId = 'note_1'; - spyOn(window.gl.utils, 'getLocationHash').and.returnValue(noteId); - spyOn($, 'ajax').and.callFake(function (options) { - options.success({ html: `<div id="${noteId}">foo</div>` }); + describe('with note fragment hash', () => { + it('should expand and scroll to linked fragment hash #note_xxx', function () { + spyOn(window.gl.utils, 'getLocationHash').and.returnValue(noteId); + this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); + + expect(noteId.length).toBeGreaterThan(0); + expect(window.notes.toggleDiffNote).toHaveBeenCalledWith({ + target: jasmine.any(Object), + lineType: 'old', + forceShow: true, + }); }); - this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); + it('should gracefully ignore non-existant fragment hash', function () { + spyOn(window.gl.utils, 'getLocationHash').and.returnValue('note_something-that-does-not-exist'); + this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); - expect(window.notes.toggleDiffNote).toHaveBeenCalledWith({ - target: jasmine.any(Object), - lineType: 'old', - forceShow: true, + expect(window.notes.toggleDiffNote).not.toHaveBeenCalled(); }); }); - it('should gracefully ignore non-existant fragment hash', function () { - spyOn(window.gl.utils, 'getLocationHash').and.returnValue('note_something-that-does-not-exist'); + describe('with line number fragment hash', () => { + it('should gracefully ignore line number fragment hash', function () { + spyOn(window.gl.utils, 'getLocationHash').and.returnValue(noteLineNumId); + this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); + + expect(noteLineNumId.length).toBeGreaterThan(0); + expect(window.notes.toggleDiffNote).not.toHaveBeenCalled(); + }); + }); + }); + + describe('with parallel diff', () => { + let noteId; + let noteLineNumId; + + beforeEach(() => { + const diffsResponse = getJSONFixture(parallelChangesTabJsonFixture); + + const $html = $(diffsResponse.html); + noteId = $html.find('.note').attr('id'); + noteLineNumId = $html + .find('.note') + .closest('.notes_holder') + .prev('.line_holder') + .find('a[data-linenumber]') + .attr('href') + .replace('#', ''); + spyOn($, 'ajax').and.callFake(function (options) { - options.success({ html: '' }); + options.success(diffsResponse); }); + }); + + describe('with note fragment hash', () => { + it('should expand and scroll to linked fragment hash #note_xxx', function () { + spyOn(window.gl.utils, 'getLocationHash').and.returnValue(noteId); - this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); + this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); - expect(window.notes.toggleDiffNote).not.toHaveBeenCalled(); + expect(noteId.length).toBeGreaterThan(0); + expect(window.notes.toggleDiffNote).toHaveBeenCalledWith({ + target: jasmine.any(Object), + lineType: 'new', + forceShow: true, + }); + }); + + it('should gracefully ignore non-existant fragment hash', function () { + spyOn(window.gl.utils, 'getLocationHash').and.returnValue('note_something-that-does-not-exist'); + this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); + + expect(window.notes.toggleDiffNote).not.toHaveBeenCalled(); + }); + }); + + describe('with line number fragment hash', () => { + it('should gracefully ignore line number fragment hash', function () { + spyOn(window.gl.utils, 'getLocationHash').and.returnValue(noteLineNumId); + this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); + + expect(noteLineNumId.length).toBeGreaterThan(0); + expect(window.notes.toggleDiffNote).not.toHaveBeenCalled(); + }); }); }); }); diff --git a/spec/javascripts/pipeline_schedules/interval_pattern_input_spec.js b/spec/javascripts/pipeline_schedules/interval_pattern_input_spec.js index 56c57d94798..040d14efed2 100644 --- a/spec/javascripts/pipeline_schedules/interval_pattern_input_spec.js +++ b/spec/javascripts/pipeline_schedules/interval_pattern_input_spec.js @@ -1,5 +1,8 @@ import Vue from 'vue'; -import IntervalPatternInput from '~/pipeline_schedules/components/interval_pattern_input'; +import Translate from '~/vue_shared/translate'; +import IntervalPatternInput from '~/pipeline_schedules/components/interval_pattern_input.vue'; + +Vue.use(Translate); const IntervalPatternInputComponent = Vue.extend(IntervalPatternInput); const inputNameAttribute = 'schedule[cron]'; diff --git a/spec/javascripts/pipelines/async_button_spec.js b/spec/javascripts/pipelines/async_button_spec.js index 28c9c7ab282..48620898357 100644 --- a/spec/javascripts/pipelines/async_button_spec.js +++ b/spec/javascripts/pipelines/async_button_spec.js @@ -1,25 +1,20 @@ import Vue from 'vue'; import asyncButtonComp from '~/pipelines/components/async_button.vue'; +import eventHub from '~/pipelines/event_hub'; describe('Pipelines Async Button', () => { let component; - let spy; let AsyncButtonComponent; beforeEach(() => { AsyncButtonComponent = Vue.extend(asyncButtonComp); - spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve()); - component = new AsyncButtonComponent({ propsData: { endpoint: '/foo', title: 'Foo', icon: 'fa fa-foo', cssClass: 'bar', - service: { - postAction: spy, - }, }, }).$mount(); }); @@ -33,7 +28,7 @@ describe('Pipelines Async Button', () => { }); it('should render the provided title', () => { - expect(component.$el.getAttribute('title')).toContain('Foo'); + expect(component.$el.getAttribute('data-original-title')).toContain('Foo'); expect(component.$el.getAttribute('aria-label')).toContain('Foo'); }); @@ -41,37 +36,12 @@ describe('Pipelines Async Button', () => { expect(component.$el.getAttribute('class')).toContain('bar'); }); - it('should call the service when it is clicked with the provided endpoint', () => { - component.$el.click(); - expect(spy).toHaveBeenCalledWith('/foo'); - }); - - it('should hide loading if request fails', () => { - spy = jasmine.createSpy('spy').and.returnValue(Promise.reject()); - - component = new AsyncButtonComponent({ - propsData: { - endpoint: '/foo', - title: 'Foo', - icon: 'fa fa-foo', - cssClass: 'bar', - dataAttributes: { - 'data-foo': 'foo', - }, - service: { - postAction: spy, - }, - }, - }).$mount(); - - component.$el.click(); - expect(component.$el.querySelector('.fa-spinner')).toBe(null); - }); - describe('With confirm dialog', () => { it('should call the service when confimation is positive', () => { spyOn(window, 'confirm').and.returnValue(true); - spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve()); + eventHub.$on('postAction', (endpoint) => { + expect(endpoint).toEqual('/foo'); + }); component = new AsyncButtonComponent({ propsData: { @@ -79,15 +49,11 @@ describe('Pipelines Async Button', () => { title: 'Foo', icon: 'fa fa-foo', cssClass: 'bar', - service: { - postAction: spy, - }, confirmActionMessage: 'bar', }, }).$mount(); component.$el.click(); - expect(spy).toHaveBeenCalledWith('/foo'); }); }); }); diff --git a/spec/javascripts/pipelines/pipelines_actions_spec.js b/spec/javascripts/pipelines/pipelines_actions_spec.js index 8a58b77f1e3..72fb0a8f9ef 100644 --- a/spec/javascripts/pipelines/pipelines_actions_spec.js +++ b/spec/javascripts/pipelines/pipelines_actions_spec.js @@ -3,7 +3,6 @@ import pipelinesActionsComp from '~/pipelines/components/pipelines_actions.vue'; describe('Pipelines Actions dropdown', () => { let component; - let spy; let actions; let ActionsComponent; @@ -22,14 +21,9 @@ describe('Pipelines Actions dropdown', () => { }, ]; - spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve()); - component = new ActionsComponent({ propsData: { actions, - service: { - postAction: spy, - }, }, }).$mount(); }); @@ -40,31 +34,6 @@ describe('Pipelines Actions dropdown', () => { ).toEqual(actions.length); }); - it('should call the service when an action is clicked', () => { - component.$el.querySelector('.js-pipeline-dropdown-manual-actions').click(); - component.$el.querySelector('.js-pipeline-action-link').click(); - - expect(spy).toHaveBeenCalledWith(actions[0].path); - }); - - it('should hide loading if request fails', () => { - spy = jasmine.createSpy('spy').and.returnValue(Promise.reject()); - - component = new ActionsComponent({ - propsData: { - actions, - service: { - postAction: spy, - }, - }, - }).$mount(); - - component.$el.querySelector('.js-pipeline-dropdown-manual-actions').click(); - component.$el.querySelector('.js-pipeline-action-link').click(); - - expect(component.$el.querySelector('.fa-spinner')).toEqual(null); - }); - it('should render a disabled action when it\'s not playable', () => { expect( component.$el.querySelector('.dropdown-menu li:last-child button').getAttribute('disabled'), diff --git a/spec/javascripts/vue_shared/components/pipelines_table_row_spec.js b/spec/javascripts/pipelines/pipelines_table_row_spec.js index 9475ee28a03..7ce39dca112 100644 --- a/spec/javascripts/vue_shared/components/pipelines_table_row_spec.js +++ b/spec/javascripts/pipelines/pipelines_table_row_spec.js @@ -1,5 +1,5 @@ import Vue from 'vue'; -import tableRowComp from '~/vue_shared/components/pipelines_table_row.vue'; +import tableRowComp from '~/pipelines/components/pipelines_table_row.vue'; describe('Pipelines Table Row', () => { const jsonFixtureName = 'pipelines/pipelines.json'; diff --git a/spec/javascripts/vue_shared/components/pipelines_table_spec.js b/spec/javascripts/pipelines/pipelines_table_spec.js index 4c35d702004..3afe89c8db4 100644 --- a/spec/javascripts/vue_shared/components/pipelines_table_spec.js +++ b/spec/javascripts/pipelines/pipelines_table_spec.js @@ -1,5 +1,5 @@ import Vue from 'vue'; -import pipelinesTableComp from '~/vue_shared/components/pipelines_table.vue'; +import pipelinesTableComp from '~/pipelines/components/pipelines_table.vue'; import '~/lib/utils/datetime_utility'; describe('Pipelines Table', () => { @@ -22,7 +22,6 @@ describe('Pipelines Table', () => { component = new PipelinesTableComponent({ propsData: { pipelines: [], - service: {}, }, }).$mount(); }); @@ -48,7 +47,6 @@ describe('Pipelines Table', () => { const component = new PipelinesTableComponent({ propsData: { pipelines: [], - service: {}, }, }).$mount(); expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(0); @@ -58,10 +56,8 @@ describe('Pipelines Table', () => { describe('with data', () => { it('should render rows', () => { const component = new PipelinesTableComponent({ - el: document.querySelector('.test-dom-element'), propsData: { pipelines: [pipeline], - service: {}, }, }).$mount(); diff --git a/spec/javascripts/pipelines/stage_spec.js b/spec/javascripts/pipelines/stage_spec.js index a4f32a1faed..1b96b2e3d51 100644 --- a/spec/javascripts/pipelines/stage_spec.js +++ b/spec/javascripts/pipelines/stage_spec.js @@ -83,4 +83,47 @@ describe('Pipelines stage component', () => { }, 0); }); }); + + describe('update endpoint correctly', () => { + const updatedInterceptor = (request, next) => { + if (request.url === 'bar') { + next(request.respondWith(JSON.stringify({ html: 'this is the updated content' }), { + status: 200, + })); + } + next(); + }; + + beforeEach(() => { + Vue.http.interceptors.push(updatedInterceptor); + }); + + afterEach(() => { + Vue.http.interceptors = _.without( + Vue.http.interceptors, updatedInterceptor, + ); + }); + + it('should update the stage to request the new endpoint provided', (done) => { + component.stage = { + status: { + group: 'running', + icon: 'running', + title: 'running', + }, + dropdown_path: 'bar', + }; + + Vue.nextTick(() => { + component.$el.querySelector('button').click(); + + setTimeout(() => { + expect( + component.$el.querySelector('.js-builds-dropdown-container ul').textContent.trim(), + ).toEqual('this is the updated content'); + done(); + }); + }); + }); + }); }); diff --git a/spec/javascripts/prometheus_metrics/mock_data.js b/spec/javascripts/prometheus_metrics/mock_data.js new file mode 100644 index 00000000000..3af56df92e2 --- /dev/null +++ b/spec/javascripts/prometheus_metrics/mock_data.js @@ -0,0 +1,41 @@ +export const metrics = [ + { + group: 'Kubernetes', + priority: 1, + active_metrics: 4, + metrics_missing_requirements: 0, + }, + { + group: 'HAProxy', + priority: 2, + active_metrics: 3, + metrics_missing_requirements: 0, + }, + { + group: 'Apache', + priority: 3, + active_metrics: 5, + metrics_missing_requirements: 0, + }, +]; + +export const missingVarMetrics = [ + { + group: 'Kubernetes', + priority: 1, + active_metrics: 4, + metrics_missing_requirements: 0, + }, + { + group: 'HAProxy', + priority: 2, + active_metrics: 3, + metrics_missing_requirements: 1, + }, + { + group: 'Apache', + priority: 3, + active_metrics: 5, + metrics_missing_requirements: 3, + }, +]; diff --git a/spec/javascripts/prometheus_metrics/prometheus_metrics_spec.js b/spec/javascripts/prometheus_metrics/prometheus_metrics_spec.js new file mode 100644 index 00000000000..2b3a821dbd9 --- /dev/null +++ b/spec/javascripts/prometheus_metrics/prometheus_metrics_spec.js @@ -0,0 +1,158 @@ +import PrometheusMetrics from '~/prometheus_metrics/prometheus_metrics'; +import PANEL_STATE from '~/prometheus_metrics/constants'; +import { metrics, missingVarMetrics } from './mock_data'; + +describe('PrometheusMetrics', () => { + const FIXTURE = 'services/prometheus/prometheus_service.html.raw'; + preloadFixtures(FIXTURE); + + beforeEach(() => { + loadFixtures(FIXTURE); + }); + + describe('constructor', () => { + let prometheusMetrics; + + beforeEach(() => { + prometheusMetrics = new PrometheusMetrics('.js-prometheus-metrics-monitoring'); + }); + + it('should initialize wrapper element refs on class object', () => { + expect(prometheusMetrics.$wrapper).toBeDefined(); + expect(prometheusMetrics.$monitoredMetricsPanel).toBeDefined(); + expect(prometheusMetrics.$monitoredMetricsCount).toBeDefined(); + expect(prometheusMetrics.$monitoredMetricsLoading).toBeDefined(); + expect(prometheusMetrics.$monitoredMetricsEmpty).toBeDefined(); + expect(prometheusMetrics.$monitoredMetricsList).toBeDefined(); + expect(prometheusMetrics.$missingEnvVarPanel).toBeDefined(); + expect(prometheusMetrics.$panelToggle).toBeDefined(); + expect(prometheusMetrics.$missingEnvVarMetricCount).toBeDefined(); + expect(prometheusMetrics.$missingEnvVarMetricsList).toBeDefined(); + }); + + it('should initialize metadata on class object', () => { + expect(prometheusMetrics.backOffRequestCounter).toEqual(0); + expect(prometheusMetrics.activeMetricsEndpoint).toContain('/test'); + }); + }); + + describe('showMonitoringMetricsPanelState', () => { + let prometheusMetrics; + + beforeEach(() => { + prometheusMetrics = new PrometheusMetrics('.js-prometheus-metrics-monitoring'); + }); + + it('should show loading state when called with `loading`', () => { + prometheusMetrics.showMonitoringMetricsPanelState(PANEL_STATE.LOADING); + + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeFalsy(); + expect(prometheusMetrics.$monitoredMetricsEmpty.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredMetricsList.hasClass('hidden')).toBeTruthy(); + }); + + it('should show metrics list when called with `list`', () => { + prometheusMetrics.showMonitoringMetricsPanelState(PANEL_STATE.LIST); + + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredMetricsEmpty.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredMetricsList.hasClass('hidden')).toBeFalsy(); + }); + + it('should show empty state when called with `empty`', () => { + prometheusMetrics.showMonitoringMetricsPanelState(PANEL_STATE.EMPTY); + + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredMetricsEmpty.hasClass('hidden')).toBeFalsy(); + expect(prometheusMetrics.$monitoredMetricsList.hasClass('hidden')).toBeTruthy(); + }); + }); + + describe('populateActiveMetrics', () => { + let prometheusMetrics; + + beforeEach(() => { + prometheusMetrics = new PrometheusMetrics('.js-prometheus-metrics-monitoring'); + }); + + it('should show monitored metrics list', () => { + prometheusMetrics.populateActiveMetrics(metrics); + + const $metricsListLi = prometheusMetrics.$monitoredMetricsList.find('li'); + + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredMetricsList.hasClass('hidden')).toBeFalsy(); + + expect(prometheusMetrics.$monitoredMetricsCount.text()).toEqual('12'); + expect($metricsListLi.length).toEqual(metrics.length); + expect($metricsListLi.first().find('.badge').text()).toEqual(`${metrics[0].active_metrics}`); + }); + + it('should show missing environment variables list', () => { + prometheusMetrics.populateActiveMetrics(missingVarMetrics); + + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$missingEnvVarPanel.hasClass('hidden')).toBeFalsy(); + + expect(prometheusMetrics.$missingEnvVarMetricCount.text()).toEqual('2'); + expect(prometheusMetrics.$missingEnvVarPanel.find('li').length).toEqual(2); + expect(prometheusMetrics.$missingEnvVarPanel.find('.flash-container')).toBeDefined(); + }); + }); + + describe('loadActiveMetrics', () => { + let prometheusMetrics; + + beforeEach(() => { + prometheusMetrics = new PrometheusMetrics('.js-prometheus-metrics-monitoring'); + }); + + it('should show loader animation while response is being loaded and hide it when request is complete', (done) => { + const deferred = $.Deferred(); + spyOn($, 'getJSON').and.returnValue(deferred.promise()); + + prometheusMetrics.loadActiveMetrics(); + + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeFalsy(); + expect($.getJSON).toHaveBeenCalledWith(prometheusMetrics.activeMetricsEndpoint); + + deferred.resolve({ data: metrics, success: true }); + + setTimeout(() => { + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeTruthy(); + done(); + }); + }); + + it('should show empty state if response failed to load', (done) => { + const deferred = $.Deferred(); + spyOn($, 'getJSON').and.returnValue(deferred.promise()); + spyOn(prometheusMetrics, 'populateActiveMetrics'); + + prometheusMetrics.loadActiveMetrics(); + + deferred.reject(); + + setTimeout(() => { + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredMetricsEmpty.hasClass('hidden')).toBeFalsy(); + done(); + }); + }); + + it('should populate metrics list once response is loaded', (done) => { + const deferred = $.Deferred(); + spyOn($, 'getJSON').and.returnValue(deferred.promise()); + spyOn(prometheusMetrics, 'populateActiveMetrics'); + + prometheusMetrics.loadActiveMetrics(); + + deferred.resolve({ data: metrics, success: true }); + + setTimeout(() => { + expect(prometheusMetrics.populateActiveMetrics).toHaveBeenCalledWith(metrics); + done(); + }); + }); + }); +}); diff --git a/spec/javascripts/sidebar/assignee_title_spec.js b/spec/javascripts/sidebar/assignee_title_spec.js index 5b5b1bf4140..ac93f918ce4 100644 --- a/spec/javascripts/sidebar/assignee_title_spec.js +++ b/spec/javascripts/sidebar/assignee_title_spec.js @@ -33,6 +33,31 @@ describe('AssigneeTitle component', () => { }); }); + describe('gutter toggle', () => { + it('does not show toggle by default', () => { + component = new AssigneeTitleComponent({ + propsData: { + numberOfAssignees: 2, + editable: false, + }, + }).$mount(); + + expect(component.$el.querySelector('.gutter-toggle')).toBeNull(); + }); + + it('shows toggle when showToggle is true', () => { + component = new AssigneeTitleComponent({ + propsData: { + numberOfAssignees: 2, + editable: false, + showToggle: true, + }, + }).$mount(); + + expect(component.$el.querySelector('.gutter-toggle')).toEqual(jasmine.any(Object)); + }); + }); + it('does not render spinner by default', () => { component = new AssigneeTitleComponent({ propsData: { diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index 729db02e06c..d4e134583c7 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -1,8 +1,18 @@ +/* eslint-disable jasmine/no-global-setup */ import $ from 'jquery'; import _ from 'underscore'; import 'jasmine-jquery'; import '~/commons'; +import Vue from 'vue'; +import VueResource from 'vue-resource'; + +const isHeadlessChrome = /\bHeadlessChrome\//.test(navigator.userAgent); +Vue.config.devtools = !isHeadlessChrome; +Vue.config.productionTip = false; + +Vue.use(VueResource); + // enable test fixtures jasmine.getFixtures().fixturesPath = '/base/spec/javascripts/fixtures'; jasmine.getJSONFixtures().fixturesPath = '/base/spec/javascripts/fixtures'; @@ -16,13 +26,44 @@ window.gl = window.gl || {}; window.gl.TEST_HOST = 'http://test.host'; window.gon = window.gon || {}; +let hasUnhandledPromiseRejections = false; + +window.addEventListener('unhandledrejection', (event) => { + hasUnhandledPromiseRejections = true; + console.error('Unhandled promise rejection:'); + console.error(event.reason.stack || event.reason); +}); + +const checkUnhandledPromiseRejections = (done) => { + expect(hasUnhandledPromiseRejections).toBe(false); + done(); +}; + // HACK: Chrome 59 disconnects if there are too many synchronous tests in a row // because it appears to lock up the thread that communicates to Karma's socket // This async beforeEach gets called on every spec and releases the JS thread long // enough for the socket to continue to communicate. // The downside is that it creates a minor performance penalty in the time it takes // to run our unit tests. -beforeEach(done => done()); // eslint-disable-line jasmine/no-global-setup +beforeEach(done => done()); + +beforeAll(() => { + const origError = console.error; + spyOn(console, 'error').and.callFake((message) => { + if (/^\[Vue warn\]/.test(message)) { + fail(message); + } else { + origError(message); + } + }); +}); + +const builtinVueHttpInterceptors = Vue.http.interceptors.slice(); + +beforeEach(() => { + // restore interceptors so we have no remaining ones from previous tests + Vue.http.interceptors = builtinVueHttpInterceptors.slice(); +}); // render all of our tests const testsContext = require.context('.', true, /_spec$/); @@ -39,6 +80,10 @@ testsContext.keys().forEach(function (path) { } }); +it('has no unhandled Promise rejections', (done) => { + setTimeout(checkUnhandledPromiseRejections(done), 1000); +}); + // if we're generating coverage reports, make sure to include all files so // that we can catch files with 0% coverage // see: https://github.com/deepsweet/istanbul-instrumenter-loader/issues/15 diff --git a/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js b/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js index 647b59520f8..4b6f171c8d6 100644 --- a/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js +++ b/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js @@ -76,6 +76,28 @@ describe('MRWidgetPipeline', () => { el = vm.$el; }); + afterEach(() => { + vm.$destroy(); + }); + + describe('without a pipeline', () => { + beforeEach(() => { + vm.mr = { pipeline: null }; + }); + + it('should render message with spinner', (done) => { + Vue.nextTick() + .then(() => { + expect(el.querySelector('.pipeline-id')).toBe(null); + expect(el.innerText.trim()).toBe('Waiting for pipeline...'); + expect(el.querySelectorAll('i.fa.fa-spinner.fa-spin').length).toBe(1); + done(); + }) + .then(done) + .catch(done.fail); + }); + }); + it('should render template elements correctly', () => { expect(el.classList.contains('mr-widget-heading')).toBeTruthy(); expect(el.querySelectorAll('.ci-status-icon.ci-status-icon-success').length).toEqual(1); @@ -93,39 +115,47 @@ describe('MRWidgetPipeline', () => { it('should list single stage', (done) => { pipeline.details.stages.splice(0, 1); - Vue.nextTick(() => { - expect(el.querySelectorAll('.stage-container button').length).toEqual(1); - expect(el.innerText).toContain('with stage'); - done(); - }); + Vue.nextTick() + .then(() => { + expect(el.querySelectorAll('.stage-container button').length).toEqual(1); + expect(el.innerText).toContain('with stage'); + }) + .then(done) + .catch(done.fail); }); it('should not have stages when there is no stage', (done) => { vm.mr.pipeline.details.stages = []; - Vue.nextTick(() => { - expect(el.querySelectorAll('.stage-container button').length).toEqual(0); - done(); - }); + Vue.nextTick() + .then(() => { + expect(el.querySelectorAll('.stage-container button').length).toEqual(0); + }) + .then(done) + .catch(done.fail); }); it('should not have coverage text when pipeline has no coverage info', (done) => { vm.mr.pipeline.coverage = null; - Vue.nextTick(() => { - expect(el.querySelector('.js-mr-coverage')).toEqual(null); - done(); - }); + Vue.nextTick() + .then(() => { + expect(el.querySelector('.js-mr-coverage')).toEqual(null); + }) + .then(done) + .catch(done.fail); }); it('should show CI error when there is a CI error', (done) => { vm.mr.ciStatus = null; - Vue.nextTick(() => { - expect(el.querySelectorAll('.js-ci-error').length).toEqual(1); - expect(el.innerText).toContain('Could not connect to the CI server'); - done(); - }); + Vue.nextTick() + .then(() => { + expect(el.querySelectorAll('.js-ci-error').length).toEqual(1); + expect(el.innerText).toContain('Could not connect to the CI server'); + }) + .then(done) + .catch(done.fail); }); }); }); diff --git a/spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js b/spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js index 6a44c54cdee..f6e0c3dfb74 100644 --- a/spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js +++ b/spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js @@ -1,31 +1,20 @@ import Vue from 'vue'; -import MRWidgetRelatedLinks from '~/vue_merge_request_widget/components/mr_widget_related_links'; +import relatedLinksComponent from '~/vue_merge_request_widget/components/mr_widget_related_links'; -describe('MRWidgetRelatedLinks', () => { - let vm; - - beforeEach(() => { - const Component = Vue.extend(MRWidgetRelatedLinks); - vm = new Component({ - el: document.createElement('div'), - propsData: { - isMerged: false, - relatedLinks: {}, - }, - }); - }); +const createComponent = (data) => { + const Component = Vue.extend(relatedLinksComponent); - afterEach(() => { - vm.$destroy(); + return new Component({ + el: document.createElement('div'), + propsData: data, }); +}; +describe('MRWidgetRelatedLinks', () => { describe('props', () => { it('should have props', () => { - const { isMerged, relatedLinks } = MRWidgetRelatedLinks.props; + const { relatedLinks } = relatedLinksComponent.props; - expect(isMerged).toBeDefined(); - expect(isMerged.type).toBe(Boolean); - expect(isMerged.required).toBeTruthy(); expect(relatedLinks).toBeDefined(); expect(relatedLinks.type instanceof Object).toBeTruthy(); expect(relatedLinks.required).toBeTruthy(); @@ -33,38 +22,16 @@ describe('MRWidgetRelatedLinks', () => { }); describe('computed', () => { - describe('closingText', () => { - const dummyIssueLabel = 'dummy label'; - - beforeEach(() => { - spyOn(vm, 'issueLabel').and.returnValue(dummyIssueLabel); - }); - - it('outputs text for closing issues', () => { - vm.isMerged = false; - - const text = vm.closingText; - - expect(text).toBe(`Closes ${dummyIssueLabel}`); - }); - - it('outputs text for closed issues', () => { - vm.isMerged = true; - - const text = vm.closingText; - - expect(text).toBe(`Closed ${dummyIssueLabel}`); - }); - }); - describe('hasLinks', () => { it('should return correct value when we have links reference', () => { - vm.relatedLinks = { - closing: '/foo', - mentioned: '/foo', - assignToMe: '/foo', + const data = { + relatedLinks: { + closing: '/foo', + mentioned: '/foo', + assignToMe: '/foo', + }, }; - + const vm = createComponent(data); expect(vm.hasLinks).toBeTruthy(); vm.relatedLinks.closing = null; @@ -77,160 +44,95 @@ describe('MRWidgetRelatedLinks', () => { expect(vm.hasLinks).toBeFalsy(); }); }); - - describe('mentionedText', () => { - it('outputs text for one mentioned issue before merging', () => { - vm.isMerged = false; - spyOn(vm, 'hasMultipleIssues').and.returnValue(false); - - const text = vm.mentionedText; - - expect(text).toBe('is mentioned but will not be closed'); - }); - - it('outputs text for one mentioned issue after merging', () => { - vm.isMerged = true; - spyOn(vm, 'hasMultipleIssues').and.returnValue(false); - - const text = vm.mentionedText; - - expect(text).toBe('is mentioned but was not closed'); - }); - - it('outputs text for multiple mentioned issue before merging', () => { - vm.isMerged = false; - spyOn(vm, 'hasMultipleIssues').and.returnValue(true); - - const text = vm.mentionedText; - - expect(text).toBe('are mentioned but will not be closed'); - }); - - it('outputs text for multiple mentioned issue after merging', () => { - vm.isMerged = true; - spyOn(vm, 'hasMultipleIssues').and.returnValue(true); - - const text = vm.mentionedText; - - expect(text).toBe('are mentioned but were not closed'); - }); - }); }); describe('methods', () => { - const relatedLinks = { - oneIssue: '<a href="#">#7</a>', - twoIssues: '<a href="#">#23</a> and <a>#42</a>', - threeIssues: '<a href="#">#1</a>, <a>#2</a>, and <a>#3</a>', + const data = { + relatedLinks: { + closing: '<a href="#">#23</a> and <a>#42</a>', + mentioned: '<a href="#">#7</a>', + }, }; - - beforeEach(() => { - vm.relatedLinks = relatedLinks; - }); + const vm = createComponent(data); describe('hasMultipleIssues', () => { it('should return true if the given text has multiple issues', () => { - expect(vm.hasMultipleIssues(relatedLinks.twoIssues)).toBeTruthy(); - expect(vm.hasMultipleIssues(relatedLinks.threeIssues)).toBeTruthy(); + expect(vm.hasMultipleIssues(data.relatedLinks.closing)).toBeTruthy(); }); it('should return false if the given text has one issue', () => { - expect(vm.hasMultipleIssues(relatedLinks.oneIssue)).toBeFalsy(); + expect(vm.hasMultipleIssues(data.relatedLinks.mentioned)).toBeFalsy(); }); }); describe('issueLabel', () => { it('should return true if the given text has multiple issues', () => { - expect(vm.issueLabel('twoIssues')).toEqual('issues'); - expect(vm.issueLabel('threeIssues')).toEqual('issues'); + expect(vm.issueLabel('closing')).toEqual('issues'); + }); + + it('should return false if the given text has one issue', () => { + expect(vm.issueLabel('mentioned')).toEqual('issue'); + }); + }); + + describe('verbLabel', () => { + it('should return true if the given text has multiple issues', () => { + expect(vm.verbLabel('closing')).toEqual('are'); }); it('should return false if the given text has one issue', () => { - expect(vm.issueLabel('oneIssue')).toEqual('issue'); + expect(vm.verbLabel('mentioned')).toEqual('is'); }); }); }); describe('template', () => { - it('should have only have closing issues text', (done) => { - vm.relatedLinks = { - closing: '<a href="#">#23</a> and <a>#42</a>', - }; - - Vue.nextTick() - .then(() => { - const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim(); + it('should have only have closing issues text', () => { + const vm = createComponent({ + relatedLinks: { + closing: '<a href="#">#23</a> and <a>#42</a>', + }, + }); + const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim(); - expect(content).toContain('Closes issues #23 and #42'); - expect(content).not.toContain('mentioned'); - }) - .then(done) - .catch(done.fail); + expect(content).toContain('Closes issues #23 and #42'); + expect(content).not.toContain('mentioned'); }); - it('should have only have mentioned issues text', (done) => { - vm.relatedLinks = { - mentioned: '<a href="#">#7</a>', - }; - - Vue.nextTick() - .then(() => { - expect(vm.$el.innerText).toContain('issue #7'); - expect(vm.$el.innerText).toContain('is mentioned but will not be closed'); - expect(vm.$el.innerText).not.toContain('Closes'); - }) - .then(done) - .catch(done.fail); - }); + it('should have only have mentioned issues text', () => { + const vm = createComponent({ + relatedLinks: { + mentioned: '<a href="#">#7</a>', + }, + }); - it('should have closing and mentioned issues at the same time', (done) => { - vm.relatedLinks = { - closing: '<a href="#">#7</a>', - mentioned: '<a href="#">#23</a> and <a>#42</a>', - }; - - Vue.nextTick() - .then(() => { - const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim(); - - expect(content).toContain('Closes issue #7.'); - expect(content).toContain('issues #23 and #42'); - expect(content).toContain('are mentioned but will not be closed'); - }) - .then(done) - .catch(done.fail); + expect(vm.$el.innerText).toContain('issue #7'); + expect(vm.$el.innerText).toContain('is mentioned but will not be closed.'); + expect(vm.$el.innerText).not.toContain('Closes'); }); - it('should have assing issues link', (done) => { - vm.relatedLinks = { - assignToMe: '<a href="#">Assign yourself to these issues</a>', - }; - - Vue.nextTick() - .then(() => { - expect(vm.$el.innerText).toContain('Assign yourself to these issues'); - }) - .then(done) - .catch(done.fail); + it('should have closing and mentioned issues at the same time', () => { + const vm = createComponent({ + relatedLinks: { + closing: '<a href="#">#7</a>', + mentioned: '<a href="#">#23</a> and <a>#42</a>', + }, + }); + const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim(); + + expect(content).toContain('Closes issue #7.'); + expect(content).toContain('issues #23 and #42'); + expect(content).toContain('are mentioned but will not be closed.'); }); - it('should use different wording after merging', (done) => { - vm.isMerged = true; - vm.relatedLinks = { - closing: '<a href="#">#7</a>', - mentioned: '<a href="#">#23</a> and <a>#42</a>', - }; - - Vue.nextTick() - .then(() => { - const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim(); - - expect(content).toContain('Closed issue #7.'); - expect(content).toContain('issues #23 and #42'); - expect(content).toContain('are mentioned but were not closed'); - }) - .then(done) - .catch(done.fail); + it('should have assing issues link', () => { + const vm = createComponent({ + relatedLinks: { + assignToMe: '<a href="#">Assign yourself to these issues</a>', + }, + }); + + expect(vm.$el.innerText).toContain('Assign yourself to these issues'); }); }); }); diff --git a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js index 425dff89439..3a0c50b750f 100644 --- a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js +++ b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js @@ -48,13 +48,12 @@ describe('mrWidgetOptions', () => { }); describe('shouldRenderMergeHelp', () => { - it('should return false after merging', () => { - vm.mr.isMerged = true; + it('should return false for the initial merged state', () => { expect(vm.shouldRenderMergeHelp).toBeFalsy(); }); - it('should return true before merging', () => { - vm.mr.isMerged = false; + it('should return true for a state which requires help widget', () => { + vm.mr.state = 'conflicts'; expect(vm.shouldRenderMergeHelp).toBeTruthy(); }); }); diff --git a/spec/javascripts/vue_mr_widget/stores/mr_widget_store_spec.js b/spec/javascripts/vue_mr_widget/stores/mr_widget_store_spec.js index 71285866302..56dd0198ae2 100644 --- a/spec/javascripts/vue_mr_widget/stores/mr_widget_store_spec.js +++ b/spec/javascripts/vue_mr_widget/stores/mr_widget_store_spec.js @@ -18,17 +18,5 @@ describe('MergeRequestStore', () => { store.setData({ ...mockData, work_in_progress: !mockData.work_in_progress }); expect(store.hasSHAChanged).toBe(false); }); - - it('sets isMerged to true for merged state', () => { - store.setData({ ...mockData, state: 'merged' }); - - expect(store.isMerged).toBe(true); - }); - - it('sets isMerged to false for readyToMerge state', () => { - store.setData({ ...mockData, state: 'readyToMerge' }); - - expect(store.isMerged).toBe(false); - }); }); }); diff --git a/spec/javascripts/vue_shared/components/markdown/field_spec.js b/spec/javascripts/vue_shared/components/markdown/field_spec.js index 4bbaff561fc..291e19c9f3c 100644 --- a/spec/javascripts/vue_shared/components/markdown/field_spec.js +++ b/spec/javascripts/vue_shared/components/markdown/field_spec.js @@ -4,47 +4,33 @@ import fieldComponent from '~/vue_shared/components/markdown/field.vue'; describe('Markdown field component', () => { let vm; - beforeEach(() => { + beforeEach((done) => { vm = new Vue({ - render(createElement) { - return createElement( - fieldComponent, - { - props: { - markdownPreviewUrl: '/preview', - markdownDocs: '/docs', - }, - }, - [ - createElement('textarea', { - slot: 'textarea', - }), - ], - ); + data() { + return { + text: 'testing\n123', + }; }, - }); - }); - - it('creates a new instance of GL form', (done) => { - spyOn(gl, 'GLForm'); - vm.$mount(); - - Vue.nextTick(() => { - expect( - gl.GLForm, - ).toHaveBeenCalled(); - - done(); - }); + components: { + fieldComponent, + }, + template: ` + <field-component + marodown-preview-url="/preview" + markdown-docs="/docs" + > + <textarea + slot="textarea" + v-model="text"> + </textarea> + </field-component> + `, + }).$mount(); + + Vue.nextTick(done); }); describe('mounted', () => { - beforeEach((done) => { - vm.$mount(); - - Vue.nextTick(done); - }); - it('renders textarea inside backdrop', () => { expect( vm.$el.querySelector('.zen-backdrop textarea'), @@ -117,5 +103,52 @@ describe('Markdown field component', () => { }); }); }); + + describe('markdown buttons', () => { + it('converts single words', (done) => { + const textarea = vm.$el.querySelector('textarea'); + + textarea.setSelectionRange(0, 7); + vm.$el.querySelector('.js-md').click(); + + Vue.nextTick(() => { + expect( + textarea.value, + ).toContain('**testing**'); + + done(); + }); + }); + + it('converts a line', (done) => { + const textarea = vm.$el.querySelector('textarea'); + + textarea.setSelectionRange(0, 0); + vm.$el.querySelectorAll('.js-md')[4].click(); + + Vue.nextTick(() => { + expect( + textarea.value, + ).toContain('* testing'); + + done(); + }); + }); + + it('converts multiple lines', (done) => { + const textarea = vm.$el.querySelector('textarea'); + + textarea.setSelectionRange(0, 50); + vm.$el.querySelectorAll('.js-md')[4].click(); + + Vue.nextTick(() => { + expect( + textarea.value, + ).toContain('* testing\n* 123'); + + done(); + }); + }); + }); }); }); diff --git a/spec/javascripts/vue_shared/components/time_ago_tooltip_spec.js b/spec/javascripts/vue_shared/components/time_ago_tooltip_spec.js index f3b4adc0b70..b4c1f70ed1e 100644 --- a/spec/javascripts/vue_shared/components/time_ago_tooltip_spec.js +++ b/spec/javascripts/vue_shared/components/time_ago_tooltip_spec.js @@ -22,7 +22,6 @@ describe('Time ago with tooltip component', () => { }).$mount(); expect(vm.$el.tagName).toEqual('TIME'); - expect(vm.$el.classList.contains('js-vue-timeago')).toEqual(true); expect( vm.$el.getAttribute('data-original-title'), ).toEqual(gl.utils.formatDate('2017-05-08T14:57:39.781Z')); diff --git a/spec/javascripts/vue_shared/directives/tooltip_spec.js b/spec/javascripts/vue_shared/directives/tooltip_spec.js new file mode 100644 index 00000000000..b1b3071527b --- /dev/null +++ b/spec/javascripts/vue_shared/directives/tooltip_spec.js @@ -0,0 +1,63 @@ +import Vue from 'vue'; +import tooltip from '~/vue_shared/directives/tooltip'; + +describe('Tooltip directive', () => { + let vm; + + afterEach(() => { + if (vm) { + vm.$destroy(); + } + }); + + describe('with a single tooltip', () => { + beforeEach(() => { + const SomeComponent = Vue.extend({ + directives: { + tooltip, + }, + template: ` + <div + v-tooltip + title="foo"> + </div> + `, + }); + + vm = new SomeComponent().$mount(); + }); + + it('should have tooltip plugin applied', () => { + expect($(vm.$el).data('bs.tooltip')).toBeDefined(); + }); + }); + + describe('with multiple tooltips', () => { + beforeEach(() => { + const SomeComponent = Vue.extend({ + directives: { + tooltip, + }, + template: ` + <div> + <div + v-tooltip + class="js-look-for-tooltip" + title="foo"> + </div> + <div + v-tooltip + title="bar"> + </div> + </div> + `, + }); + + vm = new SomeComponent().$mount(); + }); + + it('should have tooltip plugin applied to all instances', () => { + expect($(vm.$el).find('.js-look-for-tooltip').data('bs.tooltip')).toBeDefined(); + }); + }); +}); diff --git a/spec/lib/banzai/cross_project_reference_spec.rb b/spec/lib/banzai/cross_project_reference_spec.rb index deaabceef1c..787212581e2 100644 --- a/spec/lib/banzai/cross_project_reference_spec.rb +++ b/spec/lib/banzai/cross_project_reference_spec.rb @@ -24,8 +24,8 @@ describe Banzai::CrossProjectReference, lib: true do it 'returns the referenced project' do project2 = double('referenced project') - expect(Project).to receive(:find_by_full_path). - with('cross/reference').and_return(project2) + expect(Project).to receive(:find_by_full_path) + .with('cross/reference').and_return(project2) expect(project_from_ref('cross/reference')).to eq project2 end diff --git a/spec/lib/banzai/filter/abstract_reference_filter_spec.rb b/spec/lib/banzai/filter/abstract_reference_filter_spec.rb index 787c2372c5b..27532f96f56 100644 --- a/spec/lib/banzai/filter/abstract_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/abstract_reference_filter_spec.rb @@ -23,11 +23,11 @@ describe Banzai::Filter::AbstractReferenceFilter do doc = Nokogiri::HTML.fragment('') filter = described_class.new(doc, project: project) - expect(filter).to receive(:references_per_project). - and_return({ project.path_with_namespace => Set.new(%w[1]) }) + expect(filter).to receive(:references_per_project) + .and_return({ project.path_with_namespace => Set.new(%w[1]) }) - expect(filter.projects_per_reference). - to eq({ project.path_with_namespace => project }) + expect(filter.projects_per_reference) + .to eq({ project.path_with_namespace => project }) end end @@ -37,26 +37,26 @@ describe Banzai::Filter::AbstractReferenceFilter do context 'with RequestStore disabled' do it 'returns a list of Projects for a list of paths' do - expect(filter.find_projects_for_paths([project.path_with_namespace])). - to eq([project]) + expect(filter.find_projects_for_paths([project.path_with_namespace])) + .to eq([project]) end it "return an empty array for paths that don't exist" do - expect(filter.find_projects_for_paths(['nonexistent/project'])). - to eq([]) + expect(filter.find_projects_for_paths(['nonexistent/project'])) + .to eq([]) end end context 'with RequestStore enabled', :request_store do it 'returns a list of Projects for a list of paths' do - expect(filter.find_projects_for_paths([project.path_with_namespace])). - to eq([project]) + expect(filter.find_projects_for_paths([project.path_with_namespace])) + .to eq([project]) end context "when no project with that path exists" do it "returns no value" do - expect(filter.find_projects_for_paths(['nonexistent/project'])). - to eq([]) + expect(filter.find_projects_for_paths(['nonexistent/project'])) + .to eq([]) end it "adds the ref to the project refs cache" do @@ -75,8 +75,8 @@ describe Banzai::Filter::AbstractReferenceFilter do end it "return an empty array for paths that don't exist" do - expect(filter.find_projects_for_paths(['nonexistent/project'])). - to eq([]) + expect(filter.find_projects_for_paths(['nonexistent/project'])) + .to eq([]) end end end diff --git a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb index deadc36524c..fc67c7ec3c4 100644 --- a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb @@ -28,15 +28,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid two-dot reference' do doc = reference_filter("See #{reference2}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_compare_url(project.namespace, project, range2.to_param) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_compare_url(project.namespace, project, range2.to_param) end it 'links to a valid three-dot reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_compare_url(project.namespace, project, range.to_param) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_compare_url(project.namespace, project, range.to_param) end it 'links to a valid short ID' do @@ -105,15 +105,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) end it 'link has valid text' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.text). - to eql("#{project2.path_with_namespace}@#{commit1.short_id}...#{commit2.short_id}") + expect(doc.css('a').first.text) + .to eql("#{project2.path_with_namespace}@#{commit1.short_id}...#{commit2.short_id}") end it 'has valid text' do @@ -140,15 +140,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) end it 'link has valid text' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.text). - to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") + expect(doc.css('a').first.text) + .to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") end it 'has valid text' do @@ -175,15 +175,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) end it 'link has valid text' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.text). - to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") + expect(doc.css('a').first.text) + .to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") end it 'has valid text' do @@ -214,8 +214,8 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq reference + expect(doc.css('a').first.attr('href')) + .to eq reference end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb index a19aac61229..c4d8d3b6682 100644 --- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb @@ -26,8 +26,8 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do doc = reference_filter("See #{reference[0...size]}") expect(doc.css('a').first.text).to eq commit.short_id - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_commit_url(project.namespace, project, reference) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_commit_url(project.namespace, project, reference) end end @@ -180,8 +180,8 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_commit_url(project2.namespace, project2, commit.id) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_commit_url(project2.namespace, project2, commit.id) end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb index 76cefe112fb..a4bb043f8f1 100644 --- a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb @@ -58,8 +58,8 @@ describe Banzai::Filter::ExternalIssueReferenceFilter, lib: true do end it 'escapes the title attribute' do - allow(project.external_issue_tracker).to receive(:title). - and_return(%{"></a>whatever<a title="}) + allow(project.external_issue_tracker).to receive(:title) + .and_return(%{"></a>whatever<a title="}) doc = filter("Issue #{reference}") expect(doc.text).to eq "Issue #{reference}" diff --git a/spec/lib/banzai/filter/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/issue_reference_filter_spec.rb index f1082495fcc..e5c1deb338b 100644 --- a/spec/lib/banzai/filter/issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/issue_reference_filter_spec.rb @@ -49,8 +49,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("Fixed #{reference}") - expect(doc.css('a').first.attr('href')). - to eq helper.url_for_issue(issue.iid, project) + expect(doc.css('a').first.attr('href')) + .to eq helper.url_for_issue(issue.iid, project) end it 'links with adjacent text' do @@ -137,9 +137,9 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:reference) { "#{project2.path_with_namespace}##{issue.iid}" } it 'ignores valid references when cross-reference project uses external tracker' do - expect_any_instance_of(described_class).to receive(:find_object). - with(project2, issue.iid). - and_return(nil) + expect_any_instance_of(described_class).to receive(:find_object) + .with(project2, issue.iid) + .and_return(nil) exp = act = "Issue #{reference}" expect(reference_filter(act).to_html).to eq exp @@ -148,8 +148,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')) + .to eq helper.url_for_issue(issue.iid, project2) end it 'link has valid text' do @@ -181,9 +181,9 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:reference) { "#{project2.path_with_namespace}##{issue.iid}" } it 'ignores valid references when cross-reference project uses external tracker' do - expect_any_instance_of(described_class).to receive(:find_object). - with(project2, issue.iid). - and_return(nil) + expect_any_instance_of(described_class).to receive(:find_object) + .with(project2, issue.iid) + .and_return(nil) exp = act = "Issue #{reference}" expect(reference_filter(act).to_html).to eq exp @@ -192,8 +192,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')) + .to eq helper.url_for_issue(issue.iid, project2) end it 'link has valid text' do @@ -225,9 +225,9 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:reference) { "#{project2.path}##{issue.iid}" } it 'ignores valid references when cross-reference project uses external tracker' do - expect_any_instance_of(described_class).to receive(:find_object). - with(project2, issue.iid). - and_return(nil) + expect_any_instance_of(described_class).to receive(:find_object) + .with(project2, issue.iid) + .and_return(nil) exp = act = "Issue #{reference}" expect(reference_filter(act).to_html).to eq exp @@ -236,8 +236,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')) + .to eq helper.url_for_issue(issue.iid, project2) end it 'link has valid text' do @@ -270,8 +270,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq reference + expect(doc.css('a').first.attr('href')) + .to eq reference end it 'links with adjacent text' do @@ -292,8 +292,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference_link}") - expect(doc.css('a').first.attr('href')). - to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')) + .to eq helper.url_for_issue(issue.iid, project2) end it 'links with adjacent text' do @@ -314,8 +314,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference_link}") - expect(doc.css('a').first.attr('href')). - to eq helper.url_for_issue(issue.iid, project2) + "#note_123" + expect(doc.css('a').first.attr('href')) + .to eq helper.url_for_issue(issue.iid, project2) + "#note_123" end it 'links with adjacent text' do @@ -330,14 +330,14 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do doc = Nokogiri::HTML.fragment('') filter = described_class.new(doc, project: project) - expect(filter).to receive(:projects_per_reference). - and_return({ project.path_with_namespace => project }) + expect(filter).to receive(:projects_per_reference) + .and_return({ project.path_with_namespace => project }) - expect(filter).to receive(:references_per_project). - and_return({ project.path_with_namespace => Set.new([issue.iid]) }) + expect(filter).to receive(:references_per_project) + .and_return({ project.path_with_namespace => Set.new([issue.iid]) }) - expect(filter.issues_per_project). - to eq({ project => { issue.iid => issue } }) + expect(filter.issues_per_project) + .to eq({ project => { issue.iid => issue } }) end end @@ -348,14 +348,14 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do expect(project).to receive(:default_issues_tracker?).and_return(false) - expect(filter).to receive(:projects_per_reference). - and_return({ project.path_with_namespace => project }) + expect(filter).to receive(:projects_per_reference) + .and_return({ project.path_with_namespace => project }) - expect(filter).to receive(:references_per_project). - and_return({ project.path_with_namespace => Set.new([1]) }) + expect(filter).to receive(:references_per_project) + .and_return({ project.path_with_namespace => Set.new([1]) }) - expect(filter.issues_per_project[project][1]). - to be_an_instance_of(ExternalIssue) + expect(filter.issues_per_project[project][1]) + .to be_an_instance_of(ExternalIssue) end end end diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb index 284641fb20a..cb3cf982351 100644 --- a/spec/lib/banzai/filter/label_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb @@ -72,8 +72,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_issues_url(project.namespace, project, label_name: label.name) end it 'links with adjacent text' do @@ -95,8 +95,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See gfm' end @@ -119,8 +119,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See 2fa' end @@ -143,8 +143,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See ?g.fm&' end @@ -168,8 +168,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See gfm references' end @@ -192,8 +192,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See 2 factor authentication' end @@ -216,8 +216,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See g.fm & references?' end @@ -287,8 +287,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_issues_url(project.namespace, project, label_name: label.name) end it 'links with adjacent text' do @@ -324,8 +324,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}", project: project) - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: group_label.name) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_issues_url(project.namespace, project, label_name: group_label.name) expect(doc.text).to eq 'See gfm references' end @@ -347,8 +347,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}", project: project) - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_issues_url(project.namespace, project, label_name: group_label.name) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_issues_url(project.namespace, project, label_name: group_label.name) expect(doc.text).to eq "See gfm references" end @@ -447,8 +447,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do end it 'has valid color' do - expect(result.css('a span').first.attr('style')). - to match /background-color: #00ff00/ + expect(result.css('a span').first.attr('style')) + .to match /background-color: #00ff00/ end it 'has valid link text' do @@ -483,18 +483,18 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do end it 'has valid color' do - expect(result.css('a span').first.attr('style')). - to match /background-color: #00ff00/ + expect(result.css('a span').first.attr('style')) + .to match /background-color: #00ff00/ end it 'has valid link text' do - expect(result.css('a').first.text). - to eq "#{group_label.name} in #{another_project.name_with_namespace}" + expect(result.css('a').first.text) + .to eq "#{group_label.name} in #{another_project.name_with_namespace}" end it 'has valid text' do - expect(result.text). - to eq "See #{group_label.name} in #{another_project.name_with_namespace}" + expect(result.text) + .to eq "See #{group_label.name} in #{another_project.name_with_namespace}" end it 'ignores invalid IDs on the referenced label' do @@ -513,25 +513,25 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}", project: project) } it 'points to referenced project issues page' do - expect(result.css('a').first.attr('href')). - to eq urls.namespace_project_issues_url(another_project.namespace, + expect(result.css('a').first.attr('href')) + .to eq urls.namespace_project_issues_url(another_project.namespace, another_project, label_name: group_label.name) end it 'has valid color' do - expect(result.css('a span').first.attr('style')). - to match /background-color: #00ff00/ + expect(result.css('a span').first.attr('style')) + .to match /background-color: #00ff00/ end it 'has valid link text' do - expect(result.css('a').first.text). - to eq "#{group_label.name} in #{another_project.name}" + expect(result.css('a').first.text) + .to eq "#{group_label.name} in #{another_project.name}" end it 'has valid text' do - expect(result.text). - to eq "See #{group_label.name} in #{another_project.name}" + expect(result.text) + .to eq "See #{group_label.name} in #{another_project.name}" end it 'ignores invalid IDs on the referenced label' do @@ -590,8 +590,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do end it 'has valid color' do - expect(result.css('a span').first.attr('style')). - to match /background-color: #00ff00/ + expect(result.css('a span').first.attr('style')) + .to match /background-color: #00ff00/ end it 'has valid link text' do diff --git a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb index 40232f6e426..cd91681551e 100644 --- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb @@ -36,8 +36,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_merge_request_url(project.namespace, project, merge) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_merge_request_url(project.namespace, project, merge) end it 'links with adjacent text' do @@ -107,8 +107,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_merge_request_url(project2.namespace, + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_merge_request_url(project2.namespace, project2, merge) end @@ -141,8 +141,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_merge_request_url(project2.namespace, + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_merge_request_url(project2.namespace, project2, merge) end @@ -175,8 +175,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_merge_request_url(project2.namespace, + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_merge_request_url(project2.namespace, project2, merge) end @@ -208,8 +208,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq reference + expect(doc.css('a').first.attr('href')) + .to eq reference end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index a317c751d32..fe88b9cb73e 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -44,16 +44,16 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls. - namespace_project_milestone_path(project.namespace, project, milestone) + expect(link).to eq urls + .namespace_project_milestone_path(project.namespace, project, milestone) end context 'Integer-based references' do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_milestone_url(project.namespace, project, milestone) end it 'links with adjacent text' do @@ -75,8 +75,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_milestone_url(project.namespace, project, milestone) expect(doc.text).to eq 'See gfm' end @@ -99,8 +99,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_milestone_url(project.namespace, project, milestone) expect(doc.text).to eq 'See gfm references' end @@ -122,8 +122,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_milestone_url(project.namespace, project, milestone) end it 'links with adjacent text' do @@ -156,8 +156,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do - expect(result.css('a').first.attr('href')).to eq urls. - namespace_project_milestone_url(another_project.namespace, + expect(result.css('a').first.attr('href')).to eq urls + .namespace_project_milestone_url(another_project.namespace, another_project, milestone) end @@ -165,15 +165,15 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'link has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.css('a').first.text). - to eq("#{milestone.name} in #{another_project.path_with_namespace}") + expect(doc.css('a').first.text) + .to eq("#{milestone.name} in #{another_project.path_with_namespace}") end it 'has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.text). - to eq("See (#{milestone.name} in #{another_project.path_with_namespace}.)") + expect(doc.text) + .to eq("See (#{milestone.name} in #{another_project.path_with_namespace}.)") end it 'escapes the name attribute' do @@ -181,8 +181,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.text). - to eq "#{milestone.name} in #{another_project.path_with_namespace}" + expect(doc.css('a').first.text) + .to eq "#{milestone.name} in #{another_project.path_with_namespace}" end end @@ -195,8 +195,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do - expect(result.css('a').first.attr('href')).to eq urls. - namespace_project_milestone_url(another_project.namespace, + expect(result.css('a').first.attr('href')).to eq urls + .namespace_project_milestone_url(another_project.namespace, another_project, milestone) end @@ -204,15 +204,15 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'link has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.css('a').first.text). - to eq("#{milestone.name} in #{another_project.path}") + expect(doc.css('a').first.text) + .to eq("#{milestone.name} in #{another_project.path}") end it 'has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.text). - to eq("See (#{milestone.name} in #{another_project.path}.)") + expect(doc.text) + .to eq("See (#{milestone.name} in #{another_project.path}.)") end it 'escapes the name attribute' do @@ -220,8 +220,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.text). - to eq "#{milestone.name} in #{another_project.path}" + expect(doc.css('a').first.text) + .to eq "#{milestone.name} in #{another_project.path}" end end @@ -234,8 +234,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do - expect(result.css('a').first.attr('href')).to eq urls. - namespace_project_milestone_url(another_project.namespace, + expect(result.css('a').first.attr('href')).to eq urls + .namespace_project_milestone_url(another_project.namespace, another_project, milestone) end @@ -243,15 +243,15 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'link has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.css('a').first.text). - to eq("#{milestone.name} in #{another_project.path}") + expect(doc.css('a').first.text) + .to eq("#{milestone.name} in #{another_project.path}") end it 'has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.text). - to eq("See (#{milestone.name} in #{another_project.path}.)") + expect(doc.text) + .to eq("See (#{milestone.name} in #{another_project.path}.)") end it 'escapes the name attribute' do @@ -259,8 +259,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.text). - to eq "#{milestone.name} in #{another_project.path}" + expect(doc.css('a').first.text) + .to eq "#{milestone.name} in #{another_project.path}" end end end diff --git a/spec/lib/banzai/filter/redactor_filter_spec.rb b/spec/lib/banzai/filter/redactor_filter_spec.rb index 97504aebed5..b81cdbb8957 100644 --- a/spec/lib/banzai/filter/redactor_filter_spec.rb +++ b/spec/lib/banzai/filter/redactor_filter_spec.rb @@ -33,9 +33,9 @@ describe Banzai::Filter::RedactorFilter, lib: true do end before do - allow(Banzai::ReferenceParser).to receive(:[]). - with('test'). - and_return(parser_class) + allow(Banzai::ReferenceParser).to receive(:[]) + .with('test') + .and_return(parser_class) end context 'valid projects' do diff --git a/spec/lib/banzai/filter/reference_filter_spec.rb b/spec/lib/banzai/filter/reference_filter_spec.rb index 55e681f6faf..ba0fa4a609a 100644 --- a/spec/lib/banzai/filter/reference_filter_spec.rb +++ b/spec/lib/banzai/filter/reference_filter_spec.rb @@ -8,8 +8,8 @@ describe Banzai::Filter::ReferenceFilter, lib: true do document = Nokogiri::HTML.fragment('<a href="foo">foo</a>') filter = described_class.new(document, project: project) - expect { |b| filter.each_node(&b) }. - to yield_with_args(an_instance_of(Nokogiri::XML::Element)) + expect { |b| filter.each_node(&b) } + .to yield_with_args(an_instance_of(Nokogiri::XML::Element)) end it 'returns an Enumerator when no block is given' do diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb index 1957ba739e2..1ce7bd7706e 100644 --- a/spec/lib/banzai/filter/relative_link_filter_spec.rb +++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb @@ -72,15 +72,15 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do it 'ignores ref if commit is passed' do doc = filter(link('non/existent.file'), commit: project.commit('empty-branch') ) - expect(doc.at_css('a')['href']). - to eq "/#{project_path}/#{ref}/non/existent.file" # non-existent files have no leading blob/raw/tree + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/#{ref}/non/existent.file" # non-existent files have no leading blob/raw/tree end shared_examples :valid_repository do it 'rebuilds absolute URL for a file in the repo' do doc = filter(link('/doc/api/README.md')) - expect(doc.at_css('a')['href']). - to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'ignores absolute URLs with two leading slashes' do @@ -90,71 +90,71 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do it 'rebuilds relative URL for a file in the repo' do doc = filter(link('doc/api/README.md')) - expect(doc.at_css('a')['href']). - to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo with leading ./' do doc = filter(link('./doc/api/README.md')) - expect(doc.at_css('a')['href']). - to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo up one directory' do relative_link = link('../api/README.md') doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md') - expect(doc.at_css('a')['href']). - to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo up multiple directories' do relative_link = link('../../../api/README.md') doc = filter(relative_link, requested_path: 'doc/foo/bar/baz/README.md') - expect(doc.at_css('a')['href']). - to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repository root' do relative_link = link('../README.md') doc = filter(relative_link, requested_path: 'doc/some-file.md') - expect(doc.at_css('a')['href']). - to eq "/#{project_path}/blob/#{ref}/README.md" + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/blob/#{ref}/README.md" end it 'rebuilds relative URL for a file in the repo with an anchor' do doc = filter(link('README.md#section')) - expect(doc.at_css('a')['href']). - to eq "/#{project_path}/blob/#{ref}/README.md#section" + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/blob/#{ref}/README.md#section" end it 'rebuilds relative URL for a directory in the repo' do doc = filter(link('doc/api/')) - expect(doc.at_css('a')['href']). - to eq "/#{project_path}/tree/#{ref}/doc/api" + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/tree/#{ref}/doc/api" end it 'rebuilds relative URL for an image in the repo' do doc = filter(image('files/images/logo-black.png')) - expect(doc.at_css('img')['src']). - to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" + expect(doc.at_css('img')['src']) + .to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" end it 'rebuilds relative URL for link to an image in the repo' do doc = filter(link('files/images/logo-black.png')) - expect(doc.at_css('a')['href']). - to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" end it 'rebuilds relative URL for a video in the repo' do doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video') - expect(doc.at_css('video')['src']). - to eq "/#{project_path}/raw/video/files/videos/intro.mp4" + expect(doc.at_css('video')['src']) + .to eq "/#{project_path}/raw/video/files/videos/intro.mp4" end it 'does not modify relative URL with an anchor only' do diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb index fb7862f49a2..a8a0aa6d395 100644 --- a/spec/lib/banzai/filter/sanitization_filter_spec.rb +++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb @@ -221,8 +221,8 @@ describe Banzai::Filter::SanitizationFilter, lib: true do end it 'disallows invalid URIs' do - expect(Addressable::URI).to receive(:parse).with('foo://example.com'). - and_raise(Addressable::URI::InvalidURIError) + expect(Addressable::URI).to receive(:parse).with('foo://example.com') + .and_raise(Addressable::URI::InvalidURIError) input = '<a href="foo://example.com">Foo</a>' output = filter(input) diff --git a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb index e036514d283..e851120bc3a 100644 --- a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb @@ -22,8 +22,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls. - namespace_project_snippet_url(project.namespace, project, snippet) + expect(doc.css('a').first.attr('href')).to eq urls + .namespace_project_snippet_url(project.namespace, project, snippet) end it 'links with adjacent text' do @@ -88,8 +88,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'link has valid text' do @@ -121,8 +121,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'link has valid text' do @@ -154,8 +154,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'link has valid text' do @@ -186,8 +186,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/upload_link_filter_spec.rb b/spec/lib/banzai/filter/upload_link_filter_spec.rb index 639cac6406a..6327ca8bbfd 100644 --- a/spec/lib/banzai/filter/upload_link_filter_spec.rb +++ b/spec/lib/banzai/filter/upload_link_filter_spec.rb @@ -51,22 +51,22 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do context 'with a valid repository' do it 'rebuilds relative URL for a link' do doc = filter(link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('a')['href']). - to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('a')['href']) + .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" doc = filter(nested_link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('a')['href']). - to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('a')['href']) + .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" end it 'rebuilds relative URL for an image' do doc = filter(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('img')['src']). - to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('img')['src']) + .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" doc = filter(nested_image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('img')['src']). - to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('img')['src']) + .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" end it 'does not modify absolute URL' do @@ -79,10 +79,10 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do escaped = Addressable::URI.escape(path) # Stub these methods so the file doesn't actually need to be in the repo - allow_any_instance_of(described_class). - to receive(:file_exists?).and_return(true) - allow_any_instance_of(described_class). - to receive(:image?).with(path).and_return(true) + allow_any_instance_of(described_class) + .to receive(:file_exists?).and_return(true) + allow_any_instance_of(described_class) + .to receive(:image?).with(path).and_return(true) doc = filter(image(escaped)) expect(doc.at_css('img')['src']).to match "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/%ED%95%9C%EA%B8%80.png" diff --git a/spec/lib/banzai/note_renderer_spec.rb b/spec/lib/banzai/note_renderer_spec.rb index 49556074278..32764bee5eb 100644 --- a/spec/lib/banzai/note_renderer_spec.rb +++ b/spec/lib/banzai/note_renderer_spec.rb @@ -8,15 +8,15 @@ describe Banzai::NoteRenderer do wiki = double(:wiki) user = double(:user) - expect(Banzai::ObjectRenderer).to receive(:new). - with(project, user, + expect(Banzai::ObjectRenderer).to receive(:new) + .with(project, user, requested_path: 'foo', project_wiki: wiki, - ref: 'bar'). - and_call_original + ref: 'bar') + .and_call_original - expect_any_instance_of(Banzai::ObjectRenderer). - to receive(:render).with([note], :note) + expect_any_instance_of(Banzai::ObjectRenderer) + .to receive(:render).with([note], :note) described_class.render([note], project, user, 'foo', wiki, 'bar') end diff --git a/spec/lib/banzai/redactor_spec.rb b/spec/lib/banzai/redactor_spec.rb index e6f2963193c..81ae5685b10 100644 --- a/spec/lib/banzai/redactor_spec.rb +++ b/spec/lib/banzai/redactor_spec.rb @@ -12,11 +12,11 @@ describe Banzai::Redactor do end it 'redacts an array of documents' do - doc1 = Nokogiri::HTML. - fragment('<a class="gfm" data-reference-type="issue">foo</a>') + doc1 = Nokogiri::HTML + .fragment('<a class="gfm" data-reference-type="issue">foo</a>') - doc2 = Nokogiri::HTML. - fragment('<a class="gfm" data-reference-type="issue">bar</a>') + doc2 = Nokogiri::HTML + .fragment('<a class="gfm" data-reference-type="issue">bar</a>') redacted_data = redactor.redact([doc1, doc2]) @@ -93,9 +93,9 @@ describe Banzai::Redactor do doc = Nokogiri::HTML.fragment('<a href="foo">foo</a>') node = doc.children[0] - expect(redactor).to receive(:nodes_visible_to_user). - with([node]). - and_return(Set.new) + expect(redactor).to receive(:nodes_visible_to_user) + .with([node]) + .and_return(Set.new) redactor.redact_document_nodes([{ document: doc, nodes: [node] }]) @@ -108,10 +108,10 @@ describe Banzai::Redactor do doc = Nokogiri::HTML.fragment('<a data-reference-type="issue"></a>') node = doc.children[0] - expect_any_instance_of(Banzai::ReferenceParser::IssueParser). - to receive(:nodes_visible_to_user). - with(user, [node]). - and_return([node]) + expect_any_instance_of(Banzai::ReferenceParser::IssueParser) + .to receive(:nodes_visible_to_user) + .with(user, [node]) + .and_return([node]) expect(redactor.nodes_visible_to_user([node])).to eq(Set.new([node])) end diff --git a/spec/lib/banzai/reference_parser/base_parser_spec.rb b/spec/lib/banzai/reference_parser/base_parser_spec.rb index 76fab93821a..b444ca05b8e 100644 --- a/spec/lib/banzai/reference_parser/base_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/base_parser_spec.rb @@ -54,8 +54,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do describe '#referenced_by' do context 'when references_relation is implemented' do it 'returns a collection of objects' do - links = Nokogiri::HTML.fragment("<a data-foo='#{user.id}'></a>"). - children + links = Nokogiri::HTML.fragment("<a data-foo='#{user.id}'></a>") + .children expect(subject).to receive(:references_relation).and_return(User) expect(subject.referenced_by(links)).to eq([user]) @@ -66,8 +66,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'raises NotImplementedError' do links = Nokogiri::HTML.fragment('<a data-foo="1"></a>').children - expect { subject.referenced_by(links) }. - to raise_error(NotImplementedError) + expect { subject.referenced_by(links) } + .to raise_error(NotImplementedError) end end end @@ -80,8 +80,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do describe '#gather_attributes_per_project' do it 'returns a Hash containing attribute values per project' do - link = Nokogiri::HTML.fragment('<a data-project="1" data-foo="2"></a>'). - children[0] + link = Nokogiri::HTML.fragment('<a data-project="1" data-foo="2"></a>') + .children[0] hash = subject.gather_attributes_per_project([link], 'data-foo') @@ -95,19 +95,19 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'returns a Hash grouping objects per node' do link = double(:link) - expect(link).to receive(:has_attribute?). - with('data-user'). - and_return(true) + expect(link).to receive(:has_attribute?) + .with('data-user') + .and_return(true) - expect(link).to receive(:attr). - with('data-user'). - and_return(user.id.to_s) + expect(link).to receive(:attr) + .with('data-user') + .and_return(user.id.to_s) nodes = [link] - expect(subject).to receive(:unique_attribute_values). - with(nodes, 'data-user'). - and_return([user.id.to_s]) + expect(subject).to receive(:unique_attribute_values) + .with(nodes, 'data-user') + .and_return([user.id.to_s]) hash = subject.grouped_objects_for_nodes(nodes, User, 'data-user') @@ -117,20 +117,20 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'returns an empty Hash when entry does not exist in the database', :request_store do link = double(:link) - expect(link).to receive(:has_attribute?). - with('data-user'). - and_return(true) + expect(link).to receive(:has_attribute?) + .with('data-user') + .and_return(true) - expect(link).to receive(:attr). - with('data-user'). - and_return('1') + expect(link).to receive(:attr) + .with('data-user') + .and_return('1') nodes = [link] bad_id = user.id + 100 - expect(subject).to receive(:unique_attribute_values). - with(nodes, 'data-user'). - and_return([bad_id.to_s]) + expect(subject).to receive(:unique_attribute_values) + .with(nodes, 'data-user') + .and_return([bad_id.to_s]) hash = subject.grouped_objects_for_nodes(nodes, User, 'data-user') @@ -142,15 +142,15 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'returns an Array of unique values' do link = double(:link) - expect(link).to receive(:has_attribute?). - with('data-foo'). - twice. - and_return(true) + expect(link).to receive(:has_attribute?) + .with('data-foo') + .twice + .and_return(true) - expect(link).to receive(:attr). - with('data-foo'). - twice. - and_return('1') + expect(link).to receive(:attr) + .with('data-foo') + .twice + .and_return('1') nodes = [link, link] @@ -167,9 +167,9 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do instance = dummy.new(project, user) document = Nokogiri::HTML.fragment('<a class="gfm"></a><a class="gfm" data-reference-type="test"></a>') - expect(instance).to receive(:gather_references). - with([document.children[1]]). - and_return([user]) + expect(instance).to receive(:gather_references) + .with([document.children[1]]) + .and_return([user]) expect(instance.process([document])).to eq([user]) end @@ -179,9 +179,9 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do let(:link) { double(:link) } it 'does not process links a user can not reference' do - expect(subject).to receive(:nodes_user_can_reference). - with(user, [link]). - and_return([]) + expect(subject).to receive(:nodes_user_can_reference) + .with(user, [link]) + .and_return([]) expect(subject).to receive(:referenced_by).with([]) @@ -189,13 +189,13 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do end it 'does not process links a user can not see' do - expect(subject).to receive(:nodes_user_can_reference). - with(user, [link]). - and_return([link]) + expect(subject).to receive(:nodes_user_can_reference) + .with(user, [link]) + .and_return([link]) - expect(subject).to receive(:nodes_visible_to_user). - with(user, [link]). - and_return([]) + expect(subject).to receive(:nodes_visible_to_user) + .with(user, [link]) + .and_return([]) expect(subject).to receive(:referenced_by).with([]) @@ -203,13 +203,13 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do end it 'returns the references if a user can reference and see a link' do - expect(subject).to receive(:nodes_user_can_reference). - with(user, [link]). - and_return([link]) + expect(subject).to receive(:nodes_user_can_reference) + .with(user, [link]) + .and_return([link]) - expect(subject).to receive(:nodes_visible_to_user). - with(user, [link]). - and_return([link]) + expect(subject).to receive(:nodes_visible_to_user) + .with(user, [link]) + .and_return([link]) expect(subject).to receive(:referenced_by).with([link]) @@ -221,8 +221,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'delegates the permissions check to the Ability class' do user = double(:user) - expect(Ability).to receive(:allowed?). - with(user, :read_project, project) + expect(Ability).to receive(:allowed?) + .with(user, :read_project, project) subject.can?(user, :read_project, project) end @@ -230,8 +230,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do describe '#find_projects_for_hash_keys' do it 'returns a list of Projects' do - expect(subject.find_projects_for_hash_keys(project.id => project)). - to eq([project]) + expect(subject.find_projects_for_hash_keys(project.id => project)) + .to eq([project]) end end @@ -243,8 +243,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do expect(collection).to receive(:where).twice.and_call_original 2.times do - expect(subject.collection_objects_for_ids(collection, [user.id])). - to eq([user]) + expect(subject.collection_objects_for_ids(collection, [user.id])) + .to eq([user]) end end end @@ -258,8 +258,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do end it 'queries the collection on the first call' do - expect(subject.collection_objects_for_ids(User, [user.id])). - to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id])) + .to eq([user]) end it 'does not query previously queried objects' do @@ -268,34 +268,34 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do expect(collection).to receive(:where).once.and_call_original 2.times do - expect(subject.collection_objects_for_ids(collection, [user.id])). - to eq([user]) + expect(subject.collection_objects_for_ids(collection, [user.id])) + .to eq([user]) end end it 'casts String based IDs to Fixnums before querying objects' do 2.times do - expect(subject.collection_objects_for_ids(User, [user.id.to_s])). - to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id.to_s])) + .to eq([user]) end end it 'queries any additional objects after the first call' do other_user = create(:user) - expect(subject.collection_objects_for_ids(User, [user.id])). - to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id])) + .to eq([user]) - expect(subject.collection_objects_for_ids(User, [user.id, other_user.id])). - to eq([user, other_user]) + expect(subject.collection_objects_for_ids(User, [user.id, other_user.id])) + .to eq([user, other_user]) end it 'caches objects on a per collection class basis' do - expect(subject.collection_objects_for_ids(User, [user.id])). - to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id])) + .to eq([user]) - expect(subject.collection_objects_for_ids(Project, [project.id])). - to eq([project]) + expect(subject.collection_objects_for_ids(Project, [project.id])) + .to eq([project]) end end end diff --git a/spec/lib/banzai/reference_parser/commit_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_parser_spec.rb index 583ce63a8ab..a314a6119cb 100644 --- a/spec/lib/banzai/reference_parser/commit_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/commit_parser_spec.rb @@ -32,30 +32,30 @@ describe Banzai::ReferenceParser::CommitParser, lib: true do it 'returns an Array of commits' do commit = double(:commit) - allow_any_instance_of(Project).to receive(:valid_repo?). - and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?) + .and_return(true) - expect(subject).to receive(:find_commits). - with(project, ['123']). - and_return([commit]) + expect(subject).to receive(:find_commits) + .with(project, ['123']) + .and_return([commit]) expect(subject.referenced_by([link])).to eq([commit]) end it 'returns an empty Array when the commit could not be found' do - allow_any_instance_of(Project).to receive(:valid_repo?). - and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?) + .and_return(true) - expect(subject).to receive(:find_commits). - with(project, ['123']). - and_return([]) + expect(subject).to receive(:find_commits) + .with(project, ['123']) + .and_return([]) expect(subject.referenced_by([link])).to eq([]) end it 'skips projects without valid repositories' do - allow_any_instance_of(Project).to receive(:valid_repo?). - and_return(false) + allow_any_instance_of(Project).to receive(:valid_repo?) + .and_return(false) expect(subject.referenced_by([link])).to eq([]) end @@ -63,8 +63,8 @@ describe Banzai::ReferenceParser::CommitParser, lib: true do context 'when the link does not have a data-commit attribute' do it 'returns an empty Array' do - allow_any_instance_of(Project).to receive(:valid_repo?). - and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?) + .and_return(true) expect(subject.referenced_by([link])).to eq([]) end @@ -73,8 +73,8 @@ describe Banzai::ReferenceParser::CommitParser, lib: true do context 'when the link does not have a data-project attribute' do it 'returns an empty Array' do - allow_any_instance_of(Project).to receive(:valid_repo?). - and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?) + .and_return(true) expect(subject.referenced_by([link])).to eq([]) end diff --git a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb index 8c0f5d7df97..5dca5e784da 100644 --- a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb @@ -32,17 +32,17 @@ describe Banzai::ReferenceParser::CommitRangeParser, lib: true do it 'returns an Array of commit ranges' do range = double(:range) - expect(subject).to receive(:find_object). - with(project, '123..456'). - and_return(range) + expect(subject).to receive(:find_object) + .with(project, '123..456') + .and_return(range) expect(subject.referenced_by([link])).to eq([range]) end it 'returns an empty Array when the commit range could not be found' do - expect(subject).to receive(:find_object). - with(project, '123..456'). - and_return(nil) + expect(subject).to receive(:find_object) + .with(project, '123..456') + .and_return(nil) expect(subject.referenced_by([link])).to eq([]) end @@ -88,17 +88,17 @@ describe Banzai::ReferenceParser::CommitRangeParser, lib: true do it 'returns an Array of range objects' do range = double(:commit) - expect(subject).to receive(:find_object). - with(project, '123..456'). - and_return(range) + expect(subject).to receive(:find_object) + .with(project, '123..456') + .and_return(range) expect(subject.find_ranges(project, ['123..456'])).to eq([range]) end it 'skips ranges that could not be found' do - expect(subject).to receive(:find_object). - with(project, '123..456'). - and_return(nil) + expect(subject).to receive(:find_object) + .with(project, '123..456') + .and_return(nil) expect(subject.find_ranges(project, ['123..456'])).to eq([]) end diff --git a/spec/lib/banzai/reference_parser/issue_parser_spec.rb b/spec/lib/banzai/reference_parser/issue_parser_spec.rb index 7031c47231c..58e1a0c1bc1 100644 --- a/spec/lib/banzai/reference_parser/issue_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/issue_parser_spec.rb @@ -18,17 +18,17 @@ describe Banzai::ReferenceParser::IssueParser, lib: true do it_behaves_like "referenced feature visibility", "issues" it 'returns the nodes when the user can read the issue' do - expect(Ability).to receive(:issues_readable_by_user). - with([issue], user). - and_return([issue]) + expect(Ability).to receive(:issues_readable_by_user) + .with([issue], user) + .and_return([issue]) expect(subject.nodes_visible_to_user(user, [link])).to eq([link]) end it 'returns an empty Array when the user can not read the issue' do - expect(Ability).to receive(:issues_readable_by_user). - with([issue], user). - and_return([]) + expect(Ability).to receive(:issues_readable_by_user) + .with([issue], user) + .and_return([]) expect(subject.nodes_visible_to_user(user, [link])).to eq([]) end diff --git a/spec/lib/banzai/reference_parser/user_parser_spec.rb b/spec/lib/banzai/reference_parser/user_parser_spec.rb index 4d560667342..dfebb971f3a 100644 --- a/spec/lib/banzai/reference_parser/user_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/user_parser_spec.rb @@ -96,17 +96,17 @@ describe Banzai::ReferenceParser::UserParser, lib: true do end it 'returns the nodes if the user can read the group' do - expect(Ability).to receive(:allowed?). - with(user, :read_group, group). - and_return(true) + expect(Ability).to receive(:allowed?) + .with(user, :read_group, group) + .and_return(true) expect(subject.nodes_visible_to_user(user, [link])).to eq([link]) end it 'returns an empty Array if the user can not read the group' do - expect(Ability).to receive(:allowed?). - with(user, :read_group, group). - and_return(false) + expect(Ability).to receive(:allowed?) + .with(user, :read_group, group) + .and_return(false) expect(subject.nodes_visible_to_user(user, [link])).to eq([]) end @@ -129,9 +129,9 @@ describe Banzai::ReferenceParser::UserParser, lib: true do link['data-project'] = other_project.id.to_s - expect(Ability).to receive(:allowed?). - with(user, :read_project, other_project). - and_return(true) + expect(Ability).to receive(:allowed?) + .with(user, :read_project, other_project) + .and_return(true) expect(subject.nodes_visible_to_user(user, [link])).to eq([link]) end @@ -141,9 +141,9 @@ describe Banzai::ReferenceParser::UserParser, lib: true do link['data-project'] = other_project.id.to_s - expect(Ability).to receive(:allowed?). - with(user, :read_project, other_project). - and_return(false) + expect(Ability).to receive(:allowed?) + .with(user, :read_project, other_project) + .and_return(false) expect(subject.nodes_visible_to_user(user, [link])).to eq([]) end diff --git a/spec/lib/ci/charts_spec.rb b/spec/lib/ci/charts_spec.rb index fb6cc398307..51cbfd2a848 100644 --- a/spec/lib/ci/charts_spec.rb +++ b/spec/lib/ci/charts_spec.rb @@ -1,21 +1,21 @@ require 'spec_helper' describe Ci::Charts, lib: true do - context "build_times" do + context "pipeline_times" do let(:project) { create(:empty_project) } - let(:chart) { Ci::Charts::BuildTime.new(project) } + let(:chart) { Ci::Charts::PipelineTime.new(project) } - subject { chart.build_times } + subject { chart.pipeline_times } before do create(:ci_empty_pipeline, project: project, duration: 120) end - it 'returns build times in minutes' do + it 'returns pipeline times in minutes' do is_expected.to contain_exactly(2) end - it 'handles nil build times' do + it 'handles nil pipeline times' do create(:ci_empty_pipeline, project: project, duration: nil) is_expected.to contain_exactly(2, 0) diff --git a/spec/lib/container_registry/blob_spec.rb b/spec/lib/container_registry/blob_spec.rb index ab010c6dfeb..175fd2e7e13 100644 --- a/spec/lib/container_registry/blob_spec.rb +++ b/spec/lib/container_registry/blob_spec.rb @@ -72,8 +72,8 @@ describe ContainerRegistry::Blob do describe '#data' do context 'when locally stored' do before do - stub_request(:get, 'http://registry.gitlab/v2/group/test/image/blobs/sha256:0123456789012345'). - to_return( + stub_request(:get, 'http://registry.gitlab/v2/group/test/image/blobs/sha256:0123456789012345') + .to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: '{"key":"value"}') @@ -97,9 +97,9 @@ describe ContainerRegistry::Blob do context 'for a valid address' do before do - stub_request(:get, location). - with { |request| !request.headers.include?('Authorization') }. - to_return( + stub_request(:get, location) + .with { |request| !request.headers.include?('Authorization') } + .to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: '{"key":"value"}') diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb index ec03b533383..3df33f48adb 100644 --- a/spec/lib/container_registry/client_spec.rb +++ b/spec/lib/container_registry/client_spec.rb @@ -8,28 +8,28 @@ describe ContainerRegistry::Client do describe '#blob' do it 'GET /v2/:name/blobs/:digest' do - stub_request(:get, "http://container-registry/v2/group/test/blobs/sha256:0123456789012345"). - with(headers: { + stub_request(:get, "http://container-registry/v2/group/test/blobs/sha256:0123456789012345") + .with(headers: { 'Accept' => 'application/octet-stream', 'Authorization' => "bearer #{token}" - }). - to_return(status: 200, body: "Blob") + }) + .to_return(status: 200, body: "Blob") expect(client.blob('group/test', 'sha256:0123456789012345')).to eq('Blob') end it 'follows 307 redirect for GET /v2/:name/blobs/:digest' do - stub_request(:get, "http://container-registry/v2/group/test/blobs/sha256:0123456789012345"). - with(headers: { + stub_request(:get, "http://container-registry/v2/group/test/blobs/sha256:0123456789012345") + .with(headers: { 'Accept' => 'application/octet-stream', 'Authorization' => "bearer #{token}" - }). - to_return(status: 307, body: "", headers: { Location: 'http://redirected' }) + }) + .to_return(status: 307, body: "", headers: { Location: 'http://redirected' }) # We should probably use hash_excluding here, but that requires an update to WebMock: # https://github.com/bblimke/webmock/blob/master/lib/webmock/matchers/hash_excluding_matcher.rb - stub_request(:get, "http://redirected/"). - with { |request| !request.headers.include?('Authorization') }. - to_return(status: 200, body: "Successfully redirected") + stub_request(:get, "http://redirected/") + .with { |request| !request.headers.include?('Authorization') } + .to_return(status: 200, body: "Successfully redirected") response = client.blob('group/test', 'sha256:0123456789012345') diff --git a/spec/lib/container_registry/tag_spec.rb b/spec/lib/container_registry/tag_spec.rb index f8fffbdca41..cb4ae3be525 100644 --- a/spec/lib/container_registry/tag_spec.rb +++ b/spec/lib/container_registry/tag_spec.rb @@ -60,9 +60,9 @@ describe ContainerRegistry::Tag do context 'manifest processing' do context 'schema v1' do before do - stub_request(:get, 'http://registry.gitlab/v2/group/test/manifests/tag'). - with(headers: headers). - to_return( + stub_request(:get, 'http://registry.gitlab/v2/group/test/manifests/tag') + .with(headers: headers) + .to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest_1.json'), headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v1+prettyjws' }) @@ -97,9 +97,9 @@ describe ContainerRegistry::Tag do context 'schema v2' do before do - stub_request(:get, 'http://registry.gitlab/v2/group/test/manifests/tag'). - with(headers: headers). - to_return( + stub_request(:get, 'http://registry.gitlab/v2/group/test/manifests/tag') + .with(headers: headers) + .to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest.json'), headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v2+json' }) @@ -134,9 +134,9 @@ describe ContainerRegistry::Tag do context 'when locally stored' do before do - stub_request(:get, 'http://registry.gitlab/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac'). - with(headers: { 'Accept' => 'application/octet-stream' }). - to_return( + stub_request(:get, 'http://registry.gitlab/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac') + .with(headers: { 'Accept' => 'application/octet-stream' }) + .to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json')) end @@ -146,14 +146,14 @@ describe ContainerRegistry::Tag do context 'when externally stored' do before do - stub_request(:get, 'http://registry.gitlab/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac'). - with(headers: { 'Accept' => 'application/octet-stream' }). - to_return( + stub_request(:get, 'http://registry.gitlab/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac') + .with(headers: { 'Accept' => 'application/octet-stream' }) + .to_return( status: 307, headers: { 'Location' => 'http://external.com/blob/file' }) - stub_request(:get, 'http://external.com/blob/file'). - to_return( + stub_request(:get, 'http://external.com/blob/file') + .to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json')) end diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index 2b26a318583..f2132d485ab 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -14,8 +14,8 @@ describe ExtractsPath, lib: true do repo = double(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0', 'release/app', 'release/app/v1.0.0']) allow(project).to receive(:repository).and_return(repo) - allow(project).to receive(:path_with_namespace). - and_return('gitlab/gitlab-ci') + allow(project).to receive(:path_with_namespace) + .and_return('gitlab/gitlab-ci') allow(request).to receive(:format=) end diff --git a/spec/lib/feature_spec.rb b/spec/lib/feature_spec.rb index 1d92a5cb33f..5cc3a3745e4 100644 --- a/spec/lib/feature_spec.rb +++ b/spec/lib/feature_spec.rb @@ -6,8 +6,8 @@ describe Feature, lib: true do let(:key) { 'my_feature' } it 'returns the Flipper feature' do - expect_any_instance_of(Flipper::DSL).to receive(:feature).with(key). - and_return(feature) + expect_any_instance_of(Flipper::DSL).to receive(:feature).with(key) + .and_return(feature) expect(described_class.get(key)).to be(feature) end @@ -17,8 +17,8 @@ describe Feature, lib: true do let(:features) { Set.new } it 'returns the Flipper features as an array' do - expect_any_instance_of(Flipper::DSL).to receive(:features). - and_return(features) + expect_any_instance_of(Flipper::DSL).to receive(:features) + .and_return(features) expect(described_class.all).to eq(features.to_a) end diff --git a/spec/lib/gitlab/background_migration_spec.rb b/spec/lib/gitlab/background_migration_spec.rb index f2073b9bcb3..64f82fe27b2 100644 --- a/spec/lib/gitlab/background_migration_spec.rb +++ b/spec/lib/gitlab/background_migration_spec.rb @@ -5,9 +5,9 @@ describe Gitlab::BackgroundMigration do it 'steals jobs from a queue' do queue = [double(:job, args: ['Foo', [10, 20]])] - allow(Sidekiq::Queue).to receive(:new). - with(BackgroundMigrationWorker.sidekiq_options['queue']). - and_return(queue) + allow(Sidekiq::Queue).to receive(:new) + .with(BackgroundMigrationWorker.sidekiq_options['queue']) + .and_return(queue) expect(queue[0]).to receive(:delete) @@ -19,9 +19,9 @@ describe Gitlab::BackgroundMigration do it 'does not steal jobs for a different migration' do queue = [double(:job, args: ['Foo', [10, 20]])] - allow(Sidekiq::Queue).to receive(:new). - with(BackgroundMigrationWorker.sidekiq_options['queue']). - and_return(queue) + allow(Sidekiq::Queue).to receive(:new) + .with(BackgroundMigrationWorker.sidekiq_options['queue']) + .and_return(queue) expect(described_class).not_to receive(:perform) @@ -36,9 +36,9 @@ describe Gitlab::BackgroundMigration do instance = double(:instance) klass = double(:klass, new: instance) - expect(described_class).to receive(:const_get). - with('Foo'). - and_return(klass) + expect(described_class).to receive(:const_get) + .with('Foo') + .and_return(klass) expect(instance).to receive(:perform).with(10, 20) diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb index a7ee7f53a6b..d8beb05601c 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -86,11 +86,9 @@ describe Gitlab::BitbucketImport::Importer, lib: true do headers: { "Content-Type" => "application/json" }, body: issues_statuses_sample_data.to_json) - stub_request(:get, "https://api.bitbucket.org/2.0/repositories/namespace/repo?pagelen=50&sort=created_on"). - with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer', 'User-Agent' => 'Faraday v0.9.2' }). - to_return(status: 200, - body: "", - headers: {}) + stub_request(:get, "https://api.bitbucket.org/2.0/repositories/namespace/repo?pagelen=50&sort=created_on") + .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer', 'User-Agent' => 'Faraday v0.9.2' }) + .to_return(status: 200, body: "", headers: {}) sample_issues_statuses.each_with_index do |issue, index| stub_request( diff --git a/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb b/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb index cfb5cba054e..07db6c3a640 100644 --- a/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb +++ b/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb @@ -37,11 +37,11 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :redis do loaded_from_cache: false ) - expect(described_class).to receive(:new). - with(project_without_status, + expect(described_class).to receive(:new) + .with(project_without_status, pipeline_info: empty_status, - loaded_from_cache: false). - and_return(fake_pipeline) + loaded_from_cache: false) + .and_return(fake_pipeline) expect(fake_pipeline).to receive(:load_from_project) expect(fake_pipeline).to receive(:store_in_cache) @@ -112,12 +112,12 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :redis do pipeline = build_stubbed(:ci_pipeline, sha: '123456', status: 'success', ref: 'master') fake_status = double - expect(described_class).to receive(:new). - with(pipeline.project, + expect(described_class).to receive(:new) + .with(pipeline.project, pipeline_info: { sha: '123456', status: 'success', ref: 'master' - }). - and_return(fake_status) + }) + .and_return(fake_status) expect(fake_status).to receive(:store_in_cache_if_needed) diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb index eea01f91879..6a52ae01b2f 100644 --- a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb @@ -33,8 +33,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/').find_entries! } it 'matches correct paths' do - expect(subject.keys). - to contain_exactly 'other_artifacts_0.1.2/', + expect(subject.keys) + .to contain_exactly 'other_artifacts_0.1.2/', 'other_artifacts_0.1.2/doc_sample.txt', 'other_artifacts_0.1.2/another-subdirectory/' end @@ -44,8 +44,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/another-subdirectory/').find_entries! } it 'matches correct paths' do - expect(subject.keys). - to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/', + expect(subject.keys) + .to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/', 'other_artifacts_0.1.2/another-subdirectory/empty_directory/', 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' end @@ -55,8 +55,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/', recursive: true).find_entries! } it 'matches correct paths' do - expect(subject.keys). - to contain_exactly 'other_artifacts_0.1.2/', + expect(subject.keys) + .to contain_exactly 'other_artifacts_0.1.2/', 'other_artifacts_0.1.2/doc_sample.txt', 'other_artifacts_0.1.2/another-subdirectory/', 'other_artifacts_0.1.2/another-subdirectory/empty_directory/', diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb index 97af1c2523d..ca68010cb89 100644 --- a/spec/lib/gitlab/closing_issue_extractor_spec.rb +++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb @@ -306,58 +306,58 @@ describe Gitlab::ClosingIssueExtractor, lib: true do it 'fetches issues in single line message' do message = "Closes #{reference} and fix #{reference2}" - expect(subject.closed_by_message(message)). - to match_array([issue, other_issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue, other_issue]) end it 'fetches comma-separated issues references in single line message' do message = "Closes #{reference}, closes #{reference2}" - expect(subject.closed_by_message(message)). - to match_array([issue, other_issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue, other_issue]) end it 'fetches comma-separated issues numbers in single line message' do message = "Closes #{reference}, #{reference2} and #{reference3}" - expect(subject.closed_by_message(message)). - to match_array([issue, other_issue, third_issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue, other_issue, third_issue]) end it 'fetches issues in multi-line message' do message = "Awesome commit (closes #{reference})\nAlso fixes #{reference2}" - expect(subject.closed_by_message(message)). - to match_array([issue, other_issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue, other_issue]) end it 'fetches issues in hybrid message' do message = "Awesome commit (closes #{reference})\n"\ "Also fixing issues #{reference2}, #{reference3} and #4" - expect(subject.closed_by_message(message)). - to match_array([issue, other_issue, third_issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue, other_issue, third_issue]) end it "fetches cross-project references" do message = "Closes #{reference} and #{cross_reference}" - expect(subject.closed_by_message(message)). - to match_array([issue, issue2]) + expect(subject.closed_by_message(message)) + .to match_array([issue, issue2]) end it "fetches cross-project URL references" do message = "Closes #{urls.namespace_project_issue_url(issue2.project.namespace, issue2.project, issue2)} and #{reference}" - expect(subject.closed_by_message(message)). - to match_array([issue, issue2]) + expect(subject.closed_by_message(message)) + .to match_array([issue, issue2]) end it "ignores invalid cross-project URL references" do message = "Closes https://google.com#{urls.namespace_project_issue_path(issue2.project.namespace, issue2.project, issue2)} and #{reference}" - expect(subject.closed_by_message(message)). - to match_array([issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue]) end end end diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index 780ac0ad97e..585eeb77bd5 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -43,8 +43,8 @@ describe Gitlab::Conflict::File, lib: true do end it 'returns a file containing only the chosen parts of the resolved sections' do - expect(resolved_lines.chunk { |line| line.type || 'both' }.map(&:first)). - to eq(%w(both new both old both new both)) + expect(resolved_lines.chunk { |line| line.type || 'both' }.map(&:first)) + .to eq(%w(both new both old both new both)) end end @@ -52,14 +52,14 @@ describe Gitlab::Conflict::File, lib: true do empty_hash = section_keys.map { |key| [key, nil] }.to_h invalid_hash = section_keys.map { |key| [key, 'invalid'] }.to_h - expect { conflict_file.resolve_lines({}) }. - to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { conflict_file.resolve_lines({}) } + .to raise_error(Gitlab::Conflict::File::MissingResolution) - expect { conflict_file.resolve_lines(empty_hash) }. - to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { conflict_file.resolve_lines(empty_hash) } + .to raise_error(Gitlab::Conflict::File::MissingResolution) - expect { conflict_file.resolve_lines(invalid_hash) }. - to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { conflict_file.resolve_lines(invalid_hash) } + .to raise_error(Gitlab::Conflict::File::MissingResolution) end end @@ -250,8 +250,8 @@ FILE describe '#as_json' do it 'includes the blob path for the file' do - expect(conflict_file.as_json[:blob_path]). - to eq("/#{project.full_path}/blob/#{our_commit.oid}/files/ruby/regex.rb") + expect(conflict_file.as_json[:blob_path]) + .to eq("/#{project.full_path}/blob/#{our_commit.oid}/files/ruby/regex.rb") end it 'includes the blob icon for the file' do @@ -264,8 +264,8 @@ FILE end it 'includes the detected language of the conflict file' do - expect(conflict_file.as_json(full_content: true)[:blob_ace_mode]). - to eq('ruby') + expect(conflict_file.as_json(full_content: true)[:blob_ace_mode]) + .to eq('ruby') end end end diff --git a/spec/lib/gitlab/conflict/parser_spec.rb b/spec/lib/gitlab/conflict/parser_spec.rb index 2570f95dd21..aed57b75789 100644 --- a/spec/lib/gitlab/conflict/parser_spec.rb +++ b/spec/lib/gitlab/conflict/parser_spec.rb @@ -122,18 +122,18 @@ CONFLICT context 'when the file contents include conflict delimiters' do context 'when there is a non-start delimiter first' do it 'raises UnexpectedDelimiter when there is a middle delimiter first' do - expect { parse_text('=======') }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text('=======') } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) end it 'raises UnexpectedDelimiter when there is an end delimiter first' do - expect { parse_text('>>>>>>> README.md') }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text('>>>>>>> README.md') } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) end it 'does not raise when there is an end delimiter for a different path first' do - expect { parse_text('>>>>>>> some-other-path.md') }. - not_to raise_error + expect { parse_text('>>>>>>> some-other-path.md') } + .not_to raise_error end end @@ -142,18 +142,18 @@ CONFLICT let(:end_text) { "\n=======\n>>>>>>> README.md" } it 'raises UnexpectedDelimiter when it is followed by an end delimiter' do - expect { parse_text(start_text + '>>>>>>> README.md' + end_text) }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + '>>>>>>> README.md' + end_text) } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) end it 'raises UnexpectedDelimiter when it is followed by another start delimiter' do - expect { parse_text(start_text + start_text + end_text) }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + start_text + end_text) } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) end it 'does not raise when it is followed by a start delimiter for a different path' do - expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) }. - not_to raise_error + expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) } + .not_to raise_error end end @@ -162,59 +162,59 @@ CONFLICT let(:end_text) { "\n>>>>>>> README.md" } it 'raises UnexpectedDelimiter when it is followed by another middle delimiter' do - expect { parse_text(start_text + '=======' + end_text) }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + '=======' + end_text) } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) end it 'raises UnexpectedDelimiter when it is followed by a start delimiter' do - expect { parse_text(start_text + start_text + end_text) }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + start_text + end_text) } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) end it 'does not raise when it is followed by a start delimiter for another path' do - expect { parse_text(start_text + '<<<<<<< some-other-path.md' + end_text) }. - not_to raise_error + expect { parse_text(start_text + '<<<<<<< some-other-path.md' + end_text) } + .not_to raise_error end end it 'raises MissingEndDelimiter when there is no end delimiter at the end' do start_text = "<<<<<<< README.md\n=======\n" - expect { parse_text(start_text) }. - to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) + expect { parse_text(start_text) } + .to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) - expect { parse_text(start_text + '>>>>>>> some-other-path.md') }. - to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) + expect { parse_text(start_text + '>>>>>>> some-other-path.md') } + .to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) end end context 'other file types' do it 'raises UnmergeableFile when lines is blank, indicating a binary file' do - expect { parse_text('') }. - to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) + expect { parse_text('') } + .to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) - expect { parse_text(nil) }. - to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) + expect { parse_text(nil) } + .to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) end it 'raises UnmergeableFile when the file is over 200 KB' do - expect { parse_text('a' * 204801) }. - to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) + expect { parse_text('a' * 204801) } + .to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) end # All text from Rugged has an encoding of ASCII_8BIT, so force that in # these strings. context 'when the file contains UTF-8 characters' do it 'does not raise' do - expect { parse_text("Espa\xC3\xB1a".force_encoding(Encoding::ASCII_8BIT)) }. - not_to raise_error + expect { parse_text("Espa\xC3\xB1a".force_encoding(Encoding::ASCII_8BIT)) } + .not_to raise_error end end context 'when the file contains non-UTF-8 characters' do it 'raises UnsupportedEncoding' do - expect { parse_text("a\xC4\xFC".force_encoding(Encoding::ASCII_8BIT)) }. - to raise_error(Gitlab::Conflict::Parser::UnsupportedEncoding) + expect { parse_text("a\xC4\xFC".force_encoding(Encoding::ASCII_8BIT)) } + .to raise_error(Gitlab::Conflict::Parser::UnsupportedEncoding) end end end diff --git a/spec/lib/gitlab/data_builder/push_spec.rb b/spec/lib/gitlab/data_builder/push_spec.rb index e59cba35b2f..73936969832 100644 --- a/spec/lib/gitlab/data_builder/push_spec.rb +++ b/spec/lib/gitlab/data_builder/push_spec.rb @@ -47,8 +47,8 @@ describe Gitlab::DataBuilder::Push, lib: true do include_examples 'deprecated repository hook data' it 'does not raise an error when given nil commits' do - expect { described_class.build(spy, spy, spy, spy, spy, nil) }. - not_to raise_error + expect { described_class.build(spy, spy, spy, spy, spy, nil) } + .not_to raise_error end end end diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index 30aa463faf8..4259be3f522 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -57,15 +57,15 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'creates the index concurrently' do - expect(model).to receive(:add_index). - with(:users, :foo, algorithm: :concurrently) + expect(model).to receive(:add_index) + .with(:users, :foo, algorithm: :concurrently) model.add_concurrent_index(:users, :foo) end it 'creates unique index concurrently' do - expect(model).to receive(:add_index). - with(:users, :foo, { algorithm: :concurrently, unique: true }) + expect(model).to receive(:add_index) + .with(:users, :foo, { algorithm: :concurrently, unique: true }) model.add_concurrent_index(:users, :foo, unique: true) end @@ -75,8 +75,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'creates a regular index' do expect(Gitlab::Database).to receive(:postgresql?).and_return(false) - expect(model).to receive(:add_index). - with(:users, :foo, {}) + expect(model).to receive(:add_index) + .with(:users, :foo, {}) model.add_concurrent_index(:users, :foo) end @@ -87,8 +87,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'raises RuntimeError' do expect(model).to receive(:transaction_open?).and_return(true) - expect { model.add_concurrent_index(:users, :foo) }. - to raise_error(RuntimeError) + expect { model.add_concurrent_index(:users, :foo) } + .to raise_error(RuntimeError) end end end @@ -106,15 +106,15 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'removes the index concurrently by column name' do - expect(model).to receive(:remove_index). - with(:users, { algorithm: :concurrently, column: :foo }) + expect(model).to receive(:remove_index) + .with(:users, { algorithm: :concurrently, column: :foo }) model.remove_concurrent_index(:users, :foo) end it 'removes the index concurrently by index name' do - expect(model).to receive(:remove_index). - with(:users, { algorithm: :concurrently, name: "index_x_by_y" }) + expect(model).to receive(:remove_index) + .with(:users, { algorithm: :concurrently, name: "index_x_by_y" }) model.remove_concurrent_index_by_name(:users, "index_x_by_y") end @@ -124,8 +124,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'removes an index' do expect(Gitlab::Database).to receive(:postgresql?).and_return(false) - expect(model).to receive(:remove_index). - with(:users, { column: :foo }) + expect(model).to receive(:remove_index) + .with(:users, { column: :foo }) model.remove_concurrent_index(:users, :foo) end @@ -136,8 +136,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'raises RuntimeError' do expect(model).to receive(:transaction_open?).and_return(true) - expect { model.remove_concurrent_index(:users, :foo) }. - to raise_error(RuntimeError) + expect { model.remove_concurrent_index(:users, :foo) } + .to raise_error(RuntimeError) end end end @@ -162,8 +162,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'creates a regular foreign key' do allow(Gitlab::Database).to receive(:mysql?).and_return(true) - expect(model).to receive(:add_foreign_key). - with(:projects, :users, column: :user_id, on_delete: :cascade) + expect(model).to receive(:add_foreign_key) + .with(:projects, :users, column: :user_id, on_delete: :cascade) model.add_concurrent_foreign_key(:projects, :users, column: :user_id) end @@ -262,39 +262,53 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end describe '#update_column_in_batches' do - before do - create_list(:empty_project, 5) - end + context 'when running outside of a transaction' do + before do + expect(model).to receive(:transaction_open?).and_return(false) - it 'updates all the rows in a table' do - model.update_column_in_batches(:projects, :import_error, 'foo') + create_list(:empty_project, 5) + end - expect(Project.where(import_error: 'foo').count).to eq(5) - end + it 'updates all the rows in a table' do + model.update_column_in_batches(:projects, :import_error, 'foo') + + expect(Project.where(import_error: 'foo').count).to eq(5) + end - it 'updates boolean values correctly' do - model.update_column_in_batches(:projects, :archived, true) + it 'updates boolean values correctly' do + model.update_column_in_batches(:projects, :archived, true) - expect(Project.where(archived: true).count).to eq(5) - end + expect(Project.where(archived: true).count).to eq(5) + end - context 'when a block is supplied' do - it 'yields an Arel table and query object to the supplied block' do - first_id = Project.first.id + context 'when a block is supplied' do + it 'yields an Arel table and query object to the supplied block' do + first_id = Project.first.id - model.update_column_in_batches(:projects, :archived, true) do |t, query| - query.where(t[:id].eq(first_id)) + model.update_column_in_batches(:projects, :archived, true) do |t, query| + query.where(t[:id].eq(first_id)) + end + + expect(Project.where(archived: true).count).to eq(1) end + end + + context 'when the value is Arel.sql (Arel::Nodes::SqlLiteral)' do + it 'updates the value as a SQL expression' do + model.update_column_in_batches(:projects, :star_count, Arel.sql('1+1')) - expect(Project.where(archived: true).count).to eq(1) + expect(Project.sum(:star_count)).to eq(2 * Project.count) + end end end - context 'when the value is Arel.sql (Arel::Nodes::SqlLiteral)' do - it 'updates the value as a SQL expression' do - model.update_column_in_batches(:projects, :star_count, Arel.sql('1+1')) + context 'when running inside the transaction' do + it 'raises RuntimeError' do + expect(model).to receive(:transaction_open?).and_return(true) - expect(Project.sum(:star_count)).to eq(2 * Project.count) + expect do + model.update_column_in_batches(:projects, :star_count, Arel.sql('1+1')) + end.to raise_error(RuntimeError) end end end @@ -303,20 +317,22 @@ describe Gitlab::Database::MigrationHelpers, lib: true do context 'outside of a transaction' do context 'when a column limit is not set' do before do - expect(model).to receive(:transaction_open?).and_return(false) + expect(model).to receive(:transaction_open?) + .and_return(false) + .at_least(:once) expect(model).to receive(:transaction).and_yield - expect(model).to receive(:add_column). - with(:projects, :foo, :integer, default: nil) + expect(model).to receive(:add_column) + .with(:projects, :foo, :integer, default: nil) - expect(model).to receive(:change_column_default). - with(:projects, :foo, 10) + expect(model).to receive(:change_column_default) + .with(:projects, :foo, 10) end it 'adds the column while allowing NULL values' do - expect(model).to receive(:update_column_in_batches). - with(:projects, :foo, 10) + expect(model).to receive(:update_column_in_batches) + .with(:projects, :foo, 10) expect(model).not_to receive(:change_column_null) @@ -326,22 +342,22 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'adds the column while not allowing NULL values' do - expect(model).to receive(:update_column_in_batches). - with(:projects, :foo, 10) + expect(model).to receive(:update_column_in_batches) + .with(:projects, :foo, 10) - expect(model).to receive(:change_column_null). - with(:projects, :foo, false) + expect(model).to receive(:change_column_null) + .with(:projects, :foo, false) model.add_column_with_default(:projects, :foo, :integer, default: 10) end it 'removes the added column whenever updating the rows fails' do - expect(model).to receive(:update_column_in_batches). - with(:projects, :foo, 10). - and_raise(RuntimeError) + expect(model).to receive(:update_column_in_batches) + .with(:projects, :foo, 10) + .and_raise(RuntimeError) - expect(model).to receive(:remove_column). - with(:projects, :foo) + expect(model).to receive(:remove_column) + .with(:projects, :foo) expect do model.add_column_with_default(:projects, :foo, :integer, default: 10) @@ -349,12 +365,12 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'removes the added column whenever changing a column NULL constraint fails' do - expect(model).to receive(:change_column_null). - with(:projects, :foo, false). - and_raise(RuntimeError) + expect(model).to receive(:change_column_null) + .with(:projects, :foo, false) + .and_raise(RuntimeError) - expect(model).to receive(:remove_column). - with(:projects, :foo) + expect(model).to receive(:remove_column) + .with(:projects, :foo) expect do model.add_column_with_default(:projects, :foo, :integer, default: 10) @@ -370,8 +386,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do allow(model).to receive(:change_column_null).with(:projects, :foo, false) allow(model).to receive(:change_column_default).with(:projects, :foo, 10) - expect(model).to receive(:add_column). - with(:projects, :foo, :integer, default: nil, limit: 8) + expect(model).to receive(:add_column) + .with(:projects, :foo, :integer, default: nil, limit: 8) model.add_column_with_default(:projects, :foo, :integer, default: 10, limit: 8) end @@ -394,8 +410,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'raises RuntimeError' do allow(model).to receive(:transaction_open?).and_return(true) - expect { model.rename_column_concurrently(:users, :old, :new) }. - to raise_error(RuntimeError) + expect { model.rename_column_concurrently(:users, :old, :new) } + .to raise_error(RuntimeError) end end @@ -426,17 +442,17 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'renames a column concurrently' do allow(Gitlab::Database).to receive(:postgresql?).and_return(false) - expect(model).to receive(:install_rename_triggers_for_mysql). - with(trigger_name, 'users', 'old', 'new') + expect(model).to receive(:install_rename_triggers_for_mysql) + .with(trigger_name, 'users', 'old', 'new') - expect(model).to receive(:add_column). - with(:users, :new, :integer, + expect(model).to receive(:add_column) + .with(:users, :new, :integer, limit: old_column.limit, precision: old_column.precision, scale: old_column.scale) - expect(model).to receive(:change_column_default). - with(:users, :new, old_column.default) + expect(model).to receive(:change_column_default) + .with(:users, :new, old_column.default) expect(model).to receive(:update_column_in_batches) @@ -453,17 +469,17 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'renames a column concurrently' do allow(Gitlab::Database).to receive(:postgresql?).and_return(true) - expect(model).to receive(:install_rename_triggers_for_postgresql). - with(trigger_name, 'users', 'old', 'new') + expect(model).to receive(:install_rename_triggers_for_postgresql) + .with(trigger_name, 'users', 'old', 'new') - expect(model).to receive(:add_column). - with(:users, :new, :integer, + expect(model).to receive(:add_column) + .with(:users, :new, :integer, limit: old_column.limit, precision: old_column.precision, scale: old_column.scale) - expect(model).to receive(:change_column_default). - with(:users, :new, old_column.default) + expect(model).to receive(:change_column_default) + .with(:users, :new, old_column.default) expect(model).to receive(:update_column_in_batches) @@ -482,8 +498,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'cleans up the renaming procedure for PostgreSQL' do allow(Gitlab::Database).to receive(:postgresql?).and_return(true) - expect(model).to receive(:remove_rename_triggers_for_postgresql). - with(:users, /trigger_.{12}/) + expect(model).to receive(:remove_rename_triggers_for_postgresql) + .with(:users, /trigger_.{12}/) expect(model).to receive(:remove_column).with(:users, :old) @@ -493,8 +509,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'cleans up the renaming procedure for MySQL' do allow(Gitlab::Database).to receive(:postgresql?).and_return(false) - expect(model).to receive(:remove_rename_triggers_for_mysql). - with(/trigger_.{12}/) + expect(model).to receive(:remove_rename_triggers_for_mysql) + .with(/trigger_.{12}/) expect(model).to receive(:remove_column).with(:users, :old) @@ -504,8 +520,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do describe '#change_column_type_concurrently' do it 'changes the column type' do - expect(model).to receive(:rename_column_concurrently). - with('users', 'username', 'username_for_type_change', type: :text) + expect(model).to receive(:rename_column_concurrently) + .with('users', 'username', 'username_for_type_change', type: :text) model.change_column_type_concurrently('users', 'username', :text) end @@ -513,11 +529,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do describe '#cleanup_concurrent_column_type_change' do it 'cleans up the type changing procedure' do - expect(model).to receive(:cleanup_concurrent_column_rename). - with('users', 'username', 'username_for_type_change') + expect(model).to receive(:cleanup_concurrent_column_rename) + .with('users', 'username', 'username_for_type_change') - expect(model).to receive(:rename_column). - with('users', 'username_for_type_change', 'username') + expect(model).to receive(:rename_column) + .with('users', 'username_for_type_change', 'username') model.cleanup_concurrent_column_type_change('users', 'username') end @@ -525,11 +541,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do describe '#install_rename_triggers_for_postgresql' do it 'installs the triggers for PostgreSQL' do - expect(model).to receive(:execute). - with(/CREATE OR REPLACE FUNCTION foo()/m) + expect(model).to receive(:execute) + .with(/CREATE OR REPLACE FUNCTION foo()/m) - expect(model).to receive(:execute). - with(/CREATE TRIGGER foo/m) + expect(model).to receive(:execute) + .with(/CREATE TRIGGER foo/m) model.install_rename_triggers_for_postgresql('foo', :users, :old, :new) end @@ -537,11 +553,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do describe '#install_rename_triggers_for_mysql' do it 'installs the triggers for MySQL' do - expect(model).to receive(:execute). - with(/CREATE TRIGGER foo_insert.+ON users/m) + expect(model).to receive(:execute) + .with(/CREATE TRIGGER foo_insert.+ON users/m) - expect(model).to receive(:execute). - with(/CREATE TRIGGER foo_update.+ON users/m) + expect(model).to receive(:execute) + .with(/CREATE TRIGGER foo_update.+ON users/m) model.install_rename_triggers_for_mysql('foo', :users, :old, :new) end @@ -567,8 +583,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do describe '#rename_trigger_name' do it 'returns a String' do - expect(model.rename_trigger_name(:users, :foo, :bar)). - to match(/trigger_.{12}/) + expect(model.rename_trigger_name(:users, :foo, :bar)) + .to match(/trigger_.{12}/) end end @@ -607,11 +623,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do lengths: [], orders: []) - allow(model).to receive(:indexes_for).with(:issues, 'project_id'). - and_return([index]) + allow(model).to receive(:indexes_for).with(:issues, 'project_id') + .and_return([index]) - expect(model).to receive(:add_concurrent_index). - with(:issues, + expect(model).to receive(:add_concurrent_index) + .with(:issues, %w(gl_project_id), unique: false, name: 'index_on_issues_gl_project_id', @@ -634,11 +650,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do lengths: [], orders: []) - allow(model).to receive(:indexes_for).with(:issues, 'project_id'). - and_return([index]) + allow(model).to receive(:indexes_for).with(:issues, 'project_id') + .and_return([index]) - expect(model).to receive(:add_concurrent_index). - with(:issues, + expect(model).to receive(:add_concurrent_index) + .with(:issues, %w(gl_project_id foobar), unique: false, name: 'index_on_issues_gl_project_id_foobar', @@ -661,11 +677,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do lengths: [], orders: []) - allow(model).to receive(:indexes_for).with(:issues, 'project_id'). - and_return([index]) + allow(model).to receive(:indexes_for).with(:issues, 'project_id') + .and_return([index]) - expect(model).to receive(:add_concurrent_index). - with(:issues, + expect(model).to receive(:add_concurrent_index) + .with(:issues, %w(gl_project_id), unique: false, name: 'index_on_issues_gl_project_id', @@ -689,11 +705,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do lengths: [], orders: []) - allow(model).to receive(:indexes_for).with(:issues, 'project_id'). - and_return([index]) + allow(model).to receive(:indexes_for).with(:issues, 'project_id') + .and_return([index]) - expect(model).to receive(:add_concurrent_index). - with(:issues, + expect(model).to receive(:add_concurrent_index) + .with(:issues, %w(gl_project_id), unique: false, name: 'index_on_issues_gl_project_id', @@ -717,11 +733,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do lengths: [], orders: []) - allow(model).to receive(:indexes_for).with(:issues, 'project_id'). - and_return([index]) + allow(model).to receive(:indexes_for).with(:issues, 'project_id') + .and_return([index]) - expect(model).to receive(:add_concurrent_index). - with(:issues, + expect(model).to receive(:add_concurrent_index) + .with(:issues, %w(gl_project_id), unique: false, name: 'index_on_issues_gl_project_id', @@ -745,11 +761,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do lengths: [], orders: []) - allow(model).to receive(:indexes_for).with(:issues, 'project_id'). - and_return([index]) + allow(model).to receive(:indexes_for).with(:issues, 'project_id') + .and_return([index]) - expect { model.copy_indexes(:issues, :project_id, :gl_project_id) }. - to raise_error(RuntimeError) + expect { model.copy_indexes(:issues, :project_id, :gl_project_id) } + .to raise_error(RuntimeError) end end end @@ -761,11 +777,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do to_table: 'projects', on_delete: :cascade) - allow(model).to receive(:foreign_keys_for).with(:issues, :project_id). - and_return([fk]) + allow(model).to receive(:foreign_keys_for).with(:issues, :project_id) + .and_return([fk]) - expect(model).to receive(:add_concurrent_foreign_key). - with('issues', 'projects', column: :gl_project_id, on_delete: :cascade) + expect(model).to receive(:add_concurrent_foreign_key) + .with('issues', 'projects', column: :gl_project_id, on_delete: :cascade) model.copy_foreign_keys(:issues, :project_id, :gl_project_id) end @@ -790,8 +806,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'builds the sql with correct functions' do - expect(model.replace_sql(Arel::Table.new(:users)[:first_name], "Alice", "Eve").to_s). - to include('regexp_replace') + expect(model.replace_sql(Arel::Table.new(:users)[:first_name], "Alice", "Eve").to_s) + .to include('regexp_replace') end end @@ -801,8 +817,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'builds the sql with the correct functions' do - expect(model.replace_sql(Arel::Table.new(:users)[:first_name], "Alice", "Eve").to_s). - to include('locate', 'insert') + expect(model.replace_sql(Arel::Table.new(:users)[:first_name], "Alice", "Eve").to_s) + .to include('locate', 'insert') end end @@ -810,7 +826,11 @@ describe Gitlab::Database::MigrationHelpers, lib: true do let!(:user) { create(:user, name: 'Kathy Alice Aliceson') } it 'replaces the correct part of the string' do - model.update_column_in_batches(:users, :name, model.replace_sql(Arel::Table.new(:users)[:name], 'Alice', 'Eve')) + allow(model).to receive(:transaction_open?).and_return(false) + query = model.replace_sql(Arel::Table.new(:users)[:name], 'Alice', 'Eve') + + model.update_column_in_batches(:users, :name, query) + expect(user.reload.name).to eq('Kathy Eve Aliceson') end end diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb index a3ab4e3dd9e..5653cfee686 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase do +describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :truncate do let(:migration) { FakeRenameReservedPathMigrationV1.new } let(:subject) { described_class.new(['the-path'], migration) } diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb index ce2b5d620fd..8125dedd3fc 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do +describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :truncate do let(:migration) { FakeRenameReservedPathMigrationV1.new } let(:subject) { described_class.new(['the-path'], migration) } @@ -21,8 +21,8 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do parent = create(:group, path: 'parent') child = create(:group, path: 'the-path', parent: parent) - found_ids = subject.namespaces_for_paths(type: :child). - map(&:id) + found_ids = subject.namespaces_for_paths(type: :child) + .map(&:id) expect(found_ids).to contain_exactly(child.id) end @@ -38,8 +38,8 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do path: 'the-path', parent: create(:group)) - found_ids = subject.namespaces_for_paths(type: :child). - map(&:id) + found_ids = subject.namespaces_for_paths(type: :child) + .map(&:id) expect(found_ids).to contain_exactly(namespace.id) end @@ -53,8 +53,8 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do path: 'the-path', parent: create(:group)) - found_ids = subject.namespaces_for_paths(type: :child). - map(&:id) + found_ids = subject.namespaces_for_paths(type: :child) + .map(&:id) expect(found_ids).to contain_exactly(namespace.id) end @@ -68,8 +68,8 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do path: 'the-path', parent: create(:group)) - found_ids = subject.namespaces_for_paths(type: :top_level). - map(&:id) + found_ids = subject.namespaces_for_paths(type: :top_level) + .map(&:id) expect(found_ids).to contain_exactly(root_namespace.id) end @@ -81,8 +81,8 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do path: 'the-path', parent: create(:group)) - found_ids = subject.namespaces_for_paths(type: :top_level). - map(&:id) + found_ids = subject.namespaces_for_paths(type: :top_level) + .map(&:id) expect(found_ids).to contain_exactly(root_namespace.id) end @@ -140,9 +140,9 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do let(:namespace) { create(:group, name: 'the-path') } it 'renames paths & routes for the namespace' do - expect(subject).to receive(:rename_path_for_routable). - with(namespace). - and_call_original + expect(subject).to receive(:rename_path_for_routable) + .with(namespace) + .and_call_original subject.rename_namespace(namespace) @@ -211,15 +211,15 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do end it 'renames top level namespaces the namespace' do - expect(subject).to receive(:rename_namespace). - with(migration_namespace(top_level_namespace)) + expect(subject).to receive(:rename_namespace) + .with(migration_namespace(top_level_namespace)) subject.rename_namespaces(type: :top_level) end it 'renames child namespaces' do - expect(subject).to receive(:rename_namespace). - with(migration_namespace(child_namespace)) + expect(subject).to receive(:rename_namespace) + .with(migration_namespace(child_namespace)) subject.rename_namespaces(type: :child) end diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb index 59e8de2712d..802f77ad430 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects do +describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :truncate do let(:migration) { FakeRenameReservedPathMigrationV1.new } let(:subject) { described_class.new(['the-path'], migration) } @@ -13,8 +13,8 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects do namespace = create(:namespace, path: 'hello') project = create(:empty_project, path: 'THE-path', namespace: namespace) - result_ids = described_class.new(['Hello/the-path'], migration). - projects_for_paths.map(&:id) + result_ids = described_class.new(['Hello/the-path'], migration) + .projects_for_paths.map(&:id) expect(result_ids).to contain_exactly(project.id) end @@ -39,8 +39,8 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects do end it 'invalidates the markdown cache of related projects' do - expect(subject).to receive(:remove_cached_html_for_projects). - with(projects.map(&:id)) + expect(subject).to receive(:remove_cached_html_for_projects) + .with(projects.map(&:id)) subject.rename_projects end @@ -54,9 +54,9 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects do end it 'renames path & route for the project' do - expect(subject).to receive(:rename_path_for_routable). - with(project). - and_call_original + expect(subject).to receive(:rename_path_for_routable) + .with(project) + .and_call_original subject.rename_project(project) @@ -64,24 +64,24 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects do end it 'moves the wiki & the repo' do - expect(subject).to receive(:move_repository). - with(project, 'known-parent/the-path.wiki', 'known-parent/the-path0.wiki') - expect(subject).to receive(:move_repository). - with(project, 'known-parent/the-path', 'known-parent/the-path0') + expect(subject).to receive(:move_repository) + .with(project, 'known-parent/the-path.wiki', 'known-parent/the-path0.wiki') + expect(subject).to receive(:move_repository) + .with(project, 'known-parent/the-path', 'known-parent/the-path0') subject.rename_project(project) end it 'moves uploads' do - expect(subject).to receive(:move_uploads). - with('known-parent/the-path', 'known-parent/the-path0') + expect(subject).to receive(:move_uploads) + .with('known-parent/the-path', 'known-parent/the-path0') subject.rename_project(project) end it 'moves pages' do - expect(subject).to receive(:move_pages). - with('known-parent/the-path', 'known-parent/the-path0') + expect(subject).to receive(:move_pages) + .with('known-parent/the-path', 'known-parent/the-path0') subject.rename_project(project) end diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb index f8cc1eb91ec..1d5e58855c1 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb @@ -3,17 +3,17 @@ require 'spec_helper' shared_examples 'renames child namespaces' do |type| it 'renames namespaces' do rename_namespaces = double - expect(described_class::RenameNamespaces). - to receive(:new).with(['first-path', 'second-path'], subject). - and_return(rename_namespaces) - expect(rename_namespaces).to receive(:rename_namespaces). - with(type: :child) + expect(described_class::RenameNamespaces) + .to receive(:new).with(['first-path', 'second-path'], subject) + .and_return(rename_namespaces) + expect(rename_namespaces).to receive(:rename_namespaces) + .with(type: :child) subject.rename_wildcard_paths(['first-path', 'second-path']) end end -describe Gitlab::Database::RenameReservedPathsMigration::V1 do +describe Gitlab::Database::RenameReservedPathsMigration::V1, :truncate do let(:subject) { FakeRenameReservedPathMigrationV1.new } before do @@ -29,9 +29,9 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1 do it 'should rename projects' do rename_projects = double - expect(described_class::RenameProjects). - to receive(:new).with(['the-path'], subject). - and_return(rename_projects) + expect(described_class::RenameProjects) + .to receive(:new).with(['the-path'], subject) + .and_return(rename_projects) expect(rename_projects).to receive(:rename_projects) @@ -42,11 +42,11 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1 do describe '#rename_root_paths' do it 'should rename namespaces' do rename_namespaces = double - expect(described_class::RenameNamespaces). - to receive(:new).with(['the-path'], subject). - and_return(rename_namespaces) - expect(rename_namespaces).to receive(:rename_namespaces). - with(type: :top_level) + expect(described_class::RenameNamespaces) + .to receive(:new).with(['the-path'], subject) + .and_return(rename_namespaces) + expect(rename_namespaces).to receive(:rename_namespaces) + .with(type: :top_level) subject.rename_root_paths('the-path') end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 428b6edb7d6..cbf6c35356e 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -34,8 +34,8 @@ describe Gitlab::Database, lib: true do describe '.version' do context "on mysql" do it "extracts the version number" do - allow(described_class).to receive(:database_version). - and_return("5.7.12-standard") + allow(described_class).to receive(:database_version) + .and_return("5.7.12-standard") expect(described_class.version).to eq '5.7.12-standard' end @@ -43,8 +43,8 @@ describe Gitlab::Database, lib: true do context "on postgresql" do it "extracts the version number" do - allow(described_class).to receive(:database_version). - and_return("PostgreSQL 9.4.4 on x86_64-apple-darwin14.3.0") + allow(described_class).to receive(:database_version) + .and_return("PostgreSQL 9.4.4 on x86_64-apple-darwin14.3.0") expect(described_class.version).to eq '9.4.4' end @@ -176,6 +176,10 @@ describe Gitlab::Database, lib: true do described_class.bulk_insert('test', rows) end + + it 'handles non-UTF-8 data' do + expect { described_class.bulk_insert('test', [{ a: "\255" }]) }.not_to raise_error + end end describe '.create_connection_pool' do diff --git a/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb b/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb index 4da8821726c..7e32770f95d 100644 --- a/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb @@ -54,6 +54,8 @@ describe Gitlab::DependencyLinker::RequirementsTxtLinker, lib: true do Sphinx>=1.3 docutils>=0.7 markupsafe + pytest~=3.0 + foop!=3.0 CONTENT end @@ -78,6 +80,8 @@ describe Gitlab::DependencyLinker::RequirementsTxtLinker, lib: true do expect(subject).to include(link('Sphinx', 'https://pypi.python.org/pypi/Sphinx')) expect(subject).to include(link('docutils', 'https://pypi.python.org/pypi/docutils')) expect(subject).to include(link('markupsafe', 'https://pypi.python.org/pypi/markupsafe')) + expect(subject).to include(link('pytest', 'https://pypi.python.org/pypi/pytest')) + expect(subject).to include(link('foop', 'https://pypi.python.org/pypi/foop')) end it 'links URLs' do diff --git a/spec/lib/gitlab/downtime_check_spec.rb b/spec/lib/gitlab/downtime_check_spec.rb index 42d895e548e..1f1e4e0216c 100644 --- a/spec/lib/gitlab/downtime_check_spec.rb +++ b/spec/lib/gitlab/downtime_check_spec.rb @@ -11,12 +11,12 @@ describe Gitlab::DowntimeCheck do context 'when a migration does not specify if downtime is required' do it 'raises RuntimeError' do - expect(subject).to receive(:class_for_migration_file). - with(path). - and_return(Class.new) + expect(subject).to receive(:class_for_migration_file) + .with(path) + .and_return(Class.new) - expect { subject.check([path]) }. - to raise_error(RuntimeError, /it requires downtime/) + expect { subject.check([path]) } + .to raise_error(RuntimeError, /it requires downtime/) end end @@ -25,12 +25,12 @@ describe Gitlab::DowntimeCheck do it 'raises RuntimeError' do stub_const('TestMigration::DOWNTIME', true) - expect(subject).to receive(:class_for_migration_file). - with(path). - and_return(TestMigration) + expect(subject).to receive(:class_for_migration_file) + .with(path) + .and_return(TestMigration) - expect { subject.check([path]) }. - to raise_error(RuntimeError, /no reason was given/) + expect { subject.check([path]) } + .to raise_error(RuntimeError, /no reason was given/) end end @@ -39,9 +39,9 @@ describe Gitlab::DowntimeCheck do stub_const('TestMigration::DOWNTIME', true) stub_const('TestMigration::DOWNTIME_REASON', 'foo') - expect(subject).to receive(:class_for_migration_file). - with(path). - and_return(TestMigration) + expect(subject).to receive(:class_for_migration_file) + .with(path) + .and_return(TestMigration) messages = subject.check([path]) @@ -65,9 +65,9 @@ describe Gitlab::DowntimeCheck do expect(subject).to receive(:require).with(path) - expect(subject).to receive(:class_for_migration_file). - with(path). - and_return(TestMigration) + expect(subject).to receive(:class_for_migration_file) + .with(path) + .and_return(TestMigration) expect(subject).to receive(:puts).with(an_instance_of(String)) diff --git a/spec/lib/gitlab/email/reply_parser_spec.rb b/spec/lib/gitlab/email/reply_parser_spec.rb index 28698e89c33..2ea5e6460a3 100644 --- a/spec/lib/gitlab/email/reply_parser_spec.rb +++ b/spec/lib/gitlab/email/reply_parser_spec.rb @@ -20,8 +20,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders plaintext-only email" do - expect(test_parse_body(fixture_file("emails/plaintext_only.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/plaintext_only.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp ### reply from default mail client in Windows 8.1 Metro @@ -46,8 +46,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles multiple paragraphs" do - expect(test_parse_body(fixture_file("emails/paragraphs.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/paragraphs.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp Is there any reason the *old* candy can't be be kept in silos while the new candy is imported into *new* silos? @@ -61,8 +61,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles multiple paragraphs when parsing html" do - expect(test_parse_body(fixture_file("emails/html_paragraphs.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/html_paragraphs.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp Awesome! @@ -74,8 +74,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles newlines" do - expect(test_parse_body(fixture_file("emails/newlines.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/newlines.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp This is my reply. It is my best reply. @@ -85,8 +85,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles inline reply" do - expect(test_parse_body(fixture_file("emails/inline_reply.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/inline_reply.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp > techAPJ <https://meta.discourse.org/users/techapj> > November 28 @@ -132,8 +132,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders email reply from gmail web client" do - expect(test_parse_body(fixture_file("emails/gmail_web.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/gmail_web.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp ### This is a reply from standard GMail in Google Chrome. @@ -151,8 +151,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders email reply from iOS default mail client" do - expect(test_parse_body(fixture_file("emails/ios_default.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/ios_default.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp ### this is a reply from iOS default mail @@ -166,8 +166,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders email reply from Android 5 gmail client" do - expect(test_parse_body(fixture_file("emails/android_gmail.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/android_gmail.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp ### this is a reply from Android 5 gmail @@ -184,8 +184,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders email reply from Windows 8.1 Metro default mail client" do - expect(test_parse_body(fixture_file("emails/windows_8_metro.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/windows_8_metro.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp ### reply from default mail client in Windows 8.1 Metro @@ -208,5 +208,9 @@ describe Gitlab::Email::ReplyParser, lib: true do it "properly renders html-only email from MS Outlook" do expect(test_parse_body(fixture_file("emails/outlook_html.eml"))).to eq("Microsoft Outlook 2010") end + + it "does not wrap links with no href in unnecessary brackets" do + expect(test_parse_body(fixture_file("emails/html_empty_link.eml"))).to eq("no brackets!") + end end end diff --git a/spec/lib/gitlab/etag_caching/middleware_spec.rb b/spec/lib/gitlab/etag_caching/middleware_spec.rb index 4acf4f047f1..4a54d641b4e 100644 --- a/spec/lib/gitlab/etag_caching/middleware_spec.rb +++ b/spec/lib/gitlab/etag_caching/middleware_spec.rb @@ -108,8 +108,8 @@ describe Gitlab::EtagCaching::Middleware do context 'when polling is disabled' do before do - allow(Gitlab::PollingInterval).to receive(:polling_enabled?). - and_return(false) + allow(Gitlab::PollingInterval).to receive(:polling_enabled?) + .and_return(false) end it 'returns status code 429' do diff --git a/spec/lib/gitlab/exclusive_lease_spec.rb b/spec/lib/gitlab/exclusive_lease_spec.rb index a366d68a146..81bbd70ffb8 100644 --- a/spec/lib/gitlab/exclusive_lease_spec.rb +++ b/spec/lib/gitlab/exclusive_lease_spec.rb @@ -19,6 +19,19 @@ describe Gitlab::ExclusiveLease, type: :redis do end end + describe '#renew' do + it 'returns true when we have the existing lease' do + lease = described_class.new(unique_key, timeout: 3600) + expect(lease.try_obtain).to be_present + expect(lease.renew).to be_truthy + end + + it 'returns false when we dont have a lease' do + lease = described_class.new(unique_key, timeout: 3600) + expect(lease.renew).to be_falsey + end + end + describe '#exists?' do it 'returns true for an existing lease' do lease = described_class.new(unique_key, timeout: 3600) diff --git a/spec/lib/gitlab/file_detector_spec.rb b/spec/lib/gitlab/file_detector_spec.rb index e5ba13bbaf8..695fd6f8573 100644 --- a/spec/lib/gitlab/file_detector_spec.rb +++ b/spec/lib/gitlab/file_detector_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' describe Gitlab::FileDetector do describe '.types_in_paths' do it 'returns the file types for the given paths' do - expect(described_class.types_in_paths(%w(README.md CHANGELOG VERSION VERSION))). - to eq(%i{readme changelog version}) + expect(described_class.types_in_paths(%w(README.md CHANGELOG VERSION VERSION))) + .to eq(%i{readme changelog version}) end it 'does not include unrecognized file paths' do - expect(described_class.types_in_paths(%w(README.md foo.txt))). - to eq(%i{readme}) + expect(described_class.types_in_paths(%w(README.md foo.txt))) + .to eq(%i{readme}) end end diff --git a/spec/lib/gitlab/git/attributes_spec.rb b/spec/lib/gitlab/git/attributes_spec.rb index 1cfd8db09a5..b715fc3410a 100644 --- a/spec/lib/gitlab/git/attributes_spec.rb +++ b/spec/lib/gitlab/git/attributes_spec.rb @@ -14,13 +14,13 @@ describe Gitlab::Git::Attributes, seed_helper: true do end it 'returns a Hash containing multiple attributes' do - expect(subject.attributes('test.sh')). - to eq({ 'eol' => 'lf', 'gitlab-language' => 'shell' }) + expect(subject.attributes('test.sh')) + .to eq({ 'eol' => 'lf', 'gitlab-language' => 'shell' }) end it 'returns a Hash containing attributes for a file with multiple extensions' do - expect(subject.attributes('test.haml.html')). - to eq({ 'gitlab-language' => 'haml' }) + expect(subject.attributes('test.haml.html')) + .to eq({ 'gitlab-language' => 'haml' }) end it 'returns a Hash containing attributes for a file in a directory' do @@ -28,8 +28,8 @@ describe Gitlab::Git::Attributes, seed_helper: true do end it 'returns a Hash containing attributes with query string parameters' do - expect(subject.attributes('foo.cgi')). - to eq({ 'key' => 'value?p1=v1&p2=v2' }) + expect(subject.attributes('foo.cgi')) + .to eq({ 'key' => 'value?p1=v1&p2=v2' }) end it 'returns a Hash containing the attributes for an absolute path' do @@ -39,11 +39,11 @@ describe Gitlab::Git::Attributes, seed_helper: true do it 'returns a Hash containing the attributes when a pattern is defined using an absolute path' do # When a path is given without a leading slash it should still match # patterns defined with a leading slash. - expect(subject.attributes('foo.png')). - to eq({ 'gitlab-language' => 'png' }) + expect(subject.attributes('foo.png')) + .to eq({ 'gitlab-language' => 'png' }) - expect(subject.attributes('/foo.png')). - to eq({ 'gitlab-language' => 'png' }) + expect(subject.attributes('/foo.png')) + .to eq({ 'gitlab-language' => 'png' }) end it 'returns an empty Hash for a defined path without attributes' do @@ -74,8 +74,8 @@ describe Gitlab::Git::Attributes, seed_helper: true do end it 'parses an entry that uses a tab to separate the pattern and attributes' do - expect(subject.patterns[File.join(path, '*.md')]). - to eq({ 'gitlab-language' => 'markdown' }) + expect(subject.patterns[File.join(path, '*.md')]) + .to eq({ 'gitlab-language' => 'markdown' }) end it 'stores patterns in reverse order' do @@ -91,9 +91,9 @@ describe Gitlab::Git::Attributes, seed_helper: true do end it 'does not parse anything when the attributes file does not exist' do - expect(File).to receive(:exist?). - with(File.join(path, 'info/attributes')). - and_return(false) + expect(File).to receive(:exist?) + .with(File.join(path, 'info/attributes')) + .and_return(false) expect(subject.patterns).to eq({}) end @@ -115,13 +115,13 @@ describe Gitlab::Git::Attributes, seed_helper: true do it 'parses multiple attributes' do input = 'boolean key=value -negated' - expect(subject.parse_attributes(input)). - to eq({ 'boolean' => true, 'key' => 'value', 'negated' => false }) + expect(subject.parse_attributes(input)) + .to eq({ 'boolean' => true, 'key' => 'value', 'negated' => false }) end it 'parses attributes with query string parameters' do - expect(subject.parse_attributes('foo=bar?baz=1')). - to eq({ 'foo' => 'bar?baz=1' }) + expect(subject.parse_attributes('foo=bar?baz=1')) + .to eq({ 'foo' => 'bar?baz=1' }) end end @@ -133,9 +133,9 @@ describe Gitlab::Git::Attributes, seed_helper: true do end it 'does not yield when the attributes file does not exist' do - expect(File).to receive(:exist?). - with(File.join(path, 'info/attributes')). - and_return(false) + expect(File).to receive(:exist?) + .with(File.join(path, 'info/attributes')) + .and_return(false) expect { |b| subject.each_line(&b) }.not_to yield_control end diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb index e6a07a58d73..58d3ee6b488 100644 --- a/spec/lib/gitlab/git/blob_spec.rb +++ b/spec/lib/gitlab/git/blob_spec.rb @@ -15,7 +15,7 @@ describe Gitlab::Git::Blob, seed_helper: true do end end - describe '.find' do + shared_examples 'finding blobs' do context 'file in subdir' do let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "files/ruby/popen.rb") } @@ -92,15 +92,25 @@ describe Gitlab::Git::Blob, seed_helper: true do end it 'marks the blob as binary' do - expect(Gitlab::Git::Blob).to receive(:new). - with(hash_including(binary: true)). - and_call_original + expect(Gitlab::Git::Blob).to receive(:new) + .with(hash_including(binary: true)) + .and_call_original expect(blob).to be_binary end end end + describe '.find' do + context 'when project_raw_show Gitaly feature is enabled' do + it_behaves_like 'finding blobs' + end + + context 'when project_raw_show Gitaly feature is disabled', skip_gitaly_mock: true do + it_behaves_like 'finding blobs' + end + end + describe '.raw' do let(:raw_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::RubyBlob::ID) } it { expect(raw_blob.id).to eq(SeedRepo::RubyBlob::ID) } diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb index 9eac7660cd1..9dba4397e79 100644 --- a/spec/lib/gitlab/git/branch_spec.rb +++ b/spec/lib/gitlab/git/branch_spec.rb @@ -45,8 +45,8 @@ describe Gitlab::Git::Branch, seed_helper: true do let(:branch) { described_class.new(repository, 'foo', gitaly_branch) } it 'parses Gitaly::FindLocalBranchResponse correctly' do - expect(Gitlab::Git::Commit).to receive(:decorate). - with(hash_including(attributes)).and_call_original + expect(Gitlab::Git::Commit).to receive(:decorate) + .with(hash_including(attributes)).and_call_original expect(branch.dereferenced_target.message.encoding).to be(Encoding::UTF_8) end diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index 3e44c577643..f20a14155dc 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -244,6 +244,33 @@ describe Gitlab::Git::Commit, seed_helper: true do end describe '.find_all' do + it 'should return a return a collection of commits' do + commits = described_class.find_all(repository) + + expect(commits).not_to be_empty + expect(commits).to all( be_a_kind_of(Gitlab::Git::Commit) ) + end + + context 'while applying a sort order based on the `order` option' do + it "allows ordering topologically (no parents shown before their children)" do + expect_any_instance_of(Rugged::Walker).to receive(:sorting).with(Rugged::SORT_TOPO) + + described_class.find_all(repository, order: :topo) + end + + it "allows ordering by date" do + expect_any_instance_of(Rugged::Walker).to receive(:sorting).with(Rugged::SORT_DATE | Rugged::SORT_TOPO) + + described_class.find_all(repository, order: :date) + end + + it "applies no sorting by default" do + expect_any_instance_of(Rugged::Walker).to receive(:sorting).with(Rugged::SORT_NONE) + + described_class.find_all(repository) + end + end + context 'max_count' do subject do commits = Gitlab::Git::Commit.find_all( @@ -281,26 +308,6 @@ describe Gitlab::Git::Commit, seed_helper: true do it { is_expected.to include(SeedRepo::FirstCommit::ID) } it { is_expected.not_to include(SeedRepo::LastCommit::ID) } end - - context 'contains feature + max_count' do - subject do - commits = Gitlab::Git::Commit.find_all( - repository, - contains: 'feature', - max_count: 7 - ) - - commits.map { |c| c.id } - end - - it 'has 7 elements' do - expect(subject.size).to eq(7) - end - - it { is_expected.not_to include(SeedRepo::Commit::PARENT_ID) } - it { is_expected.not_to include(SeedRepo::Commit::ID) } - it { is_expected.to include(SeedRepo::BigCommit::ID) } - end end end diff --git a/spec/lib/gitlab/git/diff_collection_spec.rb b/spec/lib/gitlab/git/diff_collection_spec.rb index a9a7bba2c05..d20298fa139 100644 --- a/spec/lib/gitlab/git/diff_collection_spec.rb +++ b/spec/lib/gitlab/git/diff_collection_spec.rb @@ -325,8 +325,8 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do end it 'yields Diff instances even when they are too large' do - expect { |b| collection.each(&b) }. - to yield_with_args(an_instance_of(Gitlab::Git::Diff)) + expect { |b| collection.each(&b) } + .to yield_with_args(an_instance_of(Gitlab::Git::Diff)) end it 'prunes diffs that are too large' do @@ -348,8 +348,8 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do let(:expanded) { true } it 'yields Diff instances even when they are quite big' do - expect { |b| subject.each(&b) }. - to yield_with_args(an_instance_of(Gitlab::Git::Diff)) + expect { |b| subject.each(&b) } + .to yield_with_args(an_instance_of(Gitlab::Git::Diff)) end it 'does not prune diffs' do @@ -367,8 +367,8 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do let(:expanded) { false } it 'yields Diff instances even when they are quite big' do - expect { |b| subject.each(&b) }. - to yield_with_args(an_instance_of(Gitlab::Git::Diff)) + expect { |b| subject.each(&b) } + .to yield_with_args(an_instance_of(Gitlab::Git::Diff)) end it 'prunes diffs that are quite big' do @@ -454,8 +454,8 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do let(:limits) { false } it 'yields Diff instances even when they are quite big' do - expect { |b| subject.each(&b) }. - to yield_with_args(an_instance_of(Gitlab::Git::Diff)) + expect { |b| subject.each(&b) } + .to yield_with_args(an_instance_of(Gitlab::Git::Diff)) end it 'does not prune diffs' do diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index 78d741f0110..d50ccb0df30 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -100,8 +100,8 @@ EOT context 'using a diff that is too large' do it 'prunes the diff' do - expect_any_instance_of(String).to receive(:bytesize). - and_return(1024 * 1024 * 1024) + expect_any_instance_of(String).to receive(:bytesize) + .and_return(1024 * 1024 * 1024) diff = described_class.new(@rugged_diff) @@ -130,8 +130,8 @@ EOT context 'using a large binary diff' do it 'does not prune the diff' do - expect_any_instance_of(Rugged::Diff::Delta).to receive(:binary?). - and_return(true) + expect_any_instance_of(Rugged::Diff::Delta).to receive(:binary?) + .and_return(true) diff = described_class.new(@rugged_diff) @@ -175,6 +175,14 @@ EOT expect(diff).to be_too_large end end + + context 'when the patch passed is not UTF-8-encoded' do + let(:raw_patch) { @raw_diff_hash[:diff].encode(Encoding::ASCII_8BIT) } + + it 'encodes diff patch to UTF-8' do + expect(diff.diff.encoding).to eq(Encoding::UTF_8) + end + end end end diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 02b3f167250..ee25aeefa95 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -41,14 +41,14 @@ describe Gitlab::Git::Repository, seed_helper: true do end it 'wraps GRPC not found' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name). - and_raise(GRPC::NotFound) + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name) + .and_raise(GRPC::NotFound) expect { repository.root_ref }.to raise_error(Gitlab::Git::Repository::NoRepository) end it 'wraps GRPC exceptions' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name). - and_raise(GRPC::Unknown) + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name) + .and_raise(GRPC::Unknown) expect { repository.root_ref }.to raise_error(Gitlab::Git::CommandError) end end @@ -141,14 +141,14 @@ describe Gitlab::Git::Repository, seed_helper: true do end it 'wraps GRPC not found' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names). - and_raise(GRPC::NotFound) + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names) + .and_raise(GRPC::NotFound) expect { subject }.to raise_error(Gitlab::Git::Repository::NoRepository) end it 'wraps GRPC other exceptions' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names). - and_raise(GRPC::Unknown) + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names) + .and_raise(GRPC::Unknown) expect { subject }.to raise_error(Gitlab::Git::CommandError) end end @@ -184,14 +184,14 @@ describe Gitlab::Git::Repository, seed_helper: true do end it 'wraps GRPC not found' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names). - and_raise(GRPC::NotFound) + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names) + .and_raise(GRPC::NotFound) expect { subject }.to raise_error(Gitlab::Git::Repository::NoRepository) end it 'wraps GRPC exceptions' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names). - and_raise(GRPC::Unknown) + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names) + .and_raise(GRPC::Unknown) expect { subject }.to raise_error(Gitlab::Git::CommandError) end end @@ -348,7 +348,7 @@ describe Gitlab::Git::Repository, seed_helper: true do let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } context 'where repo has submodules' do - let(:submodules) { repository.submodules('master') } + let(:submodules) { repository.send(:submodules, 'master') } let(:submodule) { submodules.first } it { expect(submodules).to be_kind_of Hash } @@ -383,12 +383,12 @@ describe Gitlab::Git::Repository, seed_helper: true do end it 'should not have an entry for an uncommited submodule dir' do - submodules = repository.submodules('fix-existing-submodule-dir') + submodules = repository.send(:submodules, 'fix-existing-submodule-dir') expect(submodules).not_to have_key('submodule-existing-dir') end it 'should handle tags correctly' do - submodules = repository.submodules('v1.2.1') + submodules = repository.send(:submodules, 'v1.2.1') expect(submodules.first).to eq([ "six", { @@ -414,7 +414,7 @@ describe Gitlab::Git::Repository, seed_helper: true do end context 'where repo doesn\'t have submodules' do - let(:submodules) { repository.submodules('6d39438') } + let(:submodules) { repository.send(:submodules, '6d39438') } it 'should return an empty hash' do expect(submodules).to be_empty end @@ -472,8 +472,8 @@ describe Gitlab::Git::Repository, seed_helper: true do end it "should move the tip of the master branch to the correct commit" do - new_tip = @normal_repo.rugged.references["refs/heads/master"]. - target.oid + new_tip = @normal_repo.rugged.references["refs/heads/master"] + .target.oid expect(new_tip).to eq(reset_commit) end @@ -1101,35 +1101,6 @@ describe Gitlab::Git::Repository, seed_helper: true do end end - describe '#find_commits' do - it 'should return a return a collection of commits' do - commits = repository.find_commits - - expect(commits).not_to be_empty - expect(commits).to all( be_a_kind_of(Gitlab::Git::Commit) ) - end - - context 'while applying a sort order based on the `order` option' do - it "allows ordering topologically (no parents shown before their children)" do - expect_any_instance_of(Rugged::Walker).to receive(:sorting).with(Rugged::SORT_TOPO) - - repository.find_commits(order: :topo) - end - - it "allows ordering by date" do - expect_any_instance_of(Rugged::Walker).to receive(:sorting).with(Rugged::SORT_DATE | Rugged::SORT_TOPO) - - repository.find_commits(order: :date) - end - - it "applies no sorting by default" do - expect_any_instance_of(Rugged::Walker).to receive(:sorting).with(Rugged::SORT_NONE) - - repository.find_commits - end - end - end - describe '#branches with deleted branch' do before(:each) do ref = double() @@ -1306,20 +1277,20 @@ describe Gitlab::Git::Repository, seed_helper: true do end it 'gets the branches from GitalyClient' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches). - and_return([]) + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches) + .and_return([]) @repo.local_branches end it 'wraps GRPC not found' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches). - and_raise(GRPC::NotFound) + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches) + .and_raise(GRPC::NotFound) expect { @repo.local_branches }.to raise_error(Gitlab::Git::Repository::NoRepository) end it 'wraps GRPC exceptions' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches). - and_raise(GRPC::Unknown) + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches) + .and_raise(GRPC::Unknown) expect { @repo.local_branches }.to raise_error(Gitlab::Git::CommandError) end end diff --git a/spec/lib/gitlab/gitaly_client/commit_spec.rb b/spec/lib/gitlab/gitaly_client/commit_spec.rb index cf1bc74779e..dff5b25c712 100644 --- a/spec/lib/gitlab/gitaly_client/commit_spec.rb +++ b/spec/lib/gitlab/gitaly_client/commit_spec.rb @@ -16,7 +16,7 @@ describe Gitlab::GitalyClient::Commit do right_commit_id: commit.id ) - expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_diff).with(request) + expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_diff).with(request, kind_of(Hash)) described_class.new(repository).diff_from_parent(commit) end @@ -31,7 +31,7 @@ describe Gitlab::GitalyClient::Commit do right_commit_id: initial_commit.id ) - expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_diff).with(request) + expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_diff).with(request, kind_of(Hash)) described_class.new(repository).diff_from_parent(initial_commit) end @@ -61,7 +61,7 @@ describe Gitlab::GitalyClient::Commit do right_commit_id: commit.id ) - expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_delta).with(request).and_return([]) + expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_delta).with(request, kind_of(Hash)).and_return([]) described_class.new(repository).commit_deltas(commit) end @@ -76,7 +76,7 @@ describe Gitlab::GitalyClient::Commit do right_commit_id: initial_commit.id ) - expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_delta).with(request).and_return([]) + expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_delta).with(request, kind_of(Hash)).and_return([]) described_class.new(repository).commit_deltas(initial_commit) end diff --git a/spec/lib/gitlab/gitaly_client/notifications_spec.rb b/spec/lib/gitlab/gitaly_client/notifications_spec.rb index e5c9e06a15e..7404ffe0f06 100644 --- a/spec/lib/gitlab/gitaly_client/notifications_spec.rb +++ b/spec/lib/gitlab/gitaly_client/notifications_spec.rb @@ -8,8 +8,8 @@ describe Gitlab::GitalyClient::Notifications do subject { described_class.new(project.repository) } it 'sends a post_receive message' do - expect_any_instance_of(Gitaly::Notifications::Stub). - to receive(:post_receive).with(gitaly_request_with_path(storage_name, relative_path)) + expect_any_instance_of(Gitaly::Notifications::Stub) + .to receive(:post_receive).with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) subject.post_receive end diff --git a/spec/lib/gitlab/gitaly_client/ref_spec.rb b/spec/lib/gitlab/gitaly_client/ref_spec.rb index 2ea44ef74b0..42dba2ff874 100644 --- a/spec/lib/gitlab/gitaly_client/ref_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_spec.rb @@ -19,10 +19,10 @@ describe Gitlab::GitalyClient::Ref do describe '#branch_names' do it 'sends a find_all_branch_names message' do - expect_any_instance_of(Gitaly::Ref::Stub). - to receive(:find_all_branch_names). - with(gitaly_request_with_path(storage_name, relative_path)). - and_return([]) + expect_any_instance_of(Gitaly::Ref::Stub) + .to receive(:find_all_branch_names) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return([]) client.branch_names end @@ -30,10 +30,10 @@ describe Gitlab::GitalyClient::Ref do describe '#tag_names' do it 'sends a find_all_tag_names message' do - expect_any_instance_of(Gitaly::Ref::Stub). - to receive(:find_all_tag_names). - with(gitaly_request_with_path(storage_name, relative_path)). - and_return([]) + expect_any_instance_of(Gitaly::Ref::Stub) + .to receive(:find_all_tag_names) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return([]) client.tag_names end @@ -41,10 +41,10 @@ describe Gitlab::GitalyClient::Ref do describe '#default_branch_name' do it 'sends a find_default_branch_name message' do - expect_any_instance_of(Gitaly::Ref::Stub). - to receive(:find_default_branch_name). - with(gitaly_request_with_path(storage_name, relative_path)). - and_return(double(name: 'foo')) + expect_any_instance_of(Gitaly::Ref::Stub) + .to receive(:find_default_branch_name) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return(double(name: 'foo')) client.default_branch_name end @@ -52,19 +52,19 @@ describe Gitlab::GitalyClient::Ref do describe '#local_branches' do it 'sends a find_local_branches message' do - expect_any_instance_of(Gitaly::Ref::Stub). - to receive(:find_local_branches). - with(gitaly_request_with_path(storage_name, relative_path)). - and_return([]) + expect_any_instance_of(Gitaly::Ref::Stub) + .to receive(:find_local_branches) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return([]) client.local_branches end it 'parses and sends the sort parameter' do - expect_any_instance_of(Gitaly::Ref::Stub). - to receive(:find_local_branches). - with(gitaly_request_with_params(sort_by: :UPDATED_DESC)). - and_return([]) + expect_any_instance_of(Gitaly::Ref::Stub) + .to receive(:find_local_branches) + .with(gitaly_request_with_params(sort_by: :UPDATED_DESC), kind_of(Hash)) + .and_return([]) client.local_branches(sort_by: 'updated_desc') end diff --git a/spec/lib/gitlab/gitlab_import/importer_spec.rb b/spec/lib/gitlab/gitlab_import/importer_spec.rb index 9b499b593d3..4f588da0a83 100644 --- a/spec/lib/gitlab/gitlab_import/importer_spec.rb +++ b/spec/lib/gitlab/gitlab_import/importer_spec.rb @@ -45,8 +45,8 @@ describe Gitlab::GitlabImport::Importer, lib: true do def stub_request(path, body) url = "https://gitlab.com/api/v3/projects/asd%2Fvim/#{path}?page=1&per_page=100" - WebMock.stub_request(:get, url). - to_return( + WebMock.stub_request(:get, url) + .to_return( headers: { 'Content-Type' => 'application/json' }, body: body ) diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb index fdc5b484ef1..07687b470c5 100644 --- a/spec/lib/gitlab/highlight_spec.rb +++ b/spec/lib/gitlab/highlight_spec.rb @@ -51,8 +51,8 @@ describe Gitlab::Highlight, lib: true do end it 'links dependencies via DependencyLinker' do - expect(Gitlab::DependencyLinker).to receive(:link). - with('file.name', 'Contents', anything).and_call_original + expect(Gitlab::DependencyLinker).to receive(:link) + .with('file.name', 'Contents', anything).and_call_original described_class.highlight('file.name', 'Contents') end diff --git a/spec/lib/gitlab/identifier_spec.rb b/spec/lib/gitlab/identifier_spec.rb index bb758a8a202..29912da2e25 100644 --- a/spec/lib/gitlab/identifier_spec.rb +++ b/spec/lib/gitlab/identifier_spec.rb @@ -12,8 +12,8 @@ describe Gitlab::Identifier do describe '#identify' do context 'without an identifier' do it 'identifies the user using a commit' do - expect(identifier).to receive(:identify_using_commit). - with(project, '123') + expect(identifier).to receive(:identify_using_commit) + .with(project, '123') identifier.identify('', project, '123') end @@ -21,8 +21,8 @@ describe Gitlab::Identifier do context 'with a user identifier' do it 'identifies the user using a user ID' do - expect(identifier).to receive(:identify_using_user). - with("user-#{user.id}") + expect(identifier).to receive(:identify_using_user) + .with("user-#{user.id}") identifier.identify("user-#{user.id}", project, '123') end @@ -30,8 +30,8 @@ describe Gitlab::Identifier do context 'with an SSH key identifier' do it 'identifies the user using an SSH key ID' do - expect(identifier).to receive(:identify_using_ssh_key). - with("key-#{key.id}") + expect(identifier).to receive(:identify_using_ssh_key) + .with("key-#{key.id}") identifier.identify("key-#{key.id}", project, '123') end diff --git a/spec/lib/gitlab/import_export/fork_spec.rb b/spec/lib/gitlab/import_export/fork_spec.rb index 42f3fc59f04..70796781532 100644 --- a/spec/lib/gitlab/import_export/fork_spec.rb +++ b/spec/lib/gitlab/import_export/fork_spec.rb @@ -44,6 +44,8 @@ describe 'forked project import', services: true do end it 'can access the MR' do - expect(project.merge_requests.first.ensure_ref_fetched.first).to include('refs/merge-requests/1/head') + project.merge_requests.first.ensure_ref_fetched + + expect(project.repository.ref_exists?('refs/merge-requests/1/head')).to be_truthy end end diff --git a/spec/lib/gitlab/job_waiter_spec.rb b/spec/lib/gitlab/job_waiter_spec.rb index 780f5b1f8d7..6186cec2689 100644 --- a/spec/lib/gitlab/job_waiter_spec.rb +++ b/spec/lib/gitlab/job_waiter_spec.rb @@ -4,8 +4,8 @@ describe Gitlab::JobWaiter do describe '#wait' do let(:waiter) { described_class.new(%w(a)) } it 'returns when all jobs have been completed' do - expect(Gitlab::SidekiqStatus).to receive(:all_completed?).with(%w(a)). - and_return(true) + expect(Gitlab::SidekiqStatus).to receive(:all_completed?).with(%w(a)) + .and_return(true) expect(waiter).not_to receive(:sleep) @@ -13,9 +13,9 @@ describe Gitlab::JobWaiter do end it 'sleeps between checking the job statuses' do - expect(Gitlab::SidekiqStatus).to receive(:all_completed?). - with(%w(a)). - and_return(false, true) + expect(Gitlab::SidekiqStatus).to receive(:all_completed?) + .with(%w(a)) + .and_return(false, true) expect(waiter).to receive(:sleep).with(described_class::INTERVAL) diff --git a/spec/lib/gitlab/ldap/authentication_spec.rb b/spec/lib/gitlab/ldap/authentication_spec.rb index b8f3290e84c..f689b47fec4 100644 --- a/spec/lib/gitlab/ldap/authentication_spec.rb +++ b/spec/lib/gitlab/ldap/authentication_spec.rb @@ -16,8 +16,8 @@ describe Gitlab::LDAP::Authentication, lib: true do # try only to fake the LDAP call adapter = double('adapter', dn: dn).as_null_object - allow_any_instance_of(described_class). - to receive(:adapter).and_return(adapter) + allow_any_instance_of(described_class) + .to receive(:adapter).and_return(adapter) expect(described_class.login(login, password)).to be_truthy end @@ -25,8 +25,8 @@ describe Gitlab::LDAP::Authentication, lib: true do it "is false if the user does not exist" do # try only to fake the LDAP call adapter = double('adapter', dn: dn).as_null_object - allow_any_instance_of(described_class). - to receive(:adapter).and_return(adapter) + allow_any_instance_of(described_class) + .to receive(:adapter).and_return(adapter) expect(described_class.login(login, password)).to be_falsey end @@ -36,8 +36,8 @@ describe Gitlab::LDAP::Authentication, lib: true do # try only to fake the LDAP call adapter = double('adapter', bind_as: nil).as_null_object - allow_any_instance_of(described_class). - to receive(:adapter).and_return(adapter) + allow_any_instance_of(described_class) + .to receive(:adapter).and_return(adapter) expect(described_class.login(login, password)).to be_falsey end diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb index f0a1dd22fee..b796d8bf076 100644 --- a/spec/lib/gitlab/ldap/user_spec.rb +++ b/spec/lib/gitlab/ldap/user_spec.rb @@ -167,8 +167,8 @@ describe Gitlab::LDAP::User, lib: true do describe 'blocking' do def configure_block(value) - allow_any_instance_of(Gitlab::LDAP::Config). - to receive(:block_auto_created_users).and_return(value) + allow_any_instance_of(Gitlab::LDAP::Config) + .to receive(:block_auto_created_users).and_return(value) end context 'signup' do diff --git a/spec/lib/gitlab/metrics/instrumentation_spec.rb b/spec/lib/gitlab/metrics/instrumentation_spec.rb index a986cb520fb..4b19ee19103 100644 --- a/spec/lib/gitlab/metrics/instrumentation_spec.rb +++ b/spec/lib/gitlab/metrics/instrumentation_spec.rb @@ -78,11 +78,11 @@ describe Gitlab::Metrics::Instrumentation do end it 'tracks the call duration upon calling the method' do - allow(Gitlab::Metrics).to receive(:method_call_threshold). - and_return(0) + allow(Gitlab::Metrics).to receive(:method_call_threshold) + .and_return(0) - allow(described_class).to receive(:transaction). - and_return(transaction) + allow(described_class).to receive(:transaction) + .and_return(transaction) expect_any_instance_of(Gitlab::Metrics::MethodCall).to receive(:measure) @@ -90,8 +90,8 @@ describe Gitlab::Metrics::Instrumentation do end it 'does not track method calls below a given duration threshold' do - allow(Gitlab::Metrics).to receive(:method_call_threshold). - and_return(100) + allow(Gitlab::Metrics).to receive(:method_call_threshold) + .and_return(100) expect(transaction).not_to receive(:add_metric) @@ -137,8 +137,8 @@ describe Gitlab::Metrics::Instrumentation do before do allow(Gitlab::Metrics).to receive(:enabled?).and_return(true) - described_class. - instrument_instance_method(@dummy, :bar) + described_class + .instrument_instance_method(@dummy, :bar) end it 'instruments instances of the Class' do @@ -156,11 +156,11 @@ describe Gitlab::Metrics::Instrumentation do end it 'tracks the call duration upon calling the method' do - allow(Gitlab::Metrics).to receive(:method_call_threshold). - and_return(0) + allow(Gitlab::Metrics).to receive(:method_call_threshold) + .and_return(0) - allow(described_class).to receive(:transaction). - and_return(transaction) + allow(described_class).to receive(:transaction) + .and_return(transaction) expect_any_instance_of(Gitlab::Metrics::MethodCall).to receive(:measure) @@ -168,8 +168,8 @@ describe Gitlab::Metrics::Instrumentation do end it 'does not track method calls below a given duration threshold' do - allow(Gitlab::Metrics).to receive(:method_call_threshold). - and_return(100) + allow(Gitlab::Metrics).to receive(:method_call_threshold) + .and_return(100) expect(transaction).not_to receive(:add_metric) @@ -183,8 +183,8 @@ describe Gitlab::Metrics::Instrumentation do end it 'does not instrument the method' do - described_class. - instrument_instance_method(@dummy, :bar) + described_class + .instrument_instance_method(@dummy, :bar) expect(described_class.instrumented?(@dummy)).to eq(false) end diff --git a/spec/lib/gitlab/metrics/rack_middleware_spec.rb b/spec/lib/gitlab/metrics/rack_middleware_spec.rb index fb470ea7568..ec415f2bd85 100644 --- a/spec/lib/gitlab/metrics/rack_middleware_spec.rb +++ b/spec/lib/gitlab/metrics/rack_middleware_spec.rb @@ -26,8 +26,8 @@ describe Gitlab::Metrics::RackMiddleware do allow(app).to receive(:call).with(env) - expect(middleware).to receive(:tag_controller). - with(an_instance_of(Gitlab::Metrics::Transaction), env) + expect(middleware).to receive(:tag_controller) + .with(an_instance_of(Gitlab::Metrics::Transaction), env) middleware.call(env) end @@ -40,8 +40,8 @@ describe Gitlab::Metrics::RackMiddleware do allow(app).to receive(:call).with(env) - expect(middleware).to receive(:tag_endpoint). - with(an_instance_of(Gitlab::Metrics::Transaction), env) + expect(middleware).to receive(:tag_endpoint) + .with(an_instance_of(Gitlab::Metrics::Transaction), env) middleware.call(env) end @@ -49,8 +49,8 @@ describe Gitlab::Metrics::RackMiddleware do it 'tracks any raised exceptions' do expect(app).to receive(:call).with(env).and_raise(RuntimeError) - expect_any_instance_of(Gitlab::Metrics::Transaction). - to receive(:add_event).with(:rails_exception) + expect_any_instance_of(Gitlab::Metrics::Transaction) + .to receive(:add_event).with(:rails_exception) expect { middleware.call(env) }.to raise_error(RuntimeError) end diff --git a/spec/lib/gitlab/metrics/sampler_spec.rb b/spec/lib/gitlab/metrics/sampler_spec.rb index 1ab923b58cf..d07ce6f81af 100644 --- a/spec/lib/gitlab/metrics/sampler_spec.rb +++ b/spec/lib/gitlab/metrics/sampler_spec.rb @@ -38,8 +38,8 @@ describe Gitlab::Metrics::Sampler do describe '#flush' do it 'schedules the metrics using Sidekiq' do - expect(Gitlab::Metrics).to receive(:submit_metrics). - with([an_instance_of(Hash)]) + expect(Gitlab::Metrics).to receive(:submit_metrics) + .with([an_instance_of(Hash)]) sampler.sample_memory_usage sampler.flush @@ -48,12 +48,12 @@ describe Gitlab::Metrics::Sampler do describe '#sample_memory_usage' do it 'adds a metric containing the memory usage' do - expect(Gitlab::Metrics::System).to receive(:memory_usage). - and_return(9000) + expect(Gitlab::Metrics::System).to receive(:memory_usage) + .and_return(9000) - expect(sampler).to receive(:add_metric). - with(/memory_usage/, value: 9000). - and_call_original + expect(sampler).to receive(:add_metric) + .with(/memory_usage/, value: 9000) + .and_call_original sampler.sample_memory_usage end @@ -61,12 +61,12 @@ describe Gitlab::Metrics::Sampler do describe '#sample_file_descriptors' do it 'adds a metric containing the amount of open file descriptors' do - expect(Gitlab::Metrics::System).to receive(:file_descriptor_count). - and_return(4) + expect(Gitlab::Metrics::System).to receive(:file_descriptor_count) + .and_return(4) - expect(sampler).to receive(:add_metric). - with(/file_descriptors/, value: 4). - and_call_original + expect(sampler).to receive(:add_metric) + .with(/file_descriptors/, value: 4) + .and_call_original sampler.sample_file_descriptors end @@ -75,10 +75,10 @@ describe Gitlab::Metrics::Sampler do if Gitlab::Metrics.mri? describe '#sample_objects' do it 'adds a metric containing the amount of allocated objects' do - expect(sampler).to receive(:add_metric). - with(/object_counts/, an_instance_of(Hash), an_instance_of(Hash)). - at_least(:once). - and_call_original + expect(sampler).to receive(:add_metric) + .with(/object_counts/, an_instance_of(Hash), an_instance_of(Hash)) + .at_least(:once) + .and_call_original sampler.sample_objects end @@ -86,8 +86,8 @@ describe Gitlab::Metrics::Sampler do it 'ignores classes without a name' do expect(Allocations).to receive(:to_hash).and_return({ Class.new => 4 }) - expect(sampler).not_to receive(:add_metric). - with('object_counts', an_instance_of(Hash), type: nil) + expect(sampler).not_to receive(:add_metric) + .with('object_counts', an_instance_of(Hash), type: nil) sampler.sample_objects end @@ -98,9 +98,9 @@ describe Gitlab::Metrics::Sampler do it 'adds a metric containing garbage collection statistics' do expect(GC::Profiler).to receive(:total_time).and_return(0.24) - expect(sampler).to receive(:add_metric). - with(/gc_statistics/, an_instance_of(Hash)). - and_call_original + expect(sampler).to receive(:add_metric) + .with(/gc_statistics/, an_instance_of(Hash)) + .and_call_original sampler.sample_gc end @@ -110,9 +110,9 @@ describe Gitlab::Metrics::Sampler do it 'prefixes the series name for a Rails process' do expect(sampler).to receive(:sidekiq?).and_return(false) - expect(Gitlab::Metrics::Metric).to receive(:new). - with('rails_cats', { value: 10 }, {}). - and_call_original + expect(Gitlab::Metrics::Metric).to receive(:new) + .with('rails_cats', { value: 10 }, {}) + .and_call_original sampler.add_metric('cats', value: 10) end @@ -120,9 +120,9 @@ describe Gitlab::Metrics::Sampler do it 'prefixes the series name for a Sidekiq process' do expect(sampler).to receive(:sidekiq?).and_return(true) - expect(Gitlab::Metrics::Metric).to receive(:new). - with('sidekiq_cats', { value: 10 }, {}). - and_call_original + expect(Gitlab::Metrics::Metric).to receive(:new) + .with('sidekiq_cats', { value: 10 }, {}) + .and_call_original sampler.add_metric('cats', value: 10) end diff --git a/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb b/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb index acaba785606..b576d7173f5 100644 --- a/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb +++ b/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb @@ -8,12 +8,12 @@ describe Gitlab::Metrics::SidekiqMiddleware do it 'tracks the transaction' do worker = double(:worker, class: double(:class, name: 'TestWorker')) - expect(Gitlab::Metrics::Transaction).to receive(:new). - with('TestWorker#perform'). - and_call_original + expect(Gitlab::Metrics::Transaction).to receive(:new) + .with('TestWorker#perform') + .and_call_original - expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set). - with(:sidekiq_queue_duration, instance_of(Float)) + expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set) + .with(:sidekiq_queue_duration, instance_of(Float)) expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:finish) @@ -23,12 +23,12 @@ describe Gitlab::Metrics::SidekiqMiddleware do it 'tracks the transaction (for messages without `enqueued_at`)' do worker = double(:worker, class: double(:class, name: 'TestWorker')) - expect(Gitlab::Metrics::Transaction).to receive(:new). - with('TestWorker#perform'). - and_call_original + expect(Gitlab::Metrics::Transaction).to receive(:new) + .with('TestWorker#perform') + .and_call_original - expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set). - with(:sidekiq_queue_duration, instance_of(Float)) + expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set) + .with(:sidekiq_queue_duration, instance_of(Float)) expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:finish) @@ -38,17 +38,17 @@ describe Gitlab::Metrics::SidekiqMiddleware do it 'tracks any raised exceptions' do worker = double(:worker, class: double(:class, name: 'TestWorker')) - expect_any_instance_of(Gitlab::Metrics::Transaction). - to receive(:run).and_raise(RuntimeError) + expect_any_instance_of(Gitlab::Metrics::Transaction) + .to receive(:run).and_raise(RuntimeError) - expect_any_instance_of(Gitlab::Metrics::Transaction). - to receive(:add_event).with(:sidekiq_exception) + expect_any_instance_of(Gitlab::Metrics::Transaction) + .to receive(:add_event).with(:sidekiq_exception) - expect_any_instance_of(Gitlab::Metrics::Transaction). - to receive(:finish) + expect_any_instance_of(Gitlab::Metrics::Transaction) + .to receive(:finish) - expect { middleware.call(worker, message, :test) }. - to raise_error(RuntimeError) + expect { middleware.call(worker, message, :test) } + .to raise_error(RuntimeError) end end end diff --git a/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb b/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb index 0695c5ce096..e7b595405a8 100644 --- a/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb +++ b/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb @@ -21,11 +21,11 @@ describe Gitlab::Metrics::Subscribers::ActionView do values = { duration: 2.1 } tags = { view: 'app/views/x.html.haml' } - expect(transaction).to receive(:increment). - with(:view_duration, 2.1) + expect(transaction).to receive(:increment) + .with(:view_duration, 2.1) - expect(transaction).to receive(:add_metric). - with(described_class::SERIES, values, tags) + expect(transaction).to receive(:add_metric) + .with(described_class::SERIES, values, tags) subscriber.render_template(event) end diff --git a/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb b/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb index 49699ffe28f..ce6587e993f 100644 --- a/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb +++ b/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb @@ -12,8 +12,8 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do describe '#sql' do describe 'without a current transaction' do it 'simply returns' do - expect_any_instance_of(Gitlab::Metrics::Transaction). - not_to receive(:increment) + expect_any_instance_of(Gitlab::Metrics::Transaction) + .not_to receive(:increment) subscriber.sql(event) end @@ -21,15 +21,15 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do describe 'with a current transaction' do it 'increments the :sql_duration value' do - expect(subscriber).to receive(:current_transaction). - at_least(:once). - and_return(transaction) + expect(subscriber).to receive(:current_transaction) + .at_least(:once) + .and_return(transaction) - expect(transaction).to receive(:increment). - with(:sql_duration, 0.2) + expect(transaction).to receive(:increment) + .with(:sql_duration, 0.2) - expect(transaction).to receive(:increment). - with(:sql_count, 1) + expect(transaction).to receive(:increment) + .with(:sql_count, 1) subscriber.sql(event) end diff --git a/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb b/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb index d986c6fac43..f04dc8dcc02 100644 --- a/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb +++ b/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb @@ -8,26 +8,26 @@ describe Gitlab::Metrics::Subscribers::RailsCache do describe '#cache_read' do it 'increments the cache_read duration' do - expect(subscriber).to receive(:increment). - with(:cache_read, event.duration) + expect(subscriber).to receive(:increment) + .with(:cache_read, event.duration) subscriber.cache_read(event) end context 'with a transaction' do before do - allow(subscriber).to receive(:current_transaction). - and_return(transaction) + allow(subscriber).to receive(:current_transaction) + .and_return(transaction) end context 'with hit event' do let(:event) { double(:event, duration: 15.2, payload: { hit: true }) } it 'increments the cache_read_hit count' do - expect(transaction).to receive(:increment). - with(:cache_read_hit_count, 1) - expect(transaction).to receive(:increment). - with(any_args).at_least(1) # Other calls + expect(transaction).to receive(:increment) + .with(:cache_read_hit_count, 1) + expect(transaction).to receive(:increment) + .with(any_args).at_least(1) # Other calls subscriber.cache_read(event) end @@ -36,8 +36,8 @@ describe Gitlab::Metrics::Subscribers::RailsCache do let(:event) { double(:event, duration: 15.2, payload: { hit: true, super_operation: :fetch }) } it 'does not increment cache read miss' do - expect(transaction).not_to receive(:increment). - with(:cache_read_hit_count, 1) + expect(transaction).not_to receive(:increment) + .with(:cache_read_hit_count, 1) subscriber.cache_read(event) end @@ -48,10 +48,10 @@ describe Gitlab::Metrics::Subscribers::RailsCache do let(:event) { double(:event, duration: 15.2, payload: { hit: false }) } it 'increments the cache_read_miss count' do - expect(transaction).to receive(:increment). - with(:cache_read_miss_count, 1) - expect(transaction).to receive(:increment). - with(any_args).at_least(1) # Other calls + expect(transaction).to receive(:increment) + .with(:cache_read_miss_count, 1) + expect(transaction).to receive(:increment) + .with(any_args).at_least(1) # Other calls subscriber.cache_read(event) end @@ -60,8 +60,8 @@ describe Gitlab::Metrics::Subscribers::RailsCache do let(:event) { double(:event, duration: 15.2, payload: { hit: false, super_operation: :fetch }) } it 'does not increment cache read miss' do - expect(transaction).not_to receive(:increment). - with(:cache_read_miss_count, 1) + expect(transaction).not_to receive(:increment) + .with(:cache_read_miss_count, 1) subscriber.cache_read(event) end @@ -72,8 +72,8 @@ describe Gitlab::Metrics::Subscribers::RailsCache do describe '#cache_write' do it 'increments the cache_write duration' do - expect(subscriber).to receive(:increment). - with(:cache_write, event.duration) + expect(subscriber).to receive(:increment) + .with(:cache_write, event.duration) subscriber.cache_write(event) end @@ -81,8 +81,8 @@ describe Gitlab::Metrics::Subscribers::RailsCache do describe '#cache_delete' do it 'increments the cache_delete duration' do - expect(subscriber).to receive(:increment). - with(:cache_delete, event.duration) + expect(subscriber).to receive(:increment) + .with(:cache_delete, event.duration) subscriber.cache_delete(event) end @@ -90,8 +90,8 @@ describe Gitlab::Metrics::Subscribers::RailsCache do describe '#cache_exist?' do it 'increments the cache_exists duration' do - expect(subscriber).to receive(:increment). - with(:cache_exists, event.duration) + expect(subscriber).to receive(:increment) + .with(:cache_exists, event.duration) subscriber.cache_exist?(event) end @@ -108,13 +108,13 @@ describe Gitlab::Metrics::Subscribers::RailsCache do context 'with a transaction' do before do - allow(subscriber).to receive(:current_transaction). - and_return(transaction) + allow(subscriber).to receive(:current_transaction) + .and_return(transaction) end it 'increments the cache_read_hit count' do - expect(transaction).to receive(:increment). - with(:cache_read_hit_count, 1) + expect(transaction).to receive(:increment) + .with(:cache_read_hit_count, 1) subscriber.cache_fetch_hit(event) end @@ -132,13 +132,13 @@ describe Gitlab::Metrics::Subscribers::RailsCache do context 'with a transaction' do before do - allow(subscriber).to receive(:current_transaction). - and_return(transaction) + allow(subscriber).to receive(:current_transaction) + .and_return(transaction) end it 'increments the cache_fetch_miss count' do - expect(transaction).to receive(:increment). - with(:cache_read_miss_count, 1) + expect(transaction).to receive(:increment) + .with(:cache_read_miss_count, 1) subscriber.cache_generate(event) end @@ -156,22 +156,22 @@ describe Gitlab::Metrics::Subscribers::RailsCache do context 'with a transaction' do before do - allow(subscriber).to receive(:current_transaction). - and_return(transaction) + allow(subscriber).to receive(:current_transaction) + .and_return(transaction) end it 'increments the total and specific cache duration' do - expect(transaction).to receive(:increment). - with(:cache_duration, event.duration) + expect(transaction).to receive(:increment) + .with(:cache_duration, event.duration) - expect(transaction).to receive(:increment). - with(:cache_count, 1) + expect(transaction).to receive(:increment) + .with(:cache_count, 1) - expect(transaction).to receive(:increment). - with(:cache_delete_duration, event.duration) + expect(transaction).to receive(:increment) + .with(:cache_delete_duration, event.duration) - expect(transaction).to receive(:increment). - with(:cache_delete_count, 1) + expect(transaction).to receive(:increment) + .with(:cache_delete_count, 1) subscriber.increment(:cache_delete, event.duration) end diff --git a/spec/lib/gitlab/metrics/transaction_spec.rb b/spec/lib/gitlab/metrics/transaction_spec.rb index 0c5a6246d85..3779af81512 100644 --- a/spec/lib/gitlab/metrics/transaction_spec.rb +++ b/spec/lib/gitlab/metrics/transaction_spec.rb @@ -39,8 +39,8 @@ describe Gitlab::Metrics::Transaction do describe '#add_metric' do it 'adds a metric to the transaction' do - expect(Gitlab::Metrics::Metric).to receive(:new). - with('rails_foo', { number: 10 }, {}) + expect(Gitlab::Metrics::Metric).to receive(:new) + .with('rails_foo', { number: 10 }, {}) transaction.add_metric('foo', number: 10) end @@ -61,8 +61,8 @@ describe Gitlab::Metrics::Transaction do values = { duration: 0.0, time: 3, allocated_memory: a_kind_of(Numeric) } - expect(transaction).to receive(:add_metric). - with('transactions', values, {}) + expect(transaction).to receive(:add_metric) + .with('transactions', values, {}) transaction.track_self end @@ -78,8 +78,8 @@ describe Gitlab::Metrics::Transaction do allocated_memory: a_kind_of(Numeric) } - expect(transaction).to receive(:add_metric). - with('transactions', values, {}) + expect(transaction).to receive(:add_metric) + .with('transactions', values, {}) transaction.track_self end @@ -109,8 +109,8 @@ describe Gitlab::Metrics::Transaction do allocated_memory: a_kind_of(Numeric) } - expect(transaction).to receive(:add_metric). - with('transactions', values, {}) + expect(transaction).to receive(:add_metric) + .with('transactions', values, {}) transaction.track_self end @@ -120,8 +120,8 @@ describe Gitlab::Metrics::Transaction do it 'submits the metrics to Sidekiq' do transaction.track_self - expect(Gitlab::Metrics).to receive(:submit_metrics). - with([an_instance_of(Hash)]) + expect(Gitlab::Metrics).to receive(:submit_metrics) + .with([an_instance_of(Hash)]) transaction.submit end @@ -137,8 +137,8 @@ describe Gitlab::Metrics::Transaction do timestamp: a_kind_of(Integer) } - expect(Gitlab::Metrics).to receive(:submit_metrics). - with([hash]) + expect(Gitlab::Metrics).to receive(:submit_metrics) + .with([hash]) transaction.submit end @@ -154,8 +154,8 @@ describe Gitlab::Metrics::Transaction do timestamp: a_kind_of(Integer) } - expect(Gitlab::Metrics).to receive(:submit_metrics). - with([hash]) + expect(Gitlab::Metrics).to receive(:submit_metrics) + .with([hash]) transaction.submit end diff --git a/spec/lib/gitlab/metrics_spec.rb b/spec/lib/gitlab/metrics_spec.rb index 5a87b906609..599b8807d8d 100644 --- a/spec/lib/gitlab/metrics_spec.rb +++ b/spec/lib/gitlab/metrics_spec.rb @@ -15,6 +15,36 @@ describe Gitlab::Metrics do end end + describe '.prometheus_metrics_enabled_unmemoized' do + subject { described_class.send(:prometheus_metrics_enabled_unmemoized) } + + context 'prometheus metrics enabled in config' do + before do + allow(described_class).to receive(:current_application_settings).and_return(prometheus_metrics_enabled: true) + end + + context 'when metrics folder is present' do + before do + allow(described_class).to receive(:metrics_folder_present?).and_return(true) + end + + it 'metrics are enabled' do + expect(subject).to eq(true) + end + end + + context 'when metrics folder is missing' do + before do + allow(described_class).to receive(:metrics_folder_present?).and_return(false) + end + + it 'metrics are disabled' do + expect(subject).to eq(false) + end + end + end + end + describe '.prometheus_metrics_enabled?' do it 'returns a boolean' do expect(described_class.prometheus_metrics_enabled?).to be_in([true, false]) @@ -42,8 +72,8 @@ describe Gitlab::Metrics do describe '.prepare_metrics' do it 'returns a Hash with the keys as Symbols' do - metrics = described_class. - prepare_metrics([{ 'values' => {}, 'tags' => {} }]) + metrics = described_class + .prepare_metrics([{ 'values' => {}, 'tags' => {} }]) expect(metrics).to eq([{ values: {}, tags: {} }]) end @@ -88,19 +118,19 @@ describe Gitlab::Metrics do let(:transaction) { Gitlab::Metrics::Transaction.new } before do - allow(described_class).to receive(:current_transaction). - and_return(transaction) + allow(described_class).to receive(:current_transaction) + .and_return(transaction) end it 'adds a metric to the current transaction' do - expect(transaction).to receive(:increment). - with('foo_real_time', a_kind_of(Numeric)) + expect(transaction).to receive(:increment) + .with('foo_real_time', a_kind_of(Numeric)) - expect(transaction).to receive(:increment). - with('foo_cpu_time', a_kind_of(Numeric)) + expect(transaction).to receive(:increment) + .with('foo_cpu_time', a_kind_of(Numeric)) - expect(transaction).to receive(:increment). - with('foo_call_count', 1) + expect(transaction).to receive(:increment) + .with('foo_call_count', 1) described_class.measure(:foo) { 10 } end @@ -116,8 +146,8 @@ describe Gitlab::Metrics do describe '.tag_transaction' do context 'without a transaction' do it 'does nothing' do - expect_any_instance_of(Gitlab::Metrics::Transaction). - not_to receive(:add_tag) + expect_any_instance_of(Gitlab::Metrics::Transaction) + .not_to receive(:add_tag) described_class.tag_transaction(:foo, 'bar') end @@ -127,11 +157,11 @@ describe Gitlab::Metrics do let(:transaction) { Gitlab::Metrics::Transaction.new } it 'adds the tag to the transaction' do - expect(described_class).to receive(:current_transaction). - and_return(transaction) + expect(described_class).to receive(:current_transaction) + .and_return(transaction) - expect(transaction).to receive(:add_tag). - with(:foo, 'bar') + expect(transaction).to receive(:add_tag) + .with(:foo, 'bar') described_class.tag_transaction(:foo, 'bar') end @@ -141,8 +171,8 @@ describe Gitlab::Metrics do describe '.action=' do context 'without a transaction' do it 'does nothing' do - expect_any_instance_of(Gitlab::Metrics::Transaction). - not_to receive(:action=) + expect_any_instance_of(Gitlab::Metrics::Transaction) + .not_to receive(:action=) described_class.action = 'foo' end @@ -152,8 +182,8 @@ describe Gitlab::Metrics do it 'sets the action of a transaction' do trans = Gitlab::Metrics::Transaction.new - expect(described_class).to receive(:current_transaction). - and_return(trans) + expect(described_class).to receive(:current_transaction) + .and_return(trans) expect(trans).to receive(:action=).with('foo') @@ -171,8 +201,8 @@ describe Gitlab::Metrics do describe '.add_event' do context 'without a transaction' do it 'does nothing' do - expect_any_instance_of(Gitlab::Metrics::Transaction). - not_to receive(:add_event) + expect_any_instance_of(Gitlab::Metrics::Transaction) + .not_to receive(:add_event) described_class.add_event(:meow) end @@ -184,8 +214,8 @@ describe Gitlab::Metrics do expect(transaction).to receive(:add_event).with(:meow) - expect(described_class).to receive(:current_transaction). - and_return(transaction) + expect(described_class).to receive(:current_transaction) + .and_return(transaction) described_class.add_event(:meow) end diff --git a/spec/lib/gitlab/project_authorizations_spec.rb b/spec/lib/gitlab/project_authorizations_spec.rb index 67321f43710..9ce33685697 100644 --- a/spec/lib/gitlab/project_authorizations_spec.rb +++ b/spec/lib/gitlab/project_authorizations_spec.rb @@ -34,8 +34,8 @@ describe Gitlab::ProjectAuthorizations do end it 'includes the correct projects' do - expect(authorizations.pluck(:project_id)). - to include(owned_project.id, other_project.id, group_project.id) + expect(authorizations.pluck(:project_id)) + .to include(owned_project.id, other_project.id, group_project.id) end it 'includes the correct access levels' do diff --git a/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb b/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb new file mode 100644 index 00000000000..61d48b05454 --- /dev/null +++ b/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb @@ -0,0 +1,246 @@ +require 'spec_helper' + +describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do + include Prometheus::MetricBuilders + + let(:parser_error_class) { Gitlab::Prometheus::ParsingError } + + describe '#load_groups_from_yaml' do + subject { described_class.load_groups_from_yaml } + + describe 'parsing sample yaml' do + let(:sample_yaml) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + metrics: + - title: "title" + required_metrics: [ metric_a, metric_b ] + weight: 1 + queries: [{ query_range: 'query_range_a', label: label, unit: unit }] + - title: "title" + required_metrics: [metric_a] + weight: 1 + queries: [{ query_range: 'query_range_empty' }] + - group: group_b + priority: 1 + metrics: + - title: title + required_metrics: ['metric_a'] + weight: 1 + queries: [{query_range: query_range_a}] + EOF + end + + before do + allow(described_class).to receive(:load_yaml_file) { YAML.load(sample_yaml) } + end + + it 'parses to two metric groups with 2 and 1 metric respectively' do + expect(subject.count).to eq(2) + expect(subject[0].metrics.count).to eq(2) + expect(subject[1].metrics.count).to eq(1) + end + + it 'provide group data' do + expect(subject[0]).to have_attributes(name: 'group_a', priority: 1) + expect(subject[1]).to have_attributes(name: 'group_b', priority: 1) + end + + it 'provides metrics data' do + metrics = subject.flat_map(&:metrics) + + expect(metrics.count).to eq(3) + expect(metrics[0]).to have_attributes(title: 'title', required_metrics: %w(metric_a metric_b), weight: 1) + expect(metrics[1]).to have_attributes(title: 'title', required_metrics: %w(metric_a), weight: 1) + expect(metrics[2]).to have_attributes(title: 'title', required_metrics: %w{metric_a}, weight: 1) + end + + it 'provides query data' do + queries = subject.flat_map(&:metrics).flat_map(&:queries) + + expect(queries.count).to eq(3) + expect(queries[0]).to eq(query_range: 'query_range_a', label: 'label', unit: 'unit') + expect(queries[1]).to eq(query_range: 'query_range_empty') + expect(queries[2]).to eq(query_range: 'query_range_a') + end + end + + shared_examples 'required field' do |field_name| + context "when #{field_name} is nil" do + before do + allow(described_class).to receive(:load_yaml_file) { YAML.load(field_missing) } + end + + it 'throws parsing error' do + expect { subject }.to raise_error(parser_error_class, /#{field_name} can't be blank/i) + end + end + + context "when #{field_name} are not specified" do + before do + allow(described_class).to receive(:load_yaml_file) { YAML.load(field_nil) } + end + + it 'throws parsing error' do + expect { subject }.to raise_error(parser_error_class, /#{field_name} can't be blank/i) + end + end + end + + describe 'group required fields' do + it_behaves_like 'required field', 'metrics' do + let(:field_nil) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + metrics: + EOF + end + + let(:field_missing) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + EOF + end + end + + it_behaves_like 'required field', 'name' do + let(:field_nil) do + <<-EOF.strip_heredoc + - group: + priority: 1 + metrics: [] + EOF + end + + let(:field_missing) do + <<-EOF.strip_heredoc + - priority: 1 + metrics: [] + EOF + end + end + + it_behaves_like 'required field', 'priority' do + let(:field_nil) do + <<-EOF.strip_heredoc + - group: group_a + priority: + metrics: [] + EOF + end + + let(:field_missing) do + <<-EOF.strip_heredoc + - group: group_a + metrics: [] + EOF + end + end + end + + describe 'metrics fields parsing' do + it_behaves_like 'required field', 'title' do + let(:field_nil) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + metrics: + - title: + required_metrics: [] + weight: 1 + queries: [] + EOF + end + + let(:field_missing) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + metrics: + - required_metrics: [] + weight: 1 + queries: [] + EOF + end + end + + it_behaves_like 'required field', 'required metrics' do + let(:field_nil) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + metrics: + - title: title + required_metrics: + weight: 1 + queries: [] + EOF + end + + let(:field_missing) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + metrics: + - title: title + weight: 1 + queries: [] + EOF + end + end + + it_behaves_like 'required field', 'weight' do + let(:field_nil) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + metrics: + - title: title + required_metrics: [] + weight: + queries: [] + EOF + end + + let(:field_missing) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + metrics: + - title: title + required_metrics: [] + queries: [] + EOF + end + end + + it_behaves_like 'required field', :queries do + let(:field_nil) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + metrics: + - title: title + required_metrics: [] + weight: 1 + queries: + EOF + end + + let(:field_missing) do + <<-EOF.strip_heredoc + - group: group_a + priority: 1 + metrics: + - title: title + required_metrics: [] + weight: 1 + EOF + end + end + end + end +end diff --git a/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb new file mode 100644 index 00000000000..4909aec5a4d --- /dev/null +++ b/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery, lib: true do + include Prometheus::MetricBuilders + + let(:client) { double('prometheus_client') } + let(:environment) { create(:environment, slug: 'environment-slug') } + let(:deployment) { create(:deployment, environment: environment) } + + subject(:query_result) { described_class.new(client).query(deployment.id) } + + around do |example| + Timecop.freeze(Time.local(2008, 9, 1, 12, 0, 0)) { example.run } + end + + include_examples 'additional metrics query' do + it 'queries using specific time' do + expect(client).to receive(:query_range).with(anything, + start: (deployment.created_at - 30.minutes).to_f, + stop: (deployment.created_at + 30.minutes).to_f) + + expect(query_result).not_to be_nil + end + end +end diff --git a/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb new file mode 100644 index 00000000000..8e6e3bb5946 --- /dev/null +++ b/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery, lib: true do + include Prometheus::MetricBuilders + + let(:client) { double('prometheus_client') } + let(:environment) { create(:environment, slug: 'environment-slug') } + + subject(:query_result) { described_class.new(client).query(environment.id) } + + around do |example| + Timecop.freeze { example.run } + end + + include_examples 'additional metrics query' do + it 'queries using specific time' do + expect(client).to receive(:query_range).with(anything, start: 8.hours.ago.to_f, stop: Time.now.to_f) + expect(query_result).not_to be_nil + end + end +end diff --git a/spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb b/spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb new file mode 100644 index 00000000000..d2796ab72da --- /dev/null +++ b/spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb @@ -0,0 +1,134 @@ +require 'spec_helper' + +describe Gitlab::Prometheus::Queries::MatchedMetricsQuery, lib: true do + include Prometheus::MetricBuilders + + let(:metric_group_class) { Gitlab::Prometheus::MetricGroup } + let(:metric_class) { Gitlab::Prometheus::Metric } + + def series_info_with_environment(*more_metrics) + %w{metric_a metric_b}.concat(more_metrics).map { |metric_name| { '__name__' => metric_name, 'environment' => '' } } + end + + let(:metric_names) { %w{metric_a metric_b} } + let(:series_info_without_environment) do + [{ '__name__' => 'metric_a' }, + { '__name__' => 'metric_b' }] + end + let(:partialy_empty_series_info) { [{ '__name__' => 'metric_a', 'environment' => '' }] } + let(:empty_series_info) { [] } + + let(:client) { double('prometheus_client') } + + subject { described_class.new(client) } + + context 'with one group where two metrics is found' do + before do + allow(metric_group_class).to receive(:all).and_return([simple_metric_group]) + allow(client).to receive(:label_values).and_return(metric_names) + end + + context 'both metrics in the group pass requirements' do + before do + allow(client).to receive(:series).and_return(series_info_with_environment) + end + + it 'responds with both metrics as actve' do + expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 2, metrics_missing_requirements: 0 }]) + end + end + + context 'none of the metrics pass requirements' do + before do + allow(client).to receive(:series).and_return(series_info_without_environment) + end + + it 'responds with both metrics missing requirements' do + expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 0, metrics_missing_requirements: 2 }]) + end + end + + context 'no series information found about the metrics' do + before do + allow(client).to receive(:series).and_return(empty_series_info) + end + + it 'responds with both metrics missing requirements' do + expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 0, metrics_missing_requirements: 2 }]) + end + end + + context 'one of the series info was not found' do + before do + allow(client).to receive(:series).and_return(partialy_empty_series_info) + end + it 'responds with one active and one missing metric' do + expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 1, metrics_missing_requirements: 1 }]) + end + end + end + + context 'with one group where only one metric is found' do + before do + allow(metric_group_class).to receive(:all).and_return([simple_metric_group]) + allow(client).to receive(:label_values).and_return('metric_a') + end + + context 'both metrics in the group pass requirements' do + before do + allow(client).to receive(:series).and_return(series_info_with_environment) + end + + it 'responds with one metrics as active and no missing requiremens' do + expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 1, metrics_missing_requirements: 0 }]) + end + end + + context 'no metrics in group pass requirements' do + before do + allow(client).to receive(:series).and_return(series_info_without_environment) + end + + it 'responds with one metrics as active and no missing requiremens' do + expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 0, metrics_missing_requirements: 1 }]) + end + end + end + + context 'with two groups where metrics are found in each group' do + let(:second_metric_group) { simple_metric_group(name: 'nameb', metrics: simple_metrics(added_metric_name: 'metric_c')) } + + before do + allow(metric_group_class).to receive(:all).and_return([simple_metric_group, second_metric_group]) + allow(client).to receive(:label_values).and_return('metric_c') + end + + context 'all metrics in both groups pass requirements' do + before do + allow(client).to receive(:series).and_return(series_info_with_environment('metric_c')) + end + + it 'responds with one metrics as active and no missing requiremens' do + expect(subject.query).to eq([ + { group: 'name', priority: 1, active_metrics: 1, metrics_missing_requirements: 0 }, + { group: 'nameb', priority: 1, active_metrics: 2, metrics_missing_requirements: 0 } + ] + ) + end + end + + context 'no metrics in groups pass requirements' do + before do + allow(client).to receive(:series).and_return(series_info_without_environment) + end + + it 'responds with one metrics as active and no missing requiremens' do + expect(subject.query).to eq([ + { group: 'name', priority: 1, active_metrics: 0, metrics_missing_requirements: 1 }, + { group: 'nameb', priority: 1, active_metrics: 0, metrics_missing_requirements: 2 } + ] + ) + end + end + end +end diff --git a/spec/lib/gitlab/prometheus_client_spec.rb b/spec/lib/gitlab/prometheus_client_spec.rb index 2d8bd2f6b97..46eaadae206 100644 --- a/spec/lib/gitlab/prometheus_client_spec.rb +++ b/spec/lib/gitlab/prometheus_client_spec.rb @@ -119,6 +119,36 @@ describe Gitlab::PrometheusClient, lib: true do end end + describe '#series' do + let(:query_url) { prometheus_series_url('series_name', 'other_service') } + + around do |example| + Timecop.freeze { example.run } + end + + it 'calls endpoint and returns list of series' do + req_stub = stub_prometheus_request(query_url, body: prometheus_series('series_name')) + expected = prometheus_series('series_name').deep_stringify_keys['data'] + + expect(subject.series('series_name', 'other_service')).to eq(expected) + + expect(req_stub).to have_been_requested + end + end + + describe '#label_values' do + let(:query_url) { prometheus_label_values_url('__name__') } + + it 'calls endpoint and returns label values' do + req_stub = stub_prometheus_request(query_url, body: prometheus_label_values) + expected = prometheus_label_values.deep_stringify_keys['data'] + + expect(subject.label_values('__name__')).to eq(expected) + + expect(req_stub).to have_been_requested + end + end + describe '#query_range' do let(:prometheus_query) { prometheus_memory_query('env-slug') } let(:query_url) { prometheus_query_range_url(prometheus_query) } diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index 0bee892fe0c..979f4fefcb6 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -21,6 +21,18 @@ describe Gitlab::Regex, lib: true do end describe '.environment_slug_regex' do + subject { described_class.environment_name_regex } + + it { is_expected.to match('foo') } + it { is_expected.to match('foo-1') } + it { is_expected.to match('FOO') } + it { is_expected.to match('foo/1') } + it { is_expected.to match('foo.1') } + it { is_expected.not_to match('9&foo') } + it { is_expected.not_to match('foo-^') } + end + + describe '.environment_slug_regex' do subject { described_class.environment_slug_regex } it { is_expected.to match('foo') } diff --git a/spec/lib/gitlab/route_map_spec.rb b/spec/lib/gitlab/route_map_spec.rb index 2370f56a613..21c00c6e5b8 100644 --- a/spec/lib/gitlab/route_map_spec.rb +++ b/spec/lib/gitlab/route_map_spec.rb @@ -4,43 +4,43 @@ describe Gitlab::RouteMap, lib: true do describe '#initialize' do context 'when the data is not YAML' do it 'raises an error' do - expect { described_class.new('"') }. - to raise_error(Gitlab::RouteMap::FormatError, /valid YAML/) + expect { described_class.new('"') } + .to raise_error(Gitlab::RouteMap::FormatError, /valid YAML/) end end context 'when the data is not a YAML array' do it 'raises an error' do - expect { described_class.new(YAML.dump('foo')) }. - to raise_error(Gitlab::RouteMap::FormatError, /an array/) + expect { described_class.new(YAML.dump('foo')) } + .to raise_error(Gitlab::RouteMap::FormatError, /an array/) end end context 'when an entry is not a hash' do it 'raises an error' do - expect { described_class.new(YAML.dump(['foo'])) }. - to raise_error(Gitlab::RouteMap::FormatError, /a hash/) + expect { described_class.new(YAML.dump(['foo'])) } + .to raise_error(Gitlab::RouteMap::FormatError, /a hash/) end end context 'when an entry does not have a source key' do it 'raises an error' do - expect { described_class.new(YAML.dump([{ 'public' => 'index.html' }])) }. - to raise_error(Gitlab::RouteMap::FormatError, /source key/) + expect { described_class.new(YAML.dump([{ 'public' => 'index.html' }])) } + .to raise_error(Gitlab::RouteMap::FormatError, /source key/) end end context 'when an entry does not have a public key' do it 'raises an error' do - expect { described_class.new(YAML.dump([{ 'source' => '/index\.html/' }])) }. - to raise_error(Gitlab::RouteMap::FormatError, /public key/) + expect { described_class.new(YAML.dump([{ 'source' => '/index\.html/' }])) } + .to raise_error(Gitlab::RouteMap::FormatError, /public key/) end end context 'when an entry source is not a valid regex' do it 'raises an error' do - expect { described_class.new(YAML.dump([{ 'source' => '/[/', 'public' => 'index.html' }])) }. - to raise_error(Gitlab::RouteMap::FormatError, /regular expression/) + expect { described_class.new(YAML.dump([{ 'source' => '/[/', 'public' => 'index.html' }])) } + .to raise_error(Gitlab::RouteMap::FormatError, /regular expression/) end end diff --git a/spec/lib/gitlab/sherlock/file_sample_spec.rb b/spec/lib/gitlab/sherlock/file_sample_spec.rb index cadf8bbce78..4989d14def3 100644 --- a/spec/lib/gitlab/sherlock/file_sample_spec.rb +++ b/spec/lib/gitlab/sherlock/file_sample_spec.rb @@ -35,8 +35,8 @@ describe Gitlab::Sherlock::FileSample, lib: true do describe '#relative_path' do it 'returns the relative path' do - expect(sample.relative_path). - to eq('spec/lib/gitlab/sherlock/file_sample_spec.rb') + expect(sample.relative_path) + .to eq('spec/lib/gitlab/sherlock/file_sample_spec.rb') end end diff --git a/spec/lib/gitlab/sherlock/line_profiler_spec.rb b/spec/lib/gitlab/sherlock/line_profiler_spec.rb index d57627bba2b..39c6b2a4844 100644 --- a/spec/lib/gitlab/sherlock/line_profiler_spec.rb +++ b/spec/lib/gitlab/sherlock/line_profiler_spec.rb @@ -20,9 +20,9 @@ describe Gitlab::Sherlock::LineProfiler, lib: true do describe '#profile_mri' do it 'returns an Array containing the return value and profiling samples' do - allow(profiler).to receive(:lineprof). - and_yield. - and_return({ __FILE__ => [[0, 0, 0, 0]] }) + allow(profiler).to receive(:lineprof) + .and_yield + .and_return({ __FILE__ => [[0, 0, 0, 0]] }) retval, samples = profiler.profile_mri { 42 } diff --git a/spec/lib/gitlab/sherlock/middleware_spec.rb b/spec/lib/gitlab/sherlock/middleware_spec.rb index 2bbeb25ce98..b98ab0b14a2 100644 --- a/spec/lib/gitlab/sherlock/middleware_spec.rb +++ b/spec/lib/gitlab/sherlock/middleware_spec.rb @@ -72,8 +72,8 @@ describe Gitlab::Sherlock::Middleware, lib: true do 'REQUEST_URI' => '/cats' } - expect(middleware.transaction_from_env(env)). - to be_an_instance_of(Gitlab::Sherlock::Transaction) + expect(middleware.transaction_from_env(env)) + .to be_an_instance_of(Gitlab::Sherlock::Transaction) end end end diff --git a/spec/lib/gitlab/sherlock/query_spec.rb b/spec/lib/gitlab/sherlock/query_spec.rb index 0a620428138..d97b5eef573 100644 --- a/spec/lib/gitlab/sherlock/query_spec.rb +++ b/spec/lib/gitlab/sherlock/query_spec.rb @@ -13,8 +13,8 @@ describe Gitlab::Sherlock::Query, lib: true do sql = 'SELECT COUNT(*) FROM users WHERE id = $1' bindings = [[double(:column), 10]] - query = described_class. - new_with_bindings(sql, bindings, started_at, finished_at) + query = described_class + .new_with_bindings(sql, bindings, started_at, finished_at) expect(query.query).to eq('SELECT COUNT(*) FROM users WHERE id = 10;') end diff --git a/spec/lib/gitlab/sherlock/transaction_spec.rb b/spec/lib/gitlab/sherlock/transaction_spec.rb index 9fe18f253f0..6ae1aa20ea7 100644 --- a/spec/lib/gitlab/sherlock/transaction_spec.rb +++ b/spec/lib/gitlab/sherlock/transaction_spec.rb @@ -109,8 +109,8 @@ describe Gitlab::Sherlock::Transaction, lib: true do query1 = Gitlab::Sherlock::Query.new('SELECT 1', start_time, start_time) - query2 = Gitlab::Sherlock::Query. - new('SELECT 2', start_time, start_time + 5) + query2 = Gitlab::Sherlock::Query + .new('SELECT 2', start_time, start_time + 5) transaction.queries << query1 transaction.queries << query2 @@ -162,11 +162,11 @@ describe Gitlab::Sherlock::Transaction, lib: true do describe '#profile_lines' do describe 'when line profiling is enabled' do it 'yields the block using the line profiler' do - allow(Gitlab::Sherlock).to receive(:enable_line_profiler?). - and_return(true) + allow(Gitlab::Sherlock).to receive(:enable_line_profiler?) + .and_return(true) - allow_any_instance_of(Gitlab::Sherlock::LineProfiler). - to receive(:profile).and_return('cats are amazing', []) + allow_any_instance_of(Gitlab::Sherlock::LineProfiler) + .to receive(:profile).and_return('cats are amazing', []) retval = transaction.profile_lines { 'cats are amazing' } @@ -176,8 +176,8 @@ describe Gitlab::Sherlock::Transaction, lib: true do describe 'when line profiling is disabled' do it 'yields the block' do - allow(Gitlab::Sherlock).to receive(:enable_line_profiler?). - and_return(false) + allow(Gitlab::Sherlock).to receive(:enable_line_profiler?) + .and_return(false) retval = transaction.profile_lines { 'cats are amazing' } @@ -196,8 +196,8 @@ describe Gitlab::Sherlock::Transaction, lib: true do end it 'tracks executed queries' do - expect(transaction).to receive(:track_query). - with('SELECT 1', [], time, time) + expect(transaction).to receive(:track_query) + .with('SELECT 1', [], time, time) subscription.publish('test', time, time, nil, query_data) end @@ -205,8 +205,8 @@ describe Gitlab::Sherlock::Transaction, lib: true do it 'only tracks queries triggered from the transaction thread' do expect(transaction).not_to receive(:track_query) - Thread.new { subscription.publish('test', time, time, nil, query_data) }. - join + Thread.new { subscription.publish('test', time, time, nil, query_data) } + .join end end @@ -228,8 +228,8 @@ describe Gitlab::Sherlock::Transaction, lib: true do it 'only tracks views rendered from the transaction thread' do expect(transaction).not_to receive(:track_view) - Thread.new { subscription.publish('test', time, time, nil, view_data) }. - join + Thread.new { subscription.publish('test', time, time, nil, view_data) } + .join end end end diff --git a/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb b/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb index 6307f8c16a3..37d9e1d3e6b 100644 --- a/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb +++ b/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb @@ -5,8 +5,8 @@ describe Gitlab::SidekiqStatus::ClientMiddleware do it 'tracks the job in Redis' do expect(Gitlab::SidekiqStatus).to receive(:set).with('123', Gitlab::SidekiqStatus::DEFAULT_EXPIRATION) - described_class.new. - call('Foo', { 'jid' => '123' }, double(:queue), double(:pool)) { nil } + described_class.new + .call('Foo', { 'jid' => '123' }, double(:queue), double(:pool)) { nil } end end end diff --git a/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb b/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb index 80728197b8c..04e09d3dec8 100644 --- a/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb +++ b/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb @@ -5,8 +5,8 @@ describe Gitlab::SidekiqStatus::ServerMiddleware do it 'stops tracking of a job upon completion' do expect(Gitlab::SidekiqStatus).to receive(:unset).with('123') - ret = described_class.new. - call(double(:worker), { 'jid' => '123' }, double(:queue)) { 10 } + ret = described_class.new + .call(double(:worker), { 'jid' => '123' }, double(:queue)) { 10 } expect(ret).to eq(10) end diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index e8a37e8d77b..e9a6e273516 100644 --- a/spec/lib/gitlab/url_builder_spec.rb +++ b/spec/lib/gitlab/url_builder_spec.rb @@ -112,8 +112,8 @@ describe Gitlab::UrlBuilder, lib: true do it 'returns a proper URL' do project = build_stubbed(:empty_project) - expect { described_class.build(project) }. - to raise_error(NotImplementedError, 'No URL builder defined for Project') + expect { described_class.build(project) } + .to raise_error(NotImplementedError, 'No URL builder defined for Project') end end end diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index b47e1b56fa9..3c7c7562b46 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -37,6 +37,7 @@ describe Gitlab::UsageData do deploy_keys deployments environments + in_review_folder groups issues keys diff --git a/spec/lib/gitlab/view/presenter/delegated_spec.rb b/spec/lib/gitlab/view/presenter/delegated_spec.rb index e9d4af54389..940a2ce6ebd 100644 --- a/spec/lib/gitlab/view/presenter/delegated_spec.rb +++ b/spec/lib/gitlab/view/presenter/delegated_spec.rb @@ -18,8 +18,8 @@ describe Gitlab::View::Presenter::Delegated do end it 'raise an error if the presentee already respond to method' do - expect { presenter_class.new(project, user: 'Jane Doe') }. - to raise_error Gitlab::View::Presenter::CannotOverrideMethodError + expect { presenter_class.new(project, user: 'Jane Doe') } + .to raise_error Gitlab::View::Presenter::CannotOverrideMethodError end end diff --git a/spec/lib/gitlab/visibility_level_spec.rb b/spec/lib/gitlab/visibility_level_spec.rb index 3255c6f1ef7..db9d2807be6 100644 --- a/spec/lib/gitlab/visibility_level_spec.rb +++ b/spec/lib/gitlab/visibility_level_spec.rb @@ -18,4 +18,35 @@ describe Gitlab::VisibilityLevel, lib: true do expect(described_class.level_value(100)).to eq(Gitlab::VisibilityLevel::PRIVATE) end end + + describe '.levels_for_user' do + it 'returns all levels for an admin' do + user = build(:user, :admin) + + expect(described_class.levels_for_user(user)) + .to eq([Gitlab::VisibilityLevel::PRIVATE, + Gitlab::VisibilityLevel::INTERNAL, + Gitlab::VisibilityLevel::PUBLIC]) + end + + it 'returns INTERNAL and PUBLIC for internal users' do + user = build(:user) + + expect(described_class.levels_for_user(user)) + .to eq([Gitlab::VisibilityLevel::INTERNAL, + Gitlab::VisibilityLevel::PUBLIC]) + end + + it 'returns PUBLIC for external users' do + user = build(:user, :external) + + expect(described_class.levels_for_user(user)) + .to eq([Gitlab::VisibilityLevel::PUBLIC]) + end + + it 'returns PUBLIC when no user is given' do + expect(described_class.levels_for_user) + .to eq([Gitlab::VisibilityLevel::PUBLIC]) + end + end end diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb index ad19998dff4..493ff3bb5fb 100644 --- a/spec/lib/gitlab/workhorse_spec.rb +++ b/spec/lib/gitlab/workhorse_spec.rb @@ -202,7 +202,11 @@ describe Gitlab::Workhorse, lib: true do context 'when Gitaly is enabled' do let(:gitaly_params) do { - GitalyAddress: Gitlab::GitalyClient.address('default') + GitalyAddress: Gitlab::GitalyClient.address('default'), + GitalyServer: { + address: Gitlab::GitalyClient.address('default'), + token: Gitlab::GitalyClient.token('default') + } } end @@ -212,7 +216,6 @@ describe Gitlab::Workhorse, lib: true do it 'includes a Repository param' do repo_param = { Repository: { - path: '', # deprecated field; grpc automatically creates it anyway storage_name: 'default', relative_path: project.full_path + '.git' } } diff --git a/spec/lib/mattermost/command_spec.rb b/spec/lib/mattermost/command_spec.rb index 4b5938edeb9..369e7b181b9 100644 --- a/spec/lib/mattermost/command_spec.rb +++ b/spec/lib/mattermost/command_spec.rb @@ -6,8 +6,8 @@ describe Mattermost::Command do before do Mattermost::Session.base_uri('http://mattermost.example.com') - allow_any_instance_of(Mattermost::Client).to receive(:with_session). - and_yield(Mattermost::Session.new(nil)) + allow_any_instance_of(Mattermost::Client).to receive(:with_session) + .and_yield(Mattermost::Session.new(nil)) end describe '#create' do @@ -20,12 +20,12 @@ describe Mattermost::Command do context 'for valid trigger word' do before do - stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create'). - with(body: { + stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create') + .with(body: { team_id: 'abc', trigger: 'gitlab' - }.to_json). - to_return( + }.to_json) + .to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: { token: 'token' }.to_json @@ -39,8 +39,8 @@ describe Mattermost::Command do context 'for error message' do before do - stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create'). - to_return( + stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create') + .to_return( status: 500, headers: { 'Content-Type' => 'application/json' }, body: { diff --git a/spec/lib/mattermost/session_spec.rb b/spec/lib/mattermost/session_spec.rb index 74d12e37181..be3908e8f6a 100644 --- a/spec/lib/mattermost/session_spec.rb +++ b/spec/lib/mattermost/session_spec.rb @@ -21,8 +21,8 @@ describe Mattermost::Session, type: :request do describe '#with session' do let(:location) { 'http://location.tld' } let!(:stub) do - WebMock.stub_request(:get, "#{mattermost_url}/api/v3/oauth/gitlab/login"). - to_return(headers: { 'location' => location }, status: 307) + WebMock.stub_request(:get, "#{mattermost_url}/api/v3/oauth/gitlab/login") + .to_return(headers: { 'location' => location }, status: 307) end context 'without oauth uri' do @@ -60,9 +60,9 @@ describe Mattermost::Session, type: :request do end before do - WebMock.stub_request(:get, "#{mattermost_url}/signup/gitlab/complete"). - with(query: hash_including({ 'state' => state })). - to_return do |request| + WebMock.stub_request(:get, "#{mattermost_url}/signup/gitlab/complete") + .with(query: hash_including({ 'state' => state })) + .to_return do |request| post "/oauth/token", client_id: doorkeeper.uid, client_secret: doorkeeper.secret, @@ -75,8 +75,8 @@ describe Mattermost::Session, type: :request do end end - WebMock.stub_request(:post, "#{mattermost_url}/api/v3/users/logout"). - to_return(headers: { Authorization: 'token thisworksnow' }, status: 200) + WebMock.stub_request(:post, "#{mattermost_url}/api/v3/users/logout") + .to_return(headers: { Authorization: 'token thisworksnow' }, status: 200) end it 'can setup a session' do diff --git a/spec/lib/mattermost/team_spec.rb b/spec/lib/mattermost/team_spec.rb index ac493fdb20f..e638ad7a2c9 100644 --- a/spec/lib/mattermost/team_spec.rb +++ b/spec/lib/mattermost/team_spec.rb @@ -4,8 +4,8 @@ describe Mattermost::Team do before do Mattermost::Session.base_uri('http://mattermost.example.com') - allow_any_instance_of(Mattermost::Client).to receive(:with_session). - and_yield(Mattermost::Session.new(nil)) + allow_any_instance_of(Mattermost::Client).to receive(:with_session) + .and_yield(Mattermost::Session.new(nil)) end describe '#all' do @@ -30,8 +30,8 @@ describe Mattermost::Team do end before do - stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all'). - to_return( + stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all') + .to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: response.to_json @@ -45,8 +45,8 @@ describe Mattermost::Team do context 'for error message' do before do - stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all'). - to_return( + stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all') + .to_return( status: 500, headers: { 'Content-Type' => 'application/json' }, body: { diff --git a/spec/lib/system_check/simple_executor_spec.rb b/spec/lib/system_check/simple_executor_spec.rb index a5c6170cd7d..795f11ee1f8 100644 --- a/spec/lib/system_check/simple_executor_spec.rb +++ b/spec/lib/system_check/simple_executor_spec.rb @@ -75,6 +75,24 @@ describe SystemCheck::SimpleExecutor, lib: true do end end + class BugousCheck < SystemCheck::BaseCheck + CustomError = Class.new(StandardError) + set_name 'my bugous check' + + def check? + raise CustomError, 'omg' + end + end + + before do + @rainbow = Rainbow.enabled + Rainbow.enabled = false + end + + after do + Rainbow.enabled = @rainbow + end + describe '#component' do it 'returns stored component name' do expect(subject.component).to eq('Test') @@ -219,5 +237,11 @@ describe SystemCheck::SimpleExecutor, lib: true do end end end + + context 'when there is an exception' do + it 'rescues the exception' do + expect{ subject.run_check(BugousCheck) }.not_to raise_exception + end + end end end diff --git a/spec/mailers/abuse_report_mailer_spec.rb b/spec/mailers/abuse_report_mailer_spec.rb index eb433c38873..bda892083b3 100644 --- a/spec/mailers/abuse_report_mailer_spec.rb +++ b/spec/mailers/abuse_report_mailer_spec.rb @@ -30,8 +30,8 @@ describe AbuseReportMailer do it 'returns early' do stub_application_setting(admin_notification_email: nil) - expect { described_class.notify(spy).deliver_now }. - not_to change { ActionMailer::Base.deliveries.count } + expect { described_class.notify(spy).deliver_now } + .not_to change { ActionMailer::Base.deliveries.count } end end end diff --git a/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb b/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb index bd5f85b901d..65bea662b02 100644 --- a/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb +++ b/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20170508170547_add_head_pipeline_for_each_merge_request.rb') -describe AddHeadPipelineForEachMergeRequest do +describe AddHeadPipelineForEachMergeRequest, :truncate do let(:migration) { described_class.new } let!(:project) { create(:empty_project) } diff --git a/spec/migrations/migrate_build_stage_reference_spec.rb b/spec/migrations/migrate_build_stage_reference_again_spec.rb index 80b321860c2..6be480ce58e 100644 --- a/spec/migrations/migrate_build_stage_reference_spec.rb +++ b/spec/migrations/migrate_build_stage_reference_again_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170526185921_migrate_build_stage_reference.rb') +require Rails.root.join('db', 'post_migrate', '20170526190000_migrate_build_stage_reference_again.rb') -describe MigrateBuildStageReference, :migration do +describe MigrateBuildStageReferenceAgain, :migration do ## # Create test data - pipeline and CI/CD jobs. # diff --git a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb index 3db57595fa6..4223d2337a8 100644 --- a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb +++ b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb @@ -11,33 +11,33 @@ describe MigrateProcessCommitWorkerJobs do describe 'Project' do describe 'find_including_path' do it 'returns Project instances' do - expect(described_class::Project.find_including_path(project.id)). - to be_an_instance_of(described_class::Project) + expect(described_class::Project.find_including_path(project.id)) + .to be_an_instance_of(described_class::Project) end it 'selects the full path for every Project' do - migration_project = described_class::Project. - find_including_path(project.id) + migration_project = described_class::Project + .find_including_path(project.id) - expect(migration_project[:path_with_namespace]). - to eq(project.path_with_namespace) + expect(migration_project[:path_with_namespace]) + .to eq(project.path_with_namespace) end end describe '#repository_storage_path' do it 'returns the storage path for the repository' do - migration_project = described_class::Project. - find_including_path(project.id) + migration_project = described_class::Project + .find_including_path(project.id) - expect(File.directory?(migration_project.repository_storage_path)). - to eq(true) + expect(File.directory?(migration_project.repository_storage_path)) + .to eq(true) end end describe '#repository_path' do it 'returns the path to the repository' do - migration_project = described_class::Project. - find_including_path(project.id) + migration_project = described_class::Project + .find_including_path(project.id) expect(File.directory?(migration_project.repository_path)).to eq(true) end @@ -45,11 +45,11 @@ describe MigrateProcessCommitWorkerJobs do describe '#repository' do it 'returns a Rugged::Repository' do - migration_project = described_class::Project. - find_including_path(project.id) + migration_project = described_class::Project + .find_including_path(project.id) - expect(migration_project.repository). - to be_an_instance_of(Rugged::Repository) + expect(migration_project.repository) + .to be_an_instance_of(Rugged::Repository) end end end @@ -73,9 +73,9 @@ describe MigrateProcessCommitWorkerJobs do end it 'skips jobs using a project that no longer exists' do - allow(described_class::Project).to receive(:find_including_path). - with(project.id). - and_return(nil) + allow(described_class::Project).to receive(:find_including_path) + .with(project.id) + .and_return(nil) migration.up @@ -83,9 +83,9 @@ describe MigrateProcessCommitWorkerJobs do end it 'skips jobs using commits that no longer exist' do - allow_any_instance_of(Rugged::Repository).to receive(:lookup). - with(commit.oid). - and_raise(Rugged::OdbError) + allow_any_instance_of(Rugged::Repository).to receive(:lookup) + .with(commit.oid) + .and_raise(Rugged::OdbError) migration.up @@ -99,12 +99,12 @@ describe MigrateProcessCommitWorkerJobs do end it 'encodes data to UTF-8' do - allow_any_instance_of(Rugged::Repository).to receive(:lookup). - with(commit.oid). - and_return(commit) + allow_any_instance_of(Rugged::Repository).to receive(:lookup) + .with(commit.oid) + .and_return(commit) - allow(commit).to receive(:message). - and_return('김치'.force_encoding('BINARY')) + allow(commit).to receive(:message) + .and_return('김치'.force_encoding('BINARY')) migration.up diff --git a/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb b/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb index 1db9bc002ae..e3b42b5eac8 100644 --- a/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb +++ b/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20170324160416_migrate_user_activities_to_users_last_activity_on.rb') -describe MigrateUserActivitiesToUsersLastActivityOn, :redis do +describe MigrateUserActivitiesToUsersLastActivityOn, :redis, :truncate do let(:migration) { described_class.new } let!(:user_active_1) { create(:user) } let!(:user_active_2) { create(:user) } diff --git a/spec/migrations/migrate_user_project_view_spec.rb b/spec/migrations/migrate_user_project_view_spec.rb index 70f8e0d6082..afaa5d836a7 100644 --- a/spec/migrations/migrate_user_project_view_spec.rb +++ b/spec/migrations/migrate_user_project_view_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20170406142253_migrate_user_project_view.rb') -describe MigrateUserProjectView do +describe MigrateUserProjectView, :truncate do let(:migration) { described_class.new } let!(:user) { create(:user) } diff --git a/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb b/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb index 175bf1876b2..42109fd0743 100644 --- a/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb +++ b/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb @@ -31,8 +31,8 @@ describe TurnNestedGroupsIntoRegularGroupsForMysql do end it 'adds members of parent groups as members to the migrated group' do - is_member = child_group.members. - where(user_id: member, access_level: Gitlab::Access::DEVELOPER).any? + is_member = child_group.members + .where(user_id: member, access_level: Gitlab::Access::DEVELOPER).any? expect(is_member).to eq(true) end @@ -44,21 +44,21 @@ describe TurnNestedGroupsIntoRegularGroupsForMysql do end it 'renames projects of the nested group' do - expect(updated_project.path_with_namespace). - to eq("#{parent_group.name}-#{child_group.name}/#{updated_project.path}") + expect(updated_project.path_with_namespace) + .to eq("#{parent_group.name}-#{child_group.name}/#{updated_project.path}") end it 'renames the repository of any projects' do - expect(updated_project.repository.path). - to end_with("#{parent_group.name}-#{child_group.name}/#{updated_project.path}.git") + expect(updated_project.repository.path) + .to end_with("#{parent_group.name}-#{child_group.name}/#{updated_project.path}.git") expect(File.directory?(updated_project.repository.path)).to eq(true) end it 'creates a redirect route for renamed projects' do - exists = RedirectRoute. - where(source_type: 'Project', source_id: project.id). - any? + exists = RedirectRoute + .where(source_type: 'Project', source_id: project.id) + .any? expect(exists).to eq(true) end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 92d70cfc64c..090f9e70c50 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -69,8 +69,8 @@ describe Ability, lib: true do project = create(:empty_project, :public) user = build(:user) - expect(described_class.users_that_can_read_project([user], project)). - to eq([user]) + expect(described_class.users_that_can_read_project([user], project)) + .to eq([user]) end end @@ -80,8 +80,8 @@ describe Ability, lib: true do it 'returns users that are administrators' do user = build(:user, admin: true) - expect(described_class.users_that_can_read_project([user], project)). - to eq([user]) + expect(described_class.users_that_can_read_project([user], project)) + .to eq([user]) end it 'returns internal users while skipping external users' do @@ -89,8 +89,8 @@ describe Ability, lib: true do user2 = build(:user, external: true) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)). - to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)) + .to eq([user1]) end it 'returns external users if they are the project owner' do @@ -100,8 +100,8 @@ describe Ability, lib: true do expect(project).to receive(:owner).twice.and_return(user1) - expect(described_class.users_that_can_read_project(users, project)). - to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)) + .to eq([user1]) end it 'returns external users if they are project members' do @@ -111,8 +111,8 @@ describe Ability, lib: true do expect(project.team).to receive(:members).twice.and_return([user1]) - expect(described_class.users_that_can_read_project(users, project)). - to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)) + .to eq([user1]) end it 'returns an empty Array if all users are external users without access' do @@ -120,8 +120,8 @@ describe Ability, lib: true do user2 = build(:user, external: true) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)). - to eq([]) + expect(described_class.users_that_can_read_project(users, project)) + .to eq([]) end end @@ -131,8 +131,8 @@ describe Ability, lib: true do it 'returns users that are administrators' do user = build(:user, admin: true) - expect(described_class.users_that_can_read_project([user], project)). - to eq([user]) + expect(described_class.users_that_can_read_project([user], project)) + .to eq([user]) end it 'returns external users if they are the project owner' do @@ -142,8 +142,8 @@ describe Ability, lib: true do expect(project).to receive(:owner).twice.and_return(user1) - expect(described_class.users_that_can_read_project(users, project)). - to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)) + .to eq([user1]) end it 'returns external users if they are project members' do @@ -153,8 +153,8 @@ describe Ability, lib: true do expect(project.team).to receive(:members).twice.and_return([user1]) - expect(described_class.users_that_can_read_project(users, project)). - to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)) + .to eq([user1]) end it 'returns an empty Array if all users are internal users without access' do @@ -162,8 +162,8 @@ describe Ability, lib: true do user2 = build(:user) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)). - to eq([]) + expect(described_class.users_that_can_read_project(users, project)) + .to eq([]) end it 'returns an empty Array if all users are external users without access' do @@ -171,8 +171,8 @@ describe Ability, lib: true do user2 = build(:user, external: true) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)). - to eq([]) + expect(described_class.users_that_can_read_project(users, project)) + .to eq([]) end end end @@ -210,8 +210,8 @@ describe Ability, lib: true do user = build(:user, admin: true) issue = build(:issue) - expect(described_class.issues_readable_by_user([issue], user)). - to eq([issue]) + expect(described_class.issues_readable_by_user([issue], user)) + .to eq([issue]) end end @@ -222,8 +222,8 @@ describe Ability, lib: true do expect(issue).to receive(:readable_by?).with(user).and_return(true) - expect(described_class.issues_readable_by_user([issue], user)). - to eq([issue]) + expect(described_class.issues_readable_by_user([issue], user)) + .to eq([issue]) end it 'returns an empty Array when no issues are readable' do @@ -244,8 +244,8 @@ describe Ability, lib: true do expect(hidden_issue).to receive(:publicly_visible?).and_return(false) expect(visible_issue).to receive(:publicly_visible?).and_return(true) - issues = described_class. - issues_readable_by_user([hidden_issue, visible_issue]) + issues = described_class + .issues_readable_by_user([hidden_issue, visible_issue]) expect(issues).to eq([visible_issue]) end diff --git a/spec/models/abuse_report_spec.rb b/spec/models/abuse_report_spec.rb index 90aec2b45e6..c1bf5551fe0 100644 --- a/spec/models/abuse_report_spec.rb +++ b/spec/models/abuse_report_spec.rb @@ -36,8 +36,8 @@ RSpec.describe AbuseReport, type: :model do describe '#notify' do it 'delivers' do - expect(AbuseReportMailer).to receive(:notify).with(subject.id). - and_return(spy) + expect(AbuseReportMailer).to receive(:notify).with(subject.id) + .and_return(spy) subject.notify end diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 3816422fec6..488697f74eb 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -451,42 +451,6 @@ describe Ci::Build, :models do end end - describe '#environment_url' do - subject { job.environment_url } - - context 'when yaml environment uses $CI_COMMIT_REF_NAME' do - let(:job) do - create(:ci_build, - ref: 'master', - options: { environment: { url: 'http://review/$CI_COMMIT_REF_NAME' } }) - end - - it { is_expected.to eq('http://review/master') } - end - - context 'when yaml environment uses yaml_variables containing symbol keys' do - let(:job) do - create(:ci_build, - yaml_variables: [{ key: :APP_HOST, value: 'host' }], - options: { environment: { url: 'http://review/$APP_HOST' } }) - end - - it { is_expected.to eq('http://review/host') } - end - - context 'when yaml environment does not have url' do - let(:job) { create(:ci_build, environment: 'staging') } - - let!(:environment) do - create(:environment, project: job.project, name: job.environment) - end - - it 'returns the external_url from persisted environment' do - is_expected.to eq(environment.external_url) - end - end - end - describe '#starts_environment?' do subject { build.starts_environment? } @@ -899,8 +863,8 @@ describe Ci::Build, :models do pipeline2 = create(:ci_pipeline, project: project) @build2 = create(:ci_build, pipeline: pipeline2) - allow(@merge_request).to receive(:commits_sha). - and_return([pipeline.sha, pipeline2.sha]) + allow(@merge_request).to receive(:commits_sha) + .and_return([pipeline.sha, pipeline2.sha]) allow(MergeRequest).to receive_message_chain(:includes, :where, :reorder).and_return([@merge_request]) end @@ -1292,10 +1256,20 @@ describe Ci::Build, :models do context 'when the URL was set from the job' do before do - build.update(options: { environment: { url: 'http://host/$CI_JOB_NAME' } }) + build.update(options: { environment: { url: url } }) end it_behaves_like 'containing environment variables' + + context 'when variables are used in the URL, it does not expand' do + let(:url) { 'http://$CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG' } + + it_behaves_like 'containing environment variables' + + it 'puts $CI_ENVIRONMENT_URL in the last so all other variables are available to be used when runners are trying to expand it' do + expect(subject.last).to eq(environment_variables.last) + end + end end context 'when the URL was not set from the job, but environment' do diff --git a/spec/models/ci/pipeline_schedule_spec.rb b/spec/models/ci/pipeline_schedule_spec.rb index b00e7a73571..56817baf79d 100644 --- a/spec/models/ci/pipeline_schedule_spec.rb +++ b/spec/models/ci/pipeline_schedule_spec.rb @@ -40,8 +40,8 @@ describe Ci::PipelineSchedule, models: true do context 'when creates new pipeline schedule' do let(:expected_next_run_at) do - Gitlab::Ci::CronParser.new(pipeline_schedule.cron, pipeline_schedule.cron_timezone). - next_time_from(Time.now) + Gitlab::Ci::CronParser.new(pipeline_schedule.cron, pipeline_schedule.cron_timezone) + .next_time_from(Time.now) end it 'updates next_run_at automatically' do @@ -53,8 +53,8 @@ describe Ci::PipelineSchedule, models: true do let(:new_cron) { '0 0 1 1 *' } let(:expected_next_run_at) do - Gitlab::Ci::CronParser.new(new_cron, pipeline_schedule.cron_timezone). - next_time_from(Time.now) + Gitlab::Ci::CronParser.new(new_cron, pipeline_schedule.cron_timezone) + .next_time_from(Time.now) end it 'updates next_run_at automatically' do @@ -72,8 +72,8 @@ describe Ci::PipelineSchedule, models: true do let(:future_time) { 10.days.from_now } let(:expected_next_run_at) do - Gitlab::Ci::CronParser.new(pipeline_schedule.cron, pipeline_schedule.cron_timezone). - next_time_from(future_time) + Gitlab::Ci::CronParser.new(pipeline_schedule.cron, pipeline_schedule.cron_timezone) + .next_time_from(future_time) end it 'points to proper next_run_at' do diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index e86cbe8498a..dab8e8ca432 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -608,8 +608,8 @@ describe Ci::Pipeline, models: true do it 'returns the latest pipeline for the same ref and different sha' do expect(pipelines.map(&:sha)).to contain_exactly('A', 'B', 'C') - expect(pipelines.map(&:status)). - to contain_exactly('success', 'failed', 'skipped') + expect(pipelines.map(&:status)) + .to contain_exactly('success', 'failed', 'skipped') end end @@ -618,8 +618,8 @@ describe Ci::Pipeline, models: true do it 'returns the latest pipeline for ref and different sha' do expect(pipelines.map(&:sha)).to contain_exactly('A', 'B') - expect(pipelines.map(&:status)). - to contain_exactly('success', 'failed') + expect(pipelines.map(&:status)) + .to contain_exactly('success', 'failed') end end end @@ -654,8 +654,8 @@ describe Ci::Pipeline, models: true do end it 'returns the latest successful pipeline' do - expect(described_class.latest_successful_for('ref')). - to eq(latest_successful_pipeline) + expect(described_class.latest_successful_for('ref')) + .to eq(latest_successful_pipeline) end end @@ -1201,8 +1201,8 @@ describe Ci::Pipeline, models: true do before do project.team << [pipeline.user, Gitlab::Access::DEVELOPER] - pipeline.user.global_notification_setting. - update(level: 'custom', failed_pipeline: true, success_pipeline: true) + pipeline.user.global_notification_setting + .update(level: 'custom', failed_pipeline: true, success_pipeline: true) reset_delivered_emails! diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb index 077b10227d7..83494af24ba 100644 --- a/spec/models/ci/variable_spec.rb +++ b/spec/models/ci/variable_spec.rb @@ -54,8 +54,8 @@ describe Ci::Variable, models: true do it 'fails to decrypt if iv is incorrect' do subject.encrypted_value_iv = SecureRandom.hex subject.instance_variable_set(:@value, nil) - expect { subject.value }. - to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt') + expect { subject.value } + .to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt') end end diff --git a/spec/models/commit_range_spec.rb b/spec/models/commit_range_spec.rb index e4bddf67096..ba9c3f66d21 100644 --- a/spec/models/commit_range_spec.rb +++ b/spec/models/commit_range_spec.rb @@ -147,9 +147,9 @@ describe CommitRange, models: true do note: commit1.revert_description(user), project: issue.project) - expect_any_instance_of(Commit).to receive(:reverts_commit?). - with(commit1, user). - and_return(true) + expect_any_instance_of(Commit).to receive(:reverts_commit?) + .with(commit1, user) + .and_return(true) expect(commit1.has_been_reverted?(user, issue)).to eq(true) end diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index 9262ce08987..1e074c7ad26 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -284,6 +284,41 @@ describe CommitStatus, :models do end end + describe '.status' do + context 'when there are multiple statuses present' do + before do + create_status(status: 'running') + create_status(status: 'success') + create_status(allow_failure: true, status: 'failed') + end + + it 'returns a correct compound status' do + expect(described_class.all.status).to eq 'running' + end + end + + context 'when there are only allowed to fail commit statuses present' do + before do + create_status(allow_failure: true, status: 'failed') + end + + it 'returns status that indicates success' do + expect(described_class.all.status).to eq 'success' + end + end + + context 'when using a scope to select latest statuses' do + before do + create_status(name: 'test', retried: true, status: 'failed') + create_status(allow_failure: true, name: 'test', status: 'failed') + end + + it 'returns status according to the scope' do + expect(described_class.latest.status).to eq 'success' + end + end + end + describe '#before_sha' do subject { commit_status.before_sha } diff --git a/spec/models/concerns/case_sensitivity_spec.rb b/spec/models/concerns/case_sensitivity_spec.rb index 92fdc5cd65d..a6fccb668e3 100644 --- a/spec/models/concerns/case_sensitivity_spec.rb +++ b/spec/models/concerns/case_sensitivity_spec.rb @@ -15,13 +15,13 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name). - with(:foo). - and_return('"foo"') + expect(connection).to receive(:quote_table_name) + .with(:foo) + .and_return('"foo"') - expect(model).to receive(:where). - with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar'). - and_return(criteria) + expect(model).to receive(:where) + .with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar') + .and_return(criteria) expect(model.iwhere(foo: 'bar')).to eq(criteria) end @@ -29,13 +29,13 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column with a table, and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name). - with(:'foo.bar'). - and_return('"foo"."bar"') + expect(connection).to receive(:quote_table_name) + .with(:'foo.bar') + .and_return('"foo"."bar"') - expect(model).to receive(:where). - with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar'). - and_return(criteria) + expect(model).to receive(:where) + .with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar') + .and_return(criteria) expect(model.iwhere('foo.bar'.to_sym => 'bar')).to eq(criteria) end @@ -46,21 +46,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name). - with(:foo). - and_return('"foo"') + expect(connection).to receive(:quote_table_name) + .with(:foo) + .and_return('"foo"') - expect(connection).to receive(:quote_table_name). - with(:bar). - and_return('"bar"') + expect(connection).to receive(:quote_table_name) + .with(:bar) + .and_return('"bar"') - expect(model).to receive(:where). - with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar'). - and_return(initial) + expect(model).to receive(:where) + .with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar') + .and_return(initial) - expect(initial).to receive(:where). - with(%q{LOWER("bar") = LOWER(:value)}, value: 'baz'). - and_return(final) + expect(initial).to receive(:where) + .with(%q{LOWER("bar") = LOWER(:value)}, value: 'baz') + .and_return(final) got = model.iwhere(foo: 'bar', bar: 'baz') @@ -71,21 +71,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name). - with(:'foo.bar'). - and_return('"foo"."bar"') + expect(connection).to receive(:quote_table_name) + .with(:'foo.bar') + .and_return('"foo"."bar"') - expect(connection).to receive(:quote_table_name). - with(:'foo.baz'). - and_return('"foo"."baz"') + expect(connection).to receive(:quote_table_name) + .with(:'foo.baz') + .and_return('"foo"."baz"') - expect(model).to receive(:where). - with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar'). - and_return(initial) + expect(model).to receive(:where) + .with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar') + .and_return(initial) - expect(initial).to receive(:where). - with(%q{LOWER("foo"."baz") = LOWER(:value)}, value: 'baz'). - and_return(final) + expect(initial).to receive(:where) + .with(%q{LOWER("foo"."baz") = LOWER(:value)}, value: 'baz') + .and_return(final) got = model.iwhere('foo.bar'.to_sym => 'bar', 'foo.baz'.to_sym => 'baz') @@ -105,13 +105,13 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name). - with(:foo). - and_return('`foo`') + expect(connection).to receive(:quote_table_name) + .with(:foo) + .and_return('`foo`') - expect(model).to receive(:where). - with(%q{`foo` = :value}, value: 'bar'). - and_return(criteria) + expect(model).to receive(:where) + .with(%q{`foo` = :value}, value: 'bar') + .and_return(criteria) expect(model.iwhere(foo: 'bar')).to eq(criteria) end @@ -119,16 +119,16 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column with a table, and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name). - with(:'foo.bar'). - and_return('`foo`.`bar`') + expect(connection).to receive(:quote_table_name) + .with(:'foo.bar') + .and_return('`foo`.`bar`') - expect(model).to receive(:where). - with(%q{`foo`.`bar` = :value}, value: 'bar'). - and_return(criteria) + expect(model).to receive(:where) + .with(%q{`foo`.`bar` = :value}, value: 'bar') + .and_return(criteria) - expect(model.iwhere('foo.bar'.to_sym => 'bar')). - to eq(criteria) + expect(model.iwhere('foo.bar'.to_sym => 'bar')) + .to eq(criteria) end end @@ -137,21 +137,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name). - with(:foo). - and_return('`foo`') + expect(connection).to receive(:quote_table_name) + .with(:foo) + .and_return('`foo`') - expect(connection).to receive(:quote_table_name). - with(:bar). - and_return('`bar`') + expect(connection).to receive(:quote_table_name) + .with(:bar) + .and_return('`bar`') - expect(model).to receive(:where). - with(%q{`foo` = :value}, value: 'bar'). - and_return(initial) + expect(model).to receive(:where) + .with(%q{`foo` = :value}, value: 'bar') + .and_return(initial) - expect(initial).to receive(:where). - with(%q{`bar` = :value}, value: 'baz'). - and_return(final) + expect(initial).to receive(:where) + .with(%q{`bar` = :value}, value: 'baz') + .and_return(final) got = model.iwhere(foo: 'bar', bar: 'baz') @@ -162,21 +162,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name). - with(:'foo.bar'). - and_return('`foo`.`bar`') + expect(connection).to receive(:quote_table_name) + .with(:'foo.bar') + .and_return('`foo`.`bar`') - expect(connection).to receive(:quote_table_name). - with(:'foo.baz'). - and_return('`foo`.`baz`') + expect(connection).to receive(:quote_table_name) + .with(:'foo.baz') + .and_return('`foo`.`baz`') - expect(model).to receive(:where). - with(%q{`foo`.`bar` = :value}, value: 'bar'). - and_return(initial) + expect(model).to receive(:where) + .with(%q{`foo`.`bar` = :value}, value: 'bar') + .and_return(initial) - expect(initial).to receive(:where). - with(%q{`foo`.`baz` = :value}, value: 'baz'). - and_return(final) + expect(initial).to receive(:where) + .with(%q{`foo`.`baz` = :value}, value: 'baz') + .and_return(final) got = model.iwhere('foo.bar'.to_sym => 'bar', 'foo.baz'.to_sym => 'baz') diff --git a/spec/models/concerns/has_status_spec.rb b/spec/models/concerns/has_status_spec.rb index 67dae7cf4c0..a38f2553eb1 100644 --- a/spec/models/concerns/has_status_spec.rb +++ b/spec/models/concerns/has_status_spec.rb @@ -48,7 +48,7 @@ describe HasStatus do [create(type, status: :failed, allow_failure: true)] end - it { is_expected.to eq 'skipped' } + it { is_expected.to eq 'success' } end context 'success and canceled' do @@ -168,8 +168,8 @@ describe HasStatus do describe ".#{status}" do it 'contains the job' do - expect(CommitStatus.public_send(status).all). - to contain_exactly(job) + expect(CommitStatus.public_send(status).all) + .to contain_exactly(job) end end diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index 1a9bda64191..ac9303370ab 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -69,8 +69,8 @@ describe Issuable do let!(:searchable_issue) { create(:issue, title: "Searchable issue") } it 'returns notes with a matching title' do - expect(issuable_class.search(searchable_issue.title)). - to eq([searchable_issue]) + expect(issuable_class.search(searchable_issue.title)) + .to eq([searchable_issue]) end it 'returns notes with a partially matching title' do @@ -78,8 +78,8 @@ describe Issuable do end it 'returns notes with a matching title regardless of the casing' do - expect(issuable_class.search(searchable_issue.title.upcase)). - to eq([searchable_issue]) + expect(issuable_class.search(searchable_issue.title.upcase)) + .to eq([searchable_issue]) end end @@ -89,8 +89,8 @@ describe Issuable do end it 'returns notes with a matching title' do - expect(issuable_class.full_search(searchable_issue.title)). - to eq([searchable_issue]) + expect(issuable_class.full_search(searchable_issue.title)) + .to eq([searchable_issue]) end it 'returns notes with a partially matching title' do @@ -98,23 +98,23 @@ describe Issuable do end it 'returns notes with a matching title regardless of the casing' do - expect(issuable_class.full_search(searchable_issue.title.upcase)). - to eq([searchable_issue]) + expect(issuable_class.full_search(searchable_issue.title.upcase)) + .to eq([searchable_issue]) end it 'returns notes with a matching description' do - expect(issuable_class.full_search(searchable_issue.description)). - to eq([searchable_issue]) + expect(issuable_class.full_search(searchable_issue.description)) + .to eq([searchable_issue]) end it 'returns notes with a partially matching description' do - expect(issuable_class.full_search(searchable_issue.description)). - to eq([searchable_issue]) + expect(issuable_class.full_search(searchable_issue.description)) + .to eq([searchable_issue]) end it 'returns notes with a matching description regardless of the casing' do - expect(issuable_class.full_search(searchable_issue.description.upcase)). - to eq([searchable_issue]) + expect(issuable_class.full_search(searchable_issue.description.upcase)) + .to eq([searchable_issue]) end end diff --git a/spec/models/concerns/resolvable_discussion_spec.rb b/spec/models/concerns/resolvable_discussion_spec.rb index 18327fe262d..3934992c143 100644 --- a/spec/models/concerns/resolvable_discussion_spec.rb +++ b/spec/models/concerns/resolvable_discussion_spec.rb @@ -306,22 +306,22 @@ describe Discussion, ResolvableDiscussion, models: true do it "doesn't change resolved_at on the resolved note" do expect(first_note.resolved_at).not_to be_nil - expect { subject.resolve!(current_user) }. - not_to change { first_note.reload.resolved_at } + expect { subject.resolve!(current_user) } + .not_to change { first_note.reload.resolved_at } end it "doesn't change resolved_by on the resolved note" do expect(first_note.resolved_by).to eq(user) - expect { subject.resolve!(current_user) }. - not_to change { first_note.reload && first_note.resolved_by } + expect { subject.resolve!(current_user) } + .not_to change { first_note.reload && first_note.resolved_by } end it "doesn't change the resolved state on the resolved note" do expect(first_note.resolved?).to be true - expect { subject.resolve!(current_user) }. - not_to change { first_note.reload && first_note.resolved? } + expect { subject.resolve!(current_user) } + .not_to change { first_note.reload && first_note.resolved? } end it "sets resolved_at on the unresolved note" do diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index aad215d5f41..bb84d3fc13d 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -30,7 +30,7 @@ describe Deployment, models: true do end describe '#includes_commit?' do - let(:project) { create(:project, :repository) } + let(:project) { create(:project, :repository) } let(:environment) { create(:environment, project: project) } let(:deployment) do create(:deployment, environment: environment, sha: project.commit.id) @@ -90,6 +90,36 @@ describe Deployment, models: true do end end + describe '#additional_metrics' do + let(:project) { create(:project) } + let(:deployment) { create(:deployment, project: project) } + + subject { deployment.additional_metrics } + + context 'metrics are disabled' do + it { is_expected.to eq({}) } + end + + context 'metrics are enabled' do + let(:simple_metrics) do + { + success: true, + metrics: {}, + last_update: 42 + } + end + + let(:prometheus_service) { double('prometheus_service') } + + before do + allow(project).to receive(:prometheus_service).and_return(prometheus_service) + allow(prometheus_service).to receive(:additional_deployment_metrics).and_return(simple_metrics) + end + + it { is_expected.to eq(simple_metrics.merge({ deployment_time: deployment.created_at.to_i })) } + end + end + describe '#stop_action' do let(:build) { create(:ci_build) } diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index f8123cb518e..b0635c6a90a 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -432,6 +432,99 @@ describe Environment, models: true do end end + describe '#has_metrics?' do + subject { environment.has_metrics? } + + context 'when the enviroment is available' do + context 'with a deployment service' do + let(:project) { create(:prometheus_project) } + + context 'and a deployment' do + let!(:deployment) { create(:deployment, environment: environment) } + it { is_expected.to be_truthy } + end + + context 'but no deployments' do + it { is_expected.to be_falsy } + end + end + + context 'without a monitoring service' do + it { is_expected.to be_falsy } + end + end + + context 'when the environment is unavailable' do + let(:project) { create(:prometheus_project) } + + before do + environment.stop + end + + it { is_expected.to be_falsy } + end + end + + describe '#additional_metrics' do + let(:project) { create(:prometheus_project) } + subject { environment.additional_metrics } + + context 'when the environment has additional metrics' do + before do + allow(environment).to receive(:has_additional_metrics?).and_return(true) + end + + it 'returns the additional metrics from the deployment service' do + expect(project.prometheus_service).to receive(:additional_environment_metrics) + .with(environment) + .and_return(:fake_metrics) + + is_expected.to eq(:fake_metrics) + end + end + + context 'when the environment does not have metrics' do + before do + allow(environment).to receive(:has_additional_metrics?).and_return(false) + end + + it { is_expected.to be_nil } + end + end + + describe '#has_additional_metrics??' do + subject { environment.has_additional_metrics? } + + context 'when the enviroment is available' do + context 'with a deployment service' do + let(:project) { create(:prometheus_project) } + + context 'and a deployment' do + let!(:deployment) { create(:deployment, environment: environment) } + it { is_expected.to be_truthy } + end + + context 'but no deployments' do + it { is_expected.to be_falsy } + end + end + + context 'without a monitoring service' do + it { is_expected.to be_falsy } + end + end + + context 'when the environment is unavailable' do + let(:project) { create(:prometheus_project) } + + before do + environment.stop + end + + it { is_expected.to be_falsy } + end + end + describe '#slug' do it "is automatically generated" do expect(environment.slug).not_to be_nil diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index b8cb967c4cc..10b9bf9f43a 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -266,8 +266,8 @@ describe Event, models: true do it 'does not update the project' do project.update(last_activity_at: Time.now) - expect(project).not_to receive(:update_column). - with(:last_activity_at, a_kind_of(Time)) + expect(project).not_to receive(:update_column) + .with(:last_activity_at, a_kind_of(Time)) create_push_event(project, project.owner) end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 449b7c2f7d7..4de1683b21c 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -374,8 +374,8 @@ describe Group, models: true do group.add_user(master, GroupMember::MASTER) group.add_user(developer, GroupMember::DEVELOPER) - expect(group.user_ids_for_project_authorizations). - to include(master.id, developer.id) + expect(group.user_ids_for_project_authorizations) + .to include(master.id, developer.id) end end diff --git a/spec/models/issue_collection_spec.rb b/spec/models/issue_collection_spec.rb index 93c2c538e10..04d23d4c4fd 100644 --- a/spec/models/issue_collection_spec.rb +++ b/spec/models/issue_collection_spec.rb @@ -50,8 +50,8 @@ describe IssueCollection do context 'using a user that is the owner of a project' do it 'returns the issues of the project' do - expect(collection.updatable_by_user(project.namespace.owner)). - to eq([issue1, issue2]) + expect(collection.updatable_by_user(project.namespace.owner)) + .to eq([issue1, issue2]) end end end diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 12e7d646382..bf97c6ececd 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -33,8 +33,8 @@ describe Issue, models: true do let!(:issue4) { create(:issue, project: project, relative_position: 200) } it 'returns ordered list' do - expect(project.issues.order_by_position_and_priority). - to match [issue3, issue4, issue1, issue2] + expect(project.issues.order_by_position_and_priority) + .to match [issue3, issue4, issue1, issue2] end end @@ -43,16 +43,16 @@ describe Issue, models: true do allow(subject).to receive(:author).and_return(double(name: 'Robert')) allow(subject).to receive(:assignees).and_return([]) - expect(subject.card_attributes). - to eq({ 'Author' => 'Robert', 'Assignee' => '' }) + expect(subject.card_attributes) + .to eq({ 'Author' => 'Robert', 'Assignee' => '' }) end it 'includes the assignee name' do allow(subject).to receive(:author).and_return(double(name: 'Robert')) allow(subject).to receive(:assignees).and_return([double(name: 'Douwe')]) - expect(subject.card_attributes). - to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' }) + expect(subject.card_attributes) + .to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' }) end end @@ -299,8 +299,8 @@ describe Issue, models: true do let(:user) { build(:admin) } before do - allow(subject.project.repository).to receive(:branch_names). - and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name, "#{subject.iid}-branch"]) + allow(subject.project.repository).to receive(:branch_names) + .and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name, "#{subject.iid}-branch"]) # Without this stub, the `create(:merge_request)` above fails because it can't find # the source branch. This seems like a reasonable compromise, in comparison with @@ -322,8 +322,8 @@ describe Issue, models: true do end it 'excludes stable branches from the related branches' do - allow(subject.project.repository).to receive(:branch_names). - and_return(["#{subject.iid}-0-stable"]) + allow(subject.project.repository).to receive(:branch_names) + .and_return(["#{subject.iid}-0-stable"]) expect(subject.related_branches(user)).to eq [] end diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index f1e2a2cc518..f27920f9feb 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -34,8 +34,8 @@ describe Key, models: true do context 'when key was not updated during the last day' do before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). - and_return('000000') + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) + .and_return('000000') end it 'enqueues a UseKeyWorker job' do @@ -46,8 +46,8 @@ describe Key, models: true do context 'when key was updated during the last day' do before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). - and_return(false) + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) + .and_return(false) end it 'does not enqueue a UseKeyWorker job' do diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb index 84867e3d96b..31190fe5685 100644 --- a/spec/models/label_spec.rb +++ b/spec/models/label_spec.rb @@ -59,8 +59,8 @@ describe Label, models: true do describe '#text_color' do it 'uses default color if color is missing' do - expect(LabelsHelper).to receive(:text_color_for_bg).with(Label::DEFAULT_COLOR). - and_return(spy) + expect(LabelsHelper).to receive(:text_color_for_bg).with(Label::DEFAULT_COLOR) + .and_return(spy) label = described_class.new(color: nil) diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index ccc3deac199..494a88368ba 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -83,8 +83,8 @@ describe Member, models: true do @accepted_invite_member = create(:project_member, :developer, project: project, invite_token: '1234', - invite_email: 'toto2@example.com'). - tap { |u| u.accept_invite!(accepted_invite_user) } + invite_email: 'toto2@example.com') + .tap { |u| u.accept_invite!(accepted_invite_user) } requested_user = create(:user).tap { |u| project.request_access(u) } @requested_member = project.requesters.find_by(user_id: requested_user.id) @@ -265,8 +265,8 @@ describe Member, models: true do expect(source.users).not_to include(user) expect(source.requesters.exists?(user_id: user)).to be_truthy - expect { described_class.add_user(source, user, :master) }. - to raise_error(Gitlab::Access::AccessDeniedError) + expect { described_class.add_user(source, user, :master) } + .to raise_error(Gitlab::Access::AccessDeniedError) expect(source.users.reload).not_to include(user) expect(source.requesters.reload.exists?(user_id: user)).to be_truthy diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb index 17765b25856..37014268a70 100644 --- a/spec/models/members/group_member_spec.rb +++ b/spec/models/members/group_member_spec.rb @@ -33,8 +33,8 @@ describe GroupMember, models: true do it "sends email to user" do membership = build(:group_member) - allow(membership).to receive(:notification_service). - and_return(double('NotificationService').as_null_object) + allow(membership).to receive(:notification_service) + .and_return(double('NotificationService').as_null_object) expect(membership).to receive(:notification_service) membership.save @@ -44,8 +44,8 @@ describe GroupMember, models: true do describe "#after_update" do before do @group_member = create :group_member - allow(@group_member).to receive(:notification_service). - and_return(double('NotificationService').as_null_object) + allow(@group_member).to receive(:notification_service) + .and_return(double('NotificationService').as_null_object) end it "sends email to user" do diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index a56bc524a98..bb5273074a2 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -92,16 +92,16 @@ describe MergeRequest, models: true do allow(subject).to receive(:author).and_return(double(name: 'Robert')) allow(subject).to receive(:assignee).and_return(nil) - expect(subject.card_attributes). - to eq({ 'Author' => 'Robert', 'Assignee' => nil }) + expect(subject.card_attributes) + .to eq({ 'Author' => 'Robert', 'Assignee' => nil }) end it 'includes the assignee name' do allow(subject).to receive(:author).and_return(double(name: 'Robert')) allow(subject).to receive(:assignee).and_return(double(name: 'Douwe')) - expect(subject.card_attributes). - to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' }) + expect(subject.card_attributes) + .to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' }) end end @@ -361,8 +361,8 @@ describe MergeRequest, models: true do end it 'accesses the set of issues that will be closed on acceptance' do - allow(subject.project).to receive(:default_branch). - and_return(subject.target_branch) + allow(subject.project).to receive(:default_branch) + .and_return(subject.target_branch) closed = subject.closes_issues @@ -388,8 +388,8 @@ describe MergeRequest, models: true do subject.description = "Is related to #{mentioned_issue.to_reference} and #{closing_issue.to_reference}" allow(subject).to receive(:commits).and_return([commit]) - allow(subject.project).to receive(:default_branch). - and_return(subject.target_branch) + allow(subject.project).to receive(:default_branch) + .and_return(subject.target_branch) expect(subject.issues_mentioned_but_not_closing(subject.author)).to match_array([mentioned_issue]) end @@ -537,8 +537,8 @@ describe MergeRequest, models: true do subject.project.team << [subject.author, :developer] subject.description = "This issue Closes #{issue.to_reference}" - allow(subject.project).to receive(:default_branch). - and_return(subject.target_branch) + allow(subject.project).to receive(:default_branch) + .and_return(subject.target_branch) expect(subject.merge_commit_message) .to match("Closes #{issue.to_reference}") @@ -663,18 +663,18 @@ describe MergeRequest, models: true do end it 'caches the output' do - expect(subject).to receive(:compute_diverged_commits_count). - once. - and_return(2) + expect(subject).to receive(:compute_diverged_commits_count) + .once + .and_return(2) subject.diverged_commits_count subject.diverged_commits_count end it 'invalidates the cache when the source sha changes' do - expect(subject).to receive(:compute_diverged_commits_count). - twice. - and_return(2) + expect(subject).to receive(:compute_diverged_commits_count) + .twice + .and_return(2) subject.diverged_commits_count allow(subject).to receive(:source_branch_sha).and_return('123abc') @@ -682,9 +682,9 @@ describe MergeRequest, models: true do end it 'invalidates the cache when the target sha changes' do - expect(subject).to receive(:compute_diverged_commits_count). - twice. - and_return(2) + expect(subject).to receive(:compute_diverged_commits_count) + .twice + .and_return(2) subject.diverged_commits_count allow(subject).to receive(:target_branch_sha).and_return('123abc') @@ -706,8 +706,8 @@ describe MergeRequest, models: true do describe '#commits_sha' do before do - allow(subject.merge_request_diff).to receive(:commits_sha). - and_return(['sha1']) + allow(subject.merge_request_diff).to receive(:commits_sha) + .and_return(['sha1']) end it 'delegates to merge request diff' do @@ -1504,8 +1504,8 @@ describe MergeRequest, models: true do describe '#has_commits?' do before do - allow(subject.merge_request_diff).to receive(:commits_count). - and_return(2) + allow(subject.merge_request_diff).to receive(:commits_count) + .and_return(2) end it 'returns true when merge request diff has commits' do @@ -1515,8 +1515,8 @@ describe MergeRequest, models: true do describe '#has_no_commits?' do before do - allow(subject.merge_request_diff).to receive(:commits_count). - and_return(0) + allow(subject.merge_request_diff).to receive(:commits_count) + .and_return(0) end it 'returns true when merge request diff has 0 commits' do @@ -1574,4 +1574,40 @@ describe MergeRequest, models: true do end end end + + describe '#fetch_ref' do + it 'sets "ref_fetched" flag to true' do + subject.update!(ref_fetched: nil) + + subject.fetch_ref + + expect(subject.reload.ref_fetched).to be_truthy + end + end + + describe '#ref_fetched?' do + it 'does not perform git operation when value is cached' do + subject.ref_fetched = true + + expect_any_instance_of(Repository).not_to receive(:ref_exists?) + expect(subject.ref_fetched?).to be_truthy + end + + it 'caches the value when ref exists but value is not cached' do + subject.update!(ref_fetched: nil) + allow_any_instance_of(Repository).to receive(:ref_exists?) + .and_return(true) + + expect(subject.ref_fetched?).to be_truthy + expect(subject.reload.ref_fetched).to be_truthy + end + + it 'returns false when ref does not exist' do + subject.update!(ref_fetched: nil) + allow_any_instance_of(Repository).to receive(:ref_exists?) + .and_return(false) + + expect(subject.ref_fetched?).to be_falsey + end + end end diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 20b96c08a8f..45953023a36 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -164,13 +164,13 @@ describe Milestone, models: true do end it 'returns milestones with a partially matching description' do - expect(described_class.search(milestone.description[0..2])). - to eq([milestone]) + expect(described_class.search(milestone.description[0..2])) + .to eq([milestone]) end it 'returns milestones with a matching description regardless of the casing' do - expect(described_class.search(milestone.description.upcase)). - to eq([milestone]) + expect(described_class.search(milestone.description.upcase)) + .to eq([milestone]) end end diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 145c7ad5770..e7c3acf19eb 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -325,8 +325,8 @@ describe Namespace, models: true do describe '#user_ids_for_project_authorizations' do it 'returns the user IDs for which to refresh authorizations' do - expect(namespace.user_ids_for_project_authorizations). - to eq([namespace.owner_id]) + expect(namespace.user_ids_for_project_authorizations) + .to eq([namespace.owner_id]) end end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index d4d4fc86343..e2b80cb6e61 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -152,8 +152,8 @@ describe Note, models: true do let!(:note2) { create(:note_on_issue) } it "reads the rendered note body from the cache" do - expect(Banzai::Renderer).to receive(:cache_collection_render). - with([{ + expect(Banzai::Renderer).to receive(:cache_collection_render) + .with([{ text: note1.note, context: { skip_project_check: false, @@ -164,8 +164,8 @@ describe Note, models: true do } }]).and_call_original - expect(Banzai::Renderer).to receive(:cache_collection_render). - with([{ + expect(Banzai::Renderer).to receive(:cache_collection_render) + .with([{ text: note2.note, context: { skip_project_check: false, @@ -406,8 +406,8 @@ describe Note, models: true do let(:note) { build(:note_on_project_snippet) } before do - expect(Banzai::Renderer).to receive(:cacheless_render_field). - with(note, :note, { skip_project_check: false }).and_return(html) + expect(Banzai::Renderer).to receive(:cacheless_render_field) + .with(note, :note, { skip_project_check: false }).and_return(html) note.save end @@ -421,8 +421,8 @@ describe Note, models: true do let(:note) { build(:note_on_personal_snippet) } before do - expect(Banzai::Renderer).to receive(:cacheless_render_field). - with(note, :note, { skip_project_check: true }).and_return(html) + expect(Banzai::Renderer).to receive(:cacheless_render_field) + .with(note, :note, { skip_project_check: true }).and_return(html) note.save end diff --git a/spec/models/project_authorization_spec.rb b/spec/models/project_authorization_spec.rb index cd0a4a94809..ee6bdc39c8c 100644 --- a/spec/models/project_authorization_spec.rb +++ b/spec/models/project_authorization_spec.rb @@ -7,8 +7,8 @@ describe ProjectAuthorization do describe '.insert_authorizations' do it 'inserts the authorizations' do - described_class. - insert_authorizations([[user.id, project1.id, Gitlab::Access::MASTER]]) + described_class + .insert_authorizations([[user.id, project1.id, Gitlab::Access::MASTER]]) expect(user.project_authorizations.count).to eq(1) end diff --git a/spec/models/project_feature_spec.rb b/spec/models/project_feature_spec.rb index 09a4448d387..580c83c12c0 100644 --- a/spec/models/project_feature_spec.rb +++ b/spec/models/project_feature_spec.rb @@ -4,6 +4,18 @@ describe ProjectFeature do let(:project) { create(:empty_project) } let(:user) { create(:user) } + describe '.quoted_access_level_column' do + it 'returns the table name and quoted column name for a feature' do + expected = if Gitlab::Database.postgresql? + '"project_features"."issues_access_level"' + else + '`project_features`.`issues_access_level`' + end + + expect(described_class.quoted_access_level_column(:issues)).to eq(expected) + end + end + describe '#feature_available?' do let(:features) { %w(issues wiki builds merge_requests snippets repository) } diff --git a/spec/models/project_services/bamboo_service_spec.rb b/spec/models/project_services/bamboo_service_spec.rb index e62fd69e567..7b1a554d1fb 100644 --- a/spec/models/project_services/bamboo_service_spec.rb +++ b/spec/models/project_services/bamboo_service_spec.rb @@ -217,13 +217,13 @@ describe BambooService, models: true, caching: true do end def stub_request(status: 200, body: nil) - bamboo_full_url = 'http://mic:password@gitlab.com/bamboo/rest/api/latest/result?label=123&os_authType=basic' + bamboo_full_url = 'http://gitlab.com/bamboo/rest/api/latest/result?label=123&os_authType=basic' WebMock.stub_request(:get, bamboo_full_url).to_return( status: status, headers: { 'Content-Type' => 'application/json' }, body: body - ) + ).with(basic_auth: %w(mic password)) end def bamboo_response(result_key: 42, build_state: 'success', size: 1) diff --git a/spec/models/project_services/campfire_service_spec.rb b/spec/models/project_services/campfire_service_spec.rb index de55627dd27..56ff3596190 100644 --- a/spec/models/project_services/campfire_service_spec.rb +++ b/spec/models/project_services/campfire_service_spec.rb @@ -39,21 +39,22 @@ describe CampfireService, models: true do room: 'test-room' ) @sample_data = Gitlab::DataBuilder::Push.build_sample(project, user) - @rooms_url = 'https://verySecret:X@project-name.campfirenow.com/rooms.json' + @rooms_url = 'https://project-name.campfirenow.com/rooms.json' + @auth = %w(verySecret X) @headers = { 'Content-Type' => 'application/json; charset=utf-8' } end it "calls Campfire API to get a list of rooms and speak in a room" do # make sure a valid list of rooms is returned body = File.read(Rails.root + 'spec/fixtures/project_services/campfire/rooms.json') - WebMock.stub_request(:get, @rooms_url).to_return( + WebMock.stub_request(:get, @rooms_url).with(basic_auth: @auth).to_return( body: body, status: 200, headers: @headers ) # stub the speak request with the room id found in the previous request's response - speak_url = 'https://verySecret:X@project-name.campfirenow.com/room/123/speak.json' - WebMock.stub_request(:post, speak_url) + speak_url = 'https://project-name.campfirenow.com/room/123/speak.json' + WebMock.stub_request(:post, speak_url).with(basic_auth: @auth) @campfire_service.execute(@sample_data) @@ -66,7 +67,7 @@ describe CampfireService, models: true do it "calls Campfire API to get a list of rooms but shouldn't speak in a room" do # return a list of rooms that do not contain a room named 'test-room' body = File.read(Rails.root + 'spec/fixtures/project_services/campfire/rooms2.json') - WebMock.stub_request(:get, @rooms_url).to_return( + WebMock.stub_request(:get, @rooms_url).with(basic_auth: @auth).to_return( body: body, status: 200, headers: @headers diff --git a/spec/models/project_services/chat_message/pipeline_message_spec.rb b/spec/models/project_services/chat_message/pipeline_message_spec.rb index 7d2599dc703..43b02568cb9 100644 --- a/spec/models/project_services/chat_message/pipeline_message_spec.rb +++ b/spec/models/project_services/chat_message/pipeline_message_spec.rb @@ -62,7 +62,7 @@ describe ChatMessage::PipelineMessage do def build_message(status_text = status, name = user[:name]) "<http://example.gitlab.com|project_name>:" \ " Pipeline <http://example.gitlab.com/pipelines/123|#123>" \ - " of branch `<http://example.gitlab.com/commits/develop|develop>`" \ + " of branch <http://example.gitlab.com/commits/develop|develop>" \ " by #{name} #{status_text} in 02:00:10" end end @@ -81,7 +81,7 @@ describe ChatMessage::PipelineMessage do expect(subject.pretext).to be_empty expect(subject.attachments).to eq(message) expect(subject.activity).to eq({ - title: 'Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch `[develop](http://example.gitlab.com/commits/develop)` by hacker passed', + title: 'Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch [develop](http://example.gitlab.com/commits/develop) by hacker passed', subtitle: 'in [project_name](http://example.gitlab.com)', text: 'in 02:00:10', image: '' @@ -98,7 +98,7 @@ describe ChatMessage::PipelineMessage do expect(subject.pretext).to be_empty expect(subject.attachments).to eq(message) expect(subject.activity).to eq({ - title: 'Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch `[develop](http://example.gitlab.com/commits/develop)` by hacker failed', + title: 'Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch [develop](http://example.gitlab.com/commits/develop) by hacker failed', subtitle: 'in [project_name](http://example.gitlab.com)', text: 'in 02:00:10', image: '' @@ -113,7 +113,7 @@ describe ChatMessage::PipelineMessage do expect(subject.pretext).to be_empty expect(subject.attachments).to eq(message) expect(subject.activity).to eq({ - title: 'Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch `[develop](http://example.gitlab.com/commits/develop)` by API failed', + title: 'Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch [develop](http://example.gitlab.com/commits/develop) by API failed', subtitle: 'in [project_name](http://example.gitlab.com)', text: 'in 02:00:10', image: '' @@ -125,7 +125,7 @@ describe ChatMessage::PipelineMessage do def build_markdown_message(status_text = status, name = user[:name]) "[project_name](http://example.gitlab.com):" \ " Pipeline [#123](http://example.gitlab.com/pipelines/123)" \ - " of branch `[develop](http://example.gitlab.com/commits/develop)`" \ + " of branch [develop](http://example.gitlab.com/commits/develop)" \ " by #{name} #{status_text} in 02:00:10" end end diff --git a/spec/models/project_services/chat_message/push_message_spec.rb b/spec/models/project_services/chat_message/push_message_spec.rb index e38117b75f6..c794f659c41 100644 --- a/spec/models/project_services/chat_message/push_message_spec.rb +++ b/spec/models/project_services/chat_message/push_message_spec.rb @@ -28,7 +28,7 @@ describe ChatMessage::PushMessage, models: true do context 'without markdown' do it 'returns a message regarding pushes' do expect(subject.pretext).to eq( - 'test.user pushed to branch `<http://url.com/commits/master|master>` of '\ + 'test.user pushed to branch <http://url.com/commits/master|master> of '\ '<http://url.com|project_name> (<http://url.com/compare/before...after|Compare changes>)') expect(subject.attachments).to eq([{ text: "<http://url1.com|abcdefgh>: message1 - author1\n\n"\ @@ -45,7 +45,7 @@ describe ChatMessage::PushMessage, models: true do it 'returns a message regarding pushes' do expect(subject.pretext).to eq( - 'test.user pushed to branch `[master](http://url.com/commits/master)` of [project_name](http://url.com) ([Compare changes](http://url.com/compare/before...after))') + 'test.user pushed to branch [master](http://url.com/commits/master) of [project_name](http://url.com) ([Compare changes](http://url.com/compare/before...after))') expect(subject.attachments).to eq( "[abcdefgh](http://url1.com): message1 - author1\n\n[12345678](http://url2.com): message2 - author2") expect(subject.activity).to eq({ @@ -74,7 +74,7 @@ describe ChatMessage::PushMessage, models: true do context 'without markdown' do it 'returns a message regarding pushes' do expect(subject.pretext).to eq('test.user pushed new tag ' \ - '`<http://url.com/commits/new_tag|new_tag>` to ' \ + '<http://url.com/commits/new_tag|new_tag> to ' \ '<http://url.com|project_name>') expect(subject.attachments).to be_empty end @@ -87,7 +87,7 @@ describe ChatMessage::PushMessage, models: true do it 'returns a message regarding pushes' do expect(subject.pretext).to eq( - 'test.user pushed new tag `[new_tag](http://url.com/commits/new_tag)` to [project_name](http://url.com)') + 'test.user pushed new tag [new_tag](http://url.com/commits/new_tag) to [project_name](http://url.com)') expect(subject.attachments).to be_empty expect(subject.activity).to eq({ title: 'test.user created tag', @@ -107,7 +107,7 @@ describe ChatMessage::PushMessage, models: true do context 'without markdown' do it 'returns a message regarding a new branch' do expect(subject.pretext).to eq( - 'test.user pushed new branch `<http://url.com/commits/master|master>` to '\ + 'test.user pushed new branch <http://url.com/commits/master|master> to '\ '<http://url.com|project_name>') expect(subject.attachments).to be_empty end @@ -120,7 +120,7 @@ describe ChatMessage::PushMessage, models: true do it 'returns a message regarding a new branch' do expect(subject.pretext).to eq( - 'test.user pushed new branch `[master](http://url.com/commits/master)` to [project_name](http://url.com)') + 'test.user pushed new branch [master](http://url.com/commits/master) to [project_name](http://url.com)') expect(subject.attachments).to be_empty expect(subject.activity).to eq({ title: 'test.user created branch', @@ -140,7 +140,7 @@ describe ChatMessage::PushMessage, models: true do context 'without markdown' do it 'returns a message regarding a removed branch' do expect(subject.pretext).to eq( - 'test.user removed branch `master` from <http://url.com|project_name>') + 'test.user removed branch master from <http://url.com|project_name>') expect(subject.attachments).to be_empty end end @@ -152,7 +152,7 @@ describe ChatMessage::PushMessage, models: true do it 'returns a message regarding a removed branch' do expect(subject.pretext).to eq( - 'test.user removed branch `master` from [project_name](http://url.com)') + 'test.user removed branch master from [project_name](http://url.com)') expect(subject.attachments).to be_empty expect(subject.activity).to eq({ title: 'test.user removed branch', diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index e2b8226124f..c86f56c55eb 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -106,15 +106,15 @@ describe JiraService, models: true do @jira_service.save - project_issues_url = 'http://gitlab_jira_username:gitlab_jira_password@jira.example.com/rest/api/2/issue/JIRA-123' - @transitions_url = 'http://gitlab_jira_username:gitlab_jira_password@jira.example.com/rest/api/2/issue/JIRA-123/transitions' - @comment_url = 'http://gitlab_jira_username:gitlab_jira_password@jira.example.com/rest/api/2/issue/JIRA-123/comment' - @remote_link_url = 'http://gitlab_jira_username:gitlab_jira_password@jira.example.com/rest/api/2/issue/JIRA-123/remotelink' - - WebMock.stub_request(:get, project_issues_url) - WebMock.stub_request(:post, @transitions_url) - WebMock.stub_request(:post, @comment_url) - WebMock.stub_request(:post, @remote_link_url) + project_issues_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123' + @transitions_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123/transitions' + @comment_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123/comment' + @remote_link_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123/remotelink' + + WebMock.stub_request(:get, project_issues_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)) + WebMock.stub_request(:post, @transitions_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)) + WebMock.stub_request(:post, @comment_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)) + WebMock.stub_request(:post, @remote_link_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)) end it "calls JIRA API" do @@ -202,9 +202,9 @@ describe JiraService, models: true do end def test_settings(api_url) - project_url = "http://jira_username:jira_password@#{api_url}/rest/api/2/project/GitLabProject" + project_url = "http://#{api_url}/rest/api/2/project/GitLabProject" - WebMock.stub_request(:get, project_url) + WebMock.stub_request(:get, project_url).with(basic_auth: %w(jira_username jira_password)) jira_service.test_settings end diff --git a/spec/models/project_services/mattermost_slash_commands_service_spec.rb b/spec/models/project_services/mattermost_slash_commands_service_spec.rb index f9531be5d25..fa38d23e82f 100644 --- a/spec/models/project_services/mattermost_slash_commands_service_spec.rb +++ b/spec/models/project_services/mattermost_slash_commands_service_spec.rb @@ -11,8 +11,8 @@ describe MattermostSlashCommandsService, :models do before do Mattermost::Session.base_uri("http://mattermost.example.com") - allow_any_instance_of(Mattermost::Client).to receive(:with_session). - and_yield(Mattermost::Session.new(nil)) + allow_any_instance_of(Mattermost::Client).to receive(:with_session) + .and_yield(Mattermost::Session.new(nil)) end describe '#configure' do @@ -24,8 +24,8 @@ describe MattermostSlashCommandsService, :models do context 'the requests succeeds' do before do - stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create'). - with(body: { + stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create') + .with(body: { team_id: 'abc', trigger: 'gitlab', url: 'http://trigger.url', @@ -37,8 +37,8 @@ describe MattermostSlashCommandsService, :models do display_name: "GitLab / #{project.name_with_namespace}", method: 'P', username: 'GitLab' - }.to_json). - to_return( + }.to_json) + .to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: { token: 'token' }.to_json @@ -58,8 +58,8 @@ describe MattermostSlashCommandsService, :models do context 'an error is received' do before do - stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create'). - to_return( + stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create') + .to_return( status: 500, headers: { 'Content-Type' => 'application/json' }, body: { @@ -88,8 +88,8 @@ describe MattermostSlashCommandsService, :models do context 'the requests succeeds' do before do - stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all'). - to_return( + stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all') + .to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: { 'list' => true }.to_json @@ -103,8 +103,8 @@ describe MattermostSlashCommandsService, :models do context 'an error is received' do before do - stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all'). - to_return( + stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all') + .to_return( status: 500, headers: { 'Content-Type' => 'application/json' }, body: { diff --git a/spec/models/project_services/prometheus_service_spec.rb b/spec/models/project_services/prometheus_service_spec.rb index 71b53732164..37f23b1243c 100644 --- a/spec/models/project_services/prometheus_service_spec.rb +++ b/spec/models/project_services/prometheus_service_spec.rb @@ -65,13 +65,13 @@ describe PrometheusService, models: true, caching: true do end it 'returns reactive data' do - is_expected.to eq(prometheus_data) + is_expected.to eq(prometheus_metrics_data) end end end describe '#deployment_metrics' do - let(:deployment) { build_stubbed(:deployment)} + let(:deployment) { build_stubbed(:deployment) } let(:deployment_query) { Gitlab::Prometheus::Queries::DeploymentQuery } around do |example| @@ -80,13 +80,16 @@ describe PrometheusService, models: true, caching: true do context 'with valid data' do subject { service.deployment_metrics(deployment) } + let(:fake_deployment_time) { 10 } before do stub_reactive_cache(service, prometheus_data, deployment_query, deployment.id) end it 'returns reactive data' do - is_expected.to eq(prometheus_data.merge(deployment_time: deployment.created_at.to_i)) + expect(deployment).to receive(:created_at).and_return(fake_deployment_time) + + expect(subject).to eq(prometheus_metrics_data.merge(deployment_time: fake_deployment_time)) end end end @@ -116,6 +119,7 @@ describe PrometheusService, models: true, caching: true do end it { expect(subject.to_json).to eq(prometheus_data.to_json) } + it { expect(subject.to_json).to eq(prometheus_data.to_json) } end [404, 500].each do |status| diff --git a/spec/models/project_services/teamcity_service_spec.rb b/spec/models/project_services/teamcity_service_spec.rb index 7349eb4149a..6b004098510 100644 --- a/spec/models/project_services/teamcity_service_spec.rb +++ b/spec/models/project_services/teamcity_service_spec.rb @@ -205,10 +205,12 @@ describe TeamcityService, models: true, caching: true do end def stub_request(status: 200, body: nil, build_status: 'success') - teamcity_full_url = 'http://mic:password@gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,number:123' + teamcity_full_url = 'http://gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,number:123' + auth = %w(mic password) + body ||= %Q({"build":{"status":"#{build_status}","id":"666"}}) - WebMock.stub_request(:get, teamcity_full_url).to_return( + WebMock.stub_request(:get, teamcity_full_url).with(basic_auth: auth).to_return( status: status, headers: { 'Content-Type' => 'application/json' }, body: body diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 63333b7af1f..d7fcadb895e 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1195,23 +1195,23 @@ describe Project, models: true do it 'renames a repository' do stub_container_registry_config(enabled: false) - expect(gitlab_shell).to receive(:mv_repository). - ordered. - with(project.repository_storage_path, "#{project.namespace.full_path}/foo", "#{project.full_path}"). - and_return(true) + expect(gitlab_shell).to receive(:mv_repository) + .ordered + .with(project.repository_storage_path, "#{project.namespace.full_path}/foo", "#{project.full_path}") + .and_return(true) - expect(gitlab_shell).to receive(:mv_repository). - ordered. - with(project.repository_storage_path, "#{project.namespace.full_path}/foo.wiki", "#{project.full_path}.wiki"). - and_return(true) + expect(gitlab_shell).to receive(:mv_repository) + .ordered + .with(project.repository_storage_path, "#{project.namespace.full_path}/foo.wiki", "#{project.full_path}.wiki") + .and_return(true) - expect_any_instance_of(SystemHooksService). - to receive(:execute_hooks_for). - with(project, :rename) + expect_any_instance_of(SystemHooksService) + .to receive(:execute_hooks_for) + .with(project, :rename) - expect_any_instance_of(Gitlab::UploadsTransfer). - to receive(:rename_project). - with('foo', project.path, project.namespace.full_path) + expect_any_instance_of(Gitlab::UploadsTransfer) + .to receive(:rename_project) + .with('foo', project.path, project.namespace.full_path) expect(project).to receive(:expire_caches_before_rename) @@ -1239,13 +1239,13 @@ describe Project, models: true do let(:wiki) { double(:wiki, exists?: true) } it 'expires the caches of the repository and wiki' do - allow(Repository).to receive(:new). - with('foo', project). - and_return(repo) + allow(Repository).to receive(:new) + .with('foo', project) + .and_return(repo) - allow(Repository).to receive(:new). - with('foo.wiki', project). - and_return(wiki) + allow(Repository).to receive(:new) + .with('foo.wiki', project) + .and_return(wiki) expect(repo).to receive(:before_delete) expect(wiki).to receive(:before_delete) @@ -1296,9 +1296,9 @@ describe Project, models: true do context 'using a regular repository' do it 'creates the repository' do - expect(shell).to receive(:add_repository). - with(project.repository_storage_path, project.path_with_namespace). - and_return(true) + expect(shell).to receive(:add_repository) + .with(project.repository_storage_path, project.path_with_namespace) + .and_return(true) expect(project.repository).to receive(:after_create) @@ -1306,9 +1306,9 @@ describe Project, models: true do end it 'adds an error if the repository could not be created' do - expect(shell).to receive(:add_repository). - with(project.repository_storage_path, project.path_with_namespace). - and_return(false) + expect(shell).to receive(:add_repository) + .with(project.repository_storage_path, project.path_with_namespace) + .and_return(false) expect(project.repository).not_to receive(:after_create) @@ -1564,8 +1564,8 @@ describe Project, models: true do let(:project) { forked_project_link.forked_to_project } it 'schedules a RepositoryForkWorker job' do - expect(RepositoryForkWorker).to receive(:perform_async). - with(project.id, forked_from_project.repository_storage_path, + expect(RepositoryForkWorker).to receive(:perform_async) + .with(project.id, forked_from_project.repository_storage_path, forked_from_project.path_with_namespace, project.namespace.full_path) project.add_import_job @@ -2041,15 +2041,15 @@ describe Project, models: true do error_message = 'Failed to replace merge_requests because one or more of the new records could not be saved.'\ ' Validate fork Source project is not a fork of the target project' - expect { project.append_or_update_attribute(:merge_requests, [create(:merge_request)]) }. - to raise_error(ActiveRecord::RecordNotSaved, error_message) + expect { project.append_or_update_attribute(:merge_requests, [create(:merge_request)]) } + .to raise_error(ActiveRecord::RecordNotSaved, error_message) end it 'updates the project succesfully' do merge_request = create(:merge_request, target_project: project, source_project: project) - expect { project.append_or_update_attribute(:merge_requests, [merge_request]) }. - not_to raise_error + expect { project.append_or_update_attribute(:merge_requests, [merge_request]) } + .not_to raise_error end end @@ -2060,4 +2060,36 @@ describe Project, models: true do expect(project.last_repository_updated_at.to_i).to eq(project.created_at.to_i) end end + + describe '.public_or_visible_to_user' do + let!(:user) { create(:user) } + + let!(:private_project) do + create(:empty_project, :private, creator: user, namespace: user.namespace) + end + + let!(:public_project) { create(:empty_project, :public) } + + context 'with a user' do + let(:projects) do + Project.all.public_or_visible_to_user(user) + end + + it 'includes projects the user has access to' do + expect(projects).to include(private_project) + end + + it 'includes projects the user can see' do + expect(projects).to include(public_project) + end + end + + context 'without a user' do + it 'only includes public projects' do + projects = Project.all.public_or_visible_to_user + + expect(projects).to eq([public_project]) + end + end + end end diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb index ea3cd5fe10a..49f2f8c0ad1 100644 --- a/spec/models/project_team_spec.rb +++ b/spec/models/project_team_spec.rb @@ -100,8 +100,8 @@ describe ProjectTeam, models: true do group_access: Gitlab::Access::GUEST ) - expect(project.team.members). - to contain_exactly(group_member.user, project.owner) + expect(project.team.members) + .to contain_exactly(group_member.user, project.owner) end it 'returns invited members of a group of a specified level' do diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb index 3f5f4eea4a1..bf74ac5ea25 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -149,15 +149,15 @@ describe ProjectWiki, models: true do describe '#find_file' do before do file = Gollum::File.new(subject.wiki) - allow_any_instance_of(Gollum::Wiki). - to receive(:file).with('image.jpg', 'master', true). - and_return(file) - allow_any_instance_of(Gollum::File). - to receive(:mime_type). - and_return('image/jpeg') - allow_any_instance_of(Gollum::Wiki). - to receive(:file).with('non-existant', 'master', true). - and_return(nil) + allow_any_instance_of(Gollum::Wiki) + .to receive(:file).with('image.jpg', 'master', true) + .and_return(file) + allow_any_instance_of(Gollum::File) + .to receive(:mime_type) + .and_return('image/jpeg') + allow_any_instance_of(Gollum::Wiki) + .to receive(:file).with('non-existant', 'master', true) + .and_return(nil) end after do @@ -268,9 +268,9 @@ describe ProjectWiki, models: true do describe '#create_repo!' do it 'creates a repository' do - expect(subject).to receive(:init_repo). - with(subject.path_with_namespace). - and_return(true) + expect(subject).to receive(:init_repo) + .with(subject.path_with_namespace) + .and_return(true) expect(subject.repository).to receive(:after_create) diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index a6d4d92c450..3e984ec7588 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -111,8 +111,8 @@ describe Repository, models: true do describe '#ref_name_for_sha' do it 'returns the ref' do - allow(repository.raw_repository).to receive(:ref_name_for_sha). - and_return('refs/environments/production/77') + allow(repository.raw_repository).to receive(:ref_name_for_sha) + .and_return('refs/environments/production/77') expect(repository.ref_name_for_sha('bla', '0' * 40)).to eq 'refs/environments/production/77' end @@ -593,8 +593,8 @@ describe Repository, models: true do user, 'LICENSE', 'Copyright!', message: 'Add LICENSE', branch_name: 'master') - allow(repository).to receive(:file_on_head). - and_raise(Rugged::ReferenceError) + allow(repository).to receive(:file_on_head) + .and_raise(Rugged::ReferenceError) expect(repository.license_blob).to be_nil end @@ -779,8 +779,8 @@ describe Repository, models: true do context 'when pre hooks were successful' do it 'runs without errors' do - expect_any_instance_of(GitHooksService).to receive(:execute). - with(user, project.repository.path_to_repo, old_rev, blank_sha, 'refs/heads/feature') + expect_any_instance_of(GitHooksService).to receive(:execute) + .with(user, project.repository.path_to_repo, old_rev, blank_sha, 'refs/heads/feature') expect { repository.rm_branch(user, 'feature') }.not_to raise_error end @@ -822,14 +822,14 @@ describe Repository, models: true do before do service = GitHooksService.new expect(GitHooksService).to receive(:new).and_return(service) - expect(service).to receive(:execute). - with( + expect(service).to receive(:execute) + .with( user, repository.path_to_repo, old_rev, new_rev, - 'refs/heads/feature'). - and_yield(service).and_return(true) + 'refs/heads/feature') + .and_yield(service).and_return(true) end it 'runs without errors' do @@ -923,8 +923,8 @@ describe Repository, models: true do expect(repository).not_to receive(:expire_emptiness_caches) expect(repository).to receive(:expire_branches_cache) - GitOperationService.new(user, repository). - with_branch('new-feature') do + GitOperationService.new(user, repository) + .with_branch('new-feature') do new_rev end end @@ -1007,8 +1007,8 @@ describe Repository, models: true do end it 'does nothing' do - expect(repository.raw_repository).not_to receive(:autocrlf=). - with(:input) + expect(repository.raw_repository).not_to receive(:autocrlf=) + .with(:input) GitOperationService.new(nil, repository).send(:update_autocrlf_option) end @@ -1027,9 +1027,9 @@ describe Repository, models: true do end it 'caches the output' do - expect(repository.raw_repository).to receive(:empty?). - once. - and_return(false) + expect(repository.raw_repository).to receive(:empty?) + .once + .and_return(false) repository.empty? repository.empty? @@ -1042,9 +1042,9 @@ describe Repository, models: true do end it 'caches the output' do - expect(repository.raw_repository).to receive(:root_ref). - once. - and_return('master') + expect(repository.raw_repository).to receive(:root_ref) + .once + .and_return('master') repository.root_ref repository.root_ref @@ -1055,9 +1055,9 @@ describe Repository, models: true do it 'expires the root reference cache' do repository.root_ref - expect(repository.raw_repository).to receive(:root_ref). - once. - and_return('foo') + expect(repository.raw_repository).to receive(:root_ref) + .once + .and_return('foo') repository.expire_root_ref_cache @@ -1071,17 +1071,17 @@ describe Repository, models: true do let(:cache) { repository.send(:cache) } it 'expires the cache for all branches' do - expect(cache).to receive(:expire). - at_least(repository.branches.length * 2). - times + expect(cache).to receive(:expire) + .at_least(repository.branches.length * 2) + .times repository.expire_branch_cache end it 'expires the cache for all branches when the root branch is given' do - expect(cache).to receive(:expire). - at_least(repository.branches.length * 2). - times + expect(cache).to receive(:expire) + .at_least(repository.branches.length * 2) + .times repository.expire_branch_cache(repository.root_ref) end @@ -1344,12 +1344,12 @@ describe Repository, models: true do describe '#after_push_commit' do it 'expires statistics caches' do - expect(repository).to receive(:expire_statistics_caches). - and_call_original + expect(repository).to receive(:expire_statistics_caches) + .and_call_original - expect(repository).to receive(:expire_branch_cache). - with('master'). - and_call_original + expect(repository).to receive(:expire_branch_cache) + .with('master') + .and_call_original repository.after_push_commit('master') end @@ -1434,9 +1434,9 @@ describe Repository, models: true do describe '#expire_branches_cache' do it 'expires the cache' do - expect(repository).to receive(:expire_method_caches). - with(%i(branch_names branch_count)). - and_call_original + expect(repository).to receive(:expire_method_caches) + .with(%i(branch_names branch_count)) + .and_call_original repository.expire_branches_cache end @@ -1444,9 +1444,9 @@ describe Repository, models: true do describe '#expire_tags_cache' do it 'expires the cache' do - expect(repository).to receive(:expire_method_caches). - with(%i(tag_names tag_count)). - and_call_original + expect(repository).to receive(:expire_method_caches) + .with(%i(tag_names tag_count)) + .and_call_original repository.expire_tags_cache end @@ -1457,11 +1457,11 @@ describe Repository, models: true do let(:user) { build_stubbed(:user) } it 'creates the tag using rugged' do - expect(repository.rugged.tags).to receive(:create). - with('8.5', repository.commit('master').id, + expect(repository.rugged.tags).to receive(:create) + .with('8.5', repository.commit('master').id, hash_including(message: 'foo', - tagger: hash_including(name: user.name, email: user.email))). - and_call_original + tagger: hash_including(name: user.name, email: user.email))) + .and_call_original repository.add_tag(user, '8.5', 'master', 'foo') end @@ -1478,8 +1478,8 @@ describe Repository, models: true do update_hook = Gitlab::Git::Hook.new('update', repository.path_to_repo) post_receive_hook = Gitlab::Git::Hook.new('post-receive', repository.path_to_repo) - allow(Gitlab::Git::Hook).to receive(:new). - and_return(pre_receive_hook, update_hook, post_receive_hook) + allow(Gitlab::Git::Hook).to receive(:new) + .and_return(pre_receive_hook, update_hook, post_receive_hook) allow(pre_receive_hook).to receive(:trigger).and_call_original allow(update_hook).to receive(:trigger).and_call_original @@ -1490,12 +1490,12 @@ describe Repository, models: true do commit_sha = repository.commit('master').id tag_sha = tag.target - expect(pre_receive_hook).to have_received(:trigger). - with(anything, anything, commit_sha, anything) - expect(update_hook).to have_received(:trigger). - with(anything, anything, commit_sha, anything) - expect(post_receive_hook).to have_received(:trigger). - with(anything, anything, tag_sha, anything) + expect(pre_receive_hook).to have_received(:trigger) + .with(anything, anything, commit_sha, anything) + expect(update_hook).to have_received(:trigger) + .with(anything, anything, commit_sha, anything) + expect(post_receive_hook).to have_received(:trigger) + .with(anything, anything, tag_sha, anything) end end @@ -1529,25 +1529,25 @@ describe Repository, models: true do describe '#avatar' do it 'returns nil if repo does not exist' do - expect(repository).to receive(:file_on_head). - and_raise(Rugged::ReferenceError) + expect(repository).to receive(:file_on_head) + .and_raise(Rugged::ReferenceError) expect(repository.avatar).to eq(nil) end it 'returns the first avatar file found in the repository' do - expect(repository).to receive(:file_on_head). - with(:avatar). - and_return(double(:tree, path: 'logo.png')) + expect(repository).to receive(:file_on_head) + .with(:avatar) + .and_return(double(:tree, path: 'logo.png')) expect(repository.avatar).to eq('logo.png') end it 'caches the output' do - expect(repository).to receive(:file_on_head). - with(:avatar). - once. - and_return(double(:tree, path: 'logo.png')) + expect(repository).to receive(:file_on_head) + .with(:avatar) + .once + .and_return(double(:tree, path: 'logo.png')) 2.times { expect(repository.avatar).to eq('logo.png') } end @@ -1607,24 +1607,24 @@ describe Repository, models: true do describe '#contribution_guide', caching: true do it 'returns and caches the output' do - expect(repository).to receive(:file_on_head). - with(:contributing). - and_return(Gitlab::Git::Tree.new(path: 'CONTRIBUTING.md')). - once + expect(repository).to receive(:file_on_head) + .with(:contributing) + .and_return(Gitlab::Git::Tree.new(path: 'CONTRIBUTING.md')) + .once 2.times do - expect(repository.contribution_guide). - to be_an_instance_of(Gitlab::Git::Tree) + expect(repository.contribution_guide) + .to be_an_instance_of(Gitlab::Git::Tree) end end end describe '#gitignore', caching: true do it 'returns and caches the output' do - expect(repository).to receive(:file_on_head). - with(:gitignore). - and_return(Gitlab::Git::Tree.new(path: '.gitignore')). - once + expect(repository).to receive(:file_on_head) + .with(:gitignore) + .and_return(Gitlab::Git::Tree.new(path: '.gitignore')) + .once 2.times do expect(repository.gitignore).to be_an_instance_of(Gitlab::Git::Tree) @@ -1634,10 +1634,10 @@ describe Repository, models: true do describe '#koding_yml', caching: true do it 'returns and caches the output' do - expect(repository).to receive(:file_on_head). - with(:koding). - and_return(Gitlab::Git::Tree.new(path: '.koding.yml')). - once + expect(repository).to receive(:file_on_head) + .with(:koding) + .and_return(Gitlab::Git::Tree.new(path: '.koding.yml')) + .once 2.times do expect(repository.koding_yml).to be_an_instance_of(Gitlab::Git::Tree) @@ -1673,8 +1673,8 @@ describe Repository, models: true do describe '#expire_statistics_caches' do it 'expires the caches' do - expect(repository).to receive(:expire_method_caches). - with(%i(size commit_count)) + expect(repository).to receive(:expire_method_caches) + .with(%i(size commit_count)) repository.expire_statistics_caches end @@ -1691,8 +1691,8 @@ describe Repository, models: true do describe '#expire_all_method_caches' do it 'expires the caches of all methods' do - expect(repository).to receive(:expire_method_caches). - with(Repository::CACHED_METHODS) + expect(repository).to receive(:expire_method_caches) + .with(Repository::CACHED_METHODS) repository.expire_all_method_caches end @@ -1717,8 +1717,8 @@ describe Repository, models: true do context 'with an existing repository' do it 'returns a Gitlab::Git::Tree' do - expect(repository.file_on_head(:readme)). - to be_an_instance_of(Gitlab::Git::Tree) + expect(repository.file_on_head(:readme)) + .to be_an_instance_of(Gitlab::Git::Tree) end end end @@ -1856,8 +1856,8 @@ describe Repository, models: true do describe '#refresh_method_caches' do it 'refreshes the caches of the given types' do - expect(repository).to receive(:expire_method_caches). - with(%i(rendered_readme license_blob license_key license)) + expect(repository).to receive(:expire_method_caches) + .with(%i(rendered_readme license_blob license_key license)) expect(repository).to receive(:rendered_readme) expect(repository).to receive(:license_blob) diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb index 4c832c87d6a..2dea2c6015f 100644 --- a/spec/models/upload_spec.rb +++ b/spec/models/upload_spec.rb @@ -54,8 +54,8 @@ describe Upload, type: :model do uploader: 'AvatarUploader' ) - expect { described_class.remove_path(__FILE__) }. - to change { described_class.count }.from(1).to(0) + expect { described_class.remove_path(__FILE__) } + .to change { described_class.count }.from(1).to(0) end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index f6b7120e2c9..8e895ec6634 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -912,8 +912,8 @@ describe User, models: true do describe '.find_by_username!' do it 'raises RecordNotFound' do - expect { described_class.find_by_username!('JohnDoe') }. - to raise_error(ActiveRecord::RecordNotFound) + expect { described_class.find_by_username!('JohnDoe') } + .to raise_error(ActiveRecord::RecordNotFound) end it 'is case-insensitive' do @@ -1557,8 +1557,8 @@ describe User, models: true do end it 'returns the projects when using an ActiveRecord relation' do - projects = user. - projects_with_reporter_access_limited_to(Project.select(:id)) + projects = user + .projects_with_reporter_access_limited_to(Project.select(:id)) expect(projects).to eq([project1]) end @@ -1733,6 +1733,20 @@ describe User, models: true do end end + describe '#full_private_access?' do + it 'returns false for regular user' do + user = build(:user) + + expect(user.full_private_access?).to be_falsy + end + + it 'returns true for admin user' do + user = build(:user, :admin) + + expect(user.full_private_access?).to be_truthy + end + end + describe '.ghost' do it "creates a ghost user if one isn't already present" do ghost = User.ghost diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 753dc938c52..4a73552b8a6 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -61,8 +61,8 @@ describe WikiPage, models: true do actual_order = grouped_entries.map do |page_or_dir| get_slugs(page_or_dir) - end. - flatten + end + .flatten expect(actual_order).to eq(expected_order) end end diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb index 848fd547e10..d70e15f006b 100644 --- a/spec/policies/project_policy_spec.rb +++ b/spec/policies/project_policy_spec.rb @@ -80,8 +80,8 @@ describe ProjectPolicy, models: true do expect(project.team.member?(issue.author)).to eq(false) - expect(BasePolicy.class_for(project).abilities(user, project).can_set). - not_to include(:read_issue) + expect(BasePolicy.class_for(project).abilities(user, project).can_set) + .not_to include(:read_issue) expect(Ability.allowed?(user, :read_issue, project)).to be_falsy end diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb index 2190ab0e82e..518e97d17a1 100644 --- a/spec/presenters/ci/build_presenter_spec.rb +++ b/spec/presenters/ci/build_presenter_spec.rb @@ -47,8 +47,8 @@ describe Ci::BuildPresenter do context 'when build is erased' do before do expect(presenter).to receive(:erased_by_user?).and_return(true) - expect(build).to receive(:erased_by). - and_return(double(:user, name: 'John Doe')) + expect(build).to receive(:erased_by) + .and_return(double(:user, name: 'John Doe')) end it 'returns the name of the eraser' do diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb index b8ca73c321c..cdb60fc0d1a 100644 --- a/spec/requests/api/commit_statuses_spec.rb +++ b/spec/requests/api/commit_statuses_spec.rb @@ -164,25 +164,40 @@ describe API::CommitStatuses do context 'with all optional parameters' do context 'when creating a commit status' do - it 'creates commit status' do + subject do post api(post_url, developer), { state: 'success', context: 'coverage', - ref: 'develop', + ref: 'master', description: 'test', coverage: 80.0, target_url: 'http://gitlab.com/status' } + end + + it 'creates commit status' do + subject expect(response).to have_http_status(201) expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq('success') expect(json_response['name']).to eq('coverage') - expect(json_response['ref']).to eq('develop') + expect(json_response['ref']).to eq('master') expect(json_response['coverage']).to eq(80.0) expect(json_response['description']).to eq('test') expect(json_response['target_url']).to eq('http://gitlab.com/status') end + + context 'when merge request exists for given branch' do + let!(:merge_request) { create(:merge_request, source_project: project, source_branch: 'master', target_branch: 'develop') } + + it 'sets head pipeline' do + subject + + expect(response).to have_http_status(201) + expect(merge_request.reload.head_pipeline).not_to be_nil + end + end end context 'when updatig a commit status' do @@ -190,7 +205,7 @@ describe API::CommitStatuses do post api(post_url, developer), { state: 'running', context: 'coverage', - ref: 'develop', + ref: 'master', description: 'coverage test', coverage: 0.0, target_url: 'http://gitlab.com/status' @@ -199,7 +214,7 @@ describe API::CommitStatuses do post api(post_url, developer), { state: 'success', name: 'coverage', - ref: 'develop', + ref: 'master', description: 'new description', coverage: 90.0 } @@ -210,7 +225,7 @@ describe API::CommitStatuses do expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq('success') expect(json_response['name']).to eq('coverage') - expect(json_response['ref']).to eq('develop') + expect(json_response['ref']).to eq('master') expect(json_response['coverage']).to eq(90.0) expect(json_response['description']).to eq('new description') expect(json_response['target_url']).to eq('http://gitlab.com/status') diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb index 9c260f88f56..32439981b60 100644 --- a/spec/requests/api/deploy_keys_spec.rb +++ b/spec/requests/api/deploy_keys_spec.rb @@ -160,6 +160,16 @@ describe API::DeployKeys do expect(json_response['title']).to eq('new title') expect(json_response['can_push']).to eq(true) end + + it 'updates a private ssh key from projects user has access with correct attributes' do + create(:deploy_keys_project, project: project2, deploy_key: private_deploy_key) + + put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), { title: 'new title', can_push: true } + + expect(json_response['id']).to eq(private_deploy_key.id) + expect(json_response['title']).to eq('new title') + expect(json_response['can_push']).to eq(true) + end end describe 'DELETE /projects/:id/deploy_keys/:key_id' do diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb index c5ec8be4f21..9e268adf950 100644 --- a/spec/requests/api/files_spec.rb +++ b/spec/requests/api/files_spec.rb @@ -205,8 +205,8 @@ describe API::Files do end it "returns a 400 if editor fails to create file" do - allow_any_instance_of(Repository).to receive(:create_file). - and_raise(Repository::CommitError, 'Cannot create file') + allow_any_instance_of(Repository).to receive(:create_file) + .and_raise(Repository::CommitError, 'Cannot create file') post api(route("any%2Etxt"), user), valid_params diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index bb53796cbd7..656f098aea8 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -513,8 +513,8 @@ describe API::Groups do let(:project_path) { project.full_path.gsub('/', '%2F') } before(:each) do - allow_any_instance_of(Projects::TransferService). - to receive(:execute).and_return(true) + allow_any_instance_of(Projects::TransferService) + .to receive(:execute).and_return(true) end context "when authenticated as user" do diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 452ff4aba8e..4d0bd67c571 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -560,8 +560,8 @@ describe API::MergeRequests do end it "returns 406 if branch can't be merged" do - allow_any_instance_of(MergeRequest). - to receive(:can_be_merged?).and_return(false) + allow_any_instance_of(MergeRequest) + .to receive(:can_be_merged?).and_return(false) put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user) diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index 03f2b5950ee..4701ad585c9 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -13,8 +13,8 @@ describe API::Notes do # For testing the cross-reference of a private issue in a public issue let(:private_user) { create(:user) } let(:private_project) do - create(:empty_project, namespace: private_user.namespace). - tap { |p| p.team << [private_user, :master] } + create(:empty_project, namespace: private_user.namespace) + .tap { |p| p.team << [private_user, :master] } end let(:private_issue) { create(:issue, project: private_project) } diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb index 4d4631322b1..518639f45a2 100644 --- a/spec/requests/api/project_snippets_spec.rb +++ b/spec/requests/api/project_snippets_spec.rb @@ -102,23 +102,23 @@ describe API::ProjectSnippets do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(project, visibility: 'private') }. - to change { Snippet.count }.by(1) + expect { create_snippet(project, visibility: 'private') } + .to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the snippet' do - expect { create_snippet(project, visibility: 'public') }. - not_to change { Snippet.count } + expect { create_snippet(project, visibility: 'public') } + .not_to change { Snippet.count } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { create_snippet(project, visibility: 'public') }. - to change { SpamLog.count }.by(1) + expect { create_snippet(project, visibility: 'public') } + .to change { SpamLog.count }.by(1) end end end @@ -166,8 +166,8 @@ describe API::ProjectSnippets do let(:visibility_level) { Snippet::PRIVATE } it 'creates the snippet' do - expect { update_snippet(title: 'Foo') }. - to change { snippet.reload.title }.to('Foo') + expect { update_snippet(title: 'Foo') } + .to change { snippet.reload.title }.to('Foo') end end @@ -175,13 +175,13 @@ describe API::ProjectSnippets do let(:visibility_level) { Snippet::PUBLIC } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo') }. - not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo') } + .not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo') }. - to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo') } + .to change { SpamLog.count }.by(1) end end @@ -189,16 +189,16 @@ describe API::ProjectSnippets do let(:visibility_level) { Snippet::PRIVATE } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo', visibility: 'public') }. - not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo', visibility: 'public') } + .not_to change { snippet.reload.title } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { update_snippet(title: 'Foo', visibility: 'public') }. - to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo', visibility: 'public') } + .to change { SpamLog.count }.by(1) end end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index d92262a4c99..fd7ff0b9cff 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -288,15 +288,15 @@ describe API::Projects do context 'maximum number of projects reached' do it 'does not create new project and respond with 403' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) - expect { post api('/projects', user2), name: 'foo' }. - to change {Project.count}.by(0) + expect { post api('/projects', user2), name: 'foo' } + .to change {Project.count}.by(0) expect(response).to have_http_status(403) end end it 'creates new project without path but with name and returns 201' do - expect { post api('/projects', user), name: 'Foo Project' }. - to change { Project.count }.by(1) + expect { post api('/projects', user), name: 'Foo Project' } + .to change { Project.count }.by(1) expect(response).to have_http_status(201) project = Project.first @@ -306,8 +306,8 @@ describe API::Projects do end it 'creates new project without name but with path and returns 201' do - expect { post api('/projects', user), path: 'foo_project' }. - to change { Project.count }.by(1) + expect { post api('/projects', user), path: 'foo_project' } + .to change { Project.count }.by(1) expect(response).to have_http_status(201) project = Project.first @@ -317,8 +317,8 @@ describe API::Projects do end it 'creates new project with name and path and returns 201' do - expect { post api('/projects', user), path: 'path-project-Foo', name: 'Foo Project' }. - to change { Project.count }.by(1) + expect { post api('/projects', user), path: 'path-project-Foo', name: 'Foo Project' } + .to change { Project.count }.by(1) expect(response).to have_http_status(201) project = Project.first @@ -491,8 +491,8 @@ describe API::Projects do end it 'creates new project with name and path and returns 201' do - expect { post api("/projects/user/#{user.id}", admin), path: 'path-project-Foo', name: 'Foo Project' }. - to change { Project.count }.by(1) + expect { post api("/projects/user/#{user.id}", admin), path: 'path-project-Foo', name: 'Foo Project' } + .to change { Project.count }.by(1) expect(response).to have_http_status(201) project = Project.first @@ -502,8 +502,8 @@ describe API::Projects do end it 'responds with 400 on failure and not project' do - expect { post api("/projects/user/#{user.id}", admin) }. - not_to change { Project.count } + expect { post api("/projects/user/#{user.id}", admin) } + .not_to change { Project.count } expect(response).to have_http_status(400) expect(json_response['error']).to eq('name is missing') @@ -740,8 +740,8 @@ describe API::Projects do get api("/projects", user) expect(response).to have_http_status(200) - expect(json_response.first['permissions']['project_access']['access_level']). - to eq(Gitlab::Access::MASTER) + expect(json_response.first['permissions']['project_access']['access_level']) + .to eq(Gitlab::Access::MASTER) expect(json_response.first['permissions']['group_access']).to be_nil end end @@ -752,8 +752,8 @@ describe API::Projects do get api("/projects/#{project.id}", user) expect(response).to have_http_status(200) - expect(json_response['permissions']['project_access']['access_level']). - to eq(Gitlab::Access::MASTER) + expect(json_response['permissions']['project_access']['access_level']) + .to eq(Gitlab::Access::MASTER) expect(json_response['permissions']['group_access']).to be_nil end end @@ -770,8 +770,8 @@ describe API::Projects do expect(response).to have_http_status(200) expect(json_response['permissions']['project_access']).to be_nil - expect(json_response['permissions']['group_access']['access_level']). - to eq(Gitlab::Access::OWNER) + expect(json_response['permissions']['group_access']['access_level']) + .to eq(Gitlab::Access::OWNER) end end end diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index d554c242916..339a57a1f20 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -414,8 +414,8 @@ describe API::Runner do context 'when concurrently updating a job' do before do - expect_any_instance_of(Ci::Build).to receive(:run!). - and_raise(ActiveRecord::StaleObjectError.new(nil, nil)) + expect_any_instance_of(Ci::Build).to receive(:run!) + .and_raise(ActiveRecord::StaleObjectError.new(nil, nil)) end it 'returns a conflict' do diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index 8741cbd4e80..b20a187acfe 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -142,23 +142,23 @@ describe API::Snippets do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(visibility: 'private') }. - to change { Snippet.count }.by(1) + expect { create_snippet(visibility: 'private') } + .to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the shippet' do - expect { create_snippet(visibility: 'public') }. - not_to change { Snippet.count } + expect { create_snippet(visibility: 'public') } + .not_to change { Snippet.count } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { create_snippet(visibility: 'public') }. - to change { SpamLog.count }.by(1) + expect { create_snippet(visibility: 'public') } + .to change { SpamLog.count }.by(1) end end end @@ -216,8 +216,8 @@ describe API::Snippets do let(:visibility_level) { Snippet::PRIVATE } it 'updates the snippet' do - expect { update_snippet(title: 'Foo') }. - to change { snippet.reload.title }.to('Foo') + expect { update_snippet(title: 'Foo') } + .to change { snippet.reload.title }.to('Foo') end end @@ -225,16 +225,16 @@ describe API::Snippets do let(:visibility_level) { Snippet::PUBLIC } it 'rejects the shippet' do - expect { update_snippet(title: 'Foo') }. - not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo') } + .not_to change { snippet.reload.title } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { update_snippet(title: 'Foo') }. - to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo') } + .to change { SpamLog.count }.by(1) end end @@ -242,13 +242,13 @@ describe API::Snippets do let(:visibility_level) { Snippet::PRIVATE } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo', visibility: 'public') }. - not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo', visibility: 'public') } + .not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo', visibility: 'public') }. - to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo', visibility: 'public') } + .to change { SpamLog.count }.by(1) end end end diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index bc869ea1108..c0174b304c8 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -11,7 +11,7 @@ describe API::Users do let(:not_existing_user_id) { (User.maximum('id') || 0 ) + 10 } let(:not_existing_pat_id) { (PersonalAccessToken.maximum('id') || 0 ) + 10 } - describe "GET /users" do + describe 'GET /users' do context "when unauthenticated" do it "returns authentication error" do get api("/users") @@ -76,6 +76,12 @@ describe API::Users do expect(response).to have_http_status(403) end + + it 'does not reveal the `is_admin` flag of the user' do + get api('/users', user) + + expect(json_response.first.keys).not_to include 'is_admin' + end end context "when admin" do @@ -92,6 +98,7 @@ describe API::Users do expect(json_response.first.keys).to include 'two_factor_enabled' expect(json_response.first.keys).to include 'last_sign_in_at' expect(json_response.first.keys).to include 'confirmed_at' + expect(json_response.first.keys).to include 'is_admin' end it "returns an array of external users" do @@ -282,14 +289,14 @@ describe API::Users do bio: 'g' * 256, projects_limit: -1 expect(response).to have_http_status(400) - expect(json_response['message']['password']). - to eq(['is too short (minimum is 8 characters)']) - expect(json_response['message']['bio']). - to eq(['is too long (maximum is 255 characters)']) - expect(json_response['message']['projects_limit']). - to eq(['must be greater than or equal to 0']) - expect(json_response['message']['username']). - to eq([Gitlab::PathRegex.namespace_format_message]) + expect(json_response['message']['password']) + .to eq(['is too short (minimum is 8 characters)']) + expect(json_response['message']['bio']) + .to eq(['is too long (maximum is 255 characters)']) + expect(json_response['message']['projects_limit']) + .to eq(['must be greater than or equal to 0']) + expect(json_response['message']['username']) + .to eq([Gitlab::PathRegex.namespace_format_message]) end it "is not available for non admin users" do @@ -357,6 +364,7 @@ describe API::Users do it "updates user with new bio" do put api("/users/#{user.id}", admin), { bio: 'new test bio' } + expect(response).to have_http_status(200) expect(json_response['bio']).to eq('new test bio') expect(user.reload.bio).to eq('new test bio') @@ -389,13 +397,22 @@ describe API::Users do it 'updates user with his own email' do put api("/users/#{user.id}", admin), email: user.email + expect(response).to have_http_status(200) expect(json_response['email']).to eq(user.email) expect(user.reload.email).to eq(user.email) end + it 'updates user with a new email' do + put api("/users/#{user.id}", admin), email: 'new@email.com' + + expect(response).to have_http_status(200) + expect(user.reload.notification_email).to eq('new@email.com') + end + it 'updates user with his own username' do put api("/users/#{user.id}", admin), username: user.username + expect(response).to have_http_status(200) expect(json_response['username']).to eq(user.username) expect(user.reload.username).to eq(user.username) @@ -403,12 +420,14 @@ describe API::Users do it "updates user's existing identity" do put api("/users/#{omniauth_user.id}", admin), provider: 'ldapmain', extern_uid: '654321' + expect(response).to have_http_status(200) expect(omniauth_user.reload.identities.first.extern_uid).to eq('654321') end it 'updates user with new identity' do put api("/users/#{user.id}", admin), provider: 'github', extern_uid: 'john' + expect(response).to have_http_status(200) expect(user.reload.identities.first.extern_uid).to eq('john') expect(user.reload.identities.first.provider).to eq('github') @@ -416,12 +435,14 @@ describe API::Users do it "updates admin status" do put api("/users/#{user.id}", admin), { admin: true } + expect(response).to have_http_status(200) expect(user.reload.admin).to eq(true) end it "updates external status" do put api("/users/#{user.id}", admin), { external: true } + expect(response.status).to eq 200 expect(json_response['external']).to eq(true) expect(user.reload.external?).to be_truthy @@ -429,6 +450,7 @@ describe API::Users do it "does not update admin status" do put api("/users/#{admin_user.id}", admin), { can_create_group: false } + expect(response).to have_http_status(200) expect(admin_user.reload.admin).to eq(true) expect(admin_user.can_create_group).to eq(false) @@ -436,6 +458,7 @@ describe API::Users do it "does not allow invalid update" do put api("/users/#{user.id}", admin), { email: 'invalid email' } + expect(response).to have_http_status(400) expect(user.reload.email).not_to eq('invalid email') end @@ -452,6 +475,7 @@ describe API::Users do it "returns 404 for non-existing user" do put api("/users/999999", admin), { bio: 'update should fail' } + expect(response).to have_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -471,14 +495,14 @@ describe API::Users do bio: 'g' * 256, projects_limit: -1 expect(response).to have_http_status(400) - expect(json_response['message']['password']). - to eq(['is too short (minimum is 8 characters)']) - expect(json_response['message']['bio']). - to eq(['is too long (maximum is 255 characters)']) - expect(json_response['message']['projects_limit']). - to eq(['must be greater than or equal to 0']) - expect(json_response['message']['username']). - to eq([Gitlab::PathRegex.namespace_format_message]) + expect(json_response['message']['password']) + .to eq(['is too short (minimum is 8 characters)']) + expect(json_response['message']['bio']) + .to eq(['is too long (maximum is 255 characters)']) + expect(json_response['message']['projects_limit']) + .to eq(['must be greater than or equal to 0']) + expect(json_response['message']['username']) + .to eq([Gitlab::PathRegex.namespace_format_message]) end it 'returns 400 if provider is missing for identity update' do @@ -502,6 +526,7 @@ describe API::Users do it 'returns 409 conflict error if email address exists' do put api("/users/#{@user.id}", admin), email: 'test@example.com' + expect(response).to have_http_status(409) expect(@user.reload.email).to eq(@user.email) end @@ -509,6 +534,7 @@ describe API::Users do it 'returns 409 conflict error if username taken' do @user_id = User.all.last.id put api("/users/#{@user.id}", admin), username: 'test' + expect(response).to have_http_status(409) expect(@user.reload.username).to eq(@user.username) end diff --git a/spec/requests/api/v3/files_spec.rb b/spec/requests/api/v3/files_spec.rb index 378ca1720ff..8b2d165c763 100644 --- a/spec/requests/api/v3/files_spec.rb +++ b/spec/requests/api/v3/files_spec.rb @@ -126,8 +126,8 @@ describe API::V3::Files do end it "returns a 400 if editor fails to create file" do - allow_any_instance_of(Repository).to receive(:create_file). - and_raise(Repository::CommitError, 'Cannot create file') + allow_any_instance_of(Repository).to receive(:create_file) + .and_raise(Repository::CommitError, 'Cannot create file') post v3_api("/projects/#{project.id}/repository/files", user), valid_params diff --git a/spec/requests/api/v3/groups_spec.rb b/spec/requests/api/v3/groups_spec.rb index 98e8c954909..63c5707b2e4 100644 --- a/spec/requests/api/v3/groups_spec.rb +++ b/spec/requests/api/v3/groups_spec.rb @@ -505,8 +505,8 @@ describe API::V3::Groups do let(:project_path) { "#{project.namespace.path}%2F#{project.path}" } before(:each) do - allow_any_instance_of(Projects::TransferService). - to receive(:execute).and_return(true) + allow_any_instance_of(Projects::TransferService) + .to receive(:execute).and_return(true) end context "when authenticated as user" do diff --git a/spec/requests/api/v3/merge_requests_spec.rb b/spec/requests/api/v3/merge_requests_spec.rb index f6ff96be566..4f9e63f2ace 100644 --- a/spec/requests/api/v3/merge_requests_spec.rb +++ b/spec/requests/api/v3/merge_requests_spec.rb @@ -432,8 +432,8 @@ describe API::MergeRequests do end it "returns 406 if branch can't be merged" do - allow_any_instance_of(MergeRequest). - to receive(:can_be_merged?).and_return(false) + allow_any_instance_of(MergeRequest) + .to receive(:can_be_merged?).and_return(false) put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) diff --git a/spec/requests/api/v3/notes_spec.rb b/spec/requests/api/v3/notes_spec.rb index 2bae4a60931..b5f98a9a545 100644 --- a/spec/requests/api/v3/notes_spec.rb +++ b/spec/requests/api/v3/notes_spec.rb @@ -13,8 +13,8 @@ describe API::V3::Notes do # For testing the cross-reference of a private issue in a public issue let(:private_user) { create(:user) } let(:private_project) do - create(:empty_project, namespace: private_user.namespace). - tap { |p| p.team << [private_user, :master] } + create(:empty_project, namespace: private_user.namespace) + .tap { |p| p.team << [private_user, :master] } end let(:private_issue) { create(:issue, project: private_project) } diff --git a/spec/requests/api/v3/project_snippets_spec.rb b/spec/requests/api/v3/project_snippets_spec.rb index 365e7365fda..1950c64c690 100644 --- a/spec/requests/api/v3/project_snippets_spec.rb +++ b/spec/requests/api/v3/project_snippets_spec.rb @@ -85,23 +85,23 @@ describe API::ProjectSnippets do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(project, visibility_level: Snippet::PRIVATE) }. - to change { Snippet.count }.by(1) + expect { create_snippet(project, visibility_level: Snippet::PRIVATE) } + .to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the shippet' do - expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }. - not_to change { Snippet.count } + expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } + .not_to change { Snippet.count } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }. - to change { SpamLog.count }.by(1) + expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } + .to change { SpamLog.count }.by(1) end end end @@ -147,8 +147,8 @@ describe API::ProjectSnippets do let(:visibility_level) { Snippet::PRIVATE } it 'creates the snippet' do - expect { update_snippet(title: 'Foo') }. - to change { snippet.reload.title }.to('Foo') + expect { update_snippet(title: 'Foo') } + .to change { snippet.reload.title }.to('Foo') end end @@ -156,13 +156,13 @@ describe API::ProjectSnippets do let(:visibility_level) { Snippet::PUBLIC } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo') }. - not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo') } + .not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo') }. - to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo') } + .to change { SpamLog.count }.by(1) end end @@ -170,16 +170,16 @@ describe API::ProjectSnippets do let(:visibility_level) { Snippet::PRIVATE } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. - not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } + .not_to change { snippet.reload.title } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. - to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } + .to change { SpamLog.count }.by(1) end end end diff --git a/spec/requests/api/v3/projects_spec.rb b/spec/requests/api/v3/projects_spec.rb index 47cca4275af..cb74868324c 100644 --- a/spec/requests/api/v3/projects_spec.rb +++ b/spec/requests/api/v3/projects_spec.rb @@ -124,6 +124,36 @@ describe API::V3::Projects do end end + context 'and using archived' do + let!(:archived_project) { create(:empty_project, creator_id: user.id, namespace: user.namespace, archived: true) } + + it 'returns archived project' do + get v3_api('/projects?archived=true', user) + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.length).to eq(1) + expect(json_response.first['id']).to eq(archived_project.id) + end + + it 'returns non-archived project' do + get v3_api('/projects?archived=false', user) + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.length).to eq(1) + expect(json_response.first['id']).to eq(project.id) + end + + it 'returns all project' do + get v3_api('/projects', user) + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.length).to eq(2) + end + end + context 'and using sorting' do before do project2 @@ -301,15 +331,15 @@ describe API::V3::Projects do context 'maximum number of projects reached' do it 'does not create new project and respond with 403' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) - expect { post v3_api('/projects', user2), name: 'foo' }. - to change {Project.count}.by(0) + expect { post v3_api('/projects', user2), name: 'foo' } + .to change {Project.count}.by(0) expect(response).to have_http_status(403) end end it 'creates new project without path but with name and returns 201' do - expect { post v3_api('/projects', user), name: 'Foo Project' }. - to change { Project.count }.by(1) + expect { post v3_api('/projects', user), name: 'Foo Project' } + .to change { Project.count }.by(1) expect(response).to have_http_status(201) project = Project.first @@ -319,8 +349,8 @@ describe API::V3::Projects do end it 'creates new project without name but with path and returns 201' do - expect { post v3_api('/projects', user), path: 'foo_project' }. - to change { Project.count }.by(1) + expect { post v3_api('/projects', user), path: 'foo_project' } + .to change { Project.count }.by(1) expect(response).to have_http_status(201) project = Project.first @@ -330,8 +360,8 @@ describe API::V3::Projects do end it 'creates new project name and path and returns 201' do - expect { post v3_api('/projects', user), path: 'foo-Project', name: 'Foo Project' }. - to change { Project.count }.by(1) + expect { post v3_api('/projects', user), path: 'foo-Project', name: 'Foo Project' } + .to change { Project.count }.by(1) expect(response).to have_http_status(201) project = Project.first @@ -489,8 +519,8 @@ describe API::V3::Projects do end it 'responds with 400 on failure and not project' do - expect { post v3_api("/projects/user/#{user.id}", admin) }. - not_to change { Project.count } + expect { post v3_api("/projects/user/#{user.id}", admin) } + .not_to change { Project.count } expect(response).to have_http_status(400) expect(json_response['error']).to eq('name is missing') @@ -716,8 +746,8 @@ describe API::V3::Projects do get v3_api("/projects", user) expect(response).to have_http_status(200) - expect(json_response.first['permissions']['project_access']['access_level']). - to eq(Gitlab::Access::MASTER) + expect(json_response.first['permissions']['project_access']['access_level']) + .to eq(Gitlab::Access::MASTER) expect(json_response.first['permissions']['group_access']).to be_nil end end @@ -728,8 +758,8 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}", user) expect(response).to have_http_status(200) - expect(json_response['permissions']['project_access']['access_level']). - to eq(Gitlab::Access::MASTER) + expect(json_response['permissions']['project_access']['access_level']) + .to eq(Gitlab::Access::MASTER) expect(json_response['permissions']['group_access']).to be_nil end end @@ -744,8 +774,8 @@ describe API::V3::Projects do expect(response).to have_http_status(200) expect(json_response['permissions']['project_access']).to be_nil - expect(json_response['permissions']['group_access']['access_level']). - to eq(Gitlab::Access::OWNER) + expect(json_response['permissions']['group_access']['access_level']) + .to eq(Gitlab::Access::OWNER) end end end diff --git a/spec/requests/api/v3/snippets_spec.rb b/spec/requests/api/v3/snippets_spec.rb index 4f02b7b1a54..1bc2258ebd3 100644 --- a/spec/requests/api/v3/snippets_spec.rb +++ b/spec/requests/api/v3/snippets_spec.rb @@ -112,21 +112,21 @@ describe API::V3::Snippets do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(visibility_level: Snippet::PRIVATE) }. - to change { Snippet.count }.by(1) + expect { create_snippet(visibility_level: Snippet::PRIVATE) } + .to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the shippet' do - expect { create_snippet(visibility_level: Snippet::PUBLIC) }. - not_to change { Snippet.count } + expect { create_snippet(visibility_level: Snippet::PUBLIC) } + .not_to change { Snippet.count } expect(response).to have_http_status(400) end it 'creates a spam log' do - expect { create_snippet(visibility_level: Snippet::PUBLIC) }. - to change { SpamLog.count }.by(1) + expect { create_snippet(visibility_level: Snippet::PUBLIC) } + .to change { SpamLog.count }.by(1) end end end diff --git a/spec/requests/api/v3/users_spec.rb b/spec/requests/api/v3/users_spec.rb index e9c57f7c6c3..6d7401f9764 100644 --- a/spec/requests/api/v3/users_spec.rb +++ b/spec/requests/api/v3/users_spec.rb @@ -7,6 +7,38 @@ describe API::V3::Users do let(:email) { create(:email, user: user) } let(:ldap_blocked_user) { create(:omniauth_user, provider: 'ldapmain', state: 'ldap_blocked') } + describe 'GET /users' do + context 'when authenticated' do + it 'returns an array of users' do + get v3_api('/users', user) + + expect(response).to have_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + username = user.username + expect(json_response.detect do |user| + user['username'] == username + end['username']).to eq(username) + end + end + + context 'when authenticated as user' do + it 'does not reveal the `is_admin` flag of the user' do + get v3_api('/users', user) + + expect(json_response.first.keys).not_to include 'is_admin' + end + end + + context 'when authenticated as admin' do + it 'reveals the `is_admin` flag of the user' do + get v3_api('/users', admin) + + expect(json_response.first.keys).to include 'is_admin' + end + end + end + describe 'GET /user/:id/keys' do before { admin } diff --git a/spec/requests/api/variables_spec.rb b/spec/requests/api/variables_spec.rb index 83673864fe7..e0975024b80 100644 --- a/spec/requests/api/variables_spec.rb +++ b/spec/requests/api/variables_spec.rb @@ -82,6 +82,17 @@ describe API::Variables do expect(json_response['protected']).to be_truthy end + it 'creates variable with optional attributes' do + expect do + post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2' + end.to change{project.variables.count}.by(1) + + expect(response).to have_http_status(201) + expect(json_response['key']).to eq('TEST_VARIABLE_2') + expect(json_response['value']).to eq('VALUE_2') + expect(json_response['protected']).to be_falsey + end + it 'does not allow to duplicate variable key' do expect do post api("/projects/#{project.id}/variables", user), key: variable.key, value: 'VALUE_2' diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index 83c675792f4..c969d08d0dd 100644 --- a/spec/requests/ci/api/builds_spec.rb +++ b/spec/requests/ci/api/builds_spec.rb @@ -91,8 +91,8 @@ describe Ci::API::Builds do context 'when concurrently updating build' do before do - expect_any_instance_of(Ci::Build).to receive(:run!). - and_raise(ActiveRecord::StaleObjectError.new(nil, nil)) + expect_any_instance_of(Ci::Build).to receive(:run!) + .and_raise(ActiveRecord::StaleObjectError.new(nil, nil)) end it 'returns a conflict' do @@ -670,8 +670,8 @@ describe Ci::API::Builds do build.reload expect(response).to have_http_status(201) expect(json_response['artifacts_expire_at']).not_to be_empty - expect(build.artifacts_expire_at). - to be_within(5.minutes).of(7.days.from_now) + expect(build.artifacts_expire_at) + .to be_within(5.minutes).of(7.days.from_now) end end diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index b08148eca3c..185679e1a0f 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -483,8 +483,8 @@ describe 'Git HTTP requests', lib: true do context 'when LDAP is configured' do before do allow(Gitlab::LDAP::Config).to receive(:enabled?).and_return(true) - allow_any_instance_of(Gitlab::LDAP::Authentication). - to receive(:login).and_return(nil) + allow_any_instance_of(Gitlab::LDAP::Authentication) + .to receive(:login).and_return(nil) end it 'does not display the personal access token error message' do diff --git a/spec/rubocop/cop/migration/update_column_in_batches_spec.rb b/spec/rubocop/cop/migration/update_column_in_batches_spec.rb index 968dcd6232e..38b8f439a55 100644 --- a/spec/rubocop/cop/migration/update_column_in_batches_spec.rb +++ b/spec/rubocop/cop/migration/update_column_in_batches_spec.rb @@ -54,8 +54,8 @@ describe RuboCop::Cop::Migration::UpdateColumnInBatches do aggregate_failures do expect(cop.offenses.size).to eq(1) expect(cop.offenses.map(&:line)).to eq([2]) - expect(cop.offenses.first.message). - to include("`#{relative_spec_filepath}`") + expect(cop.offenses.first.message) + .to include("`#{relative_spec_filepath}`") end end end diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index 1557cb3c938..efcaccc254e 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -62,6 +62,10 @@ describe Ci::ProcessPipelineService, '#execute', :services do fail_running_or_pending expect(builds_statuses).to eq %w(failed pending) + + fail_running_or_pending + + expect(pipeline.reload).to be_success end end diff --git a/spec/services/create_deployment_service_spec.rb b/spec/services/create_deployment_service_spec.rb index 6cf4342ad4c..dfab6ebf372 100644 --- a/spec/services/create_deployment_service_spec.rb +++ b/spec/services/create_deployment_service_spec.rb @@ -122,6 +122,61 @@ describe CreateDeploymentService, services: true do end end + describe '#expanded_environment_url' do + subject { service.send(:expanded_environment_url) } + + context 'when yaml environment uses $CI_COMMIT_REF_NAME' do + let(:job) do + create(:ci_build, + ref: 'master', + options: { environment: { url: 'http://review/$CI_COMMIT_REF_NAME' } }) + end + + it { is_expected.to eq('http://review/master') } + end + + context 'when yaml environment uses $CI_ENVIRONMENT_SLUG' do + let(:job) do + create(:ci_build, + ref: 'master', + environment: 'production', + options: { environment: { url: 'http://review/$CI_ENVIRONMENT_SLUG' } }) + end + + let!(:environment) do + create(:environment, + project: job.project, + name: 'production', + slug: 'prod-slug', + external_url: 'http://review/old') + end + + it { is_expected.to eq('http://review/prod-slug') } + end + + context 'when yaml environment uses yaml_variables containing symbol keys' do + let(:job) do + create(:ci_build, + yaml_variables: [{ key: :APP_HOST, value: 'host' }], + options: { environment: { url: 'http://review/$APP_HOST' } }) + end + + it { is_expected.to eq('http://review/host') } + end + + context 'when yaml environment does not have url' do + let(:job) { create(:ci_build, environment: 'staging') } + + let!(:environment) do + create(:environment, project: job.project, name: job.environment) + end + + it 'returns the external_url from persisted environment' do + is_expected.to be_nil + end + end + end + describe 'processing of builds' do shared_examples 'does not create deployment' do it 'does not create a new deployment' do diff --git a/spec/services/emails/create_service_spec.rb b/spec/services/emails/create_service_spec.rb new file mode 100644 index 00000000000..c1f477f551e --- /dev/null +++ b/spec/services/emails/create_service_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Emails::CreateService, services: true do + let(:user) { create(:user) } + let(:opts) { { email: 'new@email.com' } } + + subject(:service) { described_class.new(user, opts) } + + describe '#execute' do + it 'creates an email with valid attributes' do + expect { service.execute }.to change { Email.count }.by(1) + expect(Email.where(opts)).not_to be_empty + end + + it 'has the right user association' do + service.execute + + expect(user.emails).to eq(Email.where(opts)) + end + end +end diff --git a/spec/services/emails/destroy_service_spec.rb b/spec/services/emails/destroy_service_spec.rb new file mode 100644 index 00000000000..5e7ab4a40af --- /dev/null +++ b/spec/services/emails/destroy_service_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe Emails::DestroyService, services: true do + let!(:user) { create(:user) } + let!(:email) { create(:email, user: user) } + + subject(:service) { described_class.new(user, email: email.email) } + + describe '#execute' do + it 'removes an email' do + expect { service.execute }.to change { user.emails.count }.by(-1) + end + end +end diff --git a/spec/services/files/update_service_spec.rb b/spec/services/files/update_service_spec.rb index 16bca66766a..cc950ae6bb3 100644 --- a/spec/services/files/update_service_spec.rb +++ b/spec/services/files/update_service_spec.rb @@ -32,8 +32,8 @@ describe Files::UpdateService do let(:last_commit_sha) { "foo" } it "returns a hash with the correct error message and a :error status " do - expect { subject.execute }. - to raise_error(Files::UpdateService::FileChangedError, + expect { subject.execute } + .to raise_error(Files::UpdateService::FileChangedError, "You are attempting to update a file that has changed since you started editing it.") end end diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index bcd1fb64ab9..ca827fc0f39 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -158,8 +158,8 @@ describe GitPushService, services: true do context "Updates merge requests" do it "when pushing a new branch for the first time" do - expect(UpdateMergeRequestsWorker).to receive(:perform_async). - with(project.id, user.id, @blankrev, 'newrev', 'refs/heads/master') + expect(UpdateMergeRequestsWorker).to receive(:perform_async) + .with(project.id, user.id, @blankrev, 'newrev', 'refs/heads/master') execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master' ) end end @@ -283,8 +283,8 @@ describe GitPushService, services: true do author_email: commit_author.email ) - allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit). - and_return(commit) + allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit) + .and_return(commit) allow(project.repository).to receive(:commits_between).and_return([commit]) end @@ -341,8 +341,8 @@ describe GitPushService, services: true do committed_date: commit_time ) - allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit). - and_return(commit) + allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit) + .and_return(commit) allow(project.repository).to receive(:commits_between).and_return([commit]) end @@ -377,11 +377,11 @@ describe GitPushService, services: true do author_email: commit_author.email ) - allow(project.repository).to receive(:commits_between). - and_return([closing_commit]) + allow(project.repository).to receive(:commits_between) + .and_return([closing_commit]) - allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit). - and_return(closing_commit) + allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit) + .and_return(closing_commit) project.team << [commit_author, :master] end @@ -403,8 +403,8 @@ describe GitPushService, services: true do end it "doesn't close issues when external issue tracker is in use" do - allow_any_instance_of(Project).to receive(:default_issues_tracker?). - and_return(false) + allow_any_instance_of(Project).to receive(:default_issues_tracker?) + .and_return(false) external_issue_tracker = double(title: 'My Tracker', issue_path: issue.iid, reference_pattern: project.issue_reference_pattern) allow_any_instance_of(Project).to receive(:external_issue_tracker).and_return(external_issue_tracker) @@ -598,13 +598,13 @@ describe GitPushService, services: true do commit = double(:commit) diff = double(:diff, new_path: 'README.md') - expect(commit).to receive(:raw_deltas). - and_return([diff]) + expect(commit).to receive(:raw_deltas) + .and_return([diff]) service.push_commits = [commit] - expect(ProjectCacheWorker).to receive(:perform_async). - with(project.id, %i(readme), %i(commit_count repository_size)) + expect(ProjectCacheWorker).to receive(:perform_async) + .with(project.id, %i(readme), %i(commit_count repository_size)) service.update_caches end @@ -616,9 +616,9 @@ describe GitPushService, services: true do end it 'does not flush any conditional caches' do - expect(ProjectCacheWorker).to receive(:perform_async). - with(project.id, [], %i(commit_count repository_size)). - and_call_original + expect(ProjectCacheWorker).to receive(:perform_async) + .with(project.id, [], %i(commit_count repository_size)) + .and_call_original service.update_caches end @@ -635,8 +635,8 @@ describe GitPushService, services: true do end it 'only schedules a limited number of commits' do - allow(service).to receive(:push_commits). - and_return(Array.new(1000, double(:commit, to_hash: {}, matches_cross_reference_regex?: true))) + allow(service).to receive(:push_commits) + .and_return(Array.new(1000, double(:commit, to_hash: {}, matches_cross_reference_regex?: true))) expect(ProcessCommitWorker).to receive(:perform_async).exactly(100).times @@ -644,8 +644,8 @@ describe GitPushService, services: true do end it "skips commits which don't include cross-references" do - allow(service).to receive(:push_commits). - and_return([double(:commit, to_hash: {}, matches_cross_reference_regex?: false)]) + allow(service).to receive(:push_commits) + .and_return([double(:commit, to_hash: {}, matches_cross_reference_regex?: false)]) expect(ProcessCommitWorker).not_to receive(:perform_async) diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index be0e829880e..d6f4c694069 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -18,26 +18,26 @@ describe Issues::CloseService, services: true do let(:service) { described_class.new(project, user) } it 'checks if the user is authorized to update the issue' do - expect(service).to receive(:can?).with(user, :update_issue, issue). - and_call_original + expect(service).to receive(:can?).with(user, :update_issue, issue) + .and_call_original service.execute(issue) end it 'does not close the issue when the user is not authorized to do so' do - allow(service).to receive(:can?).with(user, :update_issue, issue). - and_return(false) + allow(service).to receive(:can?).with(user, :update_issue, issue) + .and_return(false) expect(service).not_to receive(:close_issue) expect(service.execute(issue)).to eq(issue) end it 'closes the issue when the user is authorized to do so' do - allow(service).to receive(:can?).with(user, :update_issue, issue). - and_return(true) + allow(service).to receive(:can?).with(user, :update_issue, issue) + .and_return(true) - expect(service).to receive(:close_issue). - with(issue, commit: nil, notifications: true, system_note: true) + expect(service).to receive(:close_issue) + .with(issue, commit: nil, notifications: true, system_note: true) service.execute(issue) end diff --git a/spec/services/labels/promote_service_spec.rb b/spec/services/labels/promote_service_spec.rb index 4b90ad19640..500afdfb916 100644 --- a/spec/services/labels/promote_service_spec.rb +++ b/spec/services/labels/promote_service_spec.rb @@ -66,9 +66,9 @@ describe Labels::PromoteService, services: true do end it 'recreates the label as a group label' do - expect { service.execute(project_label_1_1) }. - to change(project_1.labels, :count).by(-1). - and change(group_1.labels, :count).by(1) + expect { service.execute(project_label_1_1) } + .to change(project_1.labels, :count).by(-1) + .and change(group_1.labels, :count).by(1) expect(new_label).not_to be_nil end diff --git a/spec/services/members/destroy_service_spec.rb b/spec/services/members/destroy_service_spec.rb index 41450c67d7e..9ab7839430c 100644 --- a/spec/services/members/destroy_service_spec.rb +++ b/spec/services/members/destroy_service_spec.rb @@ -104,8 +104,8 @@ describe Members::DestroyService, services: true do let(:params) { { id: project.members.find_by!(user_id: user.id).id } } it 'destroys the member' do - expect { described_class.new(project, user, params).execute }. - to change { project.members.count }.by(-1) + expect { described_class.new(project, user, params).execute } + .to change { project.members.count }.by(-1) end end end diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb index 154f30aac3b..074d4672b06 100644 --- a/spec/services/merge_requests/close_service_spec.rb +++ b/spec/services/merge_requests/close_service_spec.rb @@ -32,8 +32,8 @@ describe MergeRequests::CloseService, services: true do it { expect(@merge_request).to be_closed } it 'executes hooks with close action' do - expect(service).to have_received(:execute_hooks). - with(@merge_request, 'close') + expect(service).to have_received(:execute_hooks) + .with(@merge_request, 'close') end it 'sends email to user2 about assign of new merge_request' do diff --git a/spec/services/merge_requests/conflicts/resolve_service_spec.rb b/spec/services/merge_requests/conflicts/resolve_service_spec.rb index c77e6e9cd50..6f49a65d795 100644 --- a/spec/services/merge_requests/conflicts/resolve_service_spec.rb +++ b/spec/services/merge_requests/conflicts/resolve_service_spec.rb @@ -64,9 +64,9 @@ describe MergeRequests::Conflicts::ResolveService do end it 'creates a commit with the correct parents' do - expect(merge_request.source_branch_head.parents.map(&:id)). - to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 - 824be604a34828eb682305f0d963056cfac87b2d)) + expect(merge_request.source_branch_head.parents.map(&:id)) + .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 + 824be604a34828eb682305f0d963056cfac87b2d)) end end @@ -129,9 +129,8 @@ describe MergeRequests::Conflicts::ResolveService do it 'creates a commit with the correct parents' do resolve_conflicts - expect(merge_request_from_fork.source_branch_head.parents.map(&:id)). - to eq(['404fa3fc7c2c9b5dacff102f353bdf55b1be2813', - target_head]) + expect(merge_request_from_fork.source_branch_head.parents.map(&:id)) + .to eq(['404fa3fc7c2c9b5dacff102f353bdf55b1be2813', target_head]) end end end @@ -169,9 +168,9 @@ describe MergeRequests::Conflicts::ResolveService do end it 'creates a commit with the correct parents' do - expect(merge_request.source_branch_head.parents.map(&:id)). - to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 - 824be604a34828eb682305f0d963056cfac87b2d)) + expect(merge_request.source_branch_head.parents.map(&:id)) + .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 + 824be604a34828eb682305f0d963056cfac87b2d)) end it 'sets the content to the content given' do @@ -204,8 +203,8 @@ describe MergeRequests::Conflicts::ResolveService do end it 'raises a MissingResolution error' do - expect { service.execute(user, invalid_params) }. - to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { service.execute(user, invalid_params) } + .to raise_error(Gitlab::Conflict::File::MissingResolution) end end @@ -230,8 +229,8 @@ describe MergeRequests::Conflicts::ResolveService do end it 'raises a MissingResolution error' do - expect { service.execute(user, invalid_params) }. - to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { service.execute(user, invalid_params) } + .to raise_error(Gitlab::Conflict::File::MissingResolution) end end @@ -250,8 +249,8 @@ describe MergeRequests::Conflicts::ResolveService do end it 'raises a MissingFiles error' do - expect { service.execute(user, invalid_params) }. - to raise_error(described_class::MissingFiles) + expect { service.execute(user, invalid_params) } + .to raise_error(described_class::MissingFiles) end end end diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb index 2026b7f6510..36a2b672473 100644 --- a/spec/services/merge_requests/create_service_spec.rb +++ b/spec/services/merge_requests/create_service_spec.rb @@ -83,9 +83,9 @@ describe MergeRequests::CreateService, services: true do let!(:pipeline_3) { create(:ci_pipeline, project: project, ref: "other_branch", project_id: project.id) } before do - project.merge_requests. - where(source_branch: opts[:source_branch], target_branch: opts[:target_branch]). - destroy_all + project.merge_requests + .where(source_branch: opts[:source_branch], target_branch: opts[:target_branch]) + .destroy_all end it 'sets head pipeline' do diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index b3b188a805f..711059208c1 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -141,9 +141,9 @@ describe MergeRequests::MergeService, services: true do end it 'removes the source branch' do - expect(DeleteBranchService).to receive(:new). - with(merge_request.source_project, merge_request.author). - and_call_original + expect(DeleteBranchService).to receive(:new) + .with(merge_request.source_project, merge_request.author) + .and_call_original service.execute(merge_request) end end diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 1f109eab268..671a932441e 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -57,8 +57,8 @@ describe MergeRequests::RefreshService, services: true do end it 'executes hooks with update action' do - expect(refresh_service).to have_received(:execute_hooks). - with(@merge_request, 'update', @oldrev) + expect(refresh_service).to have_received(:execute_hooks) + .with(@merge_request, 'update', @oldrev) expect(@merge_request.notes).not_to be_empty expect(@merge_request).to be_open @@ -83,8 +83,8 @@ describe MergeRequests::RefreshService, services: true do end it 'executes hooks with update action' do - expect(refresh_service).to have_received(:execute_hooks). - with(@merge_request, 'update', @oldrev) + expect(refresh_service).to have_received(:execute_hooks) + .with(@merge_request, 'update', @oldrev) expect(@merge_request.notes).not_to be_empty expect(@merge_request).to be_open @@ -146,8 +146,8 @@ describe MergeRequests::RefreshService, services: true do end it 'executes hooks with update action' do - expect(refresh_service).to have_received(:execute_hooks). - with(@fork_merge_request, 'update', @oldrev) + expect(refresh_service).to have_received(:execute_hooks) + .with(@fork_merge_request, 'update', @oldrev) expect(@merge_request.notes).to be_empty expect(@merge_request).to be_open @@ -228,8 +228,8 @@ describe MergeRequests::RefreshService, services: true do let(:refresh_service) { service.new(@fork_project, @user) } it 'refreshes the merge request' do - expect(refresh_service).to receive(:execute_hooks). - with(@fork_merge_request, 'update', Gitlab::Git::BLANK_SHA) + expect(refresh_service).to receive(:execute_hooks) + .with(@fork_merge_request, 'update', Gitlab::Git::BLANK_SHA) allow_any_instance_of(Repository).to receive(:merge_base).and_return(@oldrev) refresh_service.execute(Gitlab::Git::BLANK_SHA, @newrev, 'refs/heads/master') diff --git a/spec/services/merge_requests/reopen_service_spec.rb b/spec/services/merge_requests/reopen_service_spec.rb index b6d4db2f922..6cc403bdb7f 100644 --- a/spec/services/merge_requests/reopen_service_spec.rb +++ b/spec/services/merge_requests/reopen_service_spec.rb @@ -31,8 +31,8 @@ describe MergeRequests::ReopenService, services: true do it { expect(merge_request).to be_reopened } it 'executes hooks with reopen action' do - expect(service).to have_received(:execute_hooks). - with(merge_request, 'reopen') + expect(service).to have_received(:execute_hooks) + .with(merge_request, 'reopen') end it 'sends email to user2 about reopen of merge_request' do diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index fd46020bbdb..ec15b5cac14 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -78,8 +78,8 @@ describe MergeRequests::UpdateService, services: true do end it 'executes hooks with update action' do - expect(service).to have_received(:execute_hooks). - with(@merge_request, 'update') + expect(service).to have_received(:execute_hooks) + .with(@merge_request, 'update') end it 'sends email to user2 about assign of new merge request and email to user3 about merge request unassignment' do @@ -195,8 +195,8 @@ describe MergeRequests::UpdateService, services: true do head_pipeline_of: merge_request ) - expect(MergeRequests::MergeWhenPipelineSucceedsService).to receive(:new).with(project, user). - and_return(service_mock) + expect(MergeRequests::MergeWhenPipelineSucceedsService).to receive(:new).with(project, user) + .and_return(service_mock) expect(service_mock).to receive(:execute).with(merge_request) end diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb index 0d6dd28e332..697dc18feb0 100644 --- a/spec/services/projects/destroy_service_spec.rb +++ b/spec/services/projects/destroy_service_spec.rb @@ -15,8 +15,9 @@ describe Projects::DestroyService, services: true do shared_examples 'deleting the project' do it 'deletes the project' do expect(Project.unscoped.all).not_to include(project) - expect(Dir.exist?(path)).to be_falsey - expect(Dir.exist?(remove_path)).to be_falsey + + expect(project.gitlab_shell.exists?(project.repository_storage_path, path + '.git')).to be_falsey + expect(project.gitlab_shell.exists?(project.repository_storage_path, remove_path + '.git')).to be_falsey end end diff --git a/spec/services/projects/housekeeping_service_spec.rb b/spec/services/projects/housekeeping_service_spec.rb index fff12beed71..ebed802708d 100644 --- a/spec/services/projects/housekeeping_service_spec.rb +++ b/spec/services/projects/housekeeping_service_spec.rb @@ -66,14 +66,14 @@ describe Projects::HousekeepingService do allow(subject).to receive(:lease_key).and_return(:the_lease_key) # At push 200 - expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :gc, :the_lease_key, :the_uuid). - exactly(1).times + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :gc, :the_lease_key, :the_uuid) + .exactly(1).times # At push 50, 100, 150 - expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :full_repack, :the_lease_key, :the_uuid). - exactly(3).times + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :full_repack, :the_lease_key, :the_uuid) + .exactly(3).times # At push 10, 20, ... (except those above) - expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :incremental_repack, :the_lease_key, :the_uuid). - exactly(16).times + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :incremental_repack, :the_lease_key, :the_uuid) + .exactly(16).times 201.times do subject.increment! diff --git a/spec/services/projects/import_service_spec.rb b/spec/services/projects/import_service_spec.rb index 44db299812f..e855de38037 100644 --- a/spec/services/projects/import_service_spec.rb +++ b/spec/services/projects/import_service_spec.rb @@ -111,11 +111,11 @@ describe Projects::ImportService, services: true do end it 'flushes various caches' do - allow_any_instance_of(Repository).to receive(:fetch_remote). - and_return(true) + allow_any_instance_of(Repository).to receive(:fetch_remote) + .and_return(true) - allow_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute). - and_return(true) + allow_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute) + .and_return(true) expect_any_instance_of(Repository).to receive(:expire_content_cache) diff --git a/spec/services/projects/propagate_service_template_spec.rb b/spec/services/projects/propagate_service_template_spec.rb index 8a6a9f09f74..a6d43c4f0f1 100644 --- a/spec/services/projects/propagate_service_template_spec.rb +++ b/spec/services/projects/propagate_service_template_spec.rb @@ -60,8 +60,8 @@ describe Projects::PropagateServiceTemplate, services: true do Service.build_from_template(project.id, service_template).save! Service.build_from_template(project.id, other_service).save! - expect { described_class.propagate(service_template) }. - not_to change { Service.count } + expect { described_class.propagate(service_template) } + .not_to change { Service.count } end it 'creates the service containing the template attributes' do @@ -90,8 +90,8 @@ describe Projects::PropagateServiceTemplate, services: true do it 'updates the project external tracker' do service_template.update!(category: 'issue_tracker', default: false) - expect { described_class.propagate(service_template) }. - to change { project.reload.has_external_issue_tracker }.to(true) + expect { described_class.propagate(service_template) } + .to change { project.reload.has_external_issue_tracker }.to(true) end end @@ -99,8 +99,8 @@ describe Projects::PropagateServiceTemplate, services: true do it 'updates the project external tracker' do service_template.update!(type: 'ExternalWikiService') - expect { described_class.propagate(service_template) }. - to change { project.reload.has_external_wiki }.to(true) + expect { described_class.propagate(service_template) } + .to change { project.reload.has_external_wiki }.to(true) end end end diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 5d2f4cf17fb..76c52d55ae5 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -7,10 +7,10 @@ describe Projects::TransferService, services: true do context 'namespace -> namespace' do before do - allow_any_instance_of(Gitlab::UploadsTransfer). - to receive(:move_project).and_return(true) - allow_any_instance_of(Gitlab::PagesTransfer). - to receive(:move_project).and_return(true) + allow_any_instance_of(Gitlab::UploadsTransfer) + .to receive(:move_project).and_return(true) + allow_any_instance_of(Gitlab::PagesTransfer) + .to receive(:move_project).and_return(true) group.add_owner(user) @result = transfer_project(project, user, group) end @@ -19,6 +19,67 @@ describe Projects::TransferService, services: true do it { expect(project.namespace).to eq(group) } end + context 'when transfer succeeds' do + before do + group.add_owner(user) + end + + it 'sends notifications' do + expect_any_instance_of(NotificationService).to receive(:project_was_moved) + + transfer_project(project, user, group) + end + + it 'executes system hooks' do + expect_any_instance_of(Projects::TransferService).to receive(:execute_system_hooks) + + transfer_project(project, user, group) + end + end + + context 'when transfer fails' do + let!(:original_path) { project_path(project) } + + def attempt_project_transfer + expect do + transfer_project(project, user, group) + end.to raise_error(ActiveRecord::ActiveRecordError) + end + + before do + group.add_owner(user) + + expect_any_instance_of(Labels::TransferService).to receive(:execute).and_raise(ActiveRecord::StatementInvalid, "PG ERROR") + end + + def project_path(project) + File.join(project.repository_storage_path, "#{project.path_with_namespace}.git") + end + + def current_path + project_path(project) + end + + it 'rolls back repo location' do + attempt_project_transfer + + expect(Dir.exist?(original_path)).to be_truthy + expect(original_path).to eq current_path + end + + it "doesn't send move notifications" do + expect_any_instance_of(NotificationService).not_to receive(:project_was_moved) + + attempt_project_transfer + end + + it "doesn't run system hooks" do + expect_any_instance_of(Projects::TransferService).not_to receive(:execute_system_hooks) + + attempt_project_transfer + end + end + context 'namespace -> no namespace' do before do @result = transfer_project(project, user, nil) @@ -112,9 +173,9 @@ describe Projects::TransferService, services: true do end it 'only schedules a single job for every user' do - expect(UserProjectAccessChangedService).to receive(:new). - with([owner.id, group_member.id]). - and_call_original + expect(UserProjectAccessChangedService).to receive(:new) + .with([owner.id, group_member.id]) + .and_call_original transfer_project(project, owner, group) end diff --git a/spec/services/projects/unlink_fork_service_spec.rb b/spec/services/projects/unlink_fork_service_spec.rb index 23f5555d3e0..d34652bd7ac 100644 --- a/spec/services/projects/unlink_fork_service_spec.rb +++ b/spec/services/projects/unlink_fork_service_spec.rb @@ -12,9 +12,9 @@ describe Projects::UnlinkForkService, services: true do let(:mr_close_service) { MergeRequests::CloseService.new(fork_project, user) } before do - allow(MergeRequests::CloseService).to receive(:new). - with(fork_project, user). - and_return(mr_close_service) + allow(MergeRequests::CloseService).to receive(:new) + .with(fork_project, user) + .and_return(mr_close_service) end it 'close all pending merge requests' do diff --git a/spec/services/submit_usage_ping_service_spec.rb b/spec/services/submit_usage_ping_service_spec.rb index 63a1e78f274..817fa4262d5 100644 --- a/spec/services/submit_usage_ping_service_spec.rb +++ b/spec/services/submit_usage_ping_service_spec.rb @@ -92,8 +92,8 @@ describe SubmitUsagePingService do end def stub_response(body) - stub_request(:post, 'https://version.gitlab.com/usage_data'). - to_return( + stub_request(:post, 'https://version.gitlab.com/usage_data') + .to_return( headers: { 'Content-Type' => 'application/json' }, body: body.to_json ) diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 9295c09aefc..8d3dafafab2 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -333,8 +333,8 @@ describe SystemNoteService, services: true do end it 'sets the note text' do - expect(subject.note). - to eq "changed title from **{-Old title-}** to **{+Lorem ipsum+}**" + expect(subject.note) + .to eq "changed title from **{-Old title-}** to **{+Lorem ipsum+}**" end end end @@ -521,8 +521,8 @@ describe SystemNoteService, services: true do context 'when mentioner is not a MergeRequest' do it 'is falsey' do mentioner = noteable.dup - expect(described_class.cross_reference_disallowed?(noteable, mentioner)). - to be_falsey + expect(described_class.cross_reference_disallowed?(noteable, mentioner)) + .to be_falsey end end @@ -533,14 +533,14 @@ describe SystemNoteService, services: true do it 'is truthy when noteable is in commits' do expect(mentioner).to receive(:commits).and_return([noteable]) - expect(described_class.cross_reference_disallowed?(noteable, mentioner)). - to be_truthy + expect(described_class.cross_reference_disallowed?(noteable, mentioner)) + .to be_truthy end it 'is falsey when noteable is not in commits' do expect(mentioner).to receive(:commits).and_return([]) - expect(described_class.cross_reference_disallowed?(noteable, mentioner)). - to be_falsey + expect(described_class.cross_reference_disallowed?(noteable, mentioner)) + .to be_falsey end end @@ -548,8 +548,8 @@ describe SystemNoteService, services: true do let(:noteable) { ExternalIssue.new('EXT-1234', project) } it 'is truthy' do mentioner = noteable.dup - expect(described_class.cross_reference_disallowed?(noteable, mentioner)). - to be_truthy + expect(described_class.cross_reference_disallowed?(noteable, mentioner)) + .to be_truthy end end end @@ -566,13 +566,13 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(noteable, commit0)). - to be_truthy + expect(described_class.cross_reference_exists?(noteable, commit0)) + .to be_truthy end it 'is falsey when not already mentioned' do - expect(described_class.cross_reference_exists?(noteable, commit1)). - to be_falsey + expect(described_class.cross_reference_exists?(noteable, commit1)) + .to be_falsey end context 'legacy capitalized cross reference' do @@ -583,8 +583,8 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(noteable, commit0)). - to be_truthy + expect(described_class.cross_reference_exists?(noteable, commit0)) + .to be_truthy end end end @@ -596,13 +596,13 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(commit0, commit1)). - to be_truthy + expect(described_class.cross_reference_exists?(commit0, commit1)) + .to be_truthy end it 'is falsey when not already mentioned' do - expect(described_class.cross_reference_exists?(commit1, commit0)). - to be_falsey + expect(described_class.cross_reference_exists?(commit1, commit0)) + .to be_falsey end context 'legacy capitalized cross reference' do @@ -613,8 +613,8 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(commit0, commit1)). - to be_truthy + expect(described_class.cross_reference_exists?(commit0, commit1)) + .to be_truthy end end end @@ -629,8 +629,8 @@ describe SystemNoteService, services: true do end it 'is true when a fork mentions an external issue' do - expect(described_class.cross_reference_exists?(noteable, commit2)). - to be true + expect(described_class.cross_reference_exists?(noteable, commit2)) + .to be true end context 'legacy capitalized cross reference' do @@ -640,8 +640,8 @@ describe SystemNoteService, services: true do end it 'is true when a fork mentions an external issue' do - expect(described_class.cross_reference_exists?(noteable, commit2)). - to be true + expect(described_class.cross_reference_exists?(noteable, commit2)) + .to be true end end end diff --git a/spec/services/tags/create_service_spec.rb b/spec/services/tags/create_service_spec.rb index b9121b1de49..9f143cc5667 100644 --- a/spec/services/tags/create_service_spec.rb +++ b/spec/services/tags/create_service_spec.rb @@ -26,9 +26,9 @@ describe Tags::CreateService, services: true do context 'when tag already exists' do it 'returns an error' do - expect(repository).to receive(:add_tag). - with(user, 'v1.1.0', 'master', 'Foo'). - and_raise(Rugged::TagError) + expect(repository).to receive(:add_tag) + .with(user, 'v1.1.0', 'master', 'Foo') + .and_raise(Rugged::TagError) response = service.execute('v1.1.0', 'master', 'Foo') @@ -39,9 +39,9 @@ describe Tags::CreateService, services: true do context 'when pre-receive hook fails' do it 'returns an error' do - expect(repository).to receive(:add_tag). - with(user, 'v1.1.0', 'master', 'Foo'). - and_raise(GitHooksService::PreReceiveError, 'something went wrong') + expect(repository).to receive(:add_tag) + .with(user, 'v1.1.0', 'master', 'Foo') + .and_raise(GitHooksService::PreReceiveError, 'something went wrong') response = service.execute('v1.1.0', 'master', 'Foo') diff --git a/spec/services/user_project_access_changed_service_spec.rb b/spec/services/user_project_access_changed_service_spec.rb index b4efe7de431..14a5e40350a 100644 --- a/spec/services/user_project_access_changed_service_spec.rb +++ b/spec/services/user_project_access_changed_service_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' describe UserProjectAccessChangedService do describe '#execute' do it 'schedules the user IDs' do - expect(AuthorizedProjectsWorker).to receive(:bulk_perform_and_wait). - with([[1], [2]]) + expect(AuthorizedProjectsWorker).to receive(:bulk_perform_and_wait) + .with([[1], [2]]) described_class.new([1, 2]).execute end diff --git a/spec/services/users/activity_service_spec.rb b/spec/services/users/activity_service_spec.rb index 8d67ebe3231..2e009d4ce1c 100644 --- a/spec/services/users/activity_service_spec.rb +++ b/spec/services/users/activity_service_spec.rb @@ -41,8 +41,8 @@ describe Users::ActivityService, services: true do end def last_hour_user_ids - Gitlab::UserActivities.new. - select { |k, v| v >= 1.hour.ago.to_i.to_s }. - map { |k, _| k.to_i } + Gitlab::UserActivities.new + .select { |k, v| v >= 1.hour.ago.to_i.to_s } + .map { |k, _| k.to_i } end end diff --git a/spec/services/users/refresh_authorized_projects_service_spec.rb b/spec/services/users/refresh_authorized_projects_service_spec.rb index 8c40d25e00c..b65cadbb2f5 100644 --- a/spec/services/users/refresh_authorized_projects_service_spec.rb +++ b/spec/services/users/refresh_authorized_projects_service_spec.rb @@ -10,11 +10,11 @@ describe Users::RefreshAuthorizedProjectsService do describe '#execute', :redis do it 'refreshes the authorizations using a lease' do - expect_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). - and_return('foo') + expect_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) + .and_return('foo') - expect(Gitlab::ExclusiveLease).to receive(:cancel). - with(an_instance_of(String), 'foo') + expect(Gitlab::ExclusiveLease).to receive(:cancel) + .with(an_instance_of(String), 'foo') expect(service).to receive(:execute_without_lease) @@ -29,11 +29,11 @@ describe Users::RefreshAuthorizedProjectsService do it 'updates the authorized projects of the user' do project2 = create(:empty_project) - to_remove = user.project_authorizations. - create!(project: project2, access_level: Gitlab::Access::MASTER) + to_remove = user.project_authorizations + .create!(project: project2, access_level: Gitlab::Access::MASTER) - expect(service).to receive(:update_authorizations). - with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) + expect(service).to receive(:update_authorizations) + .with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) service.execute_without_lease end @@ -41,11 +41,11 @@ describe Users::RefreshAuthorizedProjectsService do it 'sets the access level of a project to the highest available level' do user.project_authorizations.delete_all - to_remove = user.project_authorizations. - create!(project: project, access_level: Gitlab::Access::DEVELOPER) + to_remove = user.project_authorizations + .create!(project: project, access_level: Gitlab::Access::DEVELOPER) - expect(service).to receive(:update_authorizations). - with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) + expect(service).to receive(:update_authorizations) + .with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) service.execute_without_lease end diff --git a/spec/services/users/update_service_spec.rb b/spec/services/users/update_service_spec.rb new file mode 100644 index 00000000000..0b2f840c462 --- /dev/null +++ b/spec/services/users/update_service_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe Users::UpdateService, services: true do + let(:user) { create(:user) } + + describe '#execute' do + it 'updates the name' do + result = update_user(user, name: 'New Name') + + expect(result).to eq(status: :success) + expect(user.name).to eq('New Name') + end + + it 'returns an error result when record cannot be updated' do + expect do + update_user(user, { email: 'invalid' }) + end.not_to change { user.reload.email } + end + + def update_user(user, opts) + described_class.new(user, opts).execute + end + end + + describe '#execute!' do + it 'updates the name' do + result = update_user(user, name: 'New Name') + + expect(result).to be true + expect(user.name).to eq('New Name') + end + + it 'raises an error when record cannot be updated' do + expect do + update_user(user, email: 'invalid') + end.to raise_error(ActiveRecord::RecordInvalid) + end + + def update_user(user, opts) + described_class.new(user, opts).execute! + end + end +end diff --git a/spec/support/api/schema_matcher.rb b/spec/support/api/schema_matcher.rb index e42d727672b..dff0dfba675 100644 --- a/spec/support/api/schema_matcher.rb +++ b/spec/support/api/schema_matcher.rb @@ -1,8 +1,16 @@ +def schema_path(schema) + schema_directory = "#{Dir.pwd}/spec/fixtures/api/schemas" + "#{schema_directory}/#{schema}.json" +end + RSpec::Matchers.define :match_response_schema do |schema, **options| match do |response| - schema_directory = "#{Dir.pwd}/spec/fixtures/api/schemas" - schema_path = "#{schema_directory}/#{schema}.json" + JSON::Validator.validate!(schema_path(schema), response.body, options) + end +end - JSON::Validator.validate!(schema_path, response.body, options) +RSpec::Matchers.define :match_schema do |schema, **options| + match do |data| + JSON::Validator.validate!(schema_path(schema), data, options) end end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 4aa81a03558..3e5d6cf1364 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -36,12 +36,13 @@ RSpec.configure do |config| $capybara_server_already_started = true end - config.after(:each, :js) do + config.after(:each, :js) do |example| # capybara/rspec already calls Capybara.reset_sessions! in an `after` hook, # but `block_and_wait_for_requests_complete` is called before it so by # calling it explicitely here, we prevent any new requests from being fired # See https://github.com/teamcapybara/capybara/blob/ffb41cfad620de1961bb49b1562a9fa9b28c0903/lib/capybara/rspec.rb#L20-L25 - Capybara.reset_sessions! + # We don't reset the session when the example failed, because we need capybara-screenshot to have access to it. + Capybara.reset_sessions! unless example.exception block_and_wait_for_requests_complete end end diff --git a/spec/support/controllers/githubish_import_controller_shared_examples.rb b/spec/support/controllers/githubish_import_controller_shared_examples.rb index d6b40db09ce..a8d9566b4e4 100644 --- a/spec/support/controllers/githubish_import_controller_shared_examples.rb +++ b/spec/support/controllers/githubish_import_controller_shared_examples.rb @@ -14,8 +14,8 @@ shared_examples 'a GitHub-ish import controller: POST personal_access_token' do it "updates access token" do token = 'asdfasdf9876' - allow_any_instance_of(Gitlab::GithubImport::Client). - to receive(:user).and_return(true) + allow_any_instance_of(Gitlab::GithubImport::Client) + .to receive(:user).and_return(true) post :personal_access_token, personal_access_token: token @@ -79,8 +79,8 @@ shared_examples 'a GitHub-ish import controller: GET status' do end it "handles an invalid access token" do - allow_any_instance_of(Gitlab::GithubImport::Client). - to receive(:repos).and_raise(Octokit::Unauthorized) + allow_any_instance_of(Gitlab::GithubImport::Client) + .to receive(:repos).and_raise(Octokit::Unauthorized) get :status @@ -110,9 +110,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do context "when the repository owner is the provider user" do context "when the provider user and GitLab user's usernames match" do it "takes the current user's namespace" do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider) + .and_return(double(execute: true)) post :create, format: :js end @@ -122,9 +122,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do let(:provider_username) { "someone_else" } it "takes the current user's namespace" do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider) + .and_return(double(execute: true)) post :create, format: :js end @@ -144,9 +144,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do context "when the namespace is owned by the GitLab user" do it "takes the existing namespace" do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, provider_repo.name, existing_namespace, user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, provider_repo.name, existing_namespace, user, access_params, type: provider) + .and_return(double(execute: true)) post :create, format: :js end @@ -159,9 +159,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do end it "creates a project using user's namespace" do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider) + .and_return(double(execute: true)) post :create, format: :js end @@ -171,16 +171,16 @@ shared_examples 'a GitHub-ish import controller: POST create' do context "when a namespace with the provider user's username doesn't exist" do context "when current user can create namespaces" do it "creates the namespace" do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).and_return(double(execute: true)) expect { post :create, target_namespace: provider_repo.name, format: :js }.to change(Namespace, :count).by(1) end it "takes the new namespace" do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, provider_repo.name, an_instance_of(Group), user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, provider_repo.name, an_instance_of(Group), user, access_params, type: provider) + .and_return(double(execute: true)) post :create, target_namespace: provider_repo.name, format: :js end @@ -192,16 +192,16 @@ shared_examples 'a GitHub-ish import controller: POST create' do end it "doesn't create the namespace" do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).and_return(double(execute: true)) expect { post :create, format: :js }.not_to change(Namespace, :count) end it "takes the current user's namespace" do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider) + .and_return(double(execute: true)) post :create, format: :js end @@ -217,17 +217,17 @@ shared_examples 'a GitHub-ish import controller: POST create' do end it 'takes the selected namespace and name' do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, test_name, test_namespace, user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, test_name, test_namespace, user, access_params, type: provider) + .and_return(double(execute: true)) post :create, { target_namespace: test_namespace.name, new_name: test_name, format: :js } end it 'takes the selected name and default namespace' do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, test_name, user.namespace, user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, test_name, user.namespace, user, access_params, type: provider) + .and_return(double(execute: true)) post :create, { new_name: test_name, format: :js } end @@ -243,9 +243,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do end it 'takes the selected namespace and name' do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, test_name, nested_namespace, user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, test_name, nested_namespace, user, access_params, type: provider) + .and_return(double(execute: true)) post :create, { target_namespace: nested_namespace.full_path, new_name: test_name, format: :js } end @@ -255,26 +255,26 @@ shared_examples 'a GitHub-ish import controller: POST create' do let(:test_name) { 'test_name' } it 'takes the selected namespace and name' do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider) + .and_return(double(execute: true)) post :create, { target_namespace: 'foo/bar', new_name: test_name, format: :js } end it 'creates the namespaces' do - allow(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider). - and_return(double(execute: true)) + allow(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider) + .and_return(double(execute: true)) expect { post :create, { target_namespace: 'foo/bar', new_name: test_name, format: :js } } .to change { Namespace.count }.by(2) end it 'new namespace has the right parent' do - allow(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider). - and_return(double(execute: true)) + allow(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider) + .and_return(double(execute: true)) post :create, { target_namespace: 'foo/bar', new_name: test_name, format: :js } @@ -287,17 +287,17 @@ shared_examples 'a GitHub-ish import controller: POST create' do let!(:parent_namespace) { create(:group, name: 'foo', owner: user) } it 'takes the selected namespace and name' do - expect(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider). - and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider) + .and_return(double(execute: true)) post :create, { target_namespace: 'foo/foobar/bar', new_name: test_name, format: :js } end it 'creates the namespaces' do - allow(Gitlab::GithubImport::ProjectCreator). - to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider). - and_return(double(execute: true)) + allow(Gitlab::GithubImport::ProjectCreator) + .to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider) + .and_return(double(execute: true)) expect { post :create, { target_namespace: 'foo/foobar/bar', new_name: test_name, format: :js } } .to change { Namespace.count }.by(2) diff --git a/spec/support/features/reportable_note_shared_examples.rb b/spec/support/features/reportable_note_shared_examples.rb index 0d80c95e826..27e079c01dd 100644 --- a/spec/support/features/reportable_note_shared_examples.rb +++ b/spec/support/features/reportable_note_shared_examples.rb @@ -13,9 +13,7 @@ shared_examples 'reportable note' do it 'dropdown has Edit, Report and Delete links' do dropdown = comment.find(more_actions_selector) - - dropdown.click - dropdown.find('.dropdown-menu li', match: :first) + open_dropdown(dropdown) expect(dropdown).to have_button('Edit comment') expect(dropdown).to have_link('Report as abuse', href: abuse_report_path) @@ -24,13 +22,16 @@ shared_examples 'reportable note' do it 'Report button links to a report page' do dropdown = comment.find(more_actions_selector) - - dropdown.click - dropdown.find('.dropdown-menu li', match: :first) + open_dropdown(dropdown) dropdown.click_link('Report as abuse') expect(find('#user_name')['value']).to match(note.author.username) expect(find('#abuse_report_message')['value']).to match(noteable_note_url(note)) end + + def open_dropdown(dropdown) + dropdown.click + dropdown.find('.dropdown-menu li', match: :first) + end end diff --git a/spec/support/filter_item_select_helper.rb b/spec/support/filter_item_select_helper.rb new file mode 100644 index 00000000000..519e84d359e --- /dev/null +++ b/spec/support/filter_item_select_helper.rb @@ -0,0 +1,19 @@ +# Helper allows you to select value from filter-items +# +# Params +# value - value for select +# selector - css selector of item +# +# Usage: +# +# filter_item_select('Any Author', '.js-author-search') +# +module FilterItemSelectHelper + def filter_item_select(value, selector) + find(selector).click + wait_for_requests + page.within('.dropdown-content') do + click_link value + end + end +end diff --git a/spec/support/filtered_search_helpers.rb b/spec/support/filtered_search_helpers.rb index 37cc308e613..d21c4324d9e 100644 --- a/spec/support/filtered_search_helpers.rb +++ b/spec/support/filtered_search_helpers.rb @@ -14,6 +14,9 @@ module FilteredSearchHelpers filtered_search.set(search) if submit + # Wait for the lazy author/assignee tokens that + # swap out the username with an avatar and name + wait_for_requests filtered_search.send_keys(:enter) end end diff --git a/spec/support/generate-seed-repo-rb b/spec/support/generate-seed-repo-rb index 7335f74c0e9..c89389b90ca 100755 --- a/spec/support/generate-seed-repo-rb +++ b/spec/support/generate-seed-repo-rb @@ -15,7 +15,7 @@ require 'erb' require 'tempfile' -SOURCE = 'https://gitlab.com/gitlab-org/gitlab-git-test.git'.freeze +SOURCE = File.expand_path('../gitlab-git-test.git', __FILE__).freeze SCRIPT_NAME = 'generate-seed-repo-rb'.freeze REPO_NAME = 'gitlab-git-test.git'.freeze diff --git a/spec/support/gitlab-git-test.git/HEAD b/spec/support/gitlab-git-test.git/HEAD new file mode 100644 index 00000000000..cb089cd89a7 --- /dev/null +++ b/spec/support/gitlab-git-test.git/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/spec/support/gitlab-git-test.git/README.md b/spec/support/gitlab-git-test.git/README.md new file mode 100644 index 00000000000..f072cd421be --- /dev/null +++ b/spec/support/gitlab-git-test.git/README.md @@ -0,0 +1,16 @@ +# Gitlab::Git test repository + +This repository is used by (some of) the tests in spec/lib/gitlab/git. + +Do not add new large files to this repository. Otherwise we needlessly +inflate the size of the gitlab-ce repository. + +## How to make changes to this repository + +- (if needed) clone `https://gitlab.com/gitlab-org/gitlab-ce.git` to your local machine +- clone `gitlab-ce/spec/support/gitlab-git-test.git` locally (i.e. clone from your hard drive, not from the internet) +- make changes in your local clone of gitlab-git-test +- run `git push` which will push to your local source `gitlab-ce/spec/support/gitlab-git-test.git` +- in gitlab-ce: run `spec/support/prepare-gitlab-git-test-for-commit` +- in gitlab-ce: `git add spec/support/seed_repo.rb spec/support/gitlab-git-test.git` +- commit your changes in gitlab-ce diff --git a/spec/support/gitlab-git-test.git/config b/spec/support/gitlab-git-test.git/config new file mode 100644 index 00000000000..03e2d1b1e0f --- /dev/null +++ b/spec/support/gitlab-git-test.git/config @@ -0,0 +1,7 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true + precomposeunicode = true +[remote "origin"] + url = https://gitlab.com/gitlab-org/gitlab-git-test.git diff --git a/spec/support/gitlab-git-test.git/objects/pack/pack-691247af2a6acb0b63b73ac0cb90540e93614043.idx b/spec/support/gitlab-git-test.git/objects/pack/pack-691247af2a6acb0b63b73ac0cb90540e93614043.idx Binary files differnew file mode 100644 index 00000000000..2253da798c4 --- /dev/null +++ b/spec/support/gitlab-git-test.git/objects/pack/pack-691247af2a6acb0b63b73ac0cb90540e93614043.idx diff --git a/spec/support/gitlab-git-test.git/objects/pack/pack-691247af2a6acb0b63b73ac0cb90540e93614043.pack b/spec/support/gitlab-git-test.git/objects/pack/pack-691247af2a6acb0b63b73ac0cb90540e93614043.pack Binary files differnew file mode 100644 index 00000000000..3a61107c5b1 --- /dev/null +++ b/spec/support/gitlab-git-test.git/objects/pack/pack-691247af2a6acb0b63b73ac0cb90540e93614043.pack diff --git a/spec/support/gitlab-git-test.git/packed-refs b/spec/support/gitlab-git-test.git/packed-refs new file mode 100644 index 00000000000..ce5ab1f705b --- /dev/null +++ b/spec/support/gitlab-git-test.git/packed-refs @@ -0,0 +1,18 @@ +# pack-refs with: peeled fully-peeled +0b4bc9a49b562e85de7cc9e834518ea6828729b9 refs/heads/feature +12d65c8dd2b2676fa3ac47d955accc085a37a9c1 refs/heads/fix +6473c90867124755509e100d0d35ebdc85a0b6ae refs/heads/fix-blob-path +58fa1a3af4de73ea83fe25a1ef1db8e0c56f67e5 refs/heads/fix-existing-submodule-dir +40f4a7a617393735a95a0bb67b08385bc1e7c66d refs/heads/fix-mode +9abd6a8c113a2dd76df3fdb3d58a8cec6db75f8d refs/heads/gitattributes +46e1395e609395de004cacd4b142865ab0e52a29 refs/heads/gitattributes-updated +4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6 refs/heads/master +5937ac0a7beb003549fc5fd26fc247adbce4a52e refs/heads/merge-test +f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8 refs/tags/v1.0.0 +^6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 +8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b refs/tags/v1.1.0 +^5937ac0a7beb003549fc5fd26fc247adbce4a52e +10d64eed7760f2811ee2d64b44f1f7d3b364f17b refs/tags/v1.2.0 +^eb49186cfa5c4338011f5f590fac11bd66c5c631 +2ac1f24e253e08135507d0830508febaaccf02ee refs/tags/v1.2.1 +^fa1b1e6c004a68b7d8763b86455da9e6b23e36d6 diff --git a/spec/support/gitlab-git-test.git/refs/heads/.gitkeep b/spec/support/gitlab-git-test.git/refs/heads/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/spec/support/gitlab-git-test.git/refs/heads/.gitkeep diff --git a/spec/support/gitlab-git-test.git/refs/tags/.gitkeep b/spec/support/gitlab-git-test.git/refs/tags/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/spec/support/gitlab-git-test.git/refs/tags/.gitkeep diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 879386b5437..4c88958264b 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -89,4 +89,25 @@ module LoginHelpers }) Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:saml] end + + def mock_saml_config + OpenStruct.new(name: 'saml', label: 'saml', args: { + assertion_consumer_service_url: 'https://localhost:3443/users/auth/saml/callback', + idp_cert_fingerprint: '26:43:2C:47:AF:F0:6B:D0:07:9C:AD:A3:74:FE:5D:94:5F:4E:9E:52', + idp_sso_target_url: 'https://idp.example.com/sso/saml', + issuer: 'https://localhost:3443/', + name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient' + }) + end + + def stub_omniauth_saml_config(messages) + Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] + Rails.application.routes.disable_clear_and_finalize = true + Rails.application.routes.draw do + post '/users/auth/saml' => 'omniauth_callbacks#saml' + end + allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: mock_saml_config) + stub_omniauth_setting(messages) + expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') + end end diff --git a/spec/support/mentionable_shared_examples.rb b/spec/support/mentionable_shared_examples.rb index 87936bb4859..3ac201f1fb1 100644 --- a/spec/support/mentionable_shared_examples.rb +++ b/spec/support/mentionable_shared_examples.rb @@ -81,8 +81,8 @@ shared_examples 'a mentionable' do ext_issue, ext_mr, ext_commit] mentioned_objects.each do |referenced| - expect(SystemNoteService).to receive(:cross_reference). - with(referenced, subject.local_reference, author) + expect(SystemNoteService).to receive(:cross_reference) + .with(referenced, subject.local_reference, author) end subject.create_cross_references! @@ -127,15 +127,15 @@ shared_examples 'an editable mentionable' do # These three objects were already referenced, and should not receive new # notes [mentioned_issue, mentioned_commit, ext_issue].each do |oldref| - expect(SystemNoteService).not_to receive(:cross_reference). - with(oldref, any_args) + expect(SystemNoteService).not_to receive(:cross_reference) + .with(oldref, any_args) end # These two issues are new and should receive reference notes # In the case of MergeRequests remember that cannot mention commits included in the MergeRequest new_issues.each do |newref| - expect(SystemNoteService).to receive(:cross_reference). - with(newref, subject.local_reference, author) + expect(SystemNoteService).to receive(:cross_reference) + .with(newref, subject.local_reference, author) end set_mentionable_text.call(new_text) diff --git a/spec/support/prepare-gitlab-git-test-for-commit b/spec/support/prepare-gitlab-git-test-for-commit new file mode 100755 index 00000000000..3047786a599 --- /dev/null +++ b/spec/support/prepare-gitlab-git-test-for-commit @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +abort unless [ + system('spec/support/generate-seed-repo-rb', out: 'spec/support/seed_repo.rb'), + system('spec/support/unpack-gitlab-git-test') +].all? + +exit if ARGV.first != '--check-for-changes' + +git_status = IO.popen(%w[git status --porcelain], &:read) +abort unless $?.success? + +puts git_status + +if git_status.lines.grep(%r{^.. spec/support/gitlab-git-test.git}).any? + abort "error: detected changes in gitlab-git-test.git" +end diff --git a/spec/support/prometheus/additional_metrics_shared_examples.rb b/spec/support/prometheus/additional_metrics_shared_examples.rb new file mode 100644 index 00000000000..016e16fc8d4 --- /dev/null +++ b/spec/support/prometheus/additional_metrics_shared_examples.rb @@ -0,0 +1,101 @@ +RSpec.shared_examples 'additional metrics query' do + include Prometheus::MetricBuilders + + let(:metric_group_class) { Gitlab::Prometheus::MetricGroup } + let(:metric_class) { Gitlab::Prometheus::Metric } + + let(:metric_names) { %w{metric_a metric_b} } + + let(:query_range_result) do + [{ 'metric': {}, 'values': [[1488758662.506, '0.00002996364761904785'], [1488758722.506, '0.00003090239047619091']] }] + end + + before do + allow(client).to receive(:label_values).and_return(metric_names) + allow(metric_group_class).to receive(:all).and_return([simple_metric_group(metrics: [simple_metric])]) + end + + context 'with one group where two metrics is found' do + before do + allow(metric_group_class).to receive(:all).and_return([simple_metric_group]) + end + + context 'some queries return results' do + before do + allow(client).to receive(:query_range).with('query_range_a', any_args).and_return(query_range_result) + allow(client).to receive(:query_range).with('query_range_b', any_args).and_return(query_range_result) + allow(client).to receive(:query_range).with('query_range_empty', any_args).and_return([]) + end + + it 'return group data only for queries with results' do + expected = [ + { + group: 'name', + priority: 1, + metrics: [ + { + title: 'title', weight: 1, y_label: 'Values', queries: [ + { query_range: 'query_range_a', result: query_range_result }, + { query_range: 'query_range_b', label: 'label', unit: 'unit', result: query_range_result } + ] + } + ] + } + ] + + expect(query_result).to match_schema('prometheus/additional_metrics_query_result') + expect(query_result).to eq(expected) + end + end + end + + context 'with two groups with one metric each' do + let(:metrics) { [simple_metric(queries: [simple_query])] } + before do + allow(metric_group_class).to receive(:all).and_return( + [ + simple_metric_group(name: 'group_a', metrics: [simple_metric(queries: [simple_query])]), + simple_metric_group(name: 'group_b', metrics: [simple_metric(title: 'title_b', queries: [simple_query('b')])]) + ]) + allow(client).to receive(:label_values).and_return(metric_names) + end + + context 'both queries return results' do + before do + allow(client).to receive(:query_range).with('query_range_a', any_args).and_return(query_range_result) + allow(client).to receive(:query_range).with('query_range_b', any_args).and_return(query_range_result) + end + + it 'return group data both queries' do + queries_with_result_a = { queries: [{ query_range: 'query_range_a', result: query_range_result }] } + queries_with_result_b = { queries: [{ query_range: 'query_range_b', result: query_range_result }] } + + expect(query_result).to match_schema('prometheus/additional_metrics_query_result') + + expect(query_result.count).to eq(2) + expect(query_result).to all(satisfy { |r| r[:metrics].count == 1 }) + + expect(query_result[0][:metrics].first).to include(queries_with_result_a) + expect(query_result[1][:metrics].first).to include(queries_with_result_b) + end + end + + context 'one query returns result' do + before do + allow(client).to receive(:query_range).with('query_range_a', any_args).and_return(query_range_result) + allow(client).to receive(:query_range).with('query_range_b', any_args).and_return([]) + end + + it 'return group data only for query with results' do + queries_with_result = { queries: [{ query_range: 'query_range_a', result: query_range_result }] } + + expect(query_result).to match_schema('prometheus/additional_metrics_query_result') + + expect(query_result.count).to eq(1) + expect(query_result).to all(satisfy { |r| r[:metrics].count == 1 }) + + expect(query_result.first[:metrics].first).to include(queries_with_result) + end + end + end +end diff --git a/spec/support/prometheus/metric_builders.rb b/spec/support/prometheus/metric_builders.rb new file mode 100644 index 00000000000..c8d056d3fc8 --- /dev/null +++ b/spec/support/prometheus/metric_builders.rb @@ -0,0 +1,27 @@ +module Prometheus + module MetricBuilders + def simple_query(suffix = 'a', **opts) + { query_range: "query_range_#{suffix}" }.merge(opts) + end + + def simple_queries + [simple_query, simple_query('b', label: 'label', unit: 'unit')] + end + + def simple_metric(title: 'title', required_metrics: [], queries: [simple_query]) + Gitlab::Prometheus::Metric.new(title: title, required_metrics: required_metrics, weight: 1, queries: queries) + end + + def simple_metrics(added_metric_name: 'metric_a') + [ + simple_metric(required_metrics: %W(#{added_metric_name} metric_b), queries: simple_queries), + simple_metric(required_metrics: [added_metric_name], queries: [simple_query('empty')]), + simple_metric(required_metrics: %w{metric_c}) + ] + end + + def simple_metric_group(name: 'name', metrics: simple_metrics) + Gitlab::Prometheus::MetricGroup.new(name: name, priority: 1, metrics: metrics) + end + end +end diff --git a/spec/support/prometheus_helpers.rb b/spec/support/prometheus_helpers.rb index 6b9ebcf2bb3..4212be2cc88 100644 --- a/spec/support/prometheus_helpers.rb +++ b/spec/support/prometheus_helpers.rb @@ -36,6 +36,19 @@ module PrometheusHelpers "https://prometheus.example.com/api/v1/query_range?#{query}" end + def prometheus_label_values_url(name) + "https://prometheus.example.com/api/v1/label/#{name}/values" + end + + def prometheus_series_url(*matches, start: 8.hours.ago, stop: Time.now) + query = { + match: matches, + start: start.to_f, + end: stop.to_f + }.to_query + "https://prometheus.example.com/api/v1/series?#{query}" + end + def stub_prometheus_request(url, body: {}, status: 200) WebMock.stub_request(:get, url) .to_return({ @@ -85,6 +98,19 @@ module PrometheusHelpers def prometheus_data(last_update: Time.now.utc) { success: true, + data: { + memory_values: prometheus_values_body('matrix').dig(:data, :result), + memory_current: prometheus_value_body('vector').dig(:data, :result), + cpu_values: prometheus_values_body('matrix').dig(:data, :result), + cpu_current: prometheus_value_body('vector').dig(:data, :result) + }, + last_update: last_update + } + end + + def prometheus_metrics_data(last_update: Time.now.utc) + { + success: true, metrics: { memory_values: prometheus_values_body('matrix').dig(:data, :result), memory_current: prometheus_value_body('vector').dig(:data, :result), @@ -140,4 +166,37 @@ module PrometheusHelpers } } end + + def prometheus_label_values + { + 'status': 'success', + 'data': %w(job_adds job_controller_rate_limiter_use job_depth job_queue_latency job_work_duration_sum up) + } + end + + def prometheus_series(name) + { + 'status': 'success', + 'data': [ + { + '__name__': name, + 'container_name': 'gitlab', + 'environment': 'mattermost', + 'id': '/docker/9953982f95cf5010dfc59d7864564d5f188aaecddeda343699783009f89db667', + 'image': 'gitlab/gitlab-ce:8.15.4-ce.1', + 'instance': 'minikube', + 'job': 'kubernetes-nodes', + 'name': 'k8s_gitlab.e6611886_mattermost-4210310111-77z8r_gitlab_2298ae6b-da24-11e6-baee-8e7f67d0eb3a_43536cb6', + 'namespace': 'gitlab', + 'pod_name': 'mattermost-4210310111-77z8r' + }, + { + '__name__': name, + 'id': '/docker', + 'instance': 'minikube', + 'job': 'kubernetes-nodes' + } + ] + } + end end diff --git a/spec/support/reactive_caching_helpers.rb b/spec/support/reactive_caching_helpers.rb index 98eb57f8b54..34124f02133 100644 --- a/spec/support/reactive_caching_helpers.rb +++ b/spec/support/reactive_caching_helpers.rb @@ -35,8 +35,8 @@ module ReactiveCachingHelpers end def expect_reactive_cache_update_queued(subject) - expect(ReactiveCachingWorker). - to receive(:perform_in). - with(subject.class.reactive_cache_refresh_interval, subject.class, subject.id) + expect(ReactiveCachingWorker) + .to receive(:perform_in) + .with(subject.class.reactive_cache_refresh_interval, subject.class, subject.id) end end diff --git a/spec/support/seed_helper.rb b/spec/support/seed_helper.rb index 47b5f556e66..8731847592b 100644 --- a/spec/support/seed_helper.rb +++ b/spec/support/seed_helper.rb @@ -9,7 +9,7 @@ TEST_MUTABLE_REPO_PATH = 'mutable-repo.git'.freeze TEST_BROKEN_REPO_PATH = 'broken-repo.git'.freeze module SeedHelper - GITLAB_GIT_TEST_REPO_URL = ENV.fetch('GITLAB_GIT_TEST_REPO_URL', 'https://gitlab.com/gitlab-org/gitlab-git-test.git').freeze + GITLAB_GIT_TEST_REPO_URL = File.expand_path('../gitlab-git-test.git', __FILE__).freeze def ensure_seeds if File.exist?(SEED_STORAGE_PATH) diff --git a/spec/support/services_shared_context.rb b/spec/support/services_shared_context.rb index 66c93890e31..7457484a932 100644 --- a/spec/support/services_shared_context.rb +++ b/spec/support/services_shared_context.rb @@ -6,9 +6,9 @@ Service.available_services_names.each do |service| let(:service_fields) { service_klass.new.fields } let(:service_attrs_list) { service_fields.inject([]) {|arr, hash| arr << hash[:name].to_sym } } let(:service_attrs_list_without_passwords) do - service_fields. - select { |field| field[:type] != 'password' }. - map { |field| field[:name].to_sym} + service_fields + .select { |field| field[:type] != 'password' } + .map { |field| field[:name].to_sym} end let(:service_attrs) do service_attrs_list.inject({}) do |hash, k| diff --git a/spec/support/protected_branches/access_control_ce_shared_examples.rb b/spec/support/shared_examples/features/protected_branches_access_control_ce.rb index 287d6bb13c3..b6341127a76 100644 --- a/spec/support/protected_branches/access_control_ce_shared_examples.rb +++ b/spec/support/shared_examples/features/protected_branches_access_control_ce.rb @@ -1,4 +1,4 @@ -RSpec.shared_examples "protected branches > access control > CE" do +shared_examples "protected branches > access control > CE" do ProtectedBranch::PushAccessLevel.human_access_levels.each do |(access_type_id, access_type_name)| it "allows creating protected branches that #{access_type_name} can push to" do visit namespace_project_protected_branches_path(project.namespace, project) diff --git a/spec/support/slack_mattermost_notifications_shared_examples.rb b/spec/support/slack_mattermost_notifications_shared_examples.rb index a7deb038703..044c09d5fde 100644 --- a/spec/support/slack_mattermost_notifications_shared_examples.rb +++ b/spec/support/slack_mattermost_notifications_shared_examples.rb @@ -108,9 +108,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it 'uses the username as an option for slack when configured' do allow(chat_service).to receive(:username).and_return(username) - expect(Slack::Notifier).to receive(:new). - with(webhook_url, username: username). - and_return( + expect(Slack::Notifier).to receive(:new) + .with(webhook_url, username: username) + .and_return( double(:slack_service).as_null_object ) @@ -119,9 +119,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it 'uses the channel as an option when it is configured' do allow(chat_service).to receive(:channel).and_return(channel) - expect(Slack::Notifier).to receive(:new). - with(webhook_url, channel: channel). - and_return( + expect(Slack::Notifier).to receive(:new) + .with(webhook_url, channel: channel) + .and_return( double(:slack_service).as_null_object ) chat_service.execute(push_sample_data) @@ -131,9 +131,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it "uses the right channel for push event" do chat_service.update_attributes(push_channel: "random") - expect(Slack::Notifier).to receive(:new). - with(webhook_url, channel: "random"). - and_return( + expect(Slack::Notifier).to receive(:new) + .with(webhook_url, channel: "random") + .and_return( double(:slack_service).as_null_object ) @@ -143,9 +143,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it "uses the right channel for merge request event" do chat_service.update_attributes(merge_request_channel: "random") - expect(Slack::Notifier).to receive(:new). - with(webhook_url, channel: "random"). - and_return( + expect(Slack::Notifier).to receive(:new) + .with(webhook_url, channel: "random") + .and_return( double(:slack_service).as_null_object ) @@ -155,9 +155,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it "uses the right channel for issue event" do chat_service.update_attributes(issue_channel: "random") - expect(Slack::Notifier).to receive(:new). - with(webhook_url, channel: "random"). - and_return( + expect(Slack::Notifier).to receive(:new) + .with(webhook_url, channel: "random") + .and_return( double(:slack_service).as_null_object ) @@ -167,9 +167,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it "uses the right channel for wiki event" do chat_service.update_attributes(wiki_page_channel: "random") - expect(Slack::Notifier).to receive(:new). - with(webhook_url, channel: "random"). - and_return( + expect(Slack::Notifier).to receive(:new) + .with(webhook_url, channel: "random") + .and_return( double(:slack_service).as_null_object ) @@ -186,9 +186,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do note_data = Gitlab::DataBuilder::Note.build(issue_note, user) - expect(Slack::Notifier).to receive(:new). - with(webhook_url, channel: "random"). - and_return( + expect(Slack::Notifier).to receive(:new) + .with(webhook_url, channel: "random") + .and_return( double(:slack_service).as_null_object ) diff --git a/spec/support/stub_configuration.rb b/spec/support/stub_configuration.rb index b39a23bd18a..48f454c7187 100644 --- a/spec/support/stub_configuration.rb +++ b/spec/support/stub_configuration.rb @@ -5,8 +5,8 @@ module StubConfiguration # Stubbing both of these because we're not yet consistent with how we access # current application settings allow_any_instance_of(ApplicationSetting).to receive_messages(messages) - allow(Gitlab::CurrentSettings.current_application_settings). - to receive_messages(messages) + allow(Gitlab::CurrentSettings.current_application_settings) + .to receive_messages(messages) end def stub_config_setting(messages) diff --git a/spec/support/stub_env.rb b/spec/support/stub_env.rb index 18597b5c71f..2999bcd9fb1 100644 --- a/spec/support/stub_env.rb +++ b/spec/support/stub_env.rb @@ -5,3 +5,11 @@ module StubENV allow(ENV).to receive(:[]).with(key).and_return(value) end end + +# It's possible that the state of the class variables are not reset across +# test runs. +RSpec.configure do |config| + config.after(:each) do + @env_already_stubbed = nil + end +end diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index ded2d593059..78a2ff73746 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -68,22 +68,22 @@ module StubGitlabCalls def stub_session f = File.read(Rails.root.join('spec/support/gitlab_stubs/session.json')) - stub_request(:post, "#{gitlab_url}api/v3/session.json"). - with(body: "{\"email\":\"test@test.com\",\"password\":\"123456\"}", - headers: { 'Content-Type' => 'application/json' }). - to_return(status: 201, body: f, headers: { 'Content-Type' => 'application/json' }) + stub_request(:post, "#{gitlab_url}api/v3/session.json") + .with(body: "{\"email\":\"test@test.com\",\"password\":\"123456\"}", + headers: { 'Content-Type' => 'application/json' }) + .to_return(status: 201, body: f, headers: { 'Content-Type' => 'application/json' }) end def stub_user f = File.read(Rails.root.join('spec/support/gitlab_stubs/user.json')) - stub_request(:get, "#{gitlab_url}api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz"). - with(headers: { 'Content-Type' => 'application/json' }). - to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) + stub_request(:get, "#{gitlab_url}api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz") + .with(headers: { 'Content-Type' => 'application/json' }) + .to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) - stub_request(:get, "#{gitlab_url}api/v3/user?access_token=some_token"). - with(headers: { 'Content-Type' => 'application/json' }). - to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) + stub_request(:get, "#{gitlab_url}api/v3/user?access_token=some_token") + .with(headers: { 'Content-Type' => 'application/json' }) + .to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) end def stub_project_8 @@ -99,21 +99,21 @@ module StubGitlabCalls def stub_projects f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json')) - stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). - with(headers: { 'Content-Type' => 'application/json' }). - to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) + stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz") + .with(headers: { 'Content-Type' => 'application/json' }) + .to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) end def stub_projects_owned - stub_request(:get, "#{gitlab_url}api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). - with(headers: { 'Content-Type' => 'application/json' }). - to_return(status: 200, body: "", headers: {}) + stub_request(:get, "#{gitlab_url}api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz") + .with(headers: { 'Content-Type' => 'application/json' }) + .to_return(status: 200, body: "", headers: {}) end def stub_ci_enable - stub_request(:put, "#{gitlab_url}api/v3/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz"). - with(headers: { 'Content-Type' => 'application/json' }). - to_return(status: 200, body: "", headers: {}) + stub_request(:put, "#{gitlab_url}api/v3/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz") + .with(headers: { 'Content-Type' => 'application/json' }) + .to_return(status: 200, body: "", headers: {}) end def project_hash_array diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 3f472e59c49..1c5267c290b 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -83,13 +83,13 @@ module TestEnv end def disable_mailer - allow_any_instance_of(NotificationService).to receive(:mailer). - and_return(double.as_null_object) + allow_any_instance_of(NotificationService).to receive(:mailer) + .and_return(double.as_null_object) end def enable_mailer - allow_any_instance_of(NotificationService).to receive(:mailer). - and_call_original + allow_any_instance_of(NotificationService).to receive(:mailer) + .and_call_original end def disable_pre_receive diff --git a/spec/support/unpack-gitlab-git-test b/spec/support/unpack-gitlab-git-test new file mode 100755 index 00000000000..d5b4912457d --- /dev/null +++ b/spec/support/unpack-gitlab-git-test @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +require 'fileutils' + +REPO = 'spec/support/gitlab-git-test.git'.freeze +PACK_DIR = REPO + '/objects/pack' +GIT = %W[git --git-dir=#{REPO}].freeze +BASE_PACK = 'pack-691247af2a6acb0b63b73ac0cb90540e93614043'.freeze + +def main + unpack + # We want to store the refs in a packed-refs file because if we don't + # they can get mangled by filesystems. + abort unless system(*GIT, *%w[pack-refs --all]) + abort unless system(*GIT, 'fsck') +end + +# We don't want contributors to commit new pack files because those +# create unnecessary churn. +def unpack + pack_files = Dir[File.join(PACK_DIR, '*')].reject do |pack| + pack.start_with?(File.join(PACK_DIR, BASE_PACK)) + end + return if pack_files.empty? + + pack_files.each do |pack| + unless pack.end_with?('.pack') + FileUtils.rm(pack) + next + end + + File.open(pack, 'rb') do |open_pack| + File.unlink(pack) + abort unless system(*GIT, 'unpack-objects', in: open_pack) + end + end +end + +main diff --git a/spec/support/update_invalid_issuable.rb b/spec/support/update_invalid_issuable.rb index 365c34448ac..1490287681b 100644 --- a/spec/support/update_invalid_issuable.rb +++ b/spec/support/update_invalid_issuable.rb @@ -21,8 +21,8 @@ shared_examples 'update invalid issuable' do |klass| context 'when updating causes conflicts' do before do - allow_any_instance_of(issuable.class).to receive(:save). - and_raise(ActiveRecord::StaleObjectError.new(issuable, :save)) + allow_any_instance_of(issuable.class).to receive(:save) + .and_raise(ActiveRecord::StaleObjectError.new(issuable, :save)) end it 'renders edit when format is html' do diff --git a/spec/support/user_activities_helpers.rb b/spec/support/user_activities_helpers.rb index f7ca9a31edd..44feb104644 100644 --- a/spec/support/user_activities_helpers.rb +++ b/spec/support/user_activities_helpers.rb @@ -1,7 +1,7 @@ module UserActivitiesHelpers def user_activity(user) - Gitlab::UserActivities.new. - find { |k, _| k == user.id.to_s }&. + Gitlab::UserActivities.new + .find { |k, _| k == user.id.to_s }&. second end end diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index 1e5f55a738a..71580a788d0 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -47,24 +47,24 @@ describe 'gitlab:app namespace rake task' do allow(Kernel).to receive(:system).and_return(true) allow(FileUtils).to receive(:cp_r).and_return(true) allow(FileUtils).to receive(:mv).and_return(true) - allow(Rake::Task["gitlab:shell:setup"]). - to receive(:invoke).and_return(true) + allow(Rake::Task["gitlab:shell:setup"]) + .to receive(:invoke).and_return(true) ENV['force'] = 'yes' end let(:gitlab_version) { Gitlab::VERSION } it 'fails on mismatch' do - allow(YAML).to receive(:load_file). - and_return({ gitlab_version: "not #{gitlab_version}" }) + allow(YAML).to receive(:load_file) + .and_return({ gitlab_version: "not #{gitlab_version}" }) - expect { run_rake_task('gitlab:backup:restore') }. - to raise_error(SystemExit) + expect { run_rake_task('gitlab:backup:restore') } + .to raise_error(SystemExit) end it 'invokes restoration on match' do - allow(YAML).to receive(:load_file). - and_return({ gitlab_version: gitlab_version }) + allow(YAML).to receive(:load_file) + .and_return({ gitlab_version: gitlab_version }) expect(Rake::Task['gitlab:db:drop_tables']).to receive(:invoke) expect(Rake::Task['gitlab:backup:db:restore']).to receive(:invoke) expect(Rake::Task['gitlab:backup:repo:restore']).to receive(:invoke) @@ -310,8 +310,8 @@ describe 'gitlab:app namespace rake task' do end it 'does not invoke repositories restore' do - allow(Rake::Task['gitlab:shell:setup']). - to receive(:invoke).and_return(true) + allow(Rake::Task['gitlab:shell:setup']) + .to receive(:invoke).and_return(true) allow($stdout).to receive :write expect(Rake::Task['gitlab:db:drop_tables']).to receive :invoke diff --git a/spec/tasks/gitlab/gitaly_rake_spec.rb b/spec/tasks/gitlab/gitaly_rake_spec.rb index cfa6c9ca8ce..d42d2423f15 100644 --- a/spec/tasks/gitlab/gitaly_rake_spec.rb +++ b/spec/tasks/gitlab/gitaly_rake_spec.rb @@ -20,8 +20,8 @@ describe 'gitlab:gitaly namespace rake task' do context 'when an underlying Git command fail' do it 'aborts and display a help message' do - expect_any_instance_of(Object). - to receive(:checkout_or_clone_version).and_raise 'Git error' + expect_any_instance_of(Object) + .to receive(:checkout_or_clone_version).and_raise 'Git error' expect { run_rake_task('gitlab:gitaly:install', clone_path) }.to raise_error 'Git error' end @@ -33,8 +33,8 @@ describe 'gitlab:gitaly namespace rake task' do end it 'calls checkout_or_clone_version with the right arguments' do - expect_any_instance_of(Object). - to receive(:checkout_or_clone_version).with(version: version, repo: repo, target_dir: clone_path) + expect_any_instance_of(Object) + .to receive(:checkout_or_clone_version).with(version: version, repo: repo, target_dir: clone_path) run_rake_task('gitlab:gitaly:install', clone_path) end @@ -89,6 +89,7 @@ describe 'gitlab:gitaly namespace rake task' do } } allow(Gitlab.config.repositories).to receive(:storages).and_return(config) + allow(Rails.env).to receive(:test?).and_return(false) expected_output = '' Timecop.freeze do @@ -105,8 +106,8 @@ describe 'gitlab:gitaly namespace rake task' do TOML end - expect { run_rake_task('gitlab:gitaly:storage_config')}. - to output(expected_output).to_stdout + expect { run_rake_task('gitlab:gitaly:storage_config')} + .to output(expected_output).to_stdout parsed_output = TOML.parse(expected_output) config.each do |name, params| diff --git a/spec/tasks/gitlab/task_helpers_spec.rb b/spec/tasks/gitlab/task_helpers_spec.rb index 3d9ba7cdc6f..91cc684d032 100644 --- a/spec/tasks/gitlab/task_helpers_spec.rb +++ b/spec/tasks/gitlab/task_helpers_spec.rb @@ -60,8 +60,8 @@ describe Gitlab::TaskHelpers do describe '#clone_repo' do it 'clones the repo in the target dir' do - expect(subject). - to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} clone -- #{repo} #{clone_path}]) + expect(subject) + .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} clone -- #{repo} #{clone_path}]) subject.clone_repo(repo, clone_path) end @@ -69,10 +69,10 @@ describe Gitlab::TaskHelpers do describe '#checkout_version' do it 'clones the repo in the target dir' do - expect(subject). - to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} fetch --quiet]) - expect(subject). - to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} checkout --quiet #{tag}]) + expect(subject) + .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} fetch --quiet]) + expect(subject) + .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} checkout --quiet #{tag}]) subject.checkout_version(tag, clone_path) end @@ -80,8 +80,8 @@ describe Gitlab::TaskHelpers do describe '#reset_to_version' do it 'resets --hard to the given version' do - expect(subject). - to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} reset --hard #{tag}]) + expect(subject) + .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} reset --hard #{tag}]) subject.reset_to_version(tag, clone_path) end diff --git a/spec/tasks/gitlab/workhorse_rake_spec.rb b/spec/tasks/gitlab/workhorse_rake_spec.rb index 63d1cf2bbe5..1b68f3044a4 100644 --- a/spec/tasks/gitlab/workhorse_rake_spec.rb +++ b/spec/tasks/gitlab/workhorse_rake_spec.rb @@ -20,8 +20,8 @@ describe 'gitlab:workhorse namespace rake task' do context 'when an underlying Git command fail' do it 'aborts and display a help message' do - expect_any_instance_of(Object). - to receive(:checkout_or_clone_version).and_raise 'Git error' + expect_any_instance_of(Object) + .to receive(:checkout_or_clone_version).and_raise 'Git error' expect { run_rake_task('gitlab:workhorse:install', clone_path) }.to raise_error 'Git error' end @@ -33,8 +33,8 @@ describe 'gitlab:workhorse namespace rake task' do end it 'calls checkout_or_clone_version with the right arguments' do - expect_any_instance_of(Object). - to receive(:checkout_or_clone_version).with(version: version, repo: repo, target_dir: clone_path) + expect_any_instance_of(Object) + .to receive(:checkout_or_clone_version).with(version: version, repo: repo, target_dir: clone_path) run_rake_task('gitlab:workhorse:install', clone_path) end diff --git a/spec/validators/dynamic_path_validator_spec.rb b/spec/validators/dynamic_path_validator_spec.rb index 8dbf3eecd23..8bd5306ff98 100644 --- a/spec/validators/dynamic_path_validator_spec.rb +++ b/spec/validators/dynamic_path_validator_spec.rb @@ -84,5 +84,14 @@ describe DynamicPathValidator do expect(group.errors[:path]).to include('users is a reserved name') end + + it 'updating to an invalid path is not allowed' do + project = create(:empty_project) + project.path = 'update' + + validator.validate_each(project, :path, 'update') + + expect(project.errors[:path]).to include('update is a reserved name') + end end end diff --git a/spec/views/devise/shared/_signin_box.html.haml_spec.rb b/spec/views/devise/shared/_signin_box.html.haml_spec.rb index 1397bfa5864..9adbb0476be 100644 --- a/spec/views/devise/shared/_signin_box.html.haml_spec.rb +++ b/spec/views/devise/shared/_signin_box.html.haml_spec.rb @@ -31,7 +31,7 @@ describe 'devise/shared/_signin_box' do def enable_crowd allow(view).to receive(:form_based_providers).and_return([:crowd]) allow(view).to receive(:crowd_enabled?).and_return(true) - allow(view).to receive(:omniauth_authorize_path).with(:user, :crowd). - and_return('/crowd') + allow(view).to receive(:omniauth_authorize_path).with(:user, :crowd) + .and_return('/crowd') end end diff --git a/spec/views/projects/commit/show.html.haml_spec.rb b/spec/views/projects/commit/show.html.haml_spec.rb index 122075cc10e..92b4aa12d49 100644 --- a/spec/views/projects/commit/show.html.haml_spec.rb +++ b/spec/views/projects/commit/show.html.haml_spec.rb @@ -21,24 +21,26 @@ describe 'projects/commit/show.html.haml', :view do context 'inline diff view' do before do allow(view).to receive(:diff_view).and_return(:inline) + allow(view).to receive(:diff_view).and_return(:inline) render end - it 'keeps container-limited' do - expect(rendered).not_to have_selector('.limit-container-width') + it 'has limited width' do + expect(rendered).to have_selector('.limit-container-width') end end context 'parallel diff view' do before do allow(view).to receive(:diff_view).and_return(:parallel) + allow(view).to receive(:fluid_layout).and_return(true) render end it 'spans full width' do - expect(rendered).to have_selector('.limit-container-width') + expect(rendered).not_to have_selector('.limit-container-width') end end end diff --git a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb new file mode 100644 index 00000000000..e56c0f6be03 --- /dev/null +++ b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'projects/notes/_more_actions_dropdown', :view do + let(:author_user) { create(:user) } + let(:not_author_user) { create(:user) } + + let(:project) { create(:empty_project) } + let(:issue) { create(:issue, project: project) } + let!(:note) { create(:note_on_issue, author: author_user, noteable: issue, project: project) } + + before do + assign(:project, project) + end + + it 'shows Report as abuse button if not editable and not current users comment' do + render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: false, note: note + + expect(rendered).to have_link('Report as abuse') + end + + it 'does not show the More actions button if not editable and current users comment' do + render 'projects/notes/more_actions_dropdown', current_user: author_user, note_editable: false, note: note + + expect(rendered).not_to have_selector('.dropdown.more-actions') + end + + it 'shows Report as abuse, Edit and Delete buttons if editable and not current users comment' do + render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: true, note: note + + expect(rendered).to have_link('Report as abuse') + expect(rendered).to have_button('Edit comment') + expect(rendered).to have_link('Delete comment') + end + + it 'shows Edit and Delete buttons if editable and current users comment' do + render 'projects/notes/more_actions_dropdown', current_user: author_user, note_editable: true, note: note + + expect(rendered).to have_button('Edit comment') + expect(rendered).to have_link('Delete comment') + end +end diff --git a/spec/workers/background_migration_worker_spec.rb b/spec/workers/background_migration_worker_spec.rb index 0d742ae9dc7..85939429feb 100644 --- a/spec/workers/background_migration_worker_spec.rb +++ b/spec/workers/background_migration_worker_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe BackgroundMigrationWorker do describe '.perform' do it 'performs a background migration' do - expect(Gitlab::BackgroundMigration). - to receive(:perform). - with('Foo', [10, 20]) + expect(Gitlab::BackgroundMigration) + .to receive(:perform) + .with('Foo', [10, 20]) described_class.new.perform('Foo', [10, 20]) end diff --git a/spec/workers/delete_user_worker_spec.rb b/spec/workers/delete_user_worker_spec.rb index 5912dd76262..36594515005 100644 --- a/spec/workers/delete_user_worker_spec.rb +++ b/spec/workers/delete_user_worker_spec.rb @@ -5,15 +5,15 @@ describe DeleteUserWorker do let!(:current_user) { create(:user) } it "calls the DeleteUserWorker with the params it was given" do - expect_any_instance_of(Users::DestroyService).to receive(:execute). - with(user, {}) + expect_any_instance_of(Users::DestroyService).to receive(:execute) + .with(user, {}) described_class.new.perform(current_user.id, user.id) end it "uses symbolized keys" do - expect_any_instance_of(Users::DestroyService).to receive(:execute). - with(user, test: "test") + expect_any_instance_of(Users::DestroyService).to receive(:execute) + .with(user, test: "test") described_class.new.perform(current_user.id, user.id, "test" => "test") end diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb index fc9adf47c1e..30908534eb3 100644 --- a/spec/workers/every_sidekiq_worker_spec.rb +++ b/spec/workers/every_sidekiq_worker_spec.rb @@ -5,8 +5,8 @@ describe 'Every Sidekiq worker' do root = Rails.root.join('app', 'workers') concerns = root.join('concerns').to_s - workers = Dir[root.join('**', '*.rb')]. - reject { |path| path.start_with?(concerns) } + workers = Dir[root.join('**', '*.rb')] + .reject { |path| path.start_with?(concerns) } workers.map do |path| ns = Pathname.new(path).relative_path_from(root).to_s.gsub('.rb', '') @@ -22,9 +22,9 @@ describe 'Every Sidekiq worker' do end it 'uses the cronjob queue when the worker runs as a cronjob' do - cron_workers = Settings.cron_jobs. - map { |job_name, options| options['job_class'].constantize }. - to_set + cron_workers = Settings.cron_jobs + .map { |job_name, options| options['job_class'].constantize } + .to_set workers.each do |worker| next unless cron_workers.include?(worker) diff --git a/spec/workers/expire_pipeline_cache_worker_spec.rb b/spec/workers/expire_pipeline_cache_worker_spec.rb index 28e5b706803..e4f78999489 100644 --- a/spec/workers/expire_pipeline_cache_worker_spec.rb +++ b/spec/workers/expire_pipeline_cache_worker_spec.rb @@ -37,8 +37,8 @@ describe ExpirePipelineCacheWorker do end it 'updates the cached status for a project' do - expect(Gitlab::Cache::Ci::ProjectPipelineStatus).to receive(:update_for_pipeline). - with(pipeline) + expect(Gitlab::Cache::Ci::ProjectPipelineStatus).to receive(:update_for_pipeline) + .with(pipeline) subject.perform(pipeline.id) end diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb index f443bb2c9b4..309b3172da1 100644 --- a/spec/workers/git_garbage_collect_worker_spec.rb +++ b/spec/workers/git_garbage_collect_worker_spec.rb @@ -11,8 +11,8 @@ describe GitGarbageCollectWorker do describe "#perform" do it "flushes ref caches when the task is 'gc'" do expect(subject).to receive(:command).with(:gc).and_return([:the, :command]) - expect(Gitlab::Popen).to receive(:popen). - with([:the, :command], project.repository.path_to_repo).and_return(["", 0]) + expect(Gitlab::Popen).to receive(:popen) + .with([:the, :command], project.repository.path_to_repo).and_return(["", 0]) expect_any_instance_of(Repository).to receive(:after_create_branch).and_call_original expect_any_instance_of(Repository).to receive(:branch_names).and_call_original diff --git a/spec/workers/new_note_worker_spec.rb b/spec/workers/new_note_worker_spec.rb index 8fdbb35afd0..575361c93d4 100644 --- a/spec/workers/new_note_worker_spec.rb +++ b/spec/workers/new_note_worker_spec.rb @@ -24,8 +24,8 @@ describe NewNoteWorker do let(:unexistent_note_id) { 999 } it 'logs NewNoteWorker process skipping' do - expect(Rails.logger).to receive(:error). - with("NewNoteWorker: couldn't find note with ID=999, skipping job") + expect(Rails.logger).to receive(:error) + .with("NewNoteWorker: couldn't find note with ID=999, skipping job") described_class.new.perform(unexistent_note_id) end diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index 6c4df7350ea..cc9bc29c6cc 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -123,9 +123,9 @@ describe PostReceive do end it "does not run if the author is not in the project" do - allow_any_instance_of(Gitlab::GitPostReceive). - to receive(:identify_using_ssh_key). - and_return(nil) + allow_any_instance_of(Gitlab::GitPostReceive) + .to receive(:identify_using_ssh_key) + .and_return(nil) expect(project).not_to receive(:execute_hooks) diff --git a/spec/workers/process_commit_worker_spec.rb b/spec/workers/process_commit_worker_spec.rb index 4e036285e8c..6ebc94bb544 100644 --- a/spec/workers/process_commit_worker_spec.rb +++ b/spec/workers/process_commit_worker_spec.rb @@ -48,11 +48,11 @@ describe ProcessCommitWorker do describe '#process_commit_message' do context 'when pushing to the default branch' do it 'closes issues that should be closed per the commit message' do - allow(commit).to receive(:safe_message). - and_return("Closes #{issue.to_reference}") + allow(commit).to receive(:safe_message) + .and_return("Closes #{issue.to_reference}") - expect(worker).to receive(:close_issues). - with(project, user, user, commit, [issue]) + expect(worker).to receive(:close_issues) + .with(project, user, user, commit, [issue]) worker.process_commit_message(project, commit, user, user, true) end @@ -60,8 +60,8 @@ describe ProcessCommitWorker do context 'when pushing to a non-default branch' do it 'does not close any issues' do - allow(commit).to receive(:safe_message). - and_return("Closes #{issue.to_reference}") + allow(commit).to receive(:safe_message) + .and_return("Closes #{issue.to_reference}") expect(worker).not_to receive(:close_issues) @@ -102,8 +102,8 @@ describe ProcessCommitWorker do describe '#update_issue_metrics' do it 'updates any existing issue metrics' do - allow(commit).to receive(:safe_message). - and_return("Closes #{issue.to_reference}") + allow(commit).to receive(:safe_message) + .and_return("Closes #{issue.to_reference}") worker.update_issue_metrics(commit, user) @@ -113,8 +113,8 @@ describe ProcessCommitWorker do end it "doesn't execute any queries with false conditions" do - allow(commit).to receive(:safe_message). - and_return("Lorem Ipsum") + allow(commit).to receive(:safe_message) + .and_return("Lorem Ipsum") expect { worker.update_issue_metrics(commit, user) }.not_to make_queries_matching(/WHERE (?:1=0|0=1)/) end @@ -128,8 +128,8 @@ describe ProcessCommitWorker do end it 'parses date strings into Time instances' do - commit = worker. - build_commit(project, id: '123', authored_date: Time.now.to_s) + commit = worker + .build_commit(project, id: '123', authored_date: Time.now.to_s) expect(commit.authored_date).to be_an_instance_of(Time) end diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb index a4ba5f7c943..6b1f2ff3227 100644 --- a/spec/workers/project_cache_worker_spec.rb +++ b/spec/workers/project_cache_worker_spec.rb @@ -7,8 +7,8 @@ describe ProjectCacheWorker do describe '#perform' do before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). - and_return(true) + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) + .and_return(true) end context 'with a non-existing project' do @@ -39,9 +39,9 @@ describe ProjectCacheWorker do end it 'refreshes the method caches' do - expect_any_instance_of(Repository).to receive(:refresh_method_caches). - with(%i(readme)). - and_call_original + expect_any_instance_of(Repository).to receive(:refresh_method_caches) + .with(%i(readme)) + .and_call_original worker.perform(project.id, %w(readme)) end @@ -51,9 +51,9 @@ describe ProjectCacheWorker do allow(MarkupHelper).to receive(:gitlab_markdown?).and_return(false) allow(MarkupHelper).to receive(:plain?).and_return(true) - expect_any_instance_of(Repository).to receive(:refresh_method_caches). - with(%i(readme)). - and_call_original + expect_any_instance_of(Repository).to receive(:refresh_method_caches) + .with(%i(readme)) + .and_call_original worker.perform(project.id, %w(readme)) end end @@ -63,9 +63,9 @@ describe ProjectCacheWorker do describe '#update_statistics' do context 'when a lease could not be obtained' do it 'does not update the repository size' do - allow(worker).to receive(:try_obtain_lease_for). - with(project.id, :update_statistics). - and_return(false) + allow(worker).to receive(:try_obtain_lease_for) + .with(project.id, :update_statistics) + .and_return(false) expect(statistics).not_to receive(:refresh!) @@ -75,9 +75,9 @@ describe ProjectCacheWorker do context 'when a lease could be obtained' do it 'updates the project statistics' do - allow(worker).to receive(:try_obtain_lease_for). - with(project.id, :update_statistics). - and_return(true) + allow(worker).to receive(:try_obtain_lease_for) + .with(project.id, :update_statistics) + .and_return(true) expect(statistics).to receive(:refresh!) .with(only: %i(repository_size)) diff --git a/spec/workers/propagate_service_template_worker_spec.rb b/spec/workers/propagate_service_template_worker_spec.rb index 7040d5ef81c..b8b65ead9b3 100644 --- a/spec/workers/propagate_service_template_worker_spec.rb +++ b/spec/workers/propagate_service_template_worker_spec.rb @@ -15,8 +15,8 @@ describe PropagateServiceTemplateWorker do end before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). - and_return(true) + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) + .and_return(true) end describe '#perform' do diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb index 6ea5569b438..d9e9409840f 100644 --- a/spec/workers/repository_fork_worker_spec.rb +++ b/spec/workers/repository_fork_worker_spec.rb @@ -35,11 +35,11 @@ describe RepositoryForkWorker do fork_project.namespace.full_path ).and_return(true) - expect_any_instance_of(Repository).to receive(:expire_emptiness_caches). - and_call_original + expect_any_instance_of(Repository).to receive(:expire_emptiness_caches) + .and_call_original - expect_any_instance_of(Repository).to receive(:expire_exists_cache). - and_call_original + expect_any_instance_of(Repository).to receive(:expire_exists_cache) + .and_call_original subject.perform(project.id, '/test/path', project.full_path, fork_project.namespace.full_path) diff --git a/spec/workers/repository_import_worker_spec.rb b/spec/workers/repository_import_worker_spec.rb index 9c277c501f1..6b30dabc80e 100644 --- a/spec/workers/repository_import_worker_spec.rb +++ b/spec/workers/repository_import_worker_spec.rb @@ -8,8 +8,8 @@ describe RepositoryImportWorker do describe '#perform' do context 'when the import was successful' do it 'imports a project' do - expect_any_instance_of(Projects::ImportService).to receive(:execute). - and_return({ status: :ok }) + expect_any_instance_of(Projects::ImportService).to receive(:execute) + .and_return({ status: :ok }) expect_any_instance_of(Repository).to receive(:expire_emptiness_caches) expect_any_instance_of(Project).to receive(:import_finish) diff --git a/vendor/Dockerfile/Binary-alpine.Dockerfile b/vendor/Dockerfile/Binary-alpine.Dockerfile new file mode 100644 index 00000000000..5a9eb2b4716 --- /dev/null +++ b/vendor/Dockerfile/Binary-alpine.Dockerfile @@ -0,0 +1,14 @@ +# This Dockerfile installs a compiled binary into a bare system. +# You must either commit your compiled binary into source control (not recommended) +# or build the binary first as part of a CI/CD pipeline. + +FROM alpine:3.5 + +# We'll likely need to add SSL root certificates +RUN apk --no-cache add ca-certificates + +WORKDIR /usr/local/bin + +# Change `app` to whatever your binary is called +Add app . +CMD ["./app"] diff --git a/vendor/Dockerfile/Binary-scratch.Dockerfile b/vendor/Dockerfile/Binary-scratch.Dockerfile new file mode 100644 index 00000000000..5e2de2ead61 --- /dev/null +++ b/vendor/Dockerfile/Binary-scratch.Dockerfile @@ -0,0 +1,17 @@ +# This Dockerfile installs a compiled binary into an image with no system at all. +# You must either commit your compiled binary into source control (not recommended) +# or build the binary first as part of a CI/CD pipeline. +# Your binary must be statically compiled with no dynamic dependencies on system libraries. +# e.g. for Docker: +# CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . + +FROM scratch + +# Since we started from scratch, we'll likely need to add SSL root certificates +ADD /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +WORKDIR /usr/local/bin + +# Change `app` to whatever your binary is called +Add app . +CMD ["./app"] diff --git a/vendor/Dockerfile/Binary.Dockerfile b/vendor/Dockerfile/Binary.Dockerfile new file mode 100644 index 00000000000..e7d560da9ac --- /dev/null +++ b/vendor/Dockerfile/Binary.Dockerfile @@ -0,0 +1,11 @@ +# This Dockerfile installs a compiled binary into a bare system. +# You must either commit your compiled binary into source control (not recommended) +# or build the binary first as part of a CI/CD pipeline. + +FROM buildpack-deps:jessie + +WORKDIR /usr/local/bin + +# Change `app` to whatever your binary is called +Add app . +CMD ["./app"] diff --git a/vendor/Dockerfile/Golang-alpine.Dockerfile b/vendor/Dockerfile/Golang-alpine.Dockerfile new file mode 100644 index 00000000000..0287315219b --- /dev/null +++ b/vendor/Dockerfile/Golang-alpine.Dockerfile @@ -0,0 +1,17 @@ +FROM golang:1.8-alpine AS builder + +WORKDIR /usr/src/app + +COPY . . +RUN go-wrapper download +RUN go build -v + +FROM alpine:3.5 + +# We'll likely need to add SSL root certificates +RUN apk --no-cache add ca-certificates + +WORKDIR /usr/local/bin + +COPY --from=builder /usr/src/app/app . +CMD ["./app"] diff --git a/vendor/Dockerfile/Golang-scratch.Dockerfile b/vendor/Dockerfile/Golang-scratch.Dockerfile new file mode 100644 index 00000000000..9057a2d0e51 --- /dev/null +++ b/vendor/Dockerfile/Golang-scratch.Dockerfile @@ -0,0 +1,20 @@ +FROM golang:1.8-alpine AS builder + +# We'll likely need to add SSL root certificates +RUN apk --no-cache add ca-certificates + +WORKDIR /usr/src/app + +COPY . . +RUN go-wrapper download +RUN CGO_ENABLED=0 GOOS=linux go build -v -a -installsuffix cgo -o app . + +FROM scratch + +# Since we started from scratch, we'll copy the SSL root certificates from the builder +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +WORKDIR /usr/local/bin + +COPY --from=builder /usr/src/app/app . +CMD ["./app"] diff --git a/vendor/Dockerfile/Golang.Dockerfile b/vendor/Dockerfile/Golang.Dockerfile new file mode 100644 index 00000000000..ec94914be19 --- /dev/null +++ b/vendor/Dockerfile/Golang.Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.8 AS builder + +WORKDIR /usr/src/app + +COPY . . +RUN go-wrapper download +RUN go build -v + +FROM buildpack-deps:jessie + +WORKDIR /usr/local/bin + +COPY --from=builder /usr/src/app/app . +CMD ["./app"] diff --git a/vendor/Dockerfile/Node-alpine.Dockerfile b/vendor/Dockerfile/Node-alpine.Dockerfile new file mode 100644 index 00000000000..9776b1336b5 --- /dev/null +++ b/vendor/Dockerfile/Node-alpine.Dockerfile @@ -0,0 +1,14 @@ +FROM node:7.9-alpine + +WORKDIR /usr/src/app + +ARG NODE_ENV +ENV NODE_ENV $NODE_ENV +COPY package.json /usr/src/app/ +RUN npm install && npm cache clean +COPY . /usr/src/app + +CMD [ "npm", "start" ] + +# replace this with your application's default port +EXPOSE 8888 diff --git a/vendor/Dockerfile/Node.Dockerfile b/vendor/Dockerfile/Node.Dockerfile new file mode 100644 index 00000000000..7e936d5e887 --- /dev/null +++ b/vendor/Dockerfile/Node.Dockerfile @@ -0,0 +1,14 @@ +FROM node:7.9 + +WORKDIR /usr/src/app + +ARG NODE_ENV +ENV NODE_ENV $NODE_ENV +COPY package.json /usr/src/app/ +RUN npm install && npm cache clean +COPY . /usr/src/app + +CMD [ "npm", "start" ] + +# replace this with your application's default port +EXPOSE 8888 diff --git a/vendor/Dockerfile/Ruby-alpine.Dockerfile b/vendor/Dockerfile/Ruby-alpine.Dockerfile new file mode 100644 index 00000000000..9db4e2130f2 --- /dev/null +++ b/vendor/Dockerfile/Ruby-alpine.Dockerfile @@ -0,0 +1,24 @@ +FROM ruby:2.4-alpine + +# Edit with nodejs, mysql-client, postgresql-client, sqlite3, etc. for your needs. +# Or delete entirely if not needed. +RUN apk --no-cache add nodejs postgresql-client + +# throw errors if Gemfile has been modified since Gemfile.lock +RUN bundle config --global frozen 1 + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY Gemfile Gemfile.lock /usr/src/app/ +RUN bundle install + +COPY . /usr/src/app + +# For Sinatra +#EXPOSE 4567 +#CMD ["ruby", "./config.rb"] + +# For Rails +EXPOSE 3000 +CMD ["rails", "server"] diff --git a/vendor/Dockerfile/Ruby.Dockerfile b/vendor/Dockerfile/Ruby.Dockerfile new file mode 100644 index 00000000000..feb880ee4b2 --- /dev/null +++ b/vendor/Dockerfile/Ruby.Dockerfile @@ -0,0 +1,27 @@ +FROM ruby:2.4 + +# Edit with nodejs, mysql-client, postgresql-client, sqlite3, etc. for your needs. +# Or delete entirely if not needed. +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + nodejs \ + postgresql-client \ + && rm -rf /var/lib/apt/lists/* + +# throw errors if Gemfile has been modified since Gemfile.lock +RUN bundle config --global frozen 1 + +WORKDIR /usr/src/app + +COPY Gemfile Gemfile.lock /usr/src/app/ +RUN bundle install -j $(nproc) + +COPY . /usr/src/app + +# For Sinatra +#EXPOSE 4567 +#CMD ["ruby", "./config.rb"] + +# For Rails +EXPOSE 3000 +CMD ["rails", "server", "-b", "0.0.0.0"] diff --git a/vendor/gitignore/Global/Archives.gitignore b/vendor/gitignore/Global/Archives.gitignore index f440b808d98..43fd5582f91 100644 --- a/vendor/gitignore/Global/Archives.gitignore +++ b/vendor/gitignore/Global/Archives.gitignore @@ -12,11 +12,11 @@ *.lzma *.cab -#packing-only formats +# Packing-only formats *.iso *.tar -#package management formats +# Package management formats *.dmg *.xpi *.gem diff --git a/vendor/gitignore/Global/JEnv.gitignore b/vendor/gitignore/Global/JEnv.gitignore new file mode 100644 index 00000000000..d838300ad5e --- /dev/null +++ b/vendor/gitignore/Global/JEnv.gitignore @@ -0,0 +1,5 @@ +# JEnv local Java version configuration file +.java-version + +# Used by previous versions of JEnv +.jenv-version diff --git a/vendor/gitignore/Global/SublimeText.gitignore b/vendor/gitignore/Global/SublimeText.gitignore index 95ff2244c99..86c3fa455aa 100644 --- a/vendor/gitignore/Global/SublimeText.gitignore +++ b/vendor/gitignore/Global/SublimeText.gitignore @@ -1,16 +1,16 @@ -# cache files for sublime text +# Cache files for Sublime Text *.tmlanguage.cache *.tmPreferences.cache *.stTheme.cache -# workspace files are user-specific +# Workspace files are user-specific *.sublime-workspace -# project files should be checked into the repository, unless a significant -# proportion of contributors will probably not be using SublimeText +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text # *.sublime-project -# sftp configuration file +# SFTP configuration file sftp-config.json # Package control specific files diff --git a/vendor/gitignore/Global/Vagrant.gitignore b/vendor/gitignore/Global/Vagrant.gitignore index a977916f658..93987ca00ec 100644 --- a/vendor/gitignore/Global/Vagrant.gitignore +++ b/vendor/gitignore/Global/Vagrant.gitignore @@ -1 +1,5 @@ +# General .vagrant/ + +# Log files (if you are creating logs in debug mode, uncomment this) +# *.logs diff --git a/vendor/gitignore/Global/Vim.gitignore b/vendor/gitignore/Global/Vim.gitignore index 42e7afc1005..6d21783d471 100644 --- a/vendor/gitignore/Global/Vim.gitignore +++ b/vendor/gitignore/Global/Vim.gitignore @@ -1,12 +1,14 @@ -# swap +# Swap [._]*.s[a-v][a-z] [._]*.sw[a-p] [._]s[a-v][a-z] [._]sw[a-p] -# session + +# Session Session.vim -# temporary + +# Temporary .netrwhist *~ -# auto-generated tag files +# Auto-generated tag files tags diff --git a/vendor/gitignore/Global/Windows.gitignore b/vendor/gitignore/Global/Windows.gitignore index ba26afd9653..dff26a9ab70 100644 --- a/vendor/gitignore/Global/Windows.gitignore +++ b/vendor/gitignore/Global/Windows.gitignore @@ -3,6 +3,9 @@ Thumbs.db ehthumbs.db ehthumbs_vista.db +# Dump file +*.stackdump + # Folder config file Desktop.ini diff --git a/vendor/gitignore/Global/macOS.gitignore b/vendor/gitignore/Global/macOS.gitignore index 5972fe50f66..9d1061e8bc4 100644 --- a/vendor/gitignore/Global/macOS.gitignore +++ b/vendor/gitignore/Global/macOS.gitignore @@ -1,3 +1,4 @@ +# General *.DS_Store .AppleDouble .LSOverride diff --git a/vendor/gitignore/Python.gitignore b/vendor/gitignore/Python.gitignore index 768d5f400bb..113294a5f18 100644 --- a/vendor/gitignore/Python.gitignore +++ b/vendor/gitignore/Python.gitignore @@ -8,7 +8,6 @@ __pycache__/ # Distribution / packaging .Python -env/ build/ develop-eggs/ dist/ @@ -43,7 +42,7 @@ htmlcov/ .cache nosetests.xml coverage.xml -*,cover +*.cover .hypothesis/ # Translations @@ -79,11 +78,10 @@ celerybeat-schedule # SageMath parsed files *.sage.py -# dotenv +# Environments .env - -# virtualenv .venv +env/ venv/ ENV/ diff --git a/vendor/gitignore/Qt.gitignore b/vendor/gitignore/Qt.gitignore index 6732e72091c..5fa47c5a1f2 100644 --- a/vendor/gitignore/Qt.gitignore +++ b/vendor/gitignore/Qt.gitignore @@ -12,6 +12,9 @@ # Qt-es +object_script.*.Release +object_script.*.Debug +*_plugin_import.cpp /.qmake.cache /.qmake.stash *.pro.user @@ -26,6 +29,11 @@ ui_*.h Makefile* *build-* + +# Qt unit tests +target_wrapper.* + + # QtCreator *.autosave diff --git a/vendor/gitignore/SugarCRM.gitignore b/vendor/gitignore/SugarCRM.gitignore index e9270205fd5..6a183d1c748 100644 --- a/vendor/gitignore/SugarCRM.gitignore +++ b/vendor/gitignore/SugarCRM.gitignore @@ -6,7 +6,7 @@ # the misuse of the repository as backup replacement. # For development the cache directory can be safely ignored and # therefore it is ignored. -/cache/ +/cache/* !/cache/index.html # Ignore some files and directories from the custom directory. /custom/history/ @@ -22,6 +22,6 @@ # Logs files can safely be ignored. *.log # Ignore the new upload directories. -/upload/ +/upload/* !/upload/index.html /upload_backup/ diff --git a/vendor/gitignore/VisualStudio.gitignore b/vendor/gitignore/VisualStudio.gitignore index 940794e60f2..22fd88a55a3 100644 --- a/vendor/gitignore/VisualStudio.gitignore +++ b/vendor/gitignore/VisualStudio.gitignore @@ -42,6 +42,9 @@ TestResult.xml [Rr]eleasePS/ dlldata.c +# Benchmark Results +BenchmarkDotNet.Artifacts/ + # .NET Core project.lock.json project.fragment.lock.json @@ -183,6 +186,7 @@ AppPackages/ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt +*.appx # Visual Studio cache files # files ending in .cache can be ignored @@ -278,6 +282,9 @@ __pycache__/ # tools/** # !tools/packages.config +# Tabs Studio +*.tss + # Telerik's JustMock configuration file *.jmconfig diff --git a/vendor/gitlab-ci-yml/.gitlab-ci.yml b/vendor/gitlab-ci-yml/.gitlab-ci.yml index 18b14554887..e2a55163682 100644 --- a/vendor/gitlab-ci-yml/.gitlab-ci.yml +++ b/vendor/gitlab-ci-yml/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: ruby:2.3-alpine +image: ruby:2.4-alpine test: - script: ruby verify_templates.rb + script: ./verify_templates.rb diff --git a/vendor/gitlab-ci-yml/Crystal.gitlab-ci.yml b/vendor/gitlab-ci-yml/Crystal.gitlab-ci.yml index 37e44735f7c..02cfab3a5b2 100644 --- a/vendor/gitlab-ci-yml/Crystal.gitlab-ci.yml +++ b/vendor/gitlab-ci-yml/Crystal.gitlab-ci.yml @@ -4,7 +4,7 @@ image: "crystallang/crystal:latest" # Pick zero or more services to be used on all builds. # Only needed when using a docker container to run your tests in. -# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service +# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service # services: # - mysql:latest # - redis:latest diff --git a/vendor/gitlab-ci-yml/Django.gitlab-ci.yml b/vendor/gitlab-ci-yml/Django.gitlab-ci.yml index 5ded2f5ce76..57afcbbe8b5 100644 --- a/vendor/gitlab-ci-yml/Django.gitlab-ci.yml +++ b/vendor/gitlab-ci-yml/Django.gitlab-ci.yml @@ -4,7 +4,7 @@ image: python:latest # Pick zero or more services to be used on all builds. # Only needed when using a docker container to run your tests in. -# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service +# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service services: - mysql:latest - postgres:latest diff --git a/vendor/gitlab-ci-yml/Docker.gitlab-ci.yml b/vendor/gitlab-ci-yml/Docker.gitlab-ci.yml index 40648bcd3de..5b6af7be8c4 100644 --- a/vendor/gitlab-ci-yml/Docker.gitlab-ci.yml +++ b/vendor/gitlab-ci-yml/Docker.gitlab-ci.yml @@ -6,8 +6,8 @@ services: build: stage: build + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - - export IMAGE_TAG=$(echo -en $CI_COMMIT_REF_NAME | tr -c '[:alnum:]_.-' '-') - - docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY - - docker build --pull -t "$CI_REGISTRY_IMAGE:$IMAGE_TAG" . - - docker push "$CI_REGISTRY_IMAGE:$IMAGE_TAG" + - docker build --pull -t "$CI_REGISTRY_IMAGE:CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:CI_COMMIT_REF_SLUG" diff --git a/vendor/gitlab-ci-yml/Elixir.gitlab-ci.yml b/vendor/gitlab-ci-yml/Elixir.gitlab-ci.yml index 981a77497e2..cf9c731637c 100644 --- a/vendor/gitlab-ci-yml/Elixir.gitlab-ci.yml +++ b/vendor/gitlab-ci-yml/Elixir.gitlab-ci.yml @@ -2,7 +2,7 @@ image: elixir:latest # Pick zero or more services to be used on all builds. # Only needed when using a docker container to run your tests in. -# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service +# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service services: - mysql:latest - redis:latest diff --git a/vendor/gitlab-ci-yml/Laravel.gitlab-ci.yml b/vendor/gitlab-ci-yml/Laravel.gitlab-ci.yml index 0d6a6eddc97..434de4f055a 100644 --- a/vendor/gitlab-ci-yml/Laravel.gitlab-ci.yml +++ b/vendor/gitlab-ci-yml/Laravel.gitlab-ci.yml @@ -4,7 +4,7 @@ image: php:latest # Pick zero or more services to be used on all builds. # Only needed when using a docker container to run your tests in. -# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service +# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service services: - mysql:latest diff --git a/vendor/gitlab-ci-yml/Nodejs.gitlab-ci.yml b/vendor/gitlab-ci-yml/Nodejs.gitlab-ci.yml index e5bce3503f3..41de1458582 100644 --- a/vendor/gitlab-ci-yml/Nodejs.gitlab-ci.yml +++ b/vendor/gitlab-ci-yml/Nodejs.gitlab-ci.yml @@ -4,7 +4,7 @@ image: node:latest # Pick zero or more services to be used on all builds. # Only needed when using a docker container to run your tests in. -# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service +# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service services: - mysql:latest - redis:latest diff --git a/vendor/gitlab-ci-yml/Pages/JBake.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/JBake.gitlab-ci.yml index bc36a4e6966..7abfaf53e8e 100644 --- a/vendor/gitlab-ci-yml/Pages/JBake.gitlab-ci.yml +++ b/vendor/gitlab-ci-yml/Pages/JBake.gitlab-ci.yml @@ -3,7 +3,7 @@ # # JBake https://jbake.org/ is a Java based, open source, static site/blog generator for developers & designers # -# This yml works with jBake 2.4.0 +# This yml works with jBake 2.5.1 # Feel free to change JBAKE_VERSION version # # HowTo at: https://jorge.aguilera.gitlab.io/howtojbake/ @@ -11,12 +11,12 @@ image: java:8 variables: - JBAKE_VERSION: 2.4.0 + JBAKE_VERSION: 2.5.1 # We use SDKMan as tool for managing versions before_script: - - apt-get update -qq && apt-get install -y -qq unzip + - apt-get update -qq && apt-get install -y -qq unzip zip - curl -sSL https://get.sdkman.io | bash - echo sdkman_auto_answer=true > /root/.sdkman/etc/config - source /root/.sdkman/bin/sdkman-init.sh diff --git a/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml b/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml index 08b57c8c0ac..4e181e85451 100644 --- a/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml +++ b/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml @@ -4,7 +4,7 @@ image: "ruby:2.3" # Pick zero or more services to be used on all builds. # Only needed when using a docker container to run your tests in. -# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service +# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service services: - mysql:latest - redis:latest diff --git a/vendor/gitlab-ci-yml/Rust.gitlab-ci.yml b/vendor/gitlab-ci-yml/Rust.gitlab-ci.yml index ae3f7405ea3..7810121c350 100644 --- a/vendor/gitlab-ci-yml/Rust.gitlab-ci.yml +++ b/vendor/gitlab-ci-yml/Rust.gitlab-ci.yml @@ -4,7 +4,7 @@ image: "scorpil/rust:stable" # Optional: Pick zero or more services to be used on all builds. # Only needed when using a docker container to run your tests in. -# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service +# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service #services: # - mysql:latest # - redis:latest diff --git a/vendor/licenses.csv b/vendor/licenses.csv index a8e7f5e3ea9..5dcac5947a1 100644 --- a/vendor/licenses.csv +++ b/vendor/licenses.csv @@ -2,7 +2,7 @@ RedCloth,4.3.2,MIT abbrev,1.0.9,ISC accepts,1.3.3,MIT ace-rails-ap,4.1.2,MIT -acorn,4.0.11,MIT +acorn,5.0.3,MIT acorn-dynamic-import,2.0.1,MIT acorn-jsx,3.0.1,MIT actionmailer,4.2.8,MIT @@ -53,6 +53,7 @@ assert-plus,0.2.0,MIT async,0.2.10,MIT async-each,1.0.1,MIT asynckit,0.4.0,MIT +atomic,1.1.99,Apache 2.0 attr_encrypted,3.0.3,MIT attr_required,1.0.0,MIT autoparse,0.3.3,Apache 2.0 @@ -151,8 +152,9 @@ blob,0.0.4,unknown block-stream,0.0.9,ISC bluebird,3.4.7,MIT bn.js,4.11.6,MIT -body-parser,1.16.0,MIT +body-parser,1.17.2,MIT boom,2.10.1,New BSD +bootsnap,1.0.0,MIT bootstrap-sass,3.3.6,MIT brace-expansion,1.1.6,MIT braces,1.8.5,MIT @@ -222,9 +224,10 @@ compression,1.6.2,MIT compression-webpack-plugin,0.3.2,MIT concat-map,0.0.1,MIT concat-stream,1.6.0,MIT +concurrent-ruby-ext,1.0.5,MIT config-chain,1.1.11,MIT configstore,1.4.0,Simplified BSD -connect,3.5.0,MIT +connect,3.6.2,MIT connect-history-api-fallback,1.3.0,MIT connection_pool,2.2.1,MIT console-browserify,1.1.0,MIT @@ -262,8 +265,9 @@ dashdash,1.14.1,MIT date-now,0.1.4,MIT de-indent,1.0.2,MIT debug,2.6.0,MIT +debugger-ruby_core_source,1.3.8,MIT decamelize,1.2.0,MIT -deckar01-task_list,1.0.6,MIT +deckar01-task_list,2.0.0,MIT deep-extend,0.4.1,MIT deep-is,0.1.3,MIT default-require-extensions,1.0.0,MIT @@ -312,8 +316,8 @@ emojis-list,2.1.0,MIT encodeurl,1.0.1,MIT encryptor,3.0.0,MIT end-of-stream,1.0.0,MIT -engine.io,1.8.2,MIT -engine.io-client,1.8.2,MIT +engine.io,1.8.3,MIT +engine.io-client,1.8.3,MIT engine.io-parser,1.3.2,MIT enhanced-resolve,3.1.0,MIT ent,2.2.0,MIT @@ -349,7 +353,8 @@ esprima,3.1.3,Simplified BSD esrecurse,4.1.0,Simplified BSD estraverse,4.1.1,Simplified BSD esutils,2.0.2,BSD -etag,1.7.0,MIT +et-orbi,1.0.3,MIT +etag,1.8.0,MIT eve-raphael,0.5.0,Apache 2.0 event-emitter,0.3.4,MIT event-stream,3.3.4,MIT @@ -364,12 +369,11 @@ expand-braces,0.1.2,MIT expand-brackets,0.1.5,MIT expand-range,1.8.2,MIT exports-loader,0.6.4,MIT -express,4.14.1,MIT +express,4.15.3,MIT expression_parser,0.9.0,MIT extend,3.0.0,MIT extglob,0.3.2,MIT extlib,0.9.16,MIT -extract-zip,1.5.0,Simplified BSD extsprintf,1.0.2,MIT faraday,0.11.0,MIT faraday_middleware,0.11.0.1,MIT @@ -378,7 +382,6 @@ fast-levenshtein,2.0.6,MIT fast_gettext,1.4.0,"MIT,ruby" fastparse,1.1.1,MIT faye-websocket,0.7.3,MIT -fd-slicer,1.0.1,MIT ffi,1.9.10,BSD figures,1.7.0,MIT file-entry-cache,2.0.0,MIT @@ -387,13 +390,16 @@ filename-regex,2.0.0,MIT fileset,2.0.3,MIT filesize,3.3.0,New BSD fill-range,2.2.3,MIT -finalhandler,0.5.1,MIT +finalhandler,1.0.3,MIT find-cache-dir,0.1.1,MIT find-root,0.1.2,MIT find-up,2.1.0,MIT flat-cache,1.2.2,MIT flatten,1.0.2,MIT +flipper,0.10.2,MIT +flipper-active_record,0.10.2,MIT flowdock,0.7.1,MIT +fog-aliyun,0.1.0,MIT fog-aws,0.13.0,MIT fog-core,1.44.1,MIT fog-google,0.5.0,MIT @@ -409,9 +415,8 @@ forever-agent,0.6.1,Apache 2.0 form-data,2.1.2,MIT formatador,0.2.5,MIT forwarded,0.1.0,MIT -fresh,0.3.0,MIT +fresh,0.5.0,MIT from,0.1.7,MIT -fs-extra,1.0.0,MIT fs.realpath,1.0.0,ISC fsevents,,unknown fstream,1.0.10,ISC @@ -427,7 +432,7 @@ get_process_mem,0.2.0,MIT getpass,0.1.6,MIT gettext_i18n_rails,1.8.0,MIT gettext_i18n_rails_js,1.2.0,MIT -gitaly,0.6.0,MIT +gitaly,0.8.0,MIT github-linguist,4.7.6,MIT github-markup,1.4.0,MIT gitlab-flowdock-git-hook,1.0.1,MIT @@ -467,7 +472,6 @@ has-flag,1.0.0,MIT has-unicode,2.0.1,ISC hash-sum,1.0.2,MIT hash.js,1.0.3,MIT -hasha,2.2.0,MIT hashie,3.5.5,MIT hashie-forbidden_attributes,0.1.1,MIT hawk,3.1.3,New BSD @@ -487,7 +491,7 @@ htmlparser2,3.9.2,MIT http,0.9.8,MIT http-cookie,1.0.3,MIT http-deceiver,1.2.7,MIT -http-errors,1.5.1,MIT +http-errors,1.6.1,MIT http-form_data,1.0.1,MIT http-proxy,1.16.2,MIT http-proxy-middleware,0.17.4,MIT @@ -516,7 +520,7 @@ inquirer,0.12.0,MIT interpret,1.0.1,MIT invariant,2.2.2,New BSD invert-kv,1.0.0,MIT -ipaddr.js,1.2.0,MIT +ipaddr.js,1.3.0,MIT ipaddress,0.8.3,MIT is-absolute,0.2.6,MIT is-absolute-url,2.1.0,MIT @@ -563,7 +567,7 @@ istanbul-lib-instrument,1.4.2,New BSD istanbul-lib-report,1.0.0-alpha.3,New BSD istanbul-lib-source-maps,1.1.0,New BSD istanbul-reports,1.0.1,New BSD -jasmine-core,2.5.2,MIT +jasmine-core,2.6.3,MIT jasmine-jquery,2.1.1,MIT jed,1.1.1,MIT jira-ruby,1.1.2,MIT @@ -587,7 +591,6 @@ json-stable-stringify,1.0.1,MIT json-stringify-safe,5.0.1,ISC json3,3.3.2,MIT json5,0.5.1,MIT -jsonfile,2.4.0,MIT jsonify,0.0.0,Public Domain jsonpointer,4.0.1,MIT jsprim,1.3.1,MIT @@ -595,17 +598,14 @@ jszip,3.1.3,(MIT OR GPL-3.0) jszip-utils,0.0.2,MIT or GPLv3 jwt,1.5.6,MIT kaminari,0.17.0,MIT -karma,1.4.1,MIT +karma,1.7.0,MIT karma-coverage-istanbul-reporter,0.2.0,MIT karma-jasmine,1.1.0,MIT karma-mocha-reporter,2.2.2,MIT -karma-phantomjs-launcher,1.0.2,MIT karma-sourcemap-loader,0.3.7,MIT karma-webpack,2.0.2,MIT -kew,0.7.0,Apache 2.0 kgio,2.10.0,LGPL-2.1+ kind-of,3.1.0,MIT -klaw,1.3.1,MIT kubeclient,2.2.0,MIT latest-version,1.0.1,MIT launchy,2.4.3,ISC @@ -667,7 +667,7 @@ methods,1.1.2,MIT micromatch,2.3.11,MIT miller-rabin,4.0.0,MIT mime,1.3.4,MIT -mime-db,1.26.0,MIT +mime-db,1.27.0,MIT mime-types,2.99.3,"MIT,Artistic-2.0,GPL-2.0" mimemagic,0.3.0,MIT mini_portile2,2.1.0,MIT @@ -675,16 +675,20 @@ minimalistic-assert,1.0.0,ISC minimatch,3.0.3,ISC minimist,0.0.8,MIT mkdirp,0.5.1,MIT +mmap2,2.2.6,ruby moment,2.17.1,MIT mousetrap,1.4.6,Apache 2.0 mousetrap-rails,1.4.6,"MIT,Apache" ms,0.7.2,MIT +msgpack,1.1.0,Apache 2.0 multi_json,1.12.1,MIT multi_xml,0.6.0,MIT multipart-post,2.0.0,MIT mustermann,0.4.0,MIT mustermann-grape,0.4.0,MIT mute-stream,0.0.5,ISC +mysql2,0.3.20,MIT +name-all-modules-plugin,1.0.1,MIT nan,2.5.1,MIT natural-compare,1.4.0,MIT negotiator,0.6.1,MIT @@ -774,9 +778,16 @@ path-type,1.1.0,MIT pause-stream,0.0.11,"MIT,Apache2" pbkdf2,3.0.9,MIT pdfjs-dist,1.8.252,Apache 2.0 -pend,1.2.0,MIT +peek,1.0.1,MIT +peek-gc,0.0.2,MIT +peek-host,1.0.0,MIT +peek-mysql2,1.1.0,MIT +peek-performance_bar,1.2.1,MIT +peek-pg,1.3.0,MIT +peek-rblineprof,0.2.0,MIT +peek-redis,1.2.0,MIT +peek-sidekiq,1.0.3,MIT pg,0.18.4,"BSD,ruby,GPL" -phantomjs-prebuilt,2.1.14,Apache 2.0 pify,2.3.0,MIT pikaday,1.5.1,"BSD,MIT" pinkie,2.0.4,MIT @@ -833,8 +844,9 @@ private,0.1.7,MIT process,0.11.9,MIT process-nextick-args,1.0.7,MIT progress,1.1.8,MIT +prometheus-client-mmap,0.7.0.beta5,Apache 2.0 proto-list,1.2.4,ISC -proxy-addr,1.1.3,MIT +proxy-addr,1.1.4,MIT prr,0.0.0,MIT ps-tree,1.1.0,MIT pseudomap,1.0.2,ISC @@ -843,7 +855,7 @@ punycode,1.4.1,MIT pyu-ruby-sasl,0.0.3.3,MIT q,1.5.0,MIT qjobs,1.1.5,MIT -qs,6.2.0,New BSD +qs,6.3.0,New BSD query-string,4.3.2,MIT querystring,0.2.0,MIT querystring-es3,0.2.1,MIT @@ -868,7 +880,7 @@ randomatic,1.1.6,MIT randombytes,2.0.3,MIT range-parser,1.2.0,MIT raphael,2.2.7,MIT -raven-js,3.15.0,Simplified BSD +raven-js,3.14.0,Simplified BSD raw-body,2.2.0,MIT raw-loader,0.5.1,MIT rc,1.1.6,(BSD-2-Clause OR MIT OR Apache-2.0) @@ -906,7 +918,6 @@ repeat-element,1.1.2,MIT repeat-string,1.6.1,MIT repeating,2.0.1,MIT request,2.79.0,Apache 2.0 -request-progress,2.0.1,MIT request_store,1.3.1,MIT require-directory,2.1.1,MIT require-from-string,1.2.1,MIT @@ -924,7 +935,7 @@ rimraf,2.5.4,ISC rinku,2.0.0,ISC ripemd160,1.0.1,New BSD rotp,2.1.2,MIT -rouge,2.0.7,MIT +rouge,2.1.0,MIT rqrcode,0.7.0,MIT rqrcode-rails3,0.1.7,MIT ruby-fogbugz,0.2.1,MIT @@ -933,7 +944,7 @@ ruby-saml,1.4.1,MIT ruby_parser,3.8.4,MIT rubyntlm,0.5.2,MIT rubypants,0.2.0,BSD -rufus-scheduler,3.1.10,MIT +rufus-scheduler,3.4.0,MIT rugged,0.25.1.1,MIT run-async,0.1.0,MIT rx-lite,3.1.2,Apache 2.0 @@ -952,20 +963,20 @@ select2,3.5.2-browserify,unknown select2-rails,3.5.9.3,MIT semver,5.3.0,ISC semver-diff,2.1.0,MIT -send,0.14.2,MIT +send,0.15.3,MIT sentry-raven,2.4.0,Apache 2.0 serve-index,1.8.0,MIT -serve-static,1.11.2,MIT +serve-static,1.12.3,MIT set-blocking,2.0.0,ISC set-immediate-shim,1.0.1,MIT setimmediate,1.0.5,MIT -setprototypeof,1.0.2,ISC +setprototypeof,1.0.3,ISC settingslogic,2.0.9,MIT sexp_processor,4.8.0,MIT sha.js,2.4.8,MIT shelljs,0.7.6,New BSD sidekiq,5.0.0,LGPL -sidekiq-cron,0.4.4,MIT +sidekiq-cron,0.6.0,MIT sidekiq-limit_fetch,3.4.0,MIT sigmund,1.0.1,ISC signal-exit,3.0.2,ISC @@ -975,9 +986,9 @@ slash,1.0.0,MIT slice-ansi,0.0.4,MIT slide,1.1.6,ISC sntp,1.0.9,BSD -socket.io,1.7.2,MIT +socket.io,1.7.3,MIT socket.io-adapter,0.5.0,MIT -socket.io-client,1.7.2,MIT +socket.io-client,1.7.3,MIT socket.io-parser,2.3.1,MIT sockjs,0.3.18,MIT sockjs-client,1.0.1,MIT @@ -1030,7 +1041,6 @@ thread_safe,0.3.6,Apache 2.0 three,0.84.0,MIT three-orbit-controls,82.1.0,MIT three-stl-loader,1.0.4,MIT -throttleit,1.0.0,MIT through,2.3.8,MIT tilt,2.0.6,MIT timeago.js,2.0.5,MIT @@ -1038,7 +1048,7 @@ timed-out,2.0.0,MIT timers-browserify,2.0.2,MIT timfel-krb5-auth,0.8.3,LGPL tiny-emitter,1.1.0,MIT -tmp,0.0.28,MIT +tmp,0.0.31,MIT to-array,0.1.4,MIT to-arraybuffer,1.0.1,MIT to-fast-properties,1.0.2,MIT @@ -1054,15 +1064,15 @@ tty-browserify,0.0.0,MIT tunnel-agent,0.4.3,Apache 2.0 tweetnacl,0.14.5,Unlicense type-check,0.3.2,MIT -type-is,1.6.14,MIT +type-is,1.6.15,MIT typedarray,0.0.6,MIT tzinfo,1.2.2,MIT u2f,0.2.1,MIT uglifier,2.7.2,MIT -uglify-js,2.8.21,Simplified BSD +uglify-js,2.8.27,Simplified BSD uglify-to-browserify,1.0.2,MIT uid-number,0.0.6,ISC -ultron,1.0.2,MIT +ultron,1.1.0,MIT unc-path-regex,0.1.2,MIT undefsafe,0.0.3,MIT / http://rem.mit-license.org underscore,1.8.3,MIT @@ -1081,14 +1091,14 @@ url-loader,0.5.8,MIT url-parse,1.0.5,MIT url_safe_base64,0.2.2,MIT user-home,2.0.0,MIT -useragent,2.1.12,MIT +useragent,2.1.13,MIT util,0.10.3,MIT util-deprecate,1.0.2,MIT utils-merge,1.0.0,MIT uuid,3.0.1,MIT validate-npm-package-license,3.0.1,Apache 2.0 validates_hostname,1.0.6,MIT -vary,1.1.0,MIT +vary,1.1.1,MIT vendors,1.0.1,MIT verror,1.3.6,MIT version_sorter,2.1.0,MIT @@ -1107,8 +1117,8 @@ vue-template-es2015-compiler,1.5.1,MIT warden,1.2.6,MIT watchpack,1.3.1,MIT wbuf,1.7.2,MIT -webpack,2.3.3,MIT -webpack-bundle-analyzer,2.3.0,MIT +webpack,2.6.1,MIT +webpack-bundle-analyzer,2.8.2,MIT webpack-dev-middleware,1.10.0,MIT webpack-dev-server,2.4.2,MIT webpack-rails,0.9.10,MIT @@ -1127,14 +1137,14 @@ wrap-ansi,2.1.0,MIT wrappy,1.0.2,ISC write,0.2.1,MIT write-file-atomic,1.3.1,ISC -ws,1.1.1,MIT +ws,2.3.1,MIT wtf-8,1.0.0,MIT xdg-basedir,2.0.0,MIT +xml-simple,1.1.5,ruby xmlhttprequest-ssl,1.5.3,MIT xtend,4.0.1,MIT y18n,3.2.1,ISC yallist,2.1.2,ISC yargs,3.10.0,MIT yargs-parser,4.2.1,ISC -yauzl,2.4.1,MIT yeast,0.1.2,MIT |