Skip to content

Instantly share code, notes, and snippets.

@rodrigoulisses
Last active December 14, 2015 14:48
Show Gist options
  • Save rodrigoulisses/5102683 to your computer and use it in GitHub Desktop.
Save rodrigoulisses/5102683 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe PeopleController do
before do
controller.stub(:authenticate_user!)
controller.stub(:authorize_resource!)
end
describe "PUT 'update'" do
let :person do
Person.make!(:nohup)
end
it 'destroy personable_was when personable is changed' do
company = person.personable
company.update_column(:cnpj, nil)
individual = Individual.make(:sobrinho)
identity = Identity.make(:sobrinho, :individual => nil)
attributes = individual.attributes.except('created_at', 'updated_at')
attributes.merge!({ :identity_attributes => identity.attributes.except('created_at', 'updated_at') })
expect do
put :update, :id => person.id, :person => { :personable_type => "Individual",
:personable_attributes => attributes }
end.to change(Company, :count).by(-1)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment