Skip to content

Commit

Permalink
reconcile differences for counting volumes in cost report
Browse files Browse the repository at this point in the history
  • Loading branch information
aelkiss committed Feb 10, 2025
1 parent 4bbdf6b commit 974e491
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
16 changes: 0 additions & 16 deletions lib/clusterable/ht_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,10 @@ def ic_volumes
end
end

def pd_volumes
return to_enum(__method__) unless block_given?

table.exclude(rights_code: IC_RIGHTS_CODES).each do |row|
yield from_row(row)
end
end

def pd_count
table.exclude(rights_code: IC_RIGHTS_CODES).count
end

def all
return to_enum(__method__) unless block_given?

table.each do |row|
yield from_row(row)
end
end

def count
table.count
end
Expand Down
10 changes: 5 additions & 5 deletions spec/clusterable/ht_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,31 @@
end
end

describe ".pd_volumes" do
describe ".pd_count" do
it "counts pd items" do
%w[pd pdus cc-zero].each do |code|
insert_htitem build(:ht_item, access: "allow", rights: code)
end
expect(described_class.pd_volumes.count).to eq(3)
expect(described_class.pd_count).to eq(3)
end

it "ignores ic items" do
%w[ic op und].each do |code|
insert_htitem build(:ht_item, access: "deny", rights: code)
end
expect(described_class.pd_volumes.count).to eq(0)
expect(described_class.pd_count).to eq(0)
end
end

describe ".all_volumes" do
describe ".count" do
it "counts all volumes" do
%w[pd pdus cc-zero].each do |code|
insert_htitem build(:ht_item, access: "allow", rights: code)
end
%w[ic op und].each do |code|
insert_htitem build(:ht_item, access: "deny", rights: code)
end
expect(described_class.all_volumes.count).to eq(6)
expect(described_class.count).to eq(6)
end
end

Expand Down

0 comments on commit 974e491

Please sign in to comment.