File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
lib/activeadmin_addons/support/input_helpers Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ def association_name
2323 end
2424
2525 def method_model
26- object_class . reflect_on_association ( association_name ) . try ( :klass ) ||
26+ @options [ :method_model ] ||
27+ object_class . reflect_on_association ( association_name ) . try ( :klass ) ||
2728 association_name . classify . constantize
2829 end
2930
Original file line number Diff line number Diff line change 55 Class . new do
66 include ActiveAdminAddons ::InputMethods
77
8- attr_reader :method
8+ attr_reader :method , :options
99
10- def initialize ( object , method )
10+ def initialize ( object , method , options = { } )
1111 @object = object
1212 @method = method
13+ @options = options
1314 end
1415 end
1516 end
@@ -21,7 +22,8 @@ def initialize(object, method)
2122 end
2223
2324 let ( :method ) { :category_id }
24- let ( :instance ) { dummy_class . new ( object , method ) }
25+ let ( :options ) { { } }
26+ let ( :instance ) { dummy_class . new ( object , method , options ) }
2527
2628 def self . check_invalid_method ( method_name )
2729 context "with nil method" do
@@ -68,6 +70,14 @@ def self.check_invalid_object(method_name)
6870 expect ( instance . method_model ) . to be ( Store ::Manufacturer )
6971 end
7072 end
73+
74+ context "when a :method_model option is provided" do
75+ let ( :options ) { { method_model : Store ::Car } }
76+
77+ it "returns provided class" do
78+ expect ( instance . method_model ) . to be ( Store ::Car )
79+ end
80+ end
7181 end
7282
7383 describe "#tableize_method" do
You can’t perform that action at this time.
0 commit comments