Business intelligence made simple
Dropped support for Rails < 5
Andrew Kane78609f3fbe83
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7fd7258d..7c4f515b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,3 +1,7 @@+## 2.2.0 [unreleased]++- Dropped support for Rails 4.2+## 2.1.0- Require latest Chartkick to prevent possible XSS - see [#245](https://github.com/ankane/blazer/issues/245)diff --git a/app/controllers/blazer/base_controller.rb b/app/controllers/blazer/base_controller.rbindex 7790e07d..9d14b84d 100644--- a/app/controllers/blazer/base_controller.rb+++ b/app/controllers/blazer/base_controller.rb@@ -2,13 +2,9 @@ module Blazerclass BaseController < ApplicationController# skip filtersfilters = _process_action_callbacks.map(&:filter) - [:activate_authlogic]- if Rails::VERSION::MAJOR >= 5- skip_before_action(*filters, raise: false)- skip_after_action(*filters, raise: false)- skip_around_action(*filters, raise: false)- else- skip_action_callback(*filters)- end+ skip_before_action(*filters, raise: false)+ skip_after_action(*filters, raise: false)+ skip_around_action(*filters, raise: false)protect_from_forgery with: :exceptiondiff --git a/app/models/blazer/audit.rb b/app/models/blazer/audit.rbindex edb60610..3c31a5cd 100644--- a/app/models/blazer/audit.rb+++ b/app/models/blazer/audit.rb@@ -1,6 +1,6 @@module Blazerclass Audit < Record- belongs_to :user, Blazer::BELONGS_TO_OPTIONAL.merge(class_name: Blazer.user_class.to_s)- belongs_to :query, Blazer::BELONGS_TO_OPTIONAL+ belongs_to :user, optional: true, class_name: Blazer.user_class.to_s+ belongs_to :query, optional: trueendenddiff --git a/app/models/blazer/check.rb b/app/models/blazer/check.rbindex bab53709..194c3797 100644--- a/app/models/blazer/check.rb+++ b/app/models/blazer/check.rb@@ -1,6 +1,6 @@module Blazerclass Check < Record- belongs_to :creator, Blazer::BELONGS_TO_OPTIONAL.merge(class_name: Blazer.user_class.to_s) if Blazer.user_class+ belongs_to :creator, optional: true, class_name: Blazer.user_class.to_s if Blazer.user_classbelongs_to :queryvalidates :query_id, presence: truediff --git a/app/models/blazer/dashboard.rb b/app/models/blazer/dashboard.rbindex 57b4cac8..941d95ab 100644--- a/app/models/blazer/dashboard.rb+++ b/app/models/blazer/dashboard.rb@@ -1,6 +1,6 @@module Blazerclass Dashboard < Record- belongs_to :creator, Blazer::BELONGS_TO_OPTIONAL.merge(class_name: Blazer.user_class.to_s) if Blazer.user_class+ belongs_to :creator, optional: true, class_name: Blazer.user_class.to_s if Blazer.user_classhas_many :dashboard_queries, dependent: :destroyhas_many :queries, through: :dashboard_queriesdiff --git a/app/models/blazer/query.rb b/app/models/blazer/query.rbindex 2e1cc168..1a100612 100644--- a/app/models/blazer/query.rb+++ b/app/models/blazer/query.rb@@ -1,6 +1,6 @@module Blazerclass Query < Record- belongs_to :creator, Blazer::BELONGS_TO_OPTIONAL.merge(class_name: Blazer.user_class.to_s) if Blazer.user_class+ belongs_to :creator, optional: true, class_name: Blazer.user_class.to_s if Blazer.user_classhas_many :checks, dependent: :destroyhas_many :dashboard_queries, dependent: :destroyhas_many :dashboards, through: :dashboard_queriesdiff --git a/blazer.gemspec b/blazer.gemspecindex 9303c763..46eb64be 100644--- a/blazer.gemspec+++ b/blazer.gemspec@@ -1,7 +1,4 @@--lib = File.expand_path("../lib", __FILE__)-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)-require "blazer/version"+require_relative "lib/blazer/version"Gem::Specification.new do |spec|spec.name = "blazer"@@ -16,10 +13,10 @@ Gem::Specification.new do |spec|spec.files = Dir["*.{md,txt}", "{app,config,lib}/**/*"]spec.require_path = "lib"- spec.required_ruby_version = ">= 2.3"+ spec.required_ruby_version = ">= 2.4"- spec.add_dependency "railties", ">= 4.2"- spec.add_dependency "activerecord", ">= 4.2"+ spec.add_dependency "railties", ">= 5"+ spec.add_dependency "activerecord", ">= 5"spec.add_dependency "chartkick", ">= 3.2"spec.add_dependency "safely_block", ">= 0.1.1"diff --git a/lib/blazer.rb b/lib/blazer.rbindex 56fc2aa2..8d6eb001 100644--- a/lib/blazer.rb+++ b/lib/blazer.rb@@ -72,8 +72,6 @@ module Blazer"system requested abort", # redshift"maximum statement execution time exceeded" # mysql]- BELONGS_TO_OPTIONAL = {}- BELONGS_TO_OPTIONAL[:optional] = true if Rails::VERSION::MAJOR >= 5def self.time_zone=(time_zone)@time_zone = time_zone.is_a?(ActiveSupport::TimeZone) ? time_zone : ActiveSupport::TimeZone[time_zone.to_s]diff --git a/lib/blazer/adapters/sql_adapter.rb b/lib/blazer/adapters/sql_adapter.rbindex 94c828c7..563a35b3 100644--- a/lib/blazer/adapters/sql_adapter.rb+++ b/lib/blazer/adapters/sql_adapter.rb@@ -26,9 +26,8 @@ module Blazerresult = select_all("#{statement} /*#{comment}*/")columns = result.columns- cast_method = Rails::VERSION::MAJOR < 5 ? :type_cast : :cast_valueresult.rows.each do |untyped_row|- rows << (result.column_types.empty? ? untyped_row : columns.each_with_index.map { |c, i| untyped_row[i] ? result.column_types[c].send(cast_method, untyped_row[i]) : untyped_row[i] })+ rows << (result.column_types.empty? ? untyped_row : columns.each_with_index.map { |c, i| untyped_row[i] ? result.column_types[c].send(:cast_value, untyped_row[i]) : untyped_row[i] })endendrescue => ediff --git a/lib/generators/blazer/install_generator.rb b/lib/generators/blazer/install_generator.rbindex f6b53b74..fa7435f2 100644--- a/lib/generators/blazer/install_generator.rb+++ b/lib/generators/blazer/install_generator.rb@@ -15,9 +15,7 @@ module Blazerenddef migration_version- if ActiveRecord::VERSION::MAJOR >= 5- "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"- end+ "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"endendend