Take the 2008 Git User's Survey and help out! [ hide ]

public
Description: Gitorious aims to provide a great way of doing distributed opensource code collaboration.
Homepage: http://gitorious.org/projects/gitorious
Clone URL: git://github.com/dysinger/gitorious.git
Search Repo:
switched to ActionMailer::Base.default_url_options && UrlHelper 
for urls
dysinger (author)
Thu Apr 10 21:19:31 -0700 2008
commit  ffe4fc36e46e321b31e6c580c55141d7558d2f1c
tree    cf6d45a98d847bbba5947b0db5851a5e7b84c36a
parent  25177c88703dcc6146d0d67afc937e8240c3c4be
...
2
3
4
5
6
 
 
 
 
 
7
8
 
9
10
11
12
13
 
14
15
16
...
18
19
20
21
 
22
23
 
24
25
26
27
28
29
30
31
32
 
 
 
 
 
 
33
34
 
35
36
37
38
39
40
 
41
42
43
...
2
3
4
 
 
5
6
7
8
9
10
 
11
12
13
14
15
 
16
17
18
19
...
21
22
23
 
24
25
 
26
27
28
29
30
31
 
 
 
 
32
33
34
35
36
37
38
 
39
40
41
42
43
44
 
45
46
47
48
0
@@ -2,15 +2,18 @@ class Mailer < ActionMailer::Base
0
   def signup_notification(user)
0
     setup_email(user)
0
     @subject += 'Please activate your new account'
0
- @body[:url] = "http://#{GitoriousConfig['gitorious_host']}/users/activate/#{user.activation_code}"
0
-
0
+ @body[:url] = url_for(
0
+ :controller => 'users',
0
+ :action => 'activate',
0
+ :activation_code => user.activation_code
0
+ )
0
   end
0
-
0
+
0
   def activation(user)
0
     setup_email(user)
0
     @subject += 'Your account has been activated!'
0
   end
0
-
0
+
0
   def new_repository_clone(repository)
0
     setup_email(repository.project.user)
