mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
Added feature test for mailer #2369
This commit is contained in:
parent
032cff3cf3
commit
d11aee7e95
5 changed files with 52 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
47
spec/features/admin/mail_templates_spec.rb
Normal file
47
spec/features/admin/mail_templates_spec.rb
Normal file
|
@ -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 <h1>Test</h1>'
|
||||
fill_in 'mail_template_text_body', with: 'Liquid static test'
|
||||
click_button 'Save'
|
||||
|
||||
page.should have_content('Testing email template')
|
||||
page.should have_content('Test subject')
|
||||
page.should have_content('example@example.com')
|
||||
page.should have_content('Liquid Test')
|
||||
page.should have_content('Liquid static test')
|
||||
|
||||
click_link 'Email Templates'
|
||||
page.should have_content('Mail Templates')
|
||||
page.should have_content('Test subject')
|
||||
|
||||
click_link 'Testing email template'
|
||||
page.should have_content('Testing email template')
|
||||
|
||||
click_link 'Edit'
|
||||
page.should have_content('Edit: Testing email template')
|
||||
fill_in 'Subject', with: 'New edited test subject'
|
||||
click_button 'Save'
|
||||
|
||||
page.should have_content 'New edited test subject'
|
||||
click_link 'Delete'
|
||||
|
||||
page.should have_content 'Mail Templates'
|
||||
page.should_not have_content 'New edited test subject'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue