Skip to content

Commit

Permalink
Fix failing spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishant Samel committed Jun 18, 2024
1 parent 2663f8d commit ea64c1b
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions spec/requests/internal_api/v1/invoices/send_invoice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,33 @@
sign_in user
end

# it "returns a 202 response" do
# post send_invoice_internal_api_v1_invoice_path(id: invoice.id), params: { invoice_email: },
# headers: auth_headers(user)
it "returns a 202 response" do
post send_invoice_internal_api_v1_invoice_path(id: invoice.id), params: { invoice_email: },
headers: auth_headers(user)

# expect(response).to have_http_status :accepted
# expect(json_response["message"]).to eq("Invoice will be sent!")
# end
expect(response).to have_http_status :accepted
expect(json_response["message"]).to eq("Invoice will be sent!")
end

# it "enqueues an email for delivery" do
# expect do
# post send_invoice_internal_api_v1_invoice_path(id: invoice.id), params: { invoice_email: },
# headers: auth_headers(user)
# end.to have_enqueued_mail(InvoiceMailer, :invoice)
# end
it "enqueues an email for delivery" do
expect do
post send_invoice_internal_api_v1_invoice_path(id: invoice.id), params: { invoice_email: },
headers: auth_headers(user)
end.to have_enqueued_mail(InvoiceMailer, :invoice)
end

it "changes time_sheet_entries status to billed" do
post send_invoice_internal_api_v1_invoice_path(id: invoice.id), params: { invoice_email: },
headers: auth_headers(user)
expect do
post send_invoice_internal_api_v1_invoice_path(id: invoice.id), params: { invoice_email: },
headers: auth_headers(user)
end.to have_enqueued_mail(InvoiceMailer, :invoice)

perform_enqueued_jobs do
InvoiceMailer.with(
invoice_id: invoice.id, subject: invoice_email[:subject],
recipients: invoice_email[:recipients], message: invoice_email[:message]).invoice.deliver_later
end

invoice.invoice_line_items.reload.each do |line_item|
expect(line_item.timesheet_entry.bill_status).to eq("billed")
end
Expand Down

0 comments on commit ea64c1b

Please sign in to comment.