Commit d986aea3f085daafc52f4a8d8de8618eeaf01df4

Authored by Dmitriy Zaporozhets
2 parents 9e924c70 18b1f171

Merge branch 'upgrade_to_rails_4.1' into 'master'

Upgrade to rails 4.1
@@ -8,7 +8,7 @@ def linux_only(require_as) @@ -8,7 +8,7 @@ def linux_only(require_as)
8 RUBY_PLATFORM.include?('linux') && require_as 8 RUBY_PLATFORM.include?('linux') && require_as
9 end 9 end
10 10
11 -gem "rails", "~> 4.0.0" 11 +gem "rails", "~> 4.1.0"
12 12
13 gem "protected_attributes" 13 gem "protected_attributes"
14 gem 'rails-observers' 14 gem 'rails-observers'
@@ -207,7 +207,7 @@ group :development, :test do @@ -207,7 +207,7 @@ group :development, :test do
207 gem 'factory_girl_rails' 207 gem 'factory_girl_rails'
208 208
209 # Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826) 209 # Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826)
210 - gem 'minitest', '~> 4.7.0' 210 + gem 'minitest', '~> 5.3.0'
211 211
212 # Generate Fake data 212 # Generate Fake data
213 gem "ffaker" 213 gem "ffaker"
@@ -224,7 +224,7 @@ group :development, :test do @@ -224,7 +224,7 @@ group :development, :test do
224 # PhantomJS driver for Capybara 224 # PhantomJS driver for Capybara
225 gem 'poltergeist', '~> 1.5.1' 225 gem 'poltergeist', '~> 1.5.1'
226 226
227 - gem 'jasmine', '2.0.0.rc5' 227 + gem 'jasmine', '2.0.2'
228 228
229 gem "spring", '1.1.1' 229 gem "spring", '1.1.1'
230 gem "spring-commands-rspec", '1.0.1' 230 gem "spring-commands-rspec", '1.0.1'
@@ -2,37 +2,39 @@ GEM @@ -2,37 +2,39 @@ GEM
2 remote: https://rubygems.org/ 2 remote: https://rubygems.org/
3 specs: 3 specs:
4 ace-rails-ap (2.0.1) 4 ace-rails-ap (2.0.1)
5 - actionmailer (4.0.5)  
6 - actionpack (= 4.0.5) 5 + actionmailer (4.1.1)
  6 + actionpack (= 4.1.1)
  7 + actionview (= 4.1.1)
7 mail (~> 2.5.4) 8 mail (~> 2.5.4)
8 - actionpack (4.0.5)  
9 - activesupport (= 4.0.5)  
10 - builder (~> 3.1.0)  
11 - erubis (~> 2.7.0) 9 + actionpack (4.1.1)
  10 + actionview (= 4.1.1)
  11 + activesupport (= 4.1.1)
12 rack (~> 1.5.2) 12 rack (~> 1.5.2)
13 rack-test (~> 0.6.2) 13 rack-test (~> 0.6.2)
14 - activemodel (4.0.5)  
15 - activesupport (= 4.0.5)  
16 - builder (~> 3.1.0)  
17 - activerecord (4.0.5)  
18 - activemodel (= 4.0.5)  
19 - activerecord-deprecated_finders (~> 1.0.2)  
20 - activesupport (= 4.0.5)  
21 - arel (~> 4.0.0)  
22 - activerecord-deprecated_finders (1.0.3)  
23 - activesupport (4.0.5) 14 + actionview (4.1.1)
  15 + activesupport (= 4.1.1)
  16 + builder (~> 3.1)
  17 + erubis (~> 2.7.0)
  18 + activemodel (4.1.1)
  19 + activesupport (= 4.1.1)
  20 + builder (~> 3.1)
  21 + activerecord (4.1.1)
  22 + activemodel (= 4.1.1)
  23 + activesupport (= 4.1.1)
  24 + arel (~> 5.0.0)
  25 + activesupport (4.1.1)
24 i18n (~> 0.6, >= 0.6.9) 26 i18n (~> 0.6, >= 0.6.9)
25 - minitest (~> 4.2)  
26 - multi_json (~> 1.3) 27 + json (~> 1.7, >= 1.7.7)
  28 + minitest (~> 5.1)
