Skip to content

Instantly share code, notes, and snippets.

@egoholic
Created April 23, 2014 11:25
Show Gist options
  • Save egoholic/11211511 to your computer and use it in GitHub Desktop.
Save egoholic/11211511 to your computer and use it in GitHub Desktop.
# 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