popolo 0.0.2 → 0.0.3
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 +7 -0
- data/README.md +65 -7
- data/app/assets/javascripts/popolo.js +1 -0
- data/app/assets/stylesheets/popolo/bootstrap.min.scss +7 -0
- data/app/assets/stylesheets/popolo/main.css.scss +14 -0
- data/app/assets/stylesheets/popolo.css +3 -0
- data/app/controllers/popolo/memberships_controller.rb +7 -0
- data/app/controllers/popolo/organizations_controller.rb +0 -39
- data/app/controllers/popolo/people_controller.rb +1 -6
- data/app/controllers/popolo/posts_controller.rb +1 -1
- data/app/helpers/popolo_helper.rb +0 -8
- data/app/models/popolo/area.rb +20 -12
- data/app/models/popolo/contact_detail.rb +22 -0
- data/app/models/popolo/count.rb +24 -0
- data/app/models/popolo/date_string.rb +23 -0
- data/app/models/popolo/group_result.rb +15 -0
- data/app/models/popolo/identifier.rb +1 -1
- data/app/models/popolo/link.rb +7 -3
- data/app/models/popolo/membership.rb +34 -9
- data/app/models/popolo/motion.rb +37 -0
- data/app/models/popolo/organization.rb +37 -16
- data/app/models/popolo/other_name.rb +5 -5
- data/app/models/popolo/person.rb +57 -27
- data/app/models/popolo/post.rb +27 -13
- data/app/models/popolo/vote.rb +28 -0
- data/app/models/popolo/vote_event.rb +35 -0
- data/app/views/popolo/contact_details/_contact_detail.html.erb +17 -0
- data/app/views/popolo/identifiers/_identifier.html.erb +2 -0
- data/app/views/popolo/links/_link.html.erb +1 -0
- data/app/views/popolo/memberships/show.html.erb +81 -0
- data/app/views/popolo/organizations/index.html.erb +16 -1
- data/app/views/popolo/organizations/show.html.erb +146 -1
- data/app/views/popolo/other_names/other_name.html.erb +9 -0
- data/app/views/popolo/people/show.html.erb +120 -0
- data/app/views/popolo/posts/show.html.erb +90 -0
- data/config/routes.rb +4 -12
- data/lib/generators/popolo_generator.rb +4 -0
- data/lib/popolo/initializers/pupa_compat.rb +11 -0
- data/lib/popolo/version.rb +1 -1
- data/lib/popolo.rb +17 -5
- data/spec/controllers/popolo/memberships_controller_spec.rb +16 -0
- data/spec/controllers/popolo/organizations_controller_spec.rb +1 -47
- data/spec/controllers/popolo/people_controller_spec.rb +0 -14
- data/spec/controllers/popolo/posts_controller_spec.rb +0 -8
- data/spec/dummy/app/assets/stylesheets/application.css +1 -0
- data/spec/dummy/app/models/cat.rb +0 -3
- data/spec/dummy/app/models/dog.rb +0 -7
- data/spec/dummy/app/views/layouts/application.html.erb +2 -0
- data/spec/dummy/config/locales/en.yml +30 -0
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/log/test.log +8670 -48801
- data/spec/factories.rb +3 -8
- data/spec/models/popolo/{source_spec.rb → contact_detail_spec.rb} +2 -2
- data/spec/models/popolo/count_spec.rb +7 -0
- data/spec/models/popolo/date_string_spec.rb +121 -0
- data/spec/models/popolo/group_result_spec.rb +7 -0
- data/spec/models/popolo/membership_spec.rb +1 -17
- data/spec/models/popolo/motion_spec.rb +5 -0
- data/spec/models/popolo/organization_spec.rb +1 -19
- data/spec/models/popolo/other_name_spec.rb +1 -17
- data/spec/models/popolo/person_spec.rb +23 -19
- data/spec/models/popolo/post_spec.rb +1 -3
- data/spec/models/popolo/vote_event_spec.rb +4 -0
- data/spec/models/popolo/vote_spec.rb +4 -0
- data/spec/popolo_spec.rb +65 -0
- data/spec/routing/popolo/memberships_routing_spec.rb +11 -0
- data/spec/routing/popolo/organizations_routing_spec.rb +1 -19
- data/spec/routing/popolo/people_routing_spec.rb +1 -11
- data/spec/routing/popolo/posts_routing_spec.rb +1 -7
- data/spec/spec_helper.rb +6 -1
- data/spec/support/shared_examples.rb +19 -0
- metadata +99 -109
- data/app/assets/javascripts/popolo/application.js +0 -13
- data/app/assets/stylesheets/popolo/application.css +0 -13
- data/app/controllers/popolo/areas_controller.rb +0 -43
- data/app/models/popolo/address.rb +0 -27
- data/app/models/popolo/event.rb +0 -46
- data/app/models/popolo/source.rb +0 -29
- data/app/views/popolo/addresses/_address.html.erb +0 -16
- data/app/views/popolo/areas/index.html.erb +0 -1
- data/app/views/popolo/areas/show.html.erb +0 -1
- data/app/views/popolo/areas_or_organizations/_breadcrumb.html.erb +0 -13
- data/app/views/popolo/areas_or_organizations/_index.html.erb +0 -31
- data/app/views/popolo/areas_or_organizations/_show.html.erb +0 -18
- data/app/views/popolo/organizations/post.html.erb +0 -27
- data/app/views/popolo/organizations/posts.html.erb +0 -23
- data/app/views/popolo/people/index.html.erb +0 -0
- data/app/views/popolo/posts/index.html.erb +0 -0
- data/lib/popolo/mixins/eventable.rb +0 -15
- data/lib/popolo/mixins/sluggable.rb +0 -66
- data/spec/controllers/popolo/areas_controller_spec.rb +0 -53
- data/spec/dummy/log/development.log +0 -6
- data/spec/models/popolo/address_spec.rb +0 -4
- data/spec/models/popolo/event_spec.rb +0 -7
- data/spec/popolo/mixins/sluggable_spec.rb +0 -153
- data/spec/routing/popolo/areas_routing_spec.rb +0 -25
data/spec/factories.rb
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
# https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md
|
|
2
2
|
FactoryGirl.define do
|
|
3
|
-
factory :area, class: Popolo::Area do
|
|
4
|
-
name 'Foo'
|
|
5
|
-
end
|
|
6
|
-
|
|
7
3
|
factory :membership, class: Popolo::Membership do
|
|
8
|
-
person
|
|
9
4
|
organization
|
|
5
|
+
person
|
|
6
|
+
post
|
|
10
7
|
end
|
|
11
8
|
|
|
12
9
|
factory :organization, class: Popolo::Organization do
|
|
@@ -18,9 +15,7 @@ FactoryGirl.define do
|
|
|
18
15
|
end
|
|
19
16
|
|
|
20
17
|
factory :post, class: Popolo::Post do
|
|
21
|
-
|
|
22
|
-
role 'Director'
|
|
23
|
-
person
|
|
18
|
+
label 'Marketing Director'
|
|
24
19
|
organization
|
|
25
20
|
end
|
|
26
21
|
end
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Popolo::DateString do
|
|
4
|
+
let :date do
|
|
5
|
+
Date.new(2011, 2, 3)
|
|
6
|
+
end
|
|
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
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'returns a string if day truncated' do
|
|
46
|
+
date_string_year_month.mongoize.should == year_month
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'returns a string if month and day truncated' do
|
|
50
|
+
date_string_year.mongoize.should == year
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'returns nil if empty string' do
|
|
54
|
+
date_string_empty.mongoize.should == nil
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe '.demongoize' do
|
|
59
|
+
it 'returns a date' do
|
|
60
|
+
Popolo::DateString.demongoize(year_month_day).mongoize.should == date
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'returns a string if day truncated' do
|
|
64
|
+
Popolo::DateString.demongoize(year_month).mongoize.should == year_month
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'returns a string if month and day truncated' do
|
|
68
|
+
Popolo::DateString.demongoize(year).mongoize.should == year
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'returns nil if empty string' do
|
|
72
|
+
Popolo::DateString.demongoize(empty).mongoize.should == nil
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe '.mongoize' do
|
|
77
|
+
it 'returns a string when given a date' do
|
|
78
|
+
Popolo::DateString.mongoize(date).should == year_month_day
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'returns a string when given a date string' do
|
|
82
|
+
Popolo::DateString.mongoize(date_string_year_month_day).should == year_month_day
|
|
83
|
+
Popolo::DateString.mongoize(date_string_year_month).should == year_month
|
|
84
|
+
Popolo::DateString.mongoize(date_string_year).should == year
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'returns a string when given a string' do
|
|
88
|
+
Popolo::DateString.mongoize(year_month_day).should == year_month_day
|
|
89
|
+
Popolo::DateString.mongoize(year_month).should == year_month
|
|
90
|
+
Popolo::DateString.mongoize(year).should == year
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'returns nil when given an empty string' do
|
|
94
|
+
Popolo::DateString.mongoize(date_string_empty).should == nil
|
|
95
|
+
Popolo::DateString.mongoize(empty).should == nil
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe '.evolve' do
|
|
100
|
+
it 'returns a string when given a date' do
|
|
101
|
+
Popolo::DateString.evolve(date).should == year_month_day
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'returns a string when given a date string' do
|
|
105
|
+
Popolo::DateString.evolve(date_string_year_month_day).should == year_month_day
|
|
106
|
+
Popolo::DateString.evolve(date_string_year_month).should == year_month
|
|
107
|
+
Popolo::DateString.evolve(date_string_year).should == year
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'returns a string when given a string' do
|
|
111
|
+
Popolo::DateString.evolve(year_month_day).should == year_month_day
|
|
112
|
+
Popolo::DateString.evolve(year_month).should == year_month
|
|
113
|
+
Popolo::DateString.evolve(year).should == year
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'returns nil when given an empty string' do
|
|
117
|
+
Popolo::DateString.evolve(date_string_empty).should == nil
|
|
118
|
+
Popolo::DateString.evolve(empty).should == nil
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -6,22 +6,6 @@ describe Popolo::Membership do
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
[:start_date, :end_date].each do |attribute|
|
|
9
|
-
|
|
10
|
-
should validate_format_of(attribute).
|
|
11
|
-
# 4.1.2.2 Basic format
|
|
12
|
-
not_to_allow('20041231').
|
|
13
|
-
# 4.1.2.2 Extended format
|
|
14
|
-
to_allow('2004-12-31').
|
|
15
|
-
# 4.1.2.3 a) A specific month
|
|
16
|
-
to_allow('2004-01').
|
|
17
|
-
# 4.1.2.3 b) A specific year
|
|
18
|
-
to_allow('2004').
|
|
19
|
-
# 4.1.2.3 c) A specific century
|
|
20
|
-
not_to_allow('20').
|
|
21
|
-
# Avoid confusion with YYMMDD
|
|
22
|
-
not_to_allow('200401').
|
|
23
|
-
# Date and time of day.
|
|
24
|
-
not_to_allow('2004-12-31T00:00:00Z')
|
|
25
|
-
}
|
|
9
|
+
it_should_behave_like 'a model with a date attribute', attribute
|
|
26
10
|
end
|
|
27
11
|
end
|
|
@@ -1,25 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Popolo::Organization do
|
|
4
|
-
it {should validate_presence_of :name}
|
|
5
|
-
|
|
6
4
|
[:founding_date, :dissolution_date].each do |attribute|
|
|
7
|
-
|
|
8
|
-
should validate_format_of(attribute).
|
|
9
|
-
# 4.1.2.2 Basic format
|
|
10
|
-
not_to_allow('20041231').
|
|
11
|
-
# 4.1.2.2 Extended format
|
|
12
|
-
to_allow('2004-12-31').
|
|
13
|
-
# 4.1.2.3 a) A specific month
|
|
14
|
-
to_allow('2004-01').
|
|
15
|
-
# 4.1.2.3 b) A specific year
|
|
16
|
-
to_allow('2004').
|
|
17
|
-
# 4.1.2.3 c) A specific century
|
|
18
|
-
not_to_allow('20').
|
|
19
|
-
# Avoid confusion with YYMMDD
|
|
20
|
-
not_to_allow('200401').
|
|
21
|
-
# Date and time of day.
|
|
22
|
-
not_to_allow('2004-12-31T00:00:00Z')
|
|
23
|
-
}
|
|
5
|
+
it_should_behave_like 'a model with a date attribute', attribute
|
|
24
6
|
end
|
|
25
7
|
end
|
|
@@ -4,22 +4,6 @@ describe Popolo::OtherName do
|
|
|
4
4
|
it {should validate_presence_of :name}
|
|
5
5
|
|
|
6
6
|
[:start_date, :end_date].each do |attribute|
|
|
7
|
-
|
|
8
|
-
should validate_format_of(attribute).
|
|
9
|
-
# 4.1.2.2 Basic format
|
|
10
|
-
not_to_allow('20041231').
|
|
11
|
-
# 4.1.2.2 Extended format
|
|
12
|
-
to_allow('2004-12-31').
|
|
13
|
-
# 4.1.2.3 a) A specific month
|
|
14
|
-
to_allow('2004-01').
|
|
15
|
-
# 4.1.2.3 b) A specific year
|
|
16
|
-
to_allow('2004').
|
|
17
|
-
# 4.1.2.3 c) A specific century
|
|
18
|
-
not_to_allow('20').
|
|
19
|
-
# Avoid confusion with YYMMDD
|
|
20
|
-
not_to_allow('200401').
|
|
21
|
-
# Date and time of day.
|
|
22
|
-
not_to_allow('2004-12-31T00:00:00Z')
|
|
23
|
-
}
|
|
7
|
+
it_should_behave_like 'a model with a date attribute', attribute
|
|
24
8
|
end
|
|
25
9
|
end
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Popolo::Person do
|
|
4
|
-
it {should validate_presence_of :name}
|
|
5
|
-
|
|
6
4
|
[:birth_date, :death_date].each do |attribute|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
it_should_behave_like 'a model with a date attribute', attribute
|
|
6
|
+
end
|
|
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
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should return the given name and family name if the name is blank' do
|
|
14
|
+
FactoryGirl.build(:person, name: nil, given_name: 'John', family_name: 'Public').to_s.should == 'John Public'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'should return the family name if the name and given name are blank' do
|
|
18
|
+
FactoryGirl.build(:person, name: nil, family_name: 'Public').to_s.should == 'Public'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should return the given name if the name and family name are blank' do
|
|
22
|
+
FactoryGirl.build(:person, name: nil, given_name: 'John').to_s.should == 'John'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'should return the name if present' do
|
|
26
|
+
FactoryGirl.build(:person, given_name: 'John', family_name: 'Public').to_s.should == 'John Q. Public'
|
|
27
|
+
end
|
|
24
28
|
end
|
|
25
29
|
end
|
data/spec/popolo_spec.rb
CHANGED
|
@@ -1,4 +1,69 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Popolo do
|
|
4
|
+
describe '.storage_options' do
|
|
5
|
+
context 'when using default storage options' do
|
|
6
|
+
it 'should use default storage options' do
|
|
7
|
+
Popolo.storage_options.should == {}
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
context 'when using custom storage options' do
|
|
12
|
+
before do
|
|
13
|
+
Popolo.storage_options = {database: :test}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should use custom storage options' do
|
|
17
|
+
Popolo.storage_options.should == {database: :test}
|
|
18
|
+
|
|
19
|
+
# We would need to reload the app.
|
|
20
|
+
# Popolo::Membership.storage_options.should == {database: :test}
|
|
21
|
+
# Popolo::Organization.storage_options.should == {database: :test}
|
|
22
|
+
# Popolo::Person.storage_options.should == {database: :test}
|
|
23
|
+
# Popolo::Post.storage_options.should == {database: :test}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
after do
|
|
27
|
+
Popolo.storage_options = {}
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '.storage_options_per_class' do
|
|
33
|
+
context 'when using default storage options' do
|
|
34
|
+
it 'should use default storage options' do
|
|
35
|
+
Popolo.storage_options_per_class.should == {}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context 'when using custom storage options' do
|
|
40
|
+
before do
|
|
41
|
+
Popolo.storage_options_per_class = {
|
|
42
|
+
:Membership => {collection: 'a'},
|
|
43
|
+
:Organization => {collection: 'b'},
|
|
44
|
+
:Person => {collection: 'c'},
|
|
45
|
+
:Post => {collection: 'd'},
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should use custom storage options' do
|
|
50
|
+
Popolo.storage_options_per_class.should == {
|
|
51
|
+
:Membership => {collection: 'a'},
|
|
52
|
+
:Organization => {collection: 'b'},
|
|
53
|
+
:Person => {collection: 'c'},
|
|
54
|
+
:Post => {collection: 'd'},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# We would need to reload the app.
|
|
58
|
+
# Popolo::Membership.storage_options.should == {collection: 'a'}
|
|
59
|
+
# Popolo::Organization.storage_options.should == {collection: 'b'}
|
|
60
|
+
# Popolo::Person.storage_options.should == {collection: 'c'}
|
|
61
|
+
# Popolo::Post.storage_options.should == {collection: 'd'}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
after do
|
|
65
|
+
Popolo.storage_options = {}
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
4
69
|
end
|
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe Popolo::OrganizationsController do
|
|
4
4
|
describe 'routing' do
|
|
5
|
-
|
|
6
|
-
@routes = Popolo::Engine.routes
|
|
7
|
-
end
|
|
5
|
+
routes { Popolo::Engine.routes }
|
|
8
6
|
|
|
9
7
|
it 'routes to #index' do
|
|
10
8
|
get('/organizations').should route_to('popolo/organizations#index')
|
|
@@ -13,21 +11,5 @@ describe Popolo::OrganizationsController do
|
|
|
13
11
|
it 'routes to #show' do
|
|
14
12
|
get('/organizations/1').should route_to('popolo/organizations#show', id: '1')
|
|
15
13
|
end
|
|
16
|
-
|
|
17
|
-
it 'routes to #nested_index' do
|
|
18
|
-
get('/organizations/foo/organizations').should route_to('popolo/organizations#nested_index', path: 'foo')
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'routes to #nested_show' do
|
|
22
|
-
get('/organizations/foo/bar').should route_to('popolo/organizations#nested_show', path: 'foo/bar')
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'routes to #posts' do
|
|
26
|
-
get('/organizations/foo/posts').should route_to('popolo/organizations#posts', path: 'foo')
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it 'routes to #post' do
|
|
30
|
-
get('/organizations/foo/posts/bar').should route_to('popolo/organizations#post', path: 'foo', id: 'bar')
|
|
31
|
-
end
|
|
32
14
|
end
|
|
33
15
|
end
|
|
@@ -2,20 +2,10 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe Popolo::PeopleController do
|
|
4
4
|
describe 'routing' do
|
|
5
|
-
|
|
6
|
-
@routes = Popolo::Engine.routes
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it 'routes to #index' do
|
|
10
|
-
get('/people').should route_to('popolo/people#index')
|
|
11
|
-
end
|
|
5
|
+
routes { Popolo::Engine.routes }
|
|
12
6
|
|
|
13
7
|
it 'routes to #show' do
|
|
14
8
|
get('/people/1').should route_to('popolo/people#show', id: '1')
|
|
15
9
|
end
|
|
16
|
-
|
|
17
|
-
it 'routes to #show' do
|
|
18
|
-
get('/people/foo').should route_to('popolo/people#show', id: 'foo')
|
|
19
|
-
end
|
|
20
10
|
end
|
|
21
11
|
end
|
|
@@ -2,13 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe Popolo::PostsController do
|
|
4
4
|
describe 'routing' do
|
|
5
|
-
|
|
6
|
-
@routes = Popolo::Engine.routes
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it 'routes to #index' do
|
|
10
|
-
get('/posts').should route_to('popolo/posts#index')
|
|
11
|
-
end
|
|
5
|
+
routes { Popolo::Engine.routes }
|
|
12
6
|
|
|
13
7
|
it 'routes to #show' do
|
|
14
8
|
get('/posts/1').should route_to('popolo/posts#show', id: '1')
|
data/spec/spec_helper.rb
CHANGED
|
@@ -3,6 +3,9 @@ require 'spork'
|
|
|
3
3
|
Spork.prefork do
|
|
4
4
|
ENV["RAILS_ENV"] ||= 'test'
|
|
5
5
|
|
|
6
|
+
require 'coveralls'
|
|
7
|
+
Coveralls.wear!
|
|
8
|
+
|
|
6
9
|
require 'rails/application'
|
|
7
10
|
# Prevent Spork from caching the routes.
|
|
8
11
|
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
|
|
@@ -33,7 +36,6 @@ Spork.prefork do
|
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
require 'database_cleaner'
|
|
36
|
-
require 'factory_girl_rails'
|
|
37
39
|
require 'mongoid-rspec'
|
|
38
40
|
|
|
39
41
|
RSpec.configure do |config|
|
|
@@ -49,6 +51,7 @@ Spork.prefork do
|
|
|
49
51
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
50
52
|
config.run_all_when_everything_filtered = true
|
|
51
53
|
config.filter_run focus: true
|
|
54
|
+
config.infer_spec_type_from_file_location!
|
|
52
55
|
end
|
|
53
56
|
end
|
|
54
57
|
|
|
@@ -77,5 +80,7 @@ Spork.each_run do
|
|
|
77
80
|
Rails::Mongoid.create_indexes(File.expand_path("../dummy/app/models/**/*.rb", __FILE__))
|
|
78
81
|
|
|
79
82
|
# @todo I18n.backend.reload!
|
|
83
|
+
|
|
84
|
+
require 'factory_girl_rails'
|
|
80
85
|
FactoryGirl.reload
|
|
81
86
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
shared_examples_for 'a model with a date attribute' do |attribute|
|
|
2
|
+
it {
|
|
3
|
+
should validate_format_of(attribute).
|
|
4
|
+
# 4.1.2.2 Basic format
|
|
5
|
+
not_to_allow('20041231').
|
|
6
|
+
# 4.1.2.2 Extended format
|
|
7
|
+
to_allow('2004-12-31').
|
|
8
|
+
# 4.1.2.3 a) A specific month
|
|
9
|
+
to_allow('2004-01').
|
|
10
|
+
# 4.1.2.3 b) A specific year
|
|
11
|
+
to_allow('2004').
|
|
12
|
+
# 4.1.2.3 c) A specific century
|
|
13
|
+
not_to_allow('20').
|
|
14
|
+
# Avoid confusion with YYMMDD
|
|
15
|
+
not_to_allow('200401').
|
|
16
|
+
# Date and time of day.
|
|
17
|
+
not_to_allow('2004-12-31T00:00:00Z')
|
|
18
|
+
}
|
|
19
|
+
end
|