Sha256: 3b8d8fb19bbd3fc4d51178e10b3ea4ac4b35f1b6e80d9f66e093738fcbd75b8f

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe "Attaching a message" do
  let(:entity1) { FactoryGirl.create(:user) }
  let(:entity2) { FactoryGirl.create(:user) }
  let(:attachments) { [{ :file => File.open('spec/testfile.txt') }, { :file => File.open('spec/1.mp4') }] }
  let!(:receipt1) { entity1.send_message_mult_attach(entity2, "Body", "Subject", true, attachments) }
  let!(:message1) { receipt1.notification }
  it "attaches a file" do
    expect(message1.message_attachments.first.file.filename).to eq "testfile.txt"
  end
  it "stores the content type of a plain text file" do
    expect(message1.message_attachments.first.file.content_type).to eq 'text/plain'
  end
  it "stores the content type of a video file" do
    expect(message1.message_attachments.second.file.content_type).to eq 'application/mp4'
  end
  it "attaches two files" do
    expect(message1.message_attachments.count).to eq 2
  end
  it "returns the filename after the upload" do
    expect(message1.message_attachments.first.file.filename).to eq 'testfile.txt'
  end

  context "without an attachment" do
    subject { entity1.send_message_mult_attach(entity2, "Body", "Subject", true) }
    it "sends a message successfully" do
      expect(subject.class).to eq Mailboxer::Receipt
    end
    it "has no message attachments" do
      expect(subject.message.message_attachments).to eq([])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mailboxer_multi_attach-0.0.3 spec/integration/message_and_attachment_spec.rb
mailboxer_multi_attach-0.0.2 spec/integration/message_and_attachment_spec.rb