addresses 0.0.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +9 -1
- data/app/controllers/addresses/cities_controller.rb +4 -4
- data/app/controllers/addresses/neighborhoods_controller.rb +4 -4
- data/app/models/addresses/address.rb +17 -17
- data/config/routes.rb +3 -4
- data/lib/addresses/engine.rb +4 -4
- data/lib/tasks/addresses_tasks.rake +4 -4
- data/lib/tasks/natal_city.rake +1 -1
- data/lib/tasks/populate_cities.rake +5566 -5566
- data/lib/tasks/populate_countries.rake +239 -239
- data/lib/tasks/populate_neighborhoods.rake +40819 -40819
- data/lib/tasks/populate_states.rake +28 -28
- data/spec/controllers/addresses/cities_controller_spec.rb +10 -19
- data/spec/controllers/addresses/neighborhoods_controller_spec.rb +11 -20
- data/spec/dummy/Gemfile.lock +77 -68
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/schema.rb +12 -16
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +2 -735
- data/spec/factories/addresses.rb +12 -0
- data/spec/factories/{addresses_cities.rb → cities.rb} +3 -3
- data/spec/factories/countries.rb +8 -0
- data/spec/factories/neighborhoods.rb +8 -0
- data/spec/factories/states.rb +9 -0
- data/spec/models/addresses/address_spec.rb +17 -3
- data/spec/models/addresses/city_spec.rb +4 -3
- data/spec/models/addresses/country_spec.rb +3 -3
- data/spec/models/addresses/neighborhood_spec.rb +3 -3
- data/spec/models/addresses/state_spec.rb +4 -3
- data/spec/requests/cities_spec.rb +14 -14
- data/spec/requests/neighborhoods_spec.rb +13 -16
- data/spec/routing/cities_routing_spec.rb +7 -6
- data/spec/routing/neighborhoods_routing_spec.rb +11 -0
- data/spec/spec_helper.rb +15 -6
- metadata +49 -32
- data/lib/addresses/version.rb +0 -3
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20140327205948_create_addresses_countries.addresses.rb +0 -13
- data/spec/dummy/db/migrate/20140327205949_create_addresses_states.addresses.rb +0 -14
- data/spec/dummy/db/migrate/20140327205950_create_addresses_cities.addresses.rb +0 -13
- data/spec/dummy/db/migrate/20140327205951_create_addresses_neighborhoods.addresses.rb +0 -13
- data/spec/dummy/db/migrate/20140328120544_create_addresses_addresses.addresses.rb +0 -17
- data/spec/factories/addresses_addresses.rb +0 -12
- data/spec/factories/addresses_countries.rb +0 -8
- data/spec/factories/addresses_neighborhoods.rb +0 -8
- data/spec/factories/addresses_states.rb +0 -9
@@ -0,0 +1,12 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :address, class: Addresses::Address do
|
5
|
+
street "Street name"
|
6
|
+
number "Number"
|
7
|
+
complement nil
|
8
|
+
association :city
|
9
|
+
association :neighborhood
|
10
|
+
zipcode "Zipcode"
|
11
|
+
end
|
12
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
2
|
|
3
3
|
FactoryGirl.define do
|
4
|
-
factory :
|
5
|
-
name "
|
6
|
-
state
|
4
|
+
factory :city, class: Addresses::City do
|
5
|
+
name "City name"
|
6
|
+
association :state
|
7
7
|
end
|
8
8
|
end
|
@@ -1,7 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
3
|
+
RSpec.describe Addresses::Address, type: :model do
|
4
|
+
describe 'validation' do
|
5
|
+
it { is_expected.to validate_presence_of(:zipcode) }
|
6
|
+
it { is_expected.to validate_presence_of(:number) }
|
7
|
+
it { is_expected.to validate_presence_of(:city_id) }
|
8
|
+
it { is_expected.to validate_presence_of(:state_id) }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'association' do
|
12
|
+
it { is_expected.to belong_to(:city) }
|
13
|
+
it { is_expected.to belong_to(:neighborhood) }
|
14
|
+
it { is_expected.to belong_to(:addressable) }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#to_s' do
|
18
|
+
let!(:address) { create :address }
|
19
|
+
it { expect(address.to_s).to eq("Street name, Number, Neighborhood name. City name - State acronym") }
|
6
20
|
end
|
7
21
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
3
|
+
RSpec.describe Addresses::City, :type => :model do
|
4
|
+
describe 'association' do
|
5
|
+
it { is_expected.to belong_to(:state) }
|
6
|
+
it { is_expected.to have_many(:neighborhoods) }
|
6
7
|
end
|
7
8
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
3
|
+
RSpec.describe Addresses::Neighborhood, :type => :model do
|
4
|
+
describe 'association' do
|
5
|
+
it { is_expected.to belong_to(:city) }
|
6
6
|
end
|
7
7
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
3
|
+
RSpec.describe Addresses::State, :type => :model do
|
4
|
+
describe 'association' do
|
5
|
+
it { is_expected.to belong_to(:country) }
|
6
|
+
it { is_expected.to have_many(:cities) }
|
6
7
|
end
|
7
8
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
|
-
describe Addresses::CitiesController do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
RSpec.describe Addresses::CitiesController, type: :request do
|
5
|
+
let!(:state) { create :state }
|
6
|
+
let!(:city) { create :city, state: state }
|
7
|
+
|
8
|
+
describe "GET /cities" do
|
9
|
+
before { get '/addresses/cities', params: { state_id: state.id, format: "json" } }
|
10
|
+
|
11
|
+
it "should return an interview" do
|
12
|
+
json = JSON.parse(response.body)
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
get addresses.cities_path(state_id: @state.id), format: "json"
|
14
|
-
json = JSON.parse(response.body)
|
15
|
-
json[0]["name"].should == @city.name
|
16
|
-
end
|
14
|
+
expect(response.status).to be(200)
|
15
|
+
expect(json[0]["name"]).to eq(city.name)
|
17
16
|
end
|
18
|
-
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,21 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Addresses::NeighborhoodsController do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
3
|
+
RSpec.describe Addresses::NeighborhoodsController, type: :request do
|
4
|
+
let!(:state) { create :state }
|
5
|
+
let!(:city) { create :city, state: state }
|
6
|
+
let!(:neighborhood) { create :neighborhood, city: city }
|
7
|
+
|
8
|
+
describe "GET /neighborhoods" do
|
9
|
+
before { get '/addresses/neighborhoods', params: { city_id: city.id, format: "json" } }
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
get addresses.neighborhoods_path(city_id: @city.id), format: "json"
|
15
|
-
|
16
|
-
json = JSON.parse(response.body)
|
11
|
+
it "should return an interview" do
|
12
|
+
json = JSON.parse(response.body)
|
17
13
|
|
18
|
-
|
19
|
-
|
14
|
+
expect(response.status).to be(200)
|
15
|
+
expect(json[0]["name"]).to eq(neighborhood.name)
|
20
16
|
end
|
21
|
-
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Addresses::CitiesController do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
RSpec.describe Addresses::CitiesController, type: :routing do
|
4
|
+
routes { Addresses::Engine.routes }
|
5
|
+
|
6
|
+
describe "routing" do
|
7
|
+
it "routes to #index" do
|
8
|
+
expect(:get => "/cities").to route_to("addresses/cities#index")
|
9
9
|
end
|
10
|
+
end
|
10
11
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Addresses::NeighborhoodsController, type: :routing do
|
4
|
+
routes { Addresses::Engine.routes }
|
5
|
+
|
6
|
+
describe "routing" do
|
7
|
+
it "routes to #index" do
|
8
|
+
expect(:get => "/neighborhoods").to route_to("addresses/neighborhoods#index")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,20 +1,29 @@
|
|
1
1
|
ENV['RAILS_ENV'] ||= 'test'
|
2
2
|
|
3
|
+
if ENV['RAILS_ENV'] == 'test'
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start 'rails'
|
6
|
+
puts "required simplecov"
|
7
|
+
end
|
8
|
+
|
3
9
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
10
|
+
|
4
11
|
require 'rspec/rails'
|
5
|
-
require 'rspec/autorun'
|
6
12
|
require 'factory_girl_rails'
|
13
|
+
require 'shoulda/matchers'
|
7
14
|
|
8
15
|
Rails.backtrace_cleaner.remove_silencers!
|
16
|
+
# Load support files
|
9
17
|
|
10
|
-
|
11
|
-
FactoryGirl.find_definitions
|
18
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f; }
|
12
19
|
|
13
|
-
# Load support files
|
14
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
15
20
|
RSpec.configure do |config|
|
16
21
|
config.mock_with :rspec
|
17
22
|
config.use_transactional_fixtures = true
|
18
23
|
config.infer_base_class_for_anonymous_controllers = false
|
24
|
+
config.include FactoryGirl::Syntax::Methods
|
19
25
|
config.order = "random"
|
20
|
-
|
26
|
+
|
27
|
+
config.include(Shoulda::Matchers::ActiveModel, type: :model)
|
28
|
+
config.include(Shoulda::Matchers::ActiveRecord, type: :model)
|
29
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: addresses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wilbert Ribeiro
|
8
|
-
-
|
8
|
+
- Joice Taciana
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-09-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -17,33 +17,61 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '5.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '5.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rspec-rails
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 3.5.2
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - '='
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 3.5.2
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: capybara
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.8.1
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.8.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: factory_girl_rails
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 4.7.0
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 4.7.0
|
42
70
|
description: Create Country, State, City, Neighborhood and a polymorphic model called
|
43
71
|
Address that can be related as addessable.
|
44
72
|
email:
|
45
73
|
- wkelyson@gmail.com
|
46
|
-
-
|
74
|
+
- joicetaciana@gmail.com
|
47
75
|
executables: []
|
48
76
|
extensions: []
|
49
77
|
extra_rdoc_files: []
|
@@ -73,7 +101,6 @@ files:
|
|
73
101
|
- db/migrate/20140328120418_create_addresses_addresses.rb
|
74
102
|
- lib/addresses.rb
|
75
103
|
- lib/addresses/engine.rb
|
76
|
-
- lib/addresses/version.rb
|
77
104
|
- lib/tasks/addresses_tasks.rake
|
78
105
|
- lib/tasks/natal_city.rake
|
79
106
|
- lib/tasks/populate_cities.rake
|
@@ -112,12 +139,6 @@ files:
|
|
112
139
|
- spec/dummy/config/locales/en.yml
|
113
140
|
- spec/dummy/config/locales/pt-BR.yml
|
114
141
|
- spec/dummy/config/routes.rb
|
115
|
-
- spec/dummy/db/development.sqlite3
|
116
|
-
- spec/dummy/db/migrate/20140327205948_create_addresses_countries.addresses.rb
|
117
|
-
- spec/dummy/db/migrate/20140327205949_create_addresses_states.addresses.rb
|
118
|
-
- spec/dummy/db/migrate/20140327205950_create_addresses_cities.addresses.rb
|
119
|
-
- spec/dummy/db/migrate/20140327205951_create_addresses_neighborhoods.addresses.rb
|
120
|
-
- spec/dummy/db/migrate/20140328120544_create_addresses_addresses.addresses.rb
|
121
142
|
- spec/dummy/db/schema.rb
|
122
143
|
- spec/dummy/db/test.sqlite3
|
123
144
|
- spec/dummy/log/development.log
|
@@ -126,11 +147,11 @@ files:
|
|
126
147
|
- spec/dummy/public/422.html
|
127
148
|
- spec/dummy/public/500.html
|
128
149
|
- spec/dummy/public/favicon.ico
|
129
|
-
- spec/factories/
|
130
|
-
- spec/factories/
|
131
|
-
- spec/factories/
|
132
|
-
- spec/factories/
|
133
|
-
- spec/factories/
|
150
|
+
- spec/factories/addresses.rb
|
151
|
+
- spec/factories/cities.rb
|
152
|
+
- spec/factories/countries.rb
|
153
|
+
- spec/factories/neighborhoods.rb
|
154
|
+
- spec/factories/states.rb
|
134
155
|
- spec/models/addresses/address_spec.rb
|
135
156
|
- spec/models/addresses/city_spec.rb
|
136
157
|
- spec/models/addresses/country_spec.rb
|
@@ -139,6 +160,7 @@ files:
|
|
139
160
|
- spec/requests/cities_spec.rb
|
140
161
|
- spec/requests/neighborhoods_spec.rb
|
141
162
|
- spec/routing/cities_routing_spec.rb
|
163
|
+
- spec/routing/neighborhoods_routing_spec.rb
|
142
164
|
- spec/spec_helper.rb
|
143
165
|
homepage: http://www.github.com/wilbert/addresses
|
144
166
|
licenses:
|
@@ -193,12 +215,6 @@ test_files:
|
|
193
215
|
- spec/dummy/config/locales/pt-BR.yml
|
194
216
|
- spec/dummy/config/routes.rb
|
195
217
|
- spec/dummy/config.ru
|
196
|
-
- spec/dummy/db/development.sqlite3
|
197
|
-
- spec/dummy/db/migrate/20140327205948_create_addresses_countries.addresses.rb
|
198
|
-
- spec/dummy/db/migrate/20140327205949_create_addresses_states.addresses.rb
|
199
|
-
- spec/dummy/db/migrate/20140327205950_create_addresses_cities.addresses.rb
|
200
|
-
- spec/dummy/db/migrate/20140327205951_create_addresses_neighborhoods.addresses.rb
|
201
|
-
- spec/dummy/db/migrate/20140328120544_create_addresses_addresses.addresses.rb
|
202
218
|
- spec/dummy/db/schema.rb
|
203
219
|
- spec/dummy/db/test.sqlite3
|
204
220
|
- spec/dummy/Gemfile
|
@@ -211,11 +227,11 @@ test_files:
|
|
211
227
|
- spec/dummy/public/favicon.ico
|
212
228
|
- spec/dummy/Rakefile
|
213
229
|
- spec/dummy/README.rdoc
|
214
|
-
- spec/factories/
|
215
|
-
- spec/factories/
|
216
|
-
- spec/factories/
|
217
|
-
- spec/factories/
|
218
|
-
- spec/factories/
|
230
|
+
- spec/factories/addresses.rb
|
231
|
+
- spec/factories/cities.rb
|
232
|
+
- spec/factories/countries.rb
|
233
|
+
- spec/factories/neighborhoods.rb
|
234
|
+
- spec/factories/states.rb
|
219
235
|
- spec/models/addresses/address_spec.rb
|
220
236
|
- spec/models/addresses/city_spec.rb
|
221
237
|
- spec/models/addresses/country_spec.rb
|
@@ -224,4 +240,5 @@ test_files:
|
|
224
240
|
- spec/requests/cities_spec.rb
|
225
241
|
- spec/requests/neighborhoods_spec.rb
|
226
242
|
- spec/routing/cities_routing_spec.rb
|
243
|
+
- spec/routing/neighborhoods_routing_spec.rb
|
227
244
|
- spec/spec_helper.rb
|
data/lib/addresses/version.rb
DELETED
Binary file
|