-
Notifications
You must be signed in to change notification settings - Fork 13
/
email_template_spec.rb
42 lines (35 loc) · 1.54 KB
/
email_template_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# == Schema Information
#
# Table name: email_templates
#
# id :integer not null, primary key
# status :integer(enum) not null
# hide_recipients :boolean not null
# subject :string not null
# content :string not null
#
require 'rails_helper'
describe EmailTemplate do
it "can be created by email_template factory" do
expect(FactoryGirl.build(:email_template)).to be_valid
end
it "can not be created without manditory fields" do
expect(FactoryGirl.build(:email_template, subject: '', content:'')).to_not be_valid
end
it "accepts valid status values" do
expect(FactoryGirl.build(:email_template, :acceptance)).to be_valid
expect(FactoryGirl.build(:email_template, :rejection)).to be_valid
expect(FactoryGirl.build(:email_template, :default)).to be_valid
end
it "rejects invalid status values" do
expect { FactoryGirl.build(:email_template, status: :fubar) }.to raise_error(ArgumentError)
expect { FactoryGirl.build(:email_template, status: 'fubar') }.to raise_error(ArgumentError)
expect { FactoryGirl.build(:email_template, status: 42) }.to raise_error(ArgumentError)
end
it "returns correct templates by status" do
@accepted_template = FactoryGirl.create(:email_template, :acceptance)
@rejected_template = FactoryGirl.create(:email_template, :rejection)
expect(EmailTemplate.with_status(:acceptance)).to eq([@accepted_template])
expect(EmailTemplate.with_status(:rejection)).to eq([@rejected_template])
end
end