has_addresses 0.0.1
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 +19 -0
- data/MIT-LICENSE +20 -0
- data/README +111 -0
- data/Rakefile +82 -0
- data/app/models/address.rb +84 -0
- data/app/models/country.rb +114 -0
- data/app/models/region.rb +112 -0
- data/db/migrate/001_create_countries.rb +17 -0
- data/db/migrate/002_create_regions.rb +15 -0
- data/db/migrate/003_create_addresses.rb +21 -0
- data/init.rb +1 -0
- data/lib/has_addresses.rb +74 -0
- data/tasks/has_addresses_tasks.rake +23 -0
- data/test/app_root/app/models/company.rb +7 -0
- data/test/app_root/config/environment.rb +30 -0
- data/test/app_root/db/migrate/001_create_companies.rb +11 -0
- data/test/app_root/db/migrate/002_add_address_kinds.rb +9 -0
- data/test/app_root/test/fixtures/addresses.yml +47 -0
- data/test/app_root/test/fixtures/companies.yml +7 -0
- data/test/app_root/test/fixtures/countries.yml +12 -0
- data/test/app_root/test/fixtures/regions.yml +5 -0
- data/test/files/iso_3166.xml +1719 -0
- data/test/files/iso_3166_2.xml +8617 -0
- data/test/test_helper.rb +11 -0
- data/test/unit/address_test.rb +171 -0
- data/test/unit/country_test.rb +119 -0
- data/test/unit/has_addresses_test.rb +15 -0
- data/test/unit/region_test.rb +101 -0
- metadata +88 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
namespace :countries do
|
2
|
+
desc 'Generates a new fixtures file for the countries table'
|
3
|
+
task :create_fixtures => :environment do
|
4
|
+
Country.create_fixtures(ENV['OUTPUT'])
|
5
|
+
end
|
6
|
+
|
7
|
+
desc 'Bootstraps the countries table with the latest ISO 3166 standard'
|
8
|
+
task :bootstrap => :environment do
|
9
|
+
Country.bootstrap
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
namespace :regions do
|
14
|
+
desc 'Generates a new fixtures file for the regions table'
|
15
|
+
task :create_fixtures => :environment do
|
16
|
+
Region.create_fixtures(ENV['OUTPUT'])
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Bootstraps the regions table with the latest ISO 3166-2 standard'
|
20
|
+
task :bootstrap => :environment do
|
21
|
+
Region.bootstrap
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'config/boot'
|
2
|
+
|
3
|
+
$:.unshift("#{RAILS_ROOT}/../../../../../rails/plugin_dependencies/lib")
|
4
|
+
begin
|
5
|
+
require 'plugin_dependencies'
|
6
|
+
rescue
|
7
|
+
end
|
8
|
+
|
9
|
+
Rails::Initializer.run do |config|
|
10
|
+
config.log_level = :debug
|
11
|
+
config.cache_classes = false
|
12
|
+
config.whiny_nils = true
|
13
|
+
config.breakpoint_server = true
|
14
|
+
config.load_paths << "#{RAILS_ROOT}/../../lib"
|
15
|
+
|
16
|
+
config.plugin_paths.concat([
|
17
|
+
"#{RAILS_ROOT}/../../..",
|
18
|
+
"#{RAILS_ROOT}/../../../../migrations",
|
19
|
+
"#{RAILS_ROOT}/../../../../../rails",
|
20
|
+
"#{RAILS_ROOT}/../../../../../test"
|
21
|
+
])
|
22
|
+
config.plugins = [
|
23
|
+
File.basename(File.expand_path("#{RAILS_ROOT}/../..")),
|
24
|
+
'appable_plugins',
|
25
|
+
'plugin_migrations',
|
26
|
+
'dry_validity_assertions'
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
Dependencies.log_activity = true
|
@@ -0,0 +1,47 @@
|
|
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
|