Model display name fixes #319

Closed
wants to merge 6 commits into
from
@@ -24,7 +24,7 @@ def slider
def for_model
@page_type = @abstract_model.pretty_name.downcase
- @page_name = t("admin.history.page_name", :name => @model_config.list.label)
+ @page_name = t("admin.history.page_name", :name => @model_config.navigation.label)
@general = true
@page_count, @history = AbstractHistory.history_for_model @abstract_model, params[:query], params[:sort], params[:sort_reverse], params[:all], params[:page]
@@ -111,7 +111,7 @@ def update
def delete
@authorization_adapter.authorize(:delete, @abstract_model, @object) if @authorization_adapter
- @page_name = t("admin.actions.delete").capitalize + " " + @model_config.list.label.downcase
+ @page_name = t("admin.actions.delete").capitalize + " " + @model_config.navigation.label.downcase
@page_type = @abstract_model.pretty_name.downcase
render :layout => 'rails_admin/delete'
@@ -131,7 +131,7 @@ def destroy
def bulk_delete
@authorization_adapter.authorize(:bulk_delete, @abstract_model) if @authorization_adapter
- @page_name = t("admin.actions.delete").capitalize + " " + @model_config.list.label.downcase
+ @page_name = t("admin.actions.delete").capitalize + " " + @model_config.navigation.label.downcase
@page_type = @abstract_model.pretty_name.downcase
render :layout => 'rails_admin/delete'
@@ -301,7 +301,7 @@ def list_entries(other = {})
@record_count = @abstract_model.count(options, scope)
@page_type = @abstract_model.pretty_name.downcase
- @page_name = t("admin.list.select", :name => @model_config.list.label.downcase)
+ @page_name = t("admin.list.select", :name => @model_config.navigation.label.downcase)
end
def associations_hash
@@ -43,7 +43,7 @@
<% if @history %>
<li>
&rsaquo;
- <%= link_to(@model_config.list.label, rails_admin_list_path(:model_name => @abstract_model.to_param)) %>
+ <%= link_to(@model_config.navigation.label, rails_admin_list_path(:model_name => @abstract_model.to_param)) %>
</li>
<li>
&rsaquo;
@@ -52,7 +52,7 @@
<% else %>
<li>
&rsaquo;
- <span><%= @model_config.list.label %></span>
+ <span><%= @model_config.navigation.label %></span>
</li>
<% end%>
</ul>
@@ -17,7 +17,7 @@
<% if authorized? :list, abstract_model %>
<tr class="<%= cycle 'odd', 'even' %>">
<td class="modelNameRow">
- <%= link_to(RailsAdmin.config(abstract_model).list.label, rails_admin_list_path(:model_name => abstract_model.to_param), :class => "show") %>
+ <%= link_to(RailsAdmin.config(abstract_model).navigation.label, rails_admin_list_path(:model_name => abstract_model.to_param), :class => "show") %>
</td>
<td>
<% if (last_used = @most_recent_changes[abstract_model.pretty_name]) %>
@@ -46,6 +46,34 @@
end
end
+ it 'should display edited model name in model name column' do
+ RailsAdmin.config Fan do
+ label_for_navigation "NewFan"
+ end
+ get rails_admin_dashboard_path
+ response.should have_tag("td.modelNameRow") do |model_name_cells|
+ model_name_cells.should have_tag("a[href='/admin/fans']", :content => "NewFan")
+ end
+ end
+
+ it 'should use edited model name in breadcrumbs' do
+ RailsAdmin.config Fan do
+ label_for_navigation "NewFan"
+ end
+ get rails_admin_list_path(:model_name => 'fans')
+ response.should have_tag(".breadcrumb li") do |model_name_cells|
+ model_name_cells.should have_tag("span", :content => "NewFan")
+ end
+ end
+
+ it 'should use edited model name in @page_name' do
+ RailsAdmin.config Fan do
+ label_for_navigation "NewFan"
+ end
+ get rails_admin_list_path(:model_name => 'fans')
+ assigns[:page_name].should =~ /NewFan/i
+ end
+
it "should be editable via shortcut" do
RailsAdmin.config Fan do
label_for_navigation "Fan test 2"