geopolitical 3.0.0 → 3.2.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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +37 -0
- data/README.md +152 -73
- data/app/controllers/geopolitical/application_controller.rb +8 -0
- data/app/controllers/geopolitical/cities_controller.rb +57 -0
- data/app/controllers/geopolitical/geopolitical_controller.rb +19 -0
- data/app/controllers/geopolitical/hoods_controller.rb +56 -0
- data/app/controllers/geopolitical/nations_controller.rb +51 -0
- data/app/controllers/geopolitical/regions_controller.rb +56 -0
- data/app/helpers/geopolitical/application_helper.rb +2 -0
- data/app/models/city.rb +150 -48
- data/app/models/concerns/geopolitocracy.rb +121 -34
- data/app/models/hood.rb +44 -18
- data/app/models/nation.rb +97 -17
- data/app/models/region.rb +44 -14
- data/app/views/geopolitical/cities/_city.html.haml +2 -5
- data/app/views/geopolitical/cities/_form.html.haml +25 -28
- data/app/views/geopolitical/cities/edit.html.haml +1 -0
- data/app/views/geopolitical/cities/index.html.haml +17 -20
- data/app/views/geopolitical/cities/new.html.haml +1 -0
- data/app/views/geopolitical/cities/show.html.haml +7 -7
- data/app/views/geopolitical/geopolitical/index.html.haml +7 -9
- data/app/views/geopolitical/hoods/_city.html.haml +2 -5
- data/app/views/geopolitical/hoods/_form.html.haml +21 -22
- data/app/views/geopolitical/hoods/edit.html.haml +1 -0
- data/app/views/geopolitical/hoods/index.html.haml +13 -18
- data/app/views/geopolitical/hoods/new.html.haml +1 -0
- data/app/views/geopolitical/hoods/show.html.haml +5 -5
- data/app/views/geopolitical/nations/_form.html.haml +11 -8
- data/app/views/geopolitical/nations/_nation.html.haml +5 -0
- data/app/views/geopolitical/nations/edit.html.haml +1 -0
- data/app/views/geopolitical/nations/index.html.haml +16 -20
- data/app/views/geopolitical/nations/new.html.haml +1 -0
- data/app/views/geopolitical/nations/show.html.haml +7 -7
- data/app/views/geopolitical/regions/_form.html.haml +10 -8
- data/app/views/geopolitical/regions/_region.html.haml +2 -5
- data/app/views/geopolitical/regions/edit.html.haml +1 -0
- data/app/views/geopolitical/regions/index.html.haml +12 -15
- data/app/views/geopolitical/regions/new.html.haml +1 -0
- data/app/views/geopolitical/regions/show.html.haml +5 -5
- data/app/views/layouts/geopolitical.html.haml +13 -15
- data/config/locales/geopolitical.en.yml +76 -0
- data/config/locales/geopolitical.pt.yml +77 -0
- data/geopolitical.gemspec +14 -12
- data/lib/geopolitical/engine.rb +3 -0
- data/lib/geopolitical/version.rb +3 -2
- data/lib/geopolitical.rb +23 -3
- metadata +47 -118
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -11
- data/.rspec +0 -1
- data/.travis.yml +0 -26
- data/Gemfile +0 -15
- data/Guardfile +0 -24
- data/Rakefile +0 -25
- data/app/serializers/city_serializer.rb +0 -8
- data/app/serializers/nation_serializer.rb +0 -4
- data/app/serializers/region_serializer.rb +0 -4
- data/bin/rails +0 -8
- data/lib/tasks/geopolitical_tasks.rake +0 -4
- data/spec/dummy/README.rdoc +0 -28
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/config/application.rb +0 -27
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -29
- data/spec/dummy/config/environments/production.rb +0 -80
- data/spec/dummy/config/environments/test.rb +0 -36
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -12
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/mongoid.yml +0 -63
- data/spec/dummy/config/routes.rb +0 -56
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +0 -23532
- data/spec/dummy/public/404.html +0 -58
- data/spec/dummy/public/422.html +0 -58
- data/spec/dummy/public/500.html +0 -57
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/fabricators/city_fabricator.rb +0 -6
- data/spec/fabricators/hood_fabricator.rb +0 -5
- data/spec/fabricators/nation_fabricator.rb +0 -4
- data/spec/fabricators/region_fabricator.rb +0 -5
- data/spec/models/city_spec.rb +0 -158
- data/spec/models/hood_spec.rb +0 -47
- data/spec/models/nation_spec.rb +0 -53
- data/spec/models/region_spec.rb +0 -20
- data/spec/spec_helper.rb +0 -57
data/spec/dummy/public/404.html
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
-
<style>
|
|
6
|
-
body {
|
|
7
|
-
background-color: #EFEFEF;
|
|
8
|
-
color: #2E2F30;
|
|
9
|
-
text-align: center;
|
|
10
|
-
font-family: arial, sans-serif;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
div.dialog {
|
|
14
|
-
width: 25em;
|
|
15
|
-
margin: 4em auto 0 auto;
|
|
16
|
-
border: 1px solid #CCC;
|
|
17
|
-
border-right-color: #999;
|
|
18
|
-
border-left-color: #999;
|
|
19
|
-
border-bottom-color: #BBB;
|
|
20
|
-
border-top: #B00100 solid 4px;
|
|
21
|
-
border-top-left-radius: 9px;
|
|
22
|
-
border-top-right-radius: 9px;
|
|
23
|
-
background-color: white;
|
|
24
|
-
padding: 7px 4em 0 4em;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
h1 {
|
|
28
|
-
font-size: 100%;
|
|
29
|
-
color: #730E15;
|
|
30
|
-
line-height: 1.5em;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
body > p {
|
|
34
|
-
width: 33em;
|
|
35
|
-
margin: 0 auto 1em;
|
|
36
|
-
padding: 1em 0;
|
|
37
|
-
background-color: #F7F7F7;
|
|
38
|
-
border: 1px solid #CCC;
|
|
39
|
-
border-right-color: #999;
|
|
40
|
-
border-bottom-color: #999;
|
|
41
|
-
border-bottom-left-radius: 4px;
|
|
42
|
-
border-bottom-right-radius: 4px;
|
|
43
|
-
border-top-color: #DADADA;
|
|
44
|
-
color: #666;
|
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
|
46
|
-
}
|
|
47
|
-
</style>
|
|
48
|
-
</head>
|
|
49
|
-
|
|
50
|
-
<body>
|
|
51
|
-
<!-- This file lives in public/404.html -->
|
|
52
|
-
<div class="dialog">
|
|
53
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
|
54
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
|
55
|
-
</div>
|
|
56
|
-
<p>If you are the application owner check the logs for more information.</p>
|
|
57
|
-
</body>
|
|
58
|
-
</html>
|
data/spec/dummy/public/422.html
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
|
5
|
-
<style>
|
|
6
|
-
body {
|
|
7
|
-
background-color: #EFEFEF;
|
|
8
|
-
color: #2E2F30;
|
|
9
|
-
text-align: center;
|
|
10
|
-
font-family: arial, sans-serif;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
div.dialog {
|
|
14
|
-
width: 25em;
|
|
15
|
-
margin: 4em auto 0 auto;
|
|
16
|
-
border: 1px solid #CCC;
|
|
17
|
-
border-right-color: #999;
|
|
18
|
-
border-left-color: #999;
|
|
19
|
-
border-bottom-color: #BBB;
|
|
20
|
-
border-top: #B00100 solid 4px;
|
|
21
|
-
border-top-left-radius: 9px;
|
|
22
|
-
border-top-right-radius: 9px;
|
|
23
|
-
background-color: white;
|
|
24
|
-
padding: 7px 4em 0 4em;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
h1 {
|
|
28
|
-
font-size: 100%;
|
|
29
|
-
color: #730E15;
|
|
30
|
-
line-height: 1.5em;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
body > p {
|
|
34
|
-
width: 33em;
|
|
35
|
-
margin: 0 auto 1em;
|
|
36
|
-
padding: 1em 0;
|
|
37
|
-
background-color: #F7F7F7;
|
|
38
|
-
border: 1px solid #CCC;
|
|
39
|
-
border-right-color: #999;
|
|
40
|
-
border-bottom-color: #999;
|
|
41
|
-
border-bottom-left-radius: 4px;
|
|
42
|
-
border-bottom-right-radius: 4px;
|
|
43
|
-
border-top-color: #DADADA;
|
|
44
|
-
color: #666;
|
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
|
46
|
-
}
|
|
47
|
-
</style>
|
|
48
|
-
</head>
|
|
49
|
-
|
|
50
|
-
<body>
|
|
51
|
-
<!-- This file lives in public/422.html -->
|
|
52
|
-
<div class="dialog">
|
|
53
|
-
<h1>The change you wanted was rejected.</h1>
|
|
54
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
55
|
-
</div>
|
|
56
|
-
<p>If you are the application owner check the logs for more information.</p>
|
|
57
|
-
</body>
|
|
58
|
-
</html>
|
data/spec/dummy/public/500.html
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
-
<style>
|
|
6
|
-
body {
|
|
7
|
-
background-color: #EFEFEF;
|
|
8
|
-
color: #2E2F30;
|
|
9
|
-
text-align: center;
|
|
10
|
-
font-family: arial, sans-serif;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
div.dialog {
|
|
14
|
-
width: 25em;
|
|
15
|
-
margin: 4em auto 0 auto;
|
|
16
|
-
border: 1px solid #CCC;
|
|
17
|
-
border-right-color: #999;
|
|
18
|
-
border-left-color: #999;
|
|
19
|
-
border-bottom-color: #BBB;
|
|
20
|
-
border-top: #B00100 solid 4px;
|
|
21
|
-
border-top-left-radius: 9px;
|
|
22
|
-
border-top-right-radius: 9px;
|
|
23
|
-
background-color: white;
|
|
24
|
-
padding: 7px 4em 0 4em;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
h1 {
|
|
28
|
-
font-size: 100%;
|
|
29
|
-
color: #730E15;
|
|
30
|
-
line-height: 1.5em;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
body > p {
|
|
34
|
-
width: 33em;
|
|
35
|
-
margin: 0 auto 1em;
|
|
36
|
-
padding: 1em 0;
|
|
37
|
-
background-color: #F7F7F7;
|
|
38
|
-
border: 1px solid #CCC;
|
|
39
|
-
border-right-color: #999;
|
|
40
|
-
border-bottom-color: #999;
|
|
41
|
-
border-bottom-left-radius: 4px;
|
|
42
|
-
border-bottom-right-radius: 4px;
|
|
43
|
-
border-top-color: #DADADA;
|
|
44
|
-
color: #666;
|
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
|
46
|
-
}
|
|
47
|
-
</style>
|
|
48
|
-
</head>
|
|
49
|
-
|
|
50
|
-
<body>
|
|
51
|
-
<!-- This file lives in public/500.html -->
|
|
52
|
-
<div class="dialog">
|
|
53
|
-
<h1>We're sorry, but something went wrong.</h1>
|
|
54
|
-
</div>
|
|
55
|
-
<p>If you are the application owner check the logs for more information.</p>
|
|
56
|
-
</body>
|
|
57
|
-
</html>
|
|
File without changes
|
data/spec/models/city_spec.rb
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
describe City, type: :model do
|
|
5
|
-
it 'should create a city' do
|
|
6
|
-
expect { City.make! }.not_to raise_error
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it 'should accept some params and utf8' do
|
|
10
|
-
city = City.make(name: 'Patópolis', slug: 'patopolis', souls: 100_000)
|
|
11
|
-
expect(city).to be_valid
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it 'should create it\'s own slug' do
|
|
15
|
-
city = City.create(name: 'Patópolis', souls: 100_000)
|
|
16
|
-
expect(city.slug).to eq('patopolis')
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'should avoid dots it\'s own slug' do
|
|
20
|
-
expect(City.create(name: 'Mte. Sto. de MG').slug).to eq('mte-sto-de-mg')
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'should append region abbr if it\'s a dup' do
|
|
24
|
-
sp = Region.make(abbr: 'SP')
|
|
25
|
-
mg = Region.make(abbr: 'MG')
|
|
26
|
-
city1 = City.create(name: 'Patópolis', souls: 100_000, region: sp)
|
|
27
|
-
expect(city1.slug).to eq('patopolis')
|
|
28
|
-
city2 = City.create(name: 'Patópolis', souls: 100_000, region: mg)
|
|
29
|
-
expect(city2.slug).to eq('patopolis-mg')
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'should accept area phone code modified regex' do
|
|
33
|
-
expect(City.make(phone: '3555XXXX')).to be_valid
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'should accept area postal code modified regex' do
|
|
37
|
-
expect(City.make(postal: '15123XXX')).to be_valid
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'should be searchable' do
|
|
41
|
-
city = City.make!(name: 'São Paulo')
|
|
42
|
-
expect(City.search('sao paulo').first).to eq(city)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it 'should print nicely in #to_s' do
|
|
46
|
-
city = City.make(name: 'Ibitim', region: Region.make(abbr: 'MG'))
|
|
47
|
-
expect(city.to_s).to eq('Ibitim/MG')
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'should print nicely in #to_s' do
|
|
51
|
-
region = Region.make(name: 'Acre', abbr: nil)
|
|
52
|
-
city = City.make(name: 'Ibitim', region: region)
|
|
53
|
-
expect(city.to_s).to eq('Ibitim/Acre')
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it 'should print nicely in #with_region' do
|
|
57
|
-
region = Region.make(name: 'Acre', abbr: 'AC')
|
|
58
|
-
city = City.make(name: 'Ibitim', region: region)
|
|
59
|
-
expect(city.to_s).to eq('Ibitim/AC')
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it 'should print nicely #with_nation' do
|
|
63
|
-
nation = Nation.make(abbr: 'BR')
|
|
64
|
-
region = Region.make(abbr: 'MG', nation: nation)
|
|
65
|
-
city = City.make(name: 'Ibitim', region: region, nation: nation)
|
|
66
|
-
expect(city.with_nation).to eq('Ibitim/MG/BR')
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
describe 'instance' do
|
|
70
|
-
let(:nation) { Nation.make! }
|
|
71
|
-
let(:city) { City.make! }
|
|
72
|
-
|
|
73
|
-
it 'should belongs to nation' do
|
|
74
|
-
city.nation = nation
|
|
75
|
-
expect(city.save).to be_truthy
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it 'should belongs to region' do
|
|
79
|
-
city.nation = nation
|
|
80
|
-
expect(city.save).to be_truthy
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
describe 'geoenabled' do
|
|
85
|
-
before do
|
|
86
|
-
City.create_indexes
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it 'should find closest one' do
|
|
90
|
-
city = City.make!
|
|
91
|
-
expect(City.nearby(city.geom).first).to eql(city)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
describe 'validations' do
|
|
96
|
-
it 'should have a name' do
|
|
97
|
-
expect(City.new(name: '')).not_to be_valid
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
describe 'sorting' do
|
|
102
|
-
let(:cities) do
|
|
103
|
-
[City.make!(name: 'Abadia', souls: 500),
|
|
104
|
-
City.make!(name: 'Xangrilá', souls: 5000)]
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
it 'should sort by name' do
|
|
108
|
-
expect(City.ordered).to eq cities
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it 'should sort by pop' do
|
|
112
|
-
expect(City.population).to eq cities.reverse
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# it { should have_indices :name, :geom, :area, [:region_id, :nation_id] }
|
|
118
|
-
|
|
119
|
-
# it 'should accept an area' do
|
|
120
|
-
# @city = City.make(:area => Polygon.from_coordinates([
|
|
121
|
-
# [[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]]))
|
|
122
|
-
# @city.area.should be_instance_of(Polygon)
|
|
123
|
-
# end
|
|
124
|
-
|
|
125
|
-
# describe 'some helpers' do
|
|
126
|
-
# it 'should have some nice x y z' do
|
|
127
|
-
# @city = City.make
|
|
128
|
-
# @city.should respond_to(:x,:y,:z)
|
|
129
|
-
# end
|
|
130
|
-
# end
|
|
131
|
-
|
|
132
|
-
# describe 'Find by proximity' do
|
|
133
|
-
|
|
134
|
-
# def pt(x,y); Point.from_x_y(x,y); end
|
|
135
|
-
|
|
136
|
-
# before(:each) do
|
|
137
|
-
# @perto = City.make!(:geom => pt(10,10))
|
|
138
|
-
# @medio = City.make!(:geom => pt(20,20))
|
|
139
|
-
# @longe = City.make!(:geom => pt(30,30))
|
|
140
|
-
# @ponto = pt(12,12)
|
|
141
|
-
# end
|
|
142
|
-
|
|
143
|
-
# it 'should find the closest city' do
|
|
144
|
-
# @city = City.close_to(@ponto).first
|
|
145
|
-
# @city.should eql(@perto)
|
|
146
|
-
# end
|
|
147
|
-
|
|
148
|
-
# it 'should find the closest city to make sure' do
|
|
149
|
-
# ponto = pt(22,22)
|
|
150
|
-
# @city = City.close_to(ponto).first
|
|
151
|
-
# @city.should eql(@medio)
|
|
152
|
-
# end
|
|
153
|
-
|
|
154
|
-
# it 'should find the closest' do
|
|
155
|
-
# @poi = City.close_to(@ponto).first(2)
|
|
156
|
-
# @poi.should eql([@perto,@medio])
|
|
157
|
-
# end
|
|
158
|
-
# end
|
data/spec/models/hood_spec.rb
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Hood, type: :model do
|
|
4
|
-
it 'should create a nation' do
|
|
5
|
-
expect { Hood.make! }.not_to raise_error
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it 'should belong to city' do
|
|
9
|
-
expect(Hood.make(city: nil)).to_not be_valid
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'should not to city' do
|
|
13
|
-
expect(Hood.make(city: nil)).to_not be_valid
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'should have a name' do
|
|
17
|
-
expect(Hood.make(name: '')).to_not be_valid
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'should have a name' do
|
|
21
|
-
expect(Hood.make(name: nil)).to_not be_valid
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'should have city slug' do
|
|
25
|
-
city = City.make!(name: 'Gotham')
|
|
26
|
-
hood = Hood.make(name: 'JD. ITALIA', city: city).tap(&:save)
|
|
27
|
-
expect(hood.slug).to eq('gotham-jd-italia')
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'should titleize name' do
|
|
31
|
-
expect(Hood.make(name: 'JD. ITALIA').name).to eq('Jd. Italia')
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it 'should not have dup name in city' do
|
|
35
|
-
city = City.make!(name: 'Gotham')
|
|
36
|
-
expect(Hood.make!(name: 'Bowery', city: city)).to be_valid
|
|
37
|
-
expect(Hood.make(name: 'Bowery', city: city)).to_not be_valid
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'should accept area phone code modified regex' do
|
|
41
|
-
expect(Hood.make(phone: '115555XXXX')).to be_valid
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'should accept area postal code modified regex' do
|
|
45
|
-
expect(Hood.make(postal: '15123123')).to be_valid
|
|
46
|
-
end
|
|
47
|
-
end
|
data/spec/models/nation_spec.rb
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Nation, type: :model do
|
|
4
|
-
it 'should create a nation' do
|
|
5
|
-
expect { Nation.make! }.not_to raise_error
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it 'should require an abbr' do
|
|
9
|
-
expect(Nation.make(abbr: nil)).to_not be_valid
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'should assign upcase abbr' do
|
|
13
|
-
expect(Nation.make!(abbr: 'br').abbr).to eq('BR')
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'should validates uniqueness of abbr' do
|
|
17
|
-
Nation.make!(abbr: 'BR')
|
|
18
|
-
expect(Nation.make(abbr: 'BR')).to_not be_valid
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'should have abbr as _id' do
|
|
22
|
-
Nation.make!(abbr: 'BR')
|
|
23
|
-
expect(Nation.first[:_id]).to eq('BR')
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'should have langs' do
|
|
27
|
-
Nation.make!(abbr: 'BR', langs: %w(pt-BR es en))
|
|
28
|
-
expect(Nation.first.langs.join(',')).to eq('pt-BR,es,en')
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'should have lang' do
|
|
32
|
-
Nation.make!(abbr: 'BR', lang: 'pt-BR')
|
|
33
|
-
expect(Nation.first.lang).to eq('pt-BR')
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'should have abbr as id' do
|
|
37
|
-
Nation.make!(abbr: 'BR')
|
|
38
|
-
expect(Nation.first.id).to eq('BR')
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'should equal by abbr' do
|
|
42
|
-
expect(Nation.new(abbr: 'BR')).to eq(Nation.new(abbr: 'BR'))
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it 'may have a localized name' do
|
|
46
|
-
I18n.locale = :'pt-BR'
|
|
47
|
-
n = Nation.new(name: 'Brasil')
|
|
48
|
-
expect(n.name).to eq('Brasil')
|
|
49
|
-
I18n.locale = :en
|
|
50
|
-
n.name = 'Brazil'
|
|
51
|
-
expect(n.name_translations).to eq('pt-BR' => 'Brasil', 'en' => 'Brazil')
|
|
52
|
-
end
|
|
53
|
-
end
|
data/spec/models/region_spec.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Region, type: :model do
|
|
4
|
-
it 'should create a region' do
|
|
5
|
-
expect { Region.make! }.not_to raise_error
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it 'should create it\'s own slug' do
|
|
9
|
-
city = Region.create(name: 'Amapá')
|
|
10
|
-
expect(city.slug).to eq('amapa')
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'should accept area phone code modified regex' do
|
|
14
|
-
expect(Region.make(phone: '88XXXXXXXX')).to be_valid
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'should accept area postal code modified regex' do
|
|
18
|
-
expect(Region.make(postal: '15XXXXXX')).to be_valid
|
|
19
|
-
end
|
|
20
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
2
|
-
ENV['RAILS_ENV'] ||= 'test'
|
|
3
|
-
require File.expand_path('../dummy/config/environment', __FILE__)
|
|
4
|
-
require 'rspec/rails'
|
|
5
|
-
require 'faker'
|
|
6
|
-
require 'fabrication'
|
|
7
|
-
require 'fabrication/syntax/make'
|
|
8
|
-
require 'coveralls'
|
|
9
|
-
Coveralls.wear!
|
|
10
|
-
|
|
11
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
12
|
-
# in spec/support/ and its subdirectories.
|
|
13
|
-
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
|
14
|
-
|
|
15
|
-
# Checks for pending migrations before tests are run.
|
|
16
|
-
# If you are not using ActiveRecord, you can remove this line.
|
|
17
|
-
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
|
18
|
-
|
|
19
|
-
Fabrication.configure do |config|
|
|
20
|
-
# config.fabricator_path = 'data/fabricators'
|
|
21
|
-
config.path_prefix = Rails.root.join('../../')
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
puts "Running Mongoid v#{Mongoid::VERSION}"
|
|
25
|
-
|
|
26
|
-
RSpec.configure do |config|
|
|
27
|
-
# ## Mock Framework
|
|
28
|
-
#
|
|
29
|
-
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
|
30
|
-
#
|
|
31
|
-
# config.mock_with :mocha
|
|
32
|
-
# config.mock_with :flexmock
|
|
33
|
-
# config.mock_with :rr
|
|
34
|
-
config.after(:each) do
|
|
35
|
-
Mongoid.purge!
|
|
36
|
-
# $stdout = File.new( '/tmp/lastspec', 'w' )
|
|
37
|
-
# $stdout.sync = true
|
|
38
|
-
end
|
|
39
|
-
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
40
|
-
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
41
|
-
|
|
42
|
-
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
43
|
-
# examples within a transaction, remove the following line or assign false
|
|
44
|
-
# instead of true.
|
|
45
|
-
# config.use_transactional_fixtures = true
|
|
46
|
-
|
|
47
|
-
# If true, the base class of anonymous controllers will be inferred
|
|
48
|
-
# automatically. This will be the default behavior in future versions of
|
|
49
|
-
# rspec-rails.
|
|
50
|
-
config.infer_base_class_for_anonymous_controllers = false
|
|
51
|
-
|
|
52
|
-
# Run specs in random order to surface order dependencies. If you find an
|
|
53
|
-
# order dependency and want to debug it, you can fix the order by providing
|
|
54
|
-
# the seed, which is printed after each run.
|
|
55
|
-
# --seed 1234
|
|
56
|
-
config.order = 'random'
|
|
57
|
-
end
|