go_import 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/go-import +96 -0
 - data/lib/go_import/csv_helper.rb +47 -0
 - data/lib/go_import/email_helper.rb +10 -0
 - data/lib/go_import/errors.rb +22 -0
 - data/lib/go_import/excel_helper.rb +10 -0
 - data/lib/go_import/global_phone.json +6571 -0
 - data/lib/go_import/model/address.rb +61 -0
 - data/lib/go_import/model/class_settings.rb +50 -0
 - data/lib/go_import/model/coworker.rb +76 -0
 - data/lib/go_import/model/coworker_reference.rb +33 -0
 - data/lib/go_import/model/customfield.rb +87 -0
 - data/lib/go_import/model/deal.rb +172 -0
 - data/lib/go_import/model/deal_class_settings.rb +73 -0
 - data/lib/go_import/model/deal_state.rb +15 -0
 - data/lib/go_import/model/deal_status.rb +23 -0
 - data/lib/go_import/model/deal_status_reference.rb +47 -0
 - data/lib/go_import/model/deal_status_setting.rb +49 -0
 - data/lib/go_import/model/documents.rb +51 -0
 - data/lib/go_import/model/link.rb +70 -0
 - data/lib/go_import/model/note.rb +97 -0
 - data/lib/go_import/model/note_classification.rb +25 -0
 - data/lib/go_import/model/organization.rb +219 -0
 - data/lib/go_import/model/person.rb +151 -0
 - data/lib/go_import/model/referencetosource.rb +46 -0
 - data/lib/go_import/model/relation.rb +23 -0
 - data/lib/go_import/model/rootmodel.rb +359 -0
 - data/lib/go_import/model/settings.rb +61 -0
 - data/lib/go_import/model/tag.rb +35 -0
 - data/lib/go_import/model_helpers.rb +54 -0
 - data/lib/go_import/phone_helper.rb +74 -0
 - data/lib/go_import/roo_helper.rb +80 -0
 - data/lib/go_import/serialize_helper.rb +186 -0
 - data/lib/go_import/source.rb +87 -0
 - data/lib/go_import/templating.rb +52 -0
 - data/lib/go_import.rb +19 -0
 - data/sources/csv/.gitignore +14 -0
 - data/sources/csv/.go_import/runner.rb +62 -0
 - data/sources/csv/Gemfile +5 -0
 - data/sources/csv/Rakefile.rb +7 -0
 - data/sources/csv/converter.rb +179 -0
 - data/sources/csv/data/coworkers.csv +2 -0
 - data/sources/csv/data/deals.csv +2 -0
 - data/sources/csv/data/organizations.csv +2 -0
 - data/sources/csv/data/persons.csv +2 -0
 - data/sources/csv/spec/exporter_spec.rb +17 -0
 - data/sources/csv/spec/sample_data/coworkers.csv +2 -0
 - data/sources/csv/spec/sample_data/deals.csv +2 -0
 - data/sources/csv/spec/sample_data/organizations.csv +2 -0
 - data/sources/csv/spec/sample_data/persons.csv +2 -0
 - data/sources/csv/spec/spec_helper.rb +30 -0
 - data/sources/easy/.gitignore +14 -0
 - data/sources/easy/.go_import/runner.rb +115 -0
 - data/sources/easy/Export/readme.txt +6 -0
 - data/sources/easy/Gemfile +5 -0
 - data/sources/easy/Rakefile.rb +7 -0
 - data/sources/easy/converter.rb +435 -0
 - data/sources/easy/spec/exporter_spec.rb +10 -0
 - data/sources/easy/spec/sample_data/Company.txt +649 -0
 - data/sources/easy/spec/spec_helper.rb +30 -0
 - data/sources/excel/.gitignore +14 -0
 - data/sources/excel/.go_import/runner.rb +116 -0
 - data/sources/excel/Gemfile +6 -0
 - data/sources/excel/Rakefile.rb +7 -0
 - data/sources/excel/converter.rb +130 -0
 - data/sources/excel/spec/sample_data/sample.xlsx +0 -0
 - data/sources/excel/spec/spec_helper.rb +26 -0
 - data/sources/excel/spec/tomodel_spec.rb +18 -0
 - data/sources/excel/template.xlsx +0 -0
 - data/spec/address_spec.rb +49 -0
 - data/spec/class_settings_spec.rb +37 -0
 - data/spec/coworker_spec.rb +94 -0
 - data/spec/custom_field_spec.rb +22 -0
 - data/spec/deal_class_settings_spec.rb +104 -0
 - data/spec/deal_spec.rb +182 -0
 - data/spec/deal_status_reference_spec.rb +17 -0
 - data/spec/documents_spec.rb +37 -0
 - data/spec/helpers/csv_helper_spec.rb +29 -0
 - data/spec/helpers/email_helper_spec.rb +32 -0
 - data/spec/helpers/phone_helper_spec.rb +97 -0
 - data/spec/helpers/roo_helper_spec.rb +10 -0
 - data/spec/helpers/serialize_helper_spec.rb +249 -0
 - data/spec/helpers/xsd_validate_spec.rb +55 -0
 - data/spec/link_spec.rb +106 -0
 - data/spec/note_spec.rb +110 -0
 - data/spec/organization_spec.rb +151 -0
 - data/spec/person_spec.rb +132 -0
 - data/spec/rootmodel_spec.rb +371 -0
 - data/spec/spec_helper.rb +30 -0
 - data/spec/templating_spec.rb +12 -0
 - metadata +306 -0
 
