popolo 0.0.3 → 0.1.0
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 +4 -4
- data/README.md +6 -2
- data/Rakefile +13 -4
- data/app/models/popolo/area.rb +3 -3
- data/app/models/popolo/contact_detail.rb +4 -0
- data/app/models/popolo/motion.rb +3 -1
- data/app/models/popolo/organization.rb +8 -4
- data/app/models/popolo/other_name.rb +12 -0
- data/app/models/popolo/person.rb +3 -3
- data/app/models/popolo/post.rb +2 -0
- data/app/models/popolo/vote_event.rb +1 -1
- data/lib/popolo/version.rb +1 -1
- data/spec/controllers/popolo/memberships_controller_spec.rb +13 -11
- data/spec/controllers/popolo/organizations_controller_spec.rb +18 -17
- data/spec/controllers/popolo/people_controller_spec.rb +13 -11
- data/spec/controllers/popolo/posts_controller_spec.rb +13 -11
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +1 -2
- data/spec/dummy/app/assets/javascripts/application.js +3 -3
- data/spec/dummy/app/assets/stylesheets/application.css +5 -4
- data/spec/dummy/app/controllers/application_controller.rb +3 -1
- data/spec/dummy/app/views/layouts/application.html.erb +2 -4
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +1 -38
- data/spec/dummy/config/boot.rb +4 -9
- data/spec/dummy/config/environment.rb +3 -3
- data/spec/dummy/config/environments/development.rb +19 -19
- data/spec/dummy/config/environments/production.rb +44 -28
- data/spec/dummy/config/environments/test.rb +17 -15
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -6
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/spec/dummy/config/locales/en.yml +20 -2
- data/spec/dummy/config/mongoid.yml +21 -20
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +4423 -0
- data/spec/dummy/public/404.html +54 -13
- data/spec/dummy/public/422.html +54 -13
- data/spec/dummy/public/500.html +53 -12
- data/spec/helpers/popolo_helper_spec.rb +2 -2
- data/spec/models/popolo/area_spec.rb +4 -2
- data/spec/models/popolo/contact_detail_spec.rb +6 -4
- data/spec/models/popolo/count_spec.rb +6 -4
- data/spec/models/popolo/date_string_spec.rb +92 -90
- data/spec/models/popolo/group_result_spec.rb +6 -4
- data/spec/models/popolo/identifier_spec.rb +5 -3
- data/spec/models/popolo/link_spec.rb +5 -3
- data/spec/models/popolo/membership_spec.rb +9 -7
- data/spec/models/popolo/motion_spec.rb +5 -3
- data/spec/models/popolo/organization_spec.rb +6 -4
- data/spec/models/popolo/other_name_spec.rb +7 -5
- data/spec/models/popolo/person_spec.rb +22 -20
- data/spec/models/popolo/post_spec.rb +5 -3
- data/spec/models/popolo/vote_event_spec.rb +4 -2
- data/spec/models/popolo/vote_spec.rb +4 -2
- data/spec/popolo_spec.rb +15 -15
- data/spec/rails_helper.rb +68 -0
- data/spec/routing/popolo/memberships_routing_spec.rb +8 -6
- data/spec/routing/popolo/organizations_routing_spec.rb +11 -9
- data/spec/routing/popolo/people_routing_spec.rb +8 -6
- data/spec/routing/popolo/posts_routing_spec.rb +8 -6
- data/spec/spec_helper.rb +70 -80
- data/spec/support/{shared_examples.rb → shared_examples/date.rb} +1 -1
- metadata +52 -89
- data/spec/controllers/popolo_controller_spec.rb +0 -4
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
data/spec/dummy/public/404.html
CHANGED
@@ -2,25 +2,66 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
57
|
<body>
|
20
58
|
<!-- This file lives in public/404.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
23
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
24
65
|
</div>
|
25
66
|
</body>
|
26
67
|
</html>
|
data/spec/dummy/public/422.html
CHANGED
@@ -2,25 +2,66 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
57
|
<body>
|
20
58
|
<!-- This file lives in public/422.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
23
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
24
65
|
</div>
|
25
66
|
</body>
|
26
67
|
</html>
|
data/spec/dummy/public/500.html
CHANGED
@@ -2,24 +2,65 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
57
|
<body>
|
20
58
|
<!-- This file lives in public/500.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
23
64
|
</div>
|
24
65
|
</body>
|
25
66
|
</html>
|
@@ -1,7 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe ContactDetail do
|
5
|
+
[:type, :value].each do |attribute|
|
6
|
+
it {should validate_presence_of attribute}
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe Count do
|
5
|
+
[:option, :value].each do |attribute|
|
6
|
+
it {should validate_presence_of attribute}
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
@@ -1,121 +1,123 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
let :date_string_year_month_day do
|
9
|
-
Popolo::DateString.new('2011-02-03')
|
10
|
-
end
|
11
|
-
|
12
|
-
let :date_string_year_month do
|
13
|
-
Popolo::DateString.new('2011-02')
|
14
|
-
end
|
15
|
-
|
16
|
-
let :date_string_year do
|
17
|
-
Popolo::DateString.new('2011')
|
18
|
-
end
|
19
|
-
|
20
|
-
let :date_string_empty do
|
21
|
-
Popolo::DateString.new('')
|
22
|
-
end
|
23
|
-
|
24
|
-
let :year_month_day do
|
25
|
-
'2011-02-03'
|
26
|
-
end
|
27
|
-
|
28
|
-
let :year_month do
|
29
|
-
'2011-02'
|
30
|
-
end
|
31
|
-
|
32
|
-
let :year do
|
33
|
-
'2011'
|
34
|
-
end
|
35
|
-
|
36
|
-
let :empty do
|
37
|
-
''
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#mongoize' do
|
41
|
-
it 'returns a string' do
|
42
|
-
date_string_year_month_day.mongoize.should == year_month_day
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe DateString do
|
5
|
+
let :date do
|
6
|
+
Date.new(2011, 2, 3)
|
43
7
|
end
|
44
8
|
|
45
|
-
|
46
|
-
|
9
|
+
let :date_string_year_month_day do
|
10
|
+
Popolo::DateString.new('2011-02-03')
|
47
11
|
end
|
48
12
|
|
49
|
-
|
50
|
-
|
13
|
+
let :date_string_year_month do
|
14
|
+
Popolo::DateString.new('2011-02')
|
51
15
|
end
|
52
16
|
|
53
|
-
|
54
|
-
|
17
|
+
let :date_string_year do
|
18
|
+
Popolo::DateString.new('2011')
|
55
19
|
end
|
56
|
-
end
|
57
20
|
|
58
|
-
|
59
|
-
|
60
|
-
Popolo::DateString.demongoize(year_month_day).mongoize.should == date
|
21
|
+
let :date_string_empty do
|
22
|
+
Popolo::DateString.new('')
|
61
23
|
end
|
62
24
|
|
63
|
-
|
64
|
-
|
25
|
+
let :year_month_day do
|
26
|
+
'2011-02-03'
|
65
27
|
end
|
66
28
|
|
67
|
-
|
68
|
-
|
29
|
+
let :year_month do
|
30
|
+
'2011-02'
|
69
31
|
end
|
70
32
|
|
71
|
-
|
72
|
-
|
33
|
+
let :year do
|
34
|
+
'2011'
|
73
35
|
end
|
74
|
-
end
|
75
36
|
|
76
|
-
|
77
|
-
|
78
|
-
Popolo::DateString.mongoize(date).should == year_month_day
|
37
|
+
let :empty do
|
38
|
+
''
|
79
39
|
end
|
80
40
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
41
|
+
describe '#mongoize' do
|
42
|
+
it 'returns a string' do
|
43
|
+
expect(date_string_year_month_day.mongoize).to eq(year_month_day)
|
44
|
+
end
|
86
45
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
Popolo::DateString.mongoize(year).should == year
|
91
|
-
end
|
46
|
+
it 'returns a string if day truncated' do
|
47
|
+
expect(date_string_year_month.mongoize).to eq(year_month)
|
48
|
+
end
|
92
49
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
97
|
-
end
|
50
|
+
it 'returns a string if month and day truncated' do
|
51
|
+
expect(date_string_year.mongoize).to eq(year)
|
52
|
+
end
|
98
53
|
|
99
|
-
|
100
|
-
|
101
|
-
|
54
|
+
it 'returns nil if empty string' do
|
55
|
+
expect(date_string_empty.mongoize).to eq(nil)
|
56
|
+
end
|
102
57
|
end
|
103
58
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
59
|
+
describe '.demongoize' do
|
60
|
+
it 'returns a date' do
|
61
|
+
expect(Popolo::DateString.demongoize(year_month_day).mongoize).to eq(date)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'returns a string if day truncated' do
|
65
|
+
expect(Popolo::DateString.demongoize(year_month).mongoize).to eq(year_month)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns a string if month and day truncated' do
|
69
|
+
expect(Popolo::DateString.demongoize(year).mongoize).to eq(year)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns nil if empty string' do
|
73
|
+
expect(Popolo::DateString.demongoize(empty).mongoize).to eq(nil)
|
74
|
+
end
|
108
75
|
end
|
109
76
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
77
|
+
describe '.mongoize' do
|
78
|
+
it 'returns a string when given a date' do
|
79
|
+
expect(Popolo::DateString.mongoize(date)).to eq(year_month_day)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'returns a string when given a date string' do
|
83
|
+
expect(Popolo::DateString.mongoize(date_string_year_month_day)).to eq(year_month_day)
|
84
|
+
expect(Popolo::DateString.mongoize(date_string_year_month)).to eq(year_month)
|
85
|
+
expect(Popolo::DateString.mongoize(date_string_year)).to eq(year)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'returns a string when given a string' do
|
89
|
+
expect(Popolo::DateString.mongoize(year_month_day)).to eq(year_month_day)
|
90
|
+
expect(Popolo::DateString.mongoize(year_month)).to eq(year_month)
|
91
|
+
expect(Popolo::DateString.mongoize(year)).to eq(year)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'returns nil when given an empty string' do
|
95
|
+
expect(Popolo::DateString.mongoize(date_string_empty)).to eq(nil)
|
96
|
+
expect(Popolo::DateString.mongoize(empty)).to eq(nil)
|
97
|
+
end
|
114
98
|
end
|
115
99
|
|
116
|
-
|
117
|
-
|
118
|
-
|
100
|
+
describe '.evolve' do
|
101
|
+
it 'returns a string when given a date' do
|
102
|
+
expect(Popolo::DateString.evolve(date)).to eq(year_month_day)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'returns a string when given a date string' do
|
106
|
+
expect(Popolo::DateString.evolve(date_string_year_month_day)).to eq(year_month_day)
|
107
|
+
expect(Popolo::DateString.evolve(date_string_year_month)).to eq(year_month)
|
108
|
+
expect(Popolo::DateString.evolve(date_string_year)).to eq(year)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'returns a string when given a string' do
|
112
|
+
expect(Popolo::DateString.evolve(year_month_day)).to eq(year_month_day)
|
113
|
+
expect(Popolo::DateString.evolve(year_month)).to eq(year_month)
|
114
|
+
expect(Popolo::DateString.evolve(year)).to eq(year)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'returns nil when given an empty string' do
|
118
|
+
expect(Popolo::DateString.evolve(date_string_empty)).to eq(nil)
|
119
|
+
expect(Popolo::DateString.evolve(empty)).to eq(nil)
|
120
|
+
end
|
119
121
|
end
|
120
122
|
end
|
121
123
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe GroupResult do
|
5
|
+
[:group, :result].each do |attribute|
|
6
|
+
it {should validate_presence_of attribute}
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe Membership do
|
5
|
+
[:organization_id, :person_id].each do |attribute|
|
6
|
+
it {should validate_presence_of attribute}
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
[:start_date, :end_date].each do |attribute|
|
10
|
+
it_behaves_like 'a model with a date attribute', attribute
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe Organization do
|
5
|
+
[:founding_date, :dissolution_date].each do |attribute|
|
6
|
+
it_behaves_like 'a model with a date attribute', attribute
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe OtherName do
|
5
|
+
it {should validate_presence_of :name}
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
[:start_date, :end_date].each do |attribute|
|
8
|
+
it_behaves_like 'a model with a date attribute', attribute
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
@@ -1,29 +1,31 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
describe '#to_s' do
|
9
|
-
it 'should return the name if the name, given name and family name are blank' do
|
10
|
-
FactoryGirl.build(:person, name: nil).to_s.should == nil
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe Person do
|
5
|
+
[:birth_date, :death_date].each do |attribute|
|
6
|
+
it_behaves_like 'a model with a date attribute', attribute
|
11
7
|
end
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
describe '#to_s' do
|
10
|
+
it 'should return the name if the name, given name and family name are blank' do
|
11
|
+
expect(FactoryGirl.build(:person, name: nil).to_s).to eq(nil)
|
12
|
+
end
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
it 'should return the given name and family name if the name is blank' do
|
15
|
+
expect(FactoryGirl.build(:person, name: nil, given_name: 'John', family_name: 'Public').to_s).to eq('John Public')
|
16
|
+
end
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
it 'should return the family name if the name and given name are blank' do
|
19
|
+
expect(FactoryGirl.build(:person, name: nil, family_name: 'Public').to_s).to eq('Public')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should return the given name if the name and family name are blank' do
|
23
|
+
expect(FactoryGirl.build(:person, name: nil, given_name: 'John').to_s).to eq('John')
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
it 'should return the name if present' do
|
27
|
+
expect(FactoryGirl.build(:person, given_name: 'John', family_name: 'Public').to_s).to eq('John Q. Public')
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|