Skip to content

Instantly share code, notes, and snippets.

@manuelkiessling
Created May 20, 2011 08:40
Show Gist options
  • Save manuelkiessling/982566 to your computer and use it in GitHub Desktop.
Save manuelkiessling/982566 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe SharesController do
render_views
describe '#create' do
it "should redirect to Login if user is not logged in" do
post :create, :share => { :facebook_id => 'abc', :address_id => 7 }
response.should redirect_to login_path
end
it "should create a new Share if called correctly" do
user = login_user
share = Share.new(:user_id => user.id, :facebook_id => 'abc', :address_id => 7)
Share.should_receive(:new).once.with(:user_id => user.id, :facebook_id => 'abc', :address_id => 7).and_return(share)
share.should_receive(:save).once.and_return(true)
post :create, :format => :json, :share => { :facebook_id => 'abc', :address_id => 7 }
end
it "should respond with success if no error occured" do
user = login_user
share = Share.new(:user_id => user.id, :facebook_id => 'abc', :address_id => 7)
Share.should_receive(:new).once.with(:user_id => user.id, :facebook_id => 'abc', :address_id => 7).and_return(share)
share.should_receive(:save).once.and_return(true)
post :create, :format => :json, :share => { :facebook_id => 'abc', :address_id => 7 }
response.should be_success
end
end
end
@fronx
Copy link

fronx commented May 20, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment