mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Enterprise manager can clone an order cycle
This commit is contained in:
@@ -62,7 +62,7 @@ module Admin
|
||||
end
|
||||
|
||||
def clone
|
||||
@order_cycle = OrderCycle.find params[:order_cycle_id]
|
||||
@order_cycle = OrderCycle.find params[:id]
|
||||
@order_cycle.clone!
|
||||
redirect_to main_app.admin_order_cycles_path, :notice => "Your order cycle #{@order_cycle.name} has been cloned."
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ class AbilityDecorator
|
||||
user.enterprises.include? payment_method.distributor
|
||||
end
|
||||
|
||||
can [:admin, :index, :read, :edit, :update], OrderCycle do |order_cycle|
|
||||
can [:admin, :index, :read, :edit, :update, :clone], OrderCycle do |order_cycle|
|
||||
user.enterprises.include? order_cycle.coordinator
|
||||
end
|
||||
|
||||
|
||||
@@ -38,5 +38,5 @@
|
||||
- order_cycle.variants.each do |v|
|
||||
= image_tag(v.images.first.attachment.url(:mini)) if v.images.present?
|
||||
%td.actions
|
||||
= link_to '', main_app.admin_order_cycle_clone_path(order_cycle), class: 'clone-order-cycle icon-copy no-text'
|
||||
= link_to '', main_app.clone_admin_order_cycle_path(order_cycle), class: 'clone-order-cycle icon-copy no-text'
|
||||
= f.submit 'Update'
|
||||
|
||||
@@ -19,7 +19,7 @@ Openfoodweb::Application.routes.draw do
|
||||
namespace :admin do
|
||||
resources :order_cycles do
|
||||
post :bulk_update, :on => :collection, :as => :bulk_update
|
||||
get :clone
|
||||
get :clone, on: :member
|
||||
end
|
||||
|
||||
resources :enterprises do
|
||||
|
||||
@@ -426,6 +426,18 @@ feature %q{
|
||||
order_cycle.coordinator.should == distributor1
|
||||
end
|
||||
|
||||
scenario "cloning an order cycle" do
|
||||
oc = create(:simple_order_cycle)
|
||||
|
||||
click_link "Order Cycles"
|
||||
first('a.clone-order-cycle').click
|
||||
flash_message.should == "Your order cycle #{oc.name} has been cloned."
|
||||
|
||||
# Then I should have clone of the order cycle
|
||||
occ = OrderCycle.last
|
||||
occ.name.should == "COPY OF #{oc.name}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -126,11 +126,11 @@ module Spree
|
||||
let(:oc2) { create(:simple_order_cycle) }
|
||||
|
||||
it "should be able to read/write OrderCycles they are the co-ordinator of" do
|
||||
should have_ability([:admin, :index, :read, :edit], for: oc1)
|
||||
should have_ability([:admin, :index, :read, :edit, :update, :clone], for: oc1)
|
||||
end
|
||||
|
||||
it "should not be able to read/write OrderCycles they are not the co-ordinator of" do
|
||||
should_not have_ability([:admin, :index, :read, :create, :edit], for: oc2)
|
||||
should_not have_ability([:admin, :index, :read, :create, :edit, :update, :clone], for: oc2)
|
||||
end
|
||||
|
||||
it "should be able to create OrderCycles" do
|
||||
|
||||
Reference in New Issue
Block a user