Created
April 23, 2014 11:25
-
-
Save egoholic/11211511 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# code is not mine | |
require 'spec_helper' | |
describe Api::DocumentsController do | |
context '#share' do | |
let(:name) { SecureRandom.hex } | |
let(:box_model) { build(:box_model, name: name) } | |
let(:type) { Document::TYPES.sample } | |
let(:pxc_number) { SecureRandom.hex } | |
let(:comments) { SecureRandom.hex } | |
let(:emails) { [SecureRandom.hex] } | |
specify "users receives email" do | |
locale = 'en' | |
document = Document.new(box_model, type, locale) | |
allow(Document).to receive(:find).with(pxc_number, type, locale).and_return(document) | |
post :share, id: pxc_number, type: type, language: locale, emails: emails, comments: comments | |
expect(response).to be_success | |
mail = ActionMailer::Base.deliveries.last | |
expect(mail.to).to eq(emails) | |
expect(mail.subject).to include(name) | |
expect(mail.body).to include(comments) | |
expect(mail.body).to include(name) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment