diff options
55 files changed, 1043 insertions, 191 deletions
@@ -187,7 +187,7 @@ gem 're2', '~> 1.1.1' gem 'version_sorter', '~> 2.1.0' # Export Ruby Regex to Javascript -gem 'js_regex', '~> 2.2.1' +gem 'js_regex', '~> 3.1' # User agent parsing gem 'device_detector' diff --git a/Gemfile.lock b/Gemfile.lock index a9244fd853c..f661da41507 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -113,6 +113,7 @@ GEM activesupport (>= 4.0.0) mime-types (>= 1.16) cause (0.1) + character_set (1.1.2) charlock_holmes (0.7.6) childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) @@ -400,8 +401,10 @@ GEM multipart-post oauth (~> 0.5, >= 0.5.0) jquery-atwho-rails (1.3.2) - js_regex (2.2.1) - regexp_parser (>= 0.4.11, <= 0.5.0) + js_regex (3.1.1) + character_set (~> 1.1) + regexp_parser (~> 1.1) + regexp_property_values (~> 0.3) json (1.8.6) json-jwt (1.9.4) activesupport @@ -701,7 +704,8 @@ GEM redis-store (>= 1.2, < 2) redis-store (1.6.0) redis (>= 2.2, < 5) - regexp_parser (0.5.0) + regexp_parser (1.3.0) + regexp_property_values (0.3.4) representable (3.0.4) declarative (< 0.1.0) declarative-option (< 0.2.0) @@ -1048,7 +1052,7 @@ DEPENDENCIES jaeger-client (~> 0.10.0) jira-ruby (~> 1.4) jquery-atwho-rails (~> 1.3.2) - js_regex (~> 2.2.1) + js_regex (~> 3.1) json-schema (~> 2.8.0) jwt (~> 2.1.0) kaminari (~> 1.0) diff --git a/app/assets/stylesheets/framework/common.scss b/app/assets/stylesheets/framework/common.scss index 15fe331f9e4..cb449b642e7 100644 --- a/app/assets/stylesheets/framework/common.scss +++ b/app/assets/stylesheets/framework/common.scss @@ -89,6 +89,10 @@ hr { .str-truncated { @include str-truncated; + &-30 { + @include str-truncated(30%); + } + &-60 { @include str-truncated(60%); } diff --git a/app/assets/stylesheets/framework/images.scss b/app/assets/stylesheets/framework/images.scss index a20920e2503..d78c707192f 100644 --- a/app/assets/stylesheets/framework/images.scss +++ b/app/assets/stylesheets/framework/images.scss @@ -38,7 +38,10 @@ svg { fill: currentColor; +} +.square, +svg { $svg-sizes: 8 10 12 14 16 18 24 32 48 72; @each $svg-size in $svg-sizes { &.s#{$svg-size} { diff --git a/app/controllers/concerns/record_user_last_activity.rb b/app/controllers/concerns/record_user_last_activity.rb new file mode 100644 index 00000000000..372c803278d --- /dev/null +++ b/app/controllers/concerns/record_user_last_activity.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# == RecordUserLastActivity +# +# Controller concern that updates the `last_activity_on` field of `users` +# for any authenticated GET request. The DB update will only happen once per day. +# +# In order to determine if you should include this concern or not, please check the +# description and discussion on this issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/54947 +module RecordUserLastActivity + include CookiesHelper + extend ActiveSupport::Concern + + included do + before_action :set_user_last_activity + end + + def set_user_last_activity + return unless request.get? + return unless Feature.enabled?(:set_user_last_activity, default_enabled: true) + return if Gitlab::Database.read_only? + + if current_user && current_user.last_activity_on != Date.today + Users::ActivityService.new(current_user, "visited #{request.path}").execute + end + end +end diff --git a/app/controllers/dashboard/application_controller.rb b/app/controllers/dashboard/application_controller.rb index cee0753a021..0e9fdc60363 100644 --- a/app/controllers/dashboard/application_controller.rb +++ b/app/controllers/dashboard/application_controller.rb @@ -2,6 +2,7 @@ class Dashboard::ApplicationController < ApplicationController include ControllerWithCrossProjectAccessCheck + include RecordUserLastActivity layout 'dashboard' diff --git a/app/controllers/groups/boards_controller.rb b/app/controllers/groups/boards_controller.rb index cdc6f53df8e..51fdb6c05fb 100644 --- a/app/controllers/groups/boards_controller.rb +++ b/app/controllers/groups/boards_controller.rb @@ -2,6 +2,7 @@ class Groups::BoardsController < Groups::ApplicationController include BoardsResponses + include RecordUserLastActivity before_action :assign_endpoint_vars before_action :boards, only: :index diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 15aadf3f74b..4e50106398a 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -5,6 +5,7 @@ class GroupsController < Groups::ApplicationController include IssuableCollectionsAction include ParamsBackwardCompatibility include PreviewMarkdown + include RecordUserLastActivity respond_to :html diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index f9a80aa3cfb..b9d02a62fc3 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -8,6 +8,7 @@ class Projects::IssuesController < Projects::ApplicationController include IssuableCollections include IssuesCalendar include SpammableActions + include RecordUserLastActivity def self.issue_except_actions %i[index calendar new create bulk_update import_csv] diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index bc0a3d3526d..7c4dc95529a 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -7,6 +7,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo include RendersCommits include ToggleAwardEmoji include IssuableCollections + include RecordUserLastActivity skip_before_action :merge_request, only: [:index, :bulk_update] before_action :whitelist_query_limiting, only: [:assign_related_issues, :update] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d3af35723ac..33c6608d321 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -6,6 +6,7 @@ class ProjectsController < Projects::ApplicationController include ExtractsPath include PreviewMarkdown include SendFileUpload + include RecordUserLastActivity prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:rss) } diff --git a/app/helpers/profiles_helper.rb b/app/helpers/profiles_helper.rb index df318de740a..5a42e581867 100644 --- a/app/helpers/profiles_helper.rb +++ b/app/helpers/profiles_helper.rb @@ -25,4 +25,8 @@ module ProfilesHelper end end end + + def user_profile? + params[:controller] == 'users' + end end diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 84010e40ef4..6b2b7e77180 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -48,13 +48,23 @@ module Ci delegate :trigger_short_token, to: :trigger_request, allow_nil: true ## - # The "environment" field for builds is a String, and is the unexpanded name! + # Since Gitlab 11.5, deployments records started being created right after + # `ci_builds` creation. We can look up a relevant `environment` through + # `deployment` relation today. This is much more efficient than expanding + # environment name with variables. + # (See more https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22380) # + # However, we have to still expand environment name if it's a stop action, + # because `deployment` persists information for start action only. + # + # We will follow up this by persisting expanded name in build metadata or + # persisting stop action in database. def persisted_environment return unless has_environment? strong_memoize(:persisted_environment) do - Environment.find_by(name: expanded_environment_name, project: project) + deployment&.environment || + Environment.find_by(name: expanded_environment_name, project: project) end end diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index a3029a54604..712347e76ed 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -7,6 +7,7 @@ class MergeRequestDiff < ActiveRecord::Base include IgnorableColumn include EachBatch include Gitlab::Utils::StrongMemoize + include ObjectStorage::BackgroundMove # Don't display more than 100 commits at once COMMITS_SAFE_SIZE = 100 @@ -15,9 +16,13 @@ class MergeRequestDiff < ActiveRecord::Base :st_diffs belongs_to :merge_request + manual_inverse_association :merge_request, :merge_request_diff - has_many :merge_request_diff_files, -> { order(:merge_request_diff_id, :relative_order) } + has_many :merge_request_diff_files, + -> { order(:merge_request_diff_id, :relative_order) }, + inverse_of: :merge_request_diff + has_many :merge_request_diff_commits, -> { order(:merge_request_diff_id, :relative_order) } state_machine :state, initial: :empty do @@ -45,10 +50,14 @@ class MergeRequestDiff < ActiveRecord::Base scope :recent, -> { order(id: :desc).limit(100) } + mount_uploader :external_diff, ExternalDiffUploader + # All diff information is collected from repository after object is created. # It allows you to override variables like head_commit_sha before getting diff. after_create :save_git_content, unless: :importing? + after_save :update_external_diff_store, if: :external_diff_changed? + def self.find_by_diff_refs(diff_refs) find_by(start_commit_sha: diff_refs.start_sha, head_commit_sha: diff_refs.head_sha, base_commit_sha: diff_refs.base_sha) end @@ -241,10 +250,97 @@ class MergeRequestDiff < ActiveRecord::Base end end + # Carrierwave defines `write_uploader` dynamically on this class, so `super` + # does not work. Alias the carrierwave method so we can call it when needed + alias_method :carrierwave_write_uploader, :write_uploader + + # The `external_diff`, `external_diff_store`, and `stored_externally` + # columns were introduced in GitLab 11.8, but some background migration specs + # use factories that rely on current code with an old schema. Without these + # `has_attribute?` guards, they fail with a `MissingAttributeError`. + # + # For more details, see: https://gitlab.com/gitlab-org/gitlab-ce/issues/44990 + + def write_uploader(column, identifier) + carrierwave_write_uploader(column, identifier) if has_attribute?(column) + end + + def update_external_diff_store + update_column(:external_diff_store, external_diff.object_store) if + has_attribute?(:external_diff_store) + end + + def external_diff_changed? + super if has_attribute?(:external_diff) + end + + def stored_externally + super if has_attribute?(:stored_externally) + end + alias_method :stored_externally?, :stored_externally + + # If enabled, yields the external file containing the diff. Otherwise, yields + # nil. This method is not thread-safe, but it *is* re-entrant, which allows + # multiple merge_request_diff_files to load their data efficiently + def opening_external_diff + return yield(nil) unless stored_externally? + return yield(@external_diff_file) if @external_diff_file + + external_diff.open do |file| + begin + @external_diff_file = file + + yield(@external_diff_file) + ensure + @external_diff_file = nil + end + end + end + private def create_merge_request_diff_files(diffs) - rows = diffs.map.with_index do |diff, index| + rows = + if has_attribute?(:external_diff) && Gitlab.config.external_diffs.enabled + build_external_merge_request_diff_files(diffs) + else + build_merge_request_diff_files(diffs) + end + + # Faster inserts + Gitlab::Database.bulk_insert('merge_request_diff_files', rows) + end + + def build_external_merge_request_diff_files(diffs) + rows = build_merge_request_diff_files(diffs) + tempfile = build_external_diff_tempfile(rows) + + self.external_diff = tempfile + self.stored_externally = true + + rows + ensure + tempfile&.unlink + end + + def build_external_diff_tempfile(rows) + Tempfile.open(external_diff.filename) do |file| + rows.inject(0) do |offset, row| + data = row.delete(:diff) + row[:external_diff_offset] = offset + row[:external_diff_size] = data.size + + file.write(data) + + offset + data.size + end + + file + end + end + + def build_merge_request_diff_files(diffs) + diffs.map.with_index do |diff, index| diff_hash = diff.to_hash.merge( binary: false, merge_request_diff_id: self.id, @@ -261,18 +357,20 @@ class MergeRequestDiff < ActiveRecord::Base end end end - - Gitlab::Database.bulk_insert('merge_request_diff_files', rows) end def load_diffs(options) - collection = merge_request_diff_files + # Ensure all diff files operate on the same external diff file instance if + # present. This reduces file open/close overhead. + opening_external_diff do + collection = merge_request_diff_files - if paths = options[:paths] - collection = collection.where('old_path IN (?) OR new_path IN (?)', paths, paths) - end + if paths = options[:paths] + collection = collection.where('old_path IN (?) OR new_path IN (?)', paths, paths) + end - Gitlab::Git::DiffCollection.new(collection.map(&:to_hash), options) + Gitlab::Git::DiffCollection.new(collection.map(&:to_hash), options) + end end def load_commits diff --git a/app/models/merge_request_diff_file.rb b/app/models/merge_request_diff_file.rb index a9f110bec5c..e8d936e265c 100644 --- a/app/models/merge_request_diff_file.rb +++ b/app/models/merge_request_diff_file.rb @@ -4,7 +4,7 @@ class MergeRequestDiffFile < ActiveRecord::Base include Gitlab::EncodingHelper include DiffFile - belongs_to :merge_request_diff + belongs_to :merge_request_diff, inverse_of: :merge_request_diff_files def utf8_diff return '' if diff.blank? @@ -13,6 +13,16 @@ class MergeRequestDiffFile < ActiveRecord::Base end def diff - binary? ? super.unpack('m0').first : super + content = + if merge_request_diff&.stored_externally? + merge_request_diff.opening_external_diff do |file| + file.seek(external_diff_offset) + file.read(external_diff_size) + end + else + super + end + + binary? ? content.unpack('m0').first : content end end diff --git a/app/uploaders/external_diff_uploader.rb b/app/uploaders/external_diff_uploader.rb new file mode 100644 index 00000000000..d2707cd0777 --- /dev/null +++ b/app/uploaders/external_diff_uploader.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class ExternalDiffUploader < GitlabUploader + include ObjectStorage::Concern + + storage_options Gitlab.config.external_diffs + + alias_method :upload, :model + + def filename + "diff-#{model.id}" + end + + def store_dir + dynamic_segment + end + + private + + def dynamic_segment + File.join(model.model_name.plural, "mr-#{model.merge_request_id}") + end +end diff --git a/app/views/email_rejection_mailer/rejection.html.haml b/app/views/email_rejection_mailer/rejection.html.haml index c4ae7befe4e..666dab61f40 100644 --- a/app/views/email_rejection_mailer/rejection.html.haml +++ b/app/views/email_rejection_mailer/rejection.html.haml @@ -1,5 +1,5 @@ %p - Unfortunately, your email message to GitLab could not be processed. + = _("Unfortunately, your email message to GitLab could not be processed.") = markdown @reason = render_if_exists 'shared/additional_email_text' diff --git a/app/views/email_rejection_mailer/rejection.text.haml b/app/views/email_rejection_mailer/rejection.text.haml index 0e13b2a6473..8d940ef1293 100644 --- a/app/views/email_rejection_mailer/rejection.text.haml +++ b/app/views/email_rejection_mailer/rejection.text.haml @@ -1,4 +1,4 @@ -Unfortunately, your email message to GitLab could not be processed. += _("Unfortunately, your email message to GitLab could not be processed.") \ = @reason = render_if_exists 'shared/additional_email_text' diff --git a/app/views/events/_events.html.haml b/app/views/events/_events.html.haml index 6ae4c334f7f..e1b7804c5a7 100644 --- a/app/views/events/_events.html.haml +++ b/app/views/events/_events.html.haml @@ -1,4 +1,18 @@ +- illustration_path = 'illustrations/profile-page/activity.svg' +- current_user_empty_message_header = s_('UserProfile|Join or create a group to start contributing by commenting on issues or submitting merge requests!') +- primary_button_label = _('New group') +- primary_button_link = new_group_path +- secondary_button_label = _('Explore groups') +- secondary_button_link = explore_groups_path +- visitor_empty_message = _('No activities found') + - if @events.present? = render partial: 'events/event', collection: @events - else - .nothing-here-block= _("No activities found") + = render partial: 'shared/empty_states/profile_tabs', locals: { illustration_path: illustration_path, + current_user_empty_message_header: current_user_empty_message_header, + primary_button_label: primary_button_label, + primary_button_link: primary_button_link, + secondary_button_label: secondary_button_label, + secondary_button_link: secondary_button_link, + visitor_empty_message: visitor_empty_message } diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml index 7694217eb28..0be41b5888c 100644 --- a/app/views/projects/_home_panel.html.haml +++ b/app/views/projects/_home_panel.html.haml @@ -21,9 +21,14 @@ - if @project.tag_list.present? %span.home-panel-topic-list.d-inline-flex.prepend-left-8.has-tooltip{ data: { container: 'body' }, title: @project.has_extra_topics? ? @project.tag_list.join(', ') : nil } = sprite_icon('tag', size: 16, css_class: 'icon append-right-4') - = @project.topics_to_show + + - @project.topics_to_show.each do |topic| + %a{ class: 'badge badge-pill badge-secondary append-right-5 str-truncated-30', href: explore_projects_path(tag: topic) } + = topic.titleize + - if @project.has_extra_topics? - = _("+ %{count} more") % { count: @project.count_of_extra_topics_not_shown } + .text-nowrap + = _("+ %{count} more") % { count: @project.count_of_extra_topics_not_shown } .project-repo-buttons.col-md-12.col-lg-6.d-inline-flex.flex-wrap.justify-content-lg-end diff --git a/app/views/shared/empty_states/_profile_tabs.html.haml b/app/views/shared/empty_states/_profile_tabs.html.haml new file mode 100644 index 00000000000..6da40e1b059 --- /dev/null +++ b/app/views/shared/empty_states/_profile_tabs.html.haml @@ -0,0 +1,19 @@ +- current_user_empty_message_description = local_assigns.fetch(:current_user_empty_message_description, nil) +- secondary_button_link = local_assigns.fetch(:secondary_button_link, nil) + +.nothing-here-block + .svg-content + = image_tag illustration_path, size: '75' + .text-content + - if user_profile? and current_user.present? and current_user.username == params[:username] + %h5= current_user_empty_message_header + + - if current_user_empty_message_description.present? + %p= current_user_empty_message_description + + - if secondary_button_link.present? + = link_to secondary_button_label, secondary_button_link, class: 'btn btn-create btn-inverted' + + = link_to primary_button_label, primary_button_link, class: 'btn btn-success' + - else + %h5= visitor_empty_message diff --git a/app/views/shared/groups/_list.html.haml b/app/views/shared/groups/_list.html.haml index f50a6bd4d6a..c5b39c7db08 100644 --- a/app/views/shared/groups/_list.html.haml +++ b/app/views/shared/groups/_list.html.haml @@ -1,3 +1,10 @@ +- illustration_path = 'illustrations/profile-page/groups.svg' +- current_user_empty_message_header = s_('UserProfile|You can create a group for several dependent projects.') +- current_user_empty_message_description = s_('UserProfile|Groups are the best way to manage projects and members.') +- primary_button_label = _('New group') +- primary_button_link = new_group_path +- visitor_empty_message = s_('GroupsEmptyState|No groups found') + - if groups.any? - user = local_assigns[:user] @@ -5,4 +12,9 @@ - groups.each_with_index do |group, i| = render "shared/groups/group", group: group, user: user - else - .nothing-here-block= s_("GroupsEmptyState|No groups found") + = render partial: 'shared/empty_states/profile_tabs', locals: { illustration_path: illustration_path, + current_user_empty_message_header: current_user_empty_message_header, + current_user_empty_message_description: current_user_empty_message_description, + primary_button_label: primary_button_label, + primary_button_link: primary_button_link, + visitor_empty_message: visitor_empty_message } diff --git a/app/views/shared/projects/_list.html.haml b/app/views/shared/projects/_list.html.haml index 7d90d9ca4a5..13847cd9be1 100644 --- a/app/views/shared/projects/_list.html.haml +++ b/app/views/shared/projects/_list.html.haml @@ -14,6 +14,17 @@ - skip_pagination = false unless local_assigns[:skip_pagination] == true - compact_mode = false unless local_assigns[:compact_mode] == true - css_classes = "#{'compact' if compact_mode} #{'explore' if explore_projects_tab?}" +- contributed_projects_illustration_path = 'illustrations/profile-page/contributed-projects.svg' +- contributed_projects_current_user_empty_message_header = s_('UserProfile|Explore public groups to find projects to contribute to.') +- contributed_projects_visitor_empty_message = s_('UserProfile|This user hasn\'t contributed to any projects') +- own_projects_illustration_path = 'illustrations/profile-page/personal-project.svg' +- own_projects_current_user_empty_message_header = s_('UserProfile|You haven\'t created any personal projects.') +- own_projects_current_user_empty_message_description = s_('UserProfile|Your projects can be available publicly, internally, or privately, at your choice.') +- own_projects_visitor_empty_message = s_('UserProfile|This user doesn\'t have any personal projects') +- primary_button_label = _('New project') +- primary_button_link = new_project_path +- secondary_button_label = _('Explore groups') +- secondary_button_link = explore_groups_path .js-projects-list-holder - if any_projects?(projects) @@ -33,9 +44,18 @@ %span you have no access to. = paginate_collection(projects, remote: remote) unless skip_pagination - else - .nothing-here-block - .svg-content.svg-130 - = image_tag 'illustrations/profile-page/personal-project.svg' - %div - %span - = s_('UserProfile|This user doesn\'t have any personal projects') + - if @contributed_projects + = render partial: 'shared/empty_states/profile_tabs', locals: { illustration_path: contributed_projects_illustration_path, + current_user_empty_message_header: contributed_projects_current_user_empty_message_header, + primary_button_label: primary_button_label, + primary_button_link: primary_button_link, + secondary_button_label: secondary_button_label, + secondary_button_link: secondary_button_link, + visitor_empty_message: contributed_projects_visitor_empty_message } + - else + = render partial: 'shared/empty_states/profile_tabs', locals: { illustration_path: own_projects_illustration_path, + current_user_empty_message_header: own_projects_current_user_empty_message_header, + current_user_empty_message_description: own_projects_current_user_empty_message_description, + primary_button_label: primary_button_label, + primary_button_link: primary_button_link, + visitor_empty_message: own_projects_visitor_empty_message } diff --git a/app/views/snippets/_snippets.html.haml b/app/views/snippets/_snippets.html.haml index 69d41f8fe5e..dab247da251 100644 --- a/app/views/snippets/_snippets.html.haml +++ b/app/views/snippets/_snippets.html.haml @@ -1,10 +1,21 @@ - link_project = local_assigns.fetch(:link_project, false) +- illustration_path = 'illustrations/profile-page/activity.svg' +- current_user_empty_message_header = s_('UserProfile|You haven\'t created any snippets.') +- current_user_empty_message_description = s_('UserProfile|Snippets in GitLab can either be private, internal, or public.') +- primary_button_label = _('New snippet') +- primary_button_link = new_snippet_path +- visitor_empty_message = s_('UserProfile|No snippets found.') .snippets-list-holder %ul.content-list = render partial: 'shared/snippets/snippet', collection: @snippets, locals: { link_project: link_project } - if @snippets.empty? %li - .nothing-here-block= _("Nothing here.") + = render partial: 'shared/empty_states/profile_tabs', locals: { illustration_path: illustration_path, + current_user_empty_message_header: current_user_empty_message_header, + current_user_empty_message_description: current_user_empty_message_description, + primary_button_label: primary_button_label, + primary_button_link: primary_button_link, + visitor_empty_message: visitor_empty_message } = paginate @snippets, theme: 'gitlab' diff --git a/changelogs/unreleased/28500-empty-states-for-profile-page.yml b/changelogs/unreleased/28500-empty-states-for-profile-page.yml new file mode 100644 index 00000000000..53f840521ae --- /dev/null +++ b/changelogs/unreleased/28500-empty-states-for-profile-page.yml @@ -0,0 +1,5 @@ +--- +title: Refresh empty states for profile page tabs +merge_request: 24549 +author: +type: changed diff --git a/changelogs/unreleased/52568-external-mr-diffs.yml b/changelogs/unreleased/52568-external-mr-diffs.yml new file mode 100644 index 00000000000..b1c9d5cb809 --- /dev/null +++ b/changelogs/unreleased/52568-external-mr-diffs.yml @@ -0,0 +1,5 @@ +--- +title: Allow merge request diffs to be placed into an object store +merge_request: 24276 +author: +type: added diff --git a/changelogs/unreleased/54544-update-project-topics-styling-to-use-badges-design.yml b/changelogs/unreleased/54544-update-project-topics-styling-to-use-badges-design.yml new file mode 100644 index 00000000000..de12c66e9ef --- /dev/null +++ b/changelogs/unreleased/54544-update-project-topics-styling-to-use-badges-design.yml @@ -0,0 +1,5 @@ +--- +title: Update project topics styling to use badges design +merge_request: 24415 +author: +type: changed diff --git a/changelogs/unreleased/chore-update-js-regex.yml b/changelogs/unreleased/chore-update-js-regex.yml new file mode 100644 index 00000000000..d45d0b47457 --- /dev/null +++ b/changelogs/unreleased/chore-update-js-regex.yml @@ -0,0 +1,5 @@ +--- +title: Upgrade js-regex gem to version 3.1 +merge_request: 24433 +author: rroger +type: changed diff --git a/changelogs/unreleased/gt-externalize-app-views-email_rejection_mailer.yml b/changelogs/unreleased/gt-externalize-app-views-email_rejection_mailer.yml new file mode 100644 index 00000000000..8f6fbdceb54 --- /dev/null +++ b/changelogs/unreleased/gt-externalize-app-views-email_rejection_mailer.yml @@ -0,0 +1,5 @@ +--- +title: Externalize strings from `/app/views/email_rejection_mailer` +merge_request: 24869 +author: George Tsiolis +type: other diff --git a/changelogs/unreleased/rd-update-last_activity_on-on-logins-and-browsing-activity-54947.yml b/changelogs/unreleased/rd-update-last_activity_on-on-logins-and-browsing-activity-54947.yml new file mode 100644 index 00000000000..abce9dcc0c6 --- /dev/null +++ b/changelogs/unreleased/rd-update-last_activity_on-on-logins-and-browsing-activity-54947.yml @@ -0,0 +1,5 @@ +--- +title: Update last_activity_on for Users on some main GET endpoints +merge_request: 24642 +author: +type: changed diff --git a/changelogs/unreleased/use-deployment-relation-to-fetch-environment-ce.yml b/changelogs/unreleased/use-deployment-relation-to-fetch-environment-ce.yml new file mode 100644 index 00000000000..1ec276b4abc --- /dev/null +++ b/changelogs/unreleased/use-deployment-relation-to-fetch-environment-ce.yml @@ -0,0 +1,5 @@ +--- +title: Use deployment relation to get an environment name +merge_request: 24890 +author: +type: performance diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 6fc33e8971e..be23166cb7b 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -166,6 +166,23 @@ production: &base # aws_signature_version: 4 # For creation of signed URLs. Set to 2 if provider does not support v4. # endpoint: 'https://s3.amazonaws.com' # default: nil - Useful for S3 compliant services such as DigitalOcean Spaces + ## Merge request external diff storage + external_diffs: + # If disabled (the default), the diffs are in-database. Otherwise, they can + # be stored on disk, or in object storage + enabled: false + # The location where external diffs are stored (default: shared/lfs-external-diffs). + # storage_path: shared/external-diffs + # object_store: + # enabled: false + # remote_directory: external-diffs + # background_upload: false + # proxy_download: false + # connection: + # provider: AWS + # aws_access_key_id: AWS_ACCESS_KEY_ID + # aws_secret_access_key: AWS_SECRET_ACCESS_KEY + # region: us-east-1 ## Git LFS lfs: @@ -733,6 +750,18 @@ test: <<: *base gravatar: enabled: true + external_diffs: + enabled: false + # The location where external diffs are stored (default: shared/external-diffs). + # storage_path: shared/external-diffs + object_store: + enabled: false + remote_directory: external-diffs # The bucket name + connection: + provider: AWS # Only AWS supported at the moment + aws_access_key_id: AWS_ACCESS_KEY_ID + aws_secret_access_key: AWS_SECRET_ACCESS_KEY + region: us-east-1 lfs: enabled: false # The location where LFS objects are stored (default: shared/lfs-objects). diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 1aed41e02ab..dfcf1e648b4 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -216,6 +216,14 @@ Settings.pages['admin'] ||= Settingslogic.new({}) Settings.pages.admin['certificate'] ||= '' # +# External merge request diffs +# +Settings['external_diffs'] ||= Settingslogic.new({}) +Settings.external_diffs['enabled'] = false if Settings.external_diffs['enabled'].nil? +Settings.external_diffs['storage_path'] = Settings.absolute(Settings.external_diffs['storage_path'] || File.join(Settings.shared['path'], 'external-diffs')) +Settings.external_diffs['object_store'] = ObjectStoreSettings.parse(Settings.external_diffs['object_store']) + +# # Git LFS # Settings['lfs'] ||= Settingslogic.new({}) diff --git a/db/migrate/20190109153125_add_merge_request_external_diffs.rb b/db/migrate/20190109153125_add_merge_request_external_diffs.rb new file mode 100644 index 00000000000..c67903c7f67 --- /dev/null +++ b/db/migrate/20190109153125_add_merge_request_external_diffs.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddMergeRequestExternalDiffs < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def change + # Allow the merge request diff to store details about an external file + add_column :merge_request_diffs, :external_diff, :string + add_column :merge_request_diffs, :external_diff_store, :integer + add_column :merge_request_diffs, :stored_externally, :boolean + + # The diff for each file is mapped to a range in the external file + add_column :merge_request_diff_files, :external_diff_offset, :integer + add_column :merge_request_diff_files, :external_diff_size, :integer + + # If the diff is in object storage, it will be null in the database + change_column_null :merge_request_diff_files, :diff, true + end +end diff --git a/db/schema.rb b/db/schema.rb index 4b6e4992056..20c8dab4c3e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1203,8 +1203,10 @@ ActiveRecord::Schema.define(version: 20190131122559) do t.string "b_mode", null: false t.text "new_path", null: false t.text "old_path", null: false - t.text "diff", null: false + t.text "diff" t.boolean "binary" + t.integer "external_diff_offset" + t.integer "external_diff_size" t.index ["merge_request_diff_id", "relative_order"], name: "index_merge_request_diff_files_on_mr_diff_id_and_order", unique: true, using: :btree end @@ -1218,6 +1220,9 @@ ActiveRecord::Schema.define(version: 20190131122559) do t.string "head_commit_sha" t.string "start_commit_sha" t.integer "commits_count" + t.string "external_diff" + t.integer "external_diff_store" + t.boolean "stored_externally" t.index ["merge_request_id", "id"], name: "index_merge_request_diffs_on_merge_request_id_and_id", using: :btree end diff --git a/doc/administration/index.md b/doc/administration/index.md index 0b673d61139..184754cd467 100644 --- a/doc/administration/index.md +++ b/doc/administration/index.md @@ -48,6 +48,7 @@ Learn how to install, configure, update, and maintain your GitLab instance. - [Third party offers](../user/admin_area/settings/third_party_offers.md) - [Compliance](compliance.md): A collection of features from across the application that you may configure to help ensure that your GitLab instance and DevOps workflow meet compliance standards. - [Diff limits](../user/admin_area/diff_limits.md): Configure the diff rendering size limits of branch comparison pages. +- [Merge request diffs](merge_request_diffs.md): Configure the diffs shown on merge requests - [Broadcast Messages](../user/admin_area/broadcast_messages.md): Send messages to GitLab users through the UI. #### Customizing GitLab's appearance diff --git a/doc/administration/merge_request_diffs.md b/doc/administration/merge_request_diffs.md new file mode 100644 index 00000000000..94620c3d3a0 --- /dev/null +++ b/doc/administration/merge_request_diffs.md @@ -0,0 +1,154 @@ +# Merge request diffs administration + +> **Notes:** +> - External merge request diffs introduced in GitLab 11.8 + +Merge request diffs are size-limited copies of diffs associated with merge +requests. When viewing a merge request, diffs are sourced from these copies +wherever possible as a performance optimization. + +By default, merge request diffs are stored in the database, in a table named +`merge_request_diff_files`. Larger installations may find this table grows too +large, in which case, switching to external storage is recommended. + +### Using external storage + +Merge request diffs can be stored on disk, or in object storage. In general, it +is better to store the diffs in the database than on disk. + +To enable external storage of merge request diffs: + +--- + +**In Omnibus installations:** + +1. Edit `/etc/gitlab/gitlab.rb` and add the following line: + + ```ruby + gitlab_rails['external_diffs_enabled'] = true + ``` + +1. _The external diffs will be stored in in + `/var/opt/gitlab/gitlab-rails/shared/external-diffs`._ To change the path, + for example to `/mnt/storage/external-diffs`, edit `/etc/gitlab/gitlab.rb` + and add the following line: + + ```ruby + gitlab_rails['external_diffs_storage_path'] = "/mnt/storage/external-diffs" + ``` + +1. Save the file and [reconfigure GitLab][] for the changes to take effect. + +--- + +**In installations from source:** + +1. Edit `/home/git/gitlab/config/gitlab.yml` and add or amend the following + lines: + + ```yaml + external_diffs: + enabled: true + ``` + +1. _The external diffs will be stored in + `/home/git/gitlab/shared/external-diffs`._ To change the path, for example + to `/mnt/storage/external-diffs`, edit `/home/git/gitlab/config/gitlab.yml` + and add or amend the following lines: + + ```yaml + external_diffs: + enabled: true + storage_path: /mnt/storage/external-diffs + ``` + +1. Save the file and [restart GitLab][] for the changes to take effect. + +### Using object storage + +Instead of storing the external diffs on disk, we recommended you use an object +store like AWS S3 instead. This configuration relies on valid AWS credentials to +be configured already. + +### Object Storage Settings + +For source installations, these settings are nested under `external_diffs:` and +then `object_store:`. On omnibus installs, they are prefixed by +`external_diffs_object_store_`. + +| Setting | Description | Default | +|---------|-------------|---------| +| `enabled` | Enable/disable object storage | `false` | +| `remote_directory` | The bucket name where external diffs will be stored| | +| `direct_upload` | Set to true to enable direct upload of external diffs without the need of local shared storage. Option may be removed once we decide to support only single storage for all files. | `false` | +| `background_upload` | Set to false to disable automatic upload. Option may be removed once upload is direct to S3 | `true` | +| `proxy_download` | Set to true to enable proxying all files served. Option allows to reduce egress traffic as this allows clients to download directly from remote storage instead of proxying all data | `false` | +| `connection` | Various connection options described below | | + +#### S3 compatible connection settings + +The connection settings match those provided by [Fog](https://github.com/fog), and are as follows: + +| Setting | Description | Default | +|---------|-------------|---------| +| `provider` | Always `AWS` for compatible hosts | AWS | +| `aws_access_key_id` | AWS credentials, or compatible | | +| `aws_secret_access_key` | AWS credentials, or compatible | | +| `aws_signature_version` | AWS signature version to use. 2 or 4 are valid options. Digital Ocean Spaces and other providers may need 2. | 4 | +| `region` | AWS region | us-east-1 | +| `host` | S3 compatible host for when not using AWS, e.g. `localhost` or `storage.example.com` | s3.amazonaws.com | +| `endpoint` | Can be used when configuring an S3 compatible service such as [Minio](https://www.minio.io), by entering a URL such as `http://127.0.0.1:9000` | (optional) | +| `path_style` | Set to true to use `host/bucket_name/object` style paths instead of `bucket_name.host/object`. Leave as false for AWS S3 | false | +| `use_iam_profile` | Set to true to use IAM profile instead of access keys | false + +**In Omnibus installations:** + +1. Edit `/etc/gitlab/gitlab.rb` and add the following lines by replacing with + the values you want: + + ```ruby + gitlab_rails['external_diffs_enabled'] = true + gitlab_rails['external_diffs_object_store_enabled'] = true + gitlab_rails['external_diffs_object_store_remote_directory'] = "external-diffs" + gitlab_rails['external_diffs_object_store_connection'] = { + 'provider' => 'AWS', + 'region' => 'eu-central-1', + 'aws_access_key_id' => 'AWS_ACCESS_KEY_ID', + 'aws_secret_access_key' => 'AWS_SECRET_ACCESS_KEY' + } + ``` + + NOTE: if you are using AWS IAM profiles, be sure to omit the + AWS access key and secret access key/value pairs. For example: + + ```ruby + gitlab_rails['external_diffs_object_store_connection'] = { + 'provider' => 'AWS', + 'region' => 'eu-central-1', + 'use_iam_profile' => true + } + ``` + +1. Save the file and [reconfigure GitLab][] for the changes to take effect. + +--- + +**In installations from source:** + +1. Edit `/home/git/gitlab/config/gitlab.yml` and add or amend the following + lines: + + ```yaml + external_diffs: + enabled: true + object_store: + enabled: true + remote_directory: "external-diffs" # The bucket name + connection: + provider: AWS # Only AWS supported at the moment + aws_access_key_id: AWS_ACCESS_KEY_ID + aws_secret_access_key: AWS_SECRET_ACCESS_KEY + region: eu-central-1 + ``` + +1. Save the file and [restart GitLab][] for the changes to take effect. diff --git a/doc/api/users.md b/doc/api/users.md index 6000b9b900f..fd8778abb17 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -1212,6 +1212,7 @@ The activities that update the timestamp are: - Git HTTP/SSH activities (such as clone, push) - User logging in into GitLab + - User visiting pages related to Dashboards, Projects, Issues and Merge Requests ([introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/54947) in GitLab 11.8) By default, it shows the activity for all users in the last 6 months, but this can be amended by using the `from` parameter. diff --git a/doc/development/file_storage.md b/doc/development/file_storage.md index b90dc90e424..597812c8c49 100644 --- a/doc/development/file_storage.md +++ b/doc/development/file_storage.md @@ -18,6 +18,7 @@ There are many places where file uploading is used, according to contexts: - Issues/MR/Notes Legacy Markdown attachments - CI Artifacts (archive, metadata, trace) - LFS Objects + - Merge request diffs ## Disk storage @@ -37,6 +38,7 @@ they are still not 100% standardized. You can see them below: | Issues/MR/Notes Legacy Markdown attachments | no | uploads/-/system/note/attachment/:id/:filename | `AttachmentUploader` | Note | | CI Artifacts (CE) | yes | shared/artifacts/:disk_hash[0..1]/:disk_hash[2..3]/:disk_hash/:year_:month_:date/:job_id/:job_artifact_id (:disk_hash is SHA256 digest of project_id) | `JobArtifactUploader` | Ci::JobArtifact | | LFS Objects (CE) | yes | shared/lfs-objects/:hex/:hex/:object_hash | `LfsObjectUploader` | LfsObject | +| External merge request diffs | yes | shared/external-diffs/merge_request_diffs/mr-:parent_id/diff-:id | `ExternalDiffUploader` | MergeRequestDiff | CI Artifacts and LFS Objects behave differently in CE and EE. In CE they inherit the `GitlabUploader` while in EE they inherit the `ObjectStorage` and store files in and S3 API compatible object store. diff --git a/doc/ssh/README.md b/doc/ssh/README.md index 09a97fcea07..80de39c207a 100644 --- a/doc/ssh/README.md +++ b/doc/ssh/README.md @@ -19,7 +19,7 @@ comes pre-installed on GNU/Linux and macOS, but not on Windows. Depending on your Windows version, there are different methods to work with SSH keys. -### Installing the SSH client for Windows 10 +### Windows 10: Windows Subsystem for Linux Starting with Windows 10, you can [install the Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/install-win10) @@ -27,10 +27,10 @@ where you can run Linux distributions directly on Windows, without the overhead of a virtual machine. Once installed and set up, you'll have the Git and SSH clients at your disposal. -### Installing the SSH client for Windows 8.1 and Windows 7 +### Windows 10, 8.1, and 7: Git for Windows The easiest way to install Git and the SSH client on Windows 8.1 and Windows 7 -is [Git for Windows](https://gitforwindows.org). It provides a BASH +is [Git for Windows](https://gitforwindows.org). It provides a Bash emulation (Git Bash) used for running Git from the command line and the `ssh-keygen` command that is useful to create SSH keys as you'll learn below. diff --git a/doc/user/instance_statistics/user_cohorts.md b/doc/user/instance_statistics/user_cohorts.md index f52f24ef5f7..e76363a6d9f 100644 --- a/doc/user/instance_statistics/user_cohorts.md +++ b/doc/user/instance_statistics/user_cohorts.md @@ -25,3 +25,4 @@ How do we measure the activity of users? GitLab considers a user active if: - The user signs in. - The user has Git activity (whether push or pull). +- The user visits pages related to Dashboards, Projects, Issues and Merge Requests ([introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/54947) in GitLab 11.8). diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index add7ee58da6..099677a791c 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -130,9 +130,14 @@ excluded_attributes: snippets: - :expired_at merge_request_diff: + - :external_diff + - :stored_externally + - :external_diff_store - :st_diffs merge_request_diff_files: - :diff + - :external_diff_offset + - :external_diff_size issues: - :milestone_id merge_requests: diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index 74cd70c6e9f..b94b21775ee 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -29,10 +29,11 @@ namespace :gitlab do # If MySQL, turn off foreign key checks connection.execute('SET FOREIGN_KEY_CHECKS=0') if Gitlab::Database.mysql? - tables = connection.tables + tables = connection.data_sources + # Removes the entry from the array tables.delete 'schema_migrations' # Truncate schema_migrations to ensure migrations re-run - connection.execute('TRUNCATE schema_migrations') + connection.execute('TRUNCATE schema_migrations') if connection.data_source_exists? 'schema_migrations' # Drop tables with cascade to avoid dependent table errors # PG: http://www.postgresql.org/docs/current/static/ddl-depend.html diff --git a/locale/gitlab.pot b/locale/gitlab.pot index f426652ee4d..f2c0e96a9e1 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -4839,9 +4839,6 @@ msgstr "" msgid "Notes|Show history only" msgstr "" -msgid "Nothing here." -msgstr "" - msgid "Notification events" msgstr "" @@ -7686,6 +7683,9 @@ msgstr "" msgid "Undo" msgstr "" +msgid "Unfortunately, your email message to GitLab could not be processed." +msgstr "" + msgid "Unlock" msgstr "" @@ -7833,12 +7833,24 @@ msgstr "" msgid "UserProfile|Edit profile" msgstr "" +msgid "UserProfile|Explore public groups to find projects to contribute to." +msgstr "" + msgid "UserProfile|Groups" msgstr "" +msgid "UserProfile|Groups are the best way to manage projects and members." +msgstr "" + +msgid "UserProfile|Join or create a group to start contributing by commenting on issues or submitting merge requests!" +msgstr "" + msgid "UserProfile|Most Recent Activity" msgstr "" +msgid "UserProfile|No snippets found." +msgstr "" + msgid "UserProfile|Overview" msgstr "" @@ -7851,6 +7863,9 @@ msgstr "" msgid "UserProfile|Snippets" msgstr "" +msgid "UserProfile|Snippets in GitLab can either be private, internal, or public." +msgstr "" + msgid "UserProfile|Subscribe" msgstr "" @@ -7860,12 +7875,27 @@ msgstr "" msgid "UserProfile|This user has a private profile" msgstr "" +msgid "UserProfile|This user hasn't contributed to any projects" +msgstr "" + msgid "UserProfile|View all" msgstr "" msgid "UserProfile|View user in admin area" msgstr "" +msgid "UserProfile|You can create a group for several dependent projects." +msgstr "" + +msgid "UserProfile|You haven't created any personal projects." +msgstr "" + +msgid "UserProfile|You haven't created any snippets." +msgstr "" + +msgid "UserProfile|Your projects can be available publicly, internally, or privately, at your choice." +msgstr "" + msgid "Users" msgstr "" diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index f7efc3f325c..bc36c6f948f 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -110,16 +110,23 @@ describe 'Project' do it 'shows project topics' do project.update_attribute(:tag_list, 'topic1') + visit path + expect(page).to have_css('.home-panel-topic-list') - expect(page).to have_content('topic1') + expect(page).to have_link('Topic1', href: explore_projects_path(tag: 'topic1')) end it 'shows up to 3 project tags' do project.update_attribute(:tag_list, 'topic1, topic2, topic3, topic4') + visit path + expect(page).to have_css('.home-panel-topic-list') - expect(page).to have_content('topic1, topic2, topic3 + 1 more') + expect(page).to have_link('Topic1', href: explore_projects_path(tag: 'topic1')) + expect(page).to have_link('Topic2', href: explore_projects_path(tag: 'topic2')) + expect(page).to have_link('Topic3', href: explore_projects_path(tag: 'topic3')) + expect(page).to have_content('+ 1 more') end end diff --git a/spec/features/users/overview_spec.rb b/spec/features/users/overview_spec.rb index 3708f0ee477..3db9ae7a951 100644 --- a/spec/features/users/overview_spec.rb +++ b/spec/features/users/overview_spec.rb @@ -34,7 +34,7 @@ describe 'Overview tab on a user profile', :js do it 'does not show any entries in the list of activities' do page.within('.activities-block') do expect(page).to have_selector('.loading', visible: false) - expect(page).to have_content('No activities found') + expect(page).to have_content('Join or create a group to start contributing by commenting on issues or submitting merge requests!') expect(page).not_to have_selector('.event-item') end end @@ -96,7 +96,7 @@ describe 'Overview tab on a user profile', :js do it 'it shows an empty project list with an info message' do page.within('.projects-block') do expect(page).to have_selector('.loading', visible: false) - expect(page).to have_content('This user doesn\'t have any personal projects') + expect(page).to have_content('You haven\'t created any personal projects.') expect(page).not_to have_selector('.project-row') end end diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index 34d9115a1f6..ab67a5ab847 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -51,7 +51,7 @@ describe UsersHelper do false | 'mockRegexPattern' | { user_internal_regex_pattern: nil, user_internal_regex_options: nil } true | nil | { user_internal_regex_pattern: nil, user_internal_regex_options: nil } true | '' | { user_internal_regex_pattern: nil, user_internal_regex_options: nil } - true | 'mockRegexPattern' | { user_internal_regex_pattern: 'mockRegexPattern', user_internal_regex_options: 'gi' } + true | 'mockRegexPattern' | { user_internal_regex_pattern: 'mockRegexPattern', user_internal_regex_options: 'i' } end with_them do diff --git a/spec/javascripts/notes/components/note_app_spec.js b/spec/javascripts/notes/components/note_app_spec.js index 22bee049f9c..d5c0bf6b25d 100644 --- a/spec/javascripts/notes/components/note_app_spec.js +++ b/spec/javascripts/notes/components/note_app_spec.js @@ -1,57 +1,49 @@ import $ from 'jquery'; import _ from 'underscore'; import Vue from 'vue'; -import notesApp from '~/notes/components/notes_app.vue'; +import { mount, createLocalVue } from '@vue/test-utils'; +import NotesApp from '~/notes/components/notes_app.vue'; import service from '~/notes/services/notes_service'; import createStore from '~/notes/stores'; import '~/behaviors/markdown/render_gfm'; -import { mountComponentWithStore } from 'spec/helpers'; import * as mockData from '../mock_data'; -const vueMatchers = { - toIncludeElement() { - return { - compare(vm, selector) { - const result = { - pass: vm.$el.querySelector(selector) !== null, - }; - return result; - }, - }; - }, -}; - describe('note_app', () => { let mountComponent; - let vm; + let wrapper; let store; beforeEach(() => { - jasmine.addMatchers(vueMatchers); $('body').attr('data-page', 'projects:merge_requests:show'); - setFixtures('<div class="js-vue-notes-event"><div id="app"></div></div>'); - - const IssueNotesApp = Vue.extend(notesApp); - store = createStore(); mountComponent = data => { - const props = data || { + const propsData = data || { noteableData: mockData.noteableDataMock, notesData: mockData.notesDataMock, userData: mockData.userDataMock, }; - - return mountComponentWithStore(IssueNotesApp, { - props, - store, - el: document.getElementById('app'), - }); + const localVue = createLocalVue(); + + return mount( + { + components: { + NotesApp, + }, + template: '<div class="js-vue-notes-event"><notes-app v-bind="$attrs" /></div>', + }, + { + propsData, + store, + localVue, + sync: false, + }, + ); }; }); afterEach(() => { - vm.$destroy(); + wrapper.destroy(); }); describe('set data', () => { @@ -65,7 +57,7 @@ describe('note_app', () => { beforeEach(() => { Vue.http.interceptors.push(responseInterceptor); - vm = mountComponent(); + wrapper = mountComponent(); }); afterEach(() => { @@ -73,26 +65,26 @@ describe('note_app', () => { }); it('should set notes data', () => { - expect(vm.$store.state.notesData).toEqual(mockData.notesDataMock); + expect(store.state.notesData).toEqual(mockData.notesDataMock); }); it('should set issue data', () => { - expect(vm.$store.state.noteableData).toEqual(mockData.noteableDataMock); + expect(store.state.noteableData).toEqual(mockData.noteableDataMock); }); it('should set user data', () => { - expect(vm.$store.state.userData).toEqual(mockData.userDataMock); + expect(store.state.userData).toEqual(mockData.userDataMock); }); it('should fetch discussions', () => { - expect(vm.$store.state.discussions).toEqual([]); + expect(store.state.discussions).toEqual([]); }); }); describe('render', () => { beforeEach(() => { Vue.http.interceptors.push(mockData.individualNoteInterceptor); - vm = mountComponent(); + wrapper = mountComponent(); }); afterEach(() => { @@ -107,51 +99,50 @@ describe('note_app', () => { setTimeout(() => { expect( - vm.$el.querySelector('.main-notes-list .note-header-author-name').textContent.trim(), + wrapper + .find('.main-notes-list .note-header-author-name') + .text() + .trim(), ).toEqual(note.author.name); - expect(vm.$el.querySelector('.main-notes-list .note-text').innerHTML).toEqual( - note.note_html, - ); + expect(wrapper.find('.main-notes-list .note-text').html()).toContain(note.note_html); done(); }, 0); }); it('should render form', () => { - expect(vm.$el.querySelector('.js-main-target-form').tagName).toEqual('FORM'); - expect( - vm.$el.querySelector('.js-main-target-form textarea').getAttribute('placeholder'), - ).toEqual('Write a comment or drag your files here…'); + expect(wrapper.find('.js-main-target-form').name()).toEqual('form'); + expect(wrapper.find('.js-main-target-form textarea').attributes('placeholder')).toEqual( + 'Write a comment or drag your files here…', + ); }); it('should not render form when commenting is disabled', () => { store.state.commentsDisabled = true; - vm = mountComponent(); + wrapper = mountComponent(); - expect(vm.$el.querySelector('.js-main-target-form')).toEqual(null); + expect(wrapper.find('.js-main-target-form').exists()).toBe(false); }); it('should render form comment button as disabled', () => { - expect(vm.$el.querySelector('.js-note-new-discussion').getAttribute('disabled')).toEqual( - 'disabled', - ); + expect(wrapper.find('.js-note-new-discussion').attributes('disabled')).toEqual('disabled'); }); }); describe('while fetching data', () => { beforeEach(() => { - vm = mountComponent(); + wrapper = mountComponent(); }); it('renders skeleton notes', () => { - expect(vm).toIncludeElement('.animation-container'); + expect(wrapper.find('.animation-container').exists()).toBe(true); }); it('should render form', () => { - expect(vm.$el.querySelector('.js-main-target-form').tagName).toEqual('FORM'); - expect( - vm.$el.querySelector('.js-main-target-form textarea').getAttribute('placeholder'), - ).toEqual('Write a comment or drag your files here…'); + expect(wrapper.find('.js-main-target-form').name()).toEqual('form'); + expect(wrapper.find('.js-main-target-form textarea').attributes('placeholder')).toEqual( + 'Write a comment or drag your files here…', + ); }); }); @@ -160,9 +151,9 @@ describe('note_app', () => { beforeEach(done => { Vue.http.interceptors.push(mockData.individualNoteInterceptor); spyOn(service, 'updateNote').and.callThrough(); - vm = mountComponent(); + wrapper = mountComponent(); setTimeout(() => { - vm.$el.querySelector('.js-note-edit').click(); + wrapper.find('.js-note-edit').trigger('click'); Vue.nextTick(done); }, 0); }); @@ -175,12 +166,12 @@ describe('note_app', () => { }); it('renders edit form', () => { - expect(vm).toIncludeElement('.js-vue-issue-note-form'); + expect(wrapper.find('.js-vue-issue-note-form').exists()).toBe(true); }); it('calls the service to update the note', done => { - vm.$el.querySelector('.js-vue-issue-note-form').value = 'this is a note'; - vm.$el.querySelector('.js-vue-issue-save').click(); + wrapper.find('.js-vue-issue-note-form').value = 'this is a note'; + wrapper.find('.js-vue-issue-save').trigger('click'); expect(service.updateNote).toHaveBeenCalled(); // Wait for the requests to finish before destroying @@ -194,10 +185,10 @@ describe('note_app', () => { beforeEach(done => { Vue.http.interceptors.push(mockData.discussionNoteInterceptor); spyOn(service, 'updateNote').and.callThrough(); - vm = mountComponent(); + wrapper = mountComponent(); setTimeout(() => { - vm.$el.querySelector('.js-note-edit').click(); + wrapper.find('.js-note-edit').trigger('click'); Vue.nextTick(done); }, 0); }); @@ -210,12 +201,12 @@ describe('note_app', () => { }); it('renders edit form', () => { - expect(vm).toIncludeElement('.js-vue-issue-note-form'); + expect(wrapper.find('.js-vue-issue-note-form').exists()).toBe(true); }); it('updates the note and resets the edit form', done => { - vm.$el.querySelector('.js-vue-issue-note-form').value = 'this is a note'; - vm.$el.querySelector('.js-vue-issue-save').click(); + wrapper.find('.js-vue-issue-note-form').value = 'this is a note'; + wrapper.find('.js-vue-issue-save').trigger('click'); expect(service.updateNote).toHaveBeenCalled(); // Wait for the requests to finish before destroying @@ -228,30 +219,36 @@ describe('note_app', () => { describe('new note form', () => { beforeEach(() => { - vm = mountComponent(); + wrapper = mountComponent(); }); it('should render markdown docs url', () => { const { markdownDocsPath } = mockData.notesDataMock; - expect(vm.$el.querySelector(`a[href="${markdownDocsPath}"]`).textContent.trim()).toEqual( - 'Markdown', - ); + expect( + wrapper + .find(`a[href="${markdownDocsPath}"]`) + .text() + .trim(), + ).toEqual('Markdown'); }); it('should render quick action docs url', () => { const { quickActionsDocsPath } = mockData.notesDataMock; - expect(vm.$el.querySelector(`a[href="${quickActionsDocsPath}"]`).textContent.trim()).toEqual( - 'quick actions', - ); + expect( + wrapper + .find(`a[href="${quickActionsDocsPath}"]`) + .text() + .trim(), + ).toEqual('quick actions'); }); }); describe('edit form', () => { beforeEach(() => { Vue.http.interceptors.push(mockData.individualNoteInterceptor); - vm = mountComponent(); + wrapper = mountComponent(); }); afterEach(() => { @@ -260,12 +257,15 @@ describe('note_app', () => { it('should render markdown docs url', done => { setTimeout(() => { - vm.$el.querySelector('.js-note-edit').click(); + wrapper.find('.js-note-edit').trigger('click'); const { markdownDocsPath } = mockData.notesDataMock; Vue.nextTick(() => { expect( - vm.$el.querySelector(`.edit-note a[href="${markdownDocsPath}"]`).textContent.trim(), + wrapper + .find(`.edit-note a[href="${markdownDocsPath}"]`) + .text() + .trim(), ).toEqual('Markdown is supported'); done(); }); @@ -274,13 +274,11 @@ describe('note_app', () => { it('should not render quick actions docs url', done => { setTimeout(() => { - vm.$el.querySelector('.js-note-edit').click(); + wrapper.find('.js-note-edit').trigger('click'); const { quickActionsDocsPath } = mockData.notesDataMock; Vue.nextTick(() => { - expect(vm.$el.querySelector(`.edit-note a[href="${quickActionsDocsPath}"]`)).toEqual( - null, - ); + expect(wrapper.find(`.edit-note a[href="${quickActionsDocsPath}"]`).exists()).toBe(false); done(); }); }, 0); @@ -295,12 +293,19 @@ describe('note_app', () => { noteId: 1, }, }); + const toggleAwardAction = jasmine.createSpy('toggleAward'); + wrapper.vm.$store.hotUpdate({ + actions: { + toggleAward: toggleAwardAction, + }, + }); - spyOn(vm.$store, 'dispatch'); + wrapper.vm.$parent.$el.dispatchEvent(toggleAwardEvent); - vm.$el.parentElement.dispatchEvent(toggleAwardEvent); + expect(toggleAwardAction).toHaveBeenCalledTimes(1); + const [, payload] = toggleAwardAction.calls.argsFor(0); - expect(vm.$store.dispatch).toHaveBeenCalledWith('toggleAward', { + expect(payload).toEqual({ awardName: 'test', noteId: 1, }); diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 8a1bbb26e57..47865e4d08f 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1844,6 +1844,26 @@ describe Ci::Build do context 'when there is no environment' do it { is_expected.to be_nil } end + + context 'when build has a start environment' do + let(:build) { create(:ci_build, :deploy_to_production, pipeline: pipeline) } + + it 'does not expand environment name' do + expect(build).not_to receive(:expanded_environment_name) + + subject + end + end + + context 'when build has a stop environment' do + let(:build) { create(:ci_build, :stop_review_app, pipeline: pipeline) } + + it 'expands environment name' do + expect(build).to receive(:expanded_environment_name) + + subject + end + end end describe '#play' do diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb index 33e984dc399..1849d3bac12 100644 --- a/spec/models/merge_request_diff_spec.rb +++ b/spec/models/merge_request_diff_spec.rb @@ -46,7 +46,7 @@ describe MergeRequestDiff do it { expect(first_diff.reload).not_to be_latest } end - describe '#diffs' do + shared_examples_for 'merge request diffs' do let(:merge_request) { create(:merge_request, :with_diffs) } let!(:diff) { merge_request.merge_request_diff.reload } @@ -91,98 +91,110 @@ describe MergeRequestDiff do diff.diffs.diff_files end end - end - describe '#raw_diffs' do - context 'when the :ignore_whitespace_change option is set' do - it 'creates a new compare object instead of loading from the DB' do - expect(diff_with_commits).not_to receive(:load_diffs) - expect(diff_with_commits.compare).to receive(:diffs).and_call_original + describe '#raw_diffs' do + context 'when the :ignore_whitespace_change option is set' do + it 'creates a new compare object instead of using preprocessed data' do + expect(diff_with_commits).not_to receive(:load_diffs) + expect(diff_with_commits.compare).to receive(:diffs).and_call_original - diff_with_commits.raw_diffs(ignore_whitespace_change: true) + diff_with_commits.raw_diffs(ignore_whitespace_change: true) + end end - end - context 'when the raw diffs are empty' do - before do - MergeRequestDiffFile.where(merge_request_diff_id: diff_with_commits.id).delete_all - end + context 'when the raw diffs are empty' do + before do + MergeRequestDiffFile.where(merge_request_diff_id: diff_with_commits.id).delete_all + end - it 'returns an empty DiffCollection' do - expect(diff_with_commits.raw_diffs).to be_a(Gitlab::Git::DiffCollection) - expect(diff_with_commits.raw_diffs).to be_empty + it 'returns an empty DiffCollection' do + expect(diff_with_commits.raw_diffs).to be_a(Gitlab::Git::DiffCollection) + expect(diff_with_commits.raw_diffs).to be_empty + end end - end - context 'when the raw diffs exist' do - it 'returns the diffs' do - expect(diff_with_commits.raw_diffs).to be_a(Gitlab::Git::DiffCollection) - expect(diff_with_commits.raw_diffs).not_to be_empty - end + context 'when the raw diffs exist' do + it 'returns the diffs' do + expect(diff_with_commits.raw_diffs).to be_a(Gitlab::Git::DiffCollection) + expect(diff_with_commits.raw_diffs).not_to be_empty + end - context 'when the :paths option is set' do - let(:diffs) { diff_with_commits.raw_diffs(paths: ['files/ruby/popen.rb', 'files/ruby/popen.rb']) } + context 'when the :paths option is set' do + let(:diffs) { diff_with_commits.raw_diffs(paths: ['files/ruby/popen.rb', 'files/ruby/popen.rb']) } - it 'only returns diffs that match the (old path, new path) given' do - expect(diffs.map(&:new_path)).to contain_exactly('files/ruby/popen.rb') - end + it 'only returns diffs that match the (old path, new path) given' do + expect(diffs.map(&:new_path)).to contain_exactly('files/ruby/popen.rb') + end - it 'only serializes diff files found by query' do - expect(diff_with_commits.merge_request_diff_files.count).to be > 10 - expect_any_instance_of(MergeRequestDiffFile).to receive(:to_hash).once + it 'only serializes diff files found by query' do + expect(diff_with_commits.merge_request_diff_files.count).to be > 10 + expect_any_instance_of(MergeRequestDiffFile).to receive(:to_hash).once - diffs - end + diffs + end - it 'uses the diffs from the DB' do - expect(diff_with_commits).to receive(:load_diffs) + it 'uses the preprocessed diffs' do + expect(diff_with_commits).to receive(:load_diffs) - diffs + diffs + end end end end - end - describe '#save_diffs' do - it 'saves collected state' do - mr_diff = create(:merge_request).merge_request_diff + describe '#save_diffs' do + it 'saves collected state' do + mr_diff = create(:merge_request).merge_request_diff - expect(mr_diff.collected?).to be_truthy - end + expect(mr_diff.collected?).to be_truthy + end - it 'saves overflow state' do - allow(Commit).to receive(:max_diff_options) - .and_return(max_lines: 0, max_files: 0) + it 'saves overflow state' do + allow(Commit).to receive(:max_diff_options) + .and_return(max_lines: 0, max_files: 0) - mr_diff = create(:merge_request).merge_request_diff + mr_diff = create(:merge_request).merge_request_diff - expect(mr_diff.overflow?).to be_truthy - end + expect(mr_diff.overflow?).to be_truthy + end - it 'saves empty state' do - allow_any_instance_of(described_class).to receive_message_chain(:compare, :commits) - .and_return([]) + it 'saves empty state' do + allow_any_instance_of(described_class).to receive_message_chain(:compare, :commits) + .and_return([]) - mr_diff = create(:merge_request).merge_request_diff + mr_diff = create(:merge_request).merge_request_diff - expect(mr_diff.empty?).to be_truthy - end + expect(mr_diff.empty?).to be_truthy + end - it 'expands collapsed diffs before saving' do - mr_diff = create(:merge_request, source_branch: 'expand-collapse-lines', target_branch: 'master').merge_request_diff - diff_file = mr_diff.merge_request_diff_files.find_by(new_path: 'expand-collapse/file-5.txt') + it 'expands collapsed diffs before saving' do + mr_diff = create(:merge_request, source_branch: 'expand-collapse-lines', target_branch: 'master').merge_request_diff + diff_file = mr_diff.merge_request_diff_files.find_by(new_path: 'expand-collapse/file-5.txt') - expect(diff_file.diff).not_to be_empty + expect(diff_file.diff).not_to be_empty + end + + it 'saves binary diffs correctly' do + path = 'files/images/icn-time-tracking.pdf' + mr_diff = create(:merge_request, source_branch: 'add-pdf-text-binary', target_branch: 'master').merge_request_diff + diff_file = mr_diff.merge_request_diff_files.find_by(new_path: path) + + expect(diff_file).to be_binary + expect(diff_file.diff).to eq(mr_diff.compare.diffs(paths: [path]).to_a.first.diff) + end end + end - it 'saves binary diffs correctly' do - path = 'files/images/icn-time-tracking.pdf' - mr_diff = create(:merge_request, source_branch: 'add-pdf-text-binary', target_branch: 'master').merge_request_diff - diff_file = mr_diff.merge_request_diff_files.find_by(new_path: path) + describe 'internal diffs configured' do + include_examples 'merge request diffs' + end - expect(diff_file).to be_binary - expect(diff_file.diff).to eq(mr_diff.compare.diffs(paths: [path]).to_a.first.diff) + describe 'external diffs configured' do + before do + stub_external_diffs_setting(enabled: true) end + + include_examples 'merge request diffs' end describe '#commit_shas' do @@ -245,4 +257,55 @@ describe MergeRequestDiff do expect(subject.modified_paths).to eq(%w{foo bar baz}) end end + + describe '#opening_external_diff' do + subject(:diff) { diff_with_commits } + + context 'external diffs disabled' do + it { expect(diff.external_diff).not_to be_exists } + + it 'yields nil' do + expect { |b| diff.opening_external_diff(&b) }.to yield_with_args(nil) + end + end + + context 'external diffs enabled' do + let(:test_dir) { 'tmp/tests/external-diffs' } + + around do |example| + FileUtils.mkdir_p(test_dir) + + begin + example.run + ensure + FileUtils.rm_rf(test_dir) + end + end + + before do + stub_external_diffs_setting(enabled: true, storage_path: test_dir) + end + + it { expect(diff.external_diff).to be_exists } + + it 'yields an open file' do + expect { |b| diff.opening_external_diff(&b) }.to yield_with_args(File) + end + + it 'is re-entrant' do + outer_file_a = + diff.opening_external_diff do |outer_file| + diff.opening_external_diff do |inner_file| + expect(outer_file).to eq(inner_file) + end + + outer_file + end + + diff.opening_external_diff do |outer_file_b| + expect(outer_file_a).not_to eq(outer_file_b) + end + end + end + end end diff --git a/spec/requests/user_activity_spec.rb b/spec/requests/user_activity_spec.rb new file mode 100644 index 00000000000..15666e00b9f --- /dev/null +++ b/spec/requests/user_activity_spec.rb @@ -0,0 +1,114 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Update of user activity' do + let(:user) { create(:user, last_activity_on: nil) } + + before do + group = create(:group, name: 'group') + project = create(:project, :public, namespace: group, name: 'project') + + create(:issue, project: project, iid: 10) + create(:merge_request, source_project: project, iid: 15) + + project.add_maintainer(user) + end + + paths_to_visit = [ + '/group', + '/group/project', + '/groups/group/-/issues', + '/groups/group/-/boards', + '/dashboard/projects', + '/dashboard/snippets', + '/dashboard/groups', + '/dashboard/todos', + '/group/project/issues', + '/group/project/issues/10', + '/group/project/merge_requests', + '/group/project/merge_requests/15' + ] + + context 'without an authenticated user' do + it 'does not set the last activity cookie' do + get "/group/project" + + expect(response.cookies['user_last_activity_on']).to be_nil + end + end + + context 'with an authenticated user' do + before do + login_as(user) + end + + context 'with a POST request' do + it 'does not set the last activity cookie' do + post "/group/project/archive" + + expect(response.cookies['user_last_activity_on']).to be_nil + end + end + + paths_to_visit.each do |path| + context "on GET to #{path}" do + it 'updates the last activity date' do + expect(Users::ActivityService).to receive(:new).and_call_original + + get path + + expect(user.last_activity_on).to eq(Date.today) + end + + context 'when calling it twice' do + it 'updates last_activity_on just once' do + expect(Users::ActivityService).to receive(:new).once.and_call_original + + 2.times do + get path + end + end + end + + context 'when last_activity_on is nil' do + before do + user.update_attribute(:last_activity_on, nil) + end + + it 'updates the last activity date' do + expect(user.last_activity_on).to be_nil + + get path + + expect(user.last_activity_on).to eq(Date.today) + end + end + + context 'when last_activity_on is stale' do + before do + user.update_attribute(:last_activity_on, 2.days.ago.to_date) + end + + it 'updates the last activity date' do + get path + + expect(user.last_activity_on).to eq(Date.today) + end + end + + context 'when last_activity_on is up to date' do + before do + user.update_attribute(:last_activity_on, Date.today) + end + + it 'does not try to update it' do + expect(Users::ActivityService).not_to receive(:new) + + get path + end + end + end + end + end +end diff --git a/spec/support/helpers/stub_configuration.rb b/spec/support/helpers/stub_configuration.rb index 2851cd9733c..ff21bbe28ca 100644 --- a/spec/support/helpers/stub_configuration.rb +++ b/spec/support/helpers/stub_configuration.rb @@ -56,6 +56,10 @@ module StubConfiguration allow(Gitlab.config.lfs).to receive_messages(to_settings(messages)) end + def stub_external_diffs_setting(messages) + allow(Gitlab.config.external_diffs).to receive_messages(to_settings(messages)) + end + def stub_artifacts_setting(messages) allow(Gitlab.config.artifacts).to receive_messages(to_settings(messages)) end diff --git a/spec/support/helpers/stub_object_storage.rb b/spec/support/helpers/stub_object_storage.rb index 58b5c6a6435..e0c50e533a6 100644 --- a/spec/support/helpers/stub_object_storage.rb +++ b/spec/support/helpers/stub_object_storage.rb @@ -42,6 +42,13 @@ module StubObjectStorage **params) end + def stub_external_diffs_object_storage(uploader = described_class, **params) + stub_object_storage_uploader(config: Gitlab.config.external_diffs.object_store, + uploader: uploader, + remote_directory: 'external_diffs', + **params) + end + def stub_lfs_object_storage(**params) stub_object_storage_uploader(config: Gitlab.config.lfs.object_store, uploader: LfsObjectUploader, diff --git a/spec/uploaders/external_diff_uploader_spec.rb b/spec/uploaders/external_diff_uploader_spec.rb new file mode 100644 index 00000000000..1c959770dc4 --- /dev/null +++ b/spec/uploaders/external_diff_uploader_spec.rb @@ -0,0 +1,67 @@ +require 'spec_helper' + +describe ExternalDiffUploader do + let(:diff) { create(:merge_request).merge_request_diff } + let(:path) { Gitlab.config.external_diffs.storage_path } + + subject(:uploader) { described_class.new(diff, :external_diff) } + + it_behaves_like "builds correct paths", + store_dir: %r[merge_request_diffs/mr-\d+], + cache_dir: %r[/external-diffs/tmp/cache], + work_dir: %r[/external-diffs/tmp/work] + + context "object store is REMOTE" do + before do + stub_external_diffs_object_storage + end + + include_context 'with storage', described_class::Store::REMOTE + + it_behaves_like "builds correct paths", + store_dir: %r[merge_request_diffs/mr-\d+] + end + + describe 'migration to object storage' do + context 'with object storage disabled' do + it "is skipped" do + expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async) + + diff + end + end + + context 'with object storage enabled' do + before do + stub_external_diffs_setting(enabled: true) + stub_external_diffs_object_storage(background_upload: true) + end + + it 'is scheduled to run after creation' do + expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with(described_class.name, 'MergeRequestDiff', :external_diff, kind_of(Numeric)) + + diff + end + end + end + + describe 'remote file' do + context 'with object storage enabled' do + before do + stub_external_diffs_setting(enabled: true) + stub_external_diffs_object_storage + + diff.update!(external_diff_store: described_class::Store::REMOTE) + end + + it 'can store file remotely' do + allow(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async) + + diff + + expect(diff.external_diff_store).to eq(described_class::Store::REMOTE) + expect(diff.external_diff.path).not_to be_blank + end + end + end +end diff --git a/spec/validators/js_regex_validator_spec.rb b/spec/validators/js_regex_validator_spec.rb index aeb55cdc0e5..4d3bafaf267 100644 --- a/spec/validators/js_regex_validator_spec.rb +++ b/spec/validators/js_regex_validator_spec.rb @@ -12,8 +12,6 @@ describe JsRegexValidator do '' | [] '(?#comment)' | ['Regex Pattern (?#comment) can not be expressed in Javascript'] '(?(a)b|c)' | ['invalid conditional pattern: /(?(a)b|c)/i'] - '[a-z&&[^uo]]' | ["Dropped unsupported set intersection '[a-z&&[^uo]]' at index 0", - "Dropped unsupported nested negative set data '[^uo]' at index 6"] end with_them do |