Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop support for Rails < 4 #757

Merged
merged 1 commit into from
Jul 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env:
- DB=postgresql

gemfile:
- gemfiles/activerecord_3.2.gemfile
- gemfiles/activerecord_4.0.gemfile
- gemfiles/activerecord_4.1.gemfile

Expand All @@ -28,9 +27,3 @@ matrix:
allow_failures:
- gemfile: gemfiles/activerecord_edge.gemfile
- rvm: rbx-2
exclude:
- rvm: 2.2
gemfile: gemfiles/activerecord_3.2.gemfile
- rvm: rbx-2
gemfile: gemfiles/activerecord_3.2.gemfile

4 changes: 0 additions & 4 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
appraise "activerecord-3.2" do
gem "activerecord", github: "rails/rails" , branch: '3-2-stable'
end

appraise "activerecord-4.0" do
gem "activerecord", github: "rails/rails" , branch: '4-0-stable'
end
Expand Down
2 changes: 1 addition & 1 deletion acts-as-taggable-on.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
gem.post_install_message = File.read('UPGRADING.md')
end

gem.add_runtime_dependency 'activerecord', ['>= 3.2', '< 5']
gem.add_runtime_dependency 'activerecord', ['>= 4.0', '< 5']

gem.add_development_dependency 'sqlite3'
gem.add_development_dependency 'mysql2', '~> 0.3.7'
Expand Down
15 changes: 0 additions & 15 deletions gemfiles/activerecord_3.2.gemfile

This file was deleted.

1 change: 0 additions & 1 deletion lib/acts-as-taggable-on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def self.apply_binary_collation(bincoll)
end

ActiveSupport.on_load(:active_record) do
extend ActsAsTaggableOn::Compatibility
extend ActsAsTaggableOn::Taggable
include ActsAsTaggableOn::Tagger
end
Expand Down
35 changes: 0 additions & 35 deletions lib/acts_as_taggable_on/compatibility.rb

This file was deleted.

21 changes: 9 additions & 12 deletions lib/acts_as_taggable_on/taggable/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@ def initialize_acts_as_taggable_on_core
class_eval do
# when preserving tag order, include order option so that for a 'tags' context
# the associations tag_taggings & tags are always returned in created order
has_many_with_taggable_compatibility context_taggings, as: :taggable,
dependent: :destroy,
class_name: 'ActsAsTaggableOn::Tagging',
order: taggings_order,
conditions: {context: tags_type},
include: :tag

has_many_with_taggable_compatibility context_tags, through: context_taggings,
source: :tag,
class_name: 'ActsAsTaggableOn::Tag',
order: taggings_order

has_many context_taggings, -> { includes(:tag).order(taggings_order).where(context: tags_type) },
as: :taggable,
class_name: ActsAsTaggableOn::Tagging,
dependent: :destroy

has_many context_tags, -> { order(taggings_order) },
class_name: ActsAsTaggableOn::Tag,
through: context_taggings,
source: :tag
end

taggable_mixin.class_eval <<-RUBY, __FILE__, __LINE__ + 1
Expand Down
23 changes: 12 additions & 11 deletions lib/acts_as_taggable_on/tagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ module ClassMethods
# end
def acts_as_tagger(opts={})
class_eval do
has_many_with_taggable_compatibility :owned_taggings,
opts.merge(
as: :tagger,
dependent: :destroy,
class_name: '::ActsAsTaggableOn::Tagging'
)
owned_taggings_scope = opts.delete(:scope)

has_many_with_taggable_compatibility :owned_tags,
through: :owned_taggings,
source: :tag,
class_name: '::ActsAsTaggableOn::Tag',
uniq: true
has_many :owned_taggings, owned_taggings_scope,
opts.merge(
as: :tagger,
class_name: ::ActsAsTaggableOn::Tagging,
dependent: :destroy
)

has_many :owned_tags, -> { distinct },
class_name: ::ActsAsTaggableOn::Tag,
source: :tag,
through: :owned_taggings
end

include ActsAsTaggableOn::Tagger::InstanceMethods
Expand Down
11 changes: 0 additions & 11 deletions lib/acts_as_taggable_on/tagging.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
module ActsAsTaggableOn
class Tagging < ::ActiveRecord::Base #:nodoc:
#TODO, remove from 4.0.0
attr_accessible :tag,
:tag_id,
:context,
:taggable,
:taggable_type,
:taggable_id,
:tagger,
:tagger_type,
:tagger_id if defined?(ActiveModel::MassAssignmentSecurity)

belongs_to :tag, class_name: '::ActsAsTaggableOn::Tag', counter_cache: ActsAsTaggableOn.tags_counter
belongs_to :taggable, polymorphic: true
belongs_to :tagger, polymorphic: true
Expand Down
1 change: 0 additions & 1 deletion spec/acts_as_taggable_on/taggable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,6 @@

context 'Model.limit(x).tag_counts.sum(:tags_count)' do
it 'should not break on Mysql' do
# Activerecord 3.2 return a string
expect(TaggableModel.limit(2).tag_counts.sum('tags_count').to_i).to eq(5)
end
end
Expand Down
8 changes: 1 addition & 7 deletions spec/support/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
config = ActiveRecord::Base.configurations[db_name]

begin
#activerecord 4 uses symbol
#TODO, remove when activerecord 3 support is dropped
if ActsAsTaggableOn::Utils.active_record4? || ActsAsTaggableOn::Utils.active_record5?
ActiveRecord::Base.establish_connection(db_name.to_sym)
else
ActiveRecord::Base.establish_connection(db_name)
end
ActiveRecord::Base.establish_connection(db_name.to_sym)
ActiveRecord::Base.connection
rescue
case db_name
Expand Down