active_hash_relation 1.1.0 → 1.2.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/.rspec +2 -0
- data/.travis.yml +15 -0
- data/README.md +68 -11
- data/active_hash_relation.gemspec +13 -0
- data/lib/active_hash_relation.rb +18 -12
- data/lib/active_hash_relation/aggregation.rb +3 -0
- data/lib/active_hash_relation/association_filters.rb +3 -0
- data/lib/active_hash_relation/column_filters.rb +45 -11
- data/lib/active_hash_relation/filter_applier.rb +37 -23
- data/lib/active_hash_relation/helpers.rb +22 -2
- data/lib/active_hash_relation/scope_filters.rb +8 -1
- data/lib/active_hash_relation/sort_filters.rb +12 -0
- data/lib/active_hash_relation/version.rb +1 -1
- data/lib/active_record/scope_names.rb +4 -19
- data/lib/generators/active_hash_relation/initialize_generator.rb +13 -0
- data/lib/generators/active_hash_relation/templates/active_hash_relation.rb +12 -0
- data/spec/config/initializers/active_hash_relation.rb +16 -0
- data/spec/db/migrate/001_basic_schema.rb +53 -0
- data/spec/dummy-rails4/.gitignore +13 -0
- data/spec/dummy-rails4/.ruby-version +1 -0
- data/spec/dummy-rails4/Gemfile +18 -0
- data/spec/dummy-rails4/README.md +3 -0
- data/spec/dummy-rails4/Rakefile +6 -0
- data/spec/dummy-rails4/app/controllers/application_controller.rb +5 -0
- data/spec/dummy-rails4/app/models/.keep +0 -0
- data/spec/dummy-rails4/app/models/address.rb +1 -0
- data/spec/dummy-rails4/app/models/micropost.rb +1 -0
- data/spec/dummy-rails4/app/models/relationship.rb +1 -0
- data/spec/dummy-rails4/app/models/user.rb +1 -0
- data/spec/dummy-rails4/bin/bundle +3 -0
- data/spec/dummy-rails4/bin/rails +4 -0
- data/spec/dummy-rails4/bin/rake +4 -0
- data/spec/dummy-rails4/bin/setup +29 -0
- data/spec/dummy-rails4/config.ru +4 -0
- data/spec/dummy-rails4/config/application.rb +35 -0
- data/spec/dummy-rails4/config/boot.rb +3 -0
- data/spec/dummy-rails4/config/database.yml +18 -0
- data/spec/dummy-rails4/config/environment.rb +5 -0
- data/spec/dummy-rails4/config/environments/development.rb +41 -0
- data/spec/dummy-rails4/config/environments/production.rb +79 -0
- data/spec/dummy-rails4/config/environments/test.rb +42 -0
- data/spec/dummy-rails4/config/initializers/active_hash_relation.rb +3 -0
- data/spec/dummy-rails4/config/initializers/assets.rb +11 -0
- data/spec/dummy-rails4/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy-rails4/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy-rails4/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy-rails4/config/initializers/inflections.rb +16 -0
- data/spec/dummy-rails4/config/initializers/mime_types.rb +4 -0
- data/spec/dummy-rails4/config/initializers/session_store.rb +3 -0
- data/spec/dummy-rails4/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy-rails4/config/locales/en.yml +23 -0
- data/spec/dummy-rails4/config/routes.rb +56 -0
- data/spec/dummy-rails4/config/secrets.yml +22 -0
- data/spec/dummy-rails4/db/migrate/001_basic_schema.rb +1 -0
- data/spec/dummy-rails4/db/schema.rb +69 -0
- data/spec/dummy-rails4/spec/factories/factories.rb +1 -0
- data/spec/dummy-rails4/spec/rails_helper.rb +19 -0
- data/spec/dummy-rails4/spec/spec_helper.rb +99 -0
- data/spec/dummy-rails4/spec/support/support.rb +1 -0
- data/spec/dummy-rails4/spec/tests/tests_spec.rb +3 -0
- data/spec/dummy-rails5/.gitignore +17 -0
- data/spec/dummy-rails5/.rspec +2 -0
- data/spec/dummy-rails5/.ruby-version +1 -0
- data/spec/dummy-rails5/Gemfile +19 -0
- data/spec/dummy-rails5/README.md +3 -0
- data/spec/dummy-rails5/Rakefile +6 -0
- data/spec/dummy-rails5/app/controllers/application_controller.rb +3 -0
- data/spec/dummy-rails5/app/models/address.rb +1 -0
- data/spec/dummy-rails5/app/models/micropost.rb +1 -0
- data/spec/dummy-rails5/app/models/relationship.rb +1 -0
- data/spec/dummy-rails5/app/models/user.rb +1 -0
- data/spec/dummy-rails5/bin/bundle +3 -0
- data/spec/dummy-rails5/bin/rails +4 -0
- data/spec/dummy-rails5/bin/rake +4 -0
- data/spec/dummy-rails5/bin/setup +34 -0
- data/spec/dummy-rails5/bin/update +29 -0
- data/spec/dummy-rails5/config.ru +5 -0
- data/spec/dummy-rails5/config/application.rb +25 -0
- data/spec/dummy-rails5/config/boot.rb +3 -0
- data/spec/dummy-rails5/config/cable.yml +9 -0
- data/spec/dummy-rails5/config/database.yml +18 -0
- data/spec/dummy-rails5/config/environment.rb +5 -0
- data/spec/dummy-rails5/config/environments/development.rb +54 -0
- data/spec/dummy-rails5/config/environments/production.rb +86 -0
- data/spec/dummy-rails5/config/environments/test.rb +42 -0
- data/spec/dummy-rails5/config/initializers/active_hash_relation.rb +3 -0
- data/spec/dummy-rails5/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy-rails5/config/initializers/assets.rb +11 -0
- data/spec/dummy-rails5/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy-rails5/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy-rails5/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy-rails5/config/initializers/inflections.rb +16 -0
- data/spec/dummy-rails5/config/initializers/mime_types.rb +4 -0
- data/spec/dummy-rails5/config/initializers/new_framework_defaults.rb +24 -0
- data/spec/dummy-rails5/config/initializers/session_store.rb +3 -0
- data/spec/dummy-rails5/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy-rails5/config/locales/en.yml +23 -0
- data/spec/dummy-rails5/config/puma.rb +47 -0
- data/spec/dummy-rails5/config/routes.rb +3 -0
- data/spec/dummy-rails5/config/secrets.yml +22 -0
- data/spec/dummy-rails5/config/spring.rb +6 -0
- data/spec/dummy-rails5/db/migrate/001_basic_schema.rb +2 -0
- data/spec/dummy-rails5/db/schema.rb +64 -0
- data/spec/dummy-rails5/spec/factories/factories.rb +1 -0
- data/spec/dummy-rails5/spec/rails_helper.rb +19 -0
- data/spec/dummy-rails5/spec/spec_helper.rb +99 -0
- data/spec/dummy-rails5/spec/support/support.rb +1 -0
- data/spec/dummy-rails5/spec/tests/tests_spec.rb +3 -0
- data/spec/factories/factories.rb +39 -0
- data/spec/models/address.rb +7 -0
- data/spec/models/application_record.rb +3 -0
- data/spec/models/micropost.rb +9 -0
- data/spec/models/relationship.rb +9 -0
- data/spec/models/user.rb +32 -0
- data/spec/support/support.rb +62 -0
- data/spec/tests/aggregations/avg_spec.rb +45 -0
- data/spec/tests/aggregations/max_spec.rb +45 -0
- data/spec/tests/aggregations/min_spec.rb +46 -0
- data/spec/tests/aggregations/sum_spec.rb +43 -0
- data/spec/tests/associations/belongs_to_spec.rb +96 -0
- data/spec/tests/associations/has_many_spec.rb +91 -0
- data/spec/tests/associations/has_one_spec.rb +89 -0
- data/spec/tests/booleans_spec.rb +29 -0
- data/spec/tests/limit_spec.rb +30 -0
- data/spec/tests/null_spec.rb +44 -0
- data/spec/tests/numbers_spec.rb +142 -0
- data/spec/tests/or_filter_spec.rb +98 -0
- data/spec/tests/primary_key_spec.rb +29 -0
- data/spec/tests/scopes_spec.rb +48 -0
- data/spec/tests/sorting_spec.rb +100 -0
- data/spec/tests/strings_spec.rb +86 -0
- metadata +392 -4
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Rails.application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
|
+
|
|
4
|
+
# Code is not reloaded between requests.
|
|
5
|
+
config.cache_classes = true
|
|
6
|
+
|
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
|
8
|
+
# your application in memory, allowing both threaded web servers
|
|
9
|
+
# and those relying on copy on write to perform better.
|
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
|
11
|
+
config.eager_load = true
|
|
12
|
+
|
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
|
14
|
+
config.consider_all_requests_local = false
|
|
15
|
+
config.action_controller.perform_caching = true
|
|
16
|
+
|
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like
|
|
20
|
+
# NGINX, varnish or squid.
|
|
21
|
+
# config.action_dispatch.rack_cache = true
|
|
22
|
+
|
|
23
|
+
# Disable serving static files from the `/public` folder by default since
|
|
24
|
+
# Apache or NGINX already handles this.
|
|
25
|
+
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
|
26
|
+
|
|
27
|
+
# Compress JavaScripts and CSS.
|
|
28
|
+
config.assets.js_compressor = :uglifier
|
|
29
|
+
# config.assets.css_compressor = :sass
|
|
30
|
+
|
|
31
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
|
32
|
+
config.assets.compile = false
|
|
33
|
+
|
|
34
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
|
35
|
+
# yet still be able to expire them through the digest params.
|
|
36
|
+
config.assets.digest = true
|
|
37
|
+
|
|
38
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
|
39
|
+
|
|
40
|
+
# Specifies the header that your server uses for sending files.
|
|
41
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
|
42
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
|
43
|
+
|
|
44
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
|
45
|
+
# config.force_ssl = true
|
|
46
|
+
|
|
47
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
|
48
|
+
# when problems arise.
|
|
49
|
+
config.log_level = :debug
|
|
50
|
+
|
|
51
|
+
# Prepend all log lines with the following tags.
|
|
52
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
|
53
|
+
|
|
54
|
+
# Use a different logger for distributed setups.
|
|
55
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
|
56
|
+
|
|
57
|
+
# Use a different cache store in production.
|
|
58
|
+
# config.cache_store = :mem_cache_store
|
|
59
|
+
|
|
60
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
|
61
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
|
62
|
+
|
|
63
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
|
64
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
|
65
|
+
# config.action_mailer.raise_delivery_errors = false
|
|
66
|
+
|
|
67
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
|
68
|
+
# the I18n.default_locale when a translation cannot be found).
|
|
69
|
+
config.i18n.fallbacks = true
|
|
70
|
+
|
|
71
|
+
# Send deprecation notices to registered listeners.
|
|
72
|
+
config.active_support.deprecation = :notify
|
|
73
|
+
|
|
74
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
|
75
|
+
config.log_formatter = ::Logger::Formatter.new
|
|
76
|
+
|
|
77
|
+
# Do not dump schema after migrations.
|
|
78
|
+
config.active_record.dump_schema_after_migration = false
|
|
79
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Rails.application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
|
+
|
|
4
|
+
# The test environment is used exclusively to run your application's
|
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
|
8
|
+
config.cache_classes = true
|
|
9
|
+
|
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
|
13
|
+
config.eager_load = false
|
|
14
|
+
|
|
15
|
+
# Configure static file server for tests with Cache-Control for performance.
|
|
16
|
+
config.serve_static_files = true
|
|
17
|
+
config.static_cache_control = 'public, max-age=3600'
|
|
18
|
+
|
|
19
|
+
# Show full error reports and disable caching.
|
|
20
|
+
config.consider_all_requests_local = true
|
|
21
|
+
config.action_controller.perform_caching = false
|
|
22
|
+
|
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
|
24
|
+
config.action_dispatch.show_exceptions = false
|
|
25
|
+
|
|
26
|
+
# Disable request forgery protection in test environment.
|
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
|
28
|
+
|
|
29
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
|
30
|
+
# The :test delivery method accumulates sent emails in the
|
|
31
|
+
# ActionMailer::Base.deliveries array.
|
|
32
|
+
config.action_mailer.delivery_method = :test
|
|
33
|
+
|
|
34
|
+
# Randomize the order test cases are executed.
|
|
35
|
+
config.active_support.test_order = :random
|
|
36
|
+
|
|
37
|
+
# Print deprecation notices to the stderr.
|
|
38
|
+
config.active_support.deprecation = :stderr
|
|
39
|
+
|
|
40
|
+
# Raises error for missing translations
|
|
41
|
+
# config.action_view.raise_on_missing_translations = true
|
|
42
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
|
4
|
+
Rails.application.config.assets.version = '1.0'
|
|
5
|
+
|
|
6
|
+
# Add additional assets to the asset load path
|
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
|
8
|
+
|
|
9
|
+
# Precompile additional assets.
|
|
10
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
|
11
|
+
# Rails.application.config.assets.precompile += %w( search.js )
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
|
5
|
+
|
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
|
4
|
+
# are locale specific, and you may define rules for as many different
|
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
|
9
|
+
# inflect.irregular 'person', 'people'
|
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
|
11
|
+
# end
|
|
12
|
+
|
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
|
15
|
+
# inflect.acronym 'RESTful'
|
|
16
|
+
# end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
|
4
|
+
# is enabled by default.
|
|
5
|
+
|
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
|
8
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
|
13
|
+
# self.include_root_in_json = true
|
|
14
|
+
# end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
|
3
|
+
# than English, add the necessary files in this directory.
|
|
4
|
+
#
|
|
5
|
+
# To use the locales, use `I18n.t`:
|
|
6
|
+
#
|
|
7
|
+
# I18n.t 'hello'
|
|
8
|
+
#
|
|
9
|
+
# In views, this is aliased to just `t`:
|
|
10
|
+
#
|
|
11
|
+
# <%= t('hello') %>
|
|
12
|
+
#
|
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
|
14
|
+
#
|
|
15
|
+
# I18n.locale = :es
|
|
16
|
+
#
|
|
17
|
+
# This would use the information in config/locales/es.yml.
|
|
18
|
+
#
|
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
|
21
|
+
|
|
22
|
+
en:
|
|
23
|
+
hello: "Hello world"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Rails.application.routes.draw do
|
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
|
3
|
+
# See how all your routes lay out with "rake routes".
|
|
4
|
+
|
|
5
|
+
# You can have the root of your site routed with "root"
|
|
6
|
+
# root 'welcome#index'
|
|
7
|
+
|
|
8
|
+
# Example of regular route:
|
|
9
|
+
# get 'products/:id' => 'catalog#view'
|
|
10
|
+
|
|
11
|
+
# Example of named route that can be invoked with purchase_url(id: product.id)
|
|
12
|
+
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
|
13
|
+
|
|
14
|
+
# Example resource route (maps HTTP verbs to controller actions automatically):
|
|
15
|
+
# resources :products
|
|
16
|
+
|
|
17
|
+
# Example resource route with options:
|
|
18
|
+
# resources :products do
|
|
19
|
+
# member do
|
|
20
|
+
# get 'short'
|
|
21
|
+
# post 'toggle'
|
|
22
|
+
# end
|
|
23
|
+
#
|
|
24
|
+
# collection do
|
|
25
|
+
# get 'sold'
|
|
26
|
+
# end
|
|
27
|
+
# end
|
|
28
|
+
|
|
29
|
+
# Example resource route with sub-resources:
|
|
30
|
+
# resources :products do
|
|
31
|
+
# resources :comments, :sales
|
|
32
|
+
# resource :seller
|
|
33
|
+
# end
|
|
34
|
+
|
|
35
|
+
# Example resource route with more complex sub-resources:
|
|
36
|
+
# resources :products do
|
|
37
|
+
# resources :comments
|
|
38
|
+
# resources :sales do
|
|
39
|
+
# get 'recent', on: :collection
|
|
40
|
+
# end
|
|
41
|
+
# end
|
|
42
|
+
|
|
43
|
+
# Example resource route with concerns:
|
|
44
|
+
# concern :toggleable do
|
|
45
|
+
# post 'toggle'
|
|
46
|
+
# end
|
|
47
|
+
# resources :posts, concerns: :toggleable
|
|
48
|
+
# resources :photos, concerns: :toggleable
|
|
49
|
+
|
|
50
|
+
# Example resource route within a namespace:
|
|
51
|
+
# namespace :admin do
|
|
52
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
|
53
|
+
# # (app/controllers/admin/products_controller.rb)
|
|
54
|
+
# resources :products
|
|
55
|
+
# end
|
|
56
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
|
5
|
+
|
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
|
9
|
+
|
|
10
|
+
# Make sure the secrets in this file are kept private
|
|
11
|
+
# if you're sharing your code publicly.
|
|
12
|
+
|
|
13
|
+
development:
|
|
14
|
+
secret_key_base: 139e319331a8e4bd3360b80628597ca68de76c23732fb2ff32b8dfddf0e31b70ae8d5e98b92ac44cc2d5962060110d1684df0eaaa2212e227e7f05280d668cd6
|
|
15
|
+
|
|
16
|
+
test:
|
|
17
|
+
secret_key_base: af4f922cc881ac4c33351ae16b511e608844c692114782fb6af22391fbd89eb51d0f8c7e3b52fd948e5925ff33ab2ffa6b9cac3657618b6c7ab5365f673072b2
|
|
18
|
+
|
|
19
|
+
# Do not keep production secrets in the repository,
|
|
20
|
+
# instead read values from the environment.
|
|
21
|
+
production:
|
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative '../../../db/migrate/001_basic_schema'
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
|
5
|
+
#
|
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
|
7
|
+
# database schema. If you need to create the application database on another
|
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
|
11
|
+
#
|
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
|
13
|
+
|
|
14
|
+
ActiveRecord::Schema.define(version: 1) do
|
|
15
|
+
|
|
16
|
+
# These are extensions that must be enabled in order to support this database
|
|
17
|
+
enable_extension "plpgsql"
|
|
18
|
+
|
|
19
|
+
create_table "addresses", force: :cascade do |t|
|
|
20
|
+
t.string "street"
|
|
21
|
+
t.string "city"
|
|
22
|
+
t.string "country"
|
|
23
|
+
t.integer "user_id"
|
|
24
|
+
t.datetime "created_at"
|
|
25
|
+
t.datetime "updated_at"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
add_index "addresses", ["user_id"], name: "index_addresses_on_user_id", unique: true, using: :btree
|
|
29
|
+
|
|
30
|
+
create_table "microposts", force: :cascade do |t|
|
|
31
|
+
t.text "content", null: false
|
|
32
|
+
t.integer "user_id", null: false
|
|
33
|
+
t.integer "likes", default: 0, null: false
|
|
34
|
+
t.integer "reposts", default: 0, null: false
|
|
35
|
+
t.integer "status", default: 0, null: false
|
|
36
|
+
t.datetime "created_at", null: false
|
|
37
|
+
t.datetime "updated_at", null: false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
add_index "microposts", ["user_id"], name: "index_microposts_on_user_id", using: :btree
|
|
41
|
+
|
|
42
|
+
create_table "relationships", force: :cascade do |t|
|
|
43
|
+
t.integer "follower_id"
|
|
44
|
+
t.integer "followed_id"
|
|
45
|
+
t.datetime "created_at", null: false
|
|
46
|
+
t.datetime "updated_at", null: false
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
add_index "relationships", ["followed_id"], name: "index_relationships_on_followed_id", using: :btree
|
|
50
|
+
add_index "relationships", ["follower_id", "followed_id"], name: "index_relationships_on_follower_id_and_followed_id", unique: true, using: :btree
|
|
51
|
+
add_index "relationships", ["follower_id"], name: "index_relationships_on_follower_id", using: :btree
|
|
52
|
+
|
|
53
|
+
create_table "users", force: :cascade do |t|
|
|
54
|
+
t.string "name"
|
|
55
|
+
t.string "email", null: false
|
|
56
|
+
t.boolean "admin", default: false
|
|
57
|
+
t.boolean "verified", default: false
|
|
58
|
+
t.string "token", null: false
|
|
59
|
+
t.integer "microposts_count", default: 0, null: false
|
|
60
|
+
t.integer "followers_count", default: 0, null: false
|
|
61
|
+
t.integer "followings_count", default: 0, null: false
|
|
62
|
+
t.datetime "created_at", null: false
|
|
63
|
+
t.datetime "updated_at", null: false
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
|
|
67
|
+
|
|
68
|
+
add_foreign_key "microposts", "users"
|
|
69
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative '../../../factories/factories'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
|
3
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
|
4
|
+
require 'spec_helper'
|
|
5
|
+
require 'rspec/rails'
|
|
6
|
+
require File.expand_path('../../../../lib/active_hash_relation', __FILE__)
|
|
7
|
+
|
|
8
|
+
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
|
9
|
+
|
|
10
|
+
# Checks for pending migration and applies them before tests are run.
|
|
11
|
+
# If you are not using ActiveRecord, you can remove this line.
|
|
12
|
+
ActiveRecord::Migration.maintain_test_schema!
|
|
13
|
+
|
|
14
|
+
RSpec.configure do |config|
|
|
15
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
16
|
+
config.use_transactional_fixtures = true
|
|
17
|
+
config.infer_spec_type_from_file_location!
|
|
18
|
+
config.filter_rails_from_backtrace!
|
|
19
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
|
5
|
+
# files.
|
|
6
|
+
#
|
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
|
13
|
+
# it.
|
|
14
|
+
#
|
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
16
|
+
# users commonly want.
|
|
17
|
+
#
|
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
19
|
+
RSpec.configure do |config|
|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
22
|
+
# assertions if you prefer.
|
|
23
|
+
config.expect_with :rspec do |expectations|
|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
26
|
+
# defined using `chain`, e.g.:
|
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
29
|
+
# ...rather than:
|
|
30
|
+
# # => "be bigger than 2"
|
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
36
|
+
config.mock_with :rspec do |mocks|
|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
38
|
+
# a real object. This is generally recommended, and will default to
|
|
39
|
+
# `true` in RSpec 4.
|
|
40
|
+
mocks.verify_partial_doubles = true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
|
44
|
+
# have no way to turn it off -- the option exists only for backwards
|
|
45
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
|
46
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
|
47
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
|
48
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
49
|
+
|
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
52
|
+
=begin
|
|
53
|
+
# This allows you to limit a spec run to individual examples or groups
|
|
54
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
|
55
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
|
56
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
|
57
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
|
58
|
+
config.filter_run_when_matching :focus
|
|
59
|
+
|
|
60
|
+
# Allows RSpec to persist some state between runs in order to support
|
|
61
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
|
62
|
+
# you configure your source control system to ignore this file.
|
|
63
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
|
64
|
+
|
|
65
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
|
66
|
+
# recommended. For more details, see:
|
|
67
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
|
68
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
69
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
|
70
|
+
config.disable_monkey_patching!
|
|
71
|
+
|
|
72
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
73
|
+
# file, and it's useful to allow more verbose output when running an
|
|
74
|
+
# individual spec file.
|
|
75
|
+
if config.files_to_run.one?
|
|
76
|
+
# Use the documentation formatter for detailed output,
|
|
77
|
+
# unless a formatter has already been configured
|
|
78
|
+
# (e.g. via a command-line flag).
|
|
79
|
+
config.default_formatter = 'doc'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Print the 10 slowest examples and example groups at the
|
|
83
|
+
# end of the spec run, to help surface which specs are running
|
|
84
|
+
# particularly slow.
|
|
85
|
+
config.profile_examples = 10
|
|
86
|
+
|
|
87
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
88
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
89
|
+
# the seed, which is printed after each run.
|
|
90
|
+
# --seed 1234
|
|
91
|
+
config.order = :random
|
|
92
|
+
|
|
93
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
94
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
95
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
96
|
+
# as the one that triggered the failure.
|
|
97
|
+
Kernel.srand config.seed
|
|
98
|
+
=end
|
|
99
|
+
end
|