diff --git a/CHANGELOG b/CHANGELOG
index fed3caef7e8d7ebf1f9504e75ae94957100b823a..1c21ad36b696a358da2cf23bc2f064aa9b624c65 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,8 +1,12 @@
 Please view this file on the master branch, on stable branches it's out of date.
 
 v 8.8.0 (unreleased)
+  - Fix error when using link to uploads in global snippets
   - Assign labels and milestone to target project when moving issue. !3934 (Long Nguyen)
+  - Use a case-insensitive comparison in sanitizing URI schemes
   - Project#open_branches has been cleaned up and no longer loads entire records into memory.
+  - Escape HTML in commit titles in system note messages
+  - Improve multiple branch push performance by memoizing permission checking
   - Log to application.log when an admin starts and stops impersonating a user
   - Updated gitlab_git to 10.1.0
   - GitAccess#protected_tag? no longer loads all tags just to check if a single one exists
@@ -19,10 +23,13 @@ v 8.8.0 (unreleased)
   - Update SVG sanitizer to conform to SVG 1.1
   - Updated search UI
   - Display informative message when new milestone is created
+  - Sanitize milestones and labels titles
+  - Support multi-line tag messages. !3833 (Calin Seciu)
   - Allow "NEWS" and "CHANGES" as alternative names for CHANGELOG. !3768 (Connor Shea)
   - Added button to toggle whitespaces changes on diff view
   - Backport GitHub Enterprise import support from EE
   - Create tags using Rugged for performance reasons. !3745
+  - API: Expose Issue#user_notes_count. !3126 (Anton Popov)
   - Files over 5MB can only be viewed in their raw form, files over 1MB without highlighting !3718
   - Add support for supressing text diffs using .gitattributes on the default branch (Matt Oakes)
   - Added multiple colors for labels in dropdowns when dups happen.
@@ -31,6 +38,11 @@ v 8.8.0 (unreleased)
   - Fix Gravatar hint in user profile when Gravatar is disabled. !3988 (Artem Sidorenko)
   - Expire repository exists? and has_visible_content? caches after a push if necessary
   - Fix unintentional filtering bug in issues sorted by milestone due (Takuya Noguchi)
+  - Fix adding a todo for private group members (Ahmad Sherif)
+
+v 8.7.4
+  - Fix always showing build notification message when switching between merge requests
+  - Links for Redmine issue references are generated correctly again (Benedikt Huss)
 
 v 8.7.3
   - Emails, Gitlab::Email::Message, Gitlab::Diff, and Premailer::Adapter::Nokogiri are now instrumented
diff --git a/Gemfile b/Gemfile
index 1137ef4d72b6cc0d1595c4888e66a819d69127c3..3e5c604ae06ed0a0da0381753dfb8ab69fe008cb 100644
--- a/Gemfile
+++ b/Gemfile
@@ -242,7 +242,6 @@ group :development do
   gem "foreman"
   gem 'brakeman', '~> 3.2.0', require: false
 
-  gem "annotate", "~> 2.7.0"
   gem 'letter_opener_web', '~> 1.3.0'
   gem 'quiet_assets', '~> 1.0.2'
   gem 'rerun', '~> 0.11.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index fe083c2b56681f5b535d4429d6470d8b46a52f95..86b9142ef27deea1f12867a965620a953cdf22bb 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -51,9 +51,6 @@ GEM
       activerecord (>= 3.0)
     akismet (2.0.0)
     allocations (1.0.4)
-    annotate (2.7.0)
-      activerecord (>= 3.2, < 6.0)
-      rake (~> 10.4)
     arel (6.0.3)
     asana (0.4.0)
       faraday (~> 0.9)
@@ -893,7 +890,6 @@ DEPENDENCIES
   after_commit_queue
   akismet (~> 2.0)
   allocations (~> 1.0)
-  annotate (~> 2.7.0)
   asana (~> 0.4.0)
   asciidoctor (~> 1.5.2)
   attr_encrypted (~> 1.3.4)
@@ -1061,4 +1057,4 @@ DEPENDENCIES
   wikicloth (= 0.8.1)
 
 BUNDLED WITH
