Last active
December 15, 2015 00:29
-
-
Save scambra/5173686 to your computer and use it in GitHub Desktop.
This file contains 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
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 |
This file contains 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
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=>'[email protected]', :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" => "[email protected]" }) | |
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