Skip to content

Commit

Permalink
Fix failing specs
Browse files Browse the repository at this point in the history
  • Loading branch information
wkirby committed Aug 24, 2024
1 parent 2d42ecd commit 1b72a97
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/audited/auditor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def with_auditing(&block)
def revisions(from_version = 1)
return [] unless has_version?(from_version)

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

previous_attributes = reconstruct_attributes(all_audits - targeted_audits)
Expand All @@ -157,7 +157,7 @@ def revisions(from_version = 1)
end

def has_version?(version)
audits.loaded? ? audits.any? { |audit| audit.version >= from_version } : audits.from_version(from_version).exists?
audits.loaded? ? audits.any? { |audit| audit.version >= version } : audits.from_version(version).exists?
end

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

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

Expand Down Expand Up @@ -332,7 +332,7 @@ def audits_to(version = nil)
end
end

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

def audit_create
Expand Down

0 comments on commit 1b72a97

Please sign in to comment.