27 thread_safe (~> 0.1) 29 thread_safe (~> 0.1)
28 - tzinfo (~> 0.3.37) 30 + tzinfo (~> 1.1)
29 acts-as-taggable-on (2.4.1) 31 acts-as-taggable-on (2.4.1)
30 rails (>= 3, < 5) 32 rails (>= 3, < 5)
31 addressable (2.3.5) 33 addressable (2.3.5)
32 annotate (2.6.0) 34 annotate (2.6.0)
33 activerecord (>= 2.3.0) 35 activerecord (>= 2.3.0)
34 rake (>= 0.8.7) 36 rake (>= 0.8.7)
35 - arel (4.0.2) 37 + arel (5.0.1.20140414130214)
36 asciidoctor (0.1.4) 38 asciidoctor (0.1.4)
37 awesome_print (1.2.0) 39 awesome_print (1.2.0)
38 axiom-types (0.0.5) 40 axiom-types (0.0.5)
@@ -46,7 +48,7 @@ GEM @@ -46,7 +48,7 @@ GEM
46 debug_inspector (>= 0.0.1) 48 debug_inspector (>= 0.0.1)
47 bootstrap-sass (3.0.3.0) 49 bootstrap-sass (3.0.3.0)
48 sass (~> 3.2) 50 sass (~> 3.2)
49 - builder (3.1.4) 51 + builder (3.2.2)
50 capybara (2.2.1) 52 capybara (2.2.1)
51 mime-types (>= 1.16) 53 mime-types (>= 1.16)
52 nokogiri (>= 1.3.3) 54 nokogiri (>= 1.3.3)
@@ -223,13 +225,13 @@ GEM @@ -223,13 +225,13 @@ GEM
223 guard-spinach (0.0.2) 225 guard-spinach (0.0.2)
224 guard (>= 1.1) 226 guard (>= 1.1)
225 spinach 227 spinach
226 - haml (4.0.4) 228 + haml (4.0.5)
227 tilt 229 tilt
228 - haml-rails (0.5.1)  
229 - actionpack (~> 4.0.0)  
230 - activesupport (~> 4.0.0) 230 + haml-rails (0.5.3)
  231 + actionpack (>= 4.0.1)
  232 + activesupport (>= 4.0.1)
231 haml (>= 3.1, < 5.0) 233 haml (>= 3.1, < 5.0)
232 - railties (~> 4.0.0) 234 + railties (>= 4.0.1)
233 hashie (2.0.5) 235 hashie (2.0.5)
234 hike (1.2.3) 236 hike (1.2.3)
235 hipchat (0.14.0) 237 hipchat (0.14.0)
@@ -242,12 +244,12 @@ GEM @@ -242,12 +244,12 @@ GEM
242 httpauth (0.2.0) 244 httpauth (0.2.0)
243 i18n (0.6.9) 245 i18n (0.6.9)
244 ice_nine (0.10.0) 246 ice_nine (0.10.0)
245 - jasmine (2.0.0.rc5)  
246 - jasmine-core (~> 2.0.0.rc5) 247 + jasmine (2.0.2)
  248 + jasmine-core (~> 2.0.0)
247 phantomjs 249 phantomjs
248 rack (>= 1.2.1) 250 rack (>= 1.2.1)
249 rake 251 rake
250 - jasmine-core (2.0.0.rc5) 252 + jasmine-core (2.0.0)
251 jquery-atwho-rails (0.3.3) 253 jquery-atwho-rails (0.3.3)
252 jquery-rails (3.1.0) 254 jquery-rails (3.1.0)
253 railties (>= 3.0, < 5.0) 255 railties (>= 3.0, < 5.0)
@@ -282,11 +284,11 @@ GEM @@ -282,11 +284,11 @@ GEM
282 method_source (0.8.2) 284 method_source (0.8.2)
283 mime-types (1.25.1) 285 mime-types (1.25.1)
284 mini_portile (0.6.0) 286 mini_portile (0.6.0)
285 - minitest (4.7.5) 287 + minitest (5.3.4)
286 multi_json (1.10.1) 288 multi_json (1.10.1)
287 multi_xml (0.5.5) 289 multi_xml (0.5.5)
288 multipart-post (1.2.0) 290 multipart-post (1.2.0)
289 - mysql2 (0.3.11) 291 + mysql2 (0.3.16)
290 net-ldap (0.3.1) 292 net-ldap (0.3.1)
291 net-scp (1.1.2) 293 net-scp (1.1.2)
292 net-ssh (>= 2.6.5) 294 net-ssh (>= 2.6.5)
@@ -355,14 +357,16 @@ GEM @@ -355,14 +357,16 @@ GEM
355 rack 357 rack
356 rack-test (0.6.2) 358 rack-test (0.6.2)
357 rack (>= 1.0) 359 rack (>= 1.0)
358 - rails (4.0.5)  
359 - actionmailer (= 4.0.5)  
360 - actionpack (= 4.0.5)  
361 - activerecord (= 4.0.5)  
362 - activesupport (= 4.0.5) 360 + rails (4.1.1)
  361 + actionmailer (= 4.1.1)
  362 + actionpack (= 4.1.1)
  363 + actionview (= 4.1.1)
  364 + activemodel (= 4.1.1)
  365 + activerecord (= 4.1.1)
  366 + activesupport (= 4.1.1)
