erp_base_erp_svcs 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. data/GPL-3-LICENSE +674 -0
  2. data/README.rdoc +2 -0
  3. data/Rakefile +31 -0
  4. data/app/assets/javascripts/erp_base_erp_svcs/application.js +9 -0
  5. data/app/assets/stylesheets/erp_base_erp_svcs/application.css +7 -0
  6. data/app/controllers/erp_base_erp_svcs/application_controller.rb +4 -0
  7. data/app/helpers/erp_base_erp_svcs/application_helper.rb +4 -0
  8. data/app/models/category.rb +11 -0
  9. data/app/models/category_classification.rb +4 -0
  10. data/app/models/compass_ae_instance.rb +11 -0
  11. data/app/models/contact.rb +42 -0
  12. data/app/models/contact_purpose.rb +6 -0
  13. data/app/models/contact_type.rb +3 -0
  14. data/app/models/currency.rb +16 -0
  15. data/app/models/descriptive_asset.rb +4 -0
  16. data/app/models/email_address.rb +15 -0
  17. data/app/models/geo_country.rb +8 -0
  18. data/app/models/geo_zone.rb +8 -0
  19. data/app/models/individual.rb +76 -0
  20. data/app/models/iso_country_code.rb +10 -0
  21. data/app/models/money.rb +19 -0
  22. data/app/models/note.rb +14 -0
  23. data/app/models/note_type.rb +7 -0
  24. data/app/models/organization.rb +32 -0
  25. data/app/models/party.rb +191 -0
  26. data/app/models/party_relationship.rb +9 -0
  27. data/app/models/party_role.rb +8 -0
  28. data/app/models/phone_number.rb +16 -0
  29. data/app/models/postal_address.rb +19 -0
  30. data/app/models/relationship_type.rb +7 -0
  31. data/app/models/role_type.rb +7 -0
  32. data/app/models/valid_note_type.rb +4 -0
  33. data/app/models/view_type.rb +3 -0
  34. data/app/views/layouts/erp_base_erp_svcs/application.html.erb +14 -0
  35. data/config/initializers/erp_base_erp_svcs.rb +4 -0
  36. data/config/routes.rb +2 -0
  37. data/db/data_migrations/20110525001935_add_usd_currency.rb +11 -0
  38. data/db/data_migrations/20110609150135_add_iso_codes.rb +18 -0
  39. data/db/data_migrations/20110913145838_setup_compass_ae_instance.rb +11 -0
  40. data/db/data_sets/geo_countries.yml +2952 -0
  41. data/db/data_sets/geo_zones.yml +1233 -0
  42. data/db/migrate/20080805000020_base_erp_services.rb +461 -0
  43. data/db/migrate/20110913145329_create_compass_ae_instance.rb +15 -0
  44. data/db/migrate/upgrade/20110907171257_add_notes.rb +63 -0
  45. data/lib/erp_base_erp_svcs/ar_fixtures.rb +103 -0
  46. data/lib/erp_base_erp_svcs/command.rb +37 -0
  47. data/lib/erp_base_erp_svcs/config.rb +27 -0
  48. data/lib/erp_base_erp_svcs/engine.rb +27 -0
  49. data/lib/erp_base_erp_svcs/extensions/active_record/acts_as_category.rb +50 -0
  50. data/lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb +148 -0
  51. data/lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb +47 -0
  52. data/lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb +46 -0
  53. data/lib/erp_base_erp_svcs/extensions/active_record/has_contact.rb +56 -0
  54. data/lib/erp_base_erp_svcs/extensions/active_record/has_notes.rb +32 -0
  55. data/lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb +44 -0
  56. data/lib/erp_base_erp_svcs/extensions/active_record/migrator.rb +76 -0
  57. data/lib/erp_base_erp_svcs/extensions/active_record/sti_instantiation.rb +37 -0
  58. data/lib/erp_base_erp_svcs/extensions/core/array.rb +20 -0
  59. data/lib/erp_base_erp_svcs/extensions/core/hash.rb +19 -0
  60. data/lib/erp_base_erp_svcs/extensions/core/numbers.rb +27 -0
  61. data/lib/erp_base_erp_svcs/extensions/core/object.rb +6 -0
  62. data/lib/erp_base_erp_svcs/extensions/railties/engine.rb +85 -0
  63. data/lib/erp_base_erp_svcs/extensions.rb +19 -0
  64. data/lib/erp_base_erp_svcs/non_escape_json_string.rb +5 -0
  65. data/lib/erp_base_erp_svcs/rails_template.rb +93 -0
  66. data/lib/erp_base_erp_svcs/version.rb +3 -0
  67. data/lib/erp_base_erp_svcs.rb +17 -0
  68. data/lib/tasks/compass_backup.rake +87 -0
  69. data/lib/tasks/erp_base_erp_svcs_tasks.rake +59 -0
  70. data/lib/tasks/release_notes/NOTES +21 -0
  71. data/spec/dummy/Rakefile +7 -0
  72. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  73. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  74. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  75. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  76. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  77. data/spec/dummy/config/application.rb +42 -0
  78. data/spec/dummy/config/boot.rb +10 -0
  79. data/spec/dummy/config/database.yml +8 -0
  80. data/spec/dummy/config/environment.rb +5 -0
  81. data/spec/dummy/config/environments/spec.rb +27 -0
  82. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  83. data/spec/dummy/config/initializers/inflections.rb +10 -0
  84. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  85. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  86. data/spec/dummy/config/initializers/session_store.rb +8 -0
  87. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  88. data/spec/dummy/config/locales/en.yml +5 -0
  89. data/spec/dummy/config/routes.rb +4 -0
  90. data/spec/dummy/config.ru +4 -0
  91. data/spec/dummy/db/spec.sqlite3 +0 -0
  92. data/spec/dummy/log/spec.log +4820 -0
  93. data/spec/dummy/public/404.html +26 -0
  94. data/spec/dummy/public/422.html +26 -0
  95. data/spec/dummy/public/500.html +26 -0
  96. data/spec/dummy/public/favicon.ico +0 -0
  97. data/spec/dummy/script/rails +6 -0
  98. data/spec/factories/business_party.rb +21 -0
  99. data/spec/factories/contact_purpose.rb +8 -0
  100. data/spec/factories/party.rb +16 -0
  101. data/spec/factories/party_relationship.rb +10 -0
  102. data/spec/factories/party_role.rb +7 -0
  103. data/spec/factories/phone_number.rb +7 -0
  104. data/spec/factories/relationship_type.rb +8 -0
  105. data/spec/factories/role_type.rb +8 -0
  106. data/spec/models/category_classification_spec.rb +11 -0
  107. data/spec/models/category_spec.rb +18 -0
  108. data/spec/models/contact_purpose_spec.rb +12 -0
  109. data/spec/models/contact_spec.rb +12 -0
  110. data/spec/models/contact_type_spec.rb +12 -0
  111. data/spec/models/currency_spec.rb +12 -0
  112. data/spec/models/descriptive_asset_spec.rb +12 -0
  113. data/spec/models/email_address_spec.rb +12 -0
  114. data/spec/models/geo_country_spec.rb +13 -0
  115. data/spec/models/geo_zone_spec.rb +12 -0
  116. data/spec/models/individual_spec.rb +40 -0
  117. data/spec/models/money_spec.rb +12 -0
  118. data/spec/models/note_spec.rb +26 -0
  119. data/spec/models/note_type_spec.rb +12 -0
  120. data/spec/models/organization_spec.rb +33 -0
  121. data/spec/models/party_relationship_spec.rb +12 -0
  122. data/spec/models/party_role_spec.rb +12 -0
  123. data/spec/models/party_spec.rb +98 -0
  124. data/spec/models/phone_number_spec.rb +12 -0
  125. data/spec/models/postal_address_spec.rb +12 -0
  126. data/spec/models/relationship_type_spec.rb +11 -0
  127. data/spec/models/role_type_spec.rb +12 -0
  128. data/spec/models/view_type_spec.rb +12 -0
  129. data/spec/spec_helper.rb +57 -0
  130. metadata +391 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,21 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :individual do |i|
