From e42f720b625b3d4c4d1cb6c067034674abed194e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20K=C3=B6berl?= Date: Mon, 29 Dec 2014 17:09:36 +0100 Subject: [PATCH 01/80] add environment variable force to the documentation --- doc/raketasks/backup_restore.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/raketasks/backup_restore.md b/doc/raketasks/backup_restore.md index f9d2f5dc4eb..6d31388baee 100644 --- a/doc/raketasks/backup_restore.md +++ b/doc/raketasks/backup_restore.md @@ -155,6 +155,7 @@ Options: ``` BACKUP=timestamp_of_backup (required if more than one backup exists) +force=yes (do not ask if the authorized_keys file should get regenerated) ``` Example output: From 44535f9375ef6335551b0c9640ddad5b9d6de1c9 Mon Sep 17 00:00:00 2001 From: Chulki Lee Date: Mon, 30 Mar 2015 15:53:24 -0700 Subject: [PATCH 02/80] upgrade hipchat --- Gemfile | 2 +- Gemfile.lock | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 465e90e71a3..52e8a3f5a60 100644 --- a/Gemfile +++ b/Gemfile @@ -143,7 +143,7 @@ gem "redis-rails" gem 'tinder', '~> 1.9.2' # HipChat integration -gem "hipchat", "~> 1.4.0" +gem 'hipchat', '~> 1.5.0' # Flowdock integration gem "gitlab-flowdock-git-hook", "~> 0.4.2" diff --git a/Gemfile.lock b/Gemfile.lock index 747dbe1b037..29457552eb6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -271,8 +271,9 @@ GEM hashie (2.1.2) highline (1.6.21) hike (1.2.3) - hipchat (1.4.0) + hipchat (1.5.0) httparty + mimemagic hitimes (1.2.2) html-pipeline (1.11.0) activesupport (>= 2) @@ -284,7 +285,7 @@ GEM mime-types sanitize (~> 2.1) http_parser.rb (0.5.3) - httparty (0.13.0) + httparty (0.13.3) json (~> 1.8) multi_xml (>= 0.5.2) httpauth (0.2.1) @@ -329,6 +330,7 @@ GEM mime-types (>= 1.16, < 3) method_source (0.8.2) mime-types (1.25.1) + mimemagic (0.3.0) mini_portile (0.6.1) minitest (5.3.5) mousetrap-rails (1.4.6) @@ -714,7 +716,7 @@ DEPENDENCIES guard-rspec guard-spinach haml-rails - hipchat (~> 1.4.0) + hipchat (~> 1.5.0) html-pipeline-gitlab (~> 0.1) httparty jasmine (= 2.0.2) From bf813a22a1843f9ce2156a5d87487956049d8ae4 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 16 Apr 2015 08:29:07 -0700 Subject: [PATCH 03/80] Remove entry that was shipped in v7.9.1 --- CHANGELOG | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index e8f367c332b..a5d8e29109e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,7 +22,6 @@ v 7.10.0 (unreleased) - Allow HTML tags in Markdown input - Fix code unfold not working on Compare commits page (Stan Hu) - Fix generating SSH key fingerprints with OpenSSH 6.8. (Sašo Stanovnik) - - Include missing events and fix save functionality in admin service template settings form (Stan Hu) - Fix "Import projects from" button to show the correct instructions (Stan Hu) - Fix dots in Wiki slugs causing errors (Stan Hu) - Make maximum attachment size configurable via Application Settings (Stan Hu) From 7d5fefb780a62d063c3bbf5b050910c5542d64c1 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 11 Apr 2015 18:29:25 -0400 Subject: [PATCH 04/80] Fix 'merge_reuests' typo --- app/assets/javascripts/shortcuts_issueable.coffee | 2 +- app/views/help/_shortcuts.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/shortcuts_issueable.coffee b/app/assets/javascripts/shortcuts_issueable.coffee index b8dae71e037..f2d30eb364d 100644 --- a/app/assets/javascripts/shortcuts_issueable.coffee +++ b/app/assets/javascripts/shortcuts_issueable.coffee @@ -13,7 +13,7 @@ class @ShortcutsIssueable extends ShortcutsNavigation ) if isMergeRequest - @enabledHelp.push('.hidden-shortcut.merge_reuests') + @enabledHelp.push('.hidden-shortcut.merge_requests') else @enabledHelp.push('.hidden-shortcut.issues') diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml index 7b21ca30d8c..fdeab909b76 100644 --- a/app/views/help/_shortcuts.html.haml +++ b/app/views/help/_shortcuts.html.haml @@ -187,7 +187,7 @@ %td.shortcut .key m %td Change milestone - %tbody{ class: 'hidden-shortcut merge_reuests', style: 'display:none' } + %tbody{ class: 'hidden-shortcut merge_requests', style: 'display:none' } %tr %th %th Merge Requests From 7679c500abb8f6dff4c49a7dec1b1643a4aedeb0 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 18 Apr 2015 14:00:56 -0400 Subject: [PATCH 05/80] Update jasmine gem --- Gemfile | 4 ++-- Gemfile.lock | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 3f262655117..5c86ad15e40 100644 --- a/Gemfile +++ b/Gemfile @@ -251,12 +251,12 @@ group :development, :test do # PhantomJS driver for Capybara gem 'poltergeist', '~> 1.5.1' - gem 'jasmine', '2.0.2' + gem 'jasmine', '~> 2.2.0' gem "spring", '~> 1.3.1' gem "spring-commands-rspec", '1.0.4' gem "spring-commands-spinach", '1.0.0' - + gem "byebug" end diff --git a/Gemfile.lock b/Gemfile.lock index bfe626521e7..ab424c3777c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -292,12 +292,12 @@ GEM i18n (0.7.0) ice_cube (0.11.1) ice_nine (0.10.0) - jasmine (2.0.2) - jasmine-core (~> 2.0.0) + jasmine (2.2.0) + jasmine-core (~> 2.2) phantomjs rack (>= 1.2.1) rake - jasmine-core (2.0.0) + jasmine-core (2.2.0) jquery-atwho-rails (0.3.3) jquery-rails (3.1.0) railties (>= 3.0, < 5.0) @@ -391,7 +391,7 @@ GEM parser (2.2.0.2) ast (>= 1.1, < 3.0) pg (0.15.1) - phantomjs (1.9.2.0) + phantomjs (1.9.8.0) poltergeist (1.5.1) capybara (~> 2.1) cliver (~> 0.3.1) @@ -717,7 +717,7 @@ DEPENDENCIES hipchat (~> 1.4.0) html-pipeline-gitlab (~> 0.1) httparty - jasmine (= 2.0.2) + jasmine (~> 2.2.0) jquery-atwho-rails (~> 0.3.3) jquery-rails jquery-scrollto-rails From e15af6943ad276e9d160f786b3d58a758280c942 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 18 Apr 2015 14:01:14 -0400 Subject: [PATCH 06/80] Re-run rails g jasmine:install --- spec/javascripts/support/jasmine.yml | 54 ++++++++++++++++++++-- spec/javascripts/support/jasmine_helper.rb | 6 ++- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml index 9bfa261a356..a69c59b1837 100644 --- a/spec/javascripts/support/jasmine.yml +++ b/spec/javascripts/support/jasmine.yml @@ -25,7 +25,7 @@ src_files: # - stylesheets/*.css # stylesheets: - - stylesheets/**/*.css + - assets/application.css # helpers # @@ -38,7 +38,7 @@ stylesheets: # - helpers/**/*.js # helpers: - - helpers/**/*.js + - 'helpers/**/*.js' # spec_files # @@ -73,4 +73,52 @@ src_dir: # # spec_dir: spec/javascripts # -spec_dir: spec/javascripts +spec_dir: + +# spec_helper +# +# Ruby file that Jasmine server will require before starting. +# Returned relative to your root path +# Default spec/javascripts/support/jasmine_helper.rb +# +# EXAMPLE: +# +# spec_helper: spec/javascripts/support/jasmine_helper.rb +# +spec_helper: spec/javascripts/support/jasmine_helper.rb + +# boot_dir +# +# Boot directory path. Your boot_files must be returned relative to this path. +# Default: Built in boot file +# +# EXAMPLE: +# +# boot_dir: spec/javascripts/support/boot +# +boot_dir: + +# boot_files +# +# Return an array of filepaths relative to boot_dir to include in order to boot Jasmine +# Default: Built in boot file +# +# EXAMPLE +# +# boot_files: +# - '**/*.js' +# +boot_files: + +# rack_options +# +# Extra options to be passed to the rack server +# by default, Port and AccessLog are passed. +# +# This is an advanced options, and left empty by default +# +# EXAMPLE +# +# rack_options: +# server: 'thin' + diff --git a/spec/javascripts/support/jasmine_helper.rb b/spec/javascripts/support/jasmine_helper.rb index b4919802afe..4d73aec5a31 100644 --- a/spec/javascripts/support/jasmine_helper.rb +++ b/spec/javascripts/support/jasmine_helper.rb @@ -8,4 +8,8 @@ # config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] } #end # - +#Example: prevent PhantomJS auto install, uses PhantomJS already on your path. +#Jasmine.configure do |config| +# config.prevent_phantom_js_auto_install = true +#end +# From 0fab35217c0b5f82da0705a38697b7fab2777f15 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 18 Apr 2015 14:15:37 -0400 Subject: [PATCH 07/80] Add jasmine-rails gem --- Gemfile | 1 + Gemfile.lock | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Gemfile b/Gemfile index 5c86ad15e40..c429777777b 100644 --- a/Gemfile +++ b/Gemfile @@ -252,6 +252,7 @@ group :development, :test do gem 'poltergeist', '~> 1.5.1' gem 'jasmine', '~> 2.2.0' + gem 'jasmine-rails' gem "spring", '~> 1.3.1' gem "spring-commands-rspec", '1.0.4' diff --git a/Gemfile.lock b/Gemfile.lock index ab424c3777c..043fcbbdfcd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -298,6 +298,11 @@ GEM rack (>= 1.2.1) rake jasmine-core (2.2.0) + jasmine-rails (0.10.8) + jasmine-core (>= 1.3, < 3.0) + phantomjs (>= 1.9) + railties (>= 3.2.0) + sprockets-rails jquery-atwho-rails (0.3.3) jquery-rails (3.1.0) railties (>= 3.0, < 5.0) @@ -718,6 +723,7 @@ DEPENDENCIES html-pipeline-gitlab (~> 0.1) httparty jasmine (~> 2.2.0) + jasmine-rails jquery-atwho-rails (~> 0.3.3) jquery-rails jquery-scrollto-rails From d5c7b62b8ec2e80829746147e0fa65935120231d Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 18 Apr 2015 14:16:19 -0400 Subject: [PATCH 08/80] rails g jasmine_rails:install --- config/routes.rb | 1 + spec/javascripts/support/jasmine.yml | 156 +++++++-------------------- 2 files changed, 42 insertions(+), 115 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 4f33b11d220..d3daf9ca78a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,7 @@ require 'sidekiq/web' require 'api/api' Gitlab::Application.routes.draw do + mount JasmineRails::Engine => '/specs' if defined?(JasmineRails) use_doorkeeper do controllers applications: 'oauth/applications', authorized_applications: 'oauth/authorized_applications', diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml index a69c59b1837..b2732921919 100644 --- a/spec/javascripts/support/jasmine.yml +++ b/spec/javascripts/support/jasmine.yml @@ -1,124 +1,50 @@ -# src_files -# -# Return an array of filepaths relative to src_dir to include before jasmine specs. -# Default: [] -# -# EXAMPLE: -# -# src_files: -# - lib/source1.js -# - lib/source2.js -# - dist/**/*.js -# +# path to parent directory of src_files +# relative path from Rails.root +# defaults to app/assets/javascripts +src_dir: "app/assets/javascripts" + +# path to additional directory of source file that are not part of assets pipeline and need to be included +# relative path from Rails.root +# defaults to [] +# include_dir: +# - ../mobile_app/public/js + +# path to parent directory of css_files +# relative path from Rails.root +# defaults to app/assets/stylesheets +css_dir: "app/assets/stylesheets" + +# list of file expressions to include as source files +# relative path from src_dir src_files: - - assets/application.js + - "application.{js.coffee,js,coffee}" -# stylesheets -# -# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs. -# Default: [] -# -# EXAMPLE: -# -# stylesheets: -# - css/style.css -# - stylesheets/*.css -# -stylesheets: - - assets/application.css +# list of file expressions to include as css files +# relative path from css_dir +css_files: -# helpers +# path to parent directory of spec_files +# relative path from Rails.root # -# Return an array of filepaths relative to spec_dir to include before jasmine specs. -# Default: ["helpers/**/*.js"] -# -# EXAMPLE: -# -# helpers: -# - helpers/**/*.js +# Alternatively accept an array of directory to include external spec files +# spec_dir: +# - spec/javascripts +# - ../engine/spec/javascripts # +# defaults to spec/javascripts +spec_dir: spec/javascripts + +# list of file expressions to include as helpers into spec runner +# relative path from spec_dir helpers: - - 'helpers/**/*.js' + - "helpers/**/*.{js.coffee,js,coffee}" -# spec_files -# -# Return an array of filepaths relative to spec_dir to include. -# Default: ["**/*[sS]pec.js"] -# -# EXAMPLE: -# -# spec_files: -# - **/*[sS]pec.js -# +# list of file expressions to include as specs into spec runner +# relative path from spec_dir spec_files: - - '**/*[sS]pec.js' - -# src_dir -# -# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank. -# Default: project root -# -# EXAMPLE: -# -# src_dir: public -# -src_dir: - -# spec_dir -# -# Spec directory path. Your spec_files must be returned relative to this path. -# Default: spec/javascripts -# -# EXAMPLE: -# -# spec_dir: spec/javascripts -# -spec_dir: - -# spec_helper -# -# Ruby file that Jasmine server will require before starting. -# Returned relative to your root path -# Default spec/javascripts/support/jasmine_helper.rb -# -# EXAMPLE: -# -# spec_helper: spec/javascripts/support/jasmine_helper.rb -# -spec_helper: spec/javascripts/support/jasmine_helper.rb - -# boot_dir -# -# Boot directory path. Your boot_files must be returned relative to this path. -# Default: Built in boot file -# -# EXAMPLE: -# -# boot_dir: spec/javascripts/support/boot -# -boot_dir: - -# boot_files -# -# Return an array of filepaths relative to boot_dir to include in order to boot Jasmine -# Default: Built in boot file -# -# EXAMPLE -# -# boot_files: -# - '**/*.js' -# -boot_files: - -# rack_options -# -# Extra options to be passed to the rack server -# by default, Port and AccessLog are passed. -# -# This is an advanced options, and left empty by default -# -# EXAMPLE -# -# rack_options: -# server: 'thin' + - "**/*[Ss]pec.{js.coffee,js,coffee}" +# path to directory of temporary files +# (spec runner and asset cache) +# defaults to tmp/jasmine +tmp_dir: "tmp/jasmine" From 662bdfbeb12883944075d3e038ea58af45f3df3a Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 18 Apr 2015 14:25:54 -0400 Subject: [PATCH 09/80] Make StatGraph JS explicitly require its dependencies This allows us to test them in a bit more isolation. --- app/assets/javascripts/stat_graph_contributors.js.coffee | 4 ++++ .../javascripts/stat_graph_contributors_graph.js.coffee | 4 ++++ spec/javascripts/stat_graph_contributors_graph_spec.js | 2 ++ spec/javascripts/stat_graph_contributors_util_spec.js | 2 ++ spec/javascripts/stat_graph_spec.js | 2 ++ 5 files changed, 14 insertions(+) diff --git a/app/assets/javascripts/stat_graph_contributors.js.coffee b/app/assets/javascripts/stat_graph_contributors.js.coffee index 27f0fd31d50..ed12bdcef22 100644 --- a/app/assets/javascripts/stat_graph_contributors.js.coffee +++ b/app/assets/javascripts/stat_graph_contributors.js.coffee @@ -1,3 +1,7 @@ +#= require d3 +#= require jquery +#= require stat_graph_contributors_util + class @ContributorsStatGraph init: (log) -> @parsed_log = ContributorsStatGraphUtil.parse_log(log) diff --git a/app/assets/javascripts/stat_graph_contributors_graph.js.coffee b/app/assets/javascripts/stat_graph_contributors_graph.js.coffee index 8b82d20c6c2..0e6fbdef3bc 100644 --- a/app/assets/javascripts/stat_graph_contributors_graph.js.coffee +++ b/app/assets/javascripts/stat_graph_contributors_graph.js.coffee @@ -1,3 +1,7 @@ +#= require d3 +#= require jquery +#= require underscore + class @ContributorsGraph MARGIN: top: 20 diff --git a/spec/javascripts/stat_graph_contributors_graph_spec.js b/spec/javascripts/stat_graph_contributors_graph_spec.js index 1090cb7f620..78d39f1b428 100644 --- a/spec/javascripts/stat_graph_contributors_graph_spec.js +++ b/spec/javascripts/stat_graph_contributors_graph_spec.js @@ -1,3 +1,5 @@ +//= require stat_graph_contributors_graph + describe("ContributorsGraph", function () { describe("#set_x_domain", function () { it("set the x_domain", function () { diff --git a/spec/javascripts/stat_graph_contributors_util_spec.js b/spec/javascripts/stat_graph_contributors_util_spec.js index 9c1b588861d..ee90892eb48 100644 --- a/spec/javascripts/stat_graph_contributors_util_spec.js +++ b/spec/javascripts/stat_graph_contributors_util_spec.js @@ -1,3 +1,5 @@ +//= require stat_graph_contributors_util + describe("ContributorsStatGraphUtil", function () { describe("#parse_log", function () { diff --git a/spec/javascripts/stat_graph_spec.js b/spec/javascripts/stat_graph_spec.js index b589af34610..4c652910cd6 100644 --- a/spec/javascripts/stat_graph_spec.js +++ b/spec/javascripts/stat_graph_spec.js @@ -1,3 +1,5 @@ +//= require stat_graph + describe("StatGraph", function () { describe("#get_log", function () { From ded7053fbf23dfba167f1d69102be482749a901e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 18 Apr 2015 15:15:23 -0400 Subject: [PATCH 10/80] Simplify jasmine.yml since we're using jasmine-rails gem A lot of these values are handled by the asset pipeline. --- spec/javascripts/support/jasmine.yml | 30 ---------------------------- 1 file changed, 30 deletions(-) diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml index b2732921919..f4b01c9f27a 100644 --- a/spec/javascripts/support/jasmine.yml +++ b/spec/javascripts/support/jasmine.yml @@ -1,28 +1,3 @@ -# path to parent directory of src_files -# relative path from Rails.root -# defaults to app/assets/javascripts -src_dir: "app/assets/javascripts" - -# path to additional directory of source file that are not part of assets pipeline and need to be included -# relative path from Rails.root -# defaults to [] -# include_dir: -# - ../mobile_app/public/js - -# path to parent directory of css_files -# relative path from Rails.root -# defaults to app/assets/stylesheets -css_dir: "app/assets/stylesheets" - -# list of file expressions to include as source files -# relative path from src_dir -src_files: - - "application.{js.coffee,js,coffee}" - -# list of file expressions to include as css files -# relative path from css_dir -css_files: - # path to parent directory of spec_files # relative path from Rails.root # @@ -43,8 +18,3 @@ helpers: # relative path from spec_dir spec_files: - "**/*[Ss]pec.{js.coffee,js,coffee}" - -# path to directory of temporary files -# (spec runner and asset cache) -# defaults to tmp/jasmine -tmp_dir: "tmp/jasmine" From 4603bf500ae58ef4af9061ce20b7b33d03dcc783 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 11 Apr 2015 18:30:19 -0400 Subject: [PATCH 11/80] Add 'reply' hotkey to help modal --- app/views/help/_shortcuts.html.haml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml index fdeab909b76..ae072bacfb1 100644 --- a/app/views/help/_shortcuts.html.haml +++ b/app/views/help/_shortcuts.html.haml @@ -187,6 +187,10 @@ %td.shortcut .key m %td Change milestone + %tr + %td.shortcut + .key r + %td Reply (quoting selected text) %tbody{ class: 'hidden-shortcut merge_requests', style: 'display:none' } %tr %th @@ -199,6 +203,10 @@ %td.shortcut .key m %td Change milestone + %tr + %td.shortcut + .key r + %td Reply (quoting selected text) :javascript From ca5d0c82509cedb94f9bfa4a40e77706a58faafe Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 11 Apr 2015 18:32:24 -0400 Subject: [PATCH 12/80] Add hotkey for "reply with selected text" to Issueable --- .../javascripts/shortcuts_issueable.coffee | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/shortcuts_issueable.coffee b/app/assets/javascripts/shortcuts_issueable.coffee index f2d30eb364d..f645d4ae515 100644 --- a/app/assets/javascripts/shortcuts_issueable.coffee +++ b/app/assets/javascripts/shortcuts_issueable.coffee @@ -11,9 +11,35 @@ class @ShortcutsIssueable extends ShortcutsNavigation $('.js-milestone').select2('open') return false ) - + Mousetrap.bind('r', => + @replyWithSelectedText() + return false + ) + if isMergeRequest @enabledHelp.push('.hidden-shortcut.merge_requests') else @enabledHelp.push('.hidden-shortcut.issues') + replyWithSelectedText: -> + if window.getSelection + selected = window.getSelection().toString() + replyField = $('.js-main-target-form #note_note') + + return if selected.trim() == "" + + # Put a '>' character before each non-empty line in the selection + quote = _.map selected.split("\n"), (val) -> + "> #{val}\n" if val.trim() != '' + + # If replyField already has some content, add a newline before our quote + separator = replyField.val().trim() != "" and "\n" or '' + + replyField.val (_, current) -> + current + separator + quote.join('') + "\n" + + # Trigger autosave for the added text + replyField.trigger('input') + + # Focus the input field + replyField.focus() From 8e6fa2555ec37f010ac93b43816d8bcdb3ee835c Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 18 Apr 2015 15:16:05 -0400 Subject: [PATCH 13/80] Add JS specs for replyWithSelectedText --- .../javascripts/shortcuts_issueable.coffee | 3 + .../shortcuts_issueable_spec.js.coffee | 83 ++++ vendor/assets/javascripts/jasmine-fixture.js | 433 ++++++++++++++++++ 3 files changed, 519 insertions(+) create mode 100644 spec/javascripts/shortcuts_issueable_spec.js.coffee create mode 100644 vendor/assets/javascripts/jasmine-fixture.js diff --git a/app/assets/javascripts/shortcuts_issueable.coffee b/app/assets/javascripts/shortcuts_issueable.coffee index f645d4ae515..939004cbf76 100644 --- a/app/assets/javascripts/shortcuts_issueable.coffee +++ b/app/assets/javascripts/shortcuts_issueable.coffee @@ -1,3 +1,6 @@ +#= require jquery +#= require mousetrap + #= require shortcuts_navigation class @ShortcutsIssueable extends ShortcutsNavigation diff --git a/spec/javascripts/shortcuts_issueable_spec.js.coffee b/spec/javascripts/shortcuts_issueable_spec.js.coffee new file mode 100644 index 00000000000..5f206ddfda6 --- /dev/null +++ b/spec/javascripts/shortcuts_issueable_spec.js.coffee @@ -0,0 +1,83 @@ +#= require jquery +#= require jasmine-fixture + +#= require shortcuts_issueable + +describe 'ShortcutsIssueable', -> + beforeEach -> + @shortcut = new ShortcutsIssueable() + + describe '#replyWithSelectedText', -> + # Stub window.getSelection to return the provided String. + stubSelection = (text) -> + window.getSelection = -> text + + beforeEach -> + @selector = 'form.js-main-target-form textarea#note_note' + affix(@selector) + + describe 'with empty selection', -> + it 'does nothing', -> + stubSelection('') + @shortcut.replyWithSelectedText() + expect($(@selector).val()).toBe('') + + describe 'with any selection', -> + beforeEach -> + stubSelection('Selected text.') + + it 'leaves existing input intact', -> + $(@selector).val('This text was already here.') + expect($(@selector).val()).toBe('This text was already here.') + + @shortcut.replyWithSelectedText() + expect($(@selector).val()). + toBe("This text was already here.\n> Selected text.\n\n") + + it 'triggers `input`', -> + triggered = false + $(@selector).on 'input', -> triggered = true + @shortcut.replyWithSelectedText() + + expect(triggered).toBe(true) + + it 'triggers `focus`', -> + focused = false + $(@selector).on 'focus', -> focused = true + @shortcut.replyWithSelectedText() + + expect(focused).toBe(true) + + describe 'with a one-line selection', -> + it 'quotes the selection', -> + stubSelection('This text has been selected.') + + @shortcut.replyWithSelectedText() + + expect($(@selector).val()). + toBe("> This text has been selected.\n\n") + + describe 'with a multi-line selection', -> + it 'quotes the selected lines as a group', -> + stubSelection( + """ + Selected line one. + + Selected line two. + Selected line three. + + """ + ) + + @shortcut.replyWithSelectedText() + + expect($(@selector).val()). + toBe( + """ + > Selected line one. + > Selected line two. + > Selected line three. + + + """ + ) diff --git a/vendor/assets/javascripts/jasmine-fixture.js b/vendor/assets/javascripts/jasmine-fixture.js new file mode 100644 index 00000000000..3815731fd2f --- /dev/null +++ b/vendor/assets/javascripts/jasmine-fixture.js @@ -0,0 +1,433 @@ +/* jasmine-fixture - 1.2.2 + * Makes injecting HTML snippets into the DOM easy & clean! + * https://github.com/searls/jasmine-fixture + */ +(function() { + var createHTMLBlock, + __slice = [].slice; + + (function($) { + var ewwSideEffects, jasmineFixture, originalAffix, originalJasmineDotFixture, originalJasmineFixture, root, _, _ref; + root = this; + originalJasmineFixture = root.jasmineFixture; + originalJasmineDotFixture = (_ref = root.jasmine) != null ? _ref.fixture : void 0; + originalAffix = root.affix; + _ = function(list) { + return { + inject: function(iterator, memo) { + var item, _i, _len, _results; + _results = []; + for (_i = 0, _len = list.length; _i < _len; _i++) { + item = list[_i]; + _results.push(memo = iterator(memo, item)); + } + return _results; + } + }; + }; + root.jasmineFixture = function($) { + var $whatsTheRootOf, affix, create, jasmineFixture, noConflict; + affix = function(selectorOptions) { + return create.call(this, selectorOptions, true); + }; + create = function(selectorOptions, attach) { + var $top; + $top = null; + _(selectorOptions.split(/[ ](?=[^\]]*?(?:\[|$))/)).inject(function($parent, elementSelector) { + var $el; + if (elementSelector === ">") { + return $parent; + } + $el = createHTMLBlock($, elementSelector); + if (attach || $top) { + $el.appendTo($parent); + } + $top || ($top = $el); + return $el; + }, $whatsTheRootOf(this)); + return $top; + }; + noConflict = function() { + var currentJasmineFixture, _ref1; + currentJasmineFixture = jasmine.fixture; + root.jasmineFixture = originalJasmineFixture; + if ((_ref1 = root.jasmine) != null) { + _ref1.fixture = originalJasmineDotFixture; + } + root.affix = originalAffix; + return currentJasmineFixture; + }; + $whatsTheRootOf = function(that) { + if (that.jquery != null) { + return that; + } else if ($('#jasmine_content').length > 0) { + return $('#jasmine_content'); + } else { + return $('
').appendTo('body'); + } + }; + jasmineFixture = { + affix: affix, + create: create, + noConflict: noConflict + }; + ewwSideEffects(jasmineFixture); + return jasmineFixture; + }; + ewwSideEffects = function(jasmineFixture) { + var _ref1; + if ((_ref1 = root.jasmine) != null) { + _ref1.fixture = jasmineFixture; + } + $.fn.affix = root.affix = jasmineFixture.affix; + return afterEach(function() { + return $('#jasmine_content').remove(); + }); + }; + if ($) { + return jasmineFixture = root.jasmineFixture($); + } else { + return root.affix = function() { + var nowJQueryExists; + nowJQueryExists = window.jQuery || window.$; + if (nowJQueryExists != null) { + jasmineFixture = root.jasmineFixture(nowJQueryExists); + return affix.call.apply(affix, [this].concat(__slice.call(arguments))); + } else { + throw new Error("jasmine-fixture requires jQuery to be defined at window.jQuery or window.$"); + } + }; + } + })(window.jQuery || window.$); + + createHTMLBlock = (function() { + var bindData, bindEvents, parseAttributes, parseClasses, parseContents, parseEnclosure, parseReferences, parseVariableScope, regAttr, regAttrDfn, regAttrs, regCBrace, regClass, regClasses, regData, regDatas, regEvent, regEvents, regExclamation, regId, regReference, regTag, regTagNotContent, regZenTagDfn; + createHTMLBlock = function($, ZenObject, data, functions, indexes) { + var ZenCode, arr, block, blockAttrs, blockClasses, blockHTML, blockId, blockTag, blocks, el, el2, els, forScope, indexName, inner, len, obj, origZenCode, paren, result, ret, zc, zo; + if ($.isPlainObject(ZenObject)) { + ZenCode = ZenObject.main; + } else { + ZenCode = ZenObject; + ZenObject = { + main: ZenCode + }; + } + origZenCode = ZenCode; + if (indexes === undefined) { + indexes = {}; + } + if (ZenCode.charAt(0) === "!" || $.isArray(data)) { + if ($.isArray(data)) { + forScope = ZenCode; + } else { + obj = parseEnclosure(ZenCode, "!"); + obj = obj.substring(obj.indexOf(":") + 1, obj.length - 1); + forScope = parseVariableScope(ZenCode); + } + while (forScope.charAt(0) === "@") { + forScope = parseVariableScope("!for:!" + parseReferences(forScope, ZenObject)); + } + zo = ZenObject; + zo.main = forScope; + el = $(); + if (ZenCode.substring(0, 5) === "!for:" || $.isArray(data)) { + if (!$.isArray(data) && obj.indexOf(":") > 0) { + indexName = obj.substring(0, obj.indexOf(":")); + obj = obj.substr(obj.indexOf(":") + 1); + } + arr = ($.isArray(data) ? data : data[obj]); + zc = zo.main; + if ($.isArray(arr) || $.isPlainObject(arr)) { + $.map(arr, function(value, index) { + var next; + zo.main = zc; + if (indexName !== undefined) { + indexes[indexName] = index; + } + if (!$.isPlainObject(value)) { + value = { + value: value + }; + } + next = createHTMLBlock($, zo, value, functions, indexes); + if (el.length !== 0) { + return $.each(next, function(index, value) { + return el.push(value); + }); + } + }); + } + if (!$.isArray(data)) { + ZenCode = ZenCode.substr(obj.length + 6 + forScope.length); + } else { + ZenCode = ""; + } + } else if (ZenCode.substring(0, 4) === "!if:") { + result = parseContents("!" + obj + "!", data, indexes); + if (result !== "undefined" || result !== "false" || result !== "") { + el = createHTMLBlock($, zo, data, functions, indexes); + } + ZenCode = ZenCode.substr(obj.length + 5 + forScope.length); + } + ZenObject.main = ZenCode; + } else if (ZenCode.charAt(0) === "(") { + paren = parseEnclosure(ZenCode, "(", ")"); + inner = paren.substring(1, paren.length - 1); + ZenCode = ZenCode.substr(paren.length); + zo = ZenObject; + zo.main = inner; + el = createHTMLBlock($, zo, data, functions, indexes); + } else { + blocks = ZenCode.match(regZenTagDfn); + block = blocks[0]; + if (block.length === 0) { + return ""; + } + if (block.indexOf("@") >= 0) { + ZenCode = parseReferences(ZenCode, ZenObject); + zo = ZenObject; + zo.main = ZenCode; + return createHTMLBlock($, zo, data, functions, indexes); + } + block = parseContents(block, data, indexes); + blockClasses = parseClasses($, block); + if (regId.test(block)) { + blockId = regId.exec(block)[1]; + } + blockAttrs = parseAttributes(block, data); + blockTag = (block.charAt(0) === "{" ? "span" : "div"); + if (ZenCode.charAt(0) !== "#" && ZenCode.charAt(0) !== "." && ZenCode.charAt(0) !== "{") { + blockTag = regTag.exec(block)[1]; + } + if (block.search(regCBrace) !== -1) { + blockHTML = block.match(regCBrace)[1]; + } + blockAttrs = $.extend(blockAttrs, { + id: blockId, + "class": blockClasses, + html: blockHTML + }); + el = $("<" + blockTag + ">", blockAttrs); + el.attr(blockAttrs); + el = bindEvents(block, el, functions); + el = bindData(block, el, data); + ZenCode = ZenCode.substr(blocks[0].length); + ZenObject.main = ZenCode; + } + if (ZenCode.length > 0) { + if (ZenCode.charAt(0) === ">") { + if (ZenCode.charAt(1) === "(") { + zc = parseEnclosure(ZenCode.substr(1), "(", ")"); + ZenCode = ZenCode.substr(zc.length + 1); + } else if (ZenCode.charAt(1) === "!") { + obj = parseEnclosure(ZenCode.substr(1), "!"); + forScope = parseVariableScope(ZenCode.substr(1)); + zc = obj + forScope; + ZenCode = ZenCode.substr(zc.length + 1); + } else { + len = Math.max(ZenCode.indexOf("+"), ZenCode.length); + zc = ZenCode.substring(1, len); + ZenCode = ZenCode.substr(len); + } + zo = ZenObject; + zo.main = zc; + els = $(createHTMLBlock($, zo, data, functions, indexes)); + els.appendTo(el); + } + if (ZenCode.charAt(0) === "+") { + zo = ZenObject; + zo.main = ZenCode.substr(1); + el2 = createHTMLBlock($, zo, data, functions, indexes); + $.each(el2, function(index, value) { + return el.push(value); + }); + } + } + ret = el; + return ret; + }; + bindData = function(ZenCode, el, data) { + var datas, i, split; + if (ZenCode.search(regDatas) === 0) { + return el; + } + datas = ZenCode.match(regDatas); + if (datas === null) { + return el; + } + i = 0; + while (i < datas.length) { + split = regData.exec(datas[i]); + if (split[3] === undefined) { + $(el).data(split[1], data[split[1]]); + } else { + $(el).data(split[1], data[split[3]]); + } + i++; + } + return el; + }; + bindEvents = function(ZenCode, el, functions) { + var bindings, fn, i, split; + if (ZenCode.search(regEvents) === 0) { + return el; + } + bindings = ZenCode.match(regEvents); + if (bindings === null) { + return el; + } + i = 0; + while (i < bindings.length) { + split = regEvent.exec(bindings[i]); + if (split[2] === undefined) { + fn = functions[split[1]]; + } else { + fn = functions[split[2]]; + } + $(el).bind(split[1], fn); + i++; + } + return el; + }; + parseAttributes = function(ZenBlock, data) { + var attrStrs, attrs, i, parts; + if (ZenBlock.search(regAttrDfn) === -1) { + return undefined; + } + attrStrs = ZenBlock.match(regAttrDfn); + attrs = {}; + i = 0; + while (i < attrStrs.length) { + parts = regAttr.exec(attrStrs[i]); + attrs[parts[1]] = ""; + if (parts[3] !== undefined) { + attrs[parts[1]] = parseContents(parts[3], data); + } + i++; + } + return attrs; + }; + parseClasses = function($, ZenBlock) { + var classes, clsString, i; + ZenBlock = ZenBlock.match(regTagNotContent)[0]; + if (ZenBlock.search(regClasses) === -1) { + return undefined; + } + classes = ZenBlock.match(regClasses); + clsString = ""; + i = 0; + while (i < classes.length) { + clsString += " " + regClass.exec(classes[i])[1]; + i++; + } + return $.trim(clsString); + }; + parseContents = function(ZenBlock, data, indexes) { + var html; + if (indexes === undefined) { + indexes = {}; + } + html = ZenBlock; + if (data === undefined) { + return html; + } + while (regExclamation.test(html)) { + html = html.replace(regExclamation, function(str, str2) { + var begChar, fn, val; + begChar = ""; + if (str.indexOf("!for:") > 0 || str.indexOf("!if:") > 0) { + return str; + } + if (str.charAt(0) !== "!") { + begChar = str.charAt(0); + str = str.substring(2, str.length - 1); + } + fn = new Function("data", "indexes", "var r=undefined;" + "with(data){try{r=" + str + ";}catch(e){}}" + "with(indexes){try{if(r===undefined)r=" + str + ";}catch(e){}}" + "return r;"); + val = unescape(fn(data, indexes)); + return begChar + val; + }); + } + html = html.replace(/\\./g, function(str) { + return str.charAt(1); + }); + return unescape(html); + }; + parseEnclosure = function(ZenCode, open, close, count) { + var index, ret; + if (close === undefined) { + close = open; + } + index = 1; + if (count === undefined) { + count = (ZenCode.charAt(0) === open ? 1 : 0); + } + if (count === 0) { + return; + } + while (count > 0 && index < ZenCode.length) { + if (ZenCode.charAt(index) === close && ZenCode.charAt(index - 1) !== "\\") { + count--; + } else { + if (ZenCode.charAt(index) === open && ZenCode.charAt(index - 1) !== "\\") { + count++; + } + } + index++; + } + ret = ZenCode.substring(0, index); + return ret; + }; + parseReferences = function(ZenCode, ZenObject) { + ZenCode = ZenCode.replace(regReference, function(str) { + var fn; + str = str.substr(1); + fn = new Function("objs", "var r=\"\";" + "with(objs){try{" + "r=" + str + ";" + "}catch(e){}}" + "return r;"); + return fn(ZenObject, parseReferences); + }); + return ZenCode; + }; + parseVariableScope = function(ZenCode) { + var forCode, rest, tag; + if (ZenCode.substring(0, 5) !== "!for:" && ZenCode.substring(0, 4) !== "!if:") { + return undefined; + } + forCode = parseEnclosure(ZenCode, "!"); + ZenCode = ZenCode.substr(forCode.length); + if (ZenCode.charAt(0) === "(") { + return parseEnclosure(ZenCode, "(", ")"); + } + tag = ZenCode.match(regZenTagDfn)[0]; + ZenCode = ZenCode.substr(tag.length); + if (ZenCode.length === 0 || ZenCode.charAt(0) === "+") { + return tag; + } else if (ZenCode.charAt(0) === ">") { + rest = ""; + rest = parseEnclosure(ZenCode.substr(1), "(", ")", 1); + return tag + ">" + rest; + } + return undefined; + }; + regZenTagDfn = /([#\.\@]?[\w-]+|\[([\w-!?=:"']+(="([^"]|\\")+")? {0,})+\]|\~[\w$]+=[\w$]+|&[\w$]+(=[\w$]+)?|[#\.\@]?!([^!]|\\!)+!){0,}(\{([^\}]|\\\})+\})?/i; + regTag = /(\w+)/i; + regId = /(?:^|\b)#([\w-!]+)/i; + regTagNotContent = /((([#\.]?[\w-]+)?(\[([\w!]+(="([^"]|\\")+")? {0,})+\])?)+)/i; + /* + See lookahead syntax (?!) at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp + */ + + regClasses = /(\.[\w-]+)(?!["\w])/g; + regClass = /\.([\w-]+)/i; + regReference = /(@[\w$_][\w$_\d]+)/i; + regAttrDfn = /(\[([\w-!]+(="?([^"]|\\")+"?)? {0,})+\])/ig; + regAttrs = /([\w-!]+(="([^"]|\\")+")?)/g; + regAttr = /([\w-!]+)(="?((([\w]+(\[.*?\])+)|[^"\]]|\\")+)"?)?/i; + regCBrace = /\{(([^\}]|\\\})+)\}/i; + regExclamation = /(?:([^\\]|^))!([^!]|\\!)+!/g; + regEvents = /\~[\w$]+(=[\w$]+)?/g; + regEvent = /\~([\w$]+)=([\w$]+)/i; + regDatas = /&[\w$]+(=[\w$]+)?/g; + regData = /&([\w$]+)(=([\w$]+))?/i; + return createHTMLBlock; + })(); + +}).call(this); From 4d1878253e228db55485dae9e4ad66aebe009040 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 18 Apr 2015 15:20:15 -0400 Subject: [PATCH 14/80] Typo: Issueable -> Issuable --- app/assets/javascripts/application.js.coffee | 2 +- app/assets/javascripts/dispatcher.js.coffee | 4 ++-- ...shortcuts_issueable.coffee => shortcuts_issuable.coffee} | 2 +- ...ble_spec.js.coffee => shortcuts_issuable_spec.js.coffee} | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) rename app/assets/javascripts/{shortcuts_issueable.coffee => shortcuts_issuable.coffee} (95%) rename spec/javascripts/{shortcuts_issueable_spec.js.coffee => shortcuts_issuable_spec.js.coffee} (95%) diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index bd52d3d4d70..1a71f853b4d 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -38,7 +38,7 @@ #= require shortcuts #= require shortcuts_navigation #= require shortcuts_dashboard_navigation -#= require shortcuts_issueable +#= require shortcuts_issuable #= require shortcuts_network #= require cal-heatmap #= require_tree . diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index 330ebac6f75..9aee3b281f3 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -22,7 +22,7 @@ class Dispatcher shortcut_handler = new ShortcutsNavigation() when 'projects:issues:show' new Issue() - shortcut_handler = new ShortcutsIssueable() + shortcut_handler = new ShortcutsIssuable() new ZenMode() when 'projects:milestones:show' new Milestone() @@ -47,7 +47,7 @@ class Dispatcher new IssuableForm($('.merge-request-form')) when 'projects:merge_requests:show' new Diff() - shortcut_handler = new ShortcutsIssueable() + shortcut_handler = new ShortcutsIssuable() new ZenMode() when "projects:merge_requests:diffs" new Diff() diff --git a/app/assets/javascripts/shortcuts_issueable.coffee b/app/assets/javascripts/shortcuts_issuable.coffee similarity index 95% rename from app/assets/javascripts/shortcuts_issueable.coffee rename to app/assets/javascripts/shortcuts_issuable.coffee index 939004cbf76..6b534f29218 100644 --- a/app/assets/javascripts/shortcuts_issueable.coffee +++ b/app/assets/javascripts/shortcuts_issuable.coffee @@ -3,7 +3,7 @@ #= require shortcuts_navigation -class @ShortcutsIssueable extends ShortcutsNavigation +class @ShortcutsIssuable extends ShortcutsNavigation constructor: (isMergeRequest) -> super() Mousetrap.bind('a', -> diff --git a/spec/javascripts/shortcuts_issueable_spec.js.coffee b/spec/javascripts/shortcuts_issuable_spec.js.coffee similarity index 95% rename from spec/javascripts/shortcuts_issueable_spec.js.coffee rename to spec/javascripts/shortcuts_issuable_spec.js.coffee index 5f206ddfda6..57dcc2161d3 100644 --- a/spec/javascripts/shortcuts_issueable_spec.js.coffee +++ b/spec/javascripts/shortcuts_issuable_spec.js.coffee @@ -1,11 +1,11 @@ #= require jquery #= require jasmine-fixture -#= require shortcuts_issueable +#= require shortcuts_issuable -describe 'ShortcutsIssueable', -> +describe 'ShortcutsIssuable', -> beforeEach -> - @shortcut = new ShortcutsIssueable() + @shortcut = new ShortcutsIssuable() describe '#replyWithSelectedText', -> # Stub window.getSelection to return the provided String. From 3ae0b8853b6f1169e0341c091d8a4e1b13aac3ad Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 18 Apr 2015 18:49:33 -0400 Subject: [PATCH 15/80] Add changelog entry [ci skip] --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index adcc3b96d11..508025a3f57 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,7 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 7.11.0 (unreleased) - Fix clone URL field and X11 Primary selection (Dmitry Medvinsky) - Ignore invalid lines in .gitmodules - - + - Add "Reply quoting selected text" shortcut key (`r`) - - - From 5a4ebfb47af40de6cfe29fe59dae82f8c244e5e3 Mon Sep 17 00:00:00 2001 From: Jeroen van Baarsen Date: Thu, 16 Apr 2015 14:03:37 +0200 Subject: [PATCH 16/80] Fixed the Rails/ActionFilter cop Signed-off-by: Jeroen van Baarsen --- .rubocop.yml | 2 +- .../admin/application_controller.rb | 2 +- .../admin/application_settings_controller.rb | 2 +- .../admin/broadcast_messages_controller.rb | 2 +- .../admin/deploy_keys_controller.rb | 6 +++--- app/controllers/admin/groups_controller.rb | 2 +- app/controllers/admin/keys_controller.rb | 2 +- app/controllers/admin/projects_controller.rb | 6 +++--- app/controllers/admin/services_controller.rb | 2 +- app/controllers/admin/users_controller.rb | 2 +- app/controllers/application_controller.rb | 18 +++++++++--------- .../dashboard/milestones_controller.rb | 2 +- .../dashboard/projects_controller.rb | 2 +- app/controllers/dashboard_controller.rb | 4 ++-- app/controllers/explore/groups_controller.rb | 2 +- app/controllers/explore/projects_controller.rb | 2 +- .../groups/group_members_controller.rb | 12 ++++++------ .../groups/milestones_controller.rb | 2 +- app/controllers/groups_controller.rb | 16 ++++++++-------- app/controllers/import/bitbucket_controller.rb | 12 ++++++------ app/controllers/import/github_controller.rb | 6 +++--- app/controllers/import/gitlab_controller.rb | 8 ++++---- .../import/google_code_controller.rb | 6 +++--- app/controllers/invites_controller.rb | 8 ++++---- app/controllers/namespaces_controller.rb | 2 +- .../oauth/applications_controller.rb | 4 ++-- .../oauth/authorizations_controller.rb | 2 +- app/controllers/profiles/keys_controller.rb | 2 +- .../profiles/passwords_controller.rb | 8 ++++---- app/controllers/profiles_controller.rb | 6 +++--- .../projects/application_controller.rb | 4 ++-- app/controllers/projects/avatars_controller.rb | 2 +- app/controllers/projects/blame_controller.rb | 6 +++--- app/controllers/projects/blob_controller.rb | 18 +++++++++--------- .../projects/branches_controller.rb | 6 +++--- app/controllers/projects/commit_controller.rb | 6 +++--- app/controllers/projects/commits_controller.rb | 6 +++--- app/controllers/projects/compare_controller.rb | 4 ++-- .../projects/deploy_keys_controller.rb | 2 +- app/controllers/projects/forks_controller.rb | 4 ++-- app/controllers/projects/graphs_controller.rb | 4 ++-- app/controllers/projects/hooks_controller.rb | 2 +- app/controllers/projects/imports_controller.rb | 6 +++--- app/controllers/projects/issues_controller.rb | 14 +++++++------- app/controllers/projects/labels_controller.rb | 8 ++++---- .../projects/merge_requests_controller.rb | 18 +++++++++--------- .../projects/milestones_controller.rb | 8 ++++---- app/controllers/projects/network_controller.rb | 6 +++--- app/controllers/projects/notes_controller.rb | 8 ++++---- .../projects/project_members_controller.rb | 6 +++--- .../projects/protected_branches_controller.rb | 4 ++-- app/controllers/projects/raw_controller.rb | 6 +++--- app/controllers/projects/refs_controller.rb | 6 +++--- .../projects/repositories_controller.rb | 6 +++--- .../projects/services_controller.rb | 4 ++-- .../projects/snippets_controller.rb | 12 ++++++------ app/controllers/projects/tags_controller.rb | 8 ++++---- app/controllers/projects/tree_controller.rb | 6 +++--- app/controllers/projects/uploads_controller.rb | 8 ++++---- app/controllers/projects/wikis_controller.rb | 8 ++++---- app/controllers/projects_controller.rb | 12 ++++++------ app/controllers/registrations_controller.rb | 2 +- app/controllers/snippets_controller.rb | 10 +++++----- app/controllers/uploads_controller.rb | 6 +++--- app/controllers/users_controller.rb | 4 ++-- db/schema.rb | 2 +- 66 files changed, 197 insertions(+), 197 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 03b78d68840..0cc729d3b08 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -954,7 +954,7 @@ Lint/Void: Rails/ActionFilter: Description: 'Enforces consistent use of action filter methods.' - Enabled: false + Enabled: true Rails/DefaultScope: Description: 'Checks if the argument passed to default_scope is a block.' diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb index 6a8f20f6047..fe5456f820c 100644 --- a/app/controllers/admin/application_controller.rb +++ b/app/controllers/admin/application_controller.rb @@ -3,7 +3,7 @@ # Automatically sets the layout and ensures an administrator is logged in class Admin::ApplicationController < ApplicationController layout 'admin' - before_filter :authenticate_admin! + before_action :authenticate_admin! def authenticate_admin! return render_404 unless current_user.is_admin? diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index b5fda196bf0..e9757676908 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -1,5 +1,5 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController - before_filter :set_application_setting + before_action :set_application_setting def show end diff --git a/app/controllers/admin/broadcast_messages_controller.rb b/app/controllers/admin/broadcast_messages_controller.rb index e1643bb34bf..0808024fc39 100644 --- a/app/controllers/admin/broadcast_messages_controller.rb +++ b/app/controllers/admin/broadcast_messages_controller.rb @@ -1,5 +1,5 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController - before_filter :broadcast_messages + before_action :broadcast_messages def index @broadcast_message = BroadcastMessage.new diff --git a/app/controllers/admin/deploy_keys_controller.rb b/app/controllers/admin/deploy_keys_controller.rb index e93603bef36..c301e61d1c7 100644 --- a/app/controllers/admin/deploy_keys_controller.rb +++ b/app/controllers/admin/deploy_keys_controller.rb @@ -1,13 +1,13 @@ class Admin::DeployKeysController < Admin::ApplicationController - before_filter :deploy_keys, only: [:index] - before_filter :deploy_key, only: [:show, :destroy] + before_action :deploy_keys, only: [:index] + before_action :deploy_key, only: [:show, :destroy] def index end def show - + end def new diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 22d045fc388..2dfae13ac5c 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -1,5 +1,5 @@ class Admin::GroupsController < Admin::ApplicationController - before_filter :group, only: [:edit, :show, :update, :destroy, :project_update, :members_update] + before_action :group, only: [:edit, :show, :update, :destroy, :project_update, :members_update] def index @groups = Group.all diff --git a/app/controllers/admin/keys_controller.rb b/app/controllers/admin/keys_controller.rb index 21111bb44f5..cb33fdd9763 100644 --- a/app/controllers/admin/keys_controller.rb +++ b/app/controllers/admin/keys_controller.rb @@ -1,5 +1,5 @@ class Admin::KeysController < Admin::ApplicationController - before_filter :user, only: [:show, :destroy] + before_action :user, only: [:show, :destroy] def show @key = user.keys.find(params[:id]) diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index 5176a8399ae..ee449badf59 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -1,7 +1,7 @@ class Admin::ProjectsController < Admin::ApplicationController - before_filter :project, only: [:show, :transfer] - before_filter :group, only: [:show, :transfer] - before_filter :repository, only: [:show, :transfer] + before_action :project, only: [:show, :transfer] + before_action :group, only: [:show, :transfer] + before_action :repository, only: [:show, :transfer] def index @projects = Project.all diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb index 76a938c5fe4..c1fdcd7fab6 100644 --- a/app/controllers/admin/services_controller.rb +++ b/app/controllers/admin/services_controller.rb @@ -1,5 +1,5 @@ class Admin::ServicesController < Admin::ApplicationController - before_filter :service, only: [:edit, :update] + before_action :service, only: [:edit, :update] def index @services = services_templates diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index b4c011f213c..adb83996f8b 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,5 +1,5 @@ class Admin::UsersController < Admin::ApplicationController - before_filter :user, only: [:show, :edit, :update, :destroy] + before_action :user, only: [:show, :edit, :update, :destroy] def index @users = User.order_name_asc.filter(params[:filter]) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 920a981e7c9..8ddb424dcfb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,15 +6,15 @@ class ApplicationController < ActionController::Base PER_PAGE = 20 - before_filter :authenticate_user_from_token! - before_filter :authenticate_user! - before_filter :reject_blocked! - before_filter :check_password_expiration - before_filter :ldap_security_check - before_filter :default_headers - before_filter :add_gon_variables - before_filter :configure_permitted_parameters, if: :devise_controller? - before_filter :require_email, unless: :devise_controller? + before_action :authenticate_user_from_token! + before_action :authenticate_user! + before_action :reject_blocked! + before_action :check_password_expiration + before_action :ldap_security_check + before_action :default_headers + before_action :add_gon_variables + before_action :configure_permitted_parameters, if: :devise_controller? + before_action :require_email, unless: :devise_controller? protect_from_forgery with: :exception diff --git a/app/controllers/dashboard/milestones_controller.rb b/app/controllers/dashboard/milestones_controller.rb index cb51792df16..33227e7f1d8 100644 --- a/app/controllers/dashboard/milestones_controller.rb +++ b/app/controllers/dashboard/milestones_controller.rb @@ -1,5 +1,5 @@ class Dashboard::MilestonesController < ApplicationController - before_filter :load_projects + before_action :load_projects def index project_milestones = case params[:state] diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb index 56e6fcc41ca..426bc615415 100644 --- a/app/controllers/dashboard/projects_controller.rb +++ b/app/controllers/dashboard/projects_controller.rb @@ -1,5 +1,5 @@ class Dashboard::ProjectsController < ApplicationController - before_filter :event_filter + before_action :event_filter def starred @projects = current_user.starred_projects diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 9bd853ed5c7..40b5de1295a 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,8 +1,8 @@ class DashboardController < ApplicationController respond_to :html - before_filter :load_projects, except: [:projects] - before_filter :event_filter, only: :show + before_action :load_projects, except: [:projects] + before_action :event_filter, only: :show def show @projects = @projects.includes(:namespace) diff --git a/app/controllers/explore/groups_controller.rb b/app/controllers/explore/groups_controller.rb index c51a4a211a6..a7250b799f3 100644 --- a/app/controllers/explore/groups_controller.rb +++ b/app/controllers/explore/groups_controller.rb @@ -1,5 +1,5 @@ class Explore::GroupsController < ApplicationController - skip_before_filter :authenticate_user!, + skip_before_action :authenticate_user!, :reject_blocked, :set_current_user_for_observers layout "explore" diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb index b295f295bb1..b1b0a2514dc 100644 --- a/app/controllers/explore/projects_controller.rb +++ b/app/controllers/explore/projects_controller.rb @@ -1,5 +1,5 @@ class Explore::ProjectsController < ApplicationController - skip_before_filter :authenticate_user!, + skip_before_action :authenticate_user!, :reject_blocked layout 'explore' diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index 265cf4f0f4a..5648a652e8e 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -1,10 +1,10 @@ class Groups::GroupMembersController < Groups::ApplicationController - skip_before_filter :authenticate_user!, only: [:index] - before_filter :group + skip_before_action :authenticate_user!, only: [:index] + before_action :group # Authorize - before_filter :authorize_read_group! - before_filter :authorize_admin_group!, except: [:index, :leave] + before_action :authorize_read_group! + before_action :authorize_admin_group!, except: [:index, :leave] layout :determine_layout @@ -49,7 +49,7 @@ class Groups::GroupMembersController < Groups::ApplicationController def resend_invite redirect_path = group_group_members_path(@group) - + @group_member = @group.group_members.find(params[:id]) if @group_member.invite? @@ -63,7 +63,7 @@ class Groups::GroupMembersController < Groups::ApplicationController def leave @group_member = @group.group_members.where(user_id: current_user.id).first - + if can?(current_user, :destroy_group_member, @group_member) @group_member.destroy redirect_to(dashboard_groups_path, notice: "You left #{group.name} group.") diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb index 546ff2cc71f..41564b04a92 100644 --- a/app/controllers/groups/milestones_controller.rb +++ b/app/controllers/groups/milestones_controller.rb @@ -1,7 +1,7 @@ class Groups::MilestonesController < ApplicationController layout 'group' - before_filter :authorize_group_milestone!, only: :update + before_action :authorize_group_milestone!, only: :update def index project_milestones = case params[:state] diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 7af3c077182..294af0b1704 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,17 +1,17 @@ class GroupsController < Groups::ApplicationController - skip_before_filter :authenticate_user!, only: [:show, :issues, :merge_requests] + skip_before_action :authenticate_user!, only: [:show, :issues, :merge_requests] respond_to :html - before_filter :group, except: [:new, :create] + before_action :group, except: [:new, :create] # Authorize - before_filter :authorize_read_group!, except: [:new, :create] - before_filter :authorize_admin_group!, only: [:edit, :update, :destroy, :projects] - before_filter :authorize_create_group!, only: [:new, :create] + before_action :authorize_read_group!, except: [:new, :create] + before_action :authorize_admin_group!, only: [:edit, :update, :destroy, :projects] + before_action :authorize_create_group!, only: [:new, :create] # Load group projects - before_filter :load_projects, except: [:new, :create, :projects, :edit, :update] - before_filter :event_filter, only: :show - before_filter :set_title, only: [:new, :create] + before_action :load_projects, except: [:new, :create, :projects, :edit, :update] + before_action :event_filter, only: :show + before_action :set_title, only: [:new, :create] layout :determine_layout diff --git a/app/controllers/import/bitbucket_controller.rb b/app/controllers/import/bitbucket_controller.rb index bb8d7e0235c..ca78a4aaa8e 100644 --- a/app/controllers/import/bitbucket_controller.rb +++ b/app/controllers/import/bitbucket_controller.rb @@ -1,15 +1,15 @@ class Import::BitbucketController < Import::BaseController - before_filter :verify_bitbucket_import_enabled - before_filter :bitbucket_auth, except: :callback + before_action :verify_bitbucket_import_enabled + before_action :bitbucket_auth, except: :callback rescue_from OAuth::Error, with: :bitbucket_unauthorized def callback - request_token = session.delete(:oauth_request_token) + request_token = session.delete(:oauth_request_token) raise "Session expired!" if request_token.nil? request_token.symbolize_keys! - + access_token = client.get_token(request_token, params[:oauth_verifier], callback_import_bitbucket_url) current_user.bitbucket_access_token = access_token.token @@ -21,7 +21,7 @@ class Import::BitbucketController < Import::BaseController def status @repos = client.projects - + @already_added_projects = current_user.created_projects.where(import_type: "bitbucket") already_added_projects_names = @already_added_projects.pluck(:import_source) @@ -41,7 +41,7 @@ class Import::BitbucketController < Import::BaseController repo_owner = repo["owner"] repo_owner = current_user.username if repo_owner == client.user["user"]["username"] @target_namespace = params[:new_namespace].presence || repo_owner - + namespace = get_or_create_namespace || (render and return) unless Gitlab::BitbucketImport::KeyAdder.new(repo, current_user).execute diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb index 87b41454c77..b9f99c1b88a 100644 --- a/app/controllers/import/github_controller.rb +++ b/app/controllers/import/github_controller.rb @@ -1,6 +1,6 @@ class Import::GithubController < Import::BaseController - before_filter :verify_github_import_enabled - before_filter :github_auth, except: :callback + before_action :verify_github_import_enabled + before_action :github_auth, except: :callback rescue_from Octokit::Unauthorized, with: :github_unauthorized @@ -36,7 +36,7 @@ class Import::GithubController < Import::BaseController repo_owner = repo.owner.login repo_owner = current_user.username if repo_owner == client.user.login @target_namespace = params[:new_namespace].presence || repo_owner - + namespace = get_or_create_namespace || (render and return) @project = Gitlab::GithubImport::ProjectCreator.new(repo, namespace, current_user).execute diff --git a/app/controllers/import/gitlab_controller.rb b/app/controllers/import/gitlab_controller.rb index bddbfded812..1b8962d8924 100644 --- a/app/controllers/import/gitlab_controller.rb +++ b/app/controllers/import/gitlab_controller.rb @@ -1,6 +1,6 @@ class Import::GitlabController < Import::BaseController - before_filter :verify_gitlab_import_enabled - before_filter :gitlab_auth, except: :callback + before_action :verify_gitlab_import_enabled + before_action :gitlab_auth, except: :callback rescue_from OAuth2::Error, with: :gitlab_unauthorized @@ -13,7 +13,7 @@ class Import::GitlabController < Import::BaseController def status @repos = client.projects - + @already_added_projects = current_user.created_projects.where(import_type: "gitlab") already_added_projects_names = @already_added_projects.pluck(:import_source) @@ -33,7 +33,7 @@ class Import::GitlabController < Import::BaseController repo_owner = repo["namespace"]["path"] repo_owner = current_user.username if repo_owner == client.user["username"] @target_namespace = params[:new_namespace].presence || repo_owner - + namespace = get_or_create_namespace || (render and return) @project = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, current_user).execute diff --git a/app/controllers/import/google_code_controller.rb b/app/controllers/import/google_code_controller.rb index 73c912e285b..8a9ff652263 100644 --- a/app/controllers/import/google_code_controller.rb +++ b/app/controllers/import/google_code_controller.rb @@ -1,8 +1,8 @@ class Import::GoogleCodeController < Import::BaseController - before_filter :user_map, only: [:new_user_map, :create_user_map] + before_action :user_map, only: [:new_user_map, :create_user_map] def new - + end def callback @@ -68,7 +68,7 @@ class Import::GoogleCodeController < Import::BaseController def status unless client.valid? - return redirect_to new_import_google_path + return redirect_to new_import_google_path end @repos = client.repos diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 1f97ff16c55..a29c03395f4 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -1,6 +1,6 @@ class InvitesController < ApplicationController - before_filter :member - skip_before_filter :authenticate_user!, only: :decline + before_action :member + skip_before_action :authenticate_user!, only: :decline respond_to :html @@ -24,7 +24,7 @@ class InvitesController < ApplicationController if member.decline_invite! label, _ = source_info(member.source) - path = + path = if current_user dashboard_path else @@ -41,7 +41,7 @@ class InvitesController < ApplicationController def member return @member if defined?(@member) - + @token = params[:id] @member = Member.find_by_invite_token(@token) diff --git a/app/controllers/namespaces_controller.rb b/app/controllers/namespaces_controller.rb index 386d103ee5a..83eec1bf4a2 100644 --- a/app/controllers/namespaces_controller.rb +++ b/app/controllers/namespaces_controller.rb @@ -1,5 +1,5 @@ class NamespacesController < ApplicationController - skip_before_filter :authenticate_user! + skip_before_action :authenticate_user! def show namespace = Namespace.find_by(path: params[:id]) diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb index efa291d9397..ea256de2c3e 100644 --- a/app/controllers/oauth/applications_controller.rb +++ b/app/controllers/oauth/applications_controller.rb @@ -1,5 +1,5 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController - before_filter :authenticate_user! + before_action :authenticate_user! layout "profile" def index @@ -10,7 +10,7 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController @application = Doorkeeper::Application.new(application_params) @application.owner = current_user - + if @application.save flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create]) redirect_to oauth_application_url(@application) diff --git a/app/controllers/oauth/authorizations_controller.rb b/app/controllers/oauth/authorizations_controller.rb index a57b4a60c24..6d3c1a320db 100644 --- a/app/controllers/oauth/authorizations_controller.rb +++ b/app/controllers/oauth/authorizations_controller.rb @@ -1,5 +1,5 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController - before_filter :authenticate_resource_owner! + before_action :authenticate_resource_owner! layout "profile" def new diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index 4e2bd0a9b4b..b0a5a631c63 100644 --- a/app/controllers/profiles/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -1,6 +1,6 @@ class Profiles::KeysController < ApplicationController layout "profile" - skip_before_filter :authenticate_user!, only: [:get_keys] + skip_before_action :authenticate_user!, only: [:get_keys] def index @keys = current_user.keys diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb index 0c614969a3f..b719a7fe9a9 100644 --- a/app/controllers/profiles/passwords_controller.rb +++ b/app/controllers/profiles/passwords_controller.rb @@ -1,11 +1,11 @@ class Profiles::PasswordsController < ApplicationController layout :determine_layout - skip_before_filter :check_password_expiration, only: [:new, :create] + skip_before_action :check_password_expiration, only: [:new, :create] - before_filter :set_user - before_filter :set_title - before_filter :authorize_change_password! + before_action :set_user + before_action :set_title + before_action :authorize_change_password! def new end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 7f76906066d..eb001e8d739 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -1,9 +1,9 @@ class ProfilesController < ApplicationController include ActionView::Helpers::SanitizeHelper - before_filter :user - before_filter :authorize_change_username!, only: :update_username - skip_before_filter :require_email, only: [:show, :update] + before_action :user + before_action :authorize_change_username!, only: :update_username + skip_before_action :require_email, only: [:show, :update] layout 'profile' diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 4719933394f..f7a28e920d1 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -1,6 +1,6 @@ class Projects::ApplicationController < ApplicationController - before_filter :project - before_filter :repository + before_action :project + before_action :repository layout :determine_layout def authenticate_user! diff --git a/app/controllers/projects/avatars_controller.rb b/app/controllers/projects/avatars_controller.rb index a482b90880d..22a12c4b9ae 100644 --- a/app/controllers/projects/avatars_controller.rb +++ b/app/controllers/projects/avatars_controller.rb @@ -1,7 +1,7 @@ class Projects::AvatarsController < Projects::ApplicationController layout 'project' - before_filter :project + before_action :project def show @blob = @project.repository.blob_at_branch('master', @project.avatar_in_git) diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb index a87b8270a22..3362264dcce 100644 --- a/app/controllers/projects/blame_controller.rb +++ b/app/controllers/projects/blame_controller.rb @@ -2,9 +2,9 @@ class Projects::BlameController < Projects::ApplicationController include ExtractsPath - before_filter :require_non_empty_project - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :assign_ref_vars + before_action :authorize_download_code! def show @blame = Gitlab::Git::Blame.new(@repository, @commit.id, @path) diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 4b7eb4df298..b762518d377 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -6,15 +6,15 @@ class Projects::BlobController < Projects::ApplicationController # Raised when given an invalid file path class InvalidPathError < StandardError; end - before_filter :require_non_empty_project, except: [:new, :create] - before_filter :authorize_download_code! - before_filter :authorize_push_code!, only: [:destroy] - before_filter :assign_blob_vars - before_filter :commit, except: [:new, :create] - before_filter :blob, except: [:new, :create] - before_filter :from_merge_request, only: [:edit, :update] - before_filter :after_edit_path, only: [:edit, :update] - before_filter :require_branch_head, only: [:edit, :update] + before_action :require_non_empty_project, except: [:new, :create] + before_action :authorize_download_code! + before_action :authorize_push_code!, only: [:destroy] + before_action :assign_blob_vars + before_action :commit, except: [:new, :create] + before_action :blob, except: [:new, :create] + before_action :from_merge_request, only: [:edit, :update] + before_action :after_edit_path, only: [:edit, :update] + before_action :require_branch_head, only: [:edit, :update] def new commit unless @repository.empty? diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index f049e96e61d..696011b94b9 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -1,9 +1,9 @@ class Projects::BranchesController < Projects::ApplicationController include ActionView::Helpers::SanitizeHelper # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! - before_filter :authorize_push_code!, only: [:create, :destroy] + before_action :require_non_empty_project + before_action :authorize_download_code! + before_action :authorize_push_code!, only: [:create, :destroy] def index @sort = params[:sort] || 'name' diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 894cf93b9ae..8a1b7899be3 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -3,9 +3,9 @@ # Not to be confused with CommitsController, plural. class Projects::CommitController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! - before_filter :commit + before_action :require_non_empty_project + before_action :authorize_download_code! + before_action :commit def show return git_not_found! unless @commit diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index 4b6ab437476..d1c15174aea 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -3,9 +3,9 @@ require "base64" class Projects::CommitsController < Projects::ApplicationController include ExtractsPath - before_filter :require_non_empty_project - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :assign_ref_vars + before_action :authorize_download_code! def show @repo = @project.repository diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 146808fa562..03e6c381275 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -1,7 +1,7 @@ class Projects::CompareController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :authorize_download_code! def index end diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb index 6fba3ce299b..8c1bbf76917 100644 --- a/app/controllers/projects/deploy_keys_controller.rb +++ b/app/controllers/projects/deploy_keys_controller.rb @@ -2,7 +2,7 @@ class Projects::DeployKeysController < Projects::ApplicationController respond_to :html # Authorize - before_filter :authorize_admin_project! + before_action :authorize_admin_project! layout "project_settings" diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index 21a151a426e..01a079d2e65 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -1,7 +1,7 @@ class Projects::ForksController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :authorize_download_code! def new @namespaces = current_user.manageable_namespaces diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index 6e54af356e0..a060ea6f998 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -1,7 +1,7 @@ class Projects::GraphsController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :authorize_download_code! def show respond_to do |format| diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb index ba95bb13e1f..57fc48ac7da 100644 --- a/app/controllers/projects/hooks_controller.rb +++ b/app/controllers/projects/hooks_controller.rb @@ -1,6 +1,6 @@ class Projects::HooksController < Projects::ApplicationController # Authorize - before_filter :authorize_admin_project! + before_action :authorize_admin_project! respond_to :html diff --git a/app/controllers/projects/imports_controller.rb b/app/controllers/projects/imports_controller.rb index b64491b4666..066b66014f8 100644 --- a/app/controllers/projects/imports_controller.rb +++ b/app/controllers/projects/imports_controller.rb @@ -1,8 +1,8 @@ class Projects::ImportsController < Projects::ApplicationController # Authorize - before_filter :authorize_admin_project! - before_filter :require_no_repo - before_filter :redirect_if_progress, except: :show + before_action :authorize_admin_project! + before_action :require_no_repo + before_action :redirect_if_progress, except: :show def new end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 88302276b5e..c524e1a0ea3 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -1,18 +1,18 @@ class Projects::IssuesController < Projects::ApplicationController - before_filter :module_enabled - before_filter :issue, only: [:edit, :update, :show, :toggle_subscription] + before_action :module_enabled + before_action :issue, only: [:edit, :update, :show, :toggle_subscription] # Allow read any issue - before_filter :authorize_read_issue! + before_action :authorize_read_issue! # Allow write(create) issue - before_filter :authorize_write_issue!, only: [:new, :create] + before_action :authorize_write_issue!, only: [:new, :create] # Allow modify issue - before_filter :authorize_modify_issue!, only: [:edit, :update] + before_action :authorize_modify_issue!, only: [:edit, :update] # Allow issues bulk update - before_filter :authorize_admin_issues!, only: [:bulk_update] + before_action :authorize_admin_issues!, only: [:bulk_update] respond_to :html @@ -99,7 +99,7 @@ class Projects::IssuesController < Projects::ApplicationController def toggle_subscription @issue.toggle_subscription(current_user) - + render nothing: true end diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 207a01ed3b0..2f8cb203cf9 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -1,8 +1,8 @@ class Projects::LabelsController < Projects::ApplicationController - before_filter :module_enabled - before_filter :label, only: [:edit, :update, :destroy] - before_filter :authorize_labels! - before_filter :authorize_admin_labels!, except: [:index] + before_action :module_enabled + before_action :label, only: [:edit, :update, :destroy] + before_action :authorize_labels! + before_action :authorize_admin_labels!, except: [:index] respond_to :js, :html diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 47ce8467358..ab75f2ddb73 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -1,20 +1,20 @@ require 'gitlab/satellite/satellite' class Projects::MergeRequestsController < Projects::ApplicationController - before_filter :module_enabled - before_filter :merge_request, only: [:edit, :update, :show, :diffs, :automerge, :automerge_check, :ci_status, :toggle_subscription] - before_filter :closes_issues, only: [:edit, :update, :show, :diffs] - before_filter :validates_merge_request, only: [:show, :diffs] - before_filter :define_show_vars, only: [:show, :diffs] + before_action :module_enabled + before_action :merge_request, only: [:edit, :update, :show, :diffs, :automerge, :automerge_check, :ci_status, :toggle_subscription] + before_action :closes_issues, only: [:edit, :update, :show, :diffs] + before_action :validates_merge_request, only: [:show, :diffs] + before_action :define_show_vars, only: [:show, :diffs] # Allow read any merge_request - before_filter :authorize_read_merge_request! + before_action :authorize_read_merge_request! # Allow write(create) merge_request - before_filter :authorize_write_merge_request!, only: [:new, :create] + before_action :authorize_write_merge_request!, only: [:new, :create] # Allow modify merge_request - before_filter :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort] + before_action :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort] def index terms = params['issue_search'] @@ -176,7 +176,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController def toggle_subscription @merge_request.toggle_subscription(current_user) - + render nothing: true end diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index b49b549547a..61689488d13 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -1,12 +1,12 @@ class Projects::MilestonesController < Projects::ApplicationController - before_filter :module_enabled - before_filter :milestone, only: [:edit, :update, :destroy, :show, :sort_issues, :sort_merge_requests] + before_action :module_enabled + before_action :milestone, only: [:edit, :update, :destroy, :show, :sort_issues, :sort_merge_requests] # Allow read any milestone - before_filter :authorize_read_milestone! + before_action :authorize_read_milestone! # Allow admin milestone - before_filter :authorize_admin_milestone!, except: [:index, :show] + before_action :authorize_admin_milestone!, except: [:index, :show] respond_to :html diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb index 83d1c1dacae..06aef91cadd 100644 --- a/app/controllers/projects/network_controller.rb +++ b/app/controllers/projects/network_controller.rb @@ -2,9 +2,9 @@ class Projects::NetworkController < Projects::ApplicationController include ExtractsPath include ApplicationHelper - before_filter :require_non_empty_project - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :assign_ref_vars + before_action :authorize_download_code! def show respond_to do |format| diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 868629a0bc4..496b85cb46d 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -1,9 +1,9 @@ class Projects::NotesController < Projects::ApplicationController # Authorize - before_filter :authorize_read_note! - before_filter :authorize_write_note!, only: [:create] - before_filter :authorize_admin_note!, only: [:update, :destroy] - before_filter :find_current_user_notes, except: [:destroy, :delete_attachment] + before_action :authorize_read_note! + before_action :authorize_write_note!, only: [:create] + before_action :authorize_admin_note!, only: [:update, :destroy] + before_action :find_current_user_notes, except: [:destroy, :delete_attachment] def index current_fetched_at = Time.now.to_i diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index 72967a26ff1..d7fbc979067 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -1,6 +1,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController # Authorize - before_filter :authorize_admin_project!, except: :leave + before_action :authorize_admin_project!, except: :leave layout "project_settings" @@ -24,7 +24,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController users = @group.users.search(params[:search]).to_a @group_members = @group_members.where(user_id: users) end - + @group_members = @group_members.order('access_level DESC').limit(20) end @@ -62,7 +62,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController redirect_path = namespace_project_project_members_path(@project.namespace, @project) @project_member = @project.project_members.find(params[:id]) - + if @project_member.invite? @project_member.resend_invite diff --git a/app/controllers/projects/protected_branches_controller.rb b/app/controllers/projects/protected_branches_controller.rb index ac36ac6fcd3..6b52eccebf7 100644 --- a/app/controllers/projects/protected_branches_controller.rb +++ b/app/controllers/projects/protected_branches_controller.rb @@ -1,7 +1,7 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_admin_project! + before_action :require_non_empty_project + before_action :authorize_admin_project! layout "project_settings" diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index b1a029ce696..647c1454078 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -2,9 +2,9 @@ class Projects::RawController < Projects::ApplicationController include ExtractsPath - before_filter :require_non_empty_project - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :assign_ref_vars + before_action :authorize_download_code! def show @blob = @repository.blob_at(@commit.id, @path) diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb index ec3b2b8d75a..01ca1537c0e 100644 --- a/app/controllers/projects/refs_controller.rb +++ b/app/controllers/projects/refs_controller.rb @@ -1,9 +1,9 @@ class Projects::RefsController < Projects::ApplicationController include ExtractsPath - before_filter :require_non_empty_project - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :assign_ref_vars + before_action :authorize_download_code! def switch respond_to do |format| diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 96defb0c721..c4a5e2d6359 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -1,8 +1,8 @@ class Projects::RepositoriesController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project, except: :create - before_filter :authorize_download_code! - before_filter :authorize_admin_project!, only: :create + before_action :require_non_empty_project, except: :create + before_action :authorize_download_code! + before_action :authorize_admin_project!, only: :create def create @project.create_repository diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index 9a484c109ba..ae8146dca59 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -1,7 +1,7 @@ class Projects::ServicesController < Projects::ApplicationController # Authorize - before_filter :authorize_admin_project! - before_filter :service, only: [:edit, :update, :test] + before_action :authorize_admin_project! + before_action :service, only: [:edit, :update, :test] respond_to :html diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index ed268400373..3d75abcc29d 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -1,18 +1,18 @@ class Projects::SnippetsController < Projects::ApplicationController - before_filter :module_enabled - before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] + before_action :module_enabled + before_action :snippet, only: [:show, :edit, :destroy, :update, :raw] # Allow read any snippet - before_filter :authorize_read_project_snippet! + before_action :authorize_read_project_snippet! # Allow write(create) snippet - before_filter :authorize_write_project_snippet!, only: [:new, :create] + before_action :authorize_write_project_snippet!, only: [:new, :create] # Allow modify snippet - before_filter :authorize_modify_project_snippet!, only: [:edit, :update] + before_action :authorize_modify_project_snippet!, only: [:edit, :update] # Allow destroy snippet - before_filter :authorize_admin_project_snippet!, only: [:destroy] + before_action :authorize_admin_project_snippet!, only: [:destroy] respond_to :html diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index 83f4937bce3..f565fbbbbc3 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -1,9 +1,9 @@ class Projects::TagsController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! - before_filter :authorize_push_code!, only: [:create] - before_filter :authorize_admin_project!, only: [:destroy] + before_action :require_non_empty_project + before_action :authorize_download_code! + before_action :authorize_push_code!, only: [:create] + before_action :authorize_admin_project!, only: [:destroy] def index sorted = VersionSorter.rsort(@repository.tag_names) diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index b23010bf595..b659e15f242 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -2,9 +2,9 @@ class Projects::TreeController < Projects::ApplicationController include ExtractsPath - before_filter :require_non_empty_project, except: [:new, :create] - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project, except: [:new, :create] + before_action :assign_ref_vars + before_action :authorize_download_code! def show if tree.entries.empty? diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb index 276dced8656..6153ca2dc1b 100644 --- a/app/controllers/projects/uploads_controller.rb +++ b/app/controllers/projects/uploads_controller.rb @@ -1,11 +1,11 @@ class Projects::UploadsController < Projects::ApplicationController layout 'project' - # We want to skip these filters for only the `show` action if `image?` is true, + # We want to skip these filters for only the `show` action if `image?` is true, # but `skip_before_filter` doesn't work with both `only` and `if`, so we accomplish the same like this. skipped_filters = [:authenticate_user!, :reject_blocked!, :project, :repository] - skip_before_filter *skipped_filters, only: [:show] - before_filter *skipped_filters, only: [:show], unless: :image? + skip_before_action *skipped_filters, only: [:show] + before_action *skipped_filters, only: [:show], unless: :image? def create link_to_file = ::Projects::UploadService.new(project, params[:file]). @@ -40,7 +40,7 @@ class Projects::UploadsController < Projects::ApplicationController file_project = Project.find_with_namespace("#{namespace}/#{id}") if file_project.nil? - @uploader = nil + @uploader = nil return end diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index aeb7f0699f5..36ef86e1909 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -1,10 +1,10 @@ require 'project_wiki' class Projects::WikisController < Projects::ApplicationController - before_filter :authorize_read_wiki! - before_filter :authorize_write_wiki!, only: [:edit, :create, :history] - before_filter :authorize_admin_wiki!, only: :destroy - before_filter :load_project_wiki + before_action :authorize_read_wiki! + before_action :authorize_write_wiki!, only: [:edit, :create, :history] + before_action :authorize_admin_wiki!, only: :destroy + before_action :load_project_wiki include WikiHelper def pages diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 0f28794b736..1422f2b8a4c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,13 +1,13 @@ class ProjectsController < ApplicationController prepend_before_filter :render_go_import, only: [:show] - skip_before_filter :authenticate_user!, only: [:show] - before_filter :project, except: [:new, :create] - before_filter :repository, except: [:new, :create] + skip_before_action :authenticate_user!, only: [:show] + before_action :project, except: [:new, :create] + before_action :repository, except: [:new, :create] # Authorize - before_filter :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive] - before_filter :set_title, only: [:new, :create] - before_filter :event_filter, only: :show + before_action :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive] + before_action :set_title, only: [:new, :create] + before_action :event_filter, only: :show layout 'navless', only: [:new, :create, :fork] diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 38d116a4ee3..830751a989f 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,5 +1,5 @@ class RegistrationsController < Devise::RegistrationsController - before_filter :signup_enabled? + before_action :signup_enabled? def new redirect_to(new_user_session_path) diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index cd52556b203..1eff3dd29de 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -1,15 +1,15 @@ class SnippetsController < ApplicationController - before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] + before_action :snippet, only: [:show, :edit, :destroy, :update, :raw] # Allow modify snippet - before_filter :authorize_modify_snippet!, only: [:edit, :update] + before_action :authorize_modify_snippet!, only: [:edit, :update] # Allow destroy snippet - before_filter :authorize_admin_snippet!, only: [:destroy] + before_action :authorize_admin_snippet!, only: [:destroy] - before_filter :set_title + before_action :set_title - skip_before_filter :authenticate_user!, only: [:index, :user_index, :show, :raw] + skip_before_action :authenticate_user!, only: [:index, :user_index, :show, :raw] respond_to :html diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index c5f3da54ea2..17edff68be2 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -1,6 +1,6 @@ class UploadsController < ApplicationController - skip_before_filter :authenticate_user! - before_filter :find_model, :authorize_access! + skip_before_action :authenticate_user! + before_action :find_model, :authorize_access! def show uploader = @model.send(upload_mount) @@ -28,7 +28,7 @@ class UploadsController < ApplicationController end def authorize_access! - authorized = + authorized = case @model when Project can?(current_user, :read_project, @model) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 679d6897ce9..460cc868b35 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,6 @@ class UsersController < ApplicationController - skip_before_filter :authenticate_user! - before_filter :set_user + skip_before_action :authenticate_user! + before_action :set_user layout :determine_layout def show diff --git a/db/schema.rb b/db/schema.rb index 1aee37b2e61..2b7e27e3a31 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -470,7 +470,6 @@ ActiveRecord::Schema.define(version: 20150417122318) do t.integer "notification_level", default: 1, null: false t.datetime "password_expires_at" t.integer "created_by_id" - t.datetime "last_credential_check_at" t.string "avatar" t.string "confirmation_token" t.datetime "confirmed_at" @@ -478,6 +477,7 @@ ActiveRecord::Schema.define(version: 20150417122318) do t.string "unconfirmed_email" t.boolean "hide_no_ssh_key", default: false t.string "website_url", default: "", null: false + t.datetime "last_credential_check_at" t.string "github_access_token" t.string "gitlab_access_token" t.string "notification_email" From 5bbe2860bf3f9e24d2f658aa2a32baabbe997cea Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 20 Apr 2015 18:48:53 +0200 Subject: [PATCH 17/80] Update gitlab-grack to 2.0.1 to get unicorn to stop creating zombies. --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 1c2a9002204..3522937f18e 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,7 @@ gem "browser" gem "gitlab_git", '~> 7.1.10' # Ruby/Rack Git Smart-HTTP Server Handler -gem 'gitlab-grack', '~> 2.0.0.rc2', require: 'grack' +gem 'gitlab-grack', '~> 2.0.1', require: 'grack' # LDAP Auth gem 'gitlab_omniauth-ldap', '1.2.1', require: "omniauth-ldap" diff --git a/Gemfile.lock b/Gemfile.lock index 360b1abcf56..fbf0ef443a1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -199,7 +199,7 @@ GEM gitlab-flowdock-git-hook (0.4.2.2) gitlab-grit (>= 2.4.1) multi_json - gitlab-grack (2.0.0) + gitlab-grack (2.0.1) rack (~> 1.5.1) gitlab-grit (2.7.2) charlock_holmes (~> 0.6) @@ -700,7 +700,7 @@ DEPENDENCIES gemnasium-gitlab-service (~> 0.2) github-markup gitlab-flowdock-git-hook (~> 0.4.2) - gitlab-grack (~> 2.0.0.rc2) + gitlab-grack (~> 2.0.1) gitlab-linguist (~> 3.0.1) gitlab_emoji (~> 0.1) gitlab_git (~> 7.1.10) From 96c2b940480eb1bafd47e1f6d203ad11f8f646df Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 2 Apr 2015 20:46:43 -0400 Subject: [PATCH 18/80] Reference filters :sparkles: Commit ranges, commits, external issues, issues, labels, merge requests, snippets, users. --- app/helpers/issues_helper.rb | 2 + app/helpers/labels_helper.rb | 16 +- lib/gitlab/markdown.rb | 328 +++--------------- .../markdown/commit_range_reference_filter.rb | 127 +++++++ .../markdown/commit_reference_filter.rb | 108 ++++++ .../markdown/cross_project_reference.rb | 26 ++ .../external_issue_reference_filter.rb | 94 +++++ lib/gitlab/markdown/issue_reference_filter.rb | 110 ++++++ lib/gitlab/markdown/label_reference_filter.rb | 100 ++++++ .../merge_request_reference_filter.rb | 107 ++++++ .../markdown/snippet_reference_filter.rb | 98 ++++++ lib/gitlab/markdown/user_reference_filter.rb | 117 +++++++ spec/helpers/gitlab_markdown_helper_spec.rb | 52 +-- spec/helpers/labels_helper_spec.rb | 4 +- .../commit_range_reference_filter_spec.rb | 105 ++++++ .../markdown/commit_reference_filter_spec.rb | 98 ++++++ .../markdown/cross_project_reference_spec.rb | 23 ++ .../external_issue_reference_filter_spec.rb | 101 ++++++ .../markdown/issue_reference_filter_spec.rb | 104 ++++++ .../markdown/label_reference_filter_spec.rb | 72 ++++ .../merge_request_reference_filter_spec.rb | 93 +++++ .../markdown/snippet_reference_filter_spec.rb | 64 ++++ .../markdown/user_reference_filter_spec.rb | 87 +++++ spec/support/reference_filter_spec_helper.rb | 37 ++ 24 files changed, 1730 insertions(+), 343 deletions(-) create mode 100644 lib/gitlab/markdown/commit_range_reference_filter.rb create mode 100644 lib/gitlab/markdown/commit_reference_filter.rb create mode 100644 lib/gitlab/markdown/cross_project_reference.rb create mode 100644 lib/gitlab/markdown/external_issue_reference_filter.rb create mode 100644 lib/gitlab/markdown/issue_reference_filter.rb create mode 100644 lib/gitlab/markdown/label_reference_filter.rb create mode 100644 lib/gitlab/markdown/merge_request_reference_filter.rb create mode 100644 lib/gitlab/markdown/snippet_reference_filter.rb create mode 100644 lib/gitlab/markdown/user_reference_filter.rb create mode 100644 spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb create mode 100644 spec/lib/gitlab/markdown/commit_reference_filter_spec.rb create mode 100644 spec/lib/gitlab/markdown/cross_project_reference_spec.rb create mode 100644 spec/lib/gitlab/markdown/external_issue_reference_filter_spec.rb create mode 100644 spec/lib/gitlab/markdown/issue_reference_filter_spec.rb create mode 100644 spec/lib/gitlab/markdown/label_reference_filter_spec.rb create mode 100644 spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb create mode 100644 spec/lib/gitlab/markdown/snippet_reference_filter_spec.rb create mode 100644 spec/lib/gitlab/markdown/user_reference_filter_spec.rb create mode 100644 spec/support/reference_filter_spec_helper.rb diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index ad4a7612724..7b034f22248 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -108,4 +108,6 @@ module IssuesHelper xml.summary issue.title end end + + module_function :url_for_issue, :title_for_issue end diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 32ef2e7ca84..0259829a059 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -7,9 +7,13 @@ module LabelsHelper label_color = label.color || Label::DEFAULT_COLOR text_color = text_color_for_bg(label_color) - content_tag :span, class: 'label color-label', style: "background-color:#{label_color};color:#{text_color}" do - label.name - end + # Intentionally not using content_tag here so that this method can be called + # by LabelReferenceFilter + span = %() + + label.name + '' + + span.html_safe end def suggested_colors @@ -42,13 +46,15 @@ module LabelsHelper r, g, b = bg_color.slice(1,7).scan(/.{2}/).map(&:hex) if (r + g + b) > 500 - "#333" + '#333333' else - "#FFF" + '#FFFFFF' end end def project_labels_options(project) options_from_collection_for_select(project.labels, 'name', 'name', params[:label_name]) end + + module_function :render_colored_label, :text_color_for_bg end diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 47c456d8dc7..93c279edc32 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -10,11 +10,11 @@ module Gitlab # Supported reference formats are: # * @foo for team members # * #123 for issues - # * #JIRA-123 for Jira issues + # * JIRA-123 for Jira issues # * !123 for merge requests # * $123 for snippets - # * 123456 for commits - # * 123456...7890123 for commit ranges (comparisons) + # * 1c002d for specific commit + # * 1c002d...35cfb2 for commit ranges (comparisons) # # It also parses Emoji codes to insert images. See # http://www.emoji-cheat-sheet.com/ for a list of the supported icons. @@ -30,10 +30,6 @@ module Gitlab # >> gfm(":trollface:") # => "\":trollface:\" module Markdown - include IssuesHelper - - attr_reader :options, :html_options - # Public: Parse the provided text with GitLab-Flavored Markdown # # text - the source text @@ -65,42 +61,13 @@ module Gitlab reference_only_path: true ) - @options = options - @html_options = html_options - - # TODO: add popups with additional information - - # Used markdown pipelines in GitLab: - # GitlabEmojiFilter - performs emoji replacement. - # SanitizationFilter - remove unsafe HTML tags and attributes - # - # see https://gitlab.com/gitlab-org/html-pipeline-gitlab for more filters - filters = [ - HTML::Pipeline::Gitlab::GitlabEmojiFilter, - HTML::Pipeline::SanitizationFilter - ] - - whitelist = HTML::Pipeline::SanitizationFilter::WHITELIST - whitelist[:attributes][:all].push('class', 'id') - whitelist[:elements].push('span') - - # Remove the rel attribute that the sanitize gem adds, and remove the - # href attribute if it contains inline javascript - fix_anchors = lambda do |env| - name, node = env[:node_name], env[:node] - if name == 'a' - node.remove_attribute('rel') - if node['href'] && node['href'].match('javascript:') - node.remove_attribute('href') - end - end - end - whitelist[:transformers].push(fix_anchors) - markdown_context = { - asset_root: Gitlab.config.gitlab.url, - asset_host: Gitlab::Application.config.asset_host, - whitelist: whitelist + asset_root: Gitlab.config.gitlab.url, + asset_host: Gitlab::Application.config.asset_host, + whitelist: sanitization_whitelist, + reference_class: html_options[:class], + only_path: options[:reference_only_path], + project: project } markdown_pipeline = HTML::Pipeline::Gitlab.new(filters).pipeline @@ -114,21 +81,6 @@ module Gitlab text = result[:output].to_html(save_with: save_options) - # Extract pre blocks so they are not altered - # from http://github.github.com/github-flavored-markdown/ - text.gsub!(%r{
.*?
|.*?}m) { |match| extract_piece(match) } - # Extract links with probably parsable hrefs - text.gsub!(%r{.*?}m) { |match| extract_piece(match) } - # Extract images with probably parsable src - text.gsub!(%r{}m) { |match| extract_piece(match) } - - text = parse(text, project) - - # Insert pre block extractions - text.gsub!(/\{gfm-extraction-(\h{32})\}/) do - insert_piece($1) - end - if options[:parse_tasks] text = parse_tasks(text) end @@ -138,242 +90,48 @@ module Gitlab private - def extract_piece(text) - @extractions ||= {} - - md5 = Digest::MD5.hexdigest(text) - @extractions[md5] = text - "{gfm-extraction-#{md5}}" - end - - def insert_piece(id) - @extractions[id] - end - - # Private: Parses text for references + # Custom filters for html-pipeline: # - # text - Text to parse + # See https://gitlab.com/gitlab-org/html-pipeline-gitlab for more filters + def filters + [ + Gitlab::Markdown::UserReferenceFilter, + Gitlab::Markdown::IssueReferenceFilter, + Gitlab::Markdown::ExternalIssueReferenceFilter, + Gitlab::Markdown::MergeRequestReferenceFilter, + Gitlab::Markdown::SnippetReferenceFilter, + Gitlab::Markdown::CommitRangeReferenceFilter, + Gitlab::Markdown::CommitReferenceFilter, + Gitlab::Markdown::LabelReferenceFilter, + HTML::Pipeline::Gitlab::GitlabEmojiFilter, + HTML::Pipeline::SanitizationFilter + ] + end + + # Customize the SanitizationFilter whitelist # - # Returns parsed text - def parse(text, project = @project) - parse_references(text, project) if project + # - Allow `class` and `id` attributes on all elements + # - Allow `span` elements + # - Remove `rel` attributes from `a` elements + # - Remove `a` nodes with `javascript:` in the `href` attribute + def sanitization_whitelist + whitelist = HTML::Pipeline::SanitizationFilter::WHITELIST + whitelist[:attributes][:all].push('class', 'id') + whitelist[:elements].push('span') - text - end - - NAME_STR = Gitlab::Regex::NAMESPACE_REGEX_STR - PROJ_STR = "(?#{NAME_STR}/#{NAME_STR})" - - REFERENCE_PATTERN = %r{ - (?\W)? # Prefix - ( # Reference - @(?#{NAME_STR}) # User name - |~(?