363 bundler (>= 1.3.0, < 2.0) 367 bundler (>= 1.3.0, < 2.0)
364 - railties (= 4.0.5)  
365 - sprockets-rails (~> 2.0.0) 368 + railties (= 4.1.1)
  369 + sprockets-rails (~> 2.0)
366 rails-observers (0.1.2) 370 rails-observers (0.1.2)
367 activemodel (~> 4.0) 371 activemodel (~> 4.0)
368 rails_best_practices (1.14.4) 372 rails_best_practices (1.14.4)
@@ -374,13 +378,13 @@ GEM @@ -374,13 +378,13 @@ GEM
374 i18n 378 i18n
375 require_all 379 require_all
376 ruby-progressbar 380 ruby-progressbar
377 - railties (4.0.5)  
378 - actionpack (= 4.0.5)  
379 - activesupport (= 4.0.5) 381 + railties (4.1.1)
  382 + actionpack (= 4.1.1)
  383 + activesupport (= 4.1.1)
380 rake (>= 0.8.7) 384 rake (>= 0.8.7)
381 thor (>= 0.18.1, < 2.0) 385 thor (>= 0.18.1, < 2.0)
382 raindrops (0.12.0) 386 raindrops (0.12.0)
383 - rake (10.3.1) 387 + rake (10.3.2)
384 raphael-rails (2.1.2) 388 raphael-rails (2.1.2)
385 rb-fsevent (0.9.3) 389 rb-fsevent (0.9.3)
386 rb-inotify (0.9.2) 390 rb-inotify (0.9.2)
@@ -443,9 +447,9 @@ GEM @@ -443,9 +447,9 @@ GEM
443 sdoc (0.3.20) 447 sdoc (0.3.20)
444 json (>= 1.1.3) 448 json (>= 1.1.3)
445 rdoc (~> 3.10) 449 rdoc (~> 3.10)
446 - seed-fu (2.3.0)  
447 - activerecord (>= 3.1, < 4.1)  
448 - activesupport (>= 3.1, < 4.1) 450 + seed-fu (2.3.1)
  451 + activerecord (>= 3.1, < 4.2)
  452 + activesupport (>= 3.1, < 4.2)
449 select2-rails (3.5.2) 453 select2-rails (3.5.2)
450 thor (~> 0.14) 454 thor (~> 0.14)
451 settingslogic (2.0.9) 455 settingslogic (2.0.9)
@@ -491,7 +495,7 @@ GEM @@ -491,7 +495,7 @@ GEM
491 multi_json (~> 1.0) 495 multi_json (~> 1.0)
492 rack (~> 1.0) 496 rack (~> 1.0)
493 tilt (~> 1.1, != 1.3.0) 497 tilt (~> 1.1, != 1.3.0)
494 - sprockets-rails (2.0.1) 498 + sprockets-rails (2.1.3)
495 actionpack (>= 3.0) 499 actionpack (>= 3.0)
496 activesupport (>= 3.0) 500 activesupport (>= 3.0)
497 sprockets (~> 2.8) 501 sprockets (~> 2.8)
@@ -510,7 +514,7 @@ GEM @@ -510,7 +514,7 @@ GEM
510 eventmachine (>= 1.0.0) 514 eventmachine (>= 1.0.0)
511 rack (>= 1.0.0) 515 rack (>= 1.0.0)
512 thor (0.19.1) 516 thor (0.19.1)
513 - thread_safe (0.3.3) 517 + thread_safe (0.3.4)
514 tilt (1.4.1) 518 tilt (1.4.1)
515 timers (1.1.0) 519 timers (1.1.0)
516 tinder (1.9.3) 520 tinder (1.9.3)
@@ -532,7 +536,8 @@ GEM @@ -532,7 +536,8 @@ GEM
532 eventmachine (>= 0.12.8) 536 eventmachine (>= 0.12.8)
533 http_parser.rb (~> 0.5.1) 537 http_parser.rb (~> 0.5.1)
534 simple_oauth (~> 0.1.4) 538 simple_oauth (~> 0.1.4)
535 - tzinfo (0.3.39) 539 + tzinfo (1.2.0)
  540 + thread_safe (~> 0.1)
