Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/services/most_recently_used_searcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ def initialize(user)
end

def recently_used_facilities(limit = 5)
return [] unless user
return Facility.none unless user

facility_ids = user.orders.purchased.order("MAX(ordered_at) DESC").limit(limit).group(:facility_id).pluck(:facility_id)
Facility.where(id: facility_ids)
end

def recently_used_products(limit = 10)
return [] unless user
return Product.none unless user

product_ids = user.orders.joins(order_details: :product).merge(Product.active.in_active_facility).purchased.order("MAX(orders.ordered_at) DESC").limit(limit).group(:product_id).pluck(:product_id)
Product.where(id: product_ids)
Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/facilities_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@
@action = :index
end

it "should render the page without a logged in user" do
do_request
expect(response).to be_successful
end

it_should_allow_all [:admin, :guest] do
expect(assigns[:facilities]).to eq([@authable])
expect(response).to be_success.and render_template("facilities/index")
Expand Down