diff --git a/app/controllers/avo/associations_controller.rb b/app/controllers/avo/associations_controller.rb index d16c9d0cb..5b1800781 100644 --- a/app/controllers/avo/associations_controller.rb +++ b/app/controllers/avo/associations_controller.rb @@ -29,7 +29,13 @@ def index @association_field = find_association_field(resource: @parent_resource, association: params[:related_name]) if @association_field.present? && @association_field.scope.present? - @query = Avo::ExecutionContext.new(target: @association_field.scope, query: @query, parent: @parent_record).handle + @query = Avo::ExecutionContext.new( + target: @association_field.scope, + query: @query, + parent: @parent_record, + resource: @resource, + parent_resource: @parent_resource + ).handle end super diff --git a/spec/dummy/app/avo/resources/user.rb b/spec/dummy/app/avo/resources/user.rb index a72b6b06a..d2528f514 100644 --- a/spec/dummy/app/avo/resources/user.rb +++ b/spec/dummy/app/avo/resources/user.rb @@ -253,7 +253,11 @@ def second_tabs_group field :comments, as: :has_many, # show_on: :edit, - scope: -> { query.starts_with parent.first_name[0].downcase }, + scope: -> { + TestBuddy.hi("parent_resource:#{parent_resource.present?},resource:#{resource.present?}") + + query.starts_with parent.first_name[0].downcase + }, description: "The comments listed in the attach modal all start with the name of the parent user." field :comment, as: :has_one, name: "Main comment" end diff --git a/spec/features/avo/has_many_field_spec.rb b/spec/features/avo/has_many_field_spec.rb index 26bb57df2..5677a5fd5 100644 --- a/spec/features/avo/has_many_field_spec.rb +++ b/spec/features/avo/has_many_field_spec.rb @@ -112,6 +112,7 @@ let!(:a_comment) { create :comment, user: user, body: "A comment that starts with the letter A" } subject do + expect(TestBuddy).to receive(:hi).with("parent_resource:true,resource:true").at_least :once visit "/admin/resources/users/#{user.id}/comments?turbo_frame=has_many_field_show_comments" page end