Skip to content
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
6 changes: 3 additions & 3 deletions lib/oai/provider/model/activerecord_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def latest
# returns all the sets the model supports. See the
# activerecord_provider tests for an example.
def sets
model.sets if model.respond_to?(:sets)
model.respond_to?(:sets) ? model.sets : []
end

def find(selector, options={})
Expand Down Expand Up @@ -177,7 +177,7 @@ def sql_conditions(opts)
sql << "#{model.base_class.table_name}.#{timestamp_field} < :until"
esc_values[:until] = parse_to_local(opts[:until]) { |t| t + 1 }
end

return [sql.join(" AND "), esc_values]
end

Expand All @@ -197,7 +197,7 @@ def parse_to_local(time)
raise OAI::ArgumentException.new, "unparsable date: '#{time}'"
end
end

time_obj = yield(time_obj) if block_given?

if time_obj.kind_of?(Date)
Expand Down
15 changes: 10 additions & 5 deletions test/activerecord_provider/tc_ar_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def test_list_records_scope
assert_equal expected_count, doc.elements['OAI-PMH/ListRecords'].to_a.size
end

def test_invalid_set_raises_no_match
assert_raises(OAI::NoMatchException) do
@provider.list_records(:metadata_prefix => 'oai_dc', :set => "invalid_does_not_exist")
end
end

def test_get_record_alternate_identifier_column
@provider = ARProviderCustomIdentifierField.new
Expand Down Expand Up @@ -127,7 +132,7 @@ def test_from_and_until
)
assert_equal 40, doc.elements['OAI-PMH/ListRecords'].to_a.size
end

def test_bad_until_raises_exception
DCField.order(id: :asc).limit(10).update_all(updated_at: 1.year.ago)
DCField.order(id: :desc).limit(10).update_all(updated_at: 1.year.from_now)
Expand All @@ -140,11 +145,11 @@ def test_bad_until_raises_exception
end
end
end

def test_bad_from_raises_exception
DCField.order(id: :asc).limit(10).update_all(updated_at: 1.year.ago)
DCField.order(id: :desc).limit(10).update_all(updated_at: 1.year.from_now)

badTimes = [
'junk',
'February 92nd, 2015']
Expand All @@ -169,7 +174,7 @@ def test_handles_empty_collections
REXML::Document.new(@provider.list_records(:metadata_prefix => 'oai_dc'))
end
end

def test_bad_id_raises_exception
badIdentifiers = [
'invalid"id',
Expand All @@ -183,7 +188,7 @@ def test_bad_id_raises_exception
end
end
end


def setup
@provider = ARProvider.new
Expand Down