Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KG - Service Calendar Specs (And Moved Some Disorganized Specs) #822

Merged
merged 7 commits into from
Dec 15, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added these classes to help specify elements for specs

.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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a new Additional Details folder for organization

# 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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here

# 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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to spec/features/dashboard/sub_service_requests/

136 changes: 136 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,136 @@
# 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
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-column').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-column').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', { @ssr2.organization.id => ['first_draft'] })
end

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

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

expect(all('.visit-quantity').last).to_not be_checked
end

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

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

expect(first('.visit-quantity')).to be_checked
end
end

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

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

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

expect(all('.visit-quantity').last).to be_checked
end

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

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

expect(first('.visit-quantity')).to_not be_checked
end
end
end
end
110 changes: 110 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,110 @@
# 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
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