Skip to content

Commit

Permalink
Merge pull request #822 from sparc-request/kg-service_calendar_specs
Browse files Browse the repository at this point in the history
KG - Service Calendar Specs (And Moved Some Disorganized Specs)
  • Loading branch information
jayhardee9 committed Dec 15, 2016
2 parents c75805e + 5d2b80e commit 3f8b662
Show file tree
Hide file tree
Showing 16 changed files with 896 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
-# 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.
.panel.panel-primary.calendar-container
.panel.panel-primary.calendar-container.otf-calendar
.panel-heading
%h3.panel-title
= t(:calendars)[:otf][:header]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
- displayed_pricing_map = line_item.service.displayed_pricing_map
- otf_unit_type = displayed_pricing_map.try(:otf_unit_type)
- otf_qty_type = displayed_pricing_map.try(:quantity_type)
%tr{ class: locked ? 'bg-danger text-danger' : '' }
%tr.otf-line-item-row{ class: locked ? 'bg-danger text-danger' : '' }
%td.service-name{ colspan: 2 }
= line_item.service.display_service_name
%td.status.text-center
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

-# Line Item Visits
- livs.each do |liv|
%tr{ class: locked ? 'bg-danger text-danger' : '' }
%tr.pppv-line-item-row{ class: locked ? 'bg-danger text-danger' : '' }
%td.service-name{ colspan: 2 }
= liv.service.display_service_name
%td.status.text-center
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

-# Line Items Visits
- livs.each do |liv|
%tr{ class: locked ? 'bg-danger text-danger' : '' }
%tr.pppv-line-item-row{ class: locked ? 'bg-danger text-danger' : '' }
%td.service-name{ colspan: 2 }
= liv.service.display_service_name
%td.status.text-center
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-# 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.
- visit_groups = arm.visit_groups.page(page)
.panel.panel-primary.calendar-container{ class: "arm-calendar-container-#{arm.id}", data: { arm_id: arm.id } }
.panel.panel-primary.calendar-container.pppv-calendar{ class: "arm-calendar-container-#{arm.id}", data: { arm_id: arm.id } }
.panel-heading
.pull-left
%h3.panel-title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

-# Line Items Visits
- livs.each do |liv|
%tr{ class: locked ? 'bg-danger text-danger' : '' }
%tr.pppv-line-item-row{ class: locked ? 'bg-danger text-danger' : '' }
%td.service-name{ colspan: 2 }
= liv.service.display_service_name
%td.status.text-center
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright © 2011 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 creates an additional details questionnaire', js: true do
let_there_be_lane
scenario 'successfully' do
service = create(:service)
visit new_service_additional_details_questionnaire_path(service)
fill_in 'questionnaire_name', with: 'New Questionnaire'
fill_in 'questionnaire_items_attributes_0_content', with: 'What is your favorite color?'
select 'Radio Button', from: 'questionnaire_items_attributes_0_item_type'
fill_in 'questionnaire_items_attributes_0_item_options_attributes_0_content', with: 'Green'
click_link 'Add another Option'
fill_in 'questionnaire_items_attributes_0_item_options_attributes_1_content', with: 'Red'

check 'questionnaire_items_attributes_0_required'

click_button 'Create Questionnaire'

expect(current_path).to eq service_additional_details_questionnaires_path(service)
expect(Questionnaire.count).to eq 1
expect(Item.count).to eq 1
expect(ItemOption.count).to eq 2
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright © 2011 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 should see service questionnaire index', js: true do
let_there_be_lane
scenario 'successfully' do
service = create(:service)
questionnaire = create(:questionnaire,
name: 'Awesome Questionnaire',
service: service)
create(:item, questionnaire: questionnaire)

visit service_additional_details_questionnaires_path(service)

expect(page).to have_css 'tr td', text: questionnaire.name
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@

expect(PastStatus.first.changed_by_id).to eq(jug2.id)
end

end
end
109 changes: 109 additions & 0 deletions spec/features/service_calendar/user_checks_unchecks_column_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Copyright © 2011 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 checks and unchecks calendar columns', js: true do
let_there_be_lane

fake_login_for_each_test

before :each do
org = create(:organization)
org2 = create(:organization)
create(:pricing_setup, organization: org)
create(:pricing_setup, organization: org2)
service = create(:service, organization: org, one_time_fee: false)
service2 = create(:service, organization: org2, one_time_fee: false)

protocol = create(:protocol_federally_funded, primary_pi: jug2)
@sr = create(:service_request_without_validations, protocol: protocol)
@ssr = create(:sub_service_request, service_request: @sr, organization: org)
@ssr2 = create(:sub_service_request, service_request: @sr, organization: org2)
li = create(:line_item, service_request: @sr, sub_service_request: @ssr, service: service)
li2 = create(:line_item, service_request: @sr, sub_service_request: @ssr2, service: service2)

