Skip to content

Commit

Permalink
report task for indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Sep 5, 2018
1 parent e34ade6 commit 1b8fa57
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/tasks/reports.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace :reports do

desc 'Index all reports'
task :index => :environment do
reports = Report.all
reports.each do |report|
report.queue_report
puts "Queued indexing for #{report.uid} Data Usage Reports."
end

end
end
40 changes: 40 additions & 0 deletions spec/tasks/reports_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require "rails_helper"

describe "rake reports:index", type: :task do

# it "preloads the Rails environment" do
# expect(task.prerequisites).to include "environment"
# end

# it "runs gracefully with no subscribers" do
# expect { task.execute }.not_to raise_error
# end

# it "logs to stdout" do
# expect { task.execute }.to output("Index reports\n").to_stdout
# end

# it "index all reports" do
# report = create(:report)

# task.invoke

# expect(report).to have_received_invoice
# end

# it "checks in with Dead Mans Snitch" do
# dead_mans_snitch_request = stub_request(:get, "https://nosnch.in/c2354d53d2")

# task.execute

# expect(dead_mans_snitch_request).to have_been_requested
# end

# matcher :have_received_invoice do
# match_unless_raises do |subscriber|
# expect(last_email_sent).to be_delivered_to subscriber.email
# expect(last_email_sent).to have_subject 'Your invoice'
# end
# end

end

0 comments on commit 1b8fa57

Please sign in to comment.