diff options
34 files changed, 168 insertions, 267 deletions
diff --git a/CHANGELOG b/CHANGELOG index 7a7f86bcba8..aab2416a09b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -52,6 +52,7 @@ v 8.0.0 (unreleased) - Added service API endpoint to retrieve service parameters (Petheő Bence) - Add FogBugz project import (Jared Szechy) - Sort users autocomplete lists by user (Allister Antosik) + - Webhook for issue now contains repository field (Jungkook Park) v 7.14.3 - No changes diff --git a/app/controllers/ci/helps_controller.rb b/app/controllers/ci/helps_controller.rb deleted file mode 100644 index a1ee4111614..00000000000 --- a/app/controllers/ci/helps_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Ci - class HelpsController < Ci::ApplicationController - skip_filter :check_config - - def show - end - - def oauth2 - if valid_config? - redirect_to ci_root_path - else - render layout: 'ci/empty' - end - end - end -end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index d7be212c33a..8776721d243 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -18,12 +18,6 @@ class Projects::BlobController < Projects::ApplicationController before_action :after_edit_path, only: [:edit, :update] def new - @title = 'Upload' - @placeholder = 'Upload new file' - @button_title = 'Upload file' - @form_path = namespace_project_create_blob_path(@project.namespace, @project, @id) - @method = :post - commit unless @repository.empty? end @@ -46,11 +40,6 @@ class Projects::BlobController < Projects::ApplicationController end def show - @title = "Replace #{@blob.name}" - @placeholder = @title - @button_title = 'Replace file' - @form_path = namespace_project_update_blob_path(@project.namespace, @project, @id) - @method = :put end def edit diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index 9efe9704d1e..86f4a02a6e9 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -66,12 +66,7 @@ class Projects::MilestonesController < Projects::ApplicationController def destroy return access_denied! unless can?(current_user, :admin_milestone, @project) - update_params = { milestone: nil } - @milestone.issues.each do |issue| - Issues::UpdateService.new(@project, current_user, update_params).execute(issue) - end - - @milestone.destroy + Milestones::DestroyService.new(project, current_user).execute(milestone) respond_to do |format| format.html { redirect_to namespace_project_milestones_path } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b049bd9fcc2..39ab83ccf12 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,7 +13,9 @@ module ApplicationHelper # current_controller?(:commits) # => false # current_controller?(:commits, :tree) # => true def current_controller?(*args) - args.any? { |v| v.to_s.downcase == controller.controller_name } + args.any? do |v| + v.to_s.downcase == controller.controller_name || v.to_s.downcase == controller.controller_path + end end # Check if a particular action is the current one diff --git a/app/helpers/ci/application_helper.rb b/app/helpers/ci/application_helper.rb index 3198fe55f91..7e880b00b3a 100644 --- a/app/helpers/ci/application_helper.rb +++ b/app/helpers/ci/application_helper.rb @@ -4,118 +4,10 @@ module Ci image_tag 'ci/loader.gif', alt: 'Loading' end - # Navigation link helper - # - # Returns an `li` element with an 'active' class if the supplied - # controller(s) and/or action(s) are currently active. The content of the - # element is the value passed to the block. - # - # options - The options hash used to determine if the element is "active" (default: {}) - # :controller - One or more controller names to check (optional). - # :action - One or more action names to check (optional). - # :path - A shorthand path, such as 'dashboard#index', to check (optional). - # :html_options - Extra options to be passed to the list element (optional). - # block - An optional block that will become the contents of the returned - # `li` element. - # - # When both :controller and :action are specified, BOTH must match in order - # to be marked as active. When only one is given, either can match. - # - # Examples - # - # # Assuming we're on TreeController#show - # - # # Controller matches, but action doesn't - # nav_link(controller: [:tree, :refs], action: :edit) { "Hello" } - # # => '<li>Hello</li>' - # - # # Controller matches - # nav_link(controller: [:tree, :refs]) { "Hello" } - # # => '<li class="active">Hello</li>' - # - # # Shorthand path - # nav_link(path: 'tree#show') { "Hello" } - # # => '<li class="active">Hello</li>' - # - # # Supplying custom options for the list element - # nav_link(controller: :tree, html_options: {class: 'home'}) { "Hello" } - # # => '<li class="home active">Hello</li>' - # - # Returns a list item element String - def nav_link(options = {}, &block) - if path = options.delete(:path) - if path.respond_to?(:each) - c = path.map { |p| p.split('#').first } - a = path.map { |p| p.split('#').last } - else - c, a, _ = path.split('#') - end - else - c = options.delete(:controller) - a = options.delete(:action) - end - - if c && a - # When given both options, make sure BOTH are active - klass = current_controller?(*c) && current_action?(*a) ? 'active' : '' - else - # Otherwise check EITHER option - klass = current_controller?(*c) || current_action?(*a) ? 'active' : '' - end - - # Add our custom class into the html_options, which may or may not exist - # and which may or may not already have a :class key - o = options.delete(:html_options) || {} - o[:class] ||= '' - o[:class] += ' ' + klass - o[:class].strip! - - if block_given? - content_tag(:li, capture(&block), o) - else - content_tag(:li, nil, o) - end - end - - # Check if a particular controller is the current one - # - # args - One or more controller names to check - # - # Examples - # - # # On TreeController - # current_controller?(:tree) # => true - # current_controller?(:commits) # => false - # current_controller?(:commits, :tree) # => true - def current_controller?(*args) - args.any? { |v| v.to_s.downcase == controller.controller_name } - end - - # Check if a particular action is the current one - # - # args - One or more action names to check - # - # Examples - # - # # On Projects#new - # current_action?(:new) # => true - # current_action?(:create) # => false - # current_action?(:new, :create) # => true - def current_action?(*args) - args.any? { |v| v.to_s.downcase == action_name } - end - def date_from_to(from, to) "#{from.to_s(:short)} - #{to.to_s(:short)}" end - def body_data_page - path = controller.controller_path.split('/') - namespace = path.first if path.second - - [namespace, controller.controller_name, controller.action_name].compact.join(":") - end - def duration_in_words(finished_at, started_at) if finished_at && started_at interval_in_seconds = finished_at.to_i - started_at.to_i diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 76602614bcd..6f69c2a9f32 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -46,6 +46,14 @@ module EventsHelper } end + def event_preposition(event) + if event.push? || event.commented? || event.target + "at" + elsif event.milestone? + "in" + end + end + def event_feed_title(event) words = [] words << event.author_name @@ -62,6 +70,9 @@ module EventsHelper words << "##{truncate event.note_target_iid}" end words << "at" + elsif event.milestone? + words << "##{event.target_iid}" if event.target_iid + words << "in" elsif event.target words << "##{event.target_iid}:" words << event.target.title if event.target.respond_to?(:title) diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 40642dc63ba..4db4ffb2e79 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -140,6 +140,12 @@ module Issuable { object_kind: self.class.name.underscore, user: user.hook_attrs, + repository: { + name: project.name, + url: project.url_to_repo, + description: project.description, + homepage: project.web_url + }, object_attributes: hook_attrs } end diff --git a/app/models/event.rb b/app/models/event.rb index 78f16c6304e..47600c57e35 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -27,6 +27,7 @@ class Event < ActiveRecord::Base MERGED = 7 JOINED = 8 # User joined project LEFT = 9 # User left project + DESTROYED = 10 delegate :name, :email, to: :author, prefix: true, allow_nil: true delegate :title, to: :issue, prefix: true, allow_nil: true @@ -48,6 +49,7 @@ class Event < ActiveRecord::Base scope :code_push, -> { where(action: PUSHED) } scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent } scope :with_associations, -> { includes(project: :namespace) } + scope :for_milestone_id, ->(milestone_id) { where(target_type: "Milestone", target_id: milestone_id) } class << self def reset_event_cache_for(target) @@ -71,7 +73,7 @@ class Event < ActiveRecord::Base elsif created_project? true else - (issue? || merge_request? || note? || milestone?) && target + ((issue? || merge_request? || note?) && target) || milestone? end end @@ -115,6 +117,10 @@ class Event < ActiveRecord::Base action == LEFT end + def destroyed? + action == DESTROYED + end + def commented? action == COMMENTED end @@ -124,7 +130,7 @@ class Event < ActiveRecord::Base end def created_project? - created? && !target + created? && !target && target_type.nil? end def created_target? @@ -180,6 +186,8 @@ class Event < ActiveRecord::Base 'joined' elsif left? 'left' + elsif destroyed? + 'destroyed' elsif commented? "commented on" elsif created_project? diff --git a/app/models/milestone.rb b/app/models/milestone.rb index c6aff6f709f..d979a35084b 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -61,7 +61,7 @@ class Milestone < ActiveRecord::Base false end end - + def open_items_count self.issues.opened.count + self.merge_requests.opened.count end diff --git a/app/services/event_create_service.rb b/app/services/event_create_service.rb index 103d6b0a08b..07fc77001a5 100644 --- a/app/services/event_create_service.rb +++ b/app/services/event_create_service.rb @@ -46,6 +46,10 @@ class EventCreateService create_record_event(milestone, current_user, Event::REOPENED) end + def destroy_milestone(milestone, current_user) + create_record_event(milestone, current_user, Event::DESTROYED) + end + def leave_note(note, current_user) create_record_event(note, current_user, Event::COMMENTED) end diff --git a/app/services/milestones/destroy_service.rb b/app/services/milestones/destroy_service.rb new file mode 100644 index 00000000000..7ce7d259d0b --- /dev/null +++ b/app/services/milestones/destroy_service.rb @@ -0,0 +1,22 @@ +module Milestones + class DestroyService < Milestones::BaseService + def execute(milestone) + + Milestone.transaction do + update_params = { milestone: nil } + milestone.issues.each do |issue| + Issues::UpdateService.new(project, current_user, update_params).execute(issue) + end + + event_service.destroy_milestone(milestone, current_user) + + Event.for_milestone_id(milestone.id).each do |event| + event.target_id = nil + event.save + end + + milestone.destroy + end + end + end +end diff --git a/app/views/ci/helps/oauth2.html.haml b/app/views/ci/helps/oauth2.html.haml deleted file mode 100644 index 2031b7340d4..00000000000 --- a/app/views/ci/helps/oauth2.html.haml +++ /dev/null @@ -1,20 +0,0 @@ -.welcome-block - %h1 - Welcome to GitLab CI - %p - GitLab CI integrates with your GitLab installation and runs tests for your projects. - - %h3 You need only 2 steps to set it up - - %ol - %li - In the GitLab admin area under OAuth applications create a new entry. The redirect url should be - %code= callback_ci_user_sessions_url - %li - Update the GitLab CI config with the application id and the application secret from GitLab. - %li - Restart your GitLab CI instance - %li - Refresh this page when GitLab CI has started again - - diff --git a/app/views/ci/helps/show.html.haml b/app/views/ci/helps/show.html.haml deleted file mode 100644 index 9b32d529c60..00000000000 --- a/app/views/ci/helps/show.html.haml +++ /dev/null @@ -1,40 +0,0 @@ -.jumbotron - %h2 - GitLab CI - %span= GitlabCi::VERSION - %small= GitlabCi::REVISION - %p - GitLab CI integrates with your GitLab installation and run tests for your projects. - %br - Login with your GitLab account, add a project with one click and enjoy running your tests. - %br - Read more about GitLab CI at #{link_to "about.gitlab.com/gitlab-ci", "https://about.gitlab.com/gitlab-ci/", target: "_blank"}. - - -.bs-callout.bs-callout-success - %h4 - = link_to 'https://gitlab.com/gitlab-org/gitlab-ci/blob/master/doc/api' do - %i.fa.fa-cogs - API - %p Explore how you can access GitLab CI via the API. - -.bs-callout.bs-callout-info - %h4 - = link_to 'https://gitlab.com/gitlab-org/gitlab-ci/tree/master/doc/examples' do - %i.fa.fa-info-sign - Build script examples - %p This includes the build script we use to test GitLab CE. - -.bs-callout.bs-callout-danger - %h4 - = link_to 'https://gitlab.com/gitlab-org/gitlab-ci/issues' do - %i.fa.fa-bug - Issue tracker - %p Reports about recent bugs and problems.. - -.bs-callout.bs-callout-warning - %h4 - = link_to 'http://feedback.gitlab.com/forums/176466-general/category/64310-gitlab-ci' do - %i.fa.fa-thumbs-up - Feedback forum - %p Suggest improvements or new features for GitLab CI. diff --git a/app/views/events/event/_common.html.haml b/app/views/events/event/_common.html.haml index a39e62e9dac..4ecf1c33d2a 100644 --- a/app/views/events/event/_common.html.haml +++ b/app/views/events/event/_common.html.haml @@ -5,13 +5,14 @@ - if event.target %strong= link_to "##{event.target_iid}", [event.project.namespace.becomes(Namespace), event.project, event.target] - at + + = event_preposition(event) - if event.project = link_to_project event.project - else = event.project_name - + - if event.target.respond_to?(:title) .event-body .event-note diff --git a/app/views/layouts/ci/_nav_admin.html.haml b/app/views/layouts/ci/_nav_admin.html.haml index c987ab876a3..d0ca4c421ef 100644 --- a/app/views/layouts/ci/_nav_admin.html.haml +++ b/app/views/layouts/ci/_nav_admin.html.haml @@ -1,9 +1,9 @@ %ul.nav.nav-sidebar = nav_link do - = link_to ci_root_path, title: 'Back to dashboard', data: {placement: 'right'}, class: 'back-link' do + = link_to admin_root_path, title: 'Back to dashboard', data: {placement: 'right'}, class: 'back-link' do = icon('caret-square-o-left fw') %span - Back to Dashboard + Back to Admin %li.separate-item = nav_link path: 'projects#index' do diff --git a/app/views/layouts/ci/_nav_dashboard.html.haml b/app/views/layouts/ci/_nav_dashboard.html.haml deleted file mode 100644 index fcff405d19d..00000000000 --- a/app/views/layouts/ci/_nav_dashboard.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -%ul.nav.nav-sidebar - = nav_link do - = link_to root_path, title: 'Back to dashboard', data: {placement: 'right'}, class: 'back-link' do - = icon('caret-square-o-left fw') - %span - Back to GitLab - %li.separate-item - = nav_link path: 'projects#index' do - = link_to ci_root_path do - %i.fa.fa-home - %span - Projects - - if current_user && current_user.is_admin? - %li - = link_to ci_admin_projects_path do - %i.fa.fa-cogs - %span - Admin - %li - = link_to ci_help_path do - %i.fa.fa-info - %span - Help - diff --git a/app/views/layouts/ci/application.html.haml b/app/views/layouts/ci/application.html.haml index b9f871d5447..9cc7fb85142 100644 --- a/app/views/layouts/ci/application.html.haml +++ b/app/views/layouts/ci/application.html.haml @@ -8,4 +8,4 @@ - else = render "layouts/header/public", title: header_title - = render 'layouts/ci/page', sidebar: 'nav_dashboard' + = render 'layouts/ci/page' diff --git a/app/views/layouts/nav/_admin.html.haml b/app/views/layouts/nav/_admin.html.haml index 3fe0127041e..2079feeeab6 100644 --- a/app/views/layouts/nav/_admin.html.haml +++ b/app/views/layouts/nav/_admin.html.haml @@ -4,7 +4,7 @@ = icon('dashboard fw') %span Overview - = nav_link(controller: :projects) do + = nav_link(controller: [:admin, :projects]) do = link_to admin_namespaces_projects_path, title: 'Projects', data: {placement: 'right'} do = icon('cube fw') %span @@ -24,6 +24,11 @@ = icon('key fw') %span Deploy Keys + = nav_link do + = link_to ci_admin_projects_path, title: 'Continuous Integration', data: {placement: 'right'} do + = icon('building fw') + %span + Continuous Integration = nav_link(controller: :logs) do = link_to admin_logs_path, title: 'Logs', data: {placement: 'right'} do = icon('file-text fw') diff --git a/app/views/layouts/nav/_dashboard.html.haml b/app/views/layouts/nav/_dashboard.html.haml index 56283cba6bd..f172e9b4ae8 100644 --- a/app/views/layouts/nav/_dashboard.html.haml +++ b/app/views/layouts/nav/_dashboard.html.haml @@ -1,5 +1,5 @@ %ul.nav.nav-sidebar - = nav_link(path: ['root#index', 'projects#trending', 'projects#starred', 'projects#index'], html_options: {class: 'home'}) do + = nav_link(path: ['root#index', 'projects#trending', 'projects#starred', 'dashboard/projects#index'], html_options: {class: 'home'}) do = link_to root_path, title: 'Projects', data: {placement: 'right'} do = icon('home fw') %span @@ -31,6 +31,11 @@ %span Merge Requests %span.count= current_user.assigned_merge_requests.opened.count + = nav_link(path: 'ci/projects#index') do + = link_to ci_projects_path, title: 'Continuous Integration', data: {placement: 'right'} do + = icon('building fw') + %span + Continuous Integration = nav_link(controller: :snippets) do = link_to dashboard_snippets_path, title: 'Your snippets', data: {placement: 'right'} do = icon('clipboard fw') @@ -46,8 +51,3 @@ = icon('user fw') %span Profile Settings - = nav_link(controller: :ci) do - = link_to ci_root_path, title: 'Continuous Integration', data: {placement: 'right'} do - = icon('building fw') - %span - CI diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml index 8ce46d4865b..a218ec7486c 100644 --- a/app/views/layouts/nav/_project.html.haml +++ b/app/views/layouts/nav/_project.html.haml @@ -76,6 +76,13 @@ Merge Requests %span.count.merge_counter= @project.merge_requests.opened.count + - if @project.gitlab_ci? + = nav_link(controller: [:ci, :project]) do + = link_to ci_project_path(@project.gitlab_ci_project), title: 'Continuous Integration', data: {placement: 'right'} do + = icon('building fw') + %span + Continuous Integration + - if project_nav_tab? :settings = nav_link(controller: [:project_members, :teams]) do = link_to namespace_project_project_members_path(@project.namespace, @project), title: 'Members', class: 'team-tab tab', data: {placement: 'right'} do diff --git a/app/views/projects/blob/_upload.html.haml b/app/views/projects/blob/_upload.html.haml index 2cfb79486dc..1a1df127703 100644 --- a/app/views/projects/blob/_upload.html.haml +++ b/app/views/projects/blob/_upload.html.haml @@ -3,12 +3,12 @@ .modal-content .modal-header %a.close{href: "#", "data-dismiss" => "modal"} × - %h3.page-title #{@title} + %h3.page-title #{title} %p.light From branch %strong= @ref .modal-body - = form_tag @form_path, method: @method, class: 'blob-file-upload-form-js form-horizontal' do + = form_tag form_path, method: method, class: 'blob-file-upload-form-js form-horizontal' do .dropzone .dropzone-previews.blob-upload-dropzone-previews %p.dz-message.light @@ -17,12 +17,12 @@ %br .dropzone-alerts{class: "alert alert-danger data", style: "display:none"} = render 'shared/commit_message_container', params: params, - placeholder: @placeholder + placeholder: placeholder .form-group .col-sm-offset-2.col-sm-10 - = button_tag @button_title, class: 'btn btn-small btn-primary btn-upload-file', id: 'submit-all' + = button_tag button_title, class: 'btn btn-small btn-primary btn-upload-file', id: 'submit-all' = link_to "Cancel", '#', class: "btn btn-cancel", "data-dismiss" => "modal" :coffeescript disableButtonIfEmptyField $('.blob-file-upload-form-js').find('#commit_message'), '.btn-upload-file' - new BlobFileDropzone($('.blob-file-upload-form-js'), '#{@method}') + new BlobFileDropzone($('.blob-file-upload-form-js'), '#{method}') diff --git a/app/views/projects/blob/new.html.haml b/app/views/projects/blob/new.html.haml index 68c9ec7f802..071c3bb7da8 100644 --- a/app/views/projects/blob/new.html.haml +++ b/app/views/projects/blob/new.html.haml @@ -4,7 +4,7 @@ { class: 'upload-link', 'data-target' => '#modal-upload-blob', 'data-toggle' => 'modal'} an existing one -= render 'projects/blob/upload' += render 'projects/blob/upload', title: 'Upload', placeholder: 'Upload new file', button_title: 'Upload file', form_path: namespace_project_create_blob_path(@project.namespace, @project, @id), method: :post .file-editor = form_tag(namespace_project_create_blob_path(@project.namespace, @project, @id), method: :post, class: 'form-horizontal form-new-file js-requires-input') do diff --git a/app/views/projects/blob/show.html.haml b/app/views/projects/blob/show.html.haml index 4e66a43bbd5..a536d1cf272 100644 --- a/app/views/projects/blob/show.html.haml +++ b/app/views/projects/blob/show.html.haml @@ -10,4 +10,8 @@ - if allowed_tree_edit? = render 'projects/blob/remove' - = render 'projects/blob/upload' + + - title = "Replace #{@blob.name}" + = render 'projects/blob/upload', title: title, placeholder: title, + button_title: 'Replace file', form_path: namespace_project_update_blob_path(@project.namespace, @project, @id), + method: :put diff --git a/config/routes.rb b/config/routes.rb index 41970d2af8a..b5a84c1f192 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,10 +9,6 @@ Gitlab::Application.routes.draw do resource :lint, only: [:show, :create] - resource :help do - get :oauth2 - end - resources :projects do collection do post :add diff --git a/db/schema.rb b/db/schema.rb index a3a69a4b626..151f34e1965 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,8 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150916000405) do +ActiveRecord::Schema.define(version: 20150916145038) do + # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/doc/migrate_ci_to_ce/README.md b/doc/migrate_ci_to_ce/README.md index 13efc8442d2..1e45f29dbb2 100644 --- a/doc/migrate_ci_to_ce/README.md +++ b/doc/migrate_ci_to_ce/README.md @@ -52,7 +52,14 @@ This also breaks your database structure disallowing you to use it anymore. ALTER TABLE web_hooks RENAME TO ci_web_hooks; EOF -### 4. Dump GitLab CI database [CI] +### 4. Remove CI cronjob + +``` +cd /home/gitlab_ci/gitlab-ci +sudo -u gitlab_ci -H bundle exec whenever --clear-crontab +``` + +### 5. Dump GitLab CI database [CI] First check used database and credentials on GitLab CI and GitLab CE/EE: @@ -125,18 +132,18 @@ You will need to put these credentials into commands executed below.** # Filter to only include INSERT statements grep "^\(START\|SET\|INSERT\|COMMIT\)" gitlab_ci.sql.tmp2 > gitlab_ci.sql -### 5. Make sure that your GitLab CE/EE is 8.0 [CE] +### 6. Make sure that your GitLab CE/EE is 8.0 [CE] Please verify that you use GitLab CE/EE 8.0. If not, please follow the update guide: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/7.14-to-8.0.md -### 6. Stop GitLab CE/EE [CE] +### 7. Stop GitLab CE/EE [CE] Before you can migrate data you need to stop GitLab CE/EE first. sudo service gitlab stop -### 7. Backup GitLab CE/EE [CE] +### 8. Backup GitLab CE/EE [CE] This migration poses a **significant risk** of breaking your GitLab CE/EE. **You should create the GitLab CI/EE backup before doing it.** @@ -144,7 +151,7 @@ This migration poses a **significant risk** of breaking your GitLab CE/EE. cd /home/git/gitlab sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production -### 8. Copy secret tokens [CE] +### 9. Copy secret tokens [CE] The `secrets.yml` file stores encryption keys for secure variables. @@ -154,7 +161,7 @@ You need to copy the content of `config/secrets.yml` to the same file in GitLab sudo chown git:git /home/git/gitlab/config/secrets.yml sudo chown 0600 /home/git/gitlab/config/secrets.yml -### 9. New configuration options for `gitlab.yml` [CE] +### 10. New configuration options for `gitlab.yml` [CE] There are new configuration options available for [`gitlab.yml`](config/gitlab.yml.example). View them with the command below and apply them manually to your current `gitlab.yml`: @@ -165,7 +172,7 @@ git diff origin/7-14-stable:config/gitlab.yml.example origin/8-0-stable:config/g The new options include configuration of GitLab CI that are now being part of GitLab CE and EE. -### 10. Copy build logs [CE] +### 11. Copy build logs [CE] You need to copy the contents of `builds/` to the same directory in GitLab CE/EE. @@ -174,7 +181,7 @@ You need to copy the contents of `builds/` to the same directory in GitLab CE/EE The build traces are usually quite big so it will take a significant amount of time. -### 11. Import GitLab CI database [CE] +### 12. Import GitLab CI database [CE] The one of the last steps is to import existing GitLab CI database. @@ -189,13 +196,13 @@ The task does: 1. Fix tags assigned to Builds and Runners 1. Fix services used by CI -### 12. Start GitLab [CE] +### 13. Start GitLab [CE] You can start GitLab CI/EE now and see if everything is working. sudo service gitlab start -### 13. Update nginx [CI] +### 14. Update nginx [CI] Now get back to GitLab CI and update **Nginx** configuration in order to: 1. Have all existing runners able to communicate with a migrated GitLab CI. @@ -263,7 +270,7 @@ You should also make sure that you can do: sudo /etc/init.d/nginx restart -### 14. Done! +### 15. Done! If everything went OK you should be able to access all your GitLab CI data by pointing your browser to: https://gitlab.example.com/ci/. diff --git a/doc/web_hooks/web_hooks.md b/doc/web_hooks/web_hooks.md index 09400d9b163..f4701bb6db2 100644 --- a/doc/web_hooks/web_hooks.md +++ b/doc/web_hooks/web_hooks.md @@ -121,6 +121,12 @@ X-Gitlab-Event: Issue Hook "username": "root", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon" }, + "repository": { + "name": "Gitlab Test", + "url": "http://example.com/gitlabhq/gitlab-test.git", + "description": "Aut reprehenderit ut est.", + "homepage": "http://example.com/gitlabhq/gitlab-test" + }, "object_attributes": { "id": 301, "title": "New API: create/update/delete file", diff --git a/features/project/issues/milestones.feature b/features/project/issues/milestones.feature index bfbaaec5a35..c1a20e9b488 100644 --- a/features/project/issues/milestones.feature +++ b/features/project/issues/milestones.feature @@ -12,13 +12,17 @@ Feature: Project Issues Milestones Given I click link "v2.2" Then I should see milestone "v2.2" - Scenario: I create new milestone + @javascript + Scenario: I create and delete new milestone Given I click link "New Milestone" And I submit new milestone "v2.3" Then I should see milestone "v2.3" + Given I click link to remove milestone + When I visit project "Shop" activity page + Then I should see deleted milestone activity Scenario: I delete new milestone - Given I click link to remove milestone "v2.2" + Given I click link to remove milestone And I should see no milestones @javascript diff --git a/features/steps/project/issues/milestones.rb b/features/steps/project/issues/milestones.rb index 61e62c2adbd..c8708572ec6 100644 --- a/features/steps/project/issues/milestones.rb +++ b/features/steps/project/issues/milestones.rb @@ -49,6 +49,11 @@ class Spinach::Features::ProjectIssuesMilestones < Spinach::FeatureSteps create(:closed_issue, project: project, milestone: milestone) end + step 'I should see deleted milestone activity' do + expect(page).to have_content('opened milestone in') + expect(page).to have_content('destroyed milestone in') + end + When 'I click link "All Issues"' do click_link 'All Issues' end @@ -57,7 +62,7 @@ class Spinach::Features::ProjectIssuesMilestones < Spinach::FeatureSteps expect(page).to have_selector('#tab-issues li.issue-row', count: 4) end - step 'I click link to remove milestone "v2.2"' do + step 'I click link to remove milestone' do click_link 'Remove' end diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index ccbe8f96a4c..a9cf426852e 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -51,6 +51,11 @@ module SharedProject visit namespace_project_path(project.namespace, project) end + step 'I visit project "Shop" activity page' do + project = Project.find_by(name: 'Shop') + visit namespace_project_path(project.namespace, project) + end + step 'project "Shop" has push event' do @project = Project.find_by(name: "Shop") diff --git a/spec/controllers/projects/milestones_controller_spec.rb b/spec/controllers/projects/milestones_controller_spec.rb index d3868c13202..35446640929 100644 --- a/spec/controllers/projects/milestones_controller_spec.rb +++ b/spec/controllers/projects/milestones_controller_spec.rb @@ -15,8 +15,12 @@ describe Projects::MilestonesController do describe "#destroy" do it "should remove milestone" do expect(issue.milestone_id).to eq(milestone.id) + delete :destroy, namespace_id: project.namespace.id, project_id: project.id, id: milestone.id, format: :js expect(response).to be_success + + expect(Event.first.action).to eq(Event::DESTROYED) + expect { Milestone.find(milestone.id) }.to raise_exception(ActiveRecord::RecordNotFound) issue.reload expect(issue.milestone_id).to eq(nil) diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index b6d80451d2e..8f706f8934b 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' describe Issue, "Issuable" do let(:issue) { create(:issue) } + let(:user) { create(:user) } describe "Associations" do it { is_expected.to belong_to(:project) } @@ -66,4 +67,19 @@ describe Issue, "Issuable" do expect(issue.new?).to be_falsey end end + + + describe "#to_hook_data" do + let(:hook_data) { issue.to_hook_data(user) } + + it "returns correct hook data" do + expect(hook_data[:object_kind]).to eq("issue") + expect(hook_data[:user]).to eq(user.hook_attrs) + expect(hook_data[:repository][:name]).to eq(issue.project.name) + expect(hook_data[:repository][:url]).to eq(issue.project.url_to_repo) + expect(hook_data[:repository][:description]).to eq(issue.project.description) + expect(hook_data[:repository][:homepage]).to eq(issue.project.web_url) + expect(hook_data[:object_attributes]).to eq(issue.hook_attrs) + end + end end diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb index 007a9eed192..7756b973ecd 100644 --- a/spec/services/event_create_service_spec.rb +++ b/spec/services/event_create_service_spec.rb @@ -99,5 +99,15 @@ describe EventCreateService do expect { service.close_milestone(milestone, user) }.to change { Event.count } end end + + describe :destroy_mr do + let(:milestone) { create(:milestone) } + + it { expect(service.destroy_milestone(milestone, user)).to be_truthy } + + it "should create new event" do + expect { service.destroy_milestone(milestone, user) }.to change { Event.count } + end + end end end |