popolo 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/popolo_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
describe Popolo do
|
3
|
+
RSpec.describe Popolo do
|
4
4
|
describe '.storage_options' do
|
5
5
|
context 'when using default storage options' do
|
6
6
|
it 'should use default storage options' do
|
7
|
-
Popolo.storage_options.
|
7
|
+
expect(Popolo.storage_options).to eq({})
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -14,13 +14,13 @@ describe Popolo do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should use custom storage options' do
|
17
|
-
Popolo.storage_options.
|
17
|
+
expect(Popolo.storage_options).to eq({database: :test})
|
18
18
|
|
19
19
|
# We would need to reload the app.
|
20
|
-
# Popolo::Membership.storage_options.
|
21
|
-
# Popolo::Organization.storage_options.
|
22
|
-
# Popolo::Person.storage_options.
|
23
|
-
# Popolo::Post.storage_options.
|
20
|
+
# expect(Popolo::Membership.storage_options).to eq({database: :test})
|
21
|
+
# expect(Popolo::Organization.storage_options).to eq({database: :test})
|
22
|
+
# expect(Popolo::Person.storage_options).to eq({database: :test})
|
23
|
+
# expect(Popolo::Post.storage_options).to eq({database: :test})
|
24
24
|
end
|
25
25
|
|
26
26
|
after do
|
@@ -32,7 +32,7 @@ describe Popolo do
|
|
32
32
|
describe '.storage_options_per_class' do
|
33
33
|
context 'when using default storage options' do
|
34
34
|
it 'should use default storage options' do
|
35
|
-
Popolo.storage_options_per_class.
|
35
|
+
expect(Popolo.storage_options_per_class).to eq({})
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -47,18 +47,18 @@ describe Popolo do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should use custom storage options' do
|
50
|
-
Popolo.storage_options_per_class.
|
50
|
+
expect(Popolo.storage_options_per_class).to eq({
|
51
51
|
:Membership => {collection: 'a'},
|
52
52
|
:Organization => {collection: 'b'},
|
53
53
|
:Person => {collection: 'c'},
|
54
54
|
:Post => {collection: 'd'},
|
55
|
-
}
|
55
|
+
})
|
56
56
|
|
57
57
|
# We would need to reload the app.
|
58
|
-
# Popolo::Membership.storage_options.
|
59
|
-
# Popolo::Organization.storage_options.
|
60
|
-
# Popolo::Person.storage_options.
|
61
|
-
# Popolo::Post.storage_options.
|
58
|
+
# expect(Popolo::Membership.storage_options).to eq({collection: 'a'})
|
59
|
+
# expect(Popolo::Organization.storage_options).to eq({collection: 'b'})
|
60
|
+
# expect(Popolo::Person.storage_options).to eq({collection: 'c'})
|
61
|
+
# expect(Popolo::Post.storage_options).to eq({collection: 'd'})
|
62
62
|
end
|
63
63
|
|
64
64
|
after do
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
|
4
|
+
require 'coveralls'
|
5
|
+
Coveralls.wear!
|
6
|
+
|
7
|
+
require 'spec_helper'
|
8
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
9
|
+
require 'rspec/rails'
|
10
|
+
|
11
|
+
Rails.backtrace_cleaner.remove_silencers!
|
12
|
+
|
13
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
14
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
15
|
+
# run as spec files by default. This means that files in spec/support that end
|
16
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
17
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
18
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
19
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
20
|
+
Dir["./spec/support/**/*.rb"].sort.each { |f| require f}
|
21
|
+
|
22
|
+
# Checks for pending migrations before tests are run.
|
23
|
+
# If you are not using ActiveRecord, you can remove this line.
|
24
|
+
# ActiveRecord::Migration.maintain_test_schema!
|
25
|
+
|
26
|
+
require 'database_cleaner'
|
27
|
+
require 'mongoid-rspec'
|
28
|
+
require 'factory_girl_rails'
|
29
|
+
|
30
|
+
RSpec.configure do |config|
|
31
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
32
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
33
|
+
|
34
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
35
|
+
# examples within a transaction, remove the following line or assign false
|
36
|
+
# instead of true.
|
37
|
+
config.use_transactional_fixtures = true
|
38
|
+
|
39
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
40
|
+
# based on their file location, for example enabling you to call `get` and
|
41
|
+
# `post` in specs under `spec/controllers`.
|
42
|
+
#
|
43
|
+
# You can disable this behaviour by removing the line below, and instead
|
44
|
+
# explicitly tag your specs with their type, e.g.:
|
45
|
+
#
|
46
|
+
# RSpec.describe UsersController, :type => :controller do
|
47
|
+
# # ...
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# The different available types are documented in the features, such as in
|
51
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
52
|
+
config.infer_spec_type_from_file_location!
|
53
|
+
|
54
|
+
config.include Mongoid::Matchers
|
55
|
+
|
56
|
+
config.before(:suite) do
|
57
|
+
DatabaseCleaner.strategy = :truncation
|
58
|
+
DatabaseCleaner.clean_with(:truncation)
|
59
|
+
end
|
60
|
+
|
61
|
+
config.before(:each) do
|
62
|
+
DatabaseCleaner.start
|
63
|
+
end
|
64
|
+
|
65
|
+
config.after(:each) do
|
66
|
+
DatabaseCleaner.clean
|
67
|
+
end
|
68
|
+
end
|
@@ -1,11 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe MembershipsController, type: :routing do
|
5
|
+
describe 'routing' do
|
6
|
+
routes { Engine.routes }
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
it 'routes to #show' do
|
9
|
+
expect(get: '/memberships/1').to route_to('popolo/memberships#show', id: '1')
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -1,15 +1,17 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe OrganizationsController, type: :routing do
|
5
|
+
describe 'routing' do
|
6
|
+
routes { Engine.routes }
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
it 'routes to #index' do
|
9
|
+
expect(get: '/organizations').to route_to('popolo/organizations#index')
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
it 'routes to #show' do
|
13
|
+
expect(get: '/organizations/1').to route_to('popolo/organizations#show', id: '1')
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe PeopleController, type: :routing do
|
5
|
+
describe 'routing' do
|
6
|
+
routes { Engine.routes }
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
it 'routes to #show' do
|
9
|
+
expect(get: '/people/1').to route_to('popolo/people#show', id: '1')
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
3
|
+
module Popolo
|
4
|
+
RSpec.describe PostsController, type: :routing do
|
5
|
+
describe 'routing' do
|
6
|
+
routes { Engine.routes }
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
it 'routes to #show' do
|
9
|
+
expect(get: '/posts/1').to route_to('popolo/posts#show', id: '1')
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,86 +1,76 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, make a
|
10
|
+
# separate helper file that requires this one and then use it only in the specs
|
11
|
+
# that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# The settings below are suggested to provide a good initial experience
|
19
|
+
# with RSpec, but feel free to customize to your heart's content.
|
20
|
+
# These two settings work together to allow you to limit a spec run
|
21
|
+
# to individual examples or groups you care about by tagging them with
|
22
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
23
|
+
# get run.
|
24
|
+
config.filter_run :focus
|
25
|
+
config.run_all_when_everything_filtered = true
|
26
|
+
|
27
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
28
|
+
# file, and it's useful to allow more verbose output when running an
|
29
|
+
# individual spec file.
|
30
|
+
if config.files_to_run.one?
|
31
|
+
# Use the documentation formatter for detailed output,
|
32
|
+
# unless a formatter has already been configured
|
33
|
+
# (e.g. via a command-line flag).
|
34
|
+
config.default_formatter = 'doc'
|
27
35
|
end
|
28
36
|
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
# Print the 10 slowest examples and example groups at the
|
38
|
+
# end of the spec run, to help surface which specs are running
|
39
|
+
# particularly slow.
|
40
|
+
# config.profile_examples = 10
|
41
|
+
|
42
|
+
# Run specs in random order to surface order dependencies. If you find an
|
43
|
+
# order dependency and want to debug it, you can fix the order by providing
|
44
|
+
# the seed, which is printed after each run.
|
45
|
+
# --seed 1234
|
46
|
+
# config.order = :random
|
47
|
+
|
48
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
49
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
50
|
+
# test failures related to randomization by passing the same `--seed` value
|
51
|
+
# as the one that triggered the failure.
|
52
|
+
Kernel.srand config.seed
|
53
|
+
|
54
|
+
# rspec-expectations config goes here. You can use an alternate
|
55
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
56
|
+
# assertions if you prefer.
|
57
|
+
config.expect_with :rspec do |expectations|
|
58
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
59
|
+
# For more details, see:
|
60
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
61
|
+
expectations.syntax = :expect
|
36
62
|
end
|
37
63
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
# http://railscasts.com/episodes/285-spork
|
51
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
52
|
-
config.run_all_when_everything_filtered = true
|
53
|
-
config.filter_run focus: true
|
54
|
-
config.infer_spec_type_from_file_location!
|
64
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
65
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
66
|
+
config.mock_with :rspec do |mocks|
|
67
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
68
|
+
# For more details, see:
|
69
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
70
|
+
mocks.syntax = :expect
|
71
|
+
|
72
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
73
|
+
# a real object. This is generally recommended.
|
74
|
+
mocks.verify_partial_doubles = true
|
55
75
|
end
|
56
76
|
end
|
57
|
-
|
58
|
-
Spork.each_run do
|
59
|
-
# DatabaseCleaner will not truncate system.indexes between tests, but it
|
60
|
-
# should be truncated before running the full test suite.
|
61
|
-
Mongoid::Sessions.default.drop
|
62
|
-
|
63
|
-
# It's now okay to load Popolo.
|
64
|
-
Rails.application.railties.engines.each do |engine|
|
65
|
-
if engine.engine_name == 'popolo'
|
66
|
-
engine.eager_load!
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# Create Popolo indexes.
|
71
|
-
Rails.application.railties.engines.each do |engine|
|
72
|
-
if engine.engine_name == 'popolo'
|
73
|
-
engine.paths["app/models"].expanded.each do |path|
|
74
|
-
Rails::Mongoid.create_indexes("#{path}/**/*.rb")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Create dummy indexes.
|
80
|
-
Rails::Mongoid.create_indexes(File.expand_path("../dummy/app/models/**/*.rb", __FILE__))
|
81
|
-
|
82
|
-
# @todo I18n.backend.reload!
|
83
|
-
|
84
|
-
require 'factory_girl_rails'
|
85
|
-
FactoryGirl.reload
|
86
|
-
end
|