| 
         @@ -0,0 +1,371 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'go_import'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe "RootModel" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                let(:rootmodel) {
         
     | 
| 
      
 6 
     | 
    
         
            +
                    GoImport::RootModel.new
         
     | 
| 
      
 7 
     | 
    
         
            +
                }
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                it "will contain integration coworker by default" do
         
     | 
| 
      
 10 
     | 
    
         
            +
                    rootmodel.find_coworker_by_integration_id("import").first_name.should eq "Import"
         
     | 
| 
      
 11 
     | 
    
         
            +
                    rootmodel.coworkers.length.should eq 1
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                it "can add a coworker from a hash" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                    rootmodel.add_coworker({
         
     | 
| 
      
 16 
     | 
    
         
            +
                        :integration_id => "123key",
         
     | 
| 
      
 17 
     | 
    
         
            +
                        :first_name => "Kalle",
         
     | 
| 
      
 18 
     | 
    
         
            +
                        :last_name => "Anka",
         
     | 
| 
      
 19 
     | 
    
         
            +
                        :email => "kalle.anka@vonanka.com"
         
     | 
| 
      
 20 
     | 
    
         
            +
                    })
         
     | 
| 
      
 21 
     | 
    
         
            +
                    rootmodel.find_coworker_by_integration_id("123key").first_name.should eq "Kalle"
         
     | 
| 
      
 22 
     | 
    
         
            +
                    rootmodel.coworkers.length.should eq 2
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                it "can add a coworker from a new coworker" do
         
     | 
| 
      
 26 
     | 
    
         
            +
                    coworker = GoImport::Coworker.new
         
     | 
| 
      
 27 
     | 
    
         
            +
                    coworker.integration_id = "123key"
         
     | 
| 
      
 28 
     | 
    
         
            +
                    coworker.first_name="Kalle"
         
     | 
| 
      
 29 
     | 
    
         
            +
                    coworker.last_name="Anka"
         
     | 
| 
      
 30 
     | 
    
         
            +
                    coworker.email = "kalle.anka@vonanka.com"
         
     | 
| 
      
 31 
     | 
    
         
            +
                    rootmodel.add_coworker(coworker)
         
     | 
| 
      
 32 
     | 
    
         
            +
                    rootmodel.find_coworker_by_integration_id("123key").first_name.should eq "Kalle"
         
     | 
| 
      
 33 
     | 
    
         
            +
                    rootmodel.coworkers.length.should eq 2
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                it "will not add a new coworker when the coworker is already added (same integration id)" do
         
     | 
| 
      
 37 
     | 
    
         
            +
                    rootmodel.add_coworker({
         
     | 
| 
      
 38 
     | 
    
         
            +
                        :integration_id=>"123key",
         
     | 
| 
      
 39 
     | 
    
         
            +
                        :first_name=>"Kalle",
         
     | 
| 
      
 40 
     | 
    
         
            +
                        :last_name=>"Anka",
         
     | 
| 
      
 41 
     | 
    
         
            +
                        :email=>"kalle.anka@vonanka.com"
         
     | 
| 
      
 42 
     | 
    
         
            +
                    })
         
     | 
| 
      
 43 
     | 
    
         
            +
                    rootmodel.coworkers.length.should eq 2
         
     | 
