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
23
23
end
24
24
25
25
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 ) ||
27
28
association_name . classify . constantize
28
29
end
29
30
Original file line number Diff line number Diff line change 5
5
Class . new do
6
6
include ActiveAdminAddons ::InputMethods
7
7
8
- attr_reader :method
8
+ attr_reader :method , :options
9
9
10
- def initialize ( object , method )
10
+ def initialize ( object , method , options = { } )
11
11
@object = object
12
12
@method = method
13
+ @options = options
13
14
end
14
15
end
15
16
end
@@ -21,7 +22,8 @@ def initialize(object, method)
21
22
end
22
23
23
24
let ( :method ) { :category_id }
24
- let ( :instance ) { dummy_class . new ( object , method ) }
25
+ let ( :options ) { { } }
26
+ let ( :instance ) { dummy_class . new ( object , method , options ) }
25
27
26
28
def self . check_invalid_method ( method_name )
27
29
context "with nil method" do
@@ -68,6 +70,14 @@ def self.check_invalid_object(method_name)
68
70
expect ( instance . method_model ) . to be ( Store ::Manufacturer )
69
71
end
70
72
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
71
81
end
72
82
73
83
describe "#tableize_method" do
You can’t perform that action at this time.
0 commit comments