-   1.12.1
+   1.12.3
diff --git a/README.md b/README.md
index 5e41665a6ba8f6159bd57bbaefb16571d6c6cc3f..418d06a45a5981dee9d65130366f5af6f84b22be 100644
--- a/README.md
+++ b/README.md
@@ -35,11 +35,11 @@ There are two editions of GitLab:
 
 On [about.gitlab.com](https://about.gitlab.com/) you can find more information about:
 
-- [Subscriptions](https://about.gitlab.com/subscription/)
+- [Subscriptions](https://about.gitlab.com/pricing/)
 - [Consultancy](https://about.gitlab.com/consultancy/)
 - [Community](https://about.gitlab.com/community/)
 - [Hosted GitLab.com](https://about.gitlab.com/gitlab-com/) use GitLab as a free service
-- [GitLab Enterprise Edition](https://about.gitlab.com/gitlab-ee/) with additional features aimed at larger organizations.
+- [GitLab Enterprise Edition](https://about.gitlab.com/features/#enterprise) with additional features aimed at larger organizations.
 - [GitLab CI](https://about.gitlab.com/gitlab-ci/) a continuous integration (CI) server that is easy to integrate with GitLab.
 
 ## Requirements
diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee
index 5bac8eef1cb61ef087f266e1d4f044c54fe344e7..bffce5a0c0fe130c2f123b81a08e75b055385677 100644
--- a/app/assets/javascripts/application.js.coffee
+++ b/app/assets/javascripts/application.js.coffee
@@ -204,6 +204,7 @@ $ ->
     $('.header-content .title').toggle()
     $('.header-content .navbar-collapse').toggle()
     $('.navbar-toggle').toggleClass('active')
+    $('.navbar-toggle i').toggleClass("fa-angle-right fa-angle-left")
 
   # Show/hide comments on diff
   $("body").on "click", ".js-toggle-diff-comments", (e) ->
diff --git a/app/assets/javascripts/ci/application.js.coffee b/app/assets/javascripts/ci/application.js.coffee
index 05aa0f366bb11cccbcb5378e131ebe285c9bf69e..ca24c1d759f8798595649fc3176ffdd3974e0d6c 100644
--- a/app/assets/javascripts/ci/application.js.coffee
+++ b/app/assets/javascripts/ci/application.js.coffee
@@ -1,34 +1,6 @@
-# This is a manifest file that'll be compiled into application.js, which will include all the files
-# listed below.
-#
-# Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
-# or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
-#
-# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
-# the compiled file.
-#
-# WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
-# GO AFTER THE REQUIRES BELOW.
-#
 #= require pager
 #= require jquery_nested_form
 #= require_tree .
-#
-$(document).on 'click', '.edit-runner-link', (event) ->
-  event.preventDefault()
-
-  descr = $(this).closest('.runner-description').first()
-  descr.addClass('hide')
-  form = descr.next('.runner-description-form')
-  descrInput = form.find('input.description')
-  originalValue = descrInput.val()
-  form.removeClass('hide')
-  form.find('.cancel').on 'click', (event) ->
-    event.preventDefault()
-
-    form.addClass('hide')
-    descrInput.val(originalValue)
-    descr.removeClass('hide')
 
 $(document).on 'click', '.assign-all-runner', ->
   $(this).replaceWith('<i class="fa fa-refresh fa-spin"></i> Assign in progress..')
diff --git a/app/assets/javascripts/merge_request_widget.js.coffee b/app/assets/javascripts/merge_request_widget.js.coffee
index 17a5a057a944e07f548fec6055de3591c880f018..f58647988a2265d7c108263f94f522603ac2768a 100644
--- a/app/assets/javascripts/merge_request_widget.js.coffee
+++ b/app/assets/javascripts/merge_request_widget.js.coffee
@@ -9,11 +9,12 @@ class @MergeRequestWidget
   constructor: (@opts) ->
     $('#modal_merge_info').modal(show: false)
     @firstCICheck = true
-    @readyForCICheck = true
+    @readyForCICheck = false
     clearInterval @fetchBuildStatusInterval
 
     @clearEventListeners()
     @addEventListeners()
+    @getCIStatus(false)
     @pollCIStatus()
     notifyPermissions()
 
@@ -71,7 +72,7 @@ class @MergeRequestWidget
       if data.status is ''
         return
 
-      if @firstCiCheck || data.status isnt @opts.ci_status and data.status?
+      if @firstCICheck || data.status isnt @opts.ci_status and data.status?
         @opts.ci_status = data.status
         @showCIStatus data.status
         if data.coverage
@@ -79,7 +80,7 @@ class @MergeRequestWidget
 
         # The first check should only update the UI, a notification
         # should only be displayed on status changes
-        if showNotification and not @firstCiCheck
+        if showNotification and not @firstCICheck
           status = @ciLabelForStatus(data.status)
 
           if status is "preparing"
@@ -102,7 +103,7 @@ class @MergeRequestWidget
               @close()
               Turbolinks.visit _this.opts.builds_path
           )
-        @firstCiCheck = false
+        @firstCICheck = false
 
   showCIStatus: (state) ->
     $('.ci_widget').hide()
diff --git a/app/assets/javascripts/sidebar.js.coffee b/app/assets/javascripts/sidebar.js.coffee
index 860d4f438d0117b8efdca46a7725927663f4c7ee..ea4ac52da31cfc891e7678594391a09ef2188d79 100644
--- a/app/assets/javascripts/sidebar.js.coffee
+++ b/app/assets/javascripts/sidebar.js.coffee
@@ -12,7 +12,7 @@ toggleSidebar = ->
     niceScrollBars.updateScrollBar();
   ), 300
 
-$(document).on("click", '.toggle-nav-collapse', (e) ->
+$(document).on("click", '.toggle-nav-collapse, .side-nav-toggle', (e) ->
   e.preventDefault()
 
   toggleSidebar()
diff --git a/app/assets/stylesheets/framework/gitlab-theme.scss b/app/assets/stylesheets/framework/gitlab-theme.scss
index c83cf881596f646665b2cf7830a87871cb7f1513..dc4668877f2a6b09f90e741d76532aa2415bcc3a 100644
--- a/app/assets/stylesheets/framework/gitlab-theme.scss
+++ b/app/assets/stylesheets/framework/gitlab-theme.scss
@@ -24,6 +24,10 @@
         background-color: $color-darker;
         a {
           color: #fff;
+
+          h3 {
+            color: #fff;
+          }
         }
       }
     }
diff --git a/app/assets/stylesheets/framework/header.scss b/app/assets/stylesheets/framework/header.scss
index 97f9d5820073c7b92ef6dbb22dd30f4304ef3321..8190a97ed58e05b0f7e45b5024f59a33c7d7cd8c 100644
--- a/app/assets/stylesheets/framework/header.scss
+++ b/app/assets/stylesheets/framework/header.scss
@@ -8,7 +8,7 @@ header {
   &.navbar-empty {
     height: 58px;
     background: #fff;
-    border-bottom: 1px solid #eee;
+    border-bottom: 1px solid $btn-gray-hover;
 
     .center-logo {
       margin: 11px 0;
@@ -22,14 +22,18 @@ header {
   }
 
   &.navbar-gitlab {
-    padding: 0 20px;
+    padding: 0 16px;
     z-index: 100;
     margin-bottom: 0;
-    min-height: $header-height;
+    height: $header-height;
     background-color: $background-color;
     border: none;
     border-bottom: 1px solid $border-color;
 
+    @media (max-width: $screen-xs-min) {
+      padding: 0 16px;
+    }
+
     &.with-horizontal-nav {
       border-bottom: none;
     }
@@ -60,16 +64,44 @@ header {
         margin: 6px 0;
         border-radius: 0;
         position: absolute;
-        right: 2px;
+        right: -10px;
+        padding: 6px 10px;
 
         &:hover {
-          background-color: #eee;
+          background-color: $btn-gray-hover;
         }
+
         &.active {
           color: $gl-icon-color;
         }
       }
     }
+
+    &.header-collapsed {
+      padding: 0 16px;
+    }
+
+    .side-nav-toggle {
+      display: none;
+      position: absolute;
+      left: -10px;
+      margin: 6px 0;
+      padding: 6px 10px;
+      border: none;
+      background-color: $background-color;
+
+      &:hover {
+        background-color: $btn-gray-hover;
+      }
+
+      &:focus {
+        outline: none;
+      }
+
+      @media (max-width: $screen-xs-min) {
+        display: block;
+      }
+    }
   }
 
   .header-content {
@@ -77,6 +109,10 @@ header {
     height: $header-height;
     padding-right: 40px;
 
+    @media (max-width: $screen-xs-min) {
+      padding-left: 40px;
+    }
+
     @media (min-width: $screen-sm-min) {
       padding-right: 0;
     }
@@ -145,6 +181,10 @@ header {
   @media (min-width: $screen-md-min) {
     @include collapsed-header;
   }
+
+  @media (max-width: $screen-xs-min) {
+    margin-left: 0;
+  }
 }
 
 .header-expanded {
@@ -153,6 +193,10 @@ header {
   @media (min-width: $screen-md-min) {
     margin-left: $sidebar_width;
   }
+
+  @media (max-width: $screen-xs-min) {
+    margin-left: 0;
+  }
 }
 
 @media (max-width: $screen-xs-max) {
diff --git a/app/assets/stylesheets/framework/nav.scss b/app/assets/stylesheets/framework/nav.scss
index 7c18e93a261c9fba650734e015b1f1149325f484..f2d7dc625e00669ce85cc86693b267e71d29249b 100644
--- a/app/assets/stylesheets/framework/nav.scss
+++ b/app/assets/stylesheets/framework/nav.scss
@@ -201,9 +201,13 @@
   border-bottom: 1px solid $border-color;
   transition-duration: .3s;
 
+  .container-fluid {
+    position: relative;
+  }
+
   .controls {
     float: right;
-    padding: 7px 5px 0 0;
+    padding: 7px 0 0;
 
     i {
       color: $layout-link-gray;
diff --git a/app/assets/stylesheets/framework/sidebar.scss b/app/assets/stylesheets/framework/sidebar.scss
index e940fd7286eab605a3f1a5826515c8fb179ded6f..bd91f51708cb562838b110bce51395169a4a677d 100644
--- a/app/assets/stylesheets/framework/sidebar.scss
+++ b/app/assets/stylesheets/framework/sidebar.scss
@@ -98,7 +98,7 @@
   }
 
   .sidebar-user {
-    padding: 9px 22px;
+    padding: 7px 22px;
     position: fixed;
     bottom: 40px;
     width: $sidebar_width;
@@ -210,15 +210,33 @@
   }
 }
 
+.sidebar-wrapper {
+  &.hidden-nav {
+    width: 0;
+  }
+}
+
 .page-sidebar-collapsed {
   padding-left: $sidebar_collapsed_width;
 
+  @media (max-width: $screen-xs-min) {
+    padding-left: 0;
+  }
+
   .sidebar-wrapper {
     width: $sidebar_collapsed_width;
 
+    @media (max-width: $screen-xs-min) {
+      width: 0;
+    }
+
     .header-logo {
       width: $sidebar_collapsed_width;
 
+      @media (max-width: $screen-xs-min) {
+        width: 0;
+      }
+
       a {
         padding-left: ($sidebar_collapsed_width - 36) / 2;
 
@@ -244,12 +262,22 @@
 
     .collapse-nav a {
       width: $sidebar_collapsed_width;
+
+      @media (max-width: $screen-xs-min) {
+        width: 0;
+      }
     }
 
     .sidebar-user {
       padding-left: ($sidebar_collapsed_width - 36) / 2;
       width: $sidebar_collapsed_width;
 
+      @media (max-width: $screen-xs-min) {
+        width: 0;
+        padding-left: 0;
+        padding-right: 0;
+      }
+
       .username {
         display: none;
       }
@@ -258,6 +286,10 @@
 
   .layout-nav {
     padding-right: $sidebar_collapsed_width;
+
+    @media (max-width: $screen-xs-min) {
+      padding-right: 0;;
+    }
   }
 }
 
@@ -268,6 +300,10 @@
     padding-left: $sidebar_width;
   }
 
+  @media (max-width: $screen-xs-min) {
+    padding-left: 0;
+  }
+
   .sidebar-wrapper {
     width: $sidebar_width;
 
@@ -287,7 +323,17 @@
   }
 
   .layout-nav {
-    padding-right: $sidebar_width;
+    @media (max-width: $screen-xs-min) {
+      padding-right: 0;;
+    }
+
+    @media (min-width: $screen-xs-min) and (max-width: $screen-md-min) {
+      padding-right: 62px;
+    }
+
+    @media (min-width: $screen-md-min) {
+      padding-right: $sidebar_width;
+    }
   }
 }
 
diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss
index ccb4e5381b7930816cc0ef2c3faa38df8ff2dbba..84e74db06b0ac641be2e325e15ad7945315c3bb7 100644
--- a/app/assets/stylesheets/framework/variables.scss
+++ b/app/assets/stylesheets/framework/variables.scss
@@ -215,6 +215,7 @@ $dropdown-toggle-hover-icon-color: $dropdown-toggle-hover-border-color;
 $btn-active-gray: #ececec;
 $btn-placeholder-gray: #c7c7c7;
 $btn-white-active: #848484;
+$btn-gray-hover: #eee;
 
 /*
  *  Award emoji
diff --git a/app/assets/stylesheets/pages/profile.scss b/app/assets/stylesheets/pages/profile.scss
index abc5a0e9877377b0f7b15ff768734c2829605063..843379a3f54191f9eb3f94c4383f76075782ee6d 100644
--- a/app/assets/stylesheets/pages/profile.scss
+++ b/app/assets/stylesheets/pages/profile.scss
@@ -218,7 +218,7 @@
 
       .btn {
         display: inline-block;
-        width: 48%;
+        width: 46%;
       }
     }
   }
diff --git a/app/controllers/dashboard/labels_controller.rb b/app/controllers/dashboard/labels_controller.rb
index 23a4ef21ea20e185b5b334025cb25ddef9598f50..2a88350a4cabeb5d90ab1a87680caf3cec899409 100644
--- a/app/controllers/dashboard/labels_controller.rb
+++ b/app/controllers/dashboard/labels_controller.rb
@@ -1,6 +1,6 @@
 class Dashboard::LabelsController < Dashboard::ApplicationController
   def index
-    labels = Label.where(project_id: projects).select(:title, :color).uniq(:title)
+    labels = Label.where(project_id: projects).select(:id, :title, :color).uniq(:title)
 
     respond_to do |format|
       format.json { render json: labels }
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index f17d02a7a3f49c1768789a8e70df6f53e92b0297..85f8854d2ebb37ad447b8124a199619ed44235c1 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -205,7 +205,8 @@ module ProjectsHelper
   end
 
   def default_url_to_repo(project = @project)
-    if default_clone_protocol == "ssh"
+    case default_clone_protocol
+    when 'ssh'
       project.ssh_url_to_repo
     else
       project.http_url_to_repo
diff --git a/app/models/abuse_report.rb b/app/models/abuse_report.rb
index b61f51231278de1e99fb90f2efaafcfac2ffe47d..b01a244032d9de9bbed3594263ffa04b7ff92ecc 100644
--- a/app/models/abuse_report.rb
+++ b/app/models/abuse_report.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: abuse_reports
-#
-#  id          :integer          not null, primary key
-#  reporter_id :integer
-#  user_id     :integer
-#  message     :text
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 class AbuseReport < ActiveRecord::Base
   belongs_to :reporter, class_name: 'User'
   belongs_to :user
diff --git a/app/models/appearance.rb b/app/models/appearance.rb
index 4528760fefabdf79ff365fca8fdc77eb11021155..4cf8dd9a8ce2f3b4d5519eb4646d347004a808fc 100644
--- a/app/models/appearance.rb
+++ b/app/models/appearance.rb
@@ -1,16 +1,3 @@
-# == Schema Information
-#
-# Table name: appearances
-#
-#  id          :integer          not null, primary key
-#  title       :string
-#  description :text
-#  header_logo :string
-#  logo        :string
-#  created_at  :datetime         not null
-#  updated_at  :datetime         not null
-#
-
 class Appearance < ActiveRecord::Base
   validates :title,       presence: true
   validates :description, presence: true
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 72ec91d29092d4041be14b017df6469d400ea5c3..7039db2d41e79f835f4d24d61e38150be102b69f 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -1,55 +1,3 @@
-# == Schema Information
-#
-# Table name: application_settings
-#
-#  id                                :integer          not null, primary key
-#  default_projects_limit            :integer
-#  signup_enabled                    :boolean
-#  signin_enabled                    :boolean
-#  gravatar_enabled                  :boolean
-#  sign_in_text                      :text
-#  created_at                        :datetime
-#  updated_at                        :datetime
-#  home_page_url                     :string
-#  default_branch_protection         :integer          default(2)
-#  restricted_visibility_levels      :text
-#  version_check_enabled             :boolean          default(TRUE)
-#  max_attachment_size               :integer          default(10), not null
-#  default_project_visibility        :integer
-#  default_snippet_visibility        :integer
-#  restricted_signup_domains         :text
-#  user_oauth_applications           :boolean          default(TRUE)
-#  after_sign_out_path               :string
-#  session_expire_delay              :integer          default(10080), not null
-#  import_sources                    :text
-#  help_page_text                    :text
-#  admin_notification_email          :string
-#  shared_runners_enabled            :boolean          default(TRUE), not null
-#  max_artifacts_size                :integer          default(100), not null
-#  runners_registration_token        :string
-#  require_two_factor_authentication :boolean          default(FALSE)
-#  two_factor_grace_period           :integer          default(48)
-#  metrics_enabled                   :boolean          default(FALSE)
-#  metrics_host                      :string           default("localhost")
-#  metrics_pool_size                 :integer          default(16)
-#  metrics_timeout                   :integer          default(10)
-#  metrics_method_call_threshold     :integer          default(10)
-#  recaptcha_enabled                 :boolean          default(FALSE)
-#  recaptcha_site_key                :string
-#  recaptcha_private_key             :string
-#  metrics_port                      :integer          default(8089)
-#  metrics_sample_interval           :integer          default(15)
-#  sentry_enabled                    :boolean          default(FALSE)
-#  sentry_dsn                        :string
-#  akismet_enabled                   :boolean          default(FALSE)
-#  akismet_api_key                   :string
-#  email_author_in_body              :boolean          default(FALSE)
-#  default_group_visibility          :integer
-#  repository_checks_enabled         :boolean          default(FALSE)
-#  metrics_packet_size               :integer          default(1)
-#  shared_runners_text               :text
-#
-
 class ApplicationSetting < ActiveRecord::Base
   include TokenAuthenticatable
   add_authentication_token_field :runners_registration_token
diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb
index 44b090260e755a6546154c21542b9fa6bf0b429c..967ffd46db0832efd59ac3624a39e2ce268c05b0 100644
--- a/app/models/audit_event.rb
+++ b/app/models/audit_event.rb
@@ -1,17 +1,3 @@
-# == Schema Information
-#
-# Table name: audit_events
-#
-#  id          :integer          not null, primary key
-#  author_id   :integer          not null
-#  type        :string           not null
-#  entity_id   :integer          not null
-#  entity_type :string           not null
-#  details     :text
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 class AuditEvent < ActiveRecord::Base
   serialize :details, Hash
 
diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb
index 075ac733bfcccdf67587cbff72195da5069f4997..61498140f27da8480a5e484006af6d85a5f79f12 100644
--- a/app/models/broadcast_message.rb
+++ b/app/models/broadcast_message.rb
@@ -1,17 +1,3 @@
-# == Schema Information
-#
-# Table name: broadcast_messages
-#
-#  id         :integer          not null, primary key
-#  message    :text             not null
-#  starts_at  :datetime
-#  ends_at    :datetime
-#  created_at :datetime
-#  updated_at :datetime
-#  color      :string
-#  font       :string
-#
-
 class BroadcastMessage < ActiveRecord::Base
   include Sortable
 
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 1eb6a0d9023c336a65ad8a8bd4addce95bd2dddf..01236b8e3c7e0c683c65123bd5d848c55490ca51 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -1,40 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_builds
-#
-#  id                 :integer          not null, primary key
-#  project_id         :integer
-#  status             :string
-#  finished_at        :datetime
-#  trace              :text
-#  created_at         :datetime
-#  updated_at         :datetime
-#  started_at         :datetime
-#  runner_id          :integer
-#  coverage           :float
-#  commit_id          :integer
-#  commands           :text
-#  job_id             :integer
-#  name               :string
-#  deploy             :boolean          default(FALSE)
-#  options            :text
-#  allow_failure      :boolean          default(FALSE), not null
-#  stage              :string
-#  trigger_request_id :integer
-#  stage_idx          :integer
-#  tag                :boolean
-#  ref                :string
-#  user_id            :integer
-#  type               :string
-#  target_url         :string
-#  description        :string
-#  artifacts_file     :text
-#  gl_project_id      :integer
-#  artifacts_metadata :text
-#  erased_by_id       :integer
-#  erased_at          :datetime
-#
-
 module Ci
   class Build < CommitStatus
     belongs_to :runner, class_name: 'Ci::Runner'
diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb
index 4ac4e0fb8b2250827685b556f68b02e19953ca46..f4b61c75ab65a970247e3aa3c56a90121e739730 100644
--- a/app/models/ci/commit.rb
+++ b/app/models/ci/commit.rb
@@ -1,25 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_commits
-#
-#  id            :integer          not null, primary key
-#  project_id    :integer
-#  ref           :string
-#  sha           :string
-#  before_sha    :string
-#  push_data     :text
-#  created_at    :datetime
-#  updated_at    :datetime
-#  tag           :boolean          default(FALSE)
-#  yaml_errors   :text
-#  committed_at  :datetime
-#  gl_project_id :integer
-#  status        :string
-#  started_at    :datetime
-#  finished_at   :datetime
-#  duration      :integer
-#
-
 module Ci
   class Commit < ActiveRecord::Base
     extend Ci::Model
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index add59a08892f7dc34306885c19f0bd5da22b507d..0cdb64d6c33ec432a9a1775fe9f871057438dadd 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -1,22 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_runners
-#
-#  id           :integer          not null, primary key
-#  token        :string
-#  created_at   :datetime
-#  updated_at   :datetime
-#  description  :string
-#  contacted_at :datetime
-#  active       :boolean          default(TRUE), not null
-#  is_shared    :boolean          default(FALSE)
-#  name         :string
-#  version      :string
-#  revision     :string
-#  platform     :string
-#  architecture :string
-#
-
 module Ci
   class Runner < ActiveRecord::Base
     extend Ci::Model
diff --git a/app/models/ci/runner_project.rb b/app/models/ci/runner_project.rb
index 7b16f207a265fef918dfbd0677cee026d93ecfeb..4b44ffa886e6b838853d1cffea9660de1f3595e5 100644
--- a/app/models/ci/runner_project.rb
+++ b/app/models/ci/runner_project.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_runner_projects
-#
-#  id            :integer          not null, primary key
-#  runner_id     :integer          not null
-#  project_id    :integer
-#  created_at    :datetime
-#  updated_at    :datetime
-#  gl_project_id :integer
-#
-
 module Ci
   class RunnerProject < ActiveRecord::Base
     extend Ci::Model
diff --git a/app/models/ci/trigger.rb b/app/models/ci/trigger.rb
index 4f3f4d79fac836537b5543b19b40853b134fb964..a0b19b51a127a44372149276097c2a8ac6cdd5f7 100644
--- a/app/models/ci/trigger.rb
+++ b/app/models/ci/trigger.rb
@@ -1,16 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_triggers
-#
-#  id            :integer          not null, primary key
-#  token         :string
-#  project_id    :integer
-#  deleted_at    :datetime
-#  created_at    :datetime
-#  updated_at    :datetime
-#  gl_project_id :integer
-#
-
 module Ci
   class Trigger < ActiveRecord::Base
     extend Ci::Model
diff --git a/app/models/ci/trigger_request.rb b/app/models/ci/trigger_request.rb
index 9973d2e5ade0a87e4f21d2107698c807ad3aae4c..872d5fb31de10f7007100668d1b102529e9f4587 100644
--- a/app/models/ci/trigger_request.rb
+++ b/app/models/ci/trigger_request.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_trigger_requests
-#
-#  id         :integer          not null, primary key
-#  trigger_id :integer          not null
-#  variables  :text
-#  created_at :datetime
-#  updated_at :datetime
-#  commit_id  :integer
-#
-
 module Ci
   class TriggerRequest < ActiveRecord::Base
     extend Ci::Model
diff --git a/app/models/ci/variable.rb b/app/models/ci/variable.rb
index 4229fe085a15875c78318a0f336314463e54c565..10802f64813efcb9e89292a5d9cabdfadf863967 100644
--- a/app/models/ci/variable.rb
+++ b/app/models/ci/variable.rb
@@ -1,17 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_variables
-#
-#  id                   :integer          not null, primary key
-#  project_id           :integer
-#  key                  :string
-#  value                :text
-#  encrypted_value      :text
-#  encrypted_value_salt :string
-#  encrypted_value_iv   :string
-#  gl_project_id        :integer
-#
-
 module Ci
   class Variable < ActiveRecord::Base
     extend Ci::Model
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 1260c448de3533420d18798373bab04e0e3077f4..cacbc13b391718195b71ff5c9a6aca19e122e0bd 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -1,40 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_builds
-#
-#  id                 :integer          not null, primary key
-#  project_id         :integer
-#  status             :string
-#  finished_at        :datetime
-#  trace              :text
-#  created_at         :datetime
-#  updated_at         :datetime
-#  started_at         :datetime
-#  runner_id          :integer
-#  coverage           :float
-#  commit_id          :integer
-#  commands           :text
-#  job_id             :integer
-#  name               :string
-#  deploy             :boolean          default(FALSE)
-#  options            :text
-#  allow_failure      :boolean          default(FALSE), not null
-#  stage              :string
-#  trigger_request_id :integer
-#  stage_idx          :integer
-#  tag                :boolean
-#  ref                :string
-#  user_id            :integer
-#  type               :string
-#  target_url         :string
-#  description        :string
-#  artifacts_file     :text
-#  gl_project_id      :integer
-#  artifacts_metadata :text
-#  erased_by_id       :integer
-#  erased_at          :datetime
-#
-
 class CommitStatus < ActiveRecord::Base
   include Statuseable
 
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 2e4efc4e8d8101cf51969ad9441f75b67f7ba7b2..7a3db742030e0eeafb833d8cca1593862d374c9f 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -160,6 +160,10 @@ module Issuable
     notes.awards.where(note: "thumbsup").count
   end
 
+  def user_notes_count
+    notes.user.count
+  end
+
   def subscribed_without_subscriptions?(user)
     participants(user).include?(user)
   end
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index 98f71ae8cb04a5bb28cf8458d370df325bb4aa75..b381d22548567233e50406dc5e8da59bb49a621c 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -43,8 +43,8 @@ module Mentionable
     self
   end
 
-  def all_references(current_user = self.author, text = nil)
-    ext = Gitlab::ReferenceExtractor.new(self.project, current_user, self.author)
+  def all_references(current_user = nil, text = nil)
+    ext = Gitlab::ReferenceExtractor.new(self.project, current_user || self.author, self.author)
 
     if text
       ext.analyze(text)
diff --git a/app/models/deploy_key.rb b/app/models/deploy_key.rb
index 43cf625f770aaf901c9d1421e20c1dd3df4a2c0b..2c525d4cd7a78062e759c2c36a4b2a058bd8a58d 100644
--- a/app/models/deploy_key.rb
+++ b/app/models/deploy_key.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: keys
-#
-#  id          :integer          not null, primary key
-#  user_id     :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#  key         :text
-#  title       :string
-#  type        :string
-#  fingerprint :string
-#  public      :boolean          default(FALSE), not null
-#
-
 class DeployKey < Key
   has_many :deploy_keys_projects, dependent: :destroy
   has_many :projects, through: :deploy_keys_projects
diff --git a/app/models/deploy_keys_project.rb b/app/models/deploy_keys_project.rb
index 18db521741fba8e6b9bb752ad54c551ada19a25f..ae8486bd9acd31ab04169497e3afcb9916f023e8 100644
--- a/app/models/deploy_keys_project.rb
+++ b/app/models/deploy_keys_project.rb
@@ -1,14 +1,3 @@
-# == Schema Information
-#
-# Table name: deploy_keys_projects
-#
-#  id            :integer          not null, primary key
-#  deploy_key_id :integer          not null
-#  project_id    :integer          not null
-#  created_at    :datetime
-#  updated_at    :datetime
-#
-
 class DeployKeysProject < ActiveRecord::Base
   belongs_to :project
   belongs_to :deploy_key
diff --git a/app/models/email.rb b/app/models/email.rb
index eae2472f33765260923d57b7791f0b282d859e49..32a412ab878aedefb63dc69d6aeddf80d789225a 100644
--- a/app/models/email.rb
+++ b/app/models/email.rb
@@ -1,14 +1,3 @@
-# == Schema Information
-#
-# Table name: emails
-#
-#  id         :integer          not null, primary key
-#  user_id    :integer          not null
-#  email      :string           not null
-#  created_at :datetime
-#  updated_at :datetime
-#
-
 class Email < ActiveRecord::Base
   include Sortable
 
diff --git a/app/models/event.rb b/app/models/event.rb
index 25c7c3e6dc7814051c4d289a2b20794dd57f4e08..17ee48b91a8bad512f976bf48774b251be64d160 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -1,19 +1,3 @@
-# == Schema Information
-#
-# Table name: events
-#
-#  id          :integer          not null, primary key
-#  target_type :string
-#  target_id   :integer
-#  title       :string
-#  data        :text
-#  project_id  :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#  action      :integer
-#  author_id   :integer
-#
-
 class Event < ActiveRecord::Base
   include Sortable
   default_scope { where.not(author_id: nil) }
diff --git a/app/models/forked_project_link.rb b/app/models/forked_project_link.rb
index 9b0c6263a96ac65713a977e90c4cc568225b1d1e..9803bae0beec8dd8e32ad9f7999dec0ef761ab1f 100644
--- a/app/models/forked_project_link.rb
+++ b/app/models/forked_project_link.rb
@@ -1,14 +1,3 @@
-# == Schema Information
-#
-# Table name: forked_project_links
-#
-#  id                     :integer          not null, primary key
-#  forked_to_project_id   :integer          not null
-#  forked_from_project_id :integer          not null
-#  created_at             :datetime
-#  updated_at             :datetime
-#
-
 class ForkedProjectLink < ActiveRecord::Base
   belongs_to :forked_to_project, class_name: Project
   belongs_to :forked_from_project, class_name: Project
diff --git a/app/models/generic_commit_status.rb b/app/models/generic_commit_status.rb
index d4afd8cbe84085d5e61107de693e2e17f93f7a74..fa54e3540d07bd99637c76b65d7b53ba4acc58c5 100644
--- a/app/models/generic_commit_status.rb
+++ b/app/models/generic_commit_status.rb
@@ -1,40 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_builds
-#
-#  id                 :integer          not null, primary key
-#  project_id         :integer
-#  status             :string
-#  finished_at        :datetime
-#  trace              :text
-#  created_at         :datetime
-#  updated_at         :datetime
-#  started_at         :datetime
-#  runner_id          :integer
-#  coverage           :float
-#  commit_id          :integer
-#  commands           :text
-#  job_id             :integer
-#  name               :string
-#  deploy             :boolean          default(FALSE)
-#  options            :text
-#  allow_failure      :boolean          default(FALSE), not null
-#  stage              :string
-#  trigger_request_id :integer
-#  stage_idx          :integer
-#  tag                :boolean
-#  ref                :string
-#  user_id            :integer
-#  type               :string
-#  target_url         :string
-#  description        :string
-#  artifacts_file     :text
-#  gl_project_id      :integer
-#  artifacts_metadata :text
-#  erased_by_id       :integer
-#  erased_at          :datetime
-#
-
 class GenericCommitStatus < CommitStatus
   before_validation :set_default_values
 
diff --git a/app/models/group.rb b/app/models/group.rb
index cff76877958f6ceb971ea383893a43673a9348c5..aec92e335e63a36a8928de46ab96fefa8fba0130 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -1,20 +1,3 @@
-# == Schema Information
-#
-# Table name: namespaces
-#
-#  id                    :integer          not null, primary key
-#  name                  :string           not null
-#  path                  :string           not null
-#  owner_id              :integer
-#  created_at            :datetime
-#  updated_at            :datetime
-#  type                  :string
-#  description           :string           default(""), not null
-#  avatar                :string
-#  share_with_group_lock :boolean          default(FALSE)
-#  visibility_level      :integer          default(20), not null
-#
-
 require 'carrierwave/orm/activerecord'
 
 class Group < Namespace
diff --git a/app/models/hooks/project_hook.rb b/app/models/hooks/project_hook.rb
index 2b8f34a056844f3a9c9fa207c8d7b29750c6249f..ba42a8eeb70bdd30a2bb84bee4535eafea8e1a3d 100644
--- a/app/models/hooks/project_hook.rb
+++ b/app/models/hooks/project_hook.rb
@@ -1,25 +1,3 @@
-# == Schema Information
-#
-# Table name: web_hooks
-#
-#  id                      :integer          not null, primary key
-#  url                     :string(2000)
-#  project_id              :integer
-#  created_at              :datetime
-#  updated_at              :datetime
-#  type                    :string           default("ProjectHook")
-#  service_id              :integer
-#  push_events             :boolean          default(TRUE), not null
-#  issues_events           :boolean          default(FALSE), not null
-#  merge_requests_events   :boolean          default(FALSE), not null
-#  tag_push_events         :boolean          default(FALSE)
-#  note_events             :boolean          default(FALSE), not null
-#  enable_ssl_verification :boolean          default(TRUE)
-#  build_events            :boolean          default(FALSE), not null
-#  wiki_page_events        :boolean          default(FALSE), not null
-#  token                   :string
-#
-
 class ProjectHook < WebHook
   belongs_to :project
 
diff --git a/app/models/hooks/service_hook.rb b/app/models/hooks/service_hook.rb
index 0e176de5ef81b8e1e65b685ab06de4aaae87f068..eef24052a064fa5248f56317b9df8b5b00b7401b 100644
--- a/app/models/hooks/service_hook.rb
+++ b/app/models/hooks/service_hook.rb
@@ -1,25 +1,3 @@
-# == Schema Information
-#
-# Table name: web_hooks
-#
-#  id                      :integer          not null, primary key
-#  url                     :string(2000)
-#  project_id              :integer
-#  created_at              :datetime
-#  updated_at              :datetime
-#  type                    :string           default("ProjectHook")
-#  service_id              :integer
-#  push_events             :boolean          default(TRUE), not null
-#  issues_events           :boolean          default(FALSE), not null
-#  merge_requests_events   :boolean          default(FALSE), not null
-#  tag_push_events         :boolean          default(FALSE)
-#  note_events             :boolean          default(FALSE), not null
-#  enable_ssl_verification :boolean          default(TRUE)
-#  build_events            :boolean          default(FALSE), not null
-#  wiki_page_events        :boolean          default(FALSE), not null
-#  token                   :string
-#
-
 class ServiceHook < WebHook
   belongs_to :service
 
diff --git a/app/models/hooks/system_hook.rb b/app/models/hooks/system_hook.rb
index ad508cbbcb8a7429eb6ec1452b50bb0a985bca62..777bad1e724166f6a8558f332cecee5373863c14 100644
--- a/app/models/hooks/system_hook.rb
+++ b/app/models/hooks/system_hook.rb
@@ -1,25 +1,3 @@
-# == Schema Information
-#
-# Table name: web_hooks
-#
-#  id                      :integer          not null, primary key
-#  url                     :string(2000)
-#  project_id              :integer
-#  created_at              :datetime
-#  updated_at              :datetime
-#  type                    :string           default("ProjectHook")
-#  service_id              :integer
-#  push_events             :boolean          default(TRUE), not null
-#  issues_events           :boolean          default(FALSE), not null
-#  merge_requests_events   :boolean          default(FALSE), not null
-#  tag_push_events         :boolean          default(FALSE)
-#  note_events             :boolean          default(FALSE), not null
-#  enable_ssl_verification :boolean          default(TRUE)
-#  build_events            :boolean          default(FALSE), not null
-#  wiki_page_events        :boolean          default(FALSE), not null
-#  token                   :string
-#
-
 class SystemHook < WebHook
   def async_execute(data, hook_name)
     Sidekiq::Client.enqueue(SystemHookWorker, id, data, hook_name)
diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb
index 8e58c9583abadae05207bd6a4278eea1a97cb7d9..fde05f729dcd0958bcc8fc9a5bdb4ac6ac36dffe 100644
--- a/app/models/hooks/web_hook.rb
+++ b/app/models/hooks/web_hook.rb
@@ -1,25 +1,3 @@
-# == Schema Information
-#
-# Table name: web_hooks
-#
-#  id                      :integer          not null, primary key
-#  url                     :string(2000)
-#  project_id              :integer
-#  created_at              :datetime
-#  updated_at              :datetime
-#  type                    :string           default("ProjectHook")
-#  service_id              :integer
-#  push_events             :boolean          default(TRUE), not null
-#  issues_events           :boolean          default(FALSE), not null
-#  merge_requests_events   :boolean          default(FALSE), not null
-#  tag_push_events         :boolean          default(FALSE)
-#  note_events             :boolean          default(FALSE), not null
-#  enable_ssl_verification :boolean          default(TRUE)
-#  build_events            :boolean          default(FALSE), not null
-#  wiki_page_events        :boolean          default(FALSE), not null
-#  token                   :string
-#
-
 class WebHook < ActiveRecord::Base
   include Sortable
   include HTTParty
diff --git a/app/models/identity.rb b/app/models/identity.rb
index ef4d5f99091bf16d622ed8e516d5fa142fc2e8ff..3bacc450e6e6cfedbfde01e1a06cfd0545c6aac2 100644
--- a/app/models/identity.rb
+++ b/app/models/identity.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: identities
-#
-#  id         :integer          not null, primary key
-#  extern_uid :string
-#  provider   :string
-#  user_id    :integer
-#  created_at :datetime
-#  updated_at :datetime
-#
-
 class Identity < ActiveRecord::Base
   include Sortable
   include CaseSensitivity
diff --git a/app/models/issue.rb b/app/models/issue.rb
index abaa509707c15d0f81ff3f7cd4b4a20c717fbc7a..2d4a9b9f19a3c68000afa262a30e00657b376815 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: issues
-#
-#  id            :integer          not null, primary key
-#  title         :string
-#  assignee_id   :integer
-#  author_id     :integer
-#  project_id    :integer
-#  created_at    :datetime
-#  updated_at    :datetime
-#  position      :integer          default(0)
-#  branch_name   :string
-#  description   :text
-#  milestone_id  :integer
-#  state         :string
-#  iid           :integer
-#  updated_by_id :integer
-#  moved_to_id   :integer
-#  confidential  :boolean          default(FALSE)
-#  deleted_at    :datetime
-#  due_date      :date
-#
-
 require 'carrierwave/orm/activerecord'
 
 class Issue < ActiveRecord::Base
diff --git a/app/models/key.rb b/app/models/key.rb
index b2b57849f8a55a46c1a71ba536e9e268309a9ceb..d52afda67d1710f7300e8cf94df66adb3c100e05 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: keys
-#
-#  id          :integer          not null, primary key
-#  user_id     :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#  key         :text
-#  title       :string
-#  type        :string
-#  fingerprint :string
-#  public      :boolean          default(FALSE), not null
-#
-
 require 'digest/md5'
 
 class Key < ActiveRecord::Base
diff --git a/app/models/label.rb b/app/models/label.rb
index 9a22398d9523f4809b178721196f4a97cc13e9f1..e5ad11983bea142981bf7f428d73210683dcb7c0 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -1,17 +1,3 @@
-# == Schema Information
-#
-# Table name: labels
-#
-#  id          :integer          not null, primary key
-#  title       :string
-#  color       :string
-#  project_id  :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#  template    :boolean          default(FALSE)
-#  description :string
-#
-
 class Label < ActiveRecord::Base
   include Referable
   include Subscribable
@@ -117,6 +103,10 @@ class Label < ActiveRecord::Base
     LabelsHelper::text_color_for_bg(self.color)
   end
 
+  def title=(value)
+    write_attribute(:title, Sanitize.clean(value.to_s)) if value.present?
+  end
+
   private
 
   def label_format_reference(format = :id)
diff --git a/app/models/label_link.rb b/app/models/label_link.rb
index 7b8e872b6dd1934f45ea855bdb78df186cc364c3..47bd6eaf35f91d3570bf053e0c8bb38fce0c4ce8 100644
--- a/app/models/label_link.rb
+++ b/app/models/label_link.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: label_links
-#
-#  id          :integer          not null, primary key
-#  label_id    :integer
-#  target_id   :integer
-#  target_type :string
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 class LabelLink < ActiveRecord::Base
   belongs_to :target, polymorphic: true
   belongs_to :label
diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb
index 927e764af926983edb02151fb8bfaf33351096be..18657c3e1c893e68dbc5ad215b56a0f7fe3c48c6 100644
--- a/app/models/lfs_object.rb
+++ b/app/models/lfs_object.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: lfs_objects
-#
-#  id         :integer          not null, primary key
-#  oid        :string           not null
-#  size       :integer          not null
-#  created_at :datetime
-#  updated_at :datetime
-#  file       :string
-#
-
 class LfsObject < ActiveRecord::Base
   has_many :lfs_objects_projects, dependent: :destroy
   has_many :projects, through: :lfs_objects_projects
diff --git a/app/models/lfs_objects_project.rb b/app/models/lfs_objects_project.rb
index 890736bfc80bac8d369d23e4a920141afb1f6b8e..0fd5f089db9076d03d7c17fcea5518964d688809 100644
--- a/app/models/lfs_objects_project.rb
+++ b/app/models/lfs_objects_project.rb
@@ -1,14 +1,3 @@
-# == Schema Information
-#
-# Table name: lfs_objects_projects
-#
-#  id            :integer          not null, primary key
-#  lfs_object_id :integer          not null
-#  project_id    :integer          not null
-#  created_at    :datetime
-#  updated_at    :datetime
-#
-
 class LfsObjectsProject < ActiveRecord::Base
   belongs_to :project
   belongs_to :lfs_object
diff --git a/app/models/member.rb b/app/models/member.rb
index cca82da89f18797eb70b94d6b408c02d197e44a0..d3060f07fc0fecaa683f491949d353643dd41bb8 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -1,22 +1,3 @@
-# == Schema Information
-#
-# Table name: members
-#
-#  id                 :integer          not null, primary key
-#  access_level       :integer          not null
-#  source_id          :integer          not null
-#  source_type        :string           not null
-#  user_id            :integer
-#  notification_level :integer          not null
-#  type               :string
-#  created_at         :datetime
-#  updated_at         :datetime
-#  created_by_id      :integer
-#  invite_email       :string
-#  invite_token       :string
-#  invite_accepted_at :datetime
-#
-
 class Member < ActiveRecord::Base
   include Sortable
   include Gitlab::Access
diff --git a/app/models/members/group_member.rb b/app/models/members/group_member.rb
index a48c1943e6f86d2240b172d6dfa945f19aa0410f..f63a0debf1a80304d660ff765b6033d92d0aab78 100644
--- a/app/models/members/group_member.rb
+++ b/app/models/members/group_member.rb
@@ -1,22 +1,3 @@
-# == Schema Information
-#
-# Table name: members
-#
-#  id                 :integer          not null, primary key
-#  access_level       :integer          not null
-#  source_id          :integer          not null
-#  source_type        :string           not null
-#  user_id            :integer
-#  notification_level :integer          not null
-#  type               :string
-#  created_at         :datetime
-#  updated_at         :datetime
-#  created_by_id      :integer
-#  invite_email       :string
-#  invite_token       :string
-#  invite_accepted_at :datetime
-#
-
 class GroupMember < Member
   SOURCE_TYPE = 'Namespace'
 
diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb
index 143350a0b55d8e1173c7eb0c05812da6f7279621..8dae3bb2ef2363a0cc9927c8a2f83f0b5322802b 100644
--- a/app/models/members/project_member.rb
+++ b/app/models/members/project_member.rb
@@ -1,22 +1,3 @@
-# == Schema Information
-#
-# Table name: members
-#
-#  id                 :integer          not null, primary key
-#  access_level       :integer          not null
-#  source_id          :integer          not null
-#  source_type        :string           not null
-#  user_id            :integer
-#  notification_level :integer          not null
-#  type               :string
-#  created_at         :datetime
-#  updated_at         :datetime
-#  created_by_id      :integer
-#  invite_email       :string
-#  invite_token       :string
-#  invite_accepted_at :datetime
-#
-
 class ProjectMember < Member
   SOURCE_TYPE = 'Project'
 
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 4175e1e5fbabb9be841be4d40300b4a10806e763..5460935366c3221f2aaf778545eb4190792b7304 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -1,33 +1,3 @@
-# == Schema Information
-#
-# Table name: merge_requests
-#
-#  id                        :integer          not null, primary key
-#  target_branch             :string           not null
-#  source_branch             :string           not null
-#  source_project_id         :integer          not null
-#  author_id                 :integer
-#  assignee_id               :integer
-#  title                     :string
-#  created_at                :datetime
-#  updated_at                :datetime
-#  milestone_id              :integer
-#  state                     :string
-#  merge_status              :string
-#  target_project_id         :integer          not null
-#  iid                       :integer
-#  description               :text
-#  position                  :integer          default(0)
-#  locked_at                 :datetime
-#  updated_by_id             :integer
-#  merge_error               :string
-#  merge_params              :text
-#  merge_when_build_succeeds :boolean          default(FALSE), not null
-#  merge_user_id             :integer
-#  merge_commit_sha          :string
-#  deleted_at                :datetime
-#
-
 class MergeRequest < ActiveRecord::Base
   include InternalId
   include Issuable
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index 8951e92a0b87dc8564af0147bf98c36087b1e386..eb42c07b9b92fe7f639eeac341092e4044f82570 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: merge_request_diffs
-#
-#  id               :integer          not null, primary key
-#  state            :string
-#  st_commits       :text
-#  st_diffs         :text
-#  merge_request_id :integer          not null
-#  created_at       :datetime
-#  updated_at       :datetime
-#  base_commit_sha  :string
-#  real_size        :string
-#
-
 class MergeRequestDiff < ActiveRecord::Base
   include Sortable
 
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index 5ee8a965ad8beafc090652ffcbbb457445a24f8e..e4fdd23badb5d94f71e77769d8e786a77b411a37 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: milestones
-#
-#  id          :integer          not null, primary key
-#  title       :string           not null
-#  project_id  :integer          not null
-#  description :text
-#  due_date    :date
-#  created_at  :datetime
-#  updated_at  :datetime
-#  state       :string
-#  iid         :integer
-#
-
 class Milestone < ActiveRecord::Base
   # Represents a "No Milestone" state used for filtering Issues and Merge
   # Requests that have no milestone assigned.
@@ -129,6 +114,10 @@ class Milestone < ActiveRecord::Base
     nil
   end
 
+  def title=(value)
+    write_attribute(:title, Sanitize.clean(value.to_s)) if value.present?
+  end
+
   # Sorts the issues for the given IDs.
   #
   # This method runs a single SQL query using a CASE statement to update the
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 741e912171d5d2b546ae134b791b70e459d6a2d2..9c942a8f4e35253f2246d2d1b0004ca1cf5f3c92 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -1,20 +1,3 @@
-# == Schema Information
-#
-# Table name: namespaces
-#
-#  id                    :integer          not null, primary key
-#  name                  :string           not null
-#  path                  :string           not null
-#  owner_id              :integer
-#  created_at            :datetime
-#  updated_at            :datetime
-#  type                  :string
-#  description           :string           default(""), not null
-#  avatar                :string
-#  share_with_group_lock :boolean          default(FALSE)
-#  visibility_level      :integer          default(20), not null
-#
-
 class Namespace < ActiveRecord::Base
   include Sortable
   include Gitlab::ShellAdapter
diff --git a/app/models/note.rb b/app/models/note.rb
index deee2b9e8854cf6aa64c75684dfbaaf85b5bc497..f26aa1bf63f79f7b6079a4bfc9dbe59d4fb132ec 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -1,24 +1,3 @@
-# == Schema Information
-#
-# Table name: notes
-#
-#  id            :integer          not null, primary key
-#  note          :text
-#  noteable_type :string
-#  author_id     :integer
-#  created_at    :datetime
-#  updated_at    :datetime
-#  project_id    :integer
-#  attachment    :string
-#  line_code     :string
-#  commit_id     :string
-#  noteable_id   :integer
-#  system        :boolean          default(FALSE), not null
-#  st_diff       :text
-#  updated_by_id :integer
-#  is_award      :boolean          default(FALSE), not null
-#
-
 require 'carrierwave/orm/activerecord'
 
 class Note < ActiveRecord::Base
diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb
index 846773752a67f03b6f9946e5cf23f8b40ff88fcc..5001738f411f43a05c678d7edf6d0fd85bbda8d6 100644
--- a/app/models/notification_setting.rb
+++ b/app/models/notification_setting.rb
@@ -1,16 +1,3 @@
-# == Schema Information
-#
-# Table name: notification_settings
-#
-#  id          :integer          not null, primary key
-#  user_id     :integer          not null
-#  source_id   :integer          not null
-#  source_type :string           not null
-#  level       :integer          default(0), not null
-#  created_at  :datetime         not null
-#  updated_at  :datetime         not null
-#
-
 class NotificationSetting < ActiveRecord::Base
   enum level: { disabled: 0,  participating: 1,  watch: 2,  global: 3, mention: 4 }
 
diff --git a/app/models/oauth_access_token.rb b/app/models/oauth_access_token.rb
index c78c7f4aa0e3eb0c3cbd3213b348b2b0e9eb00b9..116fb71ac083e20467d6ea4d058eb26ad68eee53 100644
--- a/app/models/oauth_access_token.rb
+++ b/app/models/oauth_access_token.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: oauth_access_tokens
-#
-#  id                :integer          not null, primary key
-#  resource_owner_id :integer
-#  application_id    :integer
-#  token             :string           not null
-#  refresh_token     :string
-#  expires_in        :integer
-#  revoked_at        :datetime
-#  created_at        :datetime         not null
-#  scopes            :string
-#
-
 class OauthAccessToken < ActiveRecord::Base
   belongs_to :resource_owner, class_name: 'User'
   belongs_to :application, class_name: 'Doorkeeper::Application'
diff --git a/app/models/personal_snippet.rb b/app/models/personal_snippet.rb
index 1d5f4c50254f6fa624fc75b8f584199d37371178..82c1c4de3a0fcbfc82632eac332ddc54620914df 100644
--- a/app/models/personal_snippet.rb
+++ b/app/models/personal_snippet.rb
@@ -1,18 +1,2 @@
-# == Schema Information
-#
-# Table name: snippets
-#
-#  id               :integer          not null, primary key
-#  title            :string
-#  content          :text
-#  author_id        :integer          not null
-#  project_id       :integer
-#  created_at       :datetime
-#  updated_at       :datetime
-#  file_name        :string
-#  type             :string
-#  visibility_level :integer          default(0), not null
-#
-
 class PersonalSnippet < Snippet
 end
diff --git a/app/models/project.rb b/app/models/project.rb
index dfd1e54ecf79b7d9b5aaea33d2bafe62c624a498..418b85e028a0a4f15825461c0e501553ac2e43b2 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1,49 +1,3 @@
-# == Schema Information
-#
-# Table name: projects
-#
-#  id                           :integer          not null, primary key
-#  name                         :string
-#  path                         :string
-#  description                  :text
-#  created_at                   :datetime
-#  updated_at                   :datetime
-#  creator_id                   :integer
-#  issues_enabled               :boolean          default(TRUE), not null
-#  wall_enabled                 :boolean          default(TRUE), not null
-#  merge_requests_enabled       :boolean          default(TRUE), not null
-#  wiki_enabled                 :boolean          default(TRUE), not null
-#  namespace_id                 :integer
-#  issues_tracker               :string           default("gitlab"), not null
-#  issues_tracker_id            :string
-#  snippets_enabled             :boolean          default(TRUE), not null
-#  last_activity_at             :datetime
-#  import_url                   :string
-#  visibility_level             :integer          default(0), not null
-#  archived                     :boolean          default(FALSE), not null
-#  avatar                       :string
-#  import_status                :string
-#  repository_size              :float            default(0.0)
-#  star_count                   :integer          default(0), not null
-#  import_type                  :string
-#  import_source                :string
-#  commit_count                 :integer          default(0)
-#  import_error                 :text
-#  ci_id                        :integer
-#  builds_enabled               :boolean          default(TRUE), not null
-#  shared_runners_enabled       :boolean          default(TRUE), not null
-#  runners_token                :string
-#  build_coverage_regex         :string
-#  build_allow_git_fetch        :boolean          default(TRUE), not null
-#  build_timeout                :integer          default(3600), not null
-#  pending_delete               :boolean          default(FALSE)
-#  public_builds                :boolean          default(TRUE), not null
-#  main_language                :string
-#  pushes_since_gc              :integer          default(0)
-#  last_repository_check_failed :boolean
-#  last_repository_check_at     :datetime
-#
-
 require 'carrierwave/orm/activerecord'
 
 class Project < ActiveRecord::Base
@@ -67,7 +21,6 @@ class Project < ActiveRecord::Base
   default_value_for :merge_requests_enabled, gitlab_config_features.merge_requests
   default_value_for :builds_enabled, gitlab_config_features.builds
   default_value_for :wiki_enabled, gitlab_config_features.wiki
-  default_value_for :wall_enabled, false
   default_value_for :snippets_enabled, gitlab_config_features.snippets
   default_value_for(:shared_runners_enabled) { current_application_settings.shared_runners_enabled }
 
@@ -767,7 +720,7 @@ class Project < ActiveRecord::Base
 
   # Check if current branch name is marked as protected in the system
   def protected_branch?(branch_name)
-    protected_branches.where(name: branch_name).any?
+    protected_branch_names.include?(branch_name)
   end
 
   def developers_can_push_to_protected_branch?(branch_name)
diff --git a/app/models/project_group_link.rb b/app/models/project_group_link.rb
index 66f5a609bf5f3035a1f986e092472fb0e4cf88d3..e52a6bd7c8473b69054824db5724ae4d12d77954 100644
--- a/app/models/project_group_link.rb
+++ b/app/models/project_group_link.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: project_group_links
-#
-#  id           :integer          not null, primary key
-#  project_id   :integer          not null
-#  group_id     :integer          not null
-#  created_at   :datetime
-#  updated_at   :datetime
-#  group_access :integer          default(30), not null
-#
-
 class ProjectGroupLink < ActiveRecord::Base
   GUEST     = 10
   REPORTER  = 20
diff --git a/app/models/project_import_data.rb b/app/models/project_import_data.rb
index 7830f764ed3f183c09ed644b5108ddfb7f681fe8..e2f9ffb69acb98db7becc0adff22018c12e69293 100644
--- a/app/models/project_import_data.rb
+++ b/app/models/project_import_data.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: project_import_data
-#
-#  id                         :integer          not null, primary key
-#  project_id                 :integer
-#  data                       :text
-#  encrypted_credentials      :text
-#  encrypted_credentials_iv   :string
-#  encrypted_credentials_salt :string
-#
-
 require 'carrierwave/orm/activerecord'
 
 class ProjectImportData < ActiveRecord::Base
diff --git a/app/models/project_services/asana_service.rb b/app/models/project_services/asana_service.rb
index 368485a060aa8e433b536d7512e4220ff2ca5766..7c23b76676374c80af5853b58ddebc234aae87d1 100644
--- a/app/models/project_services/asana_service.rb
+++ b/app/models/project_services/asana_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 require 'asana'
 
 class AsanaService < Service
diff --git a/app/models/project_services/assembla_service.rb b/app/models/project_services/assembla_service.rb
index ffb7455b0143db3f819977ee441b95adcfb0877c..d839221d315e04dc6e53f80a64e47e2bf3b88ef7 100644
--- a/app/models/project_services/assembla_service.rb
+++ b/app/models/project_services/assembla_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class AssemblaService < Service
   include HTTParty
 
diff --git a/app/models/project_services/bamboo_service.rb b/app/models/project_services/bamboo_service.rb
index c36ee95e37801ef34a43bca57d245bf50284d7b9..1d1780dcfbf3e221f8d8cb22988b79774605af7b 100644
--- a/app/models/project_services/bamboo_service.rb
+++ b/app/models/project_services/bamboo_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class BambooService < CiService
   include HTTParty
 
diff --git a/app/models/project_services/buildkite_service.rb b/app/models/project_services/buildkite_service.rb
index f9f4897a065f02117983564936f731db81f38dda..86a06321e212d48df41b5f48cd011d218f9ff9ff 100644
--- a/app/models/project_services/buildkite_service.rb
+++ b/app/models/project_services/buildkite_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 require "addressable/uri"
 
 class BuildkiteService < CiService
diff --git a/app/models/project_services/builds_email_service.rb b/app/models/project_services/builds_email_service.rb
index 20cdfcaffb210e1e0b38621b15197b6253eca084..54da4d74fc5b21f7f45fcab78d25a1009da9c180 100644
--- a/app/models/project_services/builds_email_service.rb
+++ b/app/models/project_services/builds_email_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class BuildsEmailService < Service
   prop_accessor :recipients
   boolean_accessor :add_pusher
diff --git a/app/models/project_services/campfire_service.rb b/app/models/project_services/campfire_service.rb
index 28c969fe57f3f170d818ba7e95965a8549f58368..511b2eac792dbd1e0cdb0b92fc0d3673f9dd9b8d 100644
--- a/app/models/project_services/campfire_service.rb
+++ b/app/models/project_services/campfire_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class CampfireService < Service
   prop_accessor :token, :subdomain, :room
   validates :token, presence: true, if: :activated?
diff --git a/app/models/project_services/ci_service.rb b/app/models/project_services/ci_service.rb
index 9bc8f982da614a95239431ae33e665ad5f089491..596c00705adcbad6fa5497e0620109cf82d41761 100644
--- a/app/models/project_services/ci_service.rb
+++ b/app/models/project_services/ci_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 # Base class for CI services
 # List methods you need to implement to get your CI service
 # working with GitLab Merge Requests
diff --git a/app/models/project_services/custom_issue_tracker_service.rb b/app/models/project_services/custom_issue_tracker_service.rb
index 4d1319eb6f8329f0a8a5390bdf753bc48e548343..6b2b1daa724bab5559831c72abe931150911796a 100644
--- a/app/models/project_services/custom_issue_tracker_service.rb
+++ b/app/models/project_services/custom_issue_tracker_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class CustomIssueTrackerService < IssueTrackerService
 
   prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url
diff --git a/app/models/project_services/drone_ci_service.rb b/app/models/project_services/drone_ci_service.rb
index d8e00e018cc5627de1d30213b7f9f6575e59fe72..966dbc41d737ed7155863cc364ece180858569c8 100644
--- a/app/models/project_services/drone_ci_service.rb
+++ b/app/models/project_services/drone_ci_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class DroneCiService < CiService
 
   prop_accessor :drone_url, :token, :enable_ssl_verification
diff --git a/app/models/project_services/emails_on_push_service.rb b/app/models/project_services/emails_on_push_service.rb
index 2dbd29062dfac65a79aa2c878c07d68a8d044eff..e0083c43adb260b7bb0765693d9af7aeacb9520a 100644
--- a/app/models/project_services/emails_on_push_service.rb
+++ b/app/models/project_services/emails_on_push_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class EmailsOnPushService < Service
   prop_accessor :send_from_committer_email
   prop_accessor :disable_diffs
diff --git a/app/models/project_services/external_wiki_service.rb b/app/models/project_services/external_wiki_service.rb
index 5469049bb5eb74a91152efca355772133fc4e30a..f042bfc52109e15e10c47668a7f5aa4650a6151c 100644
--- a/app/models/project_services/external_wiki_service.rb
+++ b/app/models/project_services/external_wiki_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class ExternalWikiService < Service
   include HTTParty
 
diff --git a/app/models/project_services/flowdock_service.rb b/app/models/project_services/flowdock_service.rb
index 3dc1e0fbe8b9ca75a26385a2a3d5e65c81ee5f99..dd00275187f63533e21249d810294ce9b4ae9ee3 100644
--- a/app/models/project_services/flowdock_service.rb
+++ b/app/models/project_services/flowdock_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 require "flowdock-git-hook"
 
 class FlowdockService < Service
diff --git a/app/models/project_services/gemnasium_service.rb b/app/models/project_services/gemnasium_service.rb
index b4c311cf664d9223bab202f3eb43cb5ff69c90da..598aca5e06d28bf517fbfbdb935efe287a7b0a6e 100644
--- a/app/models/project_services/gemnasium_service.rb
+++ b/app/models/project_services/gemnasium_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 require "gemnasium/gitlab_service"
 
 class GemnasiumService < Service
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index a92f722608388ee5158eef8eda23680fac3cbefd..bbc312f521555c8bc02516cc32bcc3c1acd6fde6 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 # TODO(ayufan): The GitLabCiService is deprecated and the type should be removed when the database entries are removed
 class GitlabCiService < CiService
   # We override the active accessor to always make GitLabCiService disabled
diff --git a/app/models/project_services/gitlab_issue_tracker_service.rb b/app/models/project_services/gitlab_issue_tracker_service.rb
index 1adaeeb3b2baa5b9c6a5db7ad703e34faef6da1e..5d17c3583306c552198b5a08c28c2b127d779a4f 100644
--- a/app/models/project_services/gitlab_issue_tracker_service.rb
+++ b/app/models/project_services/gitlab_issue_tracker_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class GitlabIssueTrackerService < IssueTrackerService
   include Gitlab::Routing.url_helpers
 
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb
index f9ddf5887226ddd120ca39f6390d34ad3682e4ea..0ff4f4c8dd2cd9e41295cbb95b2b071db64efa1c 100644
--- a/app/models/project_services/hipchat_service.rb
+++ b/app/models/project_services/hipchat_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class HipchatService < Service
   MAX_COMMITS = 3
 
diff --git a/app/models/project_services/irker_service.rb b/app/models/project_services/irker_service.rb
index b9a592d709635b46d4cfe53d4028877da5d6e964..91015e6c9b1404886eea77cc7f15883f26d906e0 100644
--- a/app/models/project_services/irker_service.rb
+++ b/app/models/project_services/irker_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 require 'uri'
 
 class IrkerService < Service
diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb
index 98a3a7c6b86f3c871a6e38aa9cb8e0fa77e291d6..6ae9b16d3ce49635e3eb0f79a06cd2fe9843a1ac 100644
--- a/app/models/project_services/issue_tracker_service.rb
+++ b/app/models/project_services/issue_tracker_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class IssueTrackerService < Service
 
   validates :project_url, :issues_url, :new_issue_url, presence: true, url: true, if: :activated?
diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb
index ba68658f0bd16229f3a2ea8d283773d21e5d7216..beda89d396317adf94b70a435d18ee2d6a50de35 100644
--- a/app/models/project_services/jira_service.rb
+++ b/app/models/project_services/jira_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class JiraService < IssueTrackerService
   include HTTParty
   include Gitlab::Routing.url_helpers
diff --git a/app/models/project_services/pivotaltracker_service.rb b/app/models/project_services/pivotaltracker_service.rb
index acaa0c393651d291c8d2f35ed15a25368c99d96e..ad19b7795da86dab391d2c2358088b14779203e1 100644
--- a/app/models/project_services/pivotaltracker_service.rb
+++ b/app/models/project_services/pivotaltracker_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class PivotaltrackerService < Service
   include HTTParty
 
diff --git a/app/models/project_services/pushover_service.rb b/app/models/project_services/pushover_service.rb
index a640c8cb4404c2b3e3b1d790dd6cd53312720691..3dd878e4c7d77356dcc67c684d5968a6fc1f1718 100644
--- a/app/models/project_services/pushover_service.rb
+++ b/app/models/project_services/pushover_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class PushoverService < Service
   include HTTParty
   base_uri 'https://api.pushover.net/1'
diff --git a/app/models/project_services/redmine_service.rb b/app/models/project_services/redmine_service.rb
index e2137e92c6279872ab21fdbe193da2661232a62c..11cce3e0561f827f6023dce431ca2afc6957416c 100644
--- a/app/models/project_services/redmine_service.rb
+++ b/app/models/project_services/redmine_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class RedmineService < IssueTrackerService
 
   prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url
diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb
index 83ffa53a407e35088c347fa5975a76e2a0673e28..cf9e4d5a8b60c4c018714d4ec4f01ce50e90fe8a 100644
--- a/app/models/project_services/slack_service.rb
+++ b/app/models/project_services/slack_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class SlackService < Service
   prop_accessor :webhook, :username, :channel
   boolean_accessor :notify_only_broken_builds
diff --git a/app/models/project_services/teamcity_service.rb b/app/models/project_services/teamcity_service.rb
index 4015da31509a72ff2ce7667598e1264b708ba9d4..b0dcb52eba15db9b1f03f6f649d62a5125a9e3e7 100644
--- a/app/models/project_services/teamcity_service.rb
+++ b/app/models/project_services/teamcity_service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 class TeamcityService < CiService
   include HTTParty
 
diff --git a/app/models/project_snippet.rb b/app/models/project_snippet.rb
index b4b2807eba43ec258e862825145c2ea655082e3f..5fba6baa204e19953e9753546397f2bb0882b54d 100644
--- a/app/models/project_snippet.rb
+++ b/app/models/project_snippet.rb
@@ -1,19 +1,3 @@
-# == Schema Information
-#
-# Table name: snippets
-#
-#  id               :integer          not null, primary key
-#  title            :string
-#  content          :text
-#  author_id        :integer          not null
-#  project_id       :integer
-#  created_at       :datetime
-#  updated_at       :datetime
-#  file_name        :string
-#  type             :string
-#  visibility_level :integer          default(0), not null
-#
-
 class ProjectSnippet < Snippet
   belongs_to :project
   belongs_to :author, class_name: "User"
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb
index 3d2052c892ca75b8cdfa0829065362475c33af37..33cf046fa75c47134518a7f05bbdad9ed0b083c1 100644
--- a/app/models/protected_branch.rb
+++ b/app/models/protected_branch.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: protected_branches
-#
-#  id                  :integer          not null, primary key
-#  project_id          :integer          not null
-#  name                :string           not null
-#  created_at          :datetime
-#  updated_at          :datetime
-#  developers_can_push :boolean          default(FALSE), not null
-#
-
 class ProtectedBranch < ActiveRecord::Base
   include Gitlab::ShellAdapter
 
diff --git a/app/models/release.rb b/app/models/release.rb
index dc700d1ea5a42c34fbc10cc42c5bb0372b3b92c5..e196b84eb18845cbbfdf8b2acedd6309ab3931f2 100644
--- a/app/models/release.rb
+++ b/app/models/release.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: releases
-#
-#  id          :integer          not null, primary key
-#  tag         :string
-#  description :text
-#  project_id  :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 class Release < ActiveRecord::Base
   belongs_to :project
 
diff --git a/app/models/security_event.rb b/app/models/security_event.rb
index 0bee03974f14521506935e746de0257cb499f50e..d131c11cb6c6d7dea146141887f78755c4fe28bb 100644
--- a/app/models/security_event.rb
+++ b/app/models/security_event.rb
@@ -1,16 +1,2 @@
-# == Schema Information
-#
-# Table name: audit_events
-#
-#  id          :integer          not null, primary key
-#  author_id   :integer          not null
-#  type        :string           not null
-#  entity_id   :integer          not null
-#  entity_type :string           not null
-#  details     :text
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 class SecurityEvent < AuditEvent
 end
diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb
index 99279a2e083082a3412a41d9181c52e33ad7f404..375f195dba7234de5c5221b220faa5a4e33b7c2b 100644
--- a/app/models/sent_notification.rb
+++ b/app/models/sent_notification.rb
@@ -1,17 +1,3 @@
-# == Schema Information
-#
-# Table name: sent_notifications
-#
-#  id            :integer          not null, primary key
-#  project_id    :integer
-#  noteable_id   :integer
-#  noteable_type :string
-#  recipient_id  :integer
-#  commit_id     :string
-#  reply_key     :string           not null
-#  line_code     :string
-#
-
 class SentNotification < ActiveRecord::Base
   belongs_to :project
   belongs_to :noteable, polymorphic: true
diff --git a/app/models/service.rb b/app/models/service.rb
index bf16a5453071bf8e2faa17dbc23a14fc6e6b19a6..de3fd24584a43873287fc8416d1091c6be319637 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -1,27 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string
-#  title                 :string
-#  project_id            :integer
-#  created_at            :datetime         not null
-#  updated_at            :datetime         not null
-#  active                :boolean          not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#  category              :string           default("common"), not null
-#  default               :boolean          default(FALSE)
-#  wiki_page_events      :boolean          default(TRUE)
-#
-
 # To add new service you should build a class inherited from Service
 # and implement a set of methods
 class Service < ActiveRecord::Base
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 2f905a90942475fd6042b9c69abf200f6949197e..0a3c3b57669a1423f88c4d3cea9463dc6dddd4f5 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -1,19 +1,3 @@
-# == Schema Information
-#
-# Table name: snippets
-#
-#  id               :integer          not null, primary key
-#  title            :string
-#  content          :text
-#  author_id        :integer          not null
-#  project_id       :integer
-#  created_at       :datetime
-#  updated_at       :datetime
-#  file_name        :string
-#  type             :string
-#  visibility_level :integer          default(0), not null
-#
-
 class Snippet < ActiveRecord::Base
   include Gitlab::VisibilityLevel
   include Linguist::BlobHelper
diff --git a/app/models/spam_log.rb b/app/models/spam_log.rb
index f49eb7d88e20e3a4ab3d57be4e517d7ada78bfb1..12df68ef83bf17771b16f079216c9b9fe3cd3a97 100644
--- a/app/models/spam_log.rb
+++ b/app/models/spam_log.rb
@@ -1,20 +1,3 @@
-# == Schema Information
-#
-# Table name: spam_logs
-#
-#  id            :integer          not null, primary key
-#  user_id       :integer
-#  source_ip     :string
-#  user_agent    :string
-#  via_api       :boolean
-#  project_id    :integer
-#  noteable_type :string
-#  title         :string
-#  description   :text
-#  created_at    :datetime         not null
-#  updated_at    :datetime         not null
-#
-
 class SpamLog < ActiveRecord::Base
   belongs_to :user
 
diff --git a/app/models/subscription.rb b/app/models/subscription.rb
index 242faa7d32eb5aa6ba4a40a8fad6eb8d8761bfd6..3b8aa1eb8669bec2cb090f3257cf6fc2780de4e5 100644
--- a/app/models/subscription.rb
+++ b/app/models/subscription.rb
@@ -1,16 +1,3 @@
-# == Schema Information
-#
-# Table name: subscriptions
-#
-#  id                :integer          not null, primary key
-#  user_id           :integer
-#  subscribable_id   :integer
-#  subscribable_type :string
-#  subscribed        :boolean
-#  created_at        :datetime
-#  updated_at        :datetime
-#
-
 class Subscription < ActiveRecord::Base
   belongs_to :user
   belongs_to :subscribable, polymorphic: true
diff --git a/app/models/todo.rb b/app/models/todo.rb
index d85f7bfdf57219688596245c6b4293f8ff5e18b9..f8b59fe41261e470ae05420d5a744d43ec7d70ff 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -1,21 +1,3 @@
-# == Schema Information
-#
-# Table name: todos
-#
-#  id          :integer          not null, primary key
-#  user_id     :integer          not null
-#  project_id  :integer          not null
-#  target_id   :integer
-#  target_type :string           not null
-#  author_id   :integer
-#  action      :integer          not null
-#  state       :string           not null
-#  created_at  :datetime
-#  updated_at  :datetime
-#  note_id     :integer
-#  commit_id   :string
-#
-
 class Todo < ActiveRecord::Base
   ASSIGNED  = 1
   MENTIONED = 2
diff --git a/app/models/user.rb b/app/models/user.rb
index 959b1f93758ffd7f39358c412b02ee919c149cf3..1e4814641d1b02e4e02ac5a96902a3f76e8896f1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,68 +1,3 @@
-# == Schema Information
-#
-# Table name: users
-#
-#  id                          :integer          not null, primary key
-#  email                       :string           default(""), not null
-#  encrypted_password          :string           default(""), not null
-#  reset_password_token        :string
-#  reset_password_sent_at      :datetime
-#  remember_created_at         :datetime
-#  sign_in_count               :integer          default(0)
-#  current_sign_in_at          :datetime
-#  last_sign_in_at             :datetime
-#  current_sign_in_ip          :string
-#  last_sign_in_ip             :string
-#  created_at                  :datetime
-#  updated_at                  :datetime
-#  name                        :string
-#  admin                       :boolean          default(FALSE), not null
-#  projects_limit              :integer          default(10)
-#  skype                       :string           default(""), not null
-#  linkedin                    :string           default(""), not null
-#  twitter                     :string           default(""), not null
-#  authentication_token        :string
-#  theme_id                    :integer          default(1), not null
-#  bio                         :string
-#  failed_attempts             :integer          default(0)
-#  locked_at                   :datetime
-#  username                    :string
-#  can_create_group            :boolean          default(TRUE), not null
-#  can_create_team             :boolean          default(TRUE), not null
-#  state                       :string
-#  color_scheme_id             :integer          default(1), not null
-#  notification_level          :integer          default(1), not null
-#  password_expires_at         :datetime
-#  created_by_id               :integer
-#  last_credential_check_at    :datetime
-#  avatar                      :string
-#  confirmation_token          :string
-#  confirmed_at                :datetime
-#  confirmation_sent_at        :datetime
-#  unconfirmed_email           :string
-#  hide_no_ssh_key             :boolean          default(FALSE)
-#  website_url                 :string           default(""), not null
-#  notification_email          :string
-#  hide_no_password            :boolean          default(FALSE)
-#  password_automatically_set  :boolean          default(FALSE)
-#  location                    :string
-#  encrypted_otp_secret        :string
-#  encrypted_otp_secret_iv     :string
-#  encrypted_otp_secret_salt   :string
-#  otp_required_for_login      :boolean          default(FALSE), not null
-#  otp_backup_codes            :text
-#  public_email                :string           default(""), not null
-#  dashboard                   :integer          default(0)
-#  project_view                :integer          default(0)
-#  consumed_timestep           :integer
-#  layout                      :integer          default(0)
-#  hide_project_limit          :boolean          default(FALSE)
-#  unlock_token                :string
-#  otp_grace_period_started_at :datetime
-#  ldap_email                  :boolean          default(FALSE), not null
-#  external                    :boolean          default(FALSE)
-#
-
 require 'carrierwave/orm/activerecord'
 
 class User < ActiveRecord::Base
@@ -86,7 +21,7 @@ class User < ActiveRecord::Base
   default_value_for :theme_id, gitlab_config.default_theme
 
   devise :two_factor_authenticatable,
-         otp_secret_encryption_key: File.read(Rails.root.join('.secret')).chomp
+         otp_secret_encryption_key: Gitlab::Application.config.secret_key_base
   alias_attribute :two_factor_enabled, :otp_required_for_login
 
   devise :two_factor_backupable, otp_number_of_backup_codes: 10
diff --git a/app/models/users_star_project.rb b/app/models/users_star_project.rb
index 413f3f485a85bed453588be0aebc870b083add16..0dfe597317e3617b8045262acbccda9a8bdd0cdd 100644
--- a/app/models/users_star_project.rb
+++ b/app/models/users_star_project.rb
@@ -1,14 +1,3 @@
-# == Schema Information
-#
-# Table name: users_star_projects
-#
-#  id         :integer          not null, primary key
-#  project_id :integer          not null
-#  user_id    :integer          not null
-#  created_at :datetime
-#  updated_at :datetime
-#
-
 class UsersStarProject < ActiveRecord::Base
   belongs_to :project, counter_cache: :star_count, touch: true
   belongs_to :user
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index 82a0e2fd1f563ef98ff8108e7ac7f0fa7330c564..4bdb1b0c0747fe1a1dedabf45aa0e95b538f1438 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -351,7 +351,7 @@ class SystemNoteService
   # Returns an Array of Strings
   def self.new_commit_summary(new_commits)
     new_commits.collect do |commit|
-      "* #{commit.short_id} - #{commit.title}"
+      "* #{commit.short_id} - #{escape_html(commit.title)}"
     end
   end
 
@@ -433,4 +433,8 @@ class SystemNoteService
     body = "Moved #{direction} #{cross_reference}"
     create_note(noteable: noteable, project: project, author: author, note: body)
   end
+
+  def self.escape_html(text)
+    Rack::Utils.escape_html(text)
+  end
 end
diff --git a/app/views/admin/runners/_runner.html.haml b/app/views/admin/runners/_runner.html.haml
index 6745e58deca5f6f127bff5fc79cc7c1e0d5f2655..36b21eefdee8ddc25286fc242595c0fec1dcba42 100644
--- a/app/views/admin/runners/_runner.html.haml
+++ b/app/views/admin/runners/_runner.html.haml
@@ -11,18 +11,10 @@
     = link_to admin_runner_path(runner) do
       = runner.short_sha
   %td
-    .runner-description
-      = runner.description
-      %span (#{link_to 'edit', '#', class: 'edit-runner-link'})
-    .runner-description-form.hide
-      = form_for [:admin, runner], remote: true, html: { class: 'form-inline' } do |f|
-        .form-group
-          = f.text_field :description, class: 'form-control'
-        = f.submit 'Save', class: 'btn'
-        %span (#{link_to 'cancel', '#', class: 'cancel'})
+    = runner.description
   %td
     - if runner.shared?
-      \-
+      n/a
     - else
       = runner.projects.count(:all)
   %td
diff --git a/app/views/layouts/header/_default.html.haml b/app/views/layouts/header/_default.html.haml
index 86930d4eaaf85f67b5b9900e7f4bb4c416985536..172579dafdaaf4bd4409f6affe199bc230e7da38 100644
--- a/app/views/layouts/header/_default.html.haml
+++ b/app/views/layouts/header/_default.html.haml
@@ -1,9 +1,12 @@
 %header.navbar.navbar-fixed-top.navbar-gitlab{ class: nav_header_class }
   %div{ class: fluid_layout ? "container-fluid" : "container-fluid" }
     .header-content
-      %button.navbar-toggle{type: 'button'}
+      %button.side-nav-toggle{type: 'button'}
         %span.sr-only Toggle navigation
         = icon('bars')
+      %button.navbar-toggle{type: 'button'}
+        %span.sr-only Toggle navigation
+        = icon('angle-left')
 
       .navbar-collapse.collapse
         %ul.nav.navbar-nav
diff --git a/app/views/projects/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml
index 9ad86ed71c98f531a050ec6bfc53398a6b38c2a8..5cf70ea3bb75282647c89363da418a450b277630 100644
--- a/app/views/projects/issues/_issue.html.haml
+++ b/app/views/projects/issues/_issue.html.haml
@@ -28,16 +28,10 @@
           = downvotes
 
       - note_count = issue.notes.user.nonawards.count
-      - if note_count > 0
-        %li
-          = link_to issue_path(issue) + "#notes" do
-            = icon('comments')
-            = note_count
-      - else
-        %li
-          = link_to issue_path(issue) + "#notes", class: "issue-no-comments" do
-            = icon('comments')
-            = note_count
+      %li
+        = link_to issue_path(issue, anchor: 'notes'), class: ('issue-no-comments' if note_count.zero?) do
+          = icon('comments')
+          = note_count
 
   .issue-info
     #{issue.to_reference} &middot;
diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml
index e740fe8c84d64b1fb7ba77af698b8a304bc8a642..73c6a95f5caf131b3eb5ec74fa679948fb6da42c 100644
--- a/app/views/projects/merge_requests/_merge_request.html.haml
+++ b/app/views/projects/merge_requests/_merge_request.html.haml
@@ -36,16 +36,10 @@
           = downvotes
 
       - note_count = merge_request.mr_and_commit_notes.user.nonawards.count
-      - if note_count > 0
-        %li
-          = link_to merge_request_path(merge_request) + "#notes" do
-            = icon('comments')
-            = note_count
-      - else
-        %li
-          = link_to merge_request_path(merge_request) + "#notes", class: "merge-request-no-comments" do
-            = icon('comments')
-            = note_count
+      %li
+        = link_to merge_request_path(merge_request, anchor: 'notes'), class: ('merge-request-no-comments' if note_count.zero?) do
+          = icon('comments')
+          = note_count
 
   .merge-request-info
     #{merge_request.to_reference} &middot;
diff --git a/app/views/projects/merge_requests/widget/_heading.html.haml b/app/views/projects/merge_requests/widget/_heading.html.haml
index 2ec0d20a8796682d9bceeba128d7bd9dd1f27253..4d3817546103f1dee29139894b16fd184f5e439d 100644
--- a/app/views/projects/merge_requests/widget/_heading.html.haml
+++ b/app/views/projects/merge_requests/widget/_heading.html.haml
@@ -41,9 +41,4 @@
 
     .ci_widget.ci-error{style: "display:none"}
       = icon("times-circle")
-      Could not connect to the CI server. Please check your settings and try again.
-
-  :javascript
-    $(function() {
-      merge_request_widget.getCIStatus(false);
-    });
+      Could not connect to the CI server. Please check your settings and try again.
\ No newline at end of file
diff --git a/app/views/projects/tags/new.html.haml b/app/views/projects/tags/new.html.haml
index b40a6e5cb2d3c1c297995c9f47ce84e36264b76f..f93064532974f551cd62c7b55f3e546c5d343ca4 100644
--- a/app/views/projects/tags/new.html.haml
+++ b/app/views/projects/tags/new.html.haml
@@ -23,7 +23,7 @@
   .form-group
     = label_tag :message, nil, class: 'control-label'
     .col-sm-10
-      = text_field_tag :message, nil, required: false, tabindex: 3, class: 'form-control'
+      = text_area_tag :message, nil, required: false, tabindex: 3, class: 'form-control', rows: 5
       .help-block Optionally, enter a message to create an annotated tag.
   %hr
   .form-group
diff --git a/app/views/projects/tags/show.html.haml b/app/views/projects/tags/show.html.haml
index 9c916fd02de7b53679dadeccee4135d457a67be7..9f1424aecc7bc9d8844a65ae329ff7431dca85d7 100644
--- a/app/views/projects/tags/show.html.haml
+++ b/app/views/projects/tags/show.html.haml
@@ -19,15 +19,13 @@
           %i.fa.fa-trash-o
   .title
     %span.item-title= @tag.name
-    - if @tag.message.present?
-      %span.light
-        &nbsp;
-        = strip_gpg_signature(@tag.message)
   - if @commit
     = render 'projects/branches/commit', commit: @commit, project: @project
   - else
     Cant find HEAD commit for this tag
-
+  - if @tag.message.present?
+    %pre.body
+      = strip_gpg_signature(@tag.message)
 
 .append-bottom-default.prepend-top-default
   - if @release.description.present?
diff --git a/config/gitlab.teatro.yml b/config/gitlab.teatro.yml
index f0656400beb00c2dc9fc82bc2be41235a9504340..01c8dc5ff98e2cd278ccea0a1146131a69958137 100644
--- a/config/gitlab.teatro.yml
+++ b/config/gitlab.teatro.yml
@@ -15,7 +15,6 @@ production: &base
       issues: true
       merge_requests: true
       wiki: true
-      wall: false
       snippets: false
       visibility_level: "private"  # can be "private" | "internal" | "public"
 
diff --git a/config/initializers/trusted_proxies.rb b/config/initializers/trusted_proxies.rb
index b8cc025bae2048b4bc85ceac0c284f10b18efae8..d256a16d42b803ba6274905a3d2272c388180ae0 100644
--- a/config/initializers/trusted_proxies.rb
+++ b/config/initializers/trusted_proxies.rb
@@ -1,2 +1,3 @@
-Rails.application.config.action_dispatch.trusted_proxies =
+Rails.application.config.action_dispatch.trusted_proxies = (
   [ '127.0.0.1', '::1' ] + Array(Gitlab.config.gitlab.trusted_proxies)
+).map { |proxy| IPAddr.new(proxy) }
diff --git a/db/migrate/20160508194200_remove_wall_enabled_from_projects.rb b/db/migrate/20160508194200_remove_wall_enabled_from_projects.rb
new file mode 100644
index 0000000000000000000000000000000000000000..aa560bc0f0cbb8b59c8dd03b0fbc9a3a1c8caf01
--- /dev/null
+++ b/db/migrate/20160508194200_remove_wall_enabled_from_projects.rb
@@ -0,0 +1,5 @@
+class RemoveWallEnabledFromProjects < ActiveRecord::Migration
+  def change
+    remove_column :projects, :wall_enabled, :boolean, default: true, null: false
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 7683aad968c112f7199834da1d241f311d3313c0..71d953afe30ab9c897b2dfffe2c6a00708edc29d 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 20160421130527) do
+ActiveRecord::Schema.define(version: 20160508194200) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -728,7 +728,6 @@ ActiveRecord::Schema.define(version: 20160421130527) do
     t.datetime "updated_at"
     t.integer  "creator_id"
     t.boolean  "issues_enabled",               default: true,     null: false
-    t.boolean  "wall_enabled",                 default: true,     null: false
     t.boolean  "merge_requests_enabled",       default: true,     null: false
     t.boolean  "wiki_enabled",                 default: true,     null: false
     t.integer  "namespace_id"
diff --git a/doc/api/build_triggers.md b/doc/api/build_triggers.md
index 4a12e962b620de174c84fc89b2862ec77299fd38..0881a7d7a90408b433c10c20dfcc34788bf3c3c2 100644
--- a/doc/api/build_triggers.md
+++ b/doc/api/build_triggers.md
@@ -101,8 +101,18 @@ DELETE /projects/:id/triggers/:token
 | Attribute | Type    | required | Description              |
 |-----------|---------|----------|--------------------------|
 | `id`      | integer | yes      | The ID of a project      |
-| `token`   | string  | yes      | The `token` of a project |
+| `token`   | string  | yes      | The `token` of a trigger |
 
 ```
 curl -X DELETE -H "PRIVATE_TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/triggers/7b9148c158980bbd9bcea92c17522d"
 ```
+
+```json
+{
+    "created_at": "2015-12-23T16:25:56.760Z",
+    "deleted_at": "2015-12-24T12:32:20.100Z",
+    "last_used": null,
+    "token": "7b9148c158980bbd9bcea92c17522d",
+    "updated_at": "2015-12-24T12:32:20.100Z"
+}
+```
diff --git a/doc/api/issues.md b/doc/api/issues.md
index 3e78149f442f9d16cc72d15427028e4f7c19e96b..fc7a7ae0c0ce4b1f11e13ee7cdc98fa75d37b0b9 100644
--- a/doc/api/issues.md
+++ b/doc/api/issues.md
@@ -77,7 +77,8 @@ Example response:
       "created_at" : "2016-01-04T15:31:51.081Z",
       "iid" : 6,
       "labels" : [],
-      "subscribed" : false
+      "subscribed" : false,
+      "user_notes_count": 1
    }
 ]
 ```
@@ -154,7 +155,8 @@ Example response:
       "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
       "updated_at" : "2016-01-04T15:31:46.176Z",
       "created_at" : "2016-01-04T15:31:46.176Z",
-      "subscribed" : false
+      "subscribed" : false,
+      "user_notes_count": 1
    }
 ]
 ```
@@ -216,7 +218,8 @@ Example response:
    "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
    "updated_at" : "2016-01-04T15:31:46.176Z",
    "created_at" : "2016-01-04T15:31:46.176Z",
-   "subscribed": false
+   "subscribed": false,
+   "user_notes_count": 1
 }
 ```
 
@@ -271,7 +274,8 @@ Example response:
    "description" : null,
    "updated_at" : "2016-01-07T12:44:33.959Z",
    "milestone" : null,
-   "subscribed" : true
+   "subscribed" : true,
+   "user_notes_count": 0
 }
 ```
 
@@ -329,7 +333,8 @@ Example response:
    "id" : 85,
    "assignee" : null,
    "milestone" : null,
-   "subscribed" : true
+   "subscribed" : true,
+   "user_notes_count": 0
 }
 ```
 
diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md
index 2057f9d77aa486cb155ac89b4e46ff52f0eccd37..8217e30fe256c83e27a28806c0018cb8be5cbe0c 100644
--- a/doc/api/merge_requests.md
+++ b/doc/api/merge_requests.md
@@ -67,7 +67,8 @@ Parameters:
     },
     "merge_when_build_succeeds": true,
     "merge_status": "can_be_merged",
-    "subscribed" : false
+    "subscribed" : false,
+    "user_notes_count": 1
   }
 ]
 ```
@@ -130,7 +131,8 @@ Parameters:
   },
   "merge_when_build_succeeds": true,
   "merge_status": "can_be_merged",
-  "subscribed" : true
+  "subscribed" : true,
+  "user_notes_count": 1
 }
 ```
 
@@ -230,6 +232,7 @@ Parameters:
   "merge_when_build_succeeds": true,
   "merge_status": "can_be_merged",
   "subscribed" : true,
+  "user_notes_count": 1,
   "changes": [
     {
     "old_path": "VERSION",
@@ -308,7 +311,8 @@ Parameters:
   },
   "merge_when_build_succeeds": true,
   "merge_status": "can_be_merged",
-  "subscribed" : true
+  "subscribed" : true,
+  "user_notes_count": 0
 }
 ```
 
@@ -378,7 +382,8 @@ Parameters:
   },
   "merge_when_build_succeeds": true,
   "merge_status": "can_be_merged",
-  "subscribed" : true
+  "subscribed" : true,
+  "user_notes_count": 1
 }
 ```
 
@@ -472,7 +477,8 @@ Parameters:
   },
   "merge_when_build_succeeds": true,
   "merge_status": "can_be_merged",
-  "subscribed" : true
+  "subscribed" : true,
+  "user_notes_count": 1
 }
 ```
 
@@ -537,7 +543,8 @@ Parameters:
   },
   "merge_when_build_succeeds": true,
   "merge_status": "can_be_merged",
-  "subscribed" : true
+  "subscribed" : true,
+  "user_notes_count": 1
 }
 ```
 
@@ -602,7 +609,8 @@ Example response:
       "title" : "Consequatur vero maxime deserunt laboriosam est voluptas dolorem.",
       "created_at" : "2016-01-04T15:31:51.081Z",
       "iid" : 6,
-      "labels" : []
+      "labels" : [],
+      "user_notes_count": 1
    },
 ]
 ```
diff --git a/doc/api/notes.md b/doc/api/notes.md
index a6b5b1787fdf90550afb4e934c82773a7220be57..7aa1c2155bfe8d5c2c2b5f30ffd0002ac71115a4 100644
--- a/doc/api/notes.md
+++ b/doc/api/notes.md
@@ -15,7 +15,7 @@ GET /projects/:id/issues/:issue_id/notes
 Parameters:
 
 - `id` (required) - The ID of a project
-- `issue_id` (required) - The IID of an issue (not ID)
+- `issue_id` (required) - The ID of an issue
 
 ```json
 [
@@ -73,7 +73,7 @@ GET /projects/:id/issues/:issue_id/notes/:note_id
 Parameters:
 
 - `id` (required) - The ID of a project
-- `issue_id` (required) - The IID of a project issue (not ID)
+- `issue_id` (required) - The ID of a project issue
 - `note_id` (required) - The ID of an issue note
 
 ### Create new issue note
@@ -87,7 +87,7 @@ POST /projects/:id/issues/:issue_id/notes
 Parameters:
 
 - `id` (required) - The ID of a project
-- `issue_id` (required) - The IID of an issue (not ID)
+- `issue_id` (required) - The ID of an issue
 - `body` (required) - The content of a note
 - `created_at` (optional) - Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z
 
@@ -102,7 +102,7 @@ PUT /projects/:id/issues/:issue_id/notes/:note_id
 Parameters:
 
 - `id` (required) - The ID of a project
-- `issue_id` (required) - The IID of an issue (not ID)
+- `issue_id` (required) - The ID of an issue
 - `note_id` (required) - The ID of a note
 - `body` (required) - The content of a note
 
@@ -120,7 +120,7 @@ Parameters:
 | Attribute | Type | Required | Description |
 | --------- | ---- | -------- | ----------- |
 | `id` | integer | yes | The ID of a project |
-| `issue_id` | integer | yes | The IID of an issue |
+| `issue_id` | integer | yes | The ID of an issue |
 | `note_id` | integer | yes | The ID of a note |
 
 ```bash
diff --git a/doc/development/instrumentation.md b/doc/development/instrumentation.md
index c1cf2e77c2689ec05187499af6a2750d56eae848..9168c70945aafb1575e9dbe833c20cf3eead896e 100644
--- a/doc/development/instrumentation.md
+++ b/doc/development/instrumentation.md
@@ -1,12 +1,125 @@
 # Instrumenting Ruby Code
 
-GitLab Performance Monitoring allows instrumenting of custom blocks of Ruby
-code. This can be used to measure the time spent in a specific part of a larger
-chunk of code. The resulting data is stored as a field in the transaction that
-executed the block.
+GitLab Performance Monitoring allows instrumenting of both methods and custom
+blocks of Ruby code. Method instrumentation is the primary form of
+instrumentation with block-based instrumentation only being used when we want to
+drill down to specific regions of code within a method.
 
-To start measuring a block of Ruby code you should use `Gitlab::Metrics.measure`
-and give it a name:
+## Instrumenting Methods
+
+Instrumenting methods is done by using the `Gitlab::Metrics::Instrumentation`
+module. This module offers a few different methods that can be used to
+instrument code:
+
+* `instrument_method`: instruments a single class method.
+* `instrument_instance_method`: instruments a single instance method.
+* `instrument_class_hierarchy`: given a Class this method will recursively
+  instrument all sub-classes (both class and instance methods).
+* `instrument_methods`: instruments all public class methods of a Module.
+* `instrument_instance_methods`: instruments all public instance methods of a
+  Module.
+
+To remove the need for typing the full `Gitlab::Metrics::Instrumentation`
+namespace you can use the `configure` class method. This method simply yields
+the supplied block while passing `Gitlab::Metrics::Instrumentation` as its
+argument. An example:
+
+```
+Gitlab::Metrics::Instrumentation.configure do |conf|
+  conf.instrument_method(Foo, :bar)
+  conf.instrument_method(Foo, :baz)
+end
+```
+
+Using this method is in general preferred over directly calling the various
+instrumentation methods.
+
+Method instrumentation should be added in the initializer
+`config/initializers/metrics.rb`.
+
+### Examples
+
+Instrumenting a single method:
+
+```
+Gitlab::Metrics::Instrumentation.configure do |conf|
+  conf.instrument_method(User, :find_by)
+end
+```
+
+Instrumenting an entire class hierarchy:
+
+```
+Gitlab::Metrics::Instrumentation.configure do |conf|
+  conf.instrument_class_hierarchy(ActiveRecord::Base)
+end
+```
+
+Instrumenting all public class methods:
+
+```
+Gitlab::Metrics::Instrumentation.configure do |conf|
+  conf.instrument_methods(User)
+end
+```
+
+### Checking Instrumented Methods
+
+The easiest way to check if a method has been instrumented is to check its
+source location. For example:
+
+```
+method = Rugged::TagCollection.instance_method(:[])
+
+method.source_location
+```
+
+If the source location points to `lib/gitlab/metrics/instrumentation.rb` you
+know the method has been instrumented.
+
+If you're using Pry you can use the `$` command to display the source code of a
+method (along with its source location), this is easier than running the above
+Ruby code. In case of the above snippet you'd run the following:
+
+```
+$ Rugged::TagCollection#[]
+```
+
+This will print out something along the lines of:
+
+```
+From: /path/to/your/gitlab/lib/gitlab/metrics/instrumentation.rb @ line 148:
+Owner: #<Module:0x0055f0865c6d50>
+Visibility: public
+Number of lines: 21
+
+def #{name}(#{args_signature})
+  trans = Gitlab::Metrics::Instrumentation.transaction
+
+  if trans
+    start    = Time.now
+    retval   = super
+    duration = (Time.now - start) * 1000.0
+
+    if duration >= Gitlab::Metrics.method_call_threshold
+      trans.increment(:method_duration, duration)
+
+      trans.add_metric(Gitlab::Metrics::Instrumentation::SERIES,
+                       { duration: duration },
+                       method: #{label.inspect})
+    end
+
+    retval
+  else
+    super
+  end
+end
+```
+
+## Instrumenting Ruby Blocks
+
+Measuring blocks of Ruby code is done by calling `Gitlab::Metrics.measure` and
+passing it a block. For example:
 
 ```ruby
 Gitlab::Metrics.measure(:foo) do
@@ -14,6 +127,10 @@ Gitlab::Metrics.measure(:foo) do
 end
 ```
 
+The block is executed and the execution time is stored as a set of fields in the
+currently running transaction. If no transaction is present the block is yielded
+without measuring anything.
+
 3 values are measured for a block:
 
 1. The real time elapsed, stored in NAME_real_time.
diff --git a/doc/workflow/lfs/manage_large_binaries_with_git_lfs.md b/doc/workflow/lfs/manage_large_binaries_with_git_lfs.md
index 31620044b1501d486989bedbdc255e7c844d32bf..83db44c10b1797709e83a912bed1c8ef01918f99 100644
--- a/doc/workflow/lfs/manage_large_binaries_with_git_lfs.md
+++ b/doc/workflow/lfs/manage_large_binaries_with_git_lfs.md
@@ -152,4 +152,4 @@ If you are using OS X you can use `osxkeychain` to store and encrypt your creden
 For Windows, you can use `wincred` or Microsoft's [Git Credential Manager for Windows](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases).
 
 More details about various methods of storing the user credentials can be found
-on [Git Credential Storage documentation](https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage).
\ No newline at end of file
+on [Git Credential Storage documentation](https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage).
diff --git a/features/project/commits/tags.feature b/features/project/commits/tags.feature
deleted file mode 100644
index a4be39b2d40899542487794da6c94682a154d203..0000000000000000000000000000000000000000
--- a/features/project/commits/tags.feature
+++ /dev/null
@@ -1,46 +0,0 @@
-@project_commits
-Feature: Project Commits Tags
-  Background:
-    Given I sign in as a user
-    And I own project "Shop"
-    Given I visit project tags page
-
-  Scenario: I can see all git tags
-    Then I should see "Shop" all tags list
-
-  Scenario: I create a tag
-    And I click new tag link
-    And I submit new tag form
-    Then I should see new tag created
-
-  Scenario: I create a tag with release notes
-    Given I click new tag link
-    And I submit new tag form with release notes
-    Then I should see new tag created
-    And I should see tag release notes
-
-  Scenario: I create a tag with invalid name
-    And I click new tag link
-    And I submit new tag form with invalid name
-    Then I should see new an error that tag is invalid
-
-  Scenario: I create a tag with invalid reference
-    And I click new tag link
-    And I submit new tag form with invalid reference
-    Then I should see new an error that tag ref is invalid
-
-  Scenario: I create a tag that already exists
-    And I click new tag link
-    And I submit new tag form with tag that already exists
-    Then I should see new an error that tag already exists
-
-  Scenario: I delete a tag
-    Given I visit tag 'v1.1.0' page
-    Given I delete tag 'v1.1.0'
-    Then I should not see tag 'v1.1.0'
-
-  Scenario: I add release notes to the tag
-    Given I visit tag 'v1.1.0' page
-    When I click edit tag link
-    And I fill release notes and submit form
-    Then I should see tag release notes
diff --git a/features/project/create.feature b/features/project/create.feature
index 27136798e36d14f9b2b55a306f8b8bc30b189297..67336d73bf729a94699cd4ccdf6de0857815ca28 100644
--- a/features/project/create.feature
+++ b/features/project/create.feature
@@ -6,21 +6,9 @@ Feature: Project Create
 
   @javascript
   Scenario: User create a project
-    Given I sign in as a user
-    When I visit new project page
-    And I have an ssh key
-    And fill project form with valid data
-    Then I should see project page
-    And I should see empty project instuctions
-
-  @javascript
-  Scenario: Empty project instructions
     Given I sign in as a user
     And I have an ssh key
     When I visit new project page
     And fill project form with valid data
-    Then I see empty project instuctions
-    And I click on HTTP
-    Then Remote url should update to http link
-    And If I click on SSH
-    Then Remote url should update to ssh link
+    Then I should see project page
+    And I should see empty project instructions
diff --git a/features/steps/project/commits/tags.rb b/features/steps/project/commits/tags.rb
deleted file mode 100644
index 912ba580efd7a334d314f3b490d2d0b1a76ad419..0000000000000000000000000000000000000000
--- a/features/steps/project/commits/tags.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-class Spinach::Features::ProjectCommitsTags < Spinach::FeatureSteps
-  include SharedAuthentication
-  include SharedProject
-  include SharedPaths
-
-  step 'I should see "Shop" all tags list' do
-    expect(page).to have_content "Tags"
-    expect(page).to have_content "v1.0.0"
-  end
-
-  step 'I click new tag link' do
-    click_link 'New tag'
-  end
-
-  step 'I submit new tag form' do
-    fill_in 'tag_name', with: 'v7.0'
-    fill_in 'ref', with: 'master'
-    click_button 'Create tag'
-  end
-
-  step 'I submit new tag form with release notes' do
-    fill_in 'tag_name', with: 'v7.0'
-    fill_in 'ref', with: 'master'
-    fill_in 'release_description', with: 'Awesome release notes'
-    click_button 'Create tag'
-  end
-
-  step 'I fill release notes and submit form' do
-    fill_in 'release_description', with: 'Awesome release notes'
-    click_button 'Save changes'
-  end
-
-  step 'I submit new tag form with invalid name' do
-    fill_in 'tag_name', with: 'v 1.0'
-    fill_in 'ref', with: 'master'
-    click_button 'Create tag'
-  end
-
-  step 'I submit new tag form with invalid reference' do
-    fill_in 'tag_name', with: 'foo'
-    fill_in 'ref', with: 'foo'
-    click_button 'Create tag'
-  end
-
-  step 'I submit new tag form with tag that already exists' do
-    fill_in 'tag_name', with: 'v1.0.0'
-    fill_in 'ref', with: 'master'
-    click_button 'Create tag'
-  end
-
-  step 'I should see new tag created' do
-    expect(page).to have_content 'v7.0'
-  end
-
-  step 'I should see new an error that tag is invalid' do
-    expect(page).to have_content 'Tag name invalid'
-  end
-
-  step 'I should see new an error that tag ref is invalid' do
-    expect(page).to have_content 'Target foo is invalid'
-  end
-
-  step 'I should see new an error that tag already exists' do
-    expect(page).to have_content 'Tag v1.0.0 already exists'
-  end
-
-  step "I visit tag 'v1.1.0' page" do
-    click_link 'v1.1.0'
-  end
-
-  step "I delete tag 'v1.1.0'" do
-    page.within('.content') do
-      first('.btn-remove').click
-    end
-  end
-
-  step "I should not see tag 'v1.1.0'" do
-    page.within '.tags' do
-      expect(page).not_to have_link 'v1.1.0'
-    end
-  end
-
-  step 'I click edit tag link' do
-    click_link 'Edit release notes'
-  end
-
-  step 'I should see tag release notes' do
-    expect(page).to have_content 'Awesome release notes'
-  end
-end
diff --git a/features/steps/project/create.rb b/features/steps/project/create.rb
index 422b151eaa241829b9bffbe199a001c55f1775a5..5f5f806df36c8c9cb05a9b750d1a24c30bf837f1 100644
--- a/features/steps/project/create.rb
+++ b/features/steps/project/create.rb
@@ -13,33 +13,9 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps
     expect(current_path).to eq namespace_project_path(Project.last.namespace, Project.last)
   end
 
-  step 'I should see empty project instuctions' do
+  step 'I should see empty project instructions' do
     expect(page).to have_content "git init"
     expect(page).to have_content "git remote"
     expect(page).to have_content Project.last.url_to_repo
   end
-
-  step 'I see empty project instuctions' do
-    expect(page).to have_content "git init"
-    expect(page).to have_content "git remote"
-    expect(page).to have_content Project.last.url_to_repo
-  end
-
-  step 'I click on HTTP' do
-    find('#clone-dropdown').click
-    find('.http-selector').click
-  end
-
-  step 'Remote url should update to http link' do
-    expect(page).to have_content "git remote add origin #{Project.last.http_url_to_repo}"
-  end
-
-  step 'If I click on SSH' do
-    find('#clone-dropdown').click
-    find('.ssh-selector').click
-  end
-
-  step 'Remote url should update to ssh link' do
-    expect(page).to have_content "git remote add origin #{Project.last.url_to_repo}"
-  end
 end
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 716ca6f7ed9a0db7a7636b3651ca498591ef4ba4..2870a6a40ef7f4bc9ed5026c6d76cf68a911d56e 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -170,10 +170,10 @@ module API
       expose :label_names, as: :labels
       expose :milestone, using: Entities::Milestone
       expose :assignee, :author, using: Entities::UserBasic
-
       expose :subscribed do |issue, options|
         issue.subscribed?(options[:current_user])
       end
+      expose :user_notes_count
     end
 
     class MergeRequest < ProjectEntity
@@ -187,10 +187,10 @@ module API
       expose :milestone, using: Entities::Milestone
       expose :merge_when_build_succeeds
       expose :merge_status
-
       expose :subscribed do |merge_request, options|
         merge_request.subscribed?(options[:current_user])
       end
+      expose :user_notes_count
     end
 
     class MergeRequestChanges < MergeRequest
diff --git a/lib/banzai/filter/issue_reference_filter.rb b/lib/banzai/filter/issue_reference_filter.rb
index 2732e0b51455cadfebabf4b936fbf319e854f19c..59c5e89c5466e5f054e58e0f00124d0cfb435235 100644
--- a/lib/banzai/filter/issue_reference_filter.rb
+++ b/lib/banzai/filter/issue_reference_filter.rb
@@ -10,6 +10,9 @@ module Banzai
       end
 
       def self.user_can_see_reference?(user, node, context)
+        # It is not possible to check access rights for external issue trackers
+        return true if context[:project].try(:external_issue_tracker)
+ 
         issue = Issue.find(node.attr('data-issue')) rescue nil
         Ability.abilities.allowed?(user, :read_issue, issue)
       end
diff --git a/lib/banzai/filter/sanitization_filter.rb b/lib/banzai/filter/sanitization_filter.rb
index 42dbab9d27e97d1a6067ceea3eb3acb6b5bb726e..ca80aac5a0894c810f5a0852cc43d05a125d9b65 100644
--- a/lib/banzai/filter/sanitization_filter.rb
+++ b/lib/banzai/filter/sanitization_filter.rb
@@ -63,7 +63,7 @@ module Banzai
 
           begin
             uri = Addressable::URI.parse(node['href'])
-            uri.scheme.strip! if uri.scheme
+            uri.scheme = uri.scheme.strip.downcase if uri.scheme
 
             node.remove_attribute('href') if UNSAFE_PROTOCOLS.include?(uri.scheme)
           rescue Addressable::URI::InvalidURIError
diff --git a/lib/banzai/filter/upload_link_filter.rb b/lib/banzai/filter/upload_link_filter.rb
index 7edfe5ade2dae2601659a3b80086b64c413a9084..c0f503c9af3a859153d94da6a70fd8570d18da38 100644
--- a/lib/banzai/filter/upload_link_filter.rb
+++ b/lib/banzai/filter/upload_link_filter.rb
@@ -8,6 +8,8 @@ module Banzai
     #
     class UploadLinkFilter < HTML::Pipeline::Filter
       def call
+        return doc unless project
+
         doc.search('a').each do |el|
           process_link_attr el.attribute('href')
         end
@@ -31,7 +33,11 @@ module Banzai
       end
 
       def build_url(uri)
-        File.join(Gitlab.config.gitlab.url, context[:project].path_with_namespace, uri)
+        File.join(Gitlab.config.gitlab.url, project.path_with_namespace, uri)
+      end
+
+      def project
+        context[:project]
       end
 
       # Ensure that a :project key exists in context
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index 6cb4123987151b56020fed7f3e7c7f953bc5c843..d2a0e316cbe65ee9ae7ab0ce36b4e24d6e940a92 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -122,6 +122,11 @@ module Gitlab
       build_status_object(true)
     end
 
+    def can_user_do_action?(action)
+      @permission_cache ||= {}
+      @permission_cache[action] ||= user.can?(action, project)
+    end
+
     def change_access_check(change)
       oldrev, newrev, ref = change.split(' ')
 
@@ -135,7 +140,7 @@ module Gitlab
           :push_code
         end
 
-      unless user.can?(action, project)
+      unless can_user_do_action?(action)
         status =
           case action
           when :force_push_code_to_protected_branches
diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake
deleted file mode 100644
index 16bad4bd2bdcf895aed941a574521200b659b38a..0000000000000000000000000000000000000000
--- a/lib/tasks/auto_annotate_models.rake
+++ /dev/null
@@ -1,44 +0,0 @@
-if Rails.env.development?
-  task :set_annotation_options do
-    # You can override any of these by setting an environment variable of the
-    # same name.
-    Annotate.set_defaults(
-      'routes'                  => 'false',
-      'position_in_routes'      => 'before',
-      'position_in_class'       => 'before',
-      'position_in_test'        => 'before',
-      'position_in_fixture'     => 'before',
-      'position_in_factory'     => 'before',
-      'position_in_serializer'  => 'before',
-      'show_foreign_keys'       => 'true',
-      'show_indexes'            => 'false',
-      'simple_indexes'          => 'false',
-      'model_dir'               => 'app/models',
-      'root_dir'                => '',
-      'include_version'         => 'false',
-      'require'                 => '',
-      'exclude_tests'           => 'true',
-      'exclude_fixtures'        => 'true',
-      'exclude_factories'       => 'true',
-      'exclude_serializers'     => 'true',
-      'exclude_scaffolds'       => 'true',
-      'exclude_controllers'     => 'true',
-      'exclude_helpers'         => 'true',
-      'ignore_model_sub_dir'    => 'false',
-      'ignore_columns'          => nil,
-      'ignore_unknown_models'   => 'false',
-      'hide_limit_column_types' => 'integer,boolean',
-      'skip_on_db_migrate'      => 'false',
-      'format_bare'             => 'true',
-      'format_rdoc'             => 'false',
-      'format_markdown'         => 'false',
-      'sort'                    => 'false',
-      'force'                   => 'false',
-      'trace'                   => 'false',
-      'wrapper_open'            => nil,
-      'wrapper_close'           => nil,
-    )
-  end
-
-  Annotate.load_tasks
-end
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index 1c706dc11b33ece40c46f0ca618e9b042da2a93d..e473b7560234f0b626c5699b4ffe720379632bf7 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -29,10 +29,12 @@ namespace :gitlab do
       tables.delete 'schema_migrations'
       # Truncate schema_migrations to ensure migrations re-run
       connection.execute('TRUNCATE schema_migrations')
+
       # Drop tables with cascade to avoid dependent table errors
       # PG: http://www.postgresql.org/docs/current/static/ddl-depend.html
       # MySQL: http://dev.mysql.com/doc/refman/5.7/en/drop-table.html
-      tables.each { |t| connection.execute("DROP TABLE #{t} CASCADE") }
+      # Add `IF EXISTS` because cascade could have already deleted a table.
+      tables.each { |t| connection.execute("DROP TABLE IF EXISTS #{t} CASCADE") }
     end
   end
 end
diff --git a/spec/factories/abuse_reports.rb b/spec/factories/abuse_reports.rb
index d0e8c778518334eb0c826346d956959a420f48af..8f6422a7825e00d726db935fc96b9cf59ea5722f 100644
--- a/spec/factories/abuse_reports.rb
+++ b/spec/factories/abuse_reports.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: abuse_reports
-#
-#  id          :integer          not null, primary key
-#  reporter_id :integer
-#  user_id     :integer
-#  message     :text
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 FactoryGirl.define do
   factory :abuse_report do
     reporter factory: :user
diff --git a/spec/factories/broadcast_messages.rb b/spec/factories/broadcast_messages.rb
index c80e736655198165f1cb300b3161322593df201c..efe9803b1a7159fc40debcb74442d7b51880fa17 100644
--- a/spec/factories/broadcast_messages.rb
+++ b/spec/factories/broadcast_messages.rb
@@ -1,17 +1,3 @@
-# == Schema Information
-#
-# Table name: broadcast_messages
-#
-#  id         :integer          not null, primary key
-#  message    :text             not null
-#  starts_at  :datetime
-#  ends_at    :datetime
-#  created_at :datetime
-#  updated_at :datetime
-#  color      :string(255)
-#  font       :string(255)
-#
-
 FactoryGirl.define do
   factory :broadcast_message do
     message "MyText"
diff --git a/spec/factories/forked_project_links.rb b/spec/factories/forked_project_links.rb
index 19a54946fe0ea93f3a7140bc4501dac3a452fa91..b16c1272e6833d1d8260b7c33bbf00aac52949e2 100644
--- a/spec/factories/forked_project_links.rb
+++ b/spec/factories/forked_project_links.rb
@@ -1,14 +1,3 @@
-# == Schema Information
-#
-# Table name: forked_project_links
-#
-#  id                     :integer          not null, primary key
-#  forked_to_project_id   :integer          not null
-#  forked_from_project_id :integer          not null
-#  created_at             :datetime
-#  updated_at             :datetime
-#
-
 FactoryGirl.define do
   factory :forked_project_link do
     association :forked_to_project, factory: :project
diff --git a/spec/factories/label_links.rb b/spec/factories/label_links.rb
index 2939d4307c5700d59471c975758835584ebd20a4..3580174e873f55b91de69dea81272044494a88d4 100644
--- a/spec/factories/label_links.rb
+++ b/spec/factories/label_links.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: label_links
-#
-#  id          :integer          not null, primary key
-#  label_id    :integer
-#  target_id   :integer
-#  target_type :string(255)
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 FactoryGirl.define do
   factory :label_link do
     label
diff --git a/spec/factories/labels.rb b/spec/factories/labels.rb
index ea2be8928d5bf3f54c7b3acd817146ee64462dce..eb489099854d719e3752cf6e47701e3fc66f3ce2 100644
--- a/spec/factories/labels.rb
+++ b/spec/factories/labels.rb
@@ -1,16 +1,3 @@
-# == Schema Information
-#
-# Table name: labels
-#
-#  id         :integer          not null, primary key
-#  title      :string(255)
-#  color      :string(255)
-#  project_id :integer
-#  created_at :datetime
-#  updated_at :datetime
-#  template   :boolean          default(FALSE)
-#
-
 FactoryGirl.define do
   factory :label do
     sequence(:title) { |n| "label#{n}" }
diff --git a/spec/factories/lfs_objects.rb b/spec/factories/lfs_objects.rb
index 327858ce435db353113cfa353e91904a054c0ff1..a81645acd2b86814489de798a3c2d9fb8534a52a 100644
--- a/spec/factories/lfs_objects.rb
+++ b/spec/factories/lfs_objects.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: lfs_objects
-#
-#  id         :integer          not null, primary key
-#  oid        :string(255)      not null
-#  size       :integer          not null
-#  created_at :datetime
-#  updated_at :datetime
-#  file       :string(255)
-#
-
 include ActionDispatch::TestProcess
 
 FactoryGirl.define do
diff --git a/spec/factories/lfs_objects_projects.rb b/spec/factories/lfs_objects_projects.rb
index 50b45843c9910d613d31523db051fb1a2769b4df..1ed0355c8e4fcba1a2fd278ecba40a2c93eb41bf 100644
--- a/spec/factories/lfs_objects_projects.rb
+++ b/spec/factories/lfs_objects_projects.rb
@@ -1,14 +1,3 @@
-# == Schema Information
-#
-# Table name: lfs_objects_projects
-#
-#  id            :integer          not null, primary key
-#  lfs_object_id :integer          not null
-#  project_id    :integer          not null
-#  created_at    :datetime
-#  updated_at    :datetime
-#
-
 FactoryGirl.define do
   factory :lfs_objects_project do
     lfs_object
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb
index e281e2f227b6cb0ddcf487d19bf35af5c3907c3f..c6a08d78b78f6242a27c1353cecedf8994feaafa 100644
--- a/spec/factories/merge_requests.rb
+++ b/spec/factories/merge_requests.rb
@@ -1,32 +1,3 @@
-# == Schema Information
-#
-# Table name: merge_requests
-#
-#  id                        :integer          not null, primary key
-#  target_branch             :string(255)      not null
-#  source_branch             :string(255)      not null
-#  source_project_id         :integer          not null
-#  author_id                 :integer
-#  assignee_id               :integer
-#  title                     :string(255)
-#  created_at                :datetime
-#  updated_at                :datetime
-#  milestone_id              :integer
-#  state                     :string(255)
-#  merge_status              :string(255)
-#  target_project_id         :integer          not null
-#  iid                       :integer
-#  description               :text
-#  position                  :integer          default(0)
-#  locked_at                 :datetime
-#  updated_by_id             :integer
-#  merge_error               :string(255)
-#  merge_params              :text
-#  merge_when_build_succeeds :boolean          default(FALSE), not null
-#  merge_user_id             :integer
-#  merge_commit_sha          :string
-#
-
 FactoryGirl.define do
   factory :merge_request do
     title
diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb
index e5dcb15901419e1528de25ec70e25f79b14fc8d5..840b13196a674a504ff8b1f8145c95e4c897ac5a 100644
--- a/spec/factories/notes.rb
+++ b/spec/factories/notes.rb
@@ -1,24 +1,3 @@
-# == Schema Information
-#
-# Table name: notes
-#
-#  id            :integer          not null, primary key
-#  note          :text
-#  noteable_type :string(255)
-#  author_id     :integer
-#  created_at    :datetime
-#  updated_at    :datetime
-#  project_id    :integer
-#  attachment    :string(255)
-#  line_code     :string(255)
-#  commit_id     :string(255)
-#  noteable_id   :integer
-#  system        :boolean          default(FALSE), not null
-#  st_diff       :text
-#  updated_by_id :integer
-#  is_award      :boolean          default(FALSE), not null
-#
-
 require_relative '../support/repo_helpers'
 
 include ActionDispatch::TestProcess
diff --git a/spec/factories/oauth_access_tokens.rb b/spec/factories/oauth_access_tokens.rb
index 7700b15d538199fb70ba6b06fda67b40d22aff27..ccf02d0719b1f4ae43d34f420c26901d6f4647cf 100644
--- a/spec/factories/oauth_access_tokens.rb
+++ b/spec/factories/oauth_access_tokens.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: oauth_access_tokens
-#
-#  id                :integer          not null, primary key
-#  resource_owner_id :integer
-#  application_id    :integer
-#  token             :string           not null
-#  refresh_token     :string
-#  expires_in        :integer
-#  revoked_at        :datetime
-#  created_at        :datetime         not null
-#  scopes            :string
-#
-
 FactoryGirl.define do
   factory :oauth_access_token do
     resource_owner
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index c14b99606baa5a3cc68c7832413d1381125b552a..da8d97c9f82c27f0a429833be294e4de1dc8e2ae 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -1,43 +1,3 @@
-# == Schema Information
-#
-# Table name: projects
-#
-#  id                     :integer          not null, primary key
-#  name                   :string(255)
-#  path                   :string(255)
-#  description            :text
-#  created_at             :datetime
-#  updated_at             :datetime
-#  creator_id             :integer
-#  issues_enabled         :boolean          default(TRUE), not null
-#  wall_enabled           :boolean          default(TRUE), not null
-#  merge_requests_enabled :boolean          default(TRUE), not null
-#  wiki_enabled           :boolean          default(TRUE), not null
-#  namespace_id           :integer
-#  issues_tracker         :string(255)      default("gitlab"), not null
-#  issues_tracker_id      :string(255)
-#  snippets_enabled       :boolean          default(TRUE), not null
-#  last_activity_at       :datetime
-#  import_url             :string(255)
-#  visibility_level       :integer          default(0), not null
-#  archived               :boolean          default(FALSE), not null
-#  avatar                 :string(255)
-#  import_status          :string(255)
-#  repository_size        :float            default(0.0)
-#  star_count             :integer          default(0), not null
-#  import_type            :string(255)
-#  import_source          :string(255)
-#  commit_count           :integer          default(0)
-#  import_error           :text
-#  ci_id                  :integer
-#  builds_enabled         :boolean          default(TRUE), not null
-#  shared_runners_enabled :boolean          default(TRUE), not null
-#  runners_token          :string
-#  build_coverage_regex   :string
-#  build_allow_git_fetch  :boolean          default(TRUE), not null
-#  build_timeout          :integer          default(3600), not null
-#
-
 FactoryGirl.define do
   # Project without repository
   #
@@ -61,6 +21,12 @@ FactoryGirl.define do
     trait :private do
       visibility_level Gitlab::VisibilityLevel::PRIVATE
     end
+
+    trait :empty_repo do
+      after(:create) do |project|
+        project.create_repository
+      end
+    end
   end
 
   # Project with empty repository
@@ -68,9 +34,7 @@ FactoryGirl.define do
   # This is a case when you just created a project
   # but not pushed any code there yet
   factory :project_empty_repo, parent: :empty_project do
-    after :create do |project|
-      project.create_repository
-    end
+    empty_repo
   end
 
   # Project with test repository
diff --git a/spec/factories/releases.rb b/spec/factories/releases.rb
index 7f331c37256aad9e1cccf04497f497dcf786b6e6..74497dc82c030bb3744ef144784910c767b8609c 100644
--- a/spec/factories/releases.rb
+++ b/spec/factories/releases.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: releases
-#
-#  id          :integer          not null, primary key
-#  tag         :string(255)
-#  description :text
-#  project_id  :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 FactoryGirl.define do
   factory :release do
     tag "v1.1.0"
diff --git a/spec/factories/todos.rb b/spec/factories/todos.rb
index 7ae06c278408caae9fd352c6db57df80086a2bd7..e3681ae93a5d725a19d96bb59233290df8b1addc 100644
--- a/spec/factories/todos.rb
+++ b/spec/factories/todos.rb
@@ -1,21 +1,3 @@
-# == Schema Information
-#
-# Table name: todos
-#
-#  id          :integer          not null, primary key
-#  user_id     :integer          not null
-#  project_id  :integer          not null
-#  target_id   :integer
-#  target_type :string           not null
-#  author_id   :integer
-#  action      :integer          not null
-#  state       :string           not null
-#  created_at  :datetime
-#  updated_at  :datetime
-#  note_id     :integer
-#  commit_id   :string
-#
-
 FactoryGirl.define do
   factory :todo do
     project
diff --git a/spec/features/projects/developer_views_empty_project_instructions_spec.rb b/spec/features/projects/developer_views_empty_project_instructions_spec.rb
new file mode 100644
index 0000000000000000000000000000000000000000..0c51fe72ca4e4b97a6c77f65038c9c60ab64f2dd
--- /dev/null
+++ b/spec/features/projects/developer_views_empty_project_instructions_spec.rb
@@ -0,0 +1,63 @@
+require 'rails_helper'
+
+feature 'Developer views empty project instructions', feature: true do
+  let(:project) { create(:empty_project, :empty_repo) }
+  let(:developer) { create(:user) }
+
+  background do
+    project.team << [developer, :developer]
+
+    login_as(developer)
+  end
+
+  context 'without an SSH key' do
+    scenario 'defaults to HTTP' do
+      visit_project
+
+      expect_instructions_for('http')
+    end
+
+    scenario 'switches to SSH', js: true do
+      visit_project
+
+      select_protocol('SSH')
+
+      expect_instructions_for('ssh')
+    end
+  end
+
+  context 'with an SSH key' do
+    background do
+      create(:personal_key, user: developer)
+    end
+
+    scenario 'defaults to SSH' do
+      visit_project
+
+      expect_instructions_for('ssh')
+    end
+
+    scenario 'switches to HTTP', js: true do
+      visit_project
+
+      select_protocol('HTTP')
+
+      expect_instructions_for('http')
+    end
+  end
+
+  def visit_project
+    visit namespace_project_path(project.namespace, project)
+  end
+
+  def select_protocol(protocol)
+    find('#clone-dropdown').click
+    find(".#{protocol.downcase}-selector").click
+  end
+
+  def expect_instructions_for(protocol)
+    msg = :"#{protocol.downcase}_url_to_repo"
+
+    expect(page).to have_content("git clone #{project.send(msg)}")
+  end
+end
diff --git a/spec/features/tags/master_creates_tag_spec.rb b/spec/features/tags/master_creates_tag_spec.rb
new file mode 100644
index 0000000000000000000000000000000000000000..08a97085a9c9e566befca9fdacc9196015fdf3d6
--- /dev/null
+++ b/spec/features/tags/master_creates_tag_spec.rb
@@ -0,0 +1,62 @@
+require 'spec_helper'
+
+feature 'Master creates tag', feature: true do
+  let(:user) { create(:user) }
+  let(:project) { create(:project, namespace: user.namespace) }
+
+  before do
+    project.team << [user, :master]
+    login_with(user)
+    visit namespace_project_tags_path(project.namespace, project)
+  end
+
+  scenario 'with an invalid name displays an error' do
+    create_tag_in_form(tag: 'v 1.0', ref: 'master')
+
+    expect(page).to have_content 'Tag name invalid'
+  end
+
+  scenario 'with an invalid reference displays an error' do
+    create_tag_in_form(tag: 'v2.0', ref: 'foo')
+
+    expect(page).to have_content 'Target foo is invalid'
+  end
+
+  scenario 'that already exists displays an error' do
+    create_tag_in_form(tag: 'v1.1.0', ref: 'master')
+
+    expect(page).to have_content 'Tag v1.1.0 already exists'
+  end
+
+  scenario 'with multiline message displays the message in a <pre> block' do
+    create_tag_in_form(tag: 'v3.0', ref: 'master', message: "Awesome tag message\n\n- hello\n- world")
+
+    expect(current_path).to eq(
+      namespace_project_tag_path(project.namespace, project, 'v3.0'))
+    expect(page).to have_content 'v3.0'
+    page.within 'pre.body' do
+      expect(page).to have_content "Awesome tag message\n\n- hello\n- world"
+    end
+  end
+
+  scenario 'with multiline release notes parses the release note as Markdown' do
+    create_tag_in_form(tag: 'v4.0', ref: 'master', desc: "Awesome release notes\n\n- hello\n- world")
+
+    expect(current_path).to eq(
+      namespace_project_tag_path(project.namespace, project, 'v4.0'))
+    expect(page).to have_content 'v4.0'
+    page.within '.description' do
+      expect(page).to have_content 'Awesome release notes'
+      expect(page).to have_selector('ul li', count: 2)
+    end
+  end
+
+  def create_tag_in_form(tag:, ref:, message: nil, desc: nil)
+    click_link 'New tag'
+    fill_in 'tag_name', with: tag
+    fill_in 'ref', with: ref
+    fill_in 'message', with: message unless message.nil?
+    fill_in 'release_description', with: desc unless desc.nil?
+    click_button 'Create tag'
+  end
+end
diff --git a/spec/features/tags/master_deletes_tag_spec.rb b/spec/features/tags/master_deletes_tag_spec.rb
new file mode 100644
index 0000000000000000000000000000000000000000..f0990118e3c04ab46cc3e101522690303610e6fc
--- /dev/null
+++ b/spec/features/tags/master_deletes_tag_spec.rb
@@ -0,0 +1,41 @@
+require 'spec_helper'
+
+feature 'Master deletes tag', feature: true do
+  let(:user) { create(:user) }
+  let(:project) { create(:project, namespace: user.namespace) }
+
+  before do
+    project.team << [user, :master]
+    login_with(user)
+    visit namespace_project_tags_path(project.namespace, project)
+  end
+
+  context 'from the tags list page' do
+    scenario 'deletes the tag' do
+      expect(page).to have_content 'v1.1.0'
+
+      page.within('.content') do
+        first('.btn-remove').click
+      end
+
+      expect(current_path).to eq(
+        namespace_project_tags_path(project.namespace, project))
+      expect(page).not_to have_content 'v1.1.0'
+    end
+
+  end
+
+  context 'from a specific tag page' do
+    scenario 'deletes the tag' do
+      click_on 'v1.0.0'
+      expect(current_path).to eq(
+        namespace_project_tag_path(project.namespace, project, 'v1.0.0'))
+
+      click_on 'Delete tag'
+
+      expect(current_path).to eq(
+        namespace_project_tags_path(project.namespace, project))
+      expect(page).not_to have_content 'v1.0.0'
+    end
+  end
+end
diff --git a/spec/features/tags/master_updates_tag_spec.rb b/spec/features/tags/master_updates_tag_spec.rb
new file mode 100644
index 0000000000000000000000000000000000000000..c926e9841f31f23fe87ab85b763d4ff6b23bc336
--- /dev/null
+++ b/spec/features/tags/master_updates_tag_spec.rb
@@ -0,0 +1,42 @@
+require 'spec_helper'
+
+feature 'Master updates tag', feature: true do
+  let(:user) { create(:user) }
+  let(:project) { create(:project, namespace: user.namespace) }
+
+  before do
+    project.team << [user, :master]
+    login_with(user)
+    visit namespace_project_tags_path(project.namespace, project)
+  end
+
+  context 'from the tags list page' do
+    scenario 'updates the release notes' do
+      page.within(first('.controls')) do
+        click_link 'Edit release notes'
+      end
+
+      fill_in 'release_description', with: 'Awesome release notes'
+      click_button 'Save changes'
+
+      expect(current_path).to eq(
+        namespace_project_tag_path(project.namespace, project, 'v1.1.0'))
+      expect(page).to have_content 'v1.1.0'
+      expect(page).to have_content 'Awesome release notes'
+    end
+  end
+
+  context 'from a specific tag page' do
+    scenario 'updates the release notes' do
+      click_on 'v1.1.0'
+      click_link 'Edit release notes'
+      fill_in 'release_description', with: 'Awesome release notes'
+      click_button 'Save changes'
+
+      expect(current_path).to eq(
+        namespace_project_tag_path(project.namespace, project, 'v1.1.0'))
+      expect(page).to have_content 'v1.1.0'
+      expect(page).to have_content 'Awesome release notes'
+    end
+  end
+end
diff --git a/spec/features/tags/master_views_tags_spec.rb b/spec/features/tags/master_views_tags_spec.rb
new file mode 100644
index 0000000000000000000000000000000000000000..29d2c2447205635e9e8f0af6c013ca6b4b2092a6
--- /dev/null
+++ b/spec/features/tags/master_views_tags_spec.rb
@@ -0,0 +1,73 @@
+require 'spec_helper'
+
+feature 'Master views tags', feature: true do
+  let(:user) { create(:user) }
+
+  before do
+    project.team << [user, :master]
+    login_with(user)
+  end
+
+  context 'when project has no tags' do
+    let(:project) { create(:project_empty_repo) }
+    before do
+      visit namespace_project_path(project.namespace, project)
+      click_on 'README'
+      fill_in :commit_message, with: 'Add a README file', visible: true
+      # Remove pre-receive hook so we can push without auth
+      FileUtils.rm_f(File.join(project.repository.path, 'hooks', 'pre-receive'))
+      click_button 'Commit Changes'
+      visit namespace_project_tags_path(project.namespace, project)
+    end
+
+    scenario 'displays a specific message' do
+      expect(page).to have_content 'Repository has no tags yet.'
+    end
+  end
+
+  context 'when project has tags' do
+    let(:project) { create(:project, namespace: user.namespace) }
+    before do
+      visit namespace_project_tags_path(project.namespace, project)
+    end
+
+    scenario 'views the tags list page' do
+      expect(page).to have_content 'v1.0.0'
+    end
+
+    scenario 'views a specific tag page' do
+      click_on 'v1.0.0'
+
+      expect(current_path).to eq(
+        namespace_project_tag_path(project.namespace, project, 'v1.0.0'))
+      expect(page).to have_content 'v1.0.0'
+      expect(page).to have_content 'This tag has no release notes.'
+    end
+
+    describe 'links on the tag page' do
+      scenario 'has a button to browse files' do
+        click_on 'v1.0.0'
+
+        expect(current_path).to eq(
+          namespace_project_tag_path(project.namespace, project, 'v1.0.0'))
+
+        click_on 'Browse files'
+
+        expect(current_path).to eq(
+          namespace_project_tree_path(project.namespace, project, 'v1.0.0'))
+      end
+
+      scenario 'has a button to browse commits' do
+        click_on 'v1.0.0'
+
+        expect(current_path).to eq(
+          namespace_project_tag_path(project.namespace, project, 'v1.0.0'))
+
+        click_on 'Browse commits'
+
+        expect(current_path).to eq(
+          namespace_project_commits_path(project.namespace, project, 'v1.0.0'))
+      end
+    end
+  end
+end
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 29bcb8c58924de7bc75ef972585d9a7e2ff1ed90..ac5af8740dc142c2b1b8ea3d6a5e567e978209cb 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -88,18 +88,18 @@ describe ProjectsHelper do
   end
 
   describe 'default_clone_protocol' do
-    describe 'using HTTP' do
+    context 'when user is not logged in and gitlab protocol is HTTP' do
       it 'returns HTTP' do
-        expect(helper).to receive(:current_user).and_return(nil)
+        allow(helper).to receive(:current_user).and_return(nil)
 
         expect(helper.send(:default_clone_protocol)).to eq('http')
       end
     end
 
-    describe 'using HTTPS' do
+    context 'when user is not logged in and gitlab protocol is HTTPS' do
       it 'returns HTTPS' do
-        allow(Gitlab.config.gitlab).to receive(:protocol).and_return('https')
-        expect(helper).to receive(:current_user).and_return(nil)
+        stub_config_setting(protocol: 'https')
+        allow(helper).to receive(:current_user).and_return(nil)
 
         expect(helper.send(:default_clone_protocol)).to eq('https')
       end
diff --git a/spec/initializers/trusted_proxies_spec.rb b/spec/initializers/trusted_proxies_spec.rb
new file mode 100644
index 0000000000000000000000000000000000000000..4bb149f25ffe8961eb55157b2f2f1ff829f61e54
--- /dev/null
+++ b/spec/initializers/trusted_proxies_spec.rb
@@ -0,0 +1,51 @@
+require 'spec_helper'
+
+describe 'trusted_proxies', lib: true do
+  context 'with default config' do
+    before do
+      set_trusted_proxies([])
+    end
+
+    it 'preserves private IPs as remote_ip' do
+      request = stub_request('HTTP_X_FORWARDED_FOR' => '10.1.5.89')
+      expect(request.remote_ip).to eq('10.1.5.89')
+    end
+
+    it 'filters out localhost from remote_ip' do
+      request = stub_request('HTTP_X_FORWARDED_FOR' => '1.1.1.1, 10.1.5.89, 127.0.0.1')
+      expect(request.remote_ip).to eq('10.1.5.89')
+    end
+  end
+
+  context 'with private IP ranges added' do
+    before do
+      set_trusted_proxies([ "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16" ])
+    end
+
+    it 'filters out private and local IPs from remote_ip' do
+      request = stub_request('HTTP_X_FORWARDED_FOR' => '1.2.3.6, 1.1.1.1, 10.1.5.89, 127.0.0.1')
+      expect(request.remote_ip).to eq('1.1.1.1')
+    end
+  end
+
+  context 'with proxy IP added' do
+    before do
+      set_trusted_proxies([ "60.98.25.47" ])
+    end
+
+    it 'filters out proxy IP from remote_ip' do
+      request = stub_request('HTTP_X_FORWARDED_FOR' => '1.2.3.6, 1.1.1.1, 60.98.25.47, 127.0.0.1')
+      expect(request.remote_ip).to eq('1.1.1.1')
+    end
+  end
+
+  def stub_request(headers = {})
+    ActionDispatch::RemoteIp.new(Proc.new { }, false, Rails.application.config.action_dispatch.trusted_proxies).call(headers)
+    ActionDispatch::Request.new(headers)
+  end
+
+  def set_trusted_proxies(proxies = [])
+    stub_config_setting('trusted_proxies' => proxies)
+    load File.join(__dir__, '../../config/initializers/trusted_proxies.rb')
+  end
+end
diff --git a/spec/javascripts/merge_request_widget_spec.js.coffee b/spec/javascripts/merge_request_widget_spec.js.coffee
index c0bd8a29e43e8e93a4e54314e11a93997a60f96f..92b7eeb1116d0b11acd3f16ff0a94808fd8a3501 100644
--- a/spec/javascripts/merge_request_widget_spec.js.coffee
+++ b/spec/javascripts/merge_request_widget_spec.js.coffee
@@ -47,3 +47,9 @@ describe 'MergeRequestWidget', ->
       spy = spyOn(@class, 'showCICoverage').and.stub()
       @class.getCIStatus(false)
       expect(spy).not.toHaveBeenCalled()
+
+    it 'should not display a notification on the first check after the widget has been created', ->
+      spy = spyOn(window, 'notify')
+      @class = new MergeRequestWidget(@opts)
+      @class.getCIStatus(true)
+      expect(spy).not.toHaveBeenCalled()
diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb
index ebf3d7489b53ad71e44d0055fb3525804d80176b..5beb61dac5cccc12231ac3e50b43553b74eeac94 100644
--- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb
@@ -43,7 +43,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do
       milestone.update_attribute(:title, %{"></a>whatever<a title="})
 
       doc = reference_filter("milestone #{reference}")
-      expect(doc.text).to eq "milestone #{milestone.title}"
+      expect(doc.text).to eq "milestone \">whatever"
     end
 
     it 'includes default classes' do
diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb
index 27ce312b11c50066fd8b079a123c180513972f2b..b38e3b17e64b062aa6e60ceb61ee90a41d1f3afe 100644
--- a/spec/lib/banzai/filter/sanitization_filter_spec.rb
+++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb
@@ -22,6 +22,12 @@ describe Banzai::Filter::SanitizationFilter, lib: true do
       expect(filter(act).to_html).to eq exp
     end
 
+    it 'sanitizes mixed-cased javascript in attributes' do
+      act = %q(<a href="javaScript:alert('foo')">Text</a>)
+      exp = '<a>Text</a>'
+      expect(filter(act).to_html).to eq exp
+    end
+
     it 'allows whitelisted HTML tags from the user' do
       exp = act = "<dl>\n<dt>Term</dt>\n<dd>Definition</dd>\n</dl>"
       expect(filter(act).to_html).to eq exp
diff --git a/spec/lib/banzai/filter/upload_link_filter_spec.rb b/spec/lib/banzai/filter/upload_link_filter_spec.rb
index 3b073a90a95739387d6a4b99583a87556e2c5a24..b83be54746c9139848bff8d03835a2dd9ec4a008 100644
--- a/spec/lib/banzai/filter/upload_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/upload_link_filter_spec.rb
@@ -8,6 +8,10 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do
       project: project
     })
 
+    raw_filter(doc, contexts)
+  end
+
+  def raw_filter(doc, contexts = {})
     described_class.call(doc, contexts)
   end
 
@@ -70,4 +74,18 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do
       expect(doc.at_css('img')['src']).to match "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/%ED%95%9C%EA%B8%80.png"
     end
   end
+
+  context 'when project context does not exist' do
+    let(:upload_link) { link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg') }
+
+    it 'does not raise error' do
+      expect { raw_filter(upload_link, project: nil) }.not_to raise_error
+    end
+
+    it 'does not rewrite link' do
+      doc = raw_filter(upload_link, project: nil)
+
+      expect(doc.to_html).to eq upload_link
+    end
+  end
 end
diff --git a/spec/models/abuse_report_spec.rb b/spec/models/abuse_report_spec.rb
index ac12ab6c7579790e243052aee3f77449b2f75eba..305f8bc88cc5e64d85a8ec94ba038c02a24c7957 100644
--- a/spec/models/abuse_report_spec.rb
+++ b/spec/models/abuse_report_spec.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: abuse_reports
-#
-#  id          :integer          not null, primary key
-#  reporter_id :integer
-#  user_id     :integer
-#  message     :text
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 require 'rails_helper'
 
 RSpec.describe AbuseReport, type: :model do
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 520cf1b75de33252d5c6393d1e2af19a56a81b55..1ce22feed5c9ee0262da128154d6639c51b21003 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -1,49 +1,3 @@
-# == Schema Information
-#
-# Table name: application_settings
-#
-#  id                                :integer          not null, primary key
-#  default_projects_limit            :integer
-#  signup_enabled                    :boolean
-#  signin_enabled                    :boolean
-#  gravatar_enabled                  :boolean
-#  sign_in_text                      :text
-#  created_at                        :datetime
-#  updated_at                        :datetime
-#  home_page_url                     :string(255)
-#  default_branch_protection         :integer          default(2)
-#  restricted_visibility_levels      :text
-#  version_check_enabled             :boolean          default(TRUE)
-#  max_attachment_size               :integer          default(10), not null
-#  default_project_visibility        :integer
-#  default_snippet_visibility        :integer
-#  restricted_signup_domains         :text
-#  user_oauth_applications           :boolean          default(TRUE)
-#  after_sign_out_path               :string(255)
-#  session_expire_delay              :integer          default(10080), not null
-#  import_sources                    :text
-#  help_page_text                    :text
-#  admin_notification_email          :string(255)
-#  shared_runners_enabled            :boolean          default(TRUE), not null
-#  max_artifacts_size                :integer          default(100), not null
-#  runners_registration_token        :string
-#  require_two_factor_authentication :boolean          default(FALSE)
-#  two_factor_grace_period           :integer          default(48)
-#  metrics_enabled                   :boolean          default(FALSE)
-#  metrics_host                      :string           default("localhost")
-#  metrics_username                  :string
-#  metrics_password                  :string
-#  metrics_pool_size                 :integer          default(16)
-#  metrics_timeout                   :integer          default(10)
-#  metrics_method_call_threshold     :integer          default(10)
-#  recaptcha_enabled                 :boolean          default(FALSE)
-#  recaptcha_site_key                :string
-#  recaptcha_private_key             :string
-#  metrics_port                      :integer          default(8089)
-#  sentry_enabled                    :boolean          default(FALSE)
-#  sentry_dsn                        :string
-#
-
 require 'spec_helper'
 
 describe ApplicationSetting, models: true do
diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb
index f6f84db57e615d69b912976fd38aac6d3038ea6c..6ad8bfef4f22205ed2ab762b99f0d9e9495b9183 100644
--- a/spec/models/broadcast_message_spec.rb
+++ b/spec/models/broadcast_message_spec.rb
@@ -1,17 +1,3 @@
-# == Schema Information
-#
-# Table name: broadcast_messages
-#
-#  id         :integer          not null, primary key
-#  message    :text             not null
-#  starts_at  :datetime
-#  ends_at    :datetime
-#  created_at :datetime
-#  updated_at :datetime
-#  color      :string(255)
-#  font       :string(255)
-#
-
 require 'spec_helper'
 
 describe BroadcastMessage, models: true do
diff --git a/spec/models/ci/commit_spec.rb b/spec/models/ci/commit_spec.rb
index a747aa084476e7d7f2ec5baa12f19bf43dd1d992..dc071ad1c90eaa6387da80f8a0782e214e660914 100644
--- a/spec/models/ci/commit_spec.rb
+++ b/spec/models/ci/commit_spec.rb
@@ -1,21 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_commits
-#
-#  id            :integer          not null, primary key
-#  project_id    :integer
-#  ref           :string(255)
-#  sha           :string(255)
-#  before_sha    :string(255)
-#  push_data     :text
-#  created_at    :datetime
-#  updated_at    :datetime
-#  tag           :boolean          default(FALSE)
-#  yaml_errors   :text
-#  committed_at  :datetime
-#  gl_project_id :integer
-#
-
 require 'spec_helper'
 
 describe Ci::Commit, models: true do
diff --git a/spec/models/ci/runner_project_spec.rb b/spec/models/ci/runner_project_spec.rb
index 000a732db777b2866aebc44a96a1fe063f16c7a3..95fc160b2382acefd5a79d46f580cd5e0ab4a8a4 100644
--- a/spec/models/ci/runner_project_spec.rb
+++ b/spec/models/ci/runner_project_spec.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_runner_projects
-#
-#  id            :integer          not null, primary key
-#  runner_id     :integer          not null
-#  project_id    :integer
-#  created_at    :datetime
-#  updated_at    :datetime
-#  gl_project_id :integer
-#
-
 require 'spec_helper'
 
 describe Ci::RunnerProject, models: true do
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index 25e9e5eca48a2491d77242e4177601ce8bad1b8c..eaa94228922fdabbe9780412610898eabc3f48b3 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -1,22 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_runners
-#
-#  id           :integer          not null, primary key
-#  token        :string(255)
-#  created_at   :datetime
-#  updated_at   :datetime
-#  description  :string(255)
-#  contacted_at :datetime
-#  active       :boolean          default(TRUE), not null
-#  is_shared    :boolean          default(FALSE)
-#  name         :string(255)
-#  version      :string(255)
-#  revision     :string(255)
-#  platform     :string(255)
-#  architecture :string(255)
-#
-
 require 'spec_helper'
 
 describe Ci::Runner, models: true do
diff --git a/spec/models/ci/trigger_spec.rb b/spec/models/ci/trigger_spec.rb
index 159be939300af1b1101ddbaf6d4c07e00fab1131..474b0b1621de3f94006f3ef4275f64d76b6bed08 100644
--- a/spec/models/ci/trigger_spec.rb
+++ b/spec/models/ci/trigger_spec.rb
@@ -1,16 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_triggers
-#
-#  id            :integer          not null, primary key
-#  token         :string(255)
-#  project_id    :integer
-#  deleted_at    :datetime
-#  created_at    :datetime
-#  updated_at    :datetime
-#  gl_project_id :integer
-#
-
 require 'spec_helper'
 
 describe Ci::Trigger, models: true do
diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb
index 71e84091cb7848d90682632e39bc1d5fd22b6543..c712d211b0fd69879bdb0bb1d96b03d6bc6031c8 100644
--- a/spec/models/ci/variable_spec.rb
+++ b/spec/models/ci/variable_spec.rb
@@ -1,17 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_variables
-#
-#  id                   :integer          not null, primary key
-#  project_id           :integer
-#  key                  :string(255)
-#  value                :text
-#  encrypted_value      :text
-#  encrypted_value_salt :string(255)
-#  encrypted_value_iv   :string(255)
-#  gl_project_id        :integer
-#
-
 require 'spec_helper'
 
 describe Ci::Variable, models: true do
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index 971e6750375f2143a8386dba3b520b9b5ac518fa..434e58cfd0662b705f23ef4c13c58dcca202ed9e 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -1,37 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_builds
-#
-#  id                 :integer          not null, primary key
-#  project_id         :integer
-#  status             :string(255)
-#  finished_at        :datetime
-#  trace              :text
-#  created_at         :datetime
-#  updated_at         :datetime
-#  started_at         :datetime
-#  runner_id          :integer
-#  coverage           :float
-#  commit_id          :integer
-#  commands           :text
-#  job_id             :integer
-#  name               :string(255)
-#  deploy             :boolean          default(FALSE)
-#  options            :text
-#  allow_failure      :boolean          default(FALSE), not null
-#  stage              :string(255)
-#  trigger_request_id :integer
-#  stage_idx          :integer
-#  tag                :boolean
-#  ref                :string(255)
-#  user_id            :integer
-#  type               :string(255)
-#  target_url         :string(255)
-#  description        :string(255)
-#  artifacts_file     :text
-#  gl_project_id      :integer
-#
-
 require 'spec_helper'
 
 describe CommitStatus, models: true do
diff --git a/spec/models/deploy_key_spec.rb b/spec/models/deploy_key_spec.rb
index 64ba778afea6f3957ed538a1e069c0fd9e569974..6a90598a629d3c6ad7ced553047926d29e30c1d3 100644
--- a/spec/models/deploy_key_spec.rb
+++ b/spec/models/deploy_key_spec.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: keys
-#
-#  id          :integer          not null, primary key
-#  user_id     :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#  key         :text
-#  title       :string(255)
-#  type        :string(255)
-#  fingerprint :string(255)
-#  public      :boolean          default(FALSE), not null
-#
-
 require 'spec_helper'
 
 describe DeployKey, models: true do
diff --git a/spec/models/deploy_keys_project_spec.rb b/spec/models/deploy_keys_project_spec.rb
index 8aedbfb86360e925904b2fd5eb110d2da718b358..8a1e337c1a3fe840ffcfd6284431be3799ce3487 100644
--- a/spec/models/deploy_keys_project_spec.rb
+++ b/spec/models/deploy_keys_project_spec.rb
@@ -1,14 +1,3 @@
-# == Schema Information
-#
-# Table name: deploy_keys_projects
-#
-#  id            :integer          not null, primary key
-#  deploy_key_id :integer          not null
-#  project_id    :integer          not null
-#  created_at    :datetime
-#  updated_at    :datetime
-#
-
 require 'spec_helper'
 
 describe DeployKeysProject, models: true do
diff --git a/spec/models/email_spec.rb b/spec/models/email_spec.rb
index a20a614964924301de1fba76b636eca36c21242b..5d0bd31db5af363aad82ba6242816e8d7dbe2f59 100644
--- a/spec/models/email_spec.rb
+++ b/spec/models/email_spec.rb
@@ -1,14 +1,3 @@
-# == Schema Information
-#
-# Table name: emails
-#
-#  id         :integer          not null, primary key
-#  user_id    :integer          not null
-#  email      :string(255)      not null
-#  created_at :datetime
-#  updated_at :datetime
-#
-
 require 'spec_helper'
 
 describe Email, models: true do
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index 0c3cd13f3993905c1e788842ba3345cad5eb2032..b0e76fec6935cbea12ce9d26756832e7c325cf28 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -1,19 +1,3 @@
-# == Schema Information
-#
-# Table name: events
-#
-#  id          :integer          not null, primary key
-#  target_type :string(255)
-#  target_id   :integer
-#  title       :string(255)
-#  data        :text
-#  project_id  :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#  action      :integer
-#  author_id   :integer
-#
-
 require 'spec_helper'
 
 describe Event, models: true do
diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb
index d90fbfe1ea5965ff371e940a27de7059732460e0..3b817608ce0dfcd2374a734edb627f961fb93439 100644
--- a/spec/models/forked_project_link_spec.rb
+++ b/spec/models/forked_project_link_spec.rb
@@ -1,14 +1,3 @@
-# == Schema Information
-#
-# Table name: forked_project_links
-#
-#  id                     :integer          not null, primary key
-#  forked_to_project_id   :integer          not null
-#  forked_from_project_id :integer          not null
-#  created_at             :datetime
-#  updated_at             :datetime
-#
-
 require 'spec_helper'
 
 describe ForkedProjectLink, "add link on fork" do
diff --git a/spec/models/generic_commit_status_spec.rb b/spec/models/generic_commit_status_spec.rb
index 5b0883d8702bf0697dc6d6358973dabb50b45866..0caf5869c24fb6eb3c05d5f99679f80bce2069b7 100644
--- a/spec/models/generic_commit_status_spec.rb
+++ b/spec/models/generic_commit_status_spec.rb
@@ -1,37 +1,3 @@
-# == Schema Information
-#
-# Table name: ci_builds
-#
-#  id                 :integer          not null, primary key
-#  project_id         :integer
-#  status             :string(255)
-#  finished_at        :datetime
-#  trace              :text
-#  created_at         :datetime
-#  updated_at         :datetime
-#  started_at         :datetime
-#  runner_id          :integer
-#  coverage           :float
-#  commit_id          :integer
-#  commands           :text
-#  job_id             :integer
-#  name               :string(255)
-#  deploy             :boolean          default(FALSE)
-#  options            :text
-#  allow_failure      :boolean          default(FALSE), not null
-#  stage              :string(255)
-#  trigger_request_id :integer
-#  stage_idx          :integer
-#  tag                :boolean
-#  ref                :string(255)
-#  user_id            :integer
-#  type               :string(255)
-#  target_url         :string(255)
-#  description        :string(255)
-#  artifacts_file     :text
-#  gl_project_id      :integer
-#
-
 require 'spec_helper'
 
 describe GenericCommitStatus, models: true do
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 7bfca1e72c3c9920b13030dc921ba9dfbc475029..6fa16be7f045bb1e6be3e77800955dc820e6f168 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: namespaces
-#
-#  id          :integer          not null, primary key
-#  name        :string(255)      not null
-#  path        :string(255)      not null
-#  owner_id    :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#  type        :string(255)
-#  description :string(255)      default(""), not null
-#  avatar      :string(255)
-#
-
 require 'spec_helper'
 
 describe Group, models: true do
diff --git a/spec/models/identity_spec.rb b/spec/models/identity_spec.rb
index 5afe042e154ab9bc03e2f68908b1b6d88d403a7a..1b987588f592cdd9602120eb258fef63fc4f88b0 100644
--- a/spec/models/identity_spec.rb
+++ b/spec/models/identity_spec.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: identities
-#
-#  id         :integer          not null, primary key
-#  extern_uid :string(255)
-#  provider   :string(255)
-#  user_id    :integer
-#  created_at :datetime
-#  updated_at :datetime
-#
-
 require 'spec_helper'
 
 RSpec.describe Identity, models: true do
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index 060e6599104530840d2fa6bcb26683d50dbec441..8ab00c70f9d341a35f7e8ec248366e0cecc55d64 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -1,23 +1,3 @@
-# == Schema Information
-#
-# Table name: issues
-#
-#  id            :integer          not null, primary key
-#  title         :string(255)
-#  assignee_id   :integer
-#  author_id     :integer
-#  project_id    :integer
-#  created_at    :datetime
-#  updated_at    :datetime
-#  position      :integer          default(0)
-#  branch_name   :string(255)
-#  description   :text
-#  milestone_id  :integer
-#  state         :string(255)
-#  iid           :integer
-#  updated_by_id :integer
-#
-
 require 'spec_helper'
 
 describe Issue, models: true do
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index c962b83644a045664a6df0c86de8a401d0fb9588..26fbedbef2f83f76a8e0c52dbbe7f721cda1d8e8 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: keys
-#
-#  id          :integer          not null, primary key
-#  user_id     :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#  key         :text
-#  title       :string(255)
-#  type        :string(255)
-#  fingerprint :string(255)
-#  public      :boolean          default(FALSE), not null
-#
-
 require 'spec_helper'
 
 describe Key, models: true do
diff --git a/spec/models/label_link_spec.rb b/spec/models/label_link_spec.rb
index dc7510b1de305aeb100608a3b682b2f2a07bebda..5e6f8ca1528151ade39081c01ffcf8bc58e3a755 100644
--- a/spec/models/label_link_spec.rb
+++ b/spec/models/label_link_spec.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: label_links
-#
-#  id          :integer          not null, primary key
-#  label_id    :integer
-#  target_id   :integer
-#  target_type :string(255)
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 require 'spec_helper'
 
 describe LabelLink, models: true do
diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb
index 0614ca1e7c93d529ed43e85d47738500f334c0f4..dad2628651b480b74c98cdf759ac9df9d7159b44 100644
--- a/spec/models/label_spec.rb
+++ b/spec/models/label_spec.rb
@@ -1,16 +1,3 @@
-# == Schema Information
-#
-# Table name: labels
-#
-#  id         :integer          not null, primary key
-#  title      :string(255)
-#  color      :string(255)
-#  project_id :integer
-#  created_at :datetime
-#  updated_at :datetime
-#  template   :boolean          default(FALSE)
-#
-
 require 'spec_helper'
 
 describe Label, models: true do
@@ -55,6 +42,14 @@ describe Label, models: true do
     end
   end
 
+  describe "#title" do
+    let(:label) { create(:label, title: "<b>test</b>") }
+
+    it "sanitizes title" do
+      expect(label.title).to eq("test")
+    end
+  end
+
   describe '#to_reference' do
     context 'using id' do
       it 'returns a String reference to the object' do
diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb
index 2d8f1cc1ad3362e68ef0e9997f7b081374870f53..6e51730eecd207ff08e016b9c28913cd9d8fdb89 100644
--- a/spec/models/member_spec.rb
+++ b/spec/models/member_spec.rb
@@ -1,22 +1,3 @@
-# == Schema Information
-#
-# Table name: members
-#
-#  id                 :integer          not null, primary key
-#  access_level       :integer          not null
-#  source_id          :integer          not null
-#  source_type        :string(255)      not null
-#  user_id            :integer
-#  notification_level :integer          not null
-#  type               :string(255)
-#  created_at         :datetime
-#  updated_at         :datetime
-#  created_by_id      :integer
-#  invite_email       :string(255)
-#  invite_token       :string(255)
-#  invite_accepted_at :datetime
-#
-
 require 'spec_helper'
 
 describe Member, models: true do
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index d7884cea336fa9b5b035b1c63a8f0eb898495edf..c8578749b211613562e209690992a4aba1e54c76 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -1,32 +1,3 @@
-# == Schema Information
-#
-# Table name: merge_requests
-#
-#  id                        :integer          not null, primary key
-#  target_branch             :string(255)      not null
-#  source_branch             :string(255)      not null
-#  source_project_id         :integer          not null
-#  author_id                 :integer
-#  assignee_id               :integer
-#  title                     :string(255)
-#  created_at                :datetime
-#  updated_at                :datetime
-#  milestone_id              :integer
-#  state                     :string(255)
-#  merge_status              :string(255)
-#  target_project_id         :integer          not null
-#  iid                       :integer
-#  description               :text
-#  position                  :integer          default(0)
-#  locked_at                 :datetime
-#  updated_by_id             :integer
-#  merge_error               :string(255)
-#  merge_params              :text
-#  merge_when_build_succeeds :boolean          default(FALSE), not null
-#  merge_user_id             :integer
-#  merge_commit_sha          :string
-#
-
 require 'spec_helper'
 
 describe MergeRequest, models: true do
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb
index 72a4ea702281ae5d8dd3b8fbe2c6e86768e1821b..247a9fa9910a9a013332fde277bc4a4c4232b8da 100644
--- a/spec/models/milestone_spec.rb
+++ b/spec/models/milestone_spec.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: milestones
-#
-#  id          :integer          not null, primary key
-#  title       :string(255)      not null
-#  project_id  :integer          not null
-#  description :text
-#  due_date    :date
-#  created_at  :datetime
-#  updated_at  :datetime
-#  state       :string(255)
-#  iid         :integer
-#
-
 require 'spec_helper'
 
 describe Milestone, models: true do
@@ -34,6 +19,14 @@ describe Milestone, models: true do
   let(:issue) { create(:issue) }
   let(:user) { create(:user) }
 
+  describe "#title" do
+    let(:milestone) { create(:milestone, title: "<b>test</b>") }
+
+    it "sanitizes title" do
+      expect(milestone.title).to eq("test")
+    end
+  end
+
   describe "unique milestone title per project" do
     it "shouldn't accept the same title in a project twice" do
       new_milestone = Milestone.new(project: milestone.project, title: milestone.title)
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index 3c3a580942a97dbf029c6f9c38b4aaa30bfb1ada..4074f966299fa00a2af72ebf267a981d352c5dcc 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -1,18 +1,3 @@
-# == Schema Information
-#
-# Table name: namespaces
-#
-#  id          :integer          not null, primary key
-#  name        :string(255)      not null
-#  path        :string(255)      not null
-#  owner_id    :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#  type        :string(255)
-#  description :string(255)      default(""), not null
-#  avatar      :string(255)
-#
-
 require 'spec_helper'
 
 describe Namespace, models: true do
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 6b18936edb12f34d593b3240d8b39d7f0b99314c..4b788b578829788735ccbcd76fc518f90a05e131 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -1,24 +1,3 @@
-# == Schema Information
-#
-# Table name: notes
-#
-#  id            :integer          not null, primary key
-#  note          :text
-#  noteable_type :string(255)
-#  author_id     :integer
-#  created_at    :datetime
-#  updated_at    :datetime
-#  project_id    :integer
-#  attachment    :string(255)
-#  line_code     :string(255)
-#  commit_id     :string(255)
-#  noteable_id   :integer
-#  system        :boolean          default(FALSE), not null
-#  st_diff       :text
-#  updated_by_id :integer
-#  is_award      :boolean          default(FALSE), not null
-#
-
 require 'spec_helper'
 
 describe Note, models: true do
diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb
index e0feb606f78188734e6660e1e2fbc492c0a94edc..d9d7c0b0aaafbd2964ec38a63e6ce70ce99b29e2 100644
--- a/spec/models/project_snippet_spec.rb
+++ b/spec/models/project_snippet_spec.rb
@@ -1,19 +1,3 @@
-# == Schema Information
-#
-# Table name: snippets
-#
-#  id               :integer          not null, primary key
-#  title            :string(255)
-#  content          :text
-#  author_id        :integer          not null
-#  project_id       :integer
-#  created_at       :datetime
-#  updated_at       :datetime
-#  file_name        :string(255)
-#  type             :string(255)
-#  visibility_level :integer          default(0), not null
-#
-
 require 'spec_helper'
 
 describe ProjectSnippet, models: true do
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 5b1cf71337e552a525e14c7a7b75cfd5b9b4c242..f6e5b132643b1e0b981be42e6deb225d31e2a41e 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -1,43 +1,3 @@
-# == Schema Information
-#
-# Table name: projects
-#
-#  id                     :integer          not null, primary key
-#  name                   :string(255)
-#  path                   :string(255)
-#  description            :text
-#  created_at             :datetime
-#  updated_at             :datetime
-#  creator_id             :integer
-#  issues_enabled         :boolean          default(TRUE), not null
-#  wall_enabled           :boolean          default(TRUE), not null
-#  merge_requests_enabled :boolean          default(TRUE), not null
-#  wiki_enabled           :boolean          default(TRUE), not null
-#  namespace_id           :integer
-#  issues_tracker         :string(255)      default("gitlab"), not null
-#  issues_tracker_id      :string(255)
-#  snippets_enabled       :boolean          default(TRUE), not null
-#  last_activity_at       :datetime
-#  import_url             :string(255)
-#  visibility_level       :integer          default(0), not null
-#  archived               :boolean          default(FALSE), not null
-#  avatar                 :string(255)
-#  import_status          :string(255)
-#  repository_size        :float            default(0.0)
-#  star_count             :integer          default(0), not null
-#  import_type            :string(255)
-#  import_source          :string(255)
-#  commit_count           :integer          default(0)
-#  import_error           :text
-#  ci_id                  :integer
-#  builds_enabled         :boolean          default(TRUE), not null
-#  shared_runners_enabled :boolean          default(TRUE), not null
-#  runners_token          :string
-#  build_coverage_regex   :string
-#  build_allow_git_fetch  :boolean          default(TRUE), not null
-#  build_timeout          :integer          default(3600), not null
-#
-
 require 'spec_helper'
 
 describe Project, models: true do
diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb
index 7e956cf67797621d2326b68c20d3980df50de176..b523834c6e93ca0e5d075ce731624c7cbdba6975 100644
--- a/spec/models/protected_branch_spec.rb
+++ b/spec/models/protected_branch_spec.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: protected_branches
-#
-#  id                  :integer          not null, primary key
-#  project_id          :integer          not null
-#  name                :string(255)      not null
-#  created_at          :datetime
-#  updated_at          :datetime
-#  developers_can_push :boolean          default(FALSE), not null
-#
-
 require 'spec_helper'
 
 describe ProtectedBranch, models: true do
diff --git a/spec/models/release_spec.rb b/spec/models/release_spec.rb
index 72ecb442a361a7576704efff942c01c2d4250542..527005b2b698adae9c53e09ae84bcd81b6ebc18a 100644
--- a/spec/models/release_spec.rb
+++ b/spec/models/release_spec.rb
@@ -1,15 +1,3 @@
-# == Schema Information
-#
-# Table name: releases
-#
-#  id          :integer          not null, primary key
-#  tag         :string(255)
-#  description :text
-#  project_id  :integer
-#  created_at  :datetime
-#  updated_at  :datetime
-#
-
 require 'rails_helper'
 
 RSpec.describe Release, type: :model do
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 173628c08d0eaaf1d85b7a4a9e46673941a8e73e..8592e112c500eaa0f36be482e96d534cddebbcfe 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -1,24 +1,3 @@
-# == Schema Information
-#
-# Table name: services
-#
-#  id                    :integer          not null, primary key
-#  type                  :string(255)
-#  title                 :string(255)
-#  project_id            :integer
-#  created_at            :datetime
-#  updated_at            :datetime
-#  active                :boolean          default(FALSE), not null
-#  properties            :text
-#  template              :boolean          default(FALSE)
-#  push_events           :boolean          default(TRUE)
-#  issues_events         :boolean          default(TRUE)
-#  merge_requests_events :boolean          default(TRUE)
-#  tag_push_events       :boolean          default(TRUE)
-#  note_events           :boolean          default(TRUE), not null
-#  build_events          :boolean          default(FALSE), not null
-#
-
 require 'spec_helper'
 
 describe Service, models: true do
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb
index 5077ac7b62bd6b39a182f3a25cb72645dd719eb6..7a613e360d4944c3423aa10e3a1ede0b573f8a9a 100644
--- a/spec/models/snippet_spec.rb
+++ b/spec/models/snippet_spec.rb
@@ -1,19 +1,3 @@
-# == Schema Information
-#
-# Table name: snippets
-#
-#  id               :integer          not null, primary key
-#  title            :string(255)
-#  content          :text
-#  author_id        :integer          not null
-#  project_id       :integer
-#  created_at       :datetime
-#  updated_at       :datetime
-#  file_name        :string(255)
-#  type             :string(255)
-#  visibility_level :integer          default(0), not null
-#
-
 require 'spec_helper'
 
 describe Snippet, models: true do
diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb
index d9b86b9368fd0f704180edf5b346790e7fa23fda..623b82c01d82c8dd1488c1d76554f5c8a251522e 100644
--- a/spec/models/todo_spec.rb
+++ b/spec/models/todo_spec.rb
@@ -1,21 +1,3 @@
-# == Schema Information
-#
-# Table name: todos
-#
-#  id          :integer          not null, primary key
-#  user_id     :integer          not null
-#  project_id  :integer          not null
-#  target_id   :integer
-#  target_type :string           not null
-#  author_id   :integer
-#  action      :integer          not null
-#  state       :string           not null
-#  created_at  :datetime
-#  updated_at  :datetime
-#  note_id     :integer
-#  commit_id   :string
-#
-
 require 'spec_helper'
 
 describe Todo, models: true do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 8b2fb77e28eb1fb55ba3c916b94b16680fe56d92..26d4e139396b177d9892b19cc356a3d8af565b87 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1,66 +1,3 @@
-# == Schema Information
-#
-# Table name: users
-#
-#  id                          :integer          not null, primary key
-#  email                       :string(255)      default(""), not null
-#  encrypted_password          :string(255)      default(""), not null
-#  reset_password_token        :string(255)
-#  reset_password_sent_at      :datetime
-#  remember_created_at         :datetime
-#  sign_in_count               :integer          default(0)
-#  current_sign_in_at          :datetime
-#  last_sign_in_at             :datetime
-#  current_sign_in_ip          :string(255)
-#  last_sign_in_ip             :string(255)
-#  created_at                  :datetime
-#  updated_at                  :datetime
-#  name                        :string(255)
-#  admin                       :boolean          default(FALSE), not null
-#  projects_limit              :integer          default(10)
-#  skype                       :string(255)      default(""), not null
-#  linkedin                    :string(255)      default(""), not null
-#  twitter                     :string(255)      default(""), not null
-#  authentication_token        :string(255)
-#  theme_id                    :integer          default(1), not null
-#  bio                         :string(255)
-#  failed_attempts             :integer          default(0)
-#  locked_at                   :datetime
-#  username                    :string(255)
-#  can_create_group            :boolean          default(TRUE), not null
-#  can_create_team             :boolean          default(TRUE), not null
-#  state                       :string(255)
-#  color_scheme_id             :integer          default(1), not null
-#  notification_level          :integer          default(1), not null
-#  password_expires_at         :datetime
-#  created_by_id               :integer
-#  last_credential_check_at    :datetime
-#  avatar                      :string(255)
-#  confirmation_token          :string(255)
-#  confirmed_at                :datetime
-#  confirmation_sent_at        :datetime
-#  unconfirmed_email           :string(255)
-#  hide_no_ssh_key             :boolean          default(FALSE)
-#  website_url                 :string(255)      default(""), not null
-#  notification_email          :string(255)
-#  hide_no_password            :boolean          default(FALSE)
-#  password_automatically_set  :boolean          default(FALSE)
-#  location                    :string(255)
-#  encrypted_otp_secret        :string(255)
-#  encrypted_otp_secret_iv     :string(255)
-#  encrypted_otp_secret_salt   :string(255)
-#  otp_required_for_login      :boolean          default(FALSE), not null
-#  otp_backup_codes            :text
-#  public_email                :string(255)      default(""), not null
-#  dashboard                   :integer          default(0)
-#  project_view                :integer          default(0)
-#  consumed_timestep           :integer
-#  layout                      :integer          default(0)
-#  hide_project_limit          :boolean          default(FALSE)
-#  unlock_token                :string
-#  otp_grace_period_started_at :datetime
-#
-
 require 'spec_helper'
 
 describe User, models: true do
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index f88e39cad9eeab0e43fdf6dd75bc641f3ae7edfe..9dd43f4fab349392bf91a960af103d0044a18e7a 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -39,6 +39,7 @@ describe API::API, api: true  do
   let!(:empty_milestone) do
     create(:milestone, title: '2.0.0', project: project)
   end
+  let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) }
 
   before { project.team << [user, :reporter] }
 
@@ -232,8 +233,28 @@ describe API::API, api: true  do
   end
 
   describe "GET /projects/:id/issues/:issue_id" do
+    it 'exposes known attributes' do
+      get api("/projects/#{project.id}/issues/#{issue.id}", user)
+
+      expect(response.status).to eq(200)
+      expect(json_response['id']).to eq(issue.id)
+      expect(json_response['iid']).to eq(issue.iid)
+      expect(json_response['project_id']).to eq(issue.project.id)
+      expect(json_response['title']).to eq(issue.title)
+      expect(json_response['description']).to eq(issue.description)
+      expect(json_response['state']).to eq(issue.state)
+      expect(json_response['created_at']).to be_present
+      expect(json_response['updated_at']).to be_present
+      expect(json_response['labels']).to eq(issue.label_names)
+      expect(json_response['milestone']).to be_a Hash
+      expect(json_response['assignee']).to be_a Hash
+      expect(json_response['author']).to be_a Hash
+      expect(json_response['user_notes_count']).to be(1)
+    end
+
     it "should return a project issue by id" do
       get api("/projects/#{project.id}/issues/#{issue.id}", user)
+
       expect(response.status).to eq(200)
       expect(json_response['title']).to eq(issue.title)
       expect(json_response['iid']).to eq(issue.iid)
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 1fa7e76894fb17a3ca33b08ded7b22c2fa419e18..4b0111df149755c70314c95e9245bfb8f8569294 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -113,6 +113,34 @@ describe API::API, api: true  do
   end
 
   describe "GET /projects/:id/merge_requests/:merge_request_id" do
+    it 'exposes known attributes' do
+      get api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user)
+
+      expect(response.status).to eq(200)
+      expect(json_response['id']).to eq(merge_request.id)
+      expect(json_response['iid']).to eq(merge_request.iid)
+      expect(json_response['project_id']).to eq(merge_request.project.id)
+      expect(json_response['title']).to eq(merge_request.title)
+      expect(json_response['description']).to eq(merge_request.description)
+      expect(json_response['state']).to eq(merge_request.state)
+      expect(json_response['created_at']).to be_present
+      expect(json_response['updated_at']).to be_present
+      expect(json_response['labels']).to eq(merge_request.label_names)
+      expect(json_response['milestone']).to be_nil
+      expect(json_response['assignee']).to be_a Hash
+      expect(json_response['author']).to be_a Hash
+      expect(json_response['target_branch']).to eq(merge_request.target_branch)
+      expect(json_response['source_branch']).to eq(merge_request.source_branch)
+      expect(json_response['upvotes']).to eq(0)
+      expect(json_response['downvotes']).to eq(0)
+      expect(json_response['source_project_id']).to eq(merge_request.source_project.id)
+      expect(json_response['target_project_id']).to eq(merge_request.target_project.id)
+      expect(json_response['work_in_progress']).to be_falsy
+      expect(json_response['merge_when_build_succeeds']).to be_falsy
+      expect(json_response['merge_status']).to eq('can_be_merged')
+      expect(json_response['user_notes_count']).to be(2)
+    end
+
     it "should return merge_request" do
       get api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user)
       expect(response.status).to eq(200)
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index 240eae10052088ef00ff116c9b135a7621a6c320..5fbf2ae52476d811d6c744b76b82d7711ef21312 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -506,6 +506,15 @@ describe SystemNoteService, services: true do
     end
   end
 
+  describe '.new_commit_summary' do
+    it 'escapes HTML titles' do
+      commit = double(title: '<pre>This is a test</pre>', short_id: '12345678')
+      escaped = '* 12345678 - &lt;pre&gt;This is a test&lt;&#x2F;pre&gt;'
+
+      expect(described_class.new_commit_summary([commit])).to eq([escaped])
+    end
+  end
+
   include JiraServiceHelper
 
   describe 'JIRA integration' do
diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb
index 82b7fbfa81629862b79af258f984ff8cfde4aaa1..a075496ee63aa72d47287569ac56dac005f068d7 100644
--- a/spec/services/todo_service_spec.rb
+++ b/spec/services/todo_service_spec.rb
@@ -55,6 +55,25 @@ describe TodoService, services: true do
         should_create_todo(user: admin, target: confidential_issue, author: john_doe, action: Todo::MENTIONED)
         should_not_create_todo(user: john_doe, target: confidential_issue, author: john_doe, action: Todo::MENTIONED)
       end
+
+      context 'when a private group is mentioned' do
+        let(:group) { create :group, :private }
+        let(:project) { create :project, :private, group: group }
+        let(:issue) { create :issue, author: author, project: project, description: group.to_reference }
+
+        before do
+          group.add_owner(author)
+          group.add_user(member, Gitlab::Access::DEVELOPER)
+          group.add_user(john_doe, Gitlab::Access::DEVELOPER)
+
+          service.new_issue(issue, author)
+        end
+
+        it 'creates a todo for group members' do
+          should_create_todo(user: member, target: issue)
+          should_create_todo(user: john_doe, target: issue)
+        end
+      end
     end
 
     describe '#update_issue' do