0
     @subject += %Q{#{repository.user.login} has cloned #{repository.project.slug}/#{repository.parent.name}}
0
@@ -18,26 +21,28 @@ class Mailer < ActionMailer::Base
0
     @body[:cloner] = repository.user
0
     @body[:project] = repository.project
0
     @body[:repository] = repository
0
- @body[:url] = "http://#{GitoriousConfig['gitorious_host']}/p/#{repository.project.slug}/repos/#{repository.name}"
0
+ @body[:url] = project_repository_url(repository.project, repository)
0
   end
0
-
0
+
0
   def merge_request_notification(merge_request)
0
     setup_email(merge_request.target_repository.user)
0
     @subject += %Q{#{merge_request.source_repository.user.login} has requested a merge in #{merge_request.target_repository.project.title}}
0
     @body[:merge_request] = merge_request
0
     @body[:project] = merge_request.target_repository.project
0
- url = "http://#{GitoriousConfig['gitorious_host']}/p/#{merge_request.target_repository.project.slug}"
0
- url << "/repos/#{merge_request.target_repository.name}"
0
- url << "/merge_requests/#{merge_request.id}"
0
- @body[:url] = url
0
+ @body[:url] =
0
+ project_repository_merge_request_url(
0
+ merge_request.target_repository.project,
0
+ merge_request.target_repository,
0
+ merge_request
0
+ )
0
   end
0
-
0
+
0
   def forgotten_password(user, password)
0
     setup_email(user)
0
     @subject += "Your new password"
0
     @body[:password] = password
0
   end
0
-
0
+
0
   protected
0
     def setup_email(user)
0
       @recipients = "#{user.email}"
...
14
15
16
17
 
 
 
18
19
20
21
22
 
 
...
14
15
16
 
17
18
19
20
21
 
 
22
23
24
0
@@ -14,8 +14,10 @@ config.action_controller.perform_caching = false
0
 config.action_view.cache_template_extensions = false
0
 config.action_view.debug_rjs = true
0
 
0
-# Don't care if the mailer can't send
0
+# ActionMailer::Base.default_url_options[:protocol] = 'https'
0
+ActionMailer::Base.default_url_options[:host] =
0
+ YAML.load_file(File.join(RAILS_ROOT, "config/gitorious.yml"))["gitorious_host"]
0
 config.action_mailer.raise_delivery_errors = false
0
 config.action_mailer.delivery_method = :test
0
-ExceptionNotifier.exception_recipients = YAML.load_file(File.join(RAILS_ROOT,
0
- "config/gitorious.yml"))["exception_notification_emails"]
0
\ No newline at end of file
0
+ExceptionNotifier.exception_recipients = YAML.load_file(File.join(RAILS_ROOT,
0
+ "config/gitorious.yml"))["exception_notification_emails"]
...
23
24
25
 
 
 
26
27
28
29
 
30
31
32
33
 
 
 
34
35
...
23
24
25
26
27
28
29
30
 
 
31
32
 
 
 
33
34
35
36
37
0
@@ -23,12 +23,14 @@ config.action_controller.fragment_cache_store = :file_store, File.join(cache_dir
0
 # Enable serving of images, stylesheets, and javascripts from an asset server
0
 # config.action_controller.asset_host = "http://assets.example.com"
0
 
0
+# ActionMailer::Base.default_url_options[:protocol] = 'https'
0
+ActionMailer::Base.default_url_options[:host] =
0
+ YAML.load_file(File.join(RAILS_ROOT, "config/gitorious.yml"))["gitorious_host"]
0
 # Disable delivery errors, bad email addresses will be ignored
0
 # config.action_mailer.raise_delivery_errors = false
0
-
0
-ExceptionNotifier.exception_recipients = YAML.load_file(File.join(RAILS_ROOT,
0
+ExceptionNotifier.exception_recipients = YAML.load_file(File.join(RAILS_ROOT,
0
   "config/gitorious.yml"))["exception_notification_emails"]
0
-ExceptionNotifier.class_eval do
0
- remove_method :template_root
0
- ExceptionNotifier.template_root = "#{RAILS_ROOT}/vendor/plugins/exception_notification/lib/../views"
0
+ExceptionNotifier.class_eval do
0
+ remove_method :template_root
0
+ ExceptionNotifier.template_root = "#{RAILS_ROOT}/vendor/plugins/exception_notification/lib/../views"
0
 end
0
\ No newline at end of file
...
16
17
18
 
 
 
19
20
21
...
16
17
18
19
20
21
22
23
24
0
@@ -16,6 +16,9 @@ config.action_controller.perform_caching = false
0
 # Disable request forgery protection in test environment
0
 config.action_controller.allow_forgery_protection = false
0
 
0
+# ActionMailer::Base.default_url_options[:protocol] = 'https'
0
+ActionMailer::Base.default_url_options[:host] =
0
+ YAML.load_file(File.join(RAILS_ROOT, "config/gitorious.yml"))["gitorious_host"]
0
 # Tell ActionMailer not to deliver emails to the real world.
0
 # The :test delivery method accumulates sent emails in the
0
 # ActionMailer::Base.deliveries array.
...
1
2
3
 
 
4
5
6
7
 
8
9
 
10
11
 
12
13
14
15
16
 
 
17
18
19
20
 
21
22
23
 
24
25
 
26
27
28
29
30
 
 
31
32
33
34
 
35
36
37
38
 
39
40
41
42
 
43
44
45
46
 
47
48
 
49
50
 
51
52
53
54
55
56
 
 
57
58
59
...
1
2
3
4
5
6
7
8
 
9
10
11
12
13
 
14
15
16
17
 
 
18
19
20
21
22
 
23
24
25
26
27
28
 
29
30
31
 
32
 
33
34
35
36
37
 
38
39
40
41
 
42
43
44
45
 
46
47
48
49
 
50
51
52
53
54
 
55
56
57
58
59
60
 
61
62
63
64
65
0
@@ -1,59 +1,65 @@
0
 require File.dirname(__FILE__) + '/../spec_helper'
0
 
0
 describe Mailer do
0
+ URL_BASE = "#{Mailer.default_url_options[:protocol]||'http'}://#{Mailer.default_url_options[:host]}"
0
+
0
   before(:each) do
0
     Mailer.deliveries = []
0
   end
0
-
0
+
0
   it "send new_repository_clone" do
0
     repos = repositories(:johans2)
0
+ url = "#{URL_BASE}/projects/#{repos.project.slug}/repos/#{repos.name}"
0
     mail = Mailer.create_new_repository_clone(repos)
0
-
0
+
0
     mail.to.should == [repos.project.user.email]
0
     mail.subject.should == %Q{[Gitorious] #{repos.user.login} has cloned #{repos.project.slug}/#{repos.parent.name}}
0
     mail.body.should match(/#{repos.user.login} recently created a clone/)
0
- mail.body.should match(/\/p\/#{repos.project.slug}\/repos\/#{repos.name}/)
0
-
0
+ mail.body.should include(url)
0
+
0
     Mailer.deliver(mail)
0
     Mailer.deliveries.should == [mail]
0
   end
0
-
0
+
0
   it "sends signup_notification" do
0
     user = users(:johan)
0
     user.password = "fubar"
0
+ url = "#{URL_BASE}/users/activate/#{user.activation_code}"
0
     mail = Mailer.create_signup_notification(user)
0
-
0
+
0
     mail.to.should == [user.email]
0
     mail.subject.should == "[Gitorious] Please activate your new account"
0
- mail.body.should match(/users\/activate\/#{user.activation_code}/)
0
     mail.body.should match(/username is #{user.login}$/)
0
-
0
+ mail.body.should include(url)
0
+
0
     Mailer.deliver(mail)
0
     Mailer.deliveries.should == [mail]
0
   end
0
-
0
+
0
   it "sends activation" do
0
     user = users(:johan)
0
     mail = Mailer.create_activation(user)
0
-
0
+
0
     mail.to.should == [user.email]
0
     mail.subject.should == "[Gitorious] Your account has been activated!"
0
     mail.body.should match(/your account has been activated/)
0
-
0
+
0
     Mailer.deliver(mail)
0
     Mailer.deliveries.should == [mail]
0
   end
0
-
0
+
0
   it "sends merge_request_notification" do
0
     merge_request = merge_requests(:moes_to_johans)
0
+ url = "#{URL_BASE}/projects/#{merge_request.target_repository.project.slug}/repos/#{merge_request.target_repository.name}/merge_requests/#{merge_request.id}"
0
     mail = Mailer.create_merge_request_notification(merge_request)
0
-
0
+
0
     mail.to.should == [merge_request.target_repository.user.email]
0
     mail.subject.should == "[Gitorious] moe has requested a merge in johans project"
0
     mail.body.should match(/moe has requested that you merge #{merge_request.source_repository.name} with #{merge_request.target_repository.name}/)
0
     mail.body.should match(/in the #{merge_request.target_repository.project.title} project/)
0
     mail.body.should include(merge_request.proposal)
0
-
0
+ mail.body.should include(url)
0
+
0
     Mailer.deliver(mail)
0
     Mailer.deliveries.should == [mail]
0
   end

Comments

    No one has commented yet.