spec/griddler/mailgun/adapter_spec.rb in griddler-mailgun-1.0.0 vs spec/griddler/mailgun/adapter_spec.rb in griddler-mailgun-1.0.1

- old
+ new

@@ -5,10 +5,16 @@ Griddler.adapter_registry[:mailgun].should eq Griddler::Mailgun::Adapter end end describe Griddler::Mailgun::Adapter, '.normalize_params' do + it 'works with Griddler::Email' do + normalized_params = Griddler::Mailgun::Adapter.normalize_params(default_params) + griddler_email = Griddler::Email.new(normalized_params) + expect(griddler_email.class).to eq Griddler::Email + end + it 'falls back to headers for cc' do params = default_params.merge(Cc: '') normalized_params = Griddler::Mailgun::Adapter.normalize_params(params) expect(normalized_params[:cc]).to eq ["Brandon Stark <brandon@example.com>", "Arya Stark <arya@example.com>"] end @@ -58,10 +64,11 @@ ] end it 'handles missing params' do normalized_params = Griddler::Mailgun::Adapter.normalize_params(short_params) + expect(normalized_params[:to]).to eq ['johndoe@example.com'] end def upload_1 @upload_1 ||= ActionDispatch::Http::UploadedFile.new( filename: 'photo1.jpg', @@ -91,15 +98,16 @@ [\"Cc\", \"Brandon Stark <brandon@example.com>, Arya Stark <arya@example.com>\"] ]" end def short_params - params = { - To: 'Hello World <hi@example.com>', - From: 'There <there@example.com>', - Cc: 'emily@example.com', - 'body-plain' => 'hi', - } + params = ActiveSupport::HashWithIndifferentAccess.new( + { + "from" => "Jon Snow <jon@example.com>", + "recipient" => "johndoe@example.com", + "body-plain" => "hi" + } + ) end def default_params params = ActiveSupport::HashWithIndifferentAccess.new( {