| 
      
 44 
     | 
    
         
            +
                    expect {
         
     | 
| 
      
 45 
     | 
    
         
            +
                        rootmodel.add_coworker({
         
     | 
| 
      
 46 
     | 
    
         
            +
                            :integration_id=>"123key",
         
     | 
| 
      
 47 
     | 
    
         
            +
                            :first_name=>"Knatte",
         
     | 
| 
      
 48 
     | 
    
         
            +
                            :last_name=>"Anka",
         
     | 
| 
      
 49 
     | 
    
         
            +
                            :email=>"knatte.anka@vonanka.com"
         
     | 
| 
      
 50 
     | 
    
         
            +
                        })
         
     | 
| 
      
 51 
     | 
    
         
            +
                    }.to raise_error(GoImport::AlreadyAddedError)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    rootmodel.find_coworker_by_integration_id("123key").first_name.should eq "Kalle"
         
     | 
| 
      
 53 
     | 
    
         
            +
                    rootmodel.coworkers.length.should eq 2
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                it "can add an organization from hash" do
         
     | 
| 
      
 57 
     | 
    
         
            +
                    rootmodel.add_organization({
         
     | 
| 
      
 58 
     | 
    
         
            +
                                                   :integration_id => "123key",
         
     | 
| 
      
 59 
     | 
    
         
            +
                                                   :name => "Beagle Boys"
         
     | 
| 
      
 60 
     | 
    
         
            +
                    })
         
     | 
| 
      
 61 
     | 
    
         
            +
                    rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
         
     | 
| 
      
 62 
     | 
    
         
            +
                    rootmodel.organizations.length.should eq 1
         
     | 
| 
      
 63 
     | 
    
         
            +
                end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                it "can add an organization from a new organization" do
         
     | 
| 
      
 66 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 67 
     | 
    
         
            +
                    organization = GoImport::Organization.new
         
     | 
| 
      
 68 
     | 
    
         
            +
                    organization.integration_id = "123key"
         
     | 
| 
      
 69 
     | 
    
         
            +
                    organization.name = "Beagle Boys"
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                    # when
         
     | 
| 
      
 72 
     | 
    
         
            +
                    rootmodel.add_organization(organization)
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 75 
     | 
    
         
            +
                    rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
         
     | 
| 
      
 76 
     | 
    
         
            +
                    rootmodel.organizations.length.should eq 1
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                it "will not add a new organizations when the organizations is already added (same integration id)" do
         
     | 
| 
      
 80 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 81 
     | 
    
         
            +
                    rootmodel.add_organization({
         
     | 
| 
      
 82 
     | 
    
         
            +
                        :integration_id => "123key",
         
     | 
| 
      
 83 
     | 
    
         
            +
                        :name => "Beagle Boys"
         
     | 
| 
      
 84 
     | 
    
         
            +
                    })
         
     | 
| 
      
 85 
     | 
    
         
            +
                    rootmodel.organizations.length.should eq 1
         
     | 
| 
      
 86 
     | 
    
         
            +
                    rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                    # when, then
         
     | 
| 
      
 89 
     | 
    
         
            +
                    expect {
         
     | 
| 
      
 90 
     | 
    
         
            +
                        rootmodel.add_organization({
         
     | 
| 
      
 91 
     | 
    
         
            +
                            :integration_id => "123key",
         
     | 
| 
      
 92 
     | 
    
         
            +
                            :name => "Beagle Boys 2"
         
     | 
| 
      
 93 
     | 
    
         
            +
                        })
         
     | 
| 
      
 94 
     | 
    
         
            +
                    }.to raise_error(GoImport::AlreadyAddedError)
         
     | 
| 
      
 95 
     | 
    
         
            +
                    rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
         
     | 
| 
      
 96 
     | 
    
         
            +
                    rootmodel.organizations.length.should eq 1
         
     | 
| 
      
 97 
     | 
    
         
            +
                end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                it "can add a deal from hash" do
         
     | 
| 
      
 100 
     | 
    
         
            +
                    rootmodel.add_deal({
         
     | 
| 
      
 101 
     | 
    
         
            +
                                                   :integration_id => "123key",
         
     | 
| 
      
 102 
     | 
    
         
            +
                                                   :name => "Big deal"
         
     | 
| 
      
 103 
     | 
    
         
            +
                    })
         
     | 
