Skip to content

Commit

Permalink
Hound
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobm committed Oct 15, 2020
1 parent 35a878a commit 9b3bd4b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
5 changes: 4 additions & 1 deletion spec/lib/administrate/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ class Address < MockRecord; end

class Foo < MockRecord
belongs_to :role
belongs_to :author, class_name: "Administrate::SearchSpecMocks::Person"
belongs_to(
:author,
class_name: "Administrate::SearchSpecMocks::Person",
)
has_one :address
end

Expand Down
15 changes: 11 additions & 4 deletions spec/lib/fields/deferred_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@
context "when not given a `foreign_key` option" do
it "delegates to the backing class" do
deferred = Administrate::Field::Deferred.new(
Administrate::Field::String
Administrate::Field::String,
)
allow(Administrate::Field::String).to receive(:permitted_attribute)

deferred.permitted_attribute(:foo, resource_class: LineItem)

expect(Administrate::Field::String).
to have_received(:permitted_attribute).with(:foo, resource_class: LineItem)
expect(Administrate::Field::String).to(
have_received(:permitted_attribute).
with(:foo, resource_class: LineItem),
)
end
end

Expand All @@ -53,8 +55,13 @@
field,
class_name: "Foo::Bar",
)

deferred.permitted_attribute(:bars)
expect(field).to have_received(:permitted_attribute).with(:bars, class_name: "Foo::Bar")

expect(field).to(
have_received(:permitted_attribute).
with(:bars, class_name: "Foo::Bar"),
)
end
end
end
Expand Down
14 changes: 12 additions & 2 deletions spec/lib/fields/has_many_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
describe "#associated_collection" do
it "returns an index page for the dashboard of the associated attribute" do
customer = FactoryBot.build(:customer)
field = Administrate::Field::HasMany.new(:orders, Order.all, :show, resource: customer)
field = Administrate::Field::HasMany.new(
:orders,
Order.all,
:show,
resource: customer,
)

page = field.associated_collection

Expand Down Expand Up @@ -217,7 +222,12 @@
customer = FactoryBot.create(:customer, :with_orders)
options = { sort_by: :address_line_two, direction: :desc }
association = Administrate::Field::HasMany.with_options(options)
field = association.new(:orders, customer.orders, :show, resource: customer)
field = association.new(
:orders,
customer.orders,
:show,
resource: customer,
)

reversed_order = customer.orders.sort_by(&:address_line_two).map(&:id)
correct_order = customer.orders.sort do |a, b|
Expand Down

0 comments on commit 9b3bd4b

Please sign in to comment.