4
+ i.current_last_name "Doe"
5
+ i.current_first_name "John"
6
+ i.current_middle_name "Will"
7
+ i.current_suffix "Jr"
8
+ i.current_nickname "Billy"
9
+ i.gender "m"
10
+ i.height "6ft"
11
+ i.weight "180 lbs"
12
+ i.mothers_maiden_name "Smith"
13
+ end
14
+
15
+
16
+ factory :organization do |o|
17
+ o.sequence(:description){|n| "Organization #{n}"}
18
+ o.sequence(:tax_id_number) {|n| "#{n}"}
19
+ end
20
+
21
+ end
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :contact_purpose do |cp|
4
+
5
+ end
6
+
7
+ end
8
+
@@ -0,0 +1,16 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :party do |p|
4
+ p.sequence(:description){|n| "party #{n}"}
5
+ end
6
+
7
+ factory :individual_party, :parent => :party do |ip|
8
+ ip.association :business_party, :factory => :individual
9
+ end
10
+
11
+ factory :organization_party, :parent => :party do |op|
12
+ op.association :business_party, :factory => :organization
13
+ end
14
+
15
+ end
16
+
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ factory :party_relationship do |pr|
3
+ pr.description "A Party Relationship"
4
+ pr.association :from_party, :factory => :party
5
+ pr.association :to_party, :factory => :party
6
+ pr.association :from_role, :factory => :role_type
7
+ pr.association :to_role, :factory => :role_type
8
+ pr.association :relationship_type, :factory => :relationship_type
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :party_role do |pr|
4
+ pr.association :party, :factory => :party
5
+ pr.association :role_type, :factory => :role_type
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :phone_number do |p|
4
+
5
+ end
6
+
7
+ end
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+ factory :relationship_type do |type|
3
+ type.association :valid_from_role, :factory => :role_type
4
+ type.association :valid_to_role, :factory => :role_type
5
+ name "A relationship type"
6
+ type.sequence(:internal_identifier){|n| "party relationship #{n}"}
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :role_type do |role|
4
+ role.sequence(:description){|n| "test role #{n}"}
5
+ role.sequence(:internal_identifier){|n| "test_role_#{n}"}
6
+ role.comments "A test role automatically created by Factory Girl"
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe CategoryClassification do
4
+ it "can be instantiated" do
5
+ CategoryClassification.new.should be_an_instance_of(CategoryClassification)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ CategoryClassification.create().should be_persisted
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Category do
4
+ it "can be instantiated" do
5
+ Category.new.should be_an_instance_of(Category)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ Category.create.should be_persisted
10
+ end
11
+
12
+ it "can be found by iid" do
13
+ Category.create(:internal_identifier => 'my_category')
14
+ category = Category.iid('my_category')
15
+ category.should be_an_instance_of(Category)
16
+ category.internal_identifier.should == 'my_category'
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe ContactPurpose do
4
+ it "can be instantiated" do
5
+ ContactPurpose.new.should be_an_instance_of(ContactPurpose)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ ContactPurpose.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Contact do
4
+ it "can be instantiated" do
5
+ Contact.new.should be_an_instance_of(Contact)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ Contact.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe ContactType do
4
+ it "can be instantiated" do
5
+ ContactType.new.should be_an_instance_of(ContactType)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ ContactType.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Currency do
4
+ it "can be instantiated" do
5
+ Currency.new.should be_an_instance_of(Currency)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ Currency.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe DescriptiveAsset do
4
+ it "can be instantiated" do
5
+ DescriptiveAsset.new.should be_an_instance_of(DescriptiveAsset)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ DescriptiveAsset.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe EmailAddress do
4
+ it "can be instantiated" do
5
+ EmailAddress.new.should be_an_instance_of(EmailAddress)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ EmailAddress.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe GeoCountry do
4
+ it "can be instantiated" do
5
+ GeoCountry.new.should be_an_instance_of(GeoCountry)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ #name, iso_code_2, :iso_code_3 are required
10
+ GeoCountry.create(:name => 'test', :iso_code_2 => '12', :iso_code_3 => '345').should be_persisted
11
+ end
12
+
13
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe GeoZone do
4
+ it "can be instantiated" do
5
+ GeoZone.new.should be_an_instance_of(GeoZone)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ geo_country = GeoCountry.create(:name => 'test', :iso_code_2 => '12', :iso_code_3 => '345')
10
+ GeoZone.create(:geo_country_id => geo_country.id, :zone_code => '12', :zone_name => 'test').should be_persisted
11
+ end
12
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Individual do
4
+ it "can be instantiated" do
5
+ Individual.new.should be_an_instance_of(Individual)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ Individual.create.should be_persisted
10
+ end
11
+
12
+ it "creates party" do
13
+ individual = Individual.create(:current_first_name => 'Dummy', :current_last_name => 'Person')
14
+ individual.should be_an_instance_of(Individual)
15
+ individual.party.should be_an_instance_of(Party)
16
+ individual.party.description.should == "Dummy Person"
17
+ individual.party.business_party.should == individual
18
+ end
19
+
20
+ it "destroys party" do
21
+ individual = Individual.create(:current_first_name => 'Dummy', :current_last_name => 'Person')
22
+ individual.should be_an_instance_of(Individual)
23
+
24
+ party = individual.party
25
+ individual.party.should be_an_instance_of(Party)
26
+ individual.party.description.should == "Dummy Person"
27
+ individual.party.business_party.should == individual
28
+
29
+ individual.destroy
30
+ Party.where("id = ?",party.id).count.should == 0
31
+ end
32
+
33
+ it "should have encrypted ssn" do
34
+ individual = Individual.create(:current_first_name => 'Dummy', :current_last_name => 'Person')
35
+ individual.social_security_number = "123212323"
36
+ individual.encrypted_ssn.should_not == "123212323"
37
+ individual.social_security_number.should == "123212323"
38
+ end
39
+
40
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Money do
4
+ it "can be instantiated" do
5
+ Money.new.should be_an_instance_of(Money)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ Money.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Note do
4
+ it "can be instantiated" do
5
+ Note.new.should be_an_instance_of(Note)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ Note.create.should be_persisted
10
+ end
11
+
12
+ it "can add note" do
13
+ note = Note.create
14
+ note.content = "test"
15
+ note.save
16
+ note.content.should == "test"
17
+ end
18
+
19
+ it "should have summmary" do
20
+ note = Note.create
21
+ note.content = "This is going to be summarized"
22
+ note.save
23
+ note.summary.should == "This is going to be s..."
24
+ end
25
+
26
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe NoteType do
4
+ it "can be instantiated" do
5
+ NoteType.new.should be_an_instance_of(NoteType)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ NoteType.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Organization do
4
+ it "can be instantiated" do
5
+ Organization.new.should be_an_instance_of(Organization)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ Organization.create().should be_persisted
10
+ end
11
+
12
+ it "creates party" do
13
+ organization = Organization.create(:description => 'Worldcom')
14
+ organization.should be_an_instance_of(Organization)
15
+ organization.party.should be_an_instance_of(Party)
16
+ organization.party.description.should == "Worldcom"
17
+ organization.party.business_party.should == organization
18
+ end
19
+
20
+ it "destroys party" do
21
+ organization = Organization.create(:description => 'Worldcom')
22
+ organization.should be_an_instance_of(Organization)
23
+
24
+ party = organization.party
25
+ organization.party.should be_an_instance_of(Party)
26
+ organization.party.description.should == "Worldcom"
27
+ organization.party.business_party.should == organization
28
+
29
+ organization.destroy
30
+ Party.where("id = ?",party.id).count.should == 0
31
+ end
32
+
33
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe PartyRelationship do
4
+ it "can be instantiated" do
5
+ PartyRelationship.new.should be_an_instance_of(PartyRelationship)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ PartyRelationship.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe PartyRole do
4
+ it "can be instantiated" do
5
+ PartyRole.new.should be_an_instance_of(PartyRole)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ PartyRole.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+
3
+ describe Party do
4
+ it "can be instantiated" do
5
+ Party.new.should be_an_instance_of(Party)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ Party.create.should be_persisted
10
+ end
11
+
12
+ it "has method to check for phone number passing in a number" do
13
+ party = Factory(:party)
14
+ contact_purpose = Factory(:contact_purpose, :description => 'billing', :internal_identifier => 'billing')
15
+ party.update_or_add_contact_with_purpose(PhoneNumber, contact_purpose, :phone_number => '123-123-1234')
16
+ party.has_phone_number?('123-123-1234').should eq true
17
+ end
18
+
19
+ it "has method to check for zip code passing in a zip code" do
20
+ party = Factory(:party)
21
+ contact_purpose = Factory(:contact_purpose, :description => 'billing', :internal_identifier => 'billing')
22
+ party.update_or_add_contact_with_purpose(PostalAddress, contact_purpose, :zip => '34711')
23
+ party.has_zip_code?('34711').should eq true
24
+ end
25
+
26
+ it "has method to_label to return description" do
27
+ party = Factory(:party, :description => 'Joe Smith')
28
+ party.to_label.should eq "Joe Smith"
29
+ end
30
+
31
+ it "has method to_s to return description" do
32
+ party = Factory(:party, :description => 'Joe Smith')
33
+ party.to_s.should eq "Joe Smith"
34
+ end
35
+
36
+ it "overrids respond_to? and method_missing to find contacts" do
37
+ party = Factory(:party)
38
+ contact_purpose = Factory(:contact_purpose, :description => 'billing', :internal_identifier => 'billing')
39
+ party.update_or_add_contact_with_purpose(PhoneNumber, contact_purpose, :phone_number => '123-123-1234')
40
+ party.billing_phone_number.should_not eq nil
41
+ party.billing_phone_number.phone_number.should eq '123-123-1234'
42
+ end
43
+
44
+ it "has method to get all contacts by contact mechanism" do
45
+ party = Factory(:party)
46
+ contact_purpose_billing = Factory(:contact_purpose, :description => 'billing', :internal_identifier => 'billing')
47
+ contact_purpose_home = Factory(:contact_purpose, :description => 'home', :internal_identifier => 'home')
48
+ party.update_or_add_contact_with_purpose(PhoneNumber, contact_purpose_billing, :phone_number => '123-123-1234')
49
+ party.update_or_add_contact_with_purpose(PhoneNumber, contact_purpose_home, :phone_number => '123-123-1234')
50
+
51
+ party.find_all_contacts_by_contact_mechanism(PhoneNumber).count.should eq 2
52
+ end
53
+
54
+ it "has method to find contact with a contact purpose and can take internal identifier of contact purpose" do
55
+ party = Factory(:party)
56
+ contact_purpose_billing = Factory(:contact_purpose, :description => 'billing', :internal_identifier => 'billing')
57
+ party.update_or_add_contact_with_purpose(PhoneNumber, contact_purpose_billing, :phone_number => '123-123-1234')
58
+
59
+ party.find_contact_with_purpose(PhoneNumber, 'billing').contact_mechanism.phone_number.should eq '123-123-1234'
60
+ end
61
+
62
+ it "has method to find contact with a contact purpose and can take a contact purpose instance" do
63
+ party = Factory(:party)
64
+ contact_purpose_billing = Factory(:contact_purpose, :description => 'billing', :internal_identifier => 'billing')
65
+ party.update_or_add_contact_with_purpose(PhoneNumber, contact_purpose_billing, :phone_number => '123-123-1234')
66
+
67
+ party.find_contact_with_purpose(PhoneNumber, contact_purpose_billing).contact_mechanism.phone_number.should eq '123-123-1234'
68
+ end
69
+
70
+ it "can update contact" do
71
+ party = Factory(:party)
72
+ contact_purpose_billing = Factory(:contact_purpose, :description => 'billing', :internal_identifier => 'billing')
73
+ party.update_or_add_contact_with_purpose(PhoneNumber, contact_purpose_billing, :phone_number => '123-123-1234')
74
+
75
+ party.find_contact_with_purpose(PhoneNumber, contact_purpose_billing).contact_mechanism.phone_number.should eq '123-123-1234'
76
+
77
+ party.update_contact(PhoneNumber, party.find_contact_with_purpose(PhoneNumber, contact_purpose_billing), :phone_number => '123-123-1235')
78
+
79
+ party.find_contact_with_purpose(PhoneNumber, contact_purpose_billing).contact_mechanism.phone_number.should eq '123-123-1235'
80
+ end
81
+
82
+ it "should update contact if contact already exists" do
83
+ party = Factory(:party)
84
+ contact_purpose_billing = Factory(:contact_purpose, :description => 'billing', :internal_identifier => 'billing')
85
+ party.update_or_add_contact_with_purpose(PhoneNumber, contact_purpose_billing, :phone_number => '123-123-1234')
86
+
87
+ current_contact = party.find_contact_with_purpose(PhoneNumber, contact_purpose_billing)
88
+ current_contact.contact_mechanism.phone_number.should eq '123-123-1234'
89
+
90
+ party.update_or_add_contact_with_purpose(PhoneNumber, contact_purpose_billing, :phone_number => '123-123-1235')
91
+
92
+ new_contact = party.find_contact_with_purpose(PhoneNumber, contact_purpose_billing)
93
+ new_contact.contact_mechanism.phone_number.should eq '123-123-1235'
94
+ new_contact.id.should eq current_contact.id
95
+ end
96
+
97
+
98
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe PhoneNumber do
4
+ it "can be instantiated" do
5
+ PhoneNumber.new.should be_an_instance_of(PhoneNumber)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ PhoneNumber.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe PostalAddress do
4
+ it "can be instantiated" do
5
+ PostalAddress.new.should be_an_instance_of(PostalAddress)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ PostalAddress.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe RelationshipType do
4
+ it "can be instantiated" do
5
+ RelationshipType.new.should be_an_instance_of(RelationshipType)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ RelationshipType.create().should be_persisted
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe RoleType do
4
+ it "can be instantiated" do
5
+ RoleType.new.should be_an_instance_of(RoleType)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ RoleType.create.should be_persisted
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe ViewType do
4
+ it "can be instantiated" do
5
+ ViewType.new.should be_an_instance_of(ViewType)
6
+ end
7
+
8
+ it "can be saved successfully" do
9
+ ViewType.create.should be_persisted
10
+ end
11
+
12
+ end