Sha256: 38bc8ca88de115c82fa8988fee5f1895eda0f7d6c107a6e32836b4a84abc372b

Contents?: true

Size: 1.76 KB

Versions: 16

Compression:

Stored size: 1.76 KB

Contents

share_as :Mappings do
  
  context "mappings" do
    before(:each) do
      @class.acts_as_icontact :list => 444444, :surname => :lastName
    end
    
    it "uses any non-option keys as field mappings" do
      @class.icontact_mappings[:surname].should == :lastName
    end
    
    it "does not map option keys" do
      @class.icontact_mappings.should_not have_key(:list)
    end
    
    it "maps fields it can find from the default list" do
      @class.icontact_mappings[:firstName].should == :firstName
    end
    
    it "maps second choices when it can find them" do
      @class.icontact_mappings[:zip].should == :postalCode
    end
    
    it "maps the icontact_ exception names" do
      @class.icontact_mappings[:icontactCreated].should == :createDate
    end
    
    it "does not map the default form of exception names" do
      @class.icontact_mappings.should_not have_key(:status)
    end
    
    it "maps icontact_status" do
      @class.icontact_mappings[:icontact_status].should == :status
    end
    
    it "maps the address field" do
      @class.icontact_mappings[:address].should == :street
    end
    
    it "maps custom fields" do
      @class.icontact_mappings[:custom_field].should == :custom_field
    end
  end
  
  context "identity mapping" do
    it "looks for contactId first" do
      @class.acts_as_icontact
      @class.icontact_identity_map.should == [:icontact_id, :contactId]
    end
    
    it "looks for a Rails ID custom field second" do
      @class.acts_as_icontact :icontact_id => nil, :id => :test_field
      @class.icontact_identity_map.should == [:id, :test_field]
    end
    
    it "uses email as last resort" do
      @class.acts_as_icontact :icontact_id => nil
      @class.icontact_identity_map.should == [:email, :email]
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
SFEley-acts_as_icontact-0.2.1 spec/rails_spec/mappings_spec.rb
SFEley-acts_as_icontact-0.2.3 spec/rails_spec/mappings_spec.rb
SFEley-acts_as_icontact-0.2.4 spec/rails_spec/mappings_spec.rb
SFEley-acts_as_icontact-0.3.0 spec/rails_spec/mappings_spec.rb
SFEley-acts_as_icontact-0.3.2 spec/rails_spec/mappings_spec.rb
SFEley-acts_as_icontact-0.4.0 spec/rails_spec/mappings_spec.rb
SFEley-acts_as_icontact-0.4.2 spec/rails_spec/mappings_spec.rb
SFEley-acts_as_icontact-0.4.3 spec/rails_spec/mappings_spec.rb
acts_as_icontact-0.4.3 spec/rails_spec/mappings_spec.rb
acts_as_icontact-0.4.2 spec/rails_spec/mappings_spec.rb
acts_as_icontact-0.4.0 spec/rails_spec/mappings_spec.rb
acts_as_icontact-0.3.2 spec/rails_spec/mappings_spec.rb
acts_as_icontact-0.2.1 spec/rails_spec/mappings_spec.rb
acts_as_icontact-0.2.3 spec/rails_spec/mappings_spec.rb
acts_as_icontact-0.2.4 spec/rails_spec/mappings_spec.rb
acts_as_icontact-0.3.0 spec/rails_spec/mappings_spec.rb