536 uglifier (2.3.2) 541 uglifier (2.3.2)
537 execjs (>= 0.3.0) 542 execjs (>= 0.3.0)
538 json (>= 1.8.0) 543 json (>= 1.8.0)
@@ -612,7 +617,7 @@ DEPENDENCIES @@ -612,7 +617,7 @@ DEPENDENCIES
612 haml-rails 617 haml-rails
613 hipchat (~> 0.14.0) 618 hipchat (~> 0.14.0)
614 httparty 619 httparty
615 - jasmine (= 2.0.0.rc5) 620 + jasmine (= 2.0.2)
616 jquery-atwho-rails (~> 0.3.3) 621 jquery-atwho-rails (~> 0.3.3)
617 jquery-rails 622 jquery-rails
618 jquery-scrollto-rails 623 jquery-scrollto-rails
@@ -621,7 +626,7 @@ DEPENDENCIES @@ -621,7 +626,7 @@ DEPENDENCIES
621 kaminari (~> 0.15.1) 626 kaminari (~> 0.15.1)
622 launchy 627 launchy
623 letter_opener 628 letter_opener
624 - minitest (~> 4.7.0) 629 + minitest (~> 5.3.0)
625 mysql2 630 mysql2
626 nprogress-rails 631 nprogress-rails
627 omniauth (~> 1.1.3) 632 omniauth (~> 1.1.3)
@@ -637,7 +642,7 @@ DEPENDENCIES @@ -637,7 +642,7 @@ DEPENDENCIES
637 rack-attack 642 rack-attack
638 rack-cors 643 rack-cors
639 rack-mini-profiler 644 rack-mini-profiler
640 - rails (~> 4.0.0) 645 + rails (~> 4.1.0)
641 rails-observers 646 rails-observers
642 rails_best_practices 647 rails_best_practices
643 raphael-rails (~> 2.1.2) 648 raphael-rails (~> 2.1.2)
app/controllers/projects_controller.rb
@@ -211,6 +211,6 @@ class ProjectsController &lt; ApplicationController @@ -211,6 +211,6 @@ class ProjectsController &lt; ApplicationController
211 end 211 end
212 212
213 def sorted(users) 213 def sorted(users)
214 - users.uniq.compact.sort_by(&:username).map { |user| { username: user.username, name: user.name } } 214 + users.uniq.to_a.compact.sort_by(&:username).map { |user| { username: user.username, name: user.name } }
215 end 215 end
216 end 216 end
app/controllers/snippets_controller.rb
@@ -14,7 +14,7 @@ class SnippetsController &lt; ApplicationController @@ -14,7 +14,7 @@ class SnippetsController &lt; ApplicationController
14 layout 'navless' 14 layout 'navless'
15 15
16 def index 16 def index
17 - @snippets = Snippet.public.fresh.non_expired.page(params[:page]).per(20) 17 + @snippets = Snippet.are_public.fresh.non_expired.page(params[:page]).per(20)
18 end 18 end
19 19
20 def user_index 20 def user_index
@@ -26,15 +26,15 @@ class SnippetsController &lt; ApplicationController @@ -26,15 +26,15 @@ class SnippetsController &lt; ApplicationController
26 26
27 if @user == current_user 27 if @user == current_user
28 @snippets = case params[:scope] 28 @snippets = case params[:scope]
29 - when 'public' then  
30 - @snippets.public  
31 - when 'private' then  
32 - @snippets.private 29 + when 'are_public' then
  30 + @snippets.are_public
  31 + when 'are_private' then
  32 + @snippets.are_private
