diff --git a/app/models/mail_template.rb b/app/models/mail_template.rb index ed0e78919..ee693a0a3 100644 --- a/app/models/mail_template.rb +++ b/app/models/mail_template.rb @@ -1,10 +1,3 @@ class MailTemplate < ActiveRecord::Base - validates :name, :subject, :from, :body, :text_body, presence: true - - def to_html(body) - template = Erubis::Eruby.new(content, escape: true) - template_result = template.result(context) - Sanitize.clean(RDiscount.new(template_result).to_html.encode('UTF-8', undef: :replace), Sanitize::Config::RELAXED) - end end diff --git a/db/migrate/20150825125118_create_email_templates.rb b/db/migrate/20150825125118_create_email_templates.rb index 60e374247..ab956f5ed 100644 --- a/db/migrate/20150825125118_create_email_templates.rb +++ b/db/migrate/20150825125118_create_email_templates.rb @@ -8,7 +8,7 @@ class CreateEmailTemplates < ActiveRecord::Migration t.string :cc t.text :body, null: false t.text :text_body, null: false - t.timestamps + t.timestamps null: false end end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 4839d519e..79739bb06 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -886,8 +886,8 @@ ActiveRecord::Schema.define(version: 20150825125118) do t.string "cc" t.text "body", null: false t.text "text_body", null: false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "messages", force: :cascade do |t| diff --git a/db/structure.sql b/db/structure.sql index 65b344c97..74cddb0e9 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2241,8 +2241,8 @@ CREATE TABLE mail_templates ( cc character varying, body text NOT NULL, text_body text NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -4926,7 +4926,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150803080914'); INSERT INTO schema_migrations (version) VALUES ('20150810114746'); -INSERT INTO schema_migrations (version) VALUES ('20150810114747'); - INSERT INTO schema_migrations (version) VALUES ('20150825125118'); diff --git a/spec/features/admin/mail_templates_spec.rb b/spec/features/admin/mail_templates_spec.rb new file mode 100644 index 000000000..c6dfdaaf6 --- /dev/null +++ b/spec/features/admin/mail_templates_spec.rb @@ -0,0 +1,47 @@ +require 'rails_helper' + +feature 'MailTemplate', type: :feature do + before :all do + @user = Fabricate(:admin_user) + end + + before do + sign_in @user + end + + it 'should add a bank statement and transactions manually' do + visit admin_mail_templates_url + + click_link 'New' + fill_in 'Name', with: 'Testing email template' + fill_in 'Subject', with: 'Test subject' + fill_in 'From', with: 'example@example.com' + fill_in 'mail_template_body', with: 'Liquid