Skip to content

Commit

Permalink
File metadata has a modified_date
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcolvar authored and jcoyne committed Jun 12, 2017
1 parent 9c72971 commit 95cf7d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/active_fedora/file/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def create_date
created && created.first
end

def modified_date
modified = metadata.attributes["http://fedora.info/definitions/v4/repository#lastModified"]
modified && modified.first
end

private

# Fcrepo4.digest was used by Fedora < 4.3, but it was removed
Expand Down
14 changes: 14 additions & 0 deletions spec/unit/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,20 @@
end
end

describe "#modified_date" do
subject { af_file.modified_date }
describe "when new record" do
it { is_expected.to be_nil }
end
describe "when persisted" do
before do
af_file.content = "foo"
af_file.save!
end
it { is_expected.to be_a(DateTime) }
end
end

describe "callbacks" do
before do
class MyFile < ActiveFedora::File
Expand Down

0 comments on commit 95cf7d7

Please sign in to comment.