| 
      
 104 
     | 
    
         
            +
                    rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
         
     | 
| 
      
 105 
     | 
    
         
            +
                    rootmodel.deals.length.should eq 1
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                it "can add a deal from a new deal" do
         
     | 
| 
      
 109 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 110 
     | 
    
         
            +
                    deal = GoImport::Deal.new
         
     | 
| 
      
 111 
     | 
    
         
            +
                    deal.integration_id = "123key"
         
     | 
| 
      
 112 
     | 
    
         
            +
                    deal.name = "Big deal"
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                    # when
         
     | 
| 
      
 115 
     | 
    
         
            +
                    rootmodel.add_deal(deal)
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 118 
     | 
    
         
            +
                    rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
         
     | 
| 
      
 119 
     | 
    
         
            +
                    rootmodel.deals.length.should eq 1
         
     | 
| 
      
 120 
     | 
    
         
            +
                end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                it "will set reponsible coworker to import_coworker if none specifed" do
         
     | 
| 
      
 123 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 124 
     | 
    
         
            +
                    deal = GoImport::Deal.new
         
     | 
| 
      
 125 
     | 
    
         
            +
                    deal.integration_id = "123key"
         
     | 
| 
      
 126 
     | 
    
         
            +
                    deal.name = "Big deal"
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                    # when
         
     | 
| 
      
 129 
     | 
    
         
            +
                    rootmodel.add_deal(deal)
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 132 
     | 
    
         
            +
                    deal.responsible_coworker.integration_id.should eq rootmodel.import_coworker.integration_id
         
     | 
| 
      
 133 
     | 
    
         
            +
                end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                it "will not set reponsible coworker to import_coworker if specifed" do
         
     | 
| 
      
 136 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 137 
     | 
    
         
            +
                    deal = GoImport::Deal.new
         
     | 
| 
      
 138 
     | 
    
         
            +
                    deal.integration_id = "123key"
         
     | 
| 
      
 139 
     | 
    
         
            +
                    deal.name = "Big deal"
         
     | 
| 
      
 140 
     | 
    
         
            +
                    coworker = GoImport::Coworker.new
         
     | 
| 
      
 141 
     | 
    
         
            +
                    coworker.integration_id = "123"
         
     | 
| 
      
 142 
     | 
    
         
            +
                    deal.responsible_coworker = coworker
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
                    # when
         
     | 
| 
      
 145 
     | 
    
         
            +
                    rootmodel.add_deal(deal)
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 148 
     | 
    
         
            +
                    deal.responsible_coworker.integration_id.should eq coworker.integration_id
         
     | 
| 
      
 149 
     | 
    
         
            +
                end
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                it "will not add a new deal when the deal is already added (same integration id)" do
         
     | 
| 
      
 152 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 153 
     | 
    
         
            +
                    rootmodel.add_deal({
         
     | 
| 
      
 154 
     | 
    
         
            +
                        :integration_id => "123key",
         
     | 
| 
      
 155 
     | 
    
         
            +
                        :name => "Big deal"
         
     | 
| 
      
 156 
     | 
    
         
            +
                    })
         
     | 
| 
      
 157 
     | 
    
         
            +
                    rootmodel.deals.length.should eq 1
         
     | 
| 
      
 158 
     | 
    
         
            +
                    rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                    # when, then
         
     | 
| 
      
 161 
     | 
    
         
            +
                    expect {
         
     | 
| 
      
 162 
     | 
    
         
            +
                        rootmodel.add_deal({
         
     | 
| 
      
 163 
     | 
    
         
            +
                            :integration_id => "123key",
         
     | 
| 
      
 164 
     | 
    
         
            +
                            :name => "Bigger deal"
         
     | 
| 
      
 165 
     | 
    
         
            +
                        })
         
     | 
| 
      
 166 
     | 
    
         
            +
                    }.to raise_error(GoImport::AlreadyAddedError)
         
     | 
| 
      
 167 
     | 
    
         
            +
                    rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
         
     | 
| 
      
 168 
     | 
    
         
            +
                    rootmodel.deals.length.should eq 1
         
     | 
| 
      
 169 
     | 
    
         
            +
                end
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
                it "can add a note from hash" do
         
     | 
| 
      
 172 
     | 
    
         
            +
                    rootmodel.add_note({
         
     | 
| 
      
 173 
     | 
    
         
            +
                                           :integration_id => "123key",
         
     | 
| 
      
 174 
     | 
    
         
            +
                                           :text => "This is a note"
         
     | 
| 
      
 175 
     | 
    
         
            +
                    })
         
     | 
