Skip to content

Commit

Permalink
Merge pull request #1473 from sparc-request/sj-auto_pricing_modal_specs
Browse files Browse the repository at this point in the history
SJ - Adding specs for auto adjust modal, and small fixes.
  • Loading branch information
Stuart-Johnson committed Aug 8, 2018
2 parents 1d129c8 + c364d2e commit 5f347be
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
.clearfix
.modal-footer
%button.btn.btn-default{data: {dismiss: 'modal'}, type: 'button'} Close
%input#increase_decrease_submit.btn.btn-primary{type: 'submit', value: t(:actions)[:save]}
%input#increase_decrease_submit.btn.btn-primary{type: 'submit', value: t(:catalog_manager)[:organization_form][:pricing][:adjust_rates]}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ $("#epic .panel-body").html("<%= j render '/catalog_manager/services/epic_form',

$("#flashes_container").html("<%= escape_javascript(render( 'shared/flash' )) %>")

$("#org-form-container [data-toggle='toggle']").bootstrapToggle();
$("#epic .panel-body [data-toggle='toggle']").bootstrapToggle();
1 change: 1 addition & 0 deletions config/locales/catalog_manager.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ en:
max_dollar_cap: "Max Dollar Cap"
subsidy_instructions: "Instructions"
excluded_funding_sources: "Excluded Funding Sources"
adjust_rates: "Adjust Rates"
submission_emails:
email: "E-Mail"
remove_add: "Remove / Add"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright © 2011-2018 MUSC Foundation for Research Development
# All rights reserved.

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'rails_helper'

RSpec.describe 'User edits organization subsidy map', js: true do
let_there_be_lane
fake_login_for_each_test

before :each do
@institution = create(:institution)
@provider = create(:provider, parent_id: @institution.id)
@program = create(:program, parent: @provider)
@service = create(:service, organization: @program, components: "", one_time_fee: true, pricing_map_count: 1)
create(:catalog_manager, organization_id: @institution.id, identity_id: Identity.where(ldap_uid: 'jug2').first.id)
end

context 'on a Provider' do
context 'and the user uses the auto increase / decrease modal' do
before :each do
visit catalog_manager_catalog_index_path
wait_for_javascript_to_finish
find("#institution-#{@institution.id}").click
wait_for_javascript_to_finish
click_link @provider.name
wait_for_javascript_to_finish
click_link 'Pricing'
wait_for_javascript_to_finish
find("#increase_decrease_button").click
wait_for_javascript_to_finish
end

it 'should change pricing maps as needed' do
old_pm_count = @service.pricing_maps.size
old_rate = @service.pricing_maps.first.full_rate.to_i

fill_in 'percent_of_change', with: "-50"

find('#display_date').click
find('td.today').click

find('#effective_date').click
find('td.today').click

click_button 'Adjust Rates'
wait_for_javascript_to_finish

@service.reload

expect(@service.pricing_maps.size).to eq(old_pm_count + 1)
expect(@service.pricing_maps.last.full_rate.to_i).to eq(old_rate / 2)
end
end
end
end

0 comments on commit 5f347be

Please sign in to comment.