Skip to content

Commit

Permalink
Validate: false is not a valid option to ActiveRecord's #new. Comment…
Browse files Browse the repository at this point in the history
…ed out some specs with no expectations.
  • Loading branch information
Jay Hardee authored and William Holt committed Feb 24, 2017
1 parent 5cd2099 commit 1dd8aa7
Showing 1 changed file with 67 additions and 67 deletions.
134 changes: 67 additions & 67 deletions spec/models/line_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
organization.pricing_setups[0].update_attributes(display_date: Date.today - 1)
service = build(:service, organization_id: organization.id, pricing_map_count: 0)
service.save!(validate: false)
project = Project.new(attributes_for(:protocol), validate: false)
project = Project.new(attributes_for(:protocol))
project.save!(validate: false)
# service_request = ServiceRequest.create(attributes_for(:service_request), protocol_id: project.id, validate: false)
service_request = ServiceRequest.create(attributes_for(:service_request, protocol_id: project.id)); service_request.save!(validate: false); service_request
Expand All @@ -52,72 +52,72 @@
expect(lambda { line_item.applicable_rate }).to raise_exception(ArgumentError)
end

it 'should call applicable_rate on the pricing map of a project with the applied percentage and rate type returned by the pricing setup' do
# TODO: it's obvious by the complexity of this test that
# applicable_rate() is doing too much, but I'm not sure how to
# refactor it to be simpler.

project = Project.create(attributes_for(:protocol))
project.save(validate: false)

organization = create(:organization, pricing_setup_count: 1)
organization.pricing_setups[0].update_attributes(display_date: Date.today - 1)

service = create(:service, organization_id: organization.id, pricing_map_count: 1)
service.pricing_maps[0].update_attributes(display_date: Date.today)

service_request = ServiceRequest.create(attributes_for(:service_request, protocol_id: project.id)); service_request.save!(validate: false); service_request
service_request.save(validate: false)
line_item = create(:line_item, service_id: service.id, service_request_id: service_request.id)
allow(line_item.service_request.protocol).to receive(:funding_status).and_return('funded')
allow(line_item.service_request.protocol).to receive(:funding_source).and_return('college')

allow(line_item.service.organization.pricing_setups[0]).to receive(:rate_type).
with('college').
and_return('federal')
allow(line_item.service.organization.pricing_setups[0]).to receive(:applied_percentage).
with('federal').
and_return(0.42)

service.pricing_maps[0] = double(display_date: Date.today - 1)
allow(line_item.service.pricing_maps[0]).to receive(:applicable_rate).with('federal', 0.42)

line_item.applicable_rate
end

it 'should call applicable_rate on the pricing map of a study with the applied percentage and rate type returned by the pricing setup' do
# TODO: it's obvious by the complexity of this test that
# applicable_rate() is doing too much, but I'm not sure how to
# refactor it to be simpler.

study = Study.create(attributes_for(:protocol))
study.save(validate: false)

organization = create(:organization, pricing_setup_count: 1)
organization.pricing_setups[0].update_attributes(display_date: Date.today - 1)

service = create(:service, organization_id: organization.id, pricing_map_count: 1)
service.pricing_maps[0].update_attributes(display_date: Date.today)

service_request = build(:service_request, protocol_id: study.id)
service_request.save(validate: false)
line_item = create(:line_item, service_id: service.id, service_request_id: service_request.id)
allow(line_item.service_request.protocol).to receive(:funding_source_based_on_status).and_return('college')

allow(line_item.service.organization.pricing_setups[0]).to receive(:rate_type).
with('college').
and_return('federal')
allow(line_item.service.organization.pricing_setups[0]).to receive(:applied_percentage).
with('federal').
and_return(0.42)

service.pricing_maps[0] = double(display_date: Date.today - 1)
allow(line_item.service.pricing_maps[0]).to receive(:applicable_rate).
with('federal', 0.42)

line_item.applicable_rate
end

# it 'should call applicable_rate on the pricing map of a project with the applied percentage and rate type returned by the pricing setup' do
# # TODO: it's obvious by the complexity of this test that
# # applicable_rate() is doing too much, but I'm not sure how to
# # refactor it to be simpler.
#
# project = Project.create(attributes_for(:protocol))
# project.save(validate: false)
#
# organization = create(:organization, pricing_setup_count: 1)
# organization.pricing_setups[0].update_attributes(display_date: Date.today - 1)
#
# service = create(:service, organization_id: organization.id, pricing_map_count: 1)
# service.pricing_maps[0].update_attributes(display_date: Date.today)
#
# service_request = ServiceRequest.create(attributes_for(:service_request, protocol_id: project.id)); service_request.save!(validate: false); service_request
# service_request.save(validate: false)
# line_item = create(:line_item, service_id: service.id, service_request_id: service_request.id)
# allow(line_item.service_request.protocol).to receive(:funding_status).and_return('funded')
# allow(line_item.service_request.protocol).to receive(:funding_source).and_return('college')
#
# allow(line_item.service.organization.pricing_setups[0]).to receive(:rate_type).
# with('college').
# and_return('federal')
# allow(line_item.service.organization.pricing_setups[0]).to receive(:applied_percentage).
# with('federal').
# and_return(0.42)
#
# service.pricing_maps[0] = double(display_date: Date.today - 1)
# allow(line_item.service.pricing_maps[0]).to receive(:applicable_rate).with('federal', 0.42)
#
# line_item.applicable_rate
# end
#
# it 'should call applicable_rate on the pricing map of a study with the applied percentage and rate type returned by the pricing setup' do
# # TODO: it's obvious by the complexity of this test that
# # applicable_rate() is doing too much, but I'm not sure how to
# # refactor it to be simpler.
#
# study = Study.create(attributes_for(:protocol))
# study.save(validate: false)
#
# organization = create(:organization, pricing_setup_count: 1)
# organization.pricing_setups[0].update_attributes(display_date: Date.today - 1)
#
# service = create(:service, organization_id: organization.id, pricing_map_count: 1)
# service.pricing_maps[0].update_attributes(display_date: Date.today)
#
# service_request = build(:service_request, protocol_id: study.id)
# service_request.save(validate: false)
# line_item = create(:line_item, service_id: service.id, service_request_id: service_request.id)
# allow(line_item.service_request.protocol).to receive(:funding_source_based_on_status).and_return('college')
#
# allow(line_item.service.organization.pricing_setups[0]).to receive(:rate_type).
# with('college').
# and_return('federal')
# allow(line_item.service.organization.pricing_setups[0]).to receive(:applied_percentage).
# with('federal').
# and_return(0.42)
#
# service.pricing_maps[0] = double(display_date: Date.today - 1)
# allow(line_item.service.pricing_maps[0]).to receive(:applicable_rate).
# with('federal', 0.42)
#
# line_item.applicable_rate
# end
#
context "admin rate" do

before :each do
Expand Down

0 comments on commit 1dd8aa7

Please sign in to comment.