38 lines
925 B
Ruby
38 lines
925 B
Ruby
require 'spec_helper'
|
|
describe ResharesController do
|
|
|
|
describe '#create' do
|
|
|
|
it 'requires authentication' do
|
|
post :create, :format => :js
|
|
response.should_not be_success
|
|
end
|
|
|
|
context 'with an authenticated user' do
|
|
|
|
before do
|
|
|
|
sign_in :user, bob
|
|
@post_id = Factory(:status_message, :public => true).id
|
|
@controller.stub(:current_user).and_return(bob)
|
|
end
|
|
|
|
it 'succeeds' do
|
|
post :create, :format => :js, :root_id => @post_id
|
|
puts response.code
|
|
response.should be_success
|
|
end
|
|
|
|
it 'creates a reshare' do
|
|
expect{
|
|
post :create, :format => :js, :root_id => @post_id
|
|
}.should change(Reshare, :count).by(1)
|
|
end
|
|
|
|
it 'after save, calls add to streams' do
|
|
bob.should_receive(:add_to_streams)
|
|
post :create, :format => :js, :root_id => @post_id
|
|
end
|
|
end
|
|
end
|
|
end
|