seed_loader 0.0.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.
Files changed (67) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +8 -0
  3. data/MIT-LICENSE +21 -0
  4. data/README +0 -0
  5. data/README.rdoc +55 -0
  6. data/Rakefile +30 -0
  7. data/lib/seed_loader/active_record_methods.rb +49 -0
  8. data/lib/seed_loader/loader.rb +76 -0
  9. data/lib/seed_loader/version.rb +3 -0
  10. data/lib/seed_loader.rb +5 -0
  11. data/seed_loader.gemspec +26 -0
  12. data/test/dummy/Gemfile +7 -0
  13. data/test/dummy/Rakefile +7 -0
  14. data/test/dummy/app/assets/javascripts/application.js +9 -0
  15. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  16. data/test/dummy/app/controllers/application_controller.rb +3 -0
  17. data/test/dummy/app/helpers/application_helper.rb +2 -0
  18. data/test/dummy/app/mailers/.gitkeep +0 -0
  19. data/test/dummy/app/models/.gitkeep +0 -0
  20. data/test/dummy/app/models/dummy_table.rb +5 -0
  21. data/test/dummy/app/models/dummy_user.rb +2 -0
  22. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  23. data/test/dummy/config/application.rb +45 -0
  24. data/test/dummy/config/boot.rb +10 -0
  25. data/test/dummy/config/database.yml +13 -0
  26. data/test/dummy/config/environment.rb +5 -0
  27. data/test/dummy/config/environments/development.rb +30 -0
  28. data/test/dummy/config/environments/production.rb +60 -0
  29. data/test/dummy/config/environments/test.rb +39 -0
  30. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  31. data/test/dummy/config/initializers/inflections.rb +10 -0
  32. data/test/dummy/config/initializers/mime_types.rb +5 -0
  33. data/test/dummy/config/initializers/secret_token.rb +7 -0
  34. data/test/dummy/config/initializers/session_store.rb +8 -0
  35. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  36. data/test/dummy/config/locales/en.yml +5 -0
  37. data/test/dummy/config/routes.rb +58 -0
  38. data/test/dummy/config.ru +4 -0
  39. data/test/dummy/db/.DS_Store +0 -0
  40. data/test/dummy/db/migrate/.DS_Store +0 -0
  41. data/test/dummy/db/migrate/20111027142111_create_dummy_tables.rb +11 -0
  42. data/test/dummy/db/migrate/20111027142236_create_dummy_users.rb +9 -0
  43. data/test/dummy/db/schema.rb +29 -0
  44. data/test/dummy/db/seeds/dummy_tables.yml +12 -0
  45. data/test/dummy/db/seeds/dummy_users.yml +10 -0
  46. data/test/dummy/dummy_development +0 -0
  47. data/test/dummy/dummy_test +0 -0
  48. data/test/dummy/lib/assets/.gitkeep +0 -0
  49. data/test/dummy/log/.gitkeep +0 -0
  50. data/test/dummy/log/development.log +37 -0
  51. data/test/dummy/log/test.log +2025 -0
  52. data/test/dummy/public/404.html +26 -0
  53. data/test/dummy/public/422.html +26 -0
  54. data/test/dummy/public/500.html +26 -0
  55. data/test/dummy/public/favicon.ico +0 -0
  56. data/test/dummy/script/rails +6 -0
  57. data/test/dummy/test/fixtures/dummy_tables.yml +11 -0
  58. data/test/dummy/test/fixtures/dummy_users.yml +7 -0
  59. data/test/dummy/test/fixtures/positions.yml +9 -0
  60. data/test/dummy/test/unit/dummy_table_test.rb +7 -0
  61. data/test/dummy/test/unit/dummy_user_test.rb +7 -0
  62. data/test/dummy/test/unit/position_test.rb +7 -0
  63. data/test/seed_loader_test.rb +99 -0
  64. data/test/seeds/dummy_tables.yml +12 -0
  65. data/test/seeds/dummy_users.yml +10 -0
  66. data/test/test_helper.rb +10 -0
  67. metadata +242 -0
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in seed_loader.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'ruby-debug'
8
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) 2011 Marc Essindi <marc.essindi@dunkelbraun.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README ADDED
File without changes
data/README.rdoc ADDED
@@ -0,0 +1,55 @@
1
+ = Seed Loader -- YAML seed file loading for Rails.
2
+
3
+ Seed Loader enables you to write seed files in YAML and load them into the database.
4
+
5
+ == Download and installation
6
+
7
+ The latest version of Seed Loader can be installed with Rubygems:
8
+ % [sudo] gem install seed_loader
9
+
10
+ Include the gem in your Gemfile:
11
+ gem 'seed_loader'
12
+
13
+ Source code can be downloaded from Github:
14
+
15
+ * http://github.com/dunkelbraun/seed_loader
16
+
17
+ == Usage
18
+
19
+ Put your YAML based seeds into db/seeds/model_table_name.yml
20
+
21
+ For a Country model with attributes name and population,
22
+ the seed file (db/seeds/countries.yml) content would be:
23
+
24
+ country_1:
25
+ name: Australia
26
+ population: 1233344
27
+
28
+
29
+ For belongs_to relationships, you can reference the relationship with the seed name.
30
+ If a City belongs to a country then:
31
+ city_1:
32
+ name: Melbourne
33
+ country: country_1
34
+
35
+ You can also write ruby code inside the YAML seed files:
36
+ city_1:
37
+ name: Melbourne
38
+ country: country_1
39
+ founded_in: <%= 30.years.ago.to_s(:db) %>
40
+
41
+
42
+ In the db/seeds.rb file
43
+
44
+ SeedLoader::Loader.seed_files_to_db
45
+
46
+
47
+ Run the seeds rake task
48
+
49
+ rake db:seed
50
+
51
+
52
+ == License
53
+
54
+ Seed Loader is released under the MIT license.
55
+
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env rake
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require "bundler/gem_tasks"
5
+ require 'rake/testtask'
6
+ require 'rdoc/task'
7
+
8
+ desc 'Default: run unit tests.'
9
+ task :default => :test
10
+
11
+ desc 'Test the geo_ruby_additions plugin.'
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'lib'
14
+ t.libs << 'test'
15
+ t.test_files = FileList['test/*_test.rb']
16
+ t.loader = :direct
17
+ t.verbose = true
18
+ end
19
+
20
+ desc 'Generate documentation for the geo_ruby_additions plugin.'
21
+ RDoc::Task.new(:rdoc) do |rdoc|
22
+ rdoc.rdoc_dir = 'rdoc'
23
+ rdoc.title = 'GeoRubyAdditions'
24
+ rdoc.options << '--line-numbers' << '--inline-source'
25
+ rdoc.rdoc_files.include('README')
26
+ rdoc.rdoc_files.include('lib/**/*.rb')
27
+ end
28
+
29
+
30
+
@@ -0,0 +1,49 @@
1
+ module SeedLoader
2
+
3
+ module ActiveRecordMethods
4
+
5
+ def self.included(mod)
6
+ raise "reset_autoincrement already defined in ActiveRecord::Base" if ActiveRecord::Base.methods.include?('reset_autoincrement')
7
+ raise "belongs_to_associations_names already defined in ActiveRecord::Base" if ActiveRecord::Base.methods.include?('belongs_to_associations_names')
8
+ raise "belongs_to_associations already defined in ActiveRecord::Base" if ActiveRecord::Base.methods.include?('belongs_to_associations')
9
+ mod.extend ClassMethods
10
+ end
11
+
12
+ module ClassMethods
13
+
14
+ def reset_autoincrement(options={})
15
+ options[:to] ||= 1
16
+ case self.connection.adapter_name
17
+ when 'MySQL'
18
+ self.connection.execute "ALTER TABLE #{self.table_name} AUTO_INCREMENT=#{options[:to]}"
19
+ when 'Mysql2'
20
+ self.connection.execute "ALTER TABLE #{self.table_name} AUTO_INCREMENT=#{options[:to]}"
21
+ when 'PostgreSQL'
22
+ self.connection.execute "ALTER SEQUENCE #{self.table_name}_id_seq RESTART WITH #{options[:to]};"
23
+ when 'SQLite'
24
+ self.connection.execute "UPDATE sqlite_sequence SET seq=#{options[:to]-1} WHERE name='#{self.table_name}';"
25
+ else
26
+ end
27
+ end
28
+
29
+ def belongs_to_associations_names
30
+ self.belongs_to_associations.map(&:name)
31
+ end
32
+
33
+ def belongs_to_associations
34
+ self.reflect_on_all_associations.find_all {|association| association.macro == :belongs_to}
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+
43
+
44
+
45
+ class ActiveRecord::Base
46
+
47
+ include SeedLoader::ActiveRecordMethods
48
+
49
+ end
@@ -0,0 +1,76 @@
1
+ module SeedLoader
2
+
3
+ module Loader
4
+
5
+ @@loaded_seeds = {}
6
+ @@seeds_path = "/db/seeds"
7
+
8
+ class << self
9
+
10
+ def seeds_path
11
+ @@seeds_path
12
+ end
13
+
14
+ def seeds_path=(file_path)
15
+ @@seeds_path = file_path
16
+ end
17
+
18
+ def seed_files_to_db
19
+ @@loaded_seeds = {}
20
+ puts Dir.glob( self.seeds_path )
21
+ Dir.glob( Rails.root.to_s + self.seeds_path + "/*" ).each { |file_path| load_seed_file(file_path) }
22
+ end
23
+
24
+ private
25
+
26
+ def load_seed_file(file_path)
27
+ mod, file_ext = model_and_extension_from_file_path(file_path)
28
+ return if seeds_loaded_for_model?(mod)
29
+ case file_ext
30
+ when "yml"
31
+ seed_data = YAML.load(ERB.new(IO.read(file_path)).result)
32
+ end
33
+ mod.delete_all
34
+ mod.reset_autoincrement
35
+ belongs_to_associations = mod.belongs_to_associations.map(&:name)
36
+ seed_data.each do |seed_name,attrs|
37
+ if belongs_to_associations.present?
38
+ attrs.each do |key, val|
39
+ if belongs_to_associations.include?(key.to_sym)
40
+ association = mod.belongs_to_associations.detect { |association| association.name == key.to_sym}
41
+ load_seed_for_model(association.name.to_s.classify.constantize)
42
+ association_model = key.classify.constantize
43
+ attrs[association_foreign_key(association)] = @@loaded_seeds[association_model.table_name][val]["id"]
44
+ attrs.delete(key)
45
+ end
46
+ end
47
+ end
48
+ obj = mod.create(attrs)
49
+ attrs["id"] = obj[:id]
50
+ end
51
+ @@loaded_seeds[mod.table_name] = seed_data
52
+ end
53
+
54
+ def seeds_loaded_for_model?(mod)
55
+ @@loaded_seeds[mod.table_name].present?
56
+ end
57
+
58
+ def model_and_extension_from_file_path(file_path)
59
+ match = file_path.match(/\/(\w+)\.(yml)$/)
60
+ [ match[1].classify.constantize, match[2] ]
61
+ end
62
+
63
+ def association_foreign_key(assoc)
64
+ (assoc.options[:foreign_key] || assoc.association_foreign_key).to_s
65
+ end
66
+
67
+ def load_seed_for_model(mod)
68
+ file_path = "#{Rails.root}/db/seeds/#{mod.table_name}.yml"
69
+ load_seed_file file_path
70
+ end
71
+
72
+ end
73
+
74
+ end
75
+
76
+ end
@@ -0,0 +1,3 @@
1
+ module SeedLoader
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "seed_loader/version"
2
+
3
+
4
+ require "seed_loader/loader"
5
+ require "seed_loader/active_record_methods"
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "seed_loader/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "seed_loader"
7
+ s.version = SeedLoader::VERSION
8
+ s.authors = ["Marc Essindi"]
9
+ s.email = ["marc.essindi@dunkelbraun.com"]
10
+ s.homepage = "https://github.com/dunkelbraun/Seed-Loader"
11
+ s.summary = "YAML seed file loading for Rails."
12
+
13
+ s.rubyforge_project = "seed_loader"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency "rails", ">=3.0.3"
21
+
22
+ s.add_development_dependency "sqlite3"
23
+ s.add_development_dependency "mysql2"
24
+ s.add_development_dependency "pg"
25
+
26
+ end
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '3.1.1'
4
+
5
+ gem 'sqlite3'
6
+ gem 'mysql2'
7
+ gem 'pg'
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ class DummyTable < ActiveRecord::Base
2
+
3
+ belongs_to :dummy_user
4
+
5
+ end
@@ -0,0 +1,2 @@
1
+ class DummyUser < ActiveRecord::Base
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require
6
+ require "seed_loader"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Custom directories with classes and modules you want to be autoloadable.
15
+ # config.autoload_paths += %W(#{config.root}/extras)
16
+
17
+ # Only load the plugins named here, in the order given (default is alphabetical).
18
+ # :all can be used as a placeholder for all plugins not explicitly named.
19
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
+
21
+ # Activate observers that should always be running.
22
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
+
24
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
+ # config.time_zone = 'Central Time (US & Canada)'
27
+
28
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
+ # config.i18n.default_locale = :de
31
+
32
+ # Configure the default encoding used in templates for Ruby 1.9.
33
+ config.encoding = "utf-8"
34
+
35
+ # Configure sensitive parameters which will be filtered from the log file.
36
+ config.filter_parameters += [:password]
37
+
38
+ # Enable the asset pipeline
39
+ config.assets.enabled = true
40
+
41
+ # Version of your assets, change this if you want to expire all your assets
42
+ config.assets.version = '1.0'
43
+ end
44
+ end
45
+
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,13 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: dummy_development
4
+ pool: 5
5
+ timeout: 5000
6
+
7
+
8
+ test:
9
+ adapter: sqlite3
10
+ database: dummy_test
11
+ pool: 5
12
+ timeout: 5000
13
+
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,30 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Do not compress assets
26
+ config.assets.compress = false
27
+
28
+ # Expands the lines which load the assets
29
+ config.assets.debug = true
30
+ end
@@ -0,0 +1,60 @@
1
+ Dummy::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
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Defaults to Rails.root.join("public/assets")
24
+ # config.assets.manifest = YOUR_PATH
25
+
26
+ # Specifies the header that your server uses for sending files
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # See everything in the log (default is :info)
34
+ # config.log_level = :debug
35
+
36
+ # Use a different logger for distributed setups
37
+ # config.logger = SyslogLogger.new
38
+
39
+ # Use a different cache store in production
40
+ # config.cache_store = :mem_cache_store
41
+
42
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
43
+ # config.action_controller.asset_host = "http://assets.example.com"
44
+
45
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46
+ # config.assets.precompile += %w( search.js )
47
+
48
+ # Disable delivery errors, bad email addresses will be ignored
49
+ # config.action_mailer.raise_delivery_errors = false
50
+
51
+ # Enable threaded mode
52
+ # config.threadsafe!
53
+
54
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55
+ # the I18n.default_locale when a translation can not be found)
56
+ config.i18n.fallbacks = true
57
+
58
+ # Send deprecation notices to registered listeners
59
+ config.active_support.deprecation = :notify
60
+ end
@@ -0,0 +1,39 @@
1
+ Dummy::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
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ config.action_mailer.delivery_method = :test
31
+
32
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
33
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
34
+ # like if you have constraints or database-specific column types
35
+ # config.active_record.schema_format = :sql
36
+
37
+ # Print deprecation notices to the stderr
38
+ config.active_support.deprecation = :stderr
39
+ end
@@ -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,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = 'e2e12181c59dbc754c90c093e58df5b1861fbc45b1a39a2d26c8265621776d33eed21dfe4a0deb05be0055a3c029620a0538dcddcdb81b14bb51eff5fcd316e5'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -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]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"