forked from jpmobile/jpmobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New feature : sending decorated mails to mobile phone
- Loading branch information
Showing
9 changed files
with
120 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
class DecoratedMailer < Jpmobile::Mailer::Base | ||
default :from => "info@jp.mobile" | ||
default :to => "info@jp.mobile" | ||
|
||
def deco_mail(to_mail) | ||
attachments.inline['photo.jpg'] = open(File.join(Rails.root, 'spec/fixtures/mobile_mailer/photo.jpg')).read | ||
|
||
mail(:to => to_mail, :subject => '題名', :decorated => true) | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
test/rails/overrides/app/views/decorated_mailer/deco_mail.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<body> | ||
<p> | ||
HTMLメールの本文 | ||
</p> | ||
<p> | ||
<%= image_tag attachments['photo.jpg'].url -%> | ||
</p> | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
test/rails/overrides/app/views/decorated_mailer/deco_mail.text.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
テキストメールの本文 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions
44
test/rails/overrides/spec/mailers/decorated_mailer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
require File.expand_path(File.join(File.dirname(__FILE__), '/../spec_helper')) | ||
|
||
describe DecoratedMailer do | ||
include Jpmobile::Util | ||
|
||
before(:each) do | ||
ActionMailer::Base.deliveries = [] | ||
end | ||
|
||
shared_examples_for "content-type" do | ||
it "sends decorated mail successfully" do | ||
DecoratedMailer.deco_mail(@to).deliver | ||
|
||
email = ActionMailer::Base.deliveries.first | ||
email.header['Content-Type'].main_type.should == 'multipart' | ||
email.header['Content-Type'].sub_type.should == 'mixed' | ||
end | ||
end | ||
|
||
describe "docomo" do | ||
before(:each) do | ||
@to = "docomo@docomo.ne.jp" | ||
end | ||
|
||
it_behaves_like "content-type" | ||
end | ||
|
||
describe "au" do | ||
before(:each) do | ||
@to = "au@ezweb.ne.jp" | ||
end | ||
|
||
it_behaves_like "content-type" | ||
end | ||
|
||
describe "softbank" do | ||
before(:each) do | ||
@to = "softbank@softbank.ne.jp" | ||
end | ||
|
||
it_behaves_like "content-type" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters