mailboxer_multi_attach 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,67 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Attaching a message" do
4
- let(:entity1) { FactoryGirl.create(:user) }
5
- let(:entity2) { FactoryGirl.create(:user) }
6
- let(:attachments) { [{ :file => File.open('spec/testfile.txt') }, { :file => File.open('spec/1.mp4') }] }
7
- let!(:receipt1) { entity1.send_message_mult_attach(entity2, "Body", "Subject", true, attachments) }
8
- let!(:message1) { receipt1.notification }
9
- it "attaches a file" do
10
- expect(message1.message_attachments.first.file.filename).to eq "testfile.txt"
11
- end
12
- it "stores the content type of a plain text file" do
13
- expect(message1.message_attachments.first.file.content_type).to eq 'text/plain'
14
- end
15
- it "stores the content type of a video file" do
16
- expect(message1.message_attachments.second.file.content_type).to eq 'application/mp4'
17
- end
18
- it "attaches two files" do
19
- expect(message1.message_attachments.count).to eq 2
20
- end
21
- it "returns the filename after the upload" do
22
- expect(message1.message_attachments.first.file.filename).to eq 'testfile.txt'
23
- end
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
- context "without an attachment" do
26
- subject { entity1.send_message_mult_attach(entity2, "Body", "Subject", true) }
27
- it "sends a message successfully" do
28
- expect(subject.class).to eq Mailboxer::Receipt
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 "has no message attachments" do
31
- expect(subject.message.message_attachments).to eq([])
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.3
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-01 00:00:00.000000000 Z
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails