Skip to content

Commit

Permalink
Sort dashboard attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
nhippenmeyer committed Jan 26, 2022
1 parent 1a6e0fc commit b2ec977
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class <%= class_name %>Dashboard < Administrate::BaseDashboard
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
<% attributes.each do |attr| -%>
<% attributes.sort.each do |attr| -%>
<%= attr %>: <%= field_type(attr) %>,
<% end -%>
}.freeze
Expand Down
6 changes: 3 additions & 3 deletions spec/generators/dashboard_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Foo < ApplicationRecord
load file("app/dashboards/foo_dashboard.rb")
attrs = FooDashboard::ATTRIBUTE_TYPES

expect(attrs[:id]).to eq(Administrate::Field::Number)
expect(attrs[:created_at]).to eq(Administrate::Field::DateTime)
expect(attrs[:id]).to eq(Administrate::Field::Number)
expect(attrs[:updated_at]).to eq(Administrate::Field::DateTime)
ensure
remove_constants :Foo, :FooDashboard
Expand Down Expand Up @@ -323,10 +323,10 @@ class Foo < ApplicationRecord

run_generator ["foo"]
load file("app/dashboards/foo_dashboard.rb")
all_attrs = FooDashboard::ATTRIBUTE_TYPES.keys
all_attrs = FooDashboard::ATTRIBUTE_TYPES.keys.sort
table_attrs = FooDashboard::COLLECTION_ATTRIBUTES

expect(table_attrs).to eq(all_attrs.first(table_attribute_limit))
expect(table_attrs).to contain_exactly(:id, *all_attrs.first(table_attribute_limit-1))
expect(table_attrs).not_to eq(all_attrs)
ensure
remove_constants :Foo, :FooDashboard
Expand Down

0 comments on commit b2ec977

Please sign in to comment.