magic_addresses 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +37 -2
  3. data/app/models/magic_addresses/address.rb +3 -11
  4. data/app/models/magic_addresses/association.rb +35 -15
  5. data/app/models/magic_addresses/country.rb +5 -0
  6. data/app/models/magic_addresses/district.rb +4 -0
  7. data/app/models/magic_addresses/state.rb +4 -0
  8. data/app/models/magic_addresses/subdistrict.rb +2 -0
  9. data/lib/generators/magic_addresses/templates/magic_addresses_migration.rb +1 -10
  10. data/lib/generators/magic_addresses/templates/magic_initializer.rb +0 -2
  11. data/lib/helpers/mgca_helper.rb +6 -13
  12. data/lib/magic_addresses/configuration.rb +0 -2
  13. data/lib/magic_addresses/version.rb +1 -1
  14. data/spec/dummy/config/initializers/magic_addresses.rb +0 -2
  15. data/spec/dummy/db/development.sqlite3 +0 -0
  16. data/spec/dummy/db/migrate/{20150223223200_add_magic_addresses.rb → 20150225220219_add_magic_addresses.rb} +1 -10
  17. data/spec/dummy/db/schema.rb +1 -1
  18. data/spec/dummy/db/test.sqlite3 +0 -0
  19. data/spec/dummy/log/development.log +3729 -0
  20. data/spec/dummy/log/test.log +37882 -0
  21. data/spec/models/magic_addresses/address_spec.rb +171 -0
  22. data/spec/models/magic_addresses/association_spec.rb +93 -8
  23. metadata +4 -28
  24. data/app/models/concerns/address_builder.rb +0 -169
  25. data/app/models/concerns/has_address.rb +0 -67
  26. data/app/models/location/address.rb +0 -111
  27. data/app/models/location/city.rb +0 -39
  28. data/app/models/location/country.rb +0 -39
  29. data/app/models/location/district.rb +0 -37
  30. data/app/models/location/state.rb +0 -39
  31. data/app/models/location/subdistrict.rb +0 -38
  32. data/app/services/geo_coder.rb +0 -46
  33. data/lib/generators/magic_addresses/templates/location_addresses_migration.rb +0 -157
  34. data/spec/models/concerns/has_address_spec.rb +0 -92
  35. data/spec/models/location/address_spec.rb +0 -227
  36. data/spec/models/location/city_spec.rb +0 -27
  37. data/spec/models/location/country_spec.rb +0 -26
  38. data/spec/models/location/state_spec.rb +0 -27
  39. data/spec/models/location/subcity_spec.rb +0 -26
  40. data/spec/models/location/subsubcity_spec.rb +0 -27
