Skip to content

Commit

Permalink
Rails 6 (#1403)
Browse files Browse the repository at this point in the history
* Avoid private `ActiveModel::Dirty#attributes_changed_by_setter`

This method is removed in ActiveModel 6.0, and is private anyway. Avoid calling
it for upgradability.

* Drop support for Rails 5.1

Rails 5.1 support is ended. ActiveFedora 14 will drop support.

* Rely on `ActiveModel::Dirty` to track previous changes

We used to manually set `ActiveModel::Dirty` internals to track "previous
changes". In Rails 6, these internals are completely rewritten and much more
efficient. We can rely on the provided implementation instead of rolling our
own.

* Add support for Rails 6

Rails 6 is here. 🎉

* Drop support for Ruby 2.4
  • Loading branch information
Tom Johnson authored Sep 13, 2019
1 parent 2b75d5e commit 16e1f5e
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 33 deletions.
16 changes: 4 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,10 @@ workflows:
ruby_version: 2.5.5
rails_version: 5.2.3
- bundle_lint_test:
name: ruby2-4_rails5-2
ruby_version: 2.4.6
rails_version: 5.2.3
- bundle_lint_test:
name: ruby2-6_rails5-1
name: ruby2-6_rails6-0
ruby_version: 2.6.3
rails_version: 5.1.7
rails_version: 6.0.0
- bundle_lint_test:
name: ruby2-5_rails5.1
name: ruby2-5_rails6.0
ruby_version: 2.5.5
rails_version: 5.1.7
- bundle_lint_test:
name: ruby2-4_rails5-1
ruby_version: 2.4.6
rails_version: 5.1.7
rails_version: 6.0.0
6 changes: 3 additions & 3 deletions active-fedora.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Gem::Specification.new do |s|
s.summary = %q{A convenience libary for manipulating documents in the Fedora Repository.}
s.description = %q{ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.}
s.license = "Apache-2.0"
s.required_ruby_version = '~> 2.0'
s.required_ruby_version = '~> 2.5'

s.add_dependency 'rsolr', '>= 1.1.2', '< 3'
s.add_dependency "activesupport", '>= 4.2.4', '< 5.3'
s.add_dependency "activemodel", '>= 4.2.10', '< 5.3'
s.add_dependency "activesupport", '>= 5.2'
s.add_dependency "activemodel", '>= 5.2'
s.add_dependency "active-triples", '>= 0.11.0', '< 2.0.0'
s.add_dependency "deprecation"
s.add_dependency "ldp", '>= 0.7.0', '< 2'
Expand Down
6 changes: 0 additions & 6 deletions lib/active_fedora/aggregation/list_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ def save(*args)
super
end

# Overriding so that we don't track previously_changed, which was
# rather expensive.
def clear_changed_attributes
clear_changes_information
end

def changed?
super || ordered_self.changed?
end
Expand Down
6 changes: 1 addition & 5 deletions lib/active_fedora/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ module Attributes
include Serializers
include PrimaryKey

after_save :clear_changed_attributes
def clear_changed_attributes
@previously_changed = changes
clear_attribute_changes(changes.keys)
end
after_save :changes_applied
end

def attribute_names
Expand Down
5 changes: 0 additions & 5 deletions lib/active_fedora/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ def datastream_will_change!
attribute_will_change! :ldp_source
end

def attribute_will_change!(attr)
return super unless attr == 'content'
attributes_changed_by_setter[:content] = true
end

def remote_content
return if new_record?
@ds_content ||= retrieve_content
Expand Down
2 changes: 1 addition & 1 deletion lib/active_fedora/with_metadata/metadata_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(file)
@file = file
super(file.uri, ldp_source.graph)
return unless self.class.type && !type.include?(self.class.type)
attributes_changed_by_setter[:type] = true if type.present?
attribute_will_change!(:type) if type.present?
# Workaround for https://github.com/ActiveTriples/ActiveTriples/issues/123
get_values(:type) << self.class.type
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/with_metadata/metadata_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
generated_schema.configure type: book
end

it { is_expected.to eq('type' => true) }
it { is_expected.to match('type' => be_truthy) }
end
end

Expand Down

0 comments on commit 16e1f5e

Please sign in to comment.