has_addresses 0.0.2 → 0.5.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/CHANGELOG.rdoc +50 -0
- data/{MIT-LICENSE → LICENSE} +2 -2
- data/README.rdoc +63 -0
- data/Rakefile +48 -41
- data/app/models/address.rb +92 -50
- data/app/models/country.rb +287 -101
- data/app/models/region.rb +5378 -106
- data/db/migrate/001_create_countries.rb +7 -7
- data/db/migrate/002_create_regions.rb +7 -5
- data/db/migrate/003_create_addresses.rb +10 -12
- data/lib/has_addresses.rb +9 -68
- data/test/app_root/app/models/company.rb +1 -5
- data/test/app_root/config/environment.rb +6 -19
- data/test/app_root/db/migrate/001_create_companies.rb +1 -1
- data/test/app_root/db/migrate/002_migrate_has_addresses_to_version_3.rb +13 -0
- data/test/factory.rb +68 -0
- data/test/functional/has_addresses_test.rb +22 -0
- data/test/test_helper.rb +11 -5
- data/test/unit/address_test.rb +210 -79
- data/test/unit/country_test.rb +101 -72
- data/test/unit/region_test.rb +104 -61
- metadata +70 -61
- data/CHANGELOG +0 -23
- data/README +0 -122
- data/tasks/has_addresses_tasks.rake +0 -23
- data/test/app_root/db/migrate/002_add_address_kinds.rb +0 -9
- data/test/files/iso_3166.xml +0 -1719
- data/test/files/iso_3166_2.xml +0 -8617
- data/test/fixtures/addresses.yml +0 -47
- data/test/fixtures/companies.yml +0 -7
- data/test/fixtures/countries.yml +0 -12
- data/test/fixtures/regions.yml +0 -5
- data/test/unit/has_addresses_test.rb +0 -15
data/test/fixtures/addresses.yml
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
in_known_region:
|
2
|
-
id: 1
|
3
|
-
addressable_id: 1
|
4
|
-
addressable_type: Company
|
5
|
-
street_1: 123 Fake Street
|
6
|
-
city: Palo Alto
|
7
|
-
region_id: 3181
|
8
|
-
country_id: null
|
9
|
-
postal_code: 94306
|
10
|
-
created_at: <%= Time.now.to_s(:db) %>
|
11
|
-
updated_at: <%= Time.now.to_s(:db) %>
|
12
|
-
|
13
|
-
in_unknown_region:
|
14
|
-
id: 2
|
15
|
-
addressable_id: 1
|
16
|
-
addressable_type: Company
|
17
|
-
street_1: 123 Fake Street
|
18
|
-
city: Somewhere
|
19
|
-
custom_region: Anywhere
|
20
|
-
postal_code: 12345
|
21
|
-
country_id: 124
|
22
|
-
created_at: <%= Time.now.to_s(:db) %>
|
23
|
-
updated_at: <%= Time.now.to_s(:db) %>
|
24
|
-
|
25
|
-
google_headquarters:
|
26
|
-
id: 3
|
27
|
-
addressable_id: 2
|
28
|
-
addressable_type: Company
|
29
|
-
street_1: 1600 Amphitheatre Parkway
|
30
|
-
city: Mountain View
|
31
|
-
region_id: 3181
|
32
|
-
postal_code: 94043
|
33
|
-
created_at: <%= Time.now.to_s(:db) %>
|
34
|
-
updated_at: <%= Time.now.to_s(:db) %>
|
35
|
-
kind: headquarters
|
36
|
-
|
37
|
-
google_sales:
|
38
|
-
id: 4
|
39
|
-
addressable_id: 2
|
40
|
-
addressable_type: Company
|
41
|
-
street_1: 604 Arizona Avenue
|
42
|
-
city: Santa Monica
|
43
|
-
region_id: 3181
|
44
|
-
postal_code: 90401
|
45
|
-
created_at: <%= Time.now.to_s(:db) %>
|
46
|
-
updated_at: <%= Time.now.to_s(:db) %>
|
47
|
-
kind: sales
|
data/test/fixtures/companies.yml
DELETED
data/test/fixtures/countries.yml
DELETED
data/test/fixtures/regions.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../test_helper"
|
2
|
-
|
3
|
-
class HasAddresses < Test::Unit::TestCase
|
4
|
-
fixtures :companies, :addresses
|
5
|
-
|
6
|
-
def test_should_create_one_association
|
7
|
-
assert_equal addresses(:google_headquarters), companies(:google).headquarters_address
|
8
|
-
assert_equal addresses(:google_sales), companies(:google).sales_address
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_should_create_many_association
|
12
|
-
assert_equal 2, companies(:google).addresses.size
|
13
|
-
assert_equal [addresses(:google_headquarters), addresses(:google_sales)], companies(:google).addresses
|
14
|
-
end
|
15
|
-
end
|