Stub ::Devise.mailer for great justice. And/or fewer strange arity errors.
This commit is contained in:
parent
adbc4dddbc
commit
007b06c8ea
1 changed files with 18 additions and 8 deletions
|
|
@ -13,17 +13,27 @@ describe User do
|
|||
let(:invited_user3) { create_user_with_invitation("abc", :email => "email@example.com", :inviter => inviter_with_3_invites)}
|
||||
|
||||
context "creating invites" do
|
||||
it 'should invite the user' do
|
||||
pending "weird wrong number of arguments error (0 for 2), which changes if you put in two args"
|
||||
#User.should_receive(:invite!).and_return(invited_user)
|
||||
inviter.invite_user(:email => "email@example.com")
|
||||
before do
|
||||
deliverable = Object.new
|
||||
deliverable.stub!(:deliver)
|
||||
::Devise.mailer.stub!(:invitation).and_return(deliverable)
|
||||
end
|
||||
|
||||
it 'should add the inviter to the invited_user' do
|
||||
User.should_receive(:invite!).and_return(invited_user)
|
||||
invited_user = inviter.invite_user(:email => "email@example.com")
|
||||
it 'creates a user' do
|
||||
lambda {
|
||||
inviter.invite_user(:email => "joe@example.com")
|
||||
}.should change(User, :count).by(1)
|
||||
end
|
||||
|
||||
it 'sends email to the invited user' do
|
||||
::Devise.mailer.should_receive(:invitation).once
|
||||
inviter.invite_user(:email => "ian@example.com")
|
||||
end
|
||||
|
||||
it 'adds the inviter to the invited_user' do
|
||||
invited_user = inviter.invite_user(:email => "marcy@example.com")
|
||||
invited_user.reload
|
||||
invited_user.inviters.include?(inviter).should be true
|
||||
invited_user.inviters.include?(inviter).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue