mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
After saving, maintain filter on enterprise fees by enterprise
This commit is contained in:
@@ -7,6 +7,7 @@ module Admin
|
||||
|
||||
def index
|
||||
@include_calculators = params[:include_calculators].present?
|
||||
@enterprise = current_enterprise
|
||||
|
||||
blank_enterprise_fee = EnterpriseFee.new
|
||||
blank_enterprise_fee.enterprise = current_enterprise
|
||||
@@ -21,7 +22,12 @@ module Admin
|
||||
def bulk_update
|
||||
@enterprise_fee_set = EnterpriseFeeSet.new(params[:enterprise_fee_set])
|
||||
if @enterprise_fee_set.save
|
||||
redirect_to main_app.admin_enterprise_fees_path, :notice => 'Your enterprise fees have been updated.'
|
||||
redirect_path = main_app.admin_enterprise_fees_path
|
||||
if params.key? :enterprise_id
|
||||
redirect_path = main_app.admin_enterprise_fees_path(enterprise_id: params[:enterprise_id])
|
||||
end
|
||||
redirect_to redirect_path, :notice => 'Your enterprise fees have been updated.'
|
||||
|
||||
else
|
||||
render :index
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
%h1 Enterprise Fees
|
||||
|
||||
= ng_form_for @enterprise_fee_set, :url => main_app.bulk_update_admin_enterprise_fees_path, :html => {'ng-app' => 'enterprise_fees', 'ng-controller' => 'AdminEnterpriseFeesCtrl'} do |enterprise_fee_set_form|
|
||||
= hidden_field_tag 'enterprise_id', @enterprise.id if @enterprise
|
||||
- if @enterprise_fee_set.errors.present?
|
||||
%h2 Errors
|
||||
%ul
|
||||
|
||||
@@ -139,6 +139,8 @@ feature %q{
|
||||
end
|
||||
|
||||
it "creates enterprise fees" do
|
||||
ef2
|
||||
|
||||
click_link 'Enterprises'
|
||||
within(".enterprise-#{distributor1.id}") { click_link 'Enterprise Fees' }
|
||||
|
||||
@@ -149,6 +151,9 @@ feature %q{
|
||||
|
||||
flash_message.should == 'Your enterprise fees have been updated.'
|
||||
|
||||
# After saving, we should be redirected to the fees for our chosen enterprise
|
||||
page.should_not have_select 'enterprise_fee_set_collection_attributes_1_enterprise_id', selected: 'Second Distributor'
|
||||
|
||||
enterprise_fee = EnterpriseFee.find_by_name 'foo'
|
||||
enterprise_fee.enterprise.should == distributor1
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user