33 else 33 else
34 @snippets 34 @snippets
35 end 35 end
36 else 36 else
37 - @snippets = @snippets.public 37 + @snippets = @snippets.are_public
38 end 38 end
39 39
40 @snippets = @snippets.page(params[:page]).per(20) 40 @snippets = @snippets.page(params[:page]).per(20)
app/models/snippet.rb
@@ -34,8 +34,8 @@ class Snippet &lt; ActiveRecord::Base @@ -34,8 +34,8 @@ class Snippet &lt; ActiveRecord::Base
34 validates :content, presence: true 34 validates :content, presence: true
35 35
36 # Scopes 36 # Scopes
37 - scope :public, -> { where(private: false) }  
38 - scope :private, -> { where(private: true) } 37 + scope :are_public, -> { where(private: false) }
  38 + scope :are_private, -> { where(private: true) }
39 scope :fresh, -> { order("created_at DESC") } 39 scope :fresh, -> { order("created_at DESC") }
40 scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) } 40 scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) }
41 scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) } 41 scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) }
app/views/snippets/current_user_index.html.haml
@@ -18,16 +18,16 @@ @@ -18,16 +18,16 @@
18 All 18 All
19 %span.pull-right 19 %span.pull-right
20 = @user.snippets.count 20 = @user.snippets.count
21 - = nav_tab :scope, 'private' do  
22 - = link_to user_snippets_path(@user, scope: 'private') do 21 + = nav_tab :scope, 'are_private' do
  22 + = link_to user_snippets_path(@user, scope: 'are_private') do
23 Private 23 Private
24 %span.pull-right 24 %span.pull-right
25 - = @user.snippets.private.count  
26 - = nav_tab :scope, 'public' do  
27 - = link_to user_snippets_path(@user, scope: 'public') do 25 + = @user.snippets.are_private.count
  26 + = nav_tab :scope, 'are_public' do
  27 + = link_to user_snippets_path(@user, scope: 'are_public') do
28 Public 28 Public
29 %span.pull-right 29 %span.pull-right
30 - = @user.snippets.public.count 30 + = @user.snippets.are_public.count
31 31
32 .col-md-9.my-snippets 32 .col-md-9.my-snippets
33 = render 'snippets' 33 = render 'snippets'
config/environments/production.rb
@@ -74,10 +74,6 @@ Gitlab::Application.configure do @@ -74,10 +74,6 @@ Gitlab::Application.configure do
74 # Send deprecation notices to registered listeners 74 # Send deprecation notices to registered listeners
75 config.active_support.deprecation = :notify 75 config.active_support.deprecation = :notify
76 76
77 - # Log the query plan for queries taking more than this (works  
78 - # with SQLite, MySQL, and PostgreSQL)  
79 - # config.active_record.auto_explain_threshold_in_seconds = 0.5  
80 -  
81 config.action_mailer.delivery_method = :sendmail 77 config.action_mailer.delivery_method = :sendmail
82 # Defaults to: 78 # Defaults to:
83 # # config.action_mailer.sendmail_settings = { 79 # # config.action_mailer.sendmail_settings = {
config/initializers/acts_as_taggable_on_patch.rb 0 → 100644
@@ -0,0 +1,130 @@ @@ -0,0 +1,130 @@
  1 +# This is a patch to address the issue in https://github.com/mbleigh/acts-as-taggable-on/issues/427 caused by
  2 +# https://github.com/rails/rails/commit/31a43ebc107fbd50e7e62567e5208a05909ec76c
  3 +# gem 'acts-as-taggable-on' has the fix included https://github.com/mbleigh/acts-as-taggable-on/commit/89bbed3864a9252276fb8dd7d535fce280454b90
  4 +# but not in the currently used version of gem ('2.4.1')
  5 +# With replacement of 'acts-as-taggable-on' gem this file will become obsolete
  6 +
  7 +module ActsAsTaggableOn::Taggable
  8 + module Core
  9 + module ClassMethods
  10 + def tagged_with(tags, options = {})
  11 + tag_list = ActsAsTaggableOn::TagList.from(tags)
  12 + empty_result = where("1 = 0")
  13 +
  14 + return empty_result if tag_list.empty?
  15 +
  16 + joins = []
  17 + conditions = []
  18 + having = []
  19 + select_clause = []
  20 +
  21 + context = options.delete(:on)
  22 + owned_by = options.delete(:owned_by)
  23 + alias_base_name = undecorated_table_name.gsub('.','_')
  24 + quote = ActsAsTaggableOn::Tag.using_postgresql? ? '"' : ''
  25 +
  26 + if options.delete(:exclude)
  27 + if options.delete(:wild)
  28 + tags_conditions = tag_list.map { |t| sanitize_sql(["#{ActsAsTaggableOn::Tag.table_name}.name #{like_operator} ? ESCAPE '!'", "%#{escape_like(t)}%"]) }.join(" OR ")
  29 + else
  30 + tags_conditions = tag_list.map { |t| sanitize_sql(["#{ActsAsTaggableOn::Tag.table_name}.name #{like_operator} ?", t]) }.join(" OR ")
  31 + end
  32 +
  33 + conditions << "#{table_name}.#{primary_key} NOT IN (SELECT #{ActsAsTaggableOn::Tagging.table_name}.taggable_id FROM #{ActsAsTaggableOn::Tagging.table_name} JOIN #{ActsAsTaggableOn::Tag.table_name} ON #{ActsAsTaggableOn::Tagging.table_name}.tag_id = #{ActsAsTaggableOn::Tag.table_name}.#{ActsAsTaggableOn::Tag.primary_key} AND (#{tags_conditions}) WHERE #{ActsAsTaggableOn::Tagging.table_name}.taggable_type = #{quote_value(base_class.name, nil)})"
  34 +
  35 + if owned_by
  36 + joins << "JOIN #{ActsAsTaggableOn::Tagging.table_name}" +
  37 + " ON #{ActsAsTaggableOn::Tagging.table_name}.taggable_id = #{quote}#{table_name}#{quote}.#{primary_key}" +
  38 + " AND #{ActsAsTaggableOn::Tagging.table_name}.taggable_type = #{quote_value(base_class.name, nil)}" +
  39 + " AND #{ActsAsTaggableOn::Tagging.table_name}.tagger_id = #{owned_by.id}" +
  40 + " AND #{ActsAsTaggableOn::Tagging.table_name}.tagger_type = #{quote_value(owned_by.class.base_class.to_s, nil)}"
  41 + end
  42 +
  43 + elsif options.delete(:any)
  44 + # get tags, drop out if nothing returned (we need at least one)
  45 + tags = if options.delete(:wild)
  46 + ActsAsTaggableOn::Tag.named_like_any(tag_list)
  47 + else
  48 + ActsAsTaggableOn::Tag.named_any(tag_list)
  49 + end
  50 +
  51 + return empty_result unless tags.length > 0
  52 +
  53 + # setup taggings alias so we can chain, ex: items_locations_taggings_awesome_cool_123
  54 + # avoid ambiguous column name
  55 + taggings_context = context ? "_#{context}" : ''
  56 +
  57 + taggings_alias = adjust_taggings_alias(
  58 + "#{alias_base_name[0..4]}#{taggings_context[0..6]}_taggings_#{sha_prefix(tags.map(&:name).join('_'))}"
  59 + )
  60 +
  61 + tagging_join = "JOIN #{ActsAsTaggableOn::Tagging.table_name} #{taggings_alias}" +
  62 + " ON #{taggings_alias}.taggable_id = #{quote}#{table_name}#{quote}.#{primary_key}" +
  63 + " AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name, nil)}"
  64 + tagging_join << " AND " + sanitize_sql(["#{taggings_alias}.context = ?", context.to_s]) if context
  65 +
  66 + # don't need to sanitize sql, map all ids and join with OR logic
  67 + conditions << tags.map { |t| "#{taggings_alias}.tag_id = #{t.id}" }.join(" OR ")
  68 + select_clause = "DISTINCT #{table_name}.*" unless context and tag_types.one?
  69 +
  70 + if owned_by
  71 + tagging_join << " AND " +
  72 + sanitize_sql([
  73 + "#{taggings_alias}.tagger_id = ? AND #{taggings_alias}.tagger_type = ?",
  74 + owned_by.id,
  75 + owned_by.class.base_class.to_s
  76 + ])
  77 + end
  78 +
  79 + joins << tagging_join
  80 + else
  81 + tags = ActsAsTaggableOn::Tag.named_any(tag_list)
  82 +
  83 + return empty_result unless tags.length == tag_list.length
  84 +
  85 + tags.each do |tag|
  86 + taggings_alias = adjust_taggings_alias("#{alias_base_name[0..11]}_taggings_#{sha_prefix(tag.name)}")
  87 + tagging_join = "JOIN #{ActsAsTaggableOn::Tagging.table_name} #{taggings_alias}" +
  88 + " ON #{taggings_alias}.taggable_id = #{quote}#{table_name}#{quote}.#{primary_key}" +
  89 + " AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name, nil)}" +
  90 + " AND #{taggings_alias}.tag_id = #{tag.id}"
  91 +
  92 + tagging_join << " AND " + sanitize_sql(["#{taggings_alias}.context = ?", context.to_s]) if context
  93 +
  94 + if owned_by
  95 + tagging_join << " AND " +
  96 + sanitize_sql([
  97 + "#{taggings_alias}.tagger_id = ? AND #{taggings_alias}.tagger_type = ?",
  98 + owned_by.id,
  99 + owned_by.class.base_class.to_s
  100 + ])
  101 + end
  102 +
  103 + joins << tagging_join
  104 + end
  105 + end
  106 +
  107 + taggings_alias, tags_alias = adjust_taggings_alias("#{alias_base_name}_taggings_group"), "#{alias_base_name}_tags_group"
  108 +
  109 + if options.delete(:match_all)
  110 + joins << "LEFT OUTER JOIN #{ActsAsTaggableOn::Tagging.table_name} #{taggings_alias}" +
  111 + " ON #{taggings_alias}.taggable_id = #{quote}#{table_name}#{quote}.#{primary_key}" +
  112 + " AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name, nil)}"
  113 +
  114 +
  115 + group_columns = ActsAsTaggableOn::Tag.using_postgresql? ? grouped_column_names_for(self) : "#{table_name}.#{primary_key}"
  116 + group = group_columns
  117 + having = "COUNT(#{taggings_alias}.taggable_id) = #{tags.size}"
  118 + end
  119 +
  120 + select(select_clause) \
  121 + .joins(joins.join(" ")) \
  122 + .where(conditions.join(" AND ")) \
  123 + .group(group) \
  124 + .having(having) \
  125 + .order(options[:order]) \
  126 + .readonly(false)
  127 + end
  128 + end
  129 + end
  130 +end
