Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }

load 'config/deploy' # remove this line to skip loading any of the default tasks
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
source 'http://rubygems.org'

gem 'rails', '3.0.6'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'sqlite3'
gem 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
gem 'will_paginate', '3.0.pre2'
gem 'devise', '1.1.rc0'
gem 'dynamic_form'
gem 'capistrano'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
Expand Down
21 changes: 18 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,33 @@ GEM
activesupport (3.0.6)
arel (2.0.10)
builder (2.1.2)
capistrano (2.6.0)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
cocaine (0.0.2)
devise (1.1.rc0)
warden (~> 0.10.3)
dynamic_form (1.1.4)
erubis (2.6.6)
abstract (>= 1.0.0)
highline (1.6.2)
i18n (0.5.0)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.1.4)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
polyglot (0.3.1)
rack (1.2.3)
rack-mount (0.6.14)
Expand All @@ -73,8 +87,7 @@ GEM
thor (~> 0.14.4)
rake (0.8.7)
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
sqlite3 (1.3.3-x86-mingw32)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
Expand All @@ -85,11 +98,13 @@ GEM

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
capistrano
devise (= 1.1.rc0)
dynamic_form
paperclip!
rails (= 3.0.6)
sqlite3-ruby
sqlite3
will_paginate (= 3.0.pre2)
33 changes: 33 additions & 0 deletions app/mailers/emailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class Emailer < ActionMailer::Base
default :from => "[email protected]"

def thx_for_register_email(person)
@person = person
mail(:to => person.email, :subject => "Thx for regestering on Photosharing")
end

def activate_person_email()
mail(:to => "[email protected]", :subject => "New User")
end

def welcome_email(person)
@person = person
@url = "http://photosharing.com/login"
mail(:to => person.email, :subject => "Welcome to the Photosharing")
end

def complain_email(url, reason, person)
@url = url
@reason = reason
@person = person
mail(:to => "[email protected]", :subject => "Complainment")
end

def ban_email(person, reason, days)
@person = person
@reason = reason
@days = days
mail(:to => person.mail, :subject => "You have been banned")
end

end
13 changes: 13 additions & 0 deletions app/views/emailer/activate_person_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>We have a new member to join us<h1>
<p>
Please log in to activate him.
</p>
<p>
</body>
</html>
15 changes: 15 additions & 0 deletions app/views/emailer/ban_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1><%= @person.username %>, you have been banned</h1>
<p>
The reason for this is because of:<%= @reason %>.<br/>
</p>
<p>
The ban is for <%= @days %>days.
</p>
</body>
</html>
15 changes: 15 additions & 0 deletions app/views/emailer/complain_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>Complainment!<h1>
<p>
<%= person.name %> has a complainment about: <%= @url %>.
</p>
<p>
The reason is: <%= @reason %>
</p>
</body>
</html>
13 changes: 13 additions & 0 deletions app/views/emailer/thx_for_register_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>Thank you for registering, <%= @person.username %>.</h1>
<p>
Our Admin will soon activate your account.<br/>
</p>
<p>Thanks for joining and have a great day!</p>
</body>
</html>
15 changes: 15 additions & 0 deletions app/views/emailer/welcome_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>Welcome to photosharing.com, <%= @person.username %></h1>
<p>
You have have been activated.<br/>
</p>
<p>
To login to the site, just follow this link: <%= @url %>.
</p>
</body>
</html>
40 changes: 40 additions & 0 deletions config/Kopie von deploy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'bundler/capistrano'

set :application, "Photosharing"

set :repository, "https://github.com/ahelmel/Photosharing.git"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

# role :web, "your web-server here" # Your HTTP server, Apache/etc
# role :app, "your app-server here" # This may be the same as your `Web` server
# role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
# role :db, "your slave db-server here"

server "10.28.19.108", :web, :app, :db, :primary => true

set :user, 'student'
set :use_sudo, true

set :deploy_to, '/home/student/todo'

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
# namespace :deploy do
# task :start do ; end
# task :stop do ; end
# task :restart, :roles => :app, :except => { :no_release => true } do
# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
# end
# end

