mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Add Permissions#editable_enterprises
This commit is contained in:
@@ -15,6 +15,11 @@ module OpenFoodNetwork
|
||||
managed_and_related_enterprises_with :add_to_order_cycle
|
||||
end
|
||||
|
||||
# Find enterprises for which an admin is allowed to edit their profile
|
||||
def editable_enterprises
|
||||
managed_and_related_enterprises_with :edit_profile
|
||||
end
|
||||
|
||||
# For every hub that an admin manages, show all the producers that that hub may add
|
||||
# to the order cycle
|
||||
# {hub1_id => [producer1_id, producer2_id, ...], ...}
|
||||
|
||||
@@ -21,6 +21,19 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
describe "finding enterprises whose profiles can be edited" do
|
||||
let(:e) { double(:enterprise) }
|
||||
|
||||
it "returns managed and related enterprises with edit_profile permission" do
|
||||
permissions.
|
||||
should_receive(:managed_and_related_enterprises_with).
|
||||
with(:edit_profile).
|
||||
and_return([e])
|
||||
|
||||
permissions.editable_enterprises.should == [e]
|
||||
end
|
||||
end
|
||||
|
||||
describe "finding enterprises that can be added to an order cycle, for each hub" do
|
||||
let!(:hub) { create(:distributor_enterprise) }
|
||||
let!(:producer) { create(:supplier_enterprise) }
|
||||
|
||||
Reference in New Issue
Block a user