Skip to content

Commit

Permalink
fix bug preventing emails to be sent
Browse files Browse the repository at this point in the history
* Give the emailer a hash pulled from the JSON instead of a request_map
  • Loading branch information
zfletch committed May 2, 2019
1 parent 15a1221 commit 5b1d503
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/perseids_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def write_json_and_html!(count)
end

def send_email!(email, server, port, domain)
Emailer.new(request_map, email, server, port, domain).send!
reader = JSONReader.new
reader.read!
Emailer.new(reader.json, email, server, port, domain).send!

self
end
Expand Down
5 changes: 4 additions & 1 deletion spec/perseids_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,15 @@
let(:server) { 'your.smtp.server' }
let(:port) { 25 }
let(:domain) { 'mail.from.domain' }
let(:json_reader) { instance_double(PerseidsStatus::JSONReader, json: :json) }

before do
allow(PerseidsStatus::Emailer).to receive(:new).with(request_map, email, server, port, domain).and_return(emailer)
allow(PerseidsStatus::JSONReader).to receive(:new).with(no_args).and_return(json_reader)
allow(PerseidsStatus::Emailer).to receive(:new).with(:json, email, server, port, domain).and_return(emailer)
end

it 'sends the email' do
expect(json_reader).to receive(:read!).with(no_args)
expect(emailer).to receive(:send!).with(no_args)

expect(status.send_email!(email, server, port, domain)).to eq(status)
Expand Down

0 comments on commit 5b1d503

Please sign in to comment.