namespace :customs do
task :symlink, :roles => :app do
run <<-CMD
ln -nfs #{shared_path}/images #{release_path}/public/images
CMD
end
end
after "deploy:update_code","customs:symlink"
41 changes: 41 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'bundler/capistrano'

set :application, "Photosharing"

set :repository, "https://github.com/ahelmel/Photosharing.git"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

# role :web, "your web-server here" # Your HTTP server, Apache/etc
# role :app, "your app-server here" # This may be the same as your `Web` server
# role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
# role :db, "your slave db-server here"

server "10.28.19.108", :web, :app, :db, :primary => true

set :user, 'student'
set :password, '$tuD3NtSS11'
set :use_sudo, true

set :deploy_to, '/home/student/todo'

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
# namespace :deploy do
# task :start do ; end
# task :stop do ; end
# task :restart, :roles => :app, :except => { :no_release => true } do
# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
# end
# end

namespace :customs do
task :symlink, :roles => :app do
run <<-CMD
ln -nfs #{shared_path}/images #{release_path}/public/images
CMD
end
end
after "deploy:update_code","customs:symlink"
12 changes: 12 additions & 0 deletions config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
# Initialize the rails application
Photosharing::Application.initialize!


ActionMailer::Base.delivery_method = :smtp

ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 25,
:domain => "photosharing.com",
:authentication => :login,
:user_name => "[email protected]",
:password => "hm11sweII",
}
#=======
# Initialize pagination
WillPaginate::ViewHelpers.pagination_options[:prev_label] = "< Zurück"
WillPaginate::ViewHelpers.pagination_options[:next_label] = "Vor >"
Expand Down
67 changes: 67 additions & 0 deletions test/functional/emailer_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
require 'test_helper'

class EmailerTest < ActionMailer::TestCase

test "Thx For Register Email Test" do
person = person(:some_user_in_your_fixtures)

# Send the email, then test that it got queued
email = Emailer.thx_for_register_email(person).deliver
assert !ActionMailer::Base.deliveries.empty?

# Test the body of the sent email contains what we expect it to
assert_equal [person.email], email.to
assert_equal "Thx for regestering on Photosharing", email.subject
assert_match /<h1>Thank you for registering, #{person.username}<\/h1>/, email.encoded
end

test "Activate Email Test" do
# Send the email, then test that it got queued
email = Emailer.activate_person_email().deliver
assert !ActionMailer::Base.deliveries.empty?

# Test the body of the sent email contains what we expect it to
assert_equal "[email protected]", email.to
assert_equal "New User", email.subject
assert_match /<h1>We have a new member to join us<\/h1>/, email.encoded
end


test "Welcome Email Test" do
person = person(:some_user_in_your_fixtures)

# Send the email, then test that it got queued
email = Emailer.welcome_email(person).deliver
assert !ActionMailer::Base.deliveries.empty?

# Test the body of the sent email contains what we expect it to
assert_equal [user.email], email.to
assert_equal "Welcome to the Photosharing", email.subject
assert_match /<h1>Welcome to photosharing.com, #{person.username}<\/h1>/, email.encoded
end

test "Complain Email Test" do
# Send the email, then test that it got queued
email = Emailer.complain_email( "http://photosharing.com/bild.jpg", "Because of").deliver
assert !ActionMailer::Base.deliveries.empty?

# Test the body of the sent email contains what we expect it to
assert_equal [email protected],email.to
assert_equal "Complainment", email.subject
assert_match /<h1>Complainment<\/h1>/, email.encoded
end

test "Ban Email Test" do
person = person(:some_user_in_your_fixtures)

# Send the email, then test that it got queued
email = Emailer.ban_email(person, "Because of", 4).deliver
assert !ActionMailer::Base.deliveries.empty?

# Test the body of the sent email contains what we expect it to
assert_equal [person.email], email.to
assert_equal "You have been banned", email.subject
assert_match /<h1>#{person.username}, you have been banned<\/h1>/, email.encoded
end

end