| 
      
 176 
     | 
    
         
            +
                    rootmodel.find_note_by_integration_id("123key").text.should eq "This is a note"
         
     | 
| 
      
 177 
     | 
    
         
            +
                    rootmodel.notes.length.should eq 1
         
     | 
| 
      
 178 
     | 
    
         
            +
                end
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                it "can add a note from a new note" do
         
     | 
| 
      
 181 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 182 
     | 
    
         
            +
                    note = GoImport::Note.new
         
     | 
| 
      
 183 
     | 
    
         
            +
                    note.integration_id = "123key"
         
     | 
| 
      
 184 
     | 
    
         
            +
                    note.text = "This is a note"
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
                    # when
         
     | 
| 
      
 187 
     | 
    
         
            +
                    rootmodel.add_note(note)
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 190 
     | 
    
         
            +
                    rootmodel.find_note_by_integration_id("123key").text.should eq "This is a note"
         
     | 
| 
      
 191 
     | 
    
         
            +
                    rootmodel.notes.length.should eq 1
         
     | 
| 
      
 192 
     | 
    
         
            +
                end
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
                it "will not add a nil note" do
         
     | 
| 
      
 195 
     | 
    
         
            +
                    # given, when
         
     | 
| 
      
 196 
     | 
    
         
            +
                    rootmodel.add_note(nil)
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 199 
     | 
    
         
            +
                    rootmodel.notes.length.should eq 0
         
     | 
| 
      
 200 
     | 
    
         
            +
                end
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                it "will not add a nil organization" do
         
     | 
| 
      
 203 
     | 
    
         
            +
                    # given, when
         
     | 
| 
      
 204 
     | 
    
         
            +
                    rootmodel.add_organization(nil)
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 207 
     | 
    
         
            +
                    rootmodel.organizations.length.should eq 0
         
     | 
| 
      
 208 
     | 
    
         
            +
                end
         
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
      
 210 
     | 
    
         
            +
                it "will not add a nil deal" do
         
     | 
| 
      
 211 
     | 
    
         
            +
                    # given, when
         
     | 
| 
      
 212 
     | 
    
         
            +
                    rootmodel.add_deal(nil)
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 215 
     | 
    
         
            +
                    rootmodel.deals.length.should eq 0
         
     | 
| 
      
 216 
     | 
    
         
            +
                end
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
                it "will not add a nil coworker" do
         
     | 
| 
      
 219 
     | 
    
         
            +
                    # given, when
         
     | 
| 
      
 220 
     | 
    
         
            +
                    rootmodel.add_coworker(nil)
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 223 
     | 
    
         
            +
                    # 1 since we always have the import coworker
         
     | 
| 
      
 224 
     | 
    
         
            +
                    rootmodel.coworkers.length.should eq 1
         
     | 
| 
      
 225 
     | 
    
         
            +
                end
         
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
      
 227 
     | 
    
         
            +
                it "will add a new link" do
         
     | 
| 
      
 228 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 229 
     | 
    
         
            +
                    link = GoImport::Link.new
         
     | 
| 
      
 230 
     | 
    
         
            +
                    link.integration_id = "123key"
         
     | 
| 
      
 231 
     | 
    
         
            +
                    link.url = "http://dropbox.com/files/readme.txt"
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
                    # when
         
     | 
| 
      
 234 
     | 
    
         
            +
                    rootmodel.add_link link
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 237 
     | 
    
         
            +
                    rootmodel.documents.find_link_by_integration_id("123key").url.should eq "http://dropbox.com/files/readme.txt"
         
     | 
| 
      
 238 
     | 
    
         
            +
                    rootmodel.documents.links.length.should eq 1
         
     | 
| 
      
 239 
     | 
    
         
            +
                end
         
     | 
| 
      
 240 
     | 
    
         
            +
             
     | 
| 
      
 241 
     | 
    
         
            +
                it "will not add a new organizations when the organizations is already added (same integration id)" do
         
     | 
| 
      
 242 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 243 
     | 
    
         
            +
                    rootmodel.add_note({
         
     | 
| 
      
 244 
     | 
    
         
            +
                        :integration_id => "123key",
         
     | 
| 
      
 245 
     | 
    
         
            +
                        :text => "This is a note"
         
     | 
| 
      
 246 
     | 
    
         
            +
                    })
         
     | 
