Skip to content

Commit

Permalink
[WIP] Add method to match pc version against its po current version
Browse files Browse the repository at this point in the history
  • Loading branch information
tallenaz committed Jan 23, 2018
1 parent febbe9d commit 7cbc84d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/preserved_copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ def update_status(new_status)
yield
self.status = new_status
end

def version_matches_po_current_version?
version == preserved_object.current_version
end
end
4 changes: 4 additions & 0 deletions lib/audit/catalog_to_moab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def self.check_version_all_dirs_profiled(last_checked_b4_date)

# TODO: anything special if preserved_copy.status is not OK_STATUS? - see #480

unless preserved_copy.version_matches_po_current_version?
results.add_result(PreservedObjectHandlerResults::PC_PO_VERSION_MISMATCH, { pc_version: preserved_copy.version, po_version: preserved_copy.preserved_object.current_version })
end

if catalog_version == moab_version
p "hooray - #{id} versions match: #{catalog_version}"
results.add_result(PreservedObjectHandlerResults::VERSION_MATCHES, preserved_copy.class.name)
Expand Down
11 changes: 11 additions & 0 deletions spec/models/preserved_copy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,15 @@
expect(pc.changed?).to eq true
end
end

context '#current_version_matches_po_version?' do
it 'returns true when its version matches its preserved objects current version' do
preserved_copy.version = 1
expect(preserved_copy.version_matches_po_current_version?).to be true
end

it 'returns false when its version does not match its preserved objects current version' do
expect(preserved_copy.version_matches_po_current_version?).to be false
end
end
end

0 comments on commit 7cbc84d

Please sign in to comment.