Skip to content

Commit 1b72a97

Browse files
committed
Fix failing specs
1 parent 2d42ecd commit 1b72a97

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/audited/auditor.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def with_auditing(&block)
145145
def revisions(from_version = 1)
146146
return [] unless has_version?(from_version)
147147

148-
all_audits = audits.pluck(:audited_changes, :version, :action).to_a
148+
all_audits = audits.loaded? ? audits.to_a : audits.select([:audited_changes, :version, :action]).to_a
149149
targeted_audits = all_audits.select { |audit| audit.version >= from_version }
150150

151151
previous_attributes = reconstruct_attributes(all_audits - targeted_audits)
@@ -157,7 +157,7 @@ def revisions(from_version = 1)
157157
end
158158

159159
def has_version?(version)
160-
audits.loaded? ? audits.any? { |audit| audit.version >= from_version } : audits.from_version(from_version).exists?
160+
audits.loaded? ? audits.any? { |audit| audit.version >= version } : audits.from_version(version).exists?
161161
end
162162

163163
# Get a specific revision specified by the version number, or +:previous+
@@ -170,7 +170,7 @@ def revision(version)
170170

171171
# Find the oldest revision recorded prior to the date/time provided.
172172
def revision_at(date_or_time)
173-
targeted_audits = audits.loaded? ? audits.filter { |audit| audit.created_at <= date_or_time }.sort_by(&:version) : audits.up_until(date_or_time)
173+
targeted_audits = audits.loaded? ? audits.select { |audit| audit.created_at <= date_or_time }.sort_by(&:version) : audits.up_until(date_or_time)
174174
revision_with Audited.audit_class.reconstruct_attributes(targeted_audits) unless targeted_audits.empty?
175175
end
176176

@@ -332,7 +332,7 @@ def audits_to(version = nil)
332332
end
333333
end
334334

335-
audits.loaded? ? audits.filter { |audit| audit.version <= version }.sort_by(&:version) : audits.to_version(version)
335+
audits.loaded? ? audits.select { |audit| audit.version <= version }.sort_by(&:version) : audits.to_version(version)
336336
end
337337

338338
def audit_create

0 commit comments

Comments
 (0)