From ce1fd7bc79eb9fb0b9b271a95350bd9e3faa48e9 Mon Sep 17 00:00:00 2001 From: Erik Offenbach Date: Mon, 16 Mar 2020 15:31:52 +0100 Subject: [PATCH] Push rails dependency to 5.2, fixing related specs --- Gemfile | 2 +- Gemfile.lock | 189 +++++++++++------- app/models/survey/attempt.rb | 2 +- lib/survey.rb | 10 +- lib/survey/active_record.rb | 6 +- survey.gemspec | 4 +- .../db/migrate/20130123110019_create_users.rb | 2 +- .../migrate/20130201105206_create_survey.rb | 2 +- test/test_helper.rb | 6 +- 9 files changed, 135 insertions(+), 88 deletions(-) diff --git a/Gemfile b/Gemfile index 331e337..fcd5a84 100644 --- a/Gemfile +++ b/Gemfile @@ -6,4 +6,4 @@ gem "rdoc" group :test do gem 'sqlite3' -end \ No newline at end of file +end diff --git a/Gemfile.lock b/Gemfile.lock index 3c5ad8f..1357f7d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,100 +2,141 @@ PATH remote: . specs: survey (0.1) - rails (>= 3.2.6, < 5) - railties (>= 3.2.6, < 5) + rails (>= 3.2.6) + railties (>= 3.2.6) GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.2) - actionpack (= 4.0.2) - mail (~> 2.5.4) - actionpack (4.0.2) - activesupport (= 4.0.2) - builder (~> 3.1.0) - erubis (~> 2.7.0) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - activemodel (4.0.2) - activesupport (= 4.0.2) - builder (~> 3.1.0) - activerecord (4.0.2) - activemodel (= 4.0.2) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.2) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.3) - activesupport (4.0.2) - i18n (~> 0.6, >= 0.6.4) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.37) - arel (4.0.1) - atomic (1.1.14) - builder (3.1.4) - erubis (2.7.0) + actioncable (5.2.4.1) + actionpack (= 5.2.4.1) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.1) + actionpack (= 5.2.4.1) + actionview (= 5.2.4.1) + activejob (= 5.2.4.1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.1) + actionview (= 5.2.4.1) + activesupport (= 5.2.4.1) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.1) + activesupport (= 5.2.4.1) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.1) + activesupport (= 5.2.4.1) + globalid (>= 0.3.6) + activemodel (5.2.4.1) + activesupport (= 5.2.4.1) + activerecord (5.2.4.1) + activemodel (= 5.2.4.1) + activesupport (= 5.2.4.1) + arel (>= 9.0) + activestorage (5.2.4.1) + actionpack (= 5.2.4.1) + activerecord (= 5.2.4.1) + marcel (~> 0.3.1) + activesupport (5.2.4.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + builder (3.2.4) + byebug (11.0.1) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) faker (1.1.2) i18n (~> 0.5) - hike (1.2.3) - i18n (0.6.9) - json (1.7.6) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + json (1.8.6) + loofah (2.4.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) metaclass (0.0.1) - mime-types (1.25.1) - minitest (4.7.5) + method_source (0.9.2) + mimemagic (0.3.4) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.0) mocha (0.13.2) metaclass (~> 0.0.1) - multi_json (1.8.2) - polyglot (0.3.3) - rack (1.5.2) - rack-test (0.6.2) - rack (>= 1.0) - rails (4.0.2) - actionmailer (= 4.0.2) - actionpack (= 4.0.2) - activerecord (= 4.0.2) - activesupport (= 4.0.2) - bundler (>= 1.3.0, < 2.0) - railties (= 4.0.2) - sprockets-rails (~> 2.0.0) - railties (4.0.2) - actionpack (= 4.0.2) - activesupport (= 4.0.2) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + rack (2.2.2) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.1) + actioncable (= 5.2.4.1) + actionmailer (= 5.2.4.1) + actionpack (= 5.2.4.1) + actionview (= 5.2.4.1) + activejob (= 5.2.4.1) + activemodel (= 5.2.4.1) + activerecord (= 5.2.4.1) + activestorage (= 5.2.4.1) + activesupport (= 5.2.4.1) + bundler (>= 1.3.0) + railties (= 5.2.4.1) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.1) + actionpack (= 5.2.4.1) + activesupport (= 5.2.4.1) + method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rake (10.0.3) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) rdoc (3.12) json (~> 1.4) - sprockets (2.10.1) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.0.1) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (~> 2.8) - sqlite3 (1.3.7) - thor (0.18.1) - thread_safe (0.1.3) - atomic - tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.38) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tzinfo (1.2.6) + thread_safe (~> 0.1) + websocket-driver (0.7.1) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) PLATFORMS ruby DEPENDENCIES + byebug faker mocha rake rdoc sqlite3 survey! + +BUNDLED WITH + 2.1.2 diff --git a/app/models/survey/attempt.rb b/app/models/survey/attempt.rb index 57537b5..e12da91 100644 --- a/app/models/survey/attempt.rb +++ b/app/models/survey/attempt.rb @@ -25,7 +25,7 @@ class Survey::Attempt < ActiveRecord::Base scope :for_survey, ->(survey) { where(:survey_id => survey.id) } scope :exclude_survey, ->(survey) { where("NOT survey_id = #{survey.id}") } scope :for_participant, ->(participant) { - where(:participant_id => participant.try(:id), :participant_type => participant.class.base_class) + where(:participant_id => participant.try(:id), :participant_type => participant.class.base_class.name) } # callbacks diff --git a/lib/survey.rb b/lib/survey.rb index be0e532..b78437c 100644 --- a/lib/survey.rb +++ b/lib/survey.rb @@ -1,10 +1,10 @@ module ::Kernel - def rails4? - return defined?(Rails) && Rails::VERSION::MAJOR == 4 + def rails_less_than_4? + return defined?(Rails) && Rails::VERSION::MAJOR < 4 end - + def in_rails_3(&block) - yield if block_given? unless rails4? + yield if block_given? if rails_less_than_4? end end @@ -12,4 +12,4 @@ def in_rails_3(&block) require 'survey/version' require 'survey/active_record' -ActiveRecord::Base.send(:include, Survey::ActiveRecord) \ No newline at end of file +ActiveRecord::Base.send(:include, Survey::ActiveRecord) diff --git a/lib/survey/active_record.rb b/lib/survey/active_record.rb index a9d19e5..c417816 100644 --- a/lib/survey/active_record.rb +++ b/lib/survey/active_record.rb @@ -4,7 +4,9 @@ module ActiveRecord module ClassMethods def has_surveys - has_many :survey_tentatives, as: :participant, :class_name => ::Survey::Attempt + has_many :survey_tentatives, + as: :participant, + :class_name => ::Survey::Attempt.name define_method("for_survey") do |survey| self.survey_tentatives.where(:survey_id => survey.id) @@ -25,4 +27,4 @@ def acceptable_attributes(*args) end end end -end \ No newline at end of file +end diff --git a/survey.gemspec b/survey.gemspec index 31d8e3e..3e023a4 100644 --- a/survey.gemspec +++ b/survey.gemspec @@ -11,8 +11,8 @@ Gem::Specification.new do |s| s.authors = %Q{Runtime Revolution} s.require_paths = %w(lib) - s.add_dependency("rails", [">= 3.2.6", "< 5"]) - s.add_dependency("railties", ">= 3.2.6", "< 5") + s.add_dependency("rails", [">= 3.2.6"]) + s.add_dependency("railties", ">= 3.2.6") s.add_development_dependency("mocha") s.add_development_dependency("faker") s.add_development_dependency("rake") diff --git a/test/dummy/db/migrate/20130123110019_create_users.rb b/test/dummy/db/migrate/20130123110019_create_users.rb index 37ce317..7187df3 100644 --- a/test/dummy/db/migrate/20130123110019_create_users.rb +++ b/test/dummy/db/migrate/20130123110019_create_users.rb @@ -1,4 +1,4 @@ -class CreateUsers < ActiveRecord::Migration +class CreateUsers < ActiveRecord::Migration[4.2] def change create_table :users do |t| t.string :name diff --git a/test/dummy/db/migrate/20130201105206_create_survey.rb b/test/dummy/db/migrate/20130201105206_create_survey.rb index c9a1111..c9b47e3 100644 --- a/test/dummy/db/migrate/20130201105206_create_survey.rb +++ b/test/dummy/db/migrate/20130201105206_create_survey.rb @@ -1,4 +1,4 @@ -class CreateSurvey < ActiveRecord::Migration +class CreateSurvey < ActiveRecord::Migration[4.2] def self.up # survey surveys logic diff --git a/test/test_helper.rb b/test/test_helper.rb index 5e8687a..5473ee4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -9,7 +9,11 @@ Rails.backtrace_cleaner.remove_silencers! # Run any available migration -ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__) +if Rails.gem_version >= Gem::Version.new('5.2.0') + ActiveRecord::MigrationContext.new(File.expand_path('../dummy/db/migrate', __FILE__)).migrate +else + ActiveRecord::Migrator.migrate(File.expand_path('../dummy/db/migrate', __FILE__)) +end # Load support files # Add support to load paths so we can overwrite broken webrat setup