-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #822 from sparc-request/kg-service_calendar_specs
KG - Service Calendar Specs (And Moved Some Disorganized Specs)
- Loading branch information
Showing
16 changed files
with
896 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
spec/features/additional_details/user_creates_an_additional_details_questionnaire_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
36 changes: 36 additions & 0 deletions
36
spec/features/additional_details/user_should_see_service_questionnaires_index_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,5 +45,4 @@ | |
|
||
expect(PastStatus.first.changed_by_id).to eq(jug2.id) | ||
end | ||
|
||
end | ||
end |
109 changes: 109 additions & 0 deletions
109
spec/features/service_calendar/user_checks_unchecks_column_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
114
spec/features/service_calendar/user_checks_unchecks_row_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.