Permalink
Browse files

start project view

  • Loading branch information...
1 parent f386373 commit eef80b58347ea7336c4530f2c5ea9c39823e4239 @devton devton committed Apr 17, 2012
@@ -56,9 +56,16 @@ def start
def send_mail
current_user.update_attribute :email, params[:contact] if current_user.email.nil?
ProjectsMailer.start_project_email(
+ params[:how_much_you_need],
+ params[:category],
params[:about],
params[:rewards],
+ params[:video],
+ params[:twitter],
+ params[:blog],
params[:links],
+ params[:know_us_via],
+ params[:how_works],
params[:contact],
current_user,
"#{I18n.t('site.base_url')}#{user_path(current_user)}").deliver
@@ -1,10 +1,17 @@
class ProjectsMailer < ActionMailer::Base
include ERB::Util
- def start_project_email(about, rewards, links, contact, user, user_url)
+ def start_project_email(how_much_you_need, category, about, rewards, video, twitter, blog, links, know_us_via, how_works, contact, user, user_url)
+ @how_much_you_need = h(how_much_you_need)
+ @category = h(category)
@about = h(about).gsub("\n", "<br>").html_safe
@rewards = h(rewards).gsub("\n", "<br>").html_safe
+ @video = h(video)
+ @twitter = h(twitter)
+ @blog = h(blog)
@links = h(links).gsub("\n", "<br>").html_safe
+ @know_us_via = h(know_us_via).gsub("\n", "<br>").html_safe
+ @how_works = h(how_works).gsub("\n", "<br>").html_safe
@contact = contact
@user = user
@user_url = user_url
@@ -3,11 +3,25 @@
%meta{:content => "text/html; charset=UTF-8", 'http-equiv' => "Content-Type"}
%body
%h1= t('.subject_html', :link => link_to(@user.display_name, @user_url))
+ %h2= t('projects.start.how_much_you_need')
+ %p= @how_much_you_need
+ %h2= t('projects.start.category')
+ %p= @category
%h2= t('projects.start.about')
%p= @about
%h2= t('projects.start.rewards')
%p= @rewards
+ %h2= t('projects.start.video')
+ %p= @video
+ %h2= t('projects.start.twitter')
+ %p= @twitter
+ %h2= t('projects.start.blog')
+ %p= @blog
%h2= t('projects.start.links')
%p= @links
+ %h2= t('projects.start.know_us_via')
+ %p= @know_us_via
+ %h2= t('projects.start.how_works')
+ %p= @how_works
%h2= t('projects.start.contact')
%p= @contact
@@ -2,16 +2,25 @@
describe ProjectsMailer do
it "should send project, with HTML-safe fields and converting new lines to <br>" do
+ how_much_you_need = "1000 <javascript>"
+ category = "art <javascript>"
about = "About the project\n<javascript>"
rewards = "Rewards of the project\n<javascript>"
+ video = "http://vimeo.com/9090 <javascript>"
+ twitter = "username <javascript>"
+ blog = "www.lorem.com <javascript>"
links = "Links of the project\n<javascript>"
+ know_us_via = "My friends\n<javascript>"
+ how_works = "Through social networks\n<javascript>"
contact = "foo@bar.com"
user = Factory(:user)
- email = ProjectsMailer.start_project_email(about, rewards, links, contact, user, "#{I18n.t('site.base_url')}#{user_path(user)}").deliver
+ email = ProjectsMailer.start_project_email(how_much_you_need, category, about, rewards, video, twitter, blog, links, know_us_via, how_works, contact, user, "#{I18n.t('site.base_url')}#{user_path(user)}").deliver
ActionMailer::Base.deliveries.should_not be_empty
+ email.encoded.should =~ /1000 &lt;javascript&gt;/
email.encoded.should =~ /About the project\<br\>&lt;javascript&gt;/
email.encoded.should =~ /Rewards of the project\<br\>&lt;javascript&gt;/
email.encoded.should =~ /Links of the project\<br\>&lt;javascript&gt;/
+ email.encoded.should =~ /Through social networks\<br\>&lt;javascript&gt;/
email.encoded.should =~ /foo@bar.com/
email[:from].to_s.should == "#{I18n.t('site.name')} <#{I18n.t('site.email.system')}>"
end

0 comments on commit eef80b5

Please sign in to comment.