| 
      
 247 
     | 
    
         
            +
                    rootmodel.notes.length.should eq 1
         
     | 
| 
      
 248 
     | 
    
         
            +
             
     | 
| 
      
 249 
     | 
    
         
            +
                    # when, then
         
     | 
| 
      
 250 
     | 
    
         
            +
                    expect {
         
     | 
| 
      
 251 
     | 
    
         
            +
                        rootmodel.add_note({
         
     | 
| 
      
 252 
     | 
    
         
            +
                            :integration_id => "123key",
         
     | 
| 
      
 253 
     | 
    
         
            +
                            :text => "This is another note"
         
     | 
| 
      
 254 
     | 
    
         
            +
                        })
         
     | 
| 
      
 255 
     | 
    
         
            +
                    }.to raise_error(GoImport::AlreadyAddedError)
         
     | 
| 
      
 256 
     | 
    
         
            +
                    rootmodel.notes.length.should eq 1
         
     | 
| 
      
 257 
     | 
    
         
            +
                    rootmodel.find_note_by_integration_id("123key").text.should eq "This is a note"
         
     | 
| 
      
 258 
     | 
    
         
            +
                end
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
                it "Will find a person by integration id" do
         
     | 
| 
      
 261 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 262 
     | 
    
         
            +
                    organization = GoImport::Organization.new
         
     | 
| 
      
 263 
     | 
    
         
            +
                    organization.name = "Hubba Bubba"
         
     | 
| 
      
 264 
     | 
    
         
            +
                    organization.add_employee({
         
     | 
| 
      
 265 
     | 
    
         
            +
                        :integration_id => "123",
         
     | 
| 
      
 266 
     | 
    
         
            +
                        :first_name => "Billy",
         
     | 
| 
      
 267 
     | 
    
         
            +
                        :last_name => "Bob"
         
     | 
| 
      
 268 
     | 
    
         
            +
                    })
         
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
      
 270 
     | 
    
         
            +
                    rootmodel.add_organization(organization)
         
     | 
| 
      
 271 
     | 
    
         
            +
             
     | 
| 
      
 272 
     | 
    
         
            +
                    # when
         
     | 
| 
      
 273 
     | 
    
         
            +
                    found_person = rootmodel.find_person_by_integration_id("123")
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 276 
     | 
    
         
            +
                    found_person.integration_id.should eq "123"
         
     | 
| 
      
 277 
     | 
    
         
            +
                    found_person.first_name.should eq "Billy"
         
     | 
| 
      
 278 
     | 
    
         
            +
                    found_person.last_name.should eq "Bob"
         
     | 
| 
      
 279 
     | 
    
         
            +
                end
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
                it "Will find a person by integration id from an organization with many employees" do
         
     | 
| 
      
 282 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 283 
     | 
    
         
            +
                    organization = GoImport::Organization.new
         
     | 
| 
      
 284 
     | 
    
         
            +
                    organization.name = "Hubba Bubba"
         
     | 
| 
      
 285 
     | 
    
         
            +
                    organization.add_employee({
         
     | 
| 
      
 286 
     | 
    
         
            +
                        :integration_id => "123",
         
     | 
| 
      
 287 
     | 
    
         
            +
                        :first_name => "Billy",
         
     | 
| 
      
 288 
     | 
    
         
            +
                        :last_name => "Bob"
         
     | 
| 
      
 289 
     | 
    
         
            +
                    })
         
     | 
| 
      
 290 
     | 
    
         
            +
                    organization.add_employee({
         
     | 
| 
      
 291 
     | 
    
         
            +
                        :integration_id => "456",
         
     | 
| 
      
 292 
     | 
    
         
            +
                        :first_name => "Vincent",
         
     | 
| 
      
 293 
     | 
    
         
            +
                        :last_name => "Vega"
         
     | 
| 
      
 294 
     | 
    
         
            +
                    })
         
     | 
| 
      
 295 
     | 
    
         
            +
             
     | 
| 
      
 296 
     | 
    
         
            +
                    rootmodel.add_organization(organization)
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
                    # when
         
     | 
| 
      
 299 
     | 
    
         
            +
                    found_person = rootmodel.find_person_by_integration_id("123")
         
     | 
| 
      
 300 
     | 
    
         
            +
             
     | 
| 
      
 301 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 302 
     | 
    
         
            +
                    found_person.integration_id.should eq "123"
         
     | 
| 
      
 303 
     | 
    
         
            +
                    found_person.first_name.should eq "Billy"
         
     | 
| 
      
 304 
     | 
    
         
            +
                    found_person.last_name.should eq "Bob"
         
     | 
| 
      
 305 
     | 
    
         
            +
                end
         
     | 
| 
      
 306 
     | 
    
         
            +
             
     | 
| 
      
 307 
     | 
    
         
            +
                it "will ignore empty integration ids during sanity check" do
         
     | 
| 
      
 308 
     | 
    
         
            +
                    org1 = GoImport::Organization.new
         
     | 
| 
      
 309 
     | 
    
         
            +
                    org1.name = "company 1"
         
     | 
| 
      
 310 
     | 
    
         
            +
                    rootmodel.organizations.push org1
         
     | 
| 
      
 311 
     | 
    
         
            +
             
     | 
| 
      
 312 
     | 
    
         
            +
                    org2 = GoImport::Organization.new
         
     | 
| 
      
 313 
     | 
    
         
            +
                    org2.name = "company 2"
         
     | 
| 
      
 314 
     | 
    
         
            +
                    rootmodel.organizations.push org2
         
     | 
| 
      
 315 
     | 
    
         
            +
             
     | 
| 
      
 316 
     | 
    
         
            +
                    rootmodel.sanity_check.should eq ""
         
     | 
| 
      
 317 
     | 
    
         
            +
                end
         
     | 
| 
      
 318 
     | 
    
         
            +
             
     | 
| 
      
 319 
     | 
    
         
            +
                it "will report when the same integration id is used during sanity check" do
         
     | 
| 
      
 320 
     | 
    
         
            +
                    org1 = GoImport::Organization.new
         
     | 
| 
      
 321 
     | 
    
         
            +
                    org1.integration_id = "1"
         
     | 
| 
      
 322 
     | 
    
         
            +
                    org1.name = "company 1"
         
     | 
| 
      
 323 
     | 
    
         
            +
                    rootmodel.organizations.push org1
         
     | 
| 
      
 324 
     | 
    
         
            +
             
     | 
| 
      
 325 
     | 
    
         
            +
                    org2 = GoImport::Organization.new
         
     | 
| 
      
 326 
     | 
    
         
            +
                    org2.integration_id = "1"
         
     | 
| 
      
 327 
     | 
    
         
            +
                    org2.name = "company 2"
         
     | 
| 
      
 328 
     | 
    
         
            +
                    rootmodel.organizations.push org2
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
                    rootmodel.sanity_check.should eq "Duplicate organization integration_id: 1."
         
     | 
| 
      
 331 
     | 
    
         
            +
                end
         
     | 
| 
      
 332 
     | 
    
         
            +
             
     | 
| 
      
 333 
     | 
    
         
            +
                it "will report when the same integrationid on person is used during sanity check" do
         
     | 
| 
      
 334 
     | 
    
         
            +
                    org1 = GoImport::Organization.new
         
     | 
| 
      
 335 
     | 
    
         
            +
                    org1.integration_id = "1"
         
     | 
| 
      
 336 
     | 
    
         
            +
                    org1.name = "company 1"
         
     | 
| 
      
 337 
     | 
    
         
            +
                    person1 = GoImport::Person.new
         
     | 
| 
      
 338 
     | 
    
         
            +
                    person1.integration_id = '1'
         
     | 
| 
      
 339 
     | 
    
         
            +
                    org1.add_employee person1
         
     | 
| 
      
 340 
     | 
    
         
            +
             
     | 
| 
      
 341 
     | 
    
         
            +
                    rootmodel.organizations.push org1
         
     | 
| 
      
 342 
     | 
    
         
            +
             
     | 
| 
      
 343 
     | 
    
         
            +
                    org2 = GoImport::Organization.new
         
     | 
| 
      
 344 
     | 
    
         
            +
                    org2.integration_id = "2"
         
     | 
| 
      
 345 
     | 
    
         
            +
                    org2.name = "company 2"
         
     | 
| 
      
 346 
     | 
    
         
            +
                    person2 = GoImport::Person.new
         
     | 
| 
      
 347 
     | 
    
         
            +
                    person2.integration_id = '1'
         
     | 
| 
      
 348 
     | 
    
         
            +
                    org2.add_employee person2
         
     | 
