Last active
December 14, 2015 14:48
-
-
Save rodrigoulisses/5102683 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
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