Replace remaining calls to count() with size()

The couple that aren't removed are required: for instance, there's a
Crop.count method, but no Crop.size method.
This commit is contained in:
Miles Gould
2015-07-23 23:05:39 +01:00
parent 48649d1986
commit 96b0198d41
6 changed files with 16 additions and 16 deletions

View File

@@ -25,9 +25,9 @@
%dd= garden.active ? "Yes" : "No"
.col-md-12
%b
= "#{pluralize(garden.plantings.count, "Planting")} : "
= "#{pluralize(garden.plantings.size, "Planting")} : "
= display_garden_plantings(garden.plantings.current)
- if garden.plantings.count > 2
- if garden.plantings.size > 2
%br
= link_to "See more plantings >>", garden_path(garden)
.panel-footer

View File

@@ -1,7 +1,7 @@
- cache("homepage_stats") do
%p.stats
= t('.message_html', { member: link_to(t('.member_linktext', count: Member.confirmed.count.to_i), members_path),
number_crops: link_to(t('.number_crops_linktext', count: Crop.count.to_i), crops_path),
= t('.message_html', { member: link_to(t('.member_linktext', count: Member.confirmed.size.to_i), members_path),
number_crops: link_to(t('.number_crops_linktext', count: Crop.count.to_i), crops_path),
number_plantings: link_to(t('.number_plantings_linktext', count: Planting.count.to_i), plantings_path),
number_gardens: link_to(t('.number_gardens_linktext', count: Garden.count.to_i), gardens_path) })

View File

@@ -115,7 +115,7 @@ describe PhotosController do
post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
:type => "planting",
:id => planting.id }
Photo.last.plantings.count.should eq 1
Photo.last.plantings.size.should eq 1
end
it "attaches the photo to a harvest" do
@@ -140,7 +140,7 @@ describe PhotosController do
post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
:type => "harvest",
:id => harvest.id }
Photo.last.harvests.count.should eq 1
Photo.last.harvests.size.should eq 1
end
end

View File

@@ -23,7 +23,7 @@ describe 'member' do
end
it 'should have a default garden' do
member.gardens.count.should == 1
member.gardens.size.should == 1
end
it 'should have a accounts entry' do
@@ -221,12 +221,12 @@ describe 'member' do
end
it 'sees confirmed members' do
Member.confirmed.count.should == 2
Member.confirmed.size.should == 2
end
it 'ignores unconfirmed members' do
@member3 = FactoryGirl.create(:unconfirmed_member)
Member.confirmed.count.should == 2
Member.confirmed.size.should == 2
end
end

View File

@@ -11,19 +11,19 @@ describe Photo do
context "adds photos" do
it 'to a planting' do
planting.photos << photo
expect(planting.photos.count).to eq 1
expect(planting.photos.size).to eq 1
expect(planting.photos.first).to eq photo
end
it 'to a harvest' do
harvest.photos << photo
expect(harvest.photos.count).to eq 1
expect(harvest.photos.size).to eq 1
expect(harvest.photos.first).to eq photo
end
it 'to a garden' do
garden.photos << photo
expect(garden.photos.count).to eq 1
expect(garden.photos.size).to eq 1
expect(garden.photos.first).to eq photo
end
end
@@ -32,19 +32,19 @@ describe Photo do
it 'from a planting' do
planting.photos << photo
photo.destroy
expect(planting.photos.count).to eq 0
expect(planting.photos.size).to eq 0
end
it 'from a harvest' do
harvest.photos << photo
photo.destroy
expect(harvest.photos.count).to eq 0
expect(harvest.photos.size).to eq 0
end
it 'from a garden' do
garden.photos << photo
photo.destroy
expect(garden.photos.count).to eq 0
expect(garden.photos.size).to eq 0
end
it "automatically if unused" do

View File

@@ -10,7 +10,7 @@ class SSLVerify
def test_gateways
success, failed, missing, errored, disabled = [], [], [], [], []
puts "Verifying #{@gateways.count} SSL certificates\n\n"
puts "Verifying #{@gateways.size} SSL certificates\n\n"
@gateways.each do |g|
if !g.live_url