arm = create(:arm, protocol: protocol)
vg = create(:visit_group, arm: arm)
liv = create(:line_items_visit, line_item: li, arm: arm)
liv2 = create(:line_items_visit, line_item: li2, arm: arm)
create(:visit, visit_group: vg, line_items_visit: liv)
create(:visit, visit_group: vg, line_items_visit: liv2)
end

context 'for SSRs which aren\'t locked' do
before :each do
stub_const('EDITABLE_STATUSES', { })
end

context 'check:' do
scenario 'and sees all visits checked' do
visit service_calendar_service_request_path(@sr)

find('.service-calendar-column').click

expect(page).to have_css('.visit-quantity[checked]', count: 2)
end
end

context 'uncheck:' do
scenario 'and sees all visits unchecked' do
Visit.update_all(research_billing_qty: 1)
visit service_calendar_service_request_path(@sr)

find('.service-calendar-column').click

expect(page).to have_css('.visit-quantity[checked]', count: 0)
end
end
end

context 'for locked SSRs' do
before :each do
stub_const('EDITABLE_STATUSES', { @ssr2.organization.id => ['first_draft'] })
end

context 'check:' do
scenario 'and sees the not-locked visits checked and the locked visits not checked' do
visit service_calendar_service_request_path(@sr)

find('.service-calendar-column').click

expect(page).to have_css('.visit-quantity[checked]', count: 1)
expect(all('.visit-quantity').last).to_not be_checked
end
end

context 'uncheck:' do
before :each do
Visit.update_all(research_billing_qty: 1)
end

scenario 'and sees the not-locked visits unchecked and the locked visits checked' do
visit service_calendar_service_request_path(@sr)

find('.service-calendar-column').click

expect(page).to have_css('.visit-quantity:checked', count: 1)
expect(all('.visit-quantity').last).to be_checked
end
end
end
end
114 changes: 114 additions & 0 deletions spec/features/service_calendar/user_checks_unchecks_row_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright © 2011 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 checks and unchecks calendar rows', js: true do
let_there_be_lane

fake_login_for_each_test

before :each do
org = create(:organization)
create(:pricing_setup, organization: org)
service = create(:service, organization: org, one_time_fee: false)

protocol = create(:protocol_federally_funded, primary_pi: jug2)
@sr = create(:service_request_without_validations, protocol: protocol)
@ssr = create(:sub_service_request, service_request: @sr, organization: org)
li = create(:line_item, service_request: @sr, sub_service_request: @ssr, service: service)

arm = create(:arm, protocol: protocol, visit_count: 3)
liv = create(:line_items_visit, line_item: li, arm: arm)
vg1 = create(:visit_group, arm: arm)
vg2 = create(:visit_group, arm: arm)
vg3 = create(:visit_group, arm: arm)
create(:visit, visit_group: vg1, line_items_visit: liv)
create(:visit, visit_group: vg2, line_items_visit: liv)
create(:visit, visit_group: vg3, line_items_visit: liv)
end

context 'for SSRs which aren\'t locked' do
before :each do
stub_const('EDITABLE_STATUSES', { })
end

context 'check:' do
scenario 'and sees all visits checked' do
visit service_calendar_service_request_path(@sr)
wait_for_javascript_to_finish

first('.service-calendar-row').click
wait_for_javascript_to_finish

all('.visit-quantity').each do |checkbox|
expect(checkbox).to be_checked
end
end
end

context 'uncheck:' do
scenario 'and sees all visits unchecked' do
Visit.update_all(research_billing_qty: 1)

visit service_calendar_service_request_path(@sr)
wait_for_javascript_to_finish

first('.service-calendar-row').click
wait_for_javascript_to_finish

all('.visit-quantity').each do |checkbox|
expect(checkbox).to_not be_checked
end
end
end
end

context 'for locked SSRs' do
before :each do
stub_const('EDITABLE_STATUSES', { @ssr.organization.id => ['first_draft'] })
end

context 'check:' do
scenario 'and sees the button is disabled' do
visit service_calendar_service_request_path(@sr)
wait_for_javascript_to_finish

#Capybara::Node::Element would not return disabled for some reason, but running this script would
expect(page.evaluate_script("$('.service-calendar-row').attr('disabled');")).to eq('disabled')
end

end

context 'uncheck:' do
before :each do
Visit.update_all(research_billing_qty: 1)
end

scenario 'and sees the button is disabled' do
visit service_calendar_service_request_path(@sr)
wait_for_javascript_to_finish

#Capybara::Node::Element would not return disabled for some reason, but running this script would
expect(page.evaluate_script("$('.service-calendar-row').attr('disabled');")).to eq('disabled')
end
end
end
end

0 comments on commit 3f8b662

Please sign in to comment.