Skip to content

Instantly share code, notes, and snippets.

@scambra
Last active December 15, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scambra/5173686 to your computer and use it in GitHub Desktop.
Save scambra/5173686 to your computer and use it in GitHub Desktop.
TestingInvitable::Application.routes.draw do
root :to => "home#index"
devise_for :users, :controllers => {:invitations => 'user_invitations'}
devise_scope :user do
get "sign_out", :to => "devise/sessions#destroy"
end
end
require 'spec_helper'
describe UserInvitationsController do
let(:user) { User.new }
let(:job) { Job.new }
before :each do
@request.env["devise.mapping"] = Devise.mappings[:user]
@user = User.new(:email=>'sergio@enpijama.es', :password=>'11112222', :password_confirmation=>'11112222')
sign_in @user
UserInvitationsController.any_instance.should_receive(:current_user).at_least(1).and_return user
@user_params = HashWithIndifferentAccess.new({ "email" => "joe@blow.com" })
UserInvitationsController.any_instance.stub(:resource_params).and_return @user_params
@user_email_mock = User.should_receive(:find_by_email).with(@user_params[:email])
@user_params.should_receive(:[]=).with(:can_create,false)
@job_params = HashWithIndifferentAccess.new({"organizable_type" => "Company", "organizable_id" => 99 })
Job.should_receive(:new).and_return job # .with(@job_params)
end
it "should let you invite users to join your company" do
post :create, {:user => @user_params, :job => @job_params}, :format => :json
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment