From 492d9fde310047cebf5eb542a04b2069dd126396 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Mon, 16 Jan 2017 11:56:32 +0100 Subject: [PATCH] bump rails to 5.0.1 --- Gemfile | 2 +- Gemfile.lock | 88 ++++++++--------- config/initializers/ar_readonly_patch.rb | 97 ------------------- ...4115743_migrate_remaining_core_settings.rb | 8 -- ...81236_type_attribute_visibility_to_hash.rb | 4 - ...20160913125802_timeline_options_to_hash.rb | 4 - .../20160926102618_setting_value_to_hash.rb | 4 - ...35400_query_empty_column_names_to_array.rb | 4 - .../migration_utils/ar_parameter_patch.rb | 78 --------------- .../attachments_controller_spec.rb | 1 + 10 files changed, 45 insertions(+), 245 deletions(-) delete mode 100644 config/initializers/ar_readonly_patch.rb delete mode 100644 db/migrate/migration_utils/ar_parameter_patch.rb diff --git a/Gemfile b/Gemfile index aae48ac85d..d281629361 100644 --- a/Gemfile +++ b/Gemfile @@ -30,7 +30,7 @@ source 'https://rubygems.org' ruby '>= 2.2.5' -gem 'rails', '~> 5.0.0' +gem 'rails', '~> 5.0.1' gem 'actionpack-xml_parser', '~> 2.0.0' gem 'activemodel-serializers-xml', '~> 1.0.1' gem 'activerecord-session_store', '~> 1.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index 44464688e2..a21b33043c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,19 +98,19 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (5.0.0.1) - actionpack (= 5.0.0.1) + actioncable (5.0.1) + actionpack (= 5.0.1) nio4r (~> 1.2) websocket-driver (~> 0.6.1) - actionmailer (5.0.0.1) - actionpack (= 5.0.0.1) - actionview (= 5.0.0.1) - activejob (= 5.0.0.1) + actionmailer (5.0.1) + actionpack (= 5.0.1) + actionview (= 5.0.1) + activejob (= 5.0.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.0.0.1) - actionview (= 5.0.0.1) - activesupport (= 5.0.0.1) + actionpack (5.0.1) + actionview (= 5.0.1) + activesupport (= 5.0.1) rack (~> 2.0) rack-test (~> 0.6.3) rails-dom-testing (~> 2.0) @@ -118,26 +118,26 @@ GEM actionpack-xml_parser (2.0.0) actionpack (~> 5.x) railties (~> 5.x) - actionview (5.0.0.1) - activesupport (= 5.0.0.1) + actionview (5.0.1) + activesupport (= 5.0.1) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) active_record_query_trace (1.5.4) - activejob (5.0.0.1) - activesupport (= 5.0.0.1) + activejob (5.0.1) + activesupport (= 5.0.1) globalid (>= 0.3.6) - activemodel (5.0.0.1) - activesupport (= 5.0.0.1) + activemodel (5.0.1) + activesupport (= 5.0.1) activemodel-serializers-xml (1.0.1) activemodel (> 5.x) activerecord (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (5.0.0.1) - activemodel (= 5.0.0.1) - activesupport (= 5.0.0.1) + activerecord (5.0.1) + activemodel (= 5.0.1) + activesupport (= 5.0.1) arel (~> 7.0) activerecord-session_store (1.0.0) actionpack (>= 4.0, < 5.1) @@ -145,7 +145,7 @@ GEM multi_json (~> 1.11, >= 1.11.2) rack (>= 1.5.2, < 3) railties (>= 4.0, < 5.1) - activesupport (5.0.0.1) + activesupport (5.0.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) @@ -158,7 +158,7 @@ GEM airbrake (5.1.0) airbrake-ruby (~> 1.1) airbrake-ruby (1.5.0) - arel (7.1.2) + arel (7.1.4) ast (2.3.0) autoprefixer-rails (6.4.1.1) execjs @@ -174,7 +174,7 @@ GEM bourbon (4.2.7) sass (~> 3.4) thor (~> 0.19) - builder (3.2.2) + builder (3.2.3) byebug (9.0.5) capybara (2.8.1) addressable @@ -210,7 +210,7 @@ GEM coercible (1.0.0) descendants_tracker (~> 0.0.1) color-tools (1.3.0) - concurrent-ruby (1.0.2) + concurrent-ruby (1.0.4) crack (0.4.3) safe_yaml (~> 1.0.0) crowdin-api (0.4.1) @@ -346,7 +346,7 @@ GEM mime-types (2.99.3) mini_portile2 (2.1.0) minisyntax (0.2.5) - minitest (5.9.0) + minitest (5.10.1) mixlib-shellout (2.1.0) multi_json (1.12.1) multi_test (0.1.2) @@ -358,9 +358,8 @@ GEM netrc (0.11.0) newrelic_rpm (3.16.2.321) nio4r (1.2.1) - nokogiri (1.6.8) + nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) - pkg-config (~> 1.1.7) oj (2.17.4) parallel (1.9.0) parallel_tests (2.4.1) @@ -372,7 +371,6 @@ GEM rake (>= 0.8.1) pdf-core (0.6.1) pg (0.19.0) - pkg-config (1.1.7) powerpack (0.1.1) prawn (2.1.0) pdf-core (~> 0.6.1) @@ -411,21 +409,21 @@ GEM rack_session_access (0.1.1) builder (>= 2.0.0) rack (>= 1.0.0) - rails (5.0.0.1) - actioncable (= 5.0.0.1) - actionmailer (= 5.0.0.1) - actionpack (= 5.0.0.1) - actionview (= 5.0.0.1) - activejob (= 5.0.0.1) - activemodel (= 5.0.0.1) - activerecord (= 5.0.0.1) - activesupport (= 5.0.0.1) + rails (5.0.1) + actioncable (= 5.0.1) + actionmailer (= 5.0.1) + actionpack (= 5.0.1) + actionview (= 5.0.1) + activejob (= 5.0.1) + activemodel (= 5.0.1) + activerecord (= 5.0.1) + activesupport (= 5.0.1) bundler (>= 1.3.0, < 2.0) - railties (= 5.0.0.1) + railties (= 5.0.1) sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.1) + rails-dom-testing (2.0.2) activesupport (>= 4.2.0, < 6.0) - nokogiri (~> 1.6.0) + nokogiri (~> 1.6) rails-html-sanitizer (1.0.3) loofah (~> 2.0) rails_12factor (0.0.3) @@ -435,15 +433,15 @@ GEM rails (> 3.1) rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (5.0.0.1) - actionpack (= 5.0.0.1) - activesupport (= 5.0.0.1) + railties (5.0.1) + actionpack (= 5.0.1) + activesupport (= 5.0.1) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.1.0) raindrops (0.17.0) - rake (11.3.0) + rake (12.0.0) rdoc (4.2.2) json (~> 1.4) redcarpet (3.3.4) @@ -527,7 +525,7 @@ GEM simplecov-html (~> 0.10.0) simplecov-html (0.10.0) slop (3.6.0) - sprockets (3.7.0) + sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.0) @@ -545,7 +543,7 @@ GEM daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (0.19.1) + thor (0.19.4) thread_safe (0.3.5) tilt (2.0.5) timecop (0.8.1) @@ -666,7 +664,7 @@ DEPENDENCIES rack-protection (~> 2.0.0.beta2) rack-test (~> 0.6.3) rack_session_access - rails (~> 5.0.0) + rails (~> 5.0.1) rails-angular-xss! rails-controller-testing! rails_12factor diff --git a/config/initializers/ar_readonly_patch.rb b/config/initializers/ar_readonly_patch.rb deleted file mode 100644 index bdca9c9875..0000000000 --- a/config/initializers/ar_readonly_patch.rb +++ /dev/null @@ -1,97 +0,0 @@ -#-- encoding: UTF-8 -#-- copyright -# OpenProject is a project management system. -# Copyright (C) 2012-2017 the OpenProject Foundation (OPF) -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2017 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See doc/COPYRIGHT.rdoc for more details. -#++ - -if Rails.gem_version > Gem::Version.new('5.0.0.1') - raise <<-MESSAGE - - - Patching active record is no longer necessary as rails/rails#3cffae5953021966204854fa73bef2f9cd366e9b is part of the used rails version now. Remove the patch in config/initializers/ar_readonly_patch.rb - - - MESSAGE -end - -module MacroReflectionPatch - def scope_for(klass) - scope ? klass.unscoped.instance_exec(nil, &scope) : klass.unscoped - end -end - -ActiveRecord::Reflection::MacroReflection.prepend(MacroReflectionPatch) -ActiveRecord::Reflection::ThroughReflection.prepend(MacroReflectionPatch) - -module JoinDependencyPatch - def construct(ar_parent, parent, row, rs, seen, model_cache, aliases) - return if ar_parent.nil? - - parent.children.each do |node| - if node.reflection.collection? - other = ar_parent.association(node.reflection.name) - other.loaded! - elsif ar_parent.association_cached?(node.reflection.name) - model = ar_parent.association(node.reflection.name).target - construct(model, node, row, rs, seen, model_cache, aliases) - next - end - - key = aliases.column_alias(node, node.primary_key) - id = row[key] - if id.nil? - nil_association = ar_parent.association(node.reflection.name) - nil_association.loaded! - next - end - - model = seen[ar_parent.object_id][node.base_klass][id] - - if model - construct(model, node, row, rs, seen, model_cache, aliases) - else - model = construct_model(ar_parent, node, row, model_cache, id, aliases) - - if node.reflection.scope_for(node.base_klass).readonly_value - model.readonly! - end - - seen[ar_parent.object_id][node.base_klass][id] = model - construct(model, node, row, rs, seen, model_cache, aliases) - end - end - end -end - -ActiveRecord::Associations::JoinDependency.prepend(JoinDependencyPatch) - -module PreloaderAssociationPatch - def reflection_scope - @reflection_scope ||= reflection.scope_for(klass) - end -end - -ActiveRecord::Associations::Preloader::Association.prepend(JoinDependencyPatch) diff --git a/db/migrate/20131024115743_migrate_remaining_core_settings.rb b/db/migrate/20131024115743_migrate_remaining_core_settings.rb index 3d37138bd4..e9f9007a56 100644 --- a/db/migrate/20131024115743_migrate_remaining_core_settings.rb +++ b/db/migrate/20131024115743_migrate_remaining_core_settings.rb @@ -27,8 +27,6 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require_relative 'migration_utils/ar_parameter_patch' - class MigrateRemainingCoreSettings < ActiveRecord::Migration[4.2] REPLACED = { 'tracker' => 'type', @@ -38,9 +36,6 @@ class MigrateRemainingCoreSettings < ActiveRecord::Migration[4.2] 'updated_on' => 'updated_at' } def self.up - - ArParametersPatch.load - # Delete old plugin settings no longer needed ActiveRecord::Base.connection.execute <<-SQL DELETE FROM #{settings_table} @@ -56,9 +51,6 @@ class MigrateRemainingCoreSettings < ActiveRecord::Migration[4.2] end def self.down - - ArParametersPatch.load - # the above delete part is inherently not reversable # Rename Type to Tracker Setting['work_package_list_default_columns'] = replace(Setting['work_package_list_default_columns'], REPLACED.invert) diff --git a/db/migrate/20160913081236_type_attribute_visibility_to_hash.rb b/db/migrate/20160913081236_type_attribute_visibility_to_hash.rb index 430f445d26..9a256a415f 100644 --- a/db/migrate/20160913081236_type_attribute_visibility_to_hash.rb +++ b/db/migrate/20160913081236_type_attribute_visibility_to_hash.rb @@ -27,8 +27,6 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require_relative 'migration_utils/ar_parameter_patch' - class TypeAttributeVisibilityToHash < ActiveRecord::Migration[5.0] class TypeWithWhatever < ActiveRecord::Base self.table_name = :types @@ -43,8 +41,6 @@ class TypeAttributeVisibilityToHash < ActiveRecord::Migration[5.0] end def up - ArParametersPatch.load - TypeWithWhatever.transaction do TypeWithWhatever.all.to_a.each do |type| visibility = type.attribute_visibility diff --git a/db/migrate/20160913125802_timeline_options_to_hash.rb b/db/migrate/20160913125802_timeline_options_to_hash.rb index b573fb4e3a..59d96ad4b3 100644 --- a/db/migrate/20160913125802_timeline_options_to_hash.rb +++ b/db/migrate/20160913125802_timeline_options_to_hash.rb @@ -27,8 +27,6 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require_relative 'migration_utils/ar_parameter_patch' - class TimelineOptionsToHash < ActiveRecord::Migration[5.0] class TimelineWithWhatever < ActiveRecord::Base self.table_name = :timelines @@ -43,8 +41,6 @@ class TimelineOptionsToHash < ActiveRecord::Migration[5.0] end def up - ArParametersPatch.load - TimelineWithWhatever.transaction do TimelineWithWhatever.all.to_a.each do |timeline| options = timeline.options diff --git a/db/migrate/20160926102618_setting_value_to_hash.rb b/db/migrate/20160926102618_setting_value_to_hash.rb index 0476978273..3382f35a07 100644 --- a/db/migrate/20160926102618_setting_value_to_hash.rb +++ b/db/migrate/20160926102618_setting_value_to_hash.rb @@ -27,8 +27,6 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require_relative 'migration_utils/ar_parameter_patch' - class SettingValueToHash < ActiveRecord::Migration[5.0] class SettingWithWhatever < ActiveRecord::Base self.table_name = :settings @@ -43,8 +41,6 @@ class SettingValueToHash < ActiveRecord::Migration[5.0] end def up - ArParametersPatch.load - SettingWithWhatever.transaction do SettingWithWhatever.all.to_a.each do |setting| value = setting.value diff --git a/db/migrate/20161025135400_query_empty_column_names_to_array.rb b/db/migrate/20161025135400_query_empty_column_names_to_array.rb index 7beb6afe7d..7da2ecba0f 100644 --- a/db/migrate/20161025135400_query_empty_column_names_to_array.rb +++ b/db/migrate/20161025135400_query_empty_column_names_to_array.rb @@ -27,8 +27,6 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require_relative 'migration_utils/ar_parameter_patch' - class QueryEmptyColumnNamesToArray < ActiveRecord::Migration[5.0] class QueryWithWhatever < ActiveRecord::Base self.table_name = :queries @@ -36,8 +34,6 @@ class QueryEmptyColumnNamesToArray < ActiveRecord::Migration[5.0] end def up - ArParametersPatch.load - QueryWithWhatever.transaction do empty = QueryWithWhatever.where(column_names: '') null = QueryWithWhatever.where(column_names: nil) diff --git a/db/migrate/migration_utils/ar_parameter_patch.rb b/db/migrate/migration_utils/ar_parameter_patch.rb deleted file mode 100644 index 73bfe285b5..0000000000 --- a/db/migrate/migration_utils/ar_parameter_patch.rb +++ /dev/null @@ -1,78 +0,0 @@ -#-- encoding: UTF-8 -#-- copyright -# OpenProject is a project management system. -# Copyright (C) 2012-2017 the OpenProject Foundation (OPF) -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2017 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See doc/COPYRIGHT.rdoc for more details. -#++ - -if Rails.gem_version >= Gem::Version.new('5.0.1') - raise <<-MESSAGE - - - The patch applied to ActionController::Parameters is now part of rails itself. Check, if the patch can be removed. - - - MESSAGE -end - -module ArParametersPatch - - def self.load - hook_into_yaml_loading - - ActionController::Parameters.prepend(ArParametersPatch::InitWith) - end - - # Taken straight from https://github.com/rails/rails/compare/6b44155%5E...70b995a - # which will become part of rails 5.1 - def self.hook_into_yaml_loading # :nodoc: - # Wire up YAML format compatibility with Rails 4.2 and Psych 2.0.8 and 2.0.9+. - # Makes the YAML parser call `init_with` when it encounters the keys below - # instead of trying its own parsing routines. - name = ActionController::Parameters.name - YAML.load_tags["!ruby/hash-with-ivars:ActionController::Parameters"] = name - YAML.load_tags["!ruby/hash:ActionController::Parameters"] = name - end - - module InitWith - def init_with(coder) # :nodoc: - case coder.tag - when "!ruby/hash:ActionController::Parameters" - # YAML 2.0.8's format where hash instance variables weren't stored. - @parameters = coder.map.with_indifferent_access - @permitted = false - when "!ruby/hash-with-ivars:ActionController::Parameters" - # YAML 2.0.9's Hash subclass format where keys and values - # were stored under an elements hash and `permitted` within an ivars hash. - @parameters = coder.map["elements"].with_indifferent_access - @permitted = coder.map["ivars"][:@permitted] - when "!ruby/object:ActionController::Parameters" - # YAML's Object format. Only needed because of the format - # backwardscompability above, otherwise equivalent to YAML's initialization. - @parameters, @permitted = coder.map["parameters"], coder.map["permitted"] - end - end - end -end diff --git a/spec/controllers/attachments_controller_spec.rb b/spec/controllers/attachments_controller_spec.rb index d148127b39..f3594ebd09 100644 --- a/spec/controllers/attachments_controller_spec.rb +++ b/spec/controllers/attachments_controller_spec.rb @@ -125,6 +125,7 @@ describe AttachmentsController, type: :controller do att.id = 42 att.file.store! att.send :write_attribute, :file, file.original_filename + att.send :write_attribute, :content_type, file.content_type att end