config/initializers/state_machine_patch.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +# This is a patch to address the issue in https://github.com/pluginaweek/state_machine/issues/251
  2 +# where gem 'state_machine' was not working for Rails 4.1
  3 +module StateMachine
  4 + module Integrations
  5 + module ActiveModel
  6 + public :around_validation
  7 + end
  8 + end
  9 +end
spec/helpers/submodule_helper_spec.rb
@@ -16,7 +16,8 @@ describe SubmoduleHelper do @@ -16,7 +16,8 @@ describe SubmoduleHelper do
16 end 16 end
17 17
18 it 'should detect ssh on standard port' do 18 it 'should detect ssh on standard port' do
19 - Gitlab.config.gitlab.stub(ssh_port: 22) # set this just to be sure 19 + Gitlab.config.gitlab_shell.stub(ssh_port: 22) # set this just to be sure
  20 + Gitlab.config.gitlab_shell.stub(ssh_path_prefix: Settings.send(:build_gitlab_shell_ssh_path_prefix))
20 stub_url([ config.user, '@', config.host, ':gitlab-org/gitlab-ce.git' ].join('')) 21 stub_url([ config.user, '@', config.host, ':gitlab-org/gitlab-ce.git' ].join(''))
21 submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ] 22 submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
22 end 23 end
spec/models/system_hook_spec.rb
@@ -59,7 +59,7 @@ describe SystemHook do @@ -59,7 +59,7 @@ describe SystemHook do
59 user = create(:user) 59 user = create(:user)
60 project = create(:project) 60 project = create(:project)
61 project.team << [user, :master] 61 project.team << [user, :master]
62 - project.users_projects.clear 62 + project.users_projects.destroy_all
63 WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once 63 WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once
64 end 64 end
65 end 65 end