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

fixed empty shell bug and added specs #699

Merged
merged 1 commit into from
Oct 18, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 5 additions & 3 deletions app/controllers/service_requests_controller.rb
Expand Up @@ -435,10 +435,12 @@ def remove_service
@service_request.reload

@protocol = @service_request.protocol

if ssr.line_items.empty? && !ssr.submitted_at.nil?
send_ssr_service_provider_notifications(@service_request, ssr, true)

if ssr.line_items.empty?
ssr.destroy
if !ssr.submitted_at.nil?
send_ssr_service_provider_notifications(@service_request, ssr, true)
end
end

@service_request.reload
Expand Down
Expand Up @@ -252,6 +252,17 @@
:format => :js,
}.with_indifferent_access
end

it 'should not delete SSR (ssr1)' do
post :remove_service, {
:id => service_request.id,
:service_id => service3.id,
:line_item_id => line_item1.id,
:format => :js,
}.with_indifferent_access
ssrs = [sub_service_request, ssr1, ssr2]
expect(service_request.sub_service_requests).to eq(ssrs)
end
end

context 'SSR has one service and it is removed' do
Expand All @@ -264,6 +275,17 @@
:format => :js,
}.with_indifferent_access
end

it 'should delete SSR (ssr2)' do
post :remove_service, {
:id => service_request.id,
:service_id => service3.id,
:line_item_id => line_item3.id,
:format => :js,
}.with_indifferent_access
remaining_ssrs = [sub_service_request, ssr1]
expect(service_request.sub_service_requests).to eq(remaining_ssrs)
end
end
end

Expand Down