AutoCommit Die Sep 8 14:03:06 CEST 2015
This commit is contained in:
@@ -9,7 +9,7 @@ class NewsMailer < ActionMailer::Base
|
|||||||
@user=User.first
|
@user=User.first
|
||||||
@ability=Ability.new(@user)
|
@ability=Ability.new(@user)
|
||||||
subject = @neuigkeit.title
|
subject = @neuigkeit.title
|
||||||
subject = subject + " email: " + email if Rails.env=="development"
|
subject = subject.to_s + " email: " + email.to_s if Rails.env=="development"
|
||||||
email = "andis@fet.at" if Rails.env=="development"
|
email = "andis@fet.at" if Rails.env=="development"
|
||||||
email="andis@fet.at"
|
email="andis@fet.at"
|
||||||
mail(to: email, subject: subject)
|
mail(to: email, subject: subject)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<h1>
|
<h1>
|
||||||
<%= @neuigkeit.title%>
|
<%= @neuigkeit.title%>
|
||||||
</h1>
|
</h1>
|
||||||
<%= content_tag(:img,"",src: "http://"+ActionMailer::Base.default_url_options[:host].to_s+@neuigkeit.picture.big_thumb.url) %>
|
<%= content_tag(:img,"",src: "http://"+ActionMailer::Base.default_url_options[:host].to_s+@neuigkeit.picture.big_thumb.url.to_s) %>
|
||||||
<%=url_for controller: "neuigkeiten",action: :show, :id=>@neuigkeit.id, only_path: false %>
|
<%=url_for controller: "neuigkeiten",action: :show, :id=>@neuigkeit.id, only_path: false %>
|
||||||
<%= raw(@neuigkeit.text) %>
|
<%= raw(@neuigkeit.text) %>
|
||||||
<% @neuigkeit.questions.each do |q| %>
|
<% @neuigkeit.questions.each do |q| %>
|
||||||
|
|||||||
7
spec/factories/neuigkeit.rb
Normal file
7
spec/factories/neuigkeit.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
FactoryGirl.define do
|
||||||
|
factory :neuigkeit do
|
||||||
|
title "WIChtige Neuigkeit"
|
||||||
|
text "<p> Das ist eine wichtige Information </p>"
|
||||||
|
datum 1.days.ago
|
||||||
|
end
|
||||||
|
end
|
||||||
6
spec/factories/rubrik.rb
Normal file
6
spec/factories/rubrik.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FactoryGirl.define do
|
||||||
|
factory :rubrik do
|
||||||
|
name "Allgemeine"
|
||||||
|
desc "Allgemeine Test News"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,33 @@
|
|||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
|
||||||
describe NewsMailer do
|
describe NewsMailer do
|
||||||
|
include Rails.application.routes.url_helpers
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
describe 'neuigkeit_mail' do
|
||||||
|
before(:each) do
|
||||||
|
|
||||||
|
rubrik = FactoryGirl.create(:rubrik)
|
||||||
|
@neuigkeit=FactoryGirl.create(:neuigkeit, author_id: user.id, rubrik_id: rubrik.id)
|
||||||
|
NewsMailer.stub(:default_url_options).and_return({host:"localhost", port: 3000})
|
||||||
|
end
|
||||||
|
let(:user) {User.first || FactoryGirl.create(:user)}
|
||||||
|
let(:email) {"test@mail.com"}
|
||||||
|
let(:neuigkeit) {@neuigkeit}
|
||||||
|
|
||||||
|
let(:mail) {NewsMailer.neuigkeit_mail(email.to_s, neuigkeit.id)}
|
||||||
|
it "renders neuigkeit title" do
|
||||||
|
expect(mail.body.to_s).to match(/#{@neuigkeit.title}/)
|
||||||
|
end
|
||||||
|
it "renders neuigkeit expect" do
|
||||||
|
expect(mail.body.to_s).to match(/#{@neuigkeit.text}/)
|
||||||
|
end
|
||||||
|
it "is sent to current user" do
|
||||||
|
expect(mail.to).to eq([user.email])
|
||||||
|
end
|
||||||
|
it "links to web page" do
|
||||||
|
expect(mail.body.to_s).to match(/#{neuigkeit_url(@neuigkeit, locale: nil, theme: nil, host:"localhost", port: 3000)}/)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user