mailboxer_multi_attach 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/app/models/messageable.rb +25 -9
- data/lib/mailboxer_multi_attach/version.rb +1 -1
- data/spec/dummy/app/views/mailboxer/message_mailer/reply_message_email.html.erb +1 -1
- data/spec/dummy/app/views/mailboxer/message_mailer/reply_message_email.text.erb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +23177 -0
- data/spec/integration/message_and_attachment_spec.rb +59 -26
- data/spec/models/messageable_spec.rb +5 -0
- metadata +2 -2
@@ -1,34 +1,67 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Attaching a message" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
4
|
+
describe ".send_message_mult_attach" do
|
5
|
+
let(:entity1) { FactoryGirl.create(:user) }
|
6
|
+
let(:entity2) { FactoryGirl.create(:user) }
|
7
|
+
let(:attachments) { [{ :file => File.open('spec/testfile.txt') }, { :file => File.open('spec/1.mp4') }] }
|
8
|
+
let!(:receipt_from_sent_message) { entity1.send_message_mult_attach(entity2, "Body", "Subject", true, attachments) }
|
9
|
+
let!(:message) { receipt_from_sent_message.message }
|
10
|
+
it "attaches a file" do
|
11
|
+
expect(message.message_attachments.first.file.file.filename).to eq "testfile.txt"
|
12
|
+
end
|
13
|
+
it "stores the content type of a plain text file" do
|
14
|
+
expect(message.message_attachments.first.file.content_type).to eq 'text/plain'
|
15
|
+
end
|
16
|
+
it "stores the content type of a video file" do
|
17
|
+
expect(message.message_attachments.second.file.content_type).to eq 'application/mp4'
|
18
|
+
end
|
19
|
+
it "attaches two files" do
|
20
|
+
expect(message.message_attachments.count).to eq 2
|
21
|
+
end
|
22
|
+
it "returns the filename after the upload" do
|
23
|
+
expect(message.message_attachments.first.file.file.filename).to eq 'testfile.txt'
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
context "without an attachment" do
|
27
|
+
subject { entity1.send_message_mult_attach(entity2, "Body", "Subject", true) }
|
28
|
+
it "sends a message successfully" do
|
29
|
+
expect(subject.class).to eq Mailboxer::Receipt
|
30
|
+
end
|
31
|
+
it "has no message attachments" do
|
32
|
+
expect(subject.message.message_attachments).to eq([])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
describe ".reply_to_sender_mult_attach" do
|
37
|
+
let(:entity1) { FactoryGirl.create(:user) }
|
38
|
+
let(:entity2) { FactoryGirl.create(:user) }
|
39
|
+
let(:attachments) { [{ :file => File.open('spec/testfile.txt') }, { :file => File.open('spec/1.mp4') }] }
|
40
|
+
let!(:receipt) { entity1.send_message_mult_attach(entity2, "Body", "Subject", true, attachments)}
|
41
|
+
let!(:receipt_from_reply) { entity1.reply_to_sender_mult_attach(receipt, "Body", "Subject", true, attachments) }
|
42
|
+
let!(:message) { receipt_from_reply.message }
|
43
|
+
it "attaches a file" do
|
44
|
+
expect(message.message_attachments.first.file.file.filename).to eq "testfile.txt"
|
45
|
+
end
|
46
|
+
it "stores the content type of a plain text file" do
|
47
|
+
expect(message.message_attachments.first.file.content_type).to eq 'text/plain'
|
29
48
|
end
|
30
|
-
it "
|
31
|
-
expect(
|
49
|
+
it "stores the content type of a video file" do
|
50
|
+
expect(message.message_attachments.second.file.content_type).to eq 'application/mp4'
|
51
|
+
end
|
52
|
+
it "attaches two files" do
|
53
|
+
expect(message.message_attachments.count).to eq 2
|
54
|
+
end
|
55
|
+
it "returns the filename after the upload" do
|
56
|
+
expect(message.message_attachments.first.file.file.filename).to eq 'testfile.txt'
|
57
|
+
end
|
58
|
+
|
59
|
+
context "without an attachment" do
|
60
|
+
subject { entity1.reply_to_sender_mult_attach(receipt, "Body", "Subject", true) }
|
61
|
+
it "has no message attachments" do
|
62
|
+
receipt = subject
|
63
|
+
expect(receipt.message.message_attachments).to eq([])
|
64
|
+
end
|
32
65
|
end
|
33
66
|
end
|
34
67
|
end
|
@@ -10,4 +10,9 @@ describe Mailboxer::Models::Messageable do
|
|
10
10
|
expect(entity1).to respond_to(:send_message_mult_attach)
|
11
11
|
end
|
12
12
|
end
|
13
|
+
describe "#reply_to_sender_mult_attach" do
|
14
|
+
it "should respond" do
|
15
|
+
expect(entity1).to respond_to(:reply_to_sender_mult_attach)
|
16
|
+
end
|
17
|
+
end
|
13
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailboxer_multi_attach
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommy Rodriguez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|