Sha256: 6b512da8278288abba1107fb6a148fc27c5bf00f364bbff2ff8ed8b8e3823f58
Contents?: true
Size: 1.58 KB
Versions: 17
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' describe Effective::EmailTemplate do before :each do @email = create(:email_template) end describe 'slug' do it 'can have numbers in the slug' do email = build(:email_template, slug: 'reminder_30_days') expect(email).to be_valid end it 'cannot have spaces in the slug' do email = build(:email_template, slug: 'reminder 30 days') expect(email).to_not be_valid end end it 'should be persisted' do expect(@email.persisted?).to be(true) end it 'can be valid without a template explicitly stored' do email = build(:email_template, template: nil) expect(email).to be_valid end it 'stores a template after precompiling' do email = build(:email_template) # The initial template is an empty liquid template provided by the ::serialize method expect(email.template.render).to be_blank email.precompile expect(email.template.render).not_to be_blank end it 'stores a precompiled template' do expect(@email.template).to be_a(Liquid::Template) end it 'knows how to render itself' do expect(@email.render).to be_a(String) end it 'does not precompile if the body has not changed' do @email.from = 'other@example.com' expect(Liquid::Template).to_not receive(:parse).with(@email.body) @email.save end it 'does precompile if the body has changed' do @email.body = 'Hello World -- changed' parsed_template = Liquid::Template.parse(@email.body) expect(Liquid::Template).to receive(:parse).with(@email.body).and_return(parsed_template) @email.save end end
Version data entries
17 entries across 17 versions & 1 rubygems