Skip to content

Commit

Permalink
Add compatibility with Rubydora 2.1; drop support for Rails <= 4.2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Apr 26, 2018
1 parent ff50c15 commit bca15f7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ rvm:
matrix:
include:
- rvm: 2.5.1
env: ACTIVEMODEL_VERSION=5.1.6
env: RAILS_VERSION=5.2.0
- rvm: 2.4.4
env: RAILS_VERSION=5.1.6
- rvm: 2.3.7
env: RAILS_VERSION=5.0.7
- rvm: 2.2.10
Expand Down
2 changes: 1 addition & 1 deletion active-fedora.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.add_dependency 'rsolr', ">= 1.0.11", '< 3'
s.add_dependency 'om', '~> 3.1'
s.add_dependency 'nom-xml', '>= 0.5.1'
s.add_dependency "activesupport", '>= 3.0.0'
s.add_dependency "activesupport", '>= 4.2.10'
s.add_dependency "rubydora", '>= 1.8.0', '< 3'
s.add_dependency "active-triples", '~> 0.4.0'
s.add_dependency "rdf-rdfxml", '~> 1.1'
Expand Down
2 changes: 1 addition & 1 deletion lib/active_fedora/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Attributes
after_save :clear_changed_attributes
def clear_changed_attributes
@previously_changed = changes
@changed_attributes.clear
clear_attribute_changes(changes.keys)
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/active_fedora/datastreams/nokogiri_datastreams.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ def ng_xml=(new_xml)

# don't want content eagerly loaded by proxy, so implementing methods that would be implemented by define_attribute_methods
def ng_xml_will_change!
changed_attributes['ng_xml'] = nil
attributes_changed_by_setter[:ng_xml] = nil
end

def ng_xml_doesnt_change!
changed_attributes.delete('ng_xml')
clear_attribute_changes([:ng_xml])
end

# don't want content eagerly loaded by proxy, so implementing methods that would be implemented by define_attribute_methods
def ng_xml_changed?
changed_attributes.has_key? 'ng_xml'
changed_attributes.has_key? :ng_xml
end

def datastream_content
Expand Down
11 changes: 10 additions & 1 deletion lib/active_fedora/om_datastream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ class OmDatastream < Datastream
before_save do
if content.blank?
ActiveFedora::Base.logger.warn "Cowardly refusing to save a datastream with empty content: #{self.inspect}" if ActiveFedora::Base.logger
false
if ActiveSupport.version >= Gem::Version.new('5.0')
throw(:abort)
else
false
end
end
end

Expand Down Expand Up @@ -295,5 +299,10 @@ def term_values(*term_pointer)
end
end

def reset_profile_attributes
super
clear_attribute_changes([:ng_xml])
end

end
end
6 changes: 5 additions & 1 deletion lib/active_fedora/rdf/rdf_datastream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ def resource_class(klass=nil)
before_save do
if content.blank?
ActiveFedora::Base.logger.warn "Cowardly refusing to save a datastream with empty content: #{self.inspect}" if ActiveFedora::Base.logger
false
if ActiveSupport.version >= Gem::Version.new('5.0')
throw(:abort)
else
false
end
end
end

Expand Down
5 changes: 5 additions & 0 deletions spec/support/an_active_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def assert_equal(test, obj)
def assert_kind_of(klass, inspected_object)
expect(inspected_object).to be_kind_of(klass)
end

def assert_respond_to(obj, meth, msg = nil)
expect(obj).to respond_to meth
end

include ActiveModel::Lint::Tests

ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m|
Expand Down

0 comments on commit bca15f7

Please sign in to comment.