forked from hpyhacking/peatio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathticket_spec.rb
53 lines (44 loc) · 1.35 KB
/
ticket_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
43
44
45
46
47
48
49
50
51
52
53
require 'spec_helper'
describe Ticket do
describe "Validation" do
context "Both title and content is empty" do
subject { Ticket.new }
it { should_not be_valid }
end
context "Title is empty" do
subject { Ticket.new(content: 'xman is here') }
it { should be_valid }
end
context "Content is empty" do
subject { Ticket.new(title: 'xman is here') }
it { should be_valid }
end
end
describe "#title_for_display" do
let(:text) { 'alsadkjf aslkdjf aslkdjfla skdjf alsdkjf dlsakjf lasdkjf sadkfasdf xx' }
context "title is present" do
let(:ticket) { create(:ticket, title: text)}
subject{ ticket }
its(:title_for_display) { should == "alsadkjf aslkdjf aslkdjfla skdjf alsdkjf dlsakjf lasdkjf ..." }
end
context "title is blank" do
let(:ticket) { create(:ticket, content: text) }
subject{ ticket }
its(:title_for_display) { should == "alsadkjf aslkdjf aslkdjfla skdjf alsdkjf dlsakjf lasdkjf ..." }
end
end
describe "#send_notification" do
let(:ticket) { create(:ticket) }
let(:mailer) { mock() }
before do
mailer.stubs(:deliver)
ticket
end
after do
ticket.send(:send_notification)
end
it "should notify the admin" do
TicketMailer.expects(:admin_notification).with(ticket.id).returns(mailer)
end
end
end