Sha256: 5bc697355018ccd246b33a35f7f559806b5c71a37b226ac6c3f3fe7087524332
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
require 'spec_helper' describe Contact do before do @contact = Contact.new( name: 'Teste Contact 1', birthday: 35.years.ago, customer: Factory(:customer), department: Factory(:business_department)) end subject { @contact } it { should respond_to :name } it { should respond_to :birthday } it { should respond_to :phone } it { should respond_to :customer } it { should respond_to :emails } it { should respond_to :department } it { should respond_to :department_id } it { should be_valid } describe "require name" do before do @contact.name = "" end it { should be_invalid } end describe "require customer" do before do @contact.customer = nil end it { should be_invalid } end describe "emails associations" do let!(:email) { FactoryGirl.create(:email, emailable: @contact) } let!(:email_private) { FactoryGirl.create(:email, emailable: @contact, private: true) } it { @contact.emails.should == [email, email_private] } end describe "department" do before { @contact.department = BusinessDepartment.last } its(:department) { should == (BusinessDepartment.last) } its(:department_id) { should == (BusinessDepartment.last.id) } end describe "search" do before do @contact.save @contacts = Contact.search_by_params @contact.customer.contacts, department_id: nil end it { @contact.customer.contacts include(@contact) } it { @contacts.should include(@contact) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
guara-0.0.3 | spec/models/contact_spec.rb |
guara-0.0.1.rc | spec/models/contact_spec.rb |