@@ -1,227 +0,0 @@
1
- # => require 'spec_helper'
2
- # =>
3
- # => describe Location::Address do
4
- # =>
5
- # => describe 'should have usual attributes' do
6
- # => it { should respond_to :name }
7
- # =>
8
- # => it { should respond_to :street_default }
9
- # =>
10
- # => it { should respond_to :street }
11
- # =>
12
- # => it { should respond_to :translations }
13
- # => # it { should respond_to :translations_attributes }
14
- # =>
15
- # => it { should respond_to :street_number }
16
- # => it { should respond_to :street_additional }
17
- # => it { should respond_to :zipcode }
18
- # =>
19
- # => it { should respond_to :city }
20
- # => it { should respond_to :district }
21
- # => it { should respond_to :state }
22
- # => it { should respond_to :country }
23
- # =>
24
- # => it { should respond_to :latitude }
25
- # => it { should respond_to :longitude }
26
- # =>
27
- # => it { should respond_to :visibility }
28
- # => it { should respond_to :default }
29
- # =>
30
- # => it { should respond_to :owner }
31
- # => end
32
- # =>
33
- # => # => describe 'validations' do
34
- # => # => it { should validate_presence_of :city }
35
- # => # => end
36
- # =>
37
- # => describe 'attribute changes' do
38
- # => before(:each) do
39
- # => # Wizard::Locale.where(iso_code: "en").first.do_transition!( :activate )
40
- # => # Wizard::Locale.where(iso_code: "de").first.do_transition!( :activate )
41
- # => # I18n.available_locales.each do |lc|
42
- # => [:en, :de, :it].each do |lc|
43
- # => Wizard::Locale.create!(iso_code: lc.to_s, locale_state: "active")
44
- # => end
45
- # => @address = Location::Address.new( )
46
- # => end
47
- # =>
48
- # => it 'saves address childs correct' do
49
- # => expect( Location::Country.count ).to eq 0
50
- # => expect( Location::State.count ).to eq 0
51
- # => expect( Location::City.count ).to eq 0
52
- # => expect( Location::District.count ).to eq 0
53
- # => expect( Location::Subdistrict.count ).to eq 0
54
- # =>
55
- # => # expect( I18n.available_locales.count ).to eq 2
56
- # => expect( ::Wizard::Locale.count ).to eq 3
57
- # =>
58
- # => @address.address = "Heinz-Kapelle-Str. 6 10407 Berlin"
59
- # =>
60
- # => # puts @address.translations_attributes.to_yaml
61
- # =>
62
- # => expect( @address.street ).to be nil
63
- # =>
64
- # => @address.save
65
- # =>
66
- # => expect( Location::Country.count ).to eq 1
67
- # => expect( Location::State.count ).to eq 1
68
- # => expect( Location::City.count ).to eq 1
69
- # => expect( Location::District.count ).to eq 1
70
- # => expect( Location::Subdistrict.count ).to eq 1
71
- # =>
72
- # => # trigger background task
73
- # => @address.build_association_translations
74
- # =>
75
- # => expect( @address.city.name(:en) ).to eq ("Berlin")
76
- # => expect( @address.city.name(:it) ).to eq ("Berlino")
77
- # =>
78
- # => expect( @address.subdistrict.name(:en) ).to eq ("Prenzlauer Berg")
79
- # => expect( @address.district.name(:en) ).to eq ("Pankow")
80
- # =>
81
- # => expect( @address.country.name(:en) ).to eq ("Germany")
82
- # => expect( @address.country.name(:de) ).to eq ("Deutschland")
83
- # =>
84
- # => expect( @address.street_number ).to eq ("6")
85
- # =>
86
- # => # expect( @address.translations.count ).to eq 3
87
- # => # new model only saves stuff when different than english!
88
- # => expect( @address.translations.count ).to eq 1
89
- # =>
90
- # => # puts @address.translations.map{ |t| "'#{t.street}'"}
91
- # =>
92
- # => Rails.application.config.i18n.fallbacks = true
93
- # => expect( @address.street(:en) ).to eq ("Heinz-Kapelle-Straße")
94
- # => expect( @address.street(:de) ).to eq ("Heinz-Kapelle-Straße")
95
- # =>
96
- # => end
97
- # =>
98
- # => it 'saves street languages correct' do
99
- # => I18n.locale = "de"
100
- # => @address.street = "Sesam Str."
101
- # => I18n.locale = "en"
102
- # => @address.street = "Sesamstreet"
103
- # => @address.save
104
- # =>
105
- # => expect( @address.street(:en) ).to eq ("Sesamstreet")
106
- # => expect( @address.street(:de) ).to eq ("Sesam Str.")
107
- # => end
108
- # =>
109
- # => it 'saves from values correct', sidekiq: :fake do
110
- # => @address.street_name = "Heinz-Kapelle-Str."
111
- # => @address.street_number = "6"
112
- # => @address.city_name = "Berlin"
113
- # => @address.zipcode = "10407"
114
- # => @address.country_name = "Deutschland"
115
- # =>
116
- # =>
117
- # => expect( AddressWorker.jobs.size ).to eq 0
118
- # =>
119
- # => # => expect {
120
- # => # => @address.save
121
- # => # => sleep 1
122
- # => # => }.to change(AddressWorker.jobs, :size).by(1)
123
- # =>
124
- # => expect( AddressWorker ).to receive(:perform_async).with( 1 )
125
- # => @address.save
126
- # =>
127
- # => # expect( AddressWorker.jobs.size ).to eq 1
128
- # =>
129
- # => # AddressWorker.should have_queued_job(1)
130
- # =>
131
- # => # => expect(AddressWorker).to have_enqueued_job( @address.id )
132
- # => #expect(AddressWorker).to have_enqueued_job( @address.id, true )
133
- # => # AddressWorker.should_receive(:perform_async).with( @address.id )
134
- # =>
135
- # =>
136
- # =>
137
- # =>
138
- # => expect( @address.fetch_address ).to eq ("Heinz-Kapelle-Str. 6 Berlin 10407 Deutschland")
139
- # =>
140
- # => # trigger background task
141
- # => @address.build_association_translations
142
- # =>
143
- # => expect( @address.city.name(:en) ).to eq ("Berlin")
144
- # => expect( @address.city.name(:it) ).to eq ("Berlino")
145
- # =>
146
- # => expect( @address.subdistrict.name(:en) ).to eq ("Prenzlauer Berg")
147
- # => expect( @address.district.name(:en) ).to eq ("Pankow")
148
- # =>
149
- # => expect( @address.country.name(:en) ).to eq ("Germany")
150
- # => expect( @address.country.name(:de) ).to eq ("Deutschland")
151
- # =>
152
- # => end
153
- # =>
154
- # =>
155
- # => it 'saves right connections' do
156
- # =>
157
- # => expect( Location::Country.count ).to eq 0
158
- # => expect( Location::State.count ).to eq 0
159
- # => expect( Location::City.count ).to eq 0
160
- # => expect( Location::District.count ).to eq 0
161
- # => expect( Location::Subdistrict.count ).to eq 0
162
- # =>
163
- # => @address.address = "Heinz-Kapelle-Str. 6 10407 Berlin DE"
164
- # => @address.save
165
- # => sleep 1
166
- # => # trigger background task
167
- # => @address.build_association_translations
168
- # =>
169
- # => @address2 = Location::Address.new( )
170
- # => @address2.address = "Grünbergerstr. 60 10245 berlin DE"
171
- # => @address2.save
172
- # => sleep 1
173
- # => # trigger background task
174
- # => @address2.build_association_translations
175
- # =>
176
- # => @address3 = Location::Address.new( )
177
- # => @address3.address = "Josef-orlopp-str. 54 Berlin 10365 DE"
178
- # => @address3.save
179
- # => sleep 1
180
- # => # trigger background task
181
- # => @address3.build_association_translations
182
- # =>
183
- # => expect( Location::Country.count ).to eq 1
184
- # => expect( Location::State.count ).to eq 1
185
- # => expect( Location::City.count ).to eq 1
186
- # => expect( Location::District.count ).to eq 3
187
- # => expect( Location::Subdistrict.count ).to eq 3
188
- # =>
189
- # =>
190
- # => expect( Location::City.first.name ).to eq "Berlin"
191
- # =>
192
- # => # only save translation when different to "en"
193
- # => # de: "Berlin"
194
- # => # en: "Berlin"
195
- # => # it: "Berlino"
196
- # => expect( Location::City.first.translations.count ).to eq 2
197
- # =>
198
- # => expect( @address.translations.count ).to eq 1
199
- # => expect( @address2.translations.count ).to eq 1
200
- # => expect( @address3.translations.count ).to eq 1
201
- # =>
202
- # => I18n.locale = "de"
203
- # =>
204
- # => expect( @address.city! ).to eq "Berlin"
205
- # => expect( @address2.city! ).to eq "Berlin"
206
- # => expect( @address3.city! ).to eq "Berlin"
207
- # =>
208
- # => I18n.locale = "en"
209
- # =>
210
- # => expect( @address.city! ).to eq "Berlin"
211
- # => expect( @address2.city! ).to eq "Berlin"
212
- # => expect( @address3.city! ).to eq "Berlin"
213
- # =>
214
- # => I18n.locale = "it"
215
- # =>
216
- # => expect( @address.city! ).to eq "Berlino"
217
- # => expect( @address2.city! ).to eq "Berlino"
218
- # => expect( @address3.city! ).to eq "Berlino"
219
- # =>
220
- # =>
221
- # => end
222
- # =>
223
- # =>
224
- # => end
225
- # =>
226
- # => end
227
- # =>
@@ -1,27 +0,0 @@
1
- # => require 'spec_helper'
2
- # =>
3
- # => describe Location::City do
4
- # =>
5
- # => describe 'should have usual attributes' do
6
- # =>
7
- # => it { should respond_to :name_default }
8
- # => it { should respond_to :name }
9
- # =>
10
- # => it { should respond_to :fsm_state }
11
- # =>
12
- # => it { should respond_to :state }
13
- # => it { should respond_to :country }
14
- # =>
15
- # => it { should respond_to :addresses }
16
- # =>
17
- # => it { should respond_to :translations }
18
- # => # it { should respond_to :translations_attributes }
19
- # =>
20
- # => end
21
- # =>
22
- # => # => describe 'validations' do
23
- # => # => it { should validate_presence_of :city }
24
- # => # => end
25
- # =>
26
- # => end
27
- # =>
@@ -1,26 +0,0 @@
1
- # => require 'spec_helper'
2
- # =>
3
- # => describe Location::Country do
4
- # =>
5
- # => describe 'should have usual attributes' do
6
- # =>
7
- # => it { should respond_to :name_default }
8
- # => it { should respond_to :name }
9
- # =>
10
- # => it { should respond_to :iso_code }
11
- # =>
12
- # => it { should respond_to :fsm_state }
13
- # =>
14
- # => it { should respond_to :addresses }
15
- # =>
16
- # => it { should respond_to :translations }
17
- # => # it { should respond_to :translations_attributes }
18
- # =>
19
- # => end
20
- # =>
21
- # => # => describe 'validations' do
22
- # => # => it { should validate_presence_of :city }
23
- # => # => end
24
- # =>
25
- # => end
26
- # =>
@@ -1,27 +0,0 @@
1
- # => require 'spec_helper'
2
- # =>
3
- # => describe Location::State do
4
- # =>
5
- # => describe 'should have usual attributes' do
6
- # =>
7
- # => it { should respond_to :name_default }
8
- # => it { should respond_to :short_name }
9
- # => it { should respond_to :name }
10
- # =>
11
- # => it { should respond_to :fsm_state }
12
- # =>
13
- # => it { should respond_to :country }
14
- # =>
15
- # => it { should respond_to :addresses }
16
- # =>
17
- # => it { should respond_to :translations }
18
- # => # it { should respond_to :translations_attributes }
19
- # =>
20
- # => end
21
- # =>
22
- # => # => describe 'validations' do
23
- # => # => it { should validate_presence_of :city }
24
- # => # => end
25
- # =>
26
- # => end
27
- # =>
@@ -1,26 +0,0 @@
1
- # => require 'spec_helper'
2
- # =>
3
- # => describe Location::District do
4
- # =>
5
- # => describe 'should have usual attributes' do
6
- # =>
7
- # => it { should respond_to :name_default }
8
- # => it { should respond_to :name }
9
- # =>
10
- # => it { should respond_to :fsm_state }
11
- # =>
12
- # => it { should respond_to :city }
13
- # =>
14
- # => it { should respond_to :addresses }
15
- # =>
16
- # => it { should respond_to :translations }
17
- # => # it { should respond_to :translations_attributes }
18
- # =>
19
- # => end
20
- # =>
21
- # => # => describe 'validations' do
22
- # => # => it { should validate_presence_of :city }
23
- # => # => end
24
- # =>
25
- # => end
26
- # =>
@@ -1,27 +0,0 @@
1
- # => require 'spec_helper'
2
- # =>
3
- # => describe Location::Subdistrict do
4
- # =>
5
- # => describe 'should have usual attributes' do
6
- # =>
7
- # => it { should respond_to :name_default }
8
- # => it { should respond_to :name }
9
- # =>
10
- # => it { should respond_to :fsm_state }
11
- # =>
12
- # => it { should respond_to :city }
13
- # => it { should respond_to :district }
14
- # =>
15
- # => it { should respond_to :addresses }
16
- # =>
17
- # => it { should respond_to :translations }
18
- # => # it { should respond_to :translations_attributes }
19
- # =>
20
- # => end
21
- # =>
22
- # => # => describe 'validations' do
23
- # => # => it { should validate_presence_of :city }
24
- # => # => end
25
- # =>
26
- # => end
27
- # =>