has_addresses 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,7 @@
1
+ class Company < ActiveRecord::Base
2
+ has_address :headquarters_address,
3
+ :conditions => ['addresses.kind = ?', 'headquarters']
4
+ has_address :sales_address,
5
+ :conditions => ['addresses.kind = ?', 'sales']
6
+ has_addresses
7
+ 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,11 @@
1
+ class CreateCompanies < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :companies do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :companies
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class AddAddressKinds < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :addresses, :kind, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :addresses, :kind
8
+ end
9
+ end
@@ -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
@@ -0,0 +1,7 @@
1
+ abc_inc:
2
+ id: 1
3
+ name: Abc Inc.
4
+
5
+ google:
6
+ id: 2
7
+ name: Google
@@ -0,0 +1,12 @@
1
+ united_states:
2
+ id: 840
3
+ name: United States
4
+ official_name: United States of America
5
+ alpha_2_code: US
6
+ alpha_3_code: USA
7
+
8
+ canada:
9
+ id: 124
10
+ name: Canada
11
+ alpha_2_code: CA
12
+ alpha_3_code: CAN
@@ -0,0 +1,5 @@
1
+ california:
2
+ id: 3181
3
+ country_id: 840
4
+ name: California
5
+ abbreviation: CA