Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

failing spec for pluralizing model collection with 1 item #1359

Merged
merged 2 commits into from

3 participants

@bostonaholic

This is the failing spec for Issue #1358

@bbenezech
Collaborator

Thanks for the spec. Can you provide the fix? We are short on maintainers ;-)

@bostonaholic

Everything looks good to go. Ready for merge.

@mshibuya mshibuya merged commit fe4a4da into from
@mshibuya
Collaborator

Thanks for your work!

@bostonaholic bostonaholic deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
4 app/views/rails_admin/main/index.html.haml
@@ -135,6 +135,6 @@
- total_count = @objects.total_count.to_i
= paginate(@objects, :theme => 'twitter-bootstrap', :remote => true)
= link_to(t("admin.misc.show_all"), index_path(params.merge(:all => true)), :class => "show-all btn clearfix pjax") unless total_count > 100 || total_count <= @objects.to_a.size
- .clearfix.total-count= "#{total_count} #{@model_config.label_plural.downcase}"
+ .clearfix.total-count= "#{total_count} #{@model_config.pluralize(total_count).downcase}"
- else
- .clearfix.total-count= "#{@objects.size} #{@model_config.label_plural.downcase}"
+ .clearfix.total-count= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}"
View
4 lib/rails_admin/config/model.rb
@@ -63,6 +63,10 @@ def object_label
(@label_plural ||= {})[::I18n.locale] ||= abstract_model.model.model_name.human(:count => 2, :default => label.pluralize)
end
+ def pluralize(count)
+ count == 1 ? label : label_plural
+ end
+
register_instance_option :weight do
0
end
View
9 spec/integration/basic/list/rails_admin_basic_list_spec.rb
@@ -307,7 +307,14 @@
end
describe "GET /admin/player show all" do
- it "responds successfully" do
+ it "responds successfully with a single model" do
+ FactoryGirl.create :player
+ visit index_path(:model_name => "player", :all => true)
+ expect(find('div.total-count')).to have_content("1 player")
+ expect(find('div.total-count')).not_to have_content("1 players")
+ end
+
+ it "responds successfully with multiple models" do
2.times.map { FactoryGirl.create :player }
visit index_path(:model_name => "player", :all => true)
expect(find('div.total-count')).to have_content("2 players")
Something went wrong with that request. Please try again.