File tree 3 files changed +16
-12
lines changed
3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -101,14 +101,7 @@ def initialize
101
101
102
102
# Active Admin makes educated guesses when displaying objects, this is
103
103
# the list of methods it tries calling in order
104
- setting :display_name_methods , [ :display_name ,
105
- :full_name ,
106
- :name ,
107
- :username ,
108
- :login ,
109
- :title ,
110
- :email ,
111
- :to_s ]
104
+ setting :display_name_methods , [ :display_name , :to_s ]
112
105
113
106
# == Deprecated Settings
114
107
Original file line number Diff line number Diff line change 24
24
accepts_nested_attributes_for :author
25
25
accepts_nested_attributes_for :taggings
26
26
attr_accessible :author, :position unless Rails::VERSION::MAJOR > 3 && !defined? ProtectedAttributes
27
+
28
+ def display_name
29
+ title
30
+ end
27
31
} , after : 'class Post < ActiveRecord::Base'
28
32
copy_file File . expand_path ( '../templates/post_decorator.rb' , __FILE__ ) , "app/models/post_decorator.rb"
29
33
@@ -97,6 +101,12 @@ def set_id
97
101
98
102
generate 'active_admin:install'
99
103
104
+ inject_into_file 'app/models/admin_user.rb' , %q{
105
+ def display_name
106
+ email
107
+ end
108
+ } , after : 'class AdminUser < ActiveRecord::Base'
109
+
100
110
inject_into_file "config/routes.rb" , "\n root to: redirect('/admin')" , after : /.*::Application.routes.draw do/
101
111
remove_file "public/index.html" if File . exists? "public/index.html"
102
112
Original file line number Diff line number Diff line change 14
14
end
15
15
16
16
it "should memoize the result for the class" do
17
- subject = Class . new . new
18
- expect ( subject ) . to receive ( :name ) . twice . and_return "My Name"
17
+ subject = double ( title : "My Name" )
18
+ expect ( subject ) . to receive ( :display_name ) . twice . and_return "My Name"
19
19
expect ( display_name subject ) . to eq "My Name"
20
20
expect ( ActiveAdmin . application ) . to_not receive ( :display_name_methods )
21
21
expect ( display_name subject ) . to eq "My Name"
27
27
allow ( klass ) . to receive ( :reflect_on_all_associations ) . and_return [ double ( name : :login ) ]
28
28
allow ( subject ) . to receive :login
29
29
expect ( subject ) . to_not receive :login
30
- allow ( subject ) . to receive ( :email ) . and_return 'foo@bar.baz'
31
- expect ( display_name subject ) . to eq 'foo@bar.baz'
30
+ allow ( ActiveAdmin . application ) . to receive ( :display_name_methods ) . and_return [ :login , :display_name ]
31
+ allow ( subject ) . to receive ( :display_name ) . and_return "foo@bar.baz"
32
+ expect ( display_name subject ) . to eq "foo@bar.baz"
32
33
end
33
34
34
35
it "should return `nil` when the passed object is `nil`" do
You can’t perform that action at this time.
0 commit comments