mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Indent code to be more Readable
This commit is contained in:
@@ -40,8 +40,11 @@ module Admin
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render_as_json @collection, ams_prefix: params[:ams_prefix],
|
||||
editable_schedule_ids: permissions.editable_schedules.pluck(:id)
|
||||
render_as_json(
|
||||
@collection,
|
||||
ams_prefix: params[:ams_prefix],
|
||||
editable_schedule_ids: permissions.editable_schedules.pluck(:id)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -119,7 +122,8 @@ module Admin
|
||||
.pluck(:id)
|
||||
result = @existing_order_cycle_ids
|
||||
result |= (requested & permitted) # add any requested & permitted ids
|
||||
result -= ((result & permitted) - requested) # remove any existing and permitted ids that were not specifically requested
|
||||
# remove any existing and permitted ids that were not specifically requested
|
||||
result -= ((result & permitted) - requested)
|
||||
result
|
||||
end
|
||||
|
||||
|
||||
@@ -80,8 +80,12 @@ module Api
|
||||
end
|
||||
|
||||
def permitted_ransack_params
|
||||
[:name_or_meta_keywords_or_variants_display_as_or_variants_display_name_or_supplier_name_cont,
|
||||
:with_properties, :primary_taxon_id_in_any]
|
||||
[
|
||||
"#{[:name, :meta_keywords, :variants_display_as,
|
||||
:variants_display_name, :supplier_name]
|
||||
.join('_or_')}_cont",
|
||||
:with_properties, :primary_taxon_id_in_any
|
||||
]
|
||||
end
|
||||
|
||||
def distributor
|
||||
|
||||
@@ -34,7 +34,13 @@ class AngularFormBuilder < ActionView::Helpers::FormBuilder
|
||||
options.reverse_merge!('id' => angular_id(method), 'ng-model' => angular_model(method).to_s)
|
||||
|
||||
@template.select_tag angular_name(method),
|
||||
@template.ng_options_from_collection_for_select(collection, value_method, text_method, angular_field), options
|
||||
@template.ng_options_from_collection_for_select(
|
||||
collection,
|
||||
value_method,
|
||||
text_method,
|
||||
angular_field
|
||||
),
|
||||
options
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -15,9 +15,12 @@ module Api
|
||||
end
|
||||
|
||||
def in_open_and_upcoming_order_cycles
|
||||
OrderManagement::Subscriptions::VariantsList.in_open_and_upcoming_order_cycles?(option_or_assigned_shop,
|
||||
option_or_assigned_schedule,
|
||||
object.variant)
|
||||
OrderManagement::Subscriptions::VariantsList
|
||||
.in_open_and_upcoming_order_cycles?(
|
||||
option_or_assigned_shop,
|
||||
option_or_assigned_schedule,
|
||||
object.variant
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -13,8 +13,8 @@ module Api
|
||||
let!(:property1) { create(:property, presentation: 'Organic') }
|
||||
let!(:property2) { create(:property, presentation: 'Dairy-Free') }
|
||||
let!(:property3) { create(:property, presentation: 'May Contain Nuts') }
|
||||
let!(:product1) { create(:product, primary_taxon: taxon1, properties: [property1]) }
|
||||
let!(:product2) { create(:product, primary_taxon: taxon2, properties: [property2]) }
|
||||
let!(:product1) { create(:product, name: "Kangaroo", primary_taxon: taxon1, properties: [property1]) }
|
||||
let!(:product2) { create(:product, name: "Parsnips", primary_taxon: taxon2, properties: [property2]) }
|
||||
let!(:product3) { create(:product, primary_taxon: taxon2) }
|
||||
let!(:product4) { create(:product, primary_taxon: taxon3, properties: [property3]) }
|
||||
let!(:user) { create(:user) }
|
||||
@@ -34,6 +34,16 @@ module Api
|
||||
expect(product_ids).to include product1.id, product2.id, product3.id
|
||||
end
|
||||
|
||||
it "returns products that were searched for" do
|
||||
ransack_param = "name_or_meta_keywords_or_variants_display_as_or_" \
|
||||
"variants_display_name_or_supplier_name_cont"
|
||||
api_get :products, id: order_cycle.id, distributor: distributor.id,
|
||||
q: { ransack_param => "Kangaroo" }
|
||||
|
||||
expect(product_ids).to include product1.id
|
||||
expect(product_ids).to_not include product2.id
|
||||
end
|
||||
|
||||
context "with variant overrides" do
|
||||
let!(:vo1) {
|
||||
create(:variant_override,
|
||||
|
||||
Reference in New Issue
Block a user