| 
      
 349 
     | 
    
         
            +
                    rootmodel.organizations.push org2
         
     | 
| 
      
 350 
     | 
    
         
            +
             
     | 
| 
      
 351 
     | 
    
         
            +
                    rootmodel.sanity_check.should eq "Duplicate person integration_id: 1."
         
     | 
| 
      
 352 
     | 
    
         
            +
                end
         
     | 
| 
      
 353 
     | 
    
         
            +
             
     | 
| 
      
 354 
     | 
    
         
            +
                it "will report when two links has the same integration id during sanity check" do
         
     | 
| 
      
 355 
     | 
    
         
            +
                    # given
         
     | 
| 
      
 356 
     | 
    
         
            +
                    link1 = GoImport::Link.new
         
     | 
| 
      
 357 
     | 
    
         
            +
                    link1.integration_id = "1"
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
                    link2 = GoImport::Link.new
         
     | 
| 
      
 360 
     | 
    
         
            +
                    link2.integration_id = "2"
         
     | 
| 
      
 361 
     | 
    
         
            +
             
     | 
| 
      
 362 
     | 
    
         
            +
                    rootmodel.add_link link1
         
     | 
| 
      
 363 
     | 
    
         
            +
                    rootmodel.add_link link2
         
     | 
| 
      
 364 
     | 
    
         
            +
             
     | 
| 
      
 365 
     | 
    
         
            +
                    # when
         
     | 
| 
      
 366 
     | 
    
         
            +
                    link2.integration_id = "1"
         
     | 
| 
      
 367 
     | 
    
         
            +
             
     | 
| 
      
 368 
     | 
    
         
            +
                    # then
         
     | 
| 
      
 369 
     | 
    
         
            +
                    rootmodel.sanity_check.should eq "Duplicate link integration_id: 1."
         
     | 
| 
      
 370 
     | 
    
         
            +
                end
         
     | 
| 
      
 371 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # This file is copied to spec/ when you run 'rails generate rspec:install'
         
     | 
| 
      
 2 
     | 
    
         
            +
            #require File.expand_path("../../config/environment", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            #require 'rspec/autorun'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # Requires supporting ruby files with custom matchers and macros, etc,
         
     | 
| 
      
 6 
     | 
    
         
            +
            # in spec/support/ and its subdirectories.
         
     | 
| 
      
 7 
     | 
    
         
            +
            Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 10 
     | 
    
         
            +
                # ## Mock Framework
         
     | 
| 
      
 11 
     | 
    
         
            +
                #
         
     | 
| 
      
 12 
     | 
    
         
            +
                # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
         
     | 
| 
      
 13 
     | 
    
         
            +
                #
         
     | 
| 
      
 14 
     | 
    
         
            +
                # config.mock_with :mocha
         
     | 
| 
      
 15 
     | 
    
         
            +
                # config.mock_with :flexmock
         
     | 
| 
      
 16 
     | 
    
         
            +
                # config.mock_with :rr
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                # Run specs in random order to surface order dependencies. If you find an
         
     | 
| 
      
 19 
     | 
    
         
            +
                # order dependency and want to debug it, you can fix the order by providing
         
     | 
| 
      
 20 
     | 
    
         
            +
                # the seed, which is printed after each run.
         
     | 
| 
      
 21 
     | 
    
         
            +
                #     --seed 1234
         
     | 
| 
      
 22 
     | 
    
         
            +
                config.order = "random"
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                # Allow both should and expect syntax
         
     | 
| 
      
 25 
     | 
    
         
            +
                # http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
         
     | 
| 
      
 26 
     | 
    
         
            +
                config.expect_with :rspec do |c|
         
     | 
| 
      
 27 
     | 
    
         
            +
                    c.syntax = [:should, :expect]
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'tmpdir'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe 'Templating' do
         
     | 
| 
      
 5 
     | 
    
         
            +
                let(:templating) { GoImport::Templating.new(File.expand_path("../templates", File.dirname(__FILE__))) }
         
     | 
| 
      
 6 
     | 
    
         
            +
                
         
     | 
| 
      
 7 
     | 
    
         
            +
                describe 'list' do
         
     | 
| 
      
 8 
     | 
    
         
            +
                    it 'can find some templates' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                        templating.list().length.should > 0
         
     | 
| 
      
 10 
     | 
    
         
            +
                    end
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     |