diff --git a/app/controllers/admin/enterprise_fees_controller.rb b/app/controllers/admin/enterprise_fees_controller.rb index 829f950b1f..6e1a7da113 100644 --- a/app/controllers/admin/enterprise_fees_controller.rb +++ b/app/controllers/admin/enterprise_fees_controller.rb @@ -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 diff --git a/app/views/admin/enterprise_fees/index.html.haml b/app/views/admin/enterprise_fees/index.html.haml index 789ee19935..f7398cb6c1 100644 --- a/app/views/admin/enterprise_fees/index.html.haml +++ b/app/views/admin/enterprise_fees/index.html.haml @@ -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 diff --git a/spec/features/admin/enterprise_fees_spec.rb b/spec/features/admin/enterprise_fees_spec.rb index 3c5526d6a1..958aeea419 100644 --- a/spec/features/admin/enterprise_fees_spec.rb +++ b/spec/features/admin/enterprise_fees_spec.rb @@ -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