Commit 723176ac by cuong.tran

Merge branch 'release/v2.6.6'

parents 038b13c0 9b72c693
== 2.6.6
* Makes it possible to wrap annotations, #225
* Fix single model generation, #214
* Fix default value for Rails 4.2, #212
* Don't crash on inherited models in subdirectories, #232
* Process model_dir in rake task, #197
== 2.6.4 == 2.6.4
* Skip "models/concerns", #194 * Skip "models/concerns", #194
* Fix #173 where annotate says "Nothing to annotate" in rails 4.2 * Fix #173 where annotate says "Nothing to annotate" in rails 4.2
......
...@@ -13,7 +13,8 @@ end ...@@ -13,7 +13,8 @@ end
group :development, :test do group :development, :test do
gem 'rspec', :require => false gem 'rspec', :require => false
gem 'guard-rspec', require: false gem 'guard-rspec', :require => false
gem 'terminal-notifier-guard', :require => false
platforms :mri do platforms :mri do
gem 'pry', :require => false gem 'pry', :require => false
......
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
guard :rspec do # Note: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
# * spring: 'bin/rsspec' (This will use spring if running and you have
# installed the spring binstubs per the docs)
# * zeus: 'zeus rspec' (requires the server to be started separetly)
# * 'just' rspec: 'rspec'
guard :rspec, cmd: 'bundle exec rspec' do
watch(%r{^spec/.+_spec\.rb$}) watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" } watch('spec/spec_helper.rb') { "spec" }
...@@ -35,6 +20,7 @@ guard :rspec do ...@@ -35,6 +20,7 @@ guard :rspec do
watch(%r{^spec/support/(.+)\.rb$}) { "spec" } watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" } watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" } watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch('spec/rails_helper.rb') { "spec" }
# Capybara features specs # Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
......
...@@ -51,7 +51,7 @@ Also, if you pass the -r option, it'll annotate routes.rb with the output of ...@@ -51,7 +51,7 @@ Also, if you pass the -r option, it'll annotate routes.rb with the output of
Into Gemfile from rubygems.org: Into Gemfile from rubygems.org:
gem 'annotate', ">=2.6.0" gem 'annotate', '~> 2.6.6'
Into Gemfile from Github: Into Gemfile from Github:
...@@ -86,13 +86,13 @@ To annotate just your models, tests, and factories: ...@@ -86,13 +86,13 @@ To annotate just your models, tests, and factories:
To annotate just your models: To annotate just your models:
annotate --exclude tests,fixtures,factories annotate --exclude tests,fixtures,factories,serializers
To annotate routes.rb: To annotate routes.rb:
annotate --routes annotate --routes
To remove model/test/fixture/factory annotations: To remove model/test/fixture/factory/serializer annotations:
annotate --delete annotate --delete
...@@ -137,11 +137,11 @@ executed whenever you run +rake db:migrate+ (but only in development mode). ...@@ -137,11 +137,11 @@ executed whenever you run +rake db:migrate+ (but only in development mode).
If you want to disable this behavior permanently, edit the +.rake+ file and If you want to disable this behavior permanently, edit the +.rake+ file and
change: change:
'skip_on_db_migrate' => "false", 'skip_on_db_migrate' => 'false',
To: To:
'skip_on_db_migrate' => "true", 'skip_on_db_migrate' => 'true',
If you want to run +rake db:migrate+ as a one-off without running annotate, If you want to run +rake db:migrate+ as a one-off without running annotate,
you can do so with a simple environment variable, instead of editing the you can do so with a simple environment variable, instead of editing the
...@@ -154,33 +154,41 @@ you can do so with a simple environment variable, instead of editing the ...@@ -154,33 +154,41 @@ you can do so with a simple environment variable, instead of editing the
Usage: annotate [options] [model_file]* Usage: annotate [options] [model_file]*
-d, --delete Remove annotations from all model files or the routes.rb file -d, --delete Remove annotations from all model files or the routes.rb file
-p, --position [before|after] Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/routes file(s) -p, --position [before|top|after|bottom] Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/routes file(s)
--pc, --position-in-class [before|after] --pc, --position-in-class [before|top|after|bottom]
Place the annotations at the top (before) or the bottom (after) of the model file Place the annotations at the top (before) or the bottom (after) of the model file
--pf, --position-in-factory [before|after] --pf, --position-in-factory [before|top|after|bottom]
Place the annotations at the top (before) or the bottom (after) of any factory files Place the annotations at the top (before) or the bottom (after) of any factory files
--px, --position-in-fixture [before|after] --px, --position-in-fixture [before|top|after|bottom]
Place the annotations at the top (before) or the bottom (after) of any fixture files Place the annotations at the top (before) or the bottom (after) of any fixture files
--pt, --position-in-test [before|after] --pt, --position-in-test [before|top|after|bottom]
Place the annotations at the top (before) or the bottom (after) of any test files Place the annotations at the top (before) or the bottom (after) of any test files
--pr, --position-in-routes [before|after] --pr, --position-in-routes [before|top|after|bottom]
Place the annotations at the top (before) or the bottom (after) of the routes.rb file Place the annotations at the top (before) or the bottom (after) of the routes.rb file
--ps, --position-in-serializer [before|top|after|bottom]
Place the annotations at the top (before) or the bottom (after) of the serializer files
--w, --wrapper STR Wrap annotation with the text passed as parameter.
If --w option is used, the same text will be used as opening and closing
--wo, --wrapper-open STR Annotation wrapper opening.
--wc, --wrapper-close STR Annotation wrapper closing
-r, --routes Annotate routes.rb with the output of 'rake routes' -r, --routes Annotate routes.rb with the output of 'rake routes'
-v, --version Show the current version of this gem -v, --version Show the current version of this gem
-m, --show-migration Include the migration version number in the annotation -m, --show-migration Include the migration version number in the annotation
-i, --show-indexes List the table's database indexes in the annotation -i, --show-indexes List the table's database indexes in the annotation
-s, --simple-indexes Concat the column's related indexes in the annotation -s, --simple-indexes Concat the column's related indexes in the annotation
--model-dir dir Annotate model files stored in dir rather than app/models --model-dir dir Annotate model files stored in dir rather than app/models, separate multiple dirs with comas
--ignore-model-subdirects Ignore subdirectories of the models directory --ignore-model-subdirects Ignore subdirectories of the models directory
--sort Sort columns alphabetically, rather than in creation order --sort Sort columns alphabetically, rather than in creation order
-R, --require path Additional file to require before loading models, may be used multiple times -R, --require path Additional file to require before loading models, may be used multiple times
-e [tests,fixtures,factories], Do not annotate fixtures, test files, and/or factories -e [tests,fixtures,factories,serializers],
--exclude --exclude Do not annotate fixtures, test files, factories, and/or serializers
-f [bare|rdoc|markdown], Render Schema Infomation as plain/RDoc/Markdown -f [bare|rdoc|markdown], Render Schema Infomation as plain/RDoc/Markdown
--format --format
--force Force new annotations even if there are no changes. --force Force new annotations even if there are no changes.
--timestamp Include timestamp in (routes) annotation
--trace If unable to annotate a file, print the full stack trace, not just the exception message. --trace If unable to annotate a file, print the full stack trace, not just the exception message.
--timestamp Include an updated time in routes.rb -I, --ignore-columns REGEX don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`
== Sorting == Sorting
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
- clean up history - clean up history
- change default position back to "top" for all annotations - change default position back to "top" for all annotations
- add "top" and "bottom" as synonyms for "before" and "after"
- change 'exclude' to 'only' (double negatives are not unconfusing) - change 'exclude' to 'only' (double negatives are not unconfusing)
== TODO (proposed) == TODO (proposed)
......
...@@ -8,8 +8,7 @@ Gem::Specification.new do |s| ...@@ -8,8 +8,7 @@ Gem::Specification.new do |s|
s.version = Annotate.version s.version = Annotate.version
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Cuong Tran", "Alex Chaffee", "Marcos Piccinini", "Turadg Aleahmad", "Jon Frisby"] s.authors = ["Alex Chaffee", "Cuong Tran", "Marcos Piccinini", "Turadg Aleahmad", "Jon Frisby"]
s.date = "2014-06-16"
s.description = "Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema." s.description = "Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema."
s.email = ["alex@stinky.com", "cuong.tran@gmail.com", "x@nofxx.com", "turadg@aleahmad.net", "jon@cloudability.com"] s.email = ["alex@stinky.com", "cuong.tran@gmail.com", "x@nofxx.com", "turadg@aleahmad.net", "jon@cloudability.com"]
s.executables = ["annotate"] s.executables = ["annotate"]
...@@ -26,7 +25,7 @@ Gem::Specification.new do |s| ...@@ -26,7 +25,7 @@ Gem::Specification.new do |s|
s.specification_version = 4 s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rake>, [">= 0.8.7"]) s.add_runtime_dependency(%q<rake>, ["~> 10.4.2", ">= 10.4.2"])
s.add_runtime_dependency(%q<activerecord>, [">= 2.3.0"]) s.add_runtime_dependency(%q<activerecord>, [">= 2.3.0"])
else else
s.add_dependency(%q<rake>, [">= 0.8.7"]) s.add_dependency(%q<rake>, [">= 0.8.7"])
......
...@@ -32,46 +32,65 @@ OptionParser.new do |opts| ...@@ -32,46 +32,65 @@ OptionParser.new do |opts|
target[:task] = :remove_annotations target[:task] = :remove_annotations
end end
opts.on('-p', '--position [before|after]', ['before', 'after'], opts.on('-p', '--position [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
"Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/routes file(s)") do |p| "Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/routes file(s)") do |p|
ENV['position'] = p ENV['position'] = p
[ [
'position_in_class','position_in_factory','position_in_fixture','position_in_test', 'position_in_routes' 'position_in_class','position_in_factory','position_in_fixture','position_in_test', 'position_in_routes', 'position_in_serializer'
].each do |key| ].each do |key|
ENV[key] = p unless(has_set_position[key]) ENV[key] = p unless(has_set_position[key])
end end
end end
opts.on('--pc', '--position-in-class [before|after]', ['before', 'after'], opts.on('--pc', '--position-in-class [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
"Place the annotations at the top (before) or the bottom (after) of the model file") do |p| "Place the annotations at the top (before) or the bottom (after) of the model file") do |p|
ENV['position_in_class'] = p ENV['position_in_class'] = p
has_set_position['position_in_class'] = true has_set_position['position_in_class'] = true
end end
opts.on('--pf', '--position-in-factory [before|after]', ['before', 'after'], opts.on('--pf', '--position-in-factory [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
"Place the annotations at the top (before) or the bottom (after) of any factory files") do |p| "Place the annotations at the top (before) or the bottom (after) of any factory files") do |p|
ENV['position_in_factory'] = p ENV['position_in_factory'] = p
has_set_position['position_in_factory'] = true has_set_position['position_in_factory'] = true
end end
opts.on('--px', '--position-in-fixture [before|after]', ['before', 'after'], opts.on('--px', '--position-in-fixture [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
"Place the annotations at the top (before) or the bottom (after) of any fixture files") do |p| "Place the annotations at the top (before) or the bottom (after) of any fixture files") do |p|
ENV['position_in_fixture'] = p ENV['position_in_fixture'] = p
has_set_position['position_in_fixture'] = true has_set_position['position_in_fixture'] = true
end end
opts.on('--pt', '--position-in-test [before|after]', ['before', 'after'], opts.on('--pt', '--position-in-test [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
"Place the annotations at the top (before) or the bottom (after) of any test files") do |p| "Place the annotations at the top (before) or the bottom (after) of any test files") do |p|
ENV['position_in_test'] = p ENV['position_in_test'] = p
has_set_position['position_in_test'] = true has_set_position['position_in_test'] = true
end end
opts.on('--pr', '--position-in-routes [before|after]', ['before', 'after'], opts.on('--pr', '--position-in-routes [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
"Place the annotations at the top (before) or the bottom (after) of the routes.rb file") do |p| "Place the annotations at the top (before) or the bottom (after) of the routes.rb file") do |p|
ENV['position_in_routes'] = p ENV['position_in_routes'] = p
has_set_position['position_in_routes'] = true has_set_position['position_in_routes'] = true
end end
opts.on('--ps', '--position-in-serializer [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
"Place the annotations at the top (before) or the bottom (after) of the serializer files") do |p|
ENV['position_in_serializer'] = p
has_set_position['position_in_serializer'] = true
end
opts.on('--w', '--wrapper STR', 'Wrap annotation with the text passed as parameter.',
'If --w option is used, the same text will be used as opening and closing') do |p|
ENV['wrapper'] = p
end
opts.on('--wo', '--wrapper-open STR', 'Annotation wrapper opening.') do |p|
ENV['wrapper_open'] = p
end
opts.on('--wc', '--wrapper-close STR', 'Annotation wrapper closing') do |p|
ENV['wrapper_close'] = p
end
opts.on('-r', '--routes', opts.on('-r', '--routes',
"Annotate routes.rb with the output of 'rake routes'") do "Annotate routes.rb with the output of 'rake routes'") do
target = { target = {
...@@ -101,7 +120,7 @@ OptionParser.new do |opts| ...@@ -101,7 +120,7 @@ OptionParser.new do |opts|
end end
opts.on('--model-dir dir', opts.on('--model-dir dir',
"Annotate model files stored in dir rather than app/models") do |dir| "Annotate model files stored in dir rather than app/models, separate multiple dirs with comas") do |dir|
ENV['model_dir'] = dir ENV['model_dir'] = dir
end end
...@@ -115,6 +134,11 @@ OptionParser.new do |opts| ...@@ -115,6 +134,11 @@ OptionParser.new do |opts|
ENV['sort'] = "yes" ENV['sort'] = "yes"
end end
opts.on('--classified-sort',
"Sort columns alphabetically, but first goes id, then the rest columns, then the timestamp columns and then the association columns") do |dir|
ENV['classified_sort'] = "yes"
end
opts.on('-R', '--require path', opts.on('-R', '--require path',
"Additional file to require before loading models, may be used multiple times") do |path| "Additional file to require before loading models, may be used multiple times") do |path|
if !ENV['require'].blank? if !ENV['require'].blank?
...@@ -124,7 +148,7 @@ OptionParser.new do |opts| ...@@ -124,7 +148,7 @@ OptionParser.new do |opts|
end end
end end
opts.on('-e', '--exclude [tests,fixtures,factories]', Array, "Do not annotate fixtures, test files, and/or factories") do |exclusions| opts.on('-e', '--exclude [tests,fixtures,factories,serializers]', Array, "Do not annotate fixtures, test files, factories, and/or serializers") do |exclusions|
exclusions ||= %w(tests fixtures factories) exclusions ||= %w(tests fixtures factories)
exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" } exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
end end
......
...@@ -20,17 +20,19 @@ module Annotate ...@@ -20,17 +20,19 @@ module Annotate
POSITION_OPTIONS=[ POSITION_OPTIONS=[
:position_in_routes, :position_in_class, :position_in_test, :position_in_routes, :position_in_class, :position_in_test,
:position_in_fixture, :position_in_factory, :position, :position_in_fixture, :position_in_factory, :position,
:position_in_serializer,
] ]
FLAG_OPTIONS=[ FLAG_OPTIONS=[
:show_indexes, :simple_indexes, :include_version, :exclude_tests, :show_indexes, :simple_indexes, :include_version, :exclude_tests,
:exclude_fixtures, :exclude_factories, :ignore_model_sub_dir, :exclude_fixtures, :exclude_factories, :ignore_model_sub_dir,
:format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace, :timestamp :format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace,
:timestamp, :exclude_serializers, :classified_sort
] ]
OTHER_OPTIONS=[ OTHER_OPTIONS=[
:model_dir, :ignore_columns :ignore_columns
] ]
PATH_OPTIONS=[ PATH_OPTIONS=[
:require, :require, :model_dir
] ]
...@@ -41,7 +43,7 @@ module Annotate ...@@ -41,7 +43,7 @@ module Annotate
return if(@has_set_defaults) return if(@has_set_defaults)
@has_set_defaults = true @has_set_defaults = true
options = HashWithIndifferentAccess.new(options) options = HashWithIndifferentAccess.new(options)
[POSITION_OPTIONS, FLAG_OPTIONS, PATH_OPTIONS].flatten.each do |key| [POSITION_OPTIONS, FLAG_OPTIONS, PATH_OPTIONS, OTHER_OPTIONS].flatten.each do |key|
if(options.has_key?(key)) if(options.has_key?(key))
default_value = if(options[key].is_a?(Array)) default_value = if(options[key].is_a?(Array))
options[key].join(",") options[key].join(",")
...@@ -70,7 +72,7 @@ module Annotate ...@@ -70,7 +72,7 @@ module Annotate
end end
if(!options[:model_dir]) if(!options[:model_dir])
options[:model_dir] = 'app/models' options[:model_dir] = ['app/models']
end end
return options return options
...@@ -111,11 +113,13 @@ module Annotate ...@@ -111,11 +113,13 @@ module Annotate
klass.eager_load! klass.eager_load!
end end
else else
FileList["#{options[:model_dir]}/**/*.rb"].each do |fname| options[:model_dir].each do |dir|
FileList["#{dir}/**/*.rb"].each do |fname|
require File.expand_path(fname) require File.expand_path(fname)
end end
end end
end end
end
def self.bootstrap_rake def self.bootstrap_rake
begin begin
......
require 'bigdecimal'
module AnnotateModels module AnnotateModels
# Annotate Models plugin use this header # Annotate Models plugin use this header
COMPAT_PREFIX = "== Schema Info" COMPAT_PREFIX = "== Schema Info"
...@@ -31,6 +33,12 @@ module AnnotateModels ...@@ -31,6 +33,12 @@ module AnnotateModels
FABRICATORS_TEST_DIR = File.join("test", "fabricators") FABRICATORS_TEST_DIR = File.join("test", "fabricators")
FABRICATORS_SPEC_DIR = File.join("spec", "fabricators") FABRICATORS_SPEC_DIR = File.join("spec", "fabricators")
# Serializers https://github.com/rails-api/active_model_serializers
SERIALIZERS_DIR = File.join("app", "serializers")
SERIALIZERS_TEST_DIR = File.join("test", "serializers")
SERIALIZERS_SPEC_DIR = File.join("spec", "serializers")
TEST_PATTERNS = [ TEST_PATTERNS = [
File.join(UNIT_TEST_DIR, "%MODEL_NAME%_test.rb"), File.join(UNIT_TEST_DIR, "%MODEL_NAME%_test.rb"),
File.join(MODEL_TEST_DIR, "%MODEL_NAME%_test.rb"), File.join(MODEL_TEST_DIR, "%MODEL_NAME%_test.rb"),
...@@ -55,13 +63,19 @@ module AnnotateModels ...@@ -55,13 +63,19 @@ module AnnotateModels
File.join(FABRICATORS_SPEC_DIR, "%MODEL_NAME%_fabricator.rb"), File.join(FABRICATORS_SPEC_DIR, "%MODEL_NAME%_fabricator.rb"),
] ]
SERIALIZER_PATTERNS = [
File.join(SERIALIZERS_DIR, "%MODEL_NAME%_serializer.rb"),
File.join(SERIALIZERS_TEST_DIR, "%MODEL_NAME%_serializer_spec.rb"),
File.join(SERIALIZERS_SPEC_DIR, "%MODEL_NAME%_serializer_spec.rb")
]
# Don't show limit (#) on these column types # Don't show limit (#) on these column types
# Example: show "integer" instead of "integer(4)" # Example: show "integer" instead of "integer(4)"
NO_LIMIT_COL_TYPES = ["integer", "boolean"] NO_LIMIT_COL_TYPES = ["integer", "boolean"]
class << self class << self
def model_dir def model_dir
@model_dir || "app/models" @model_dir.is_a?(Array) ? @model_dir : [@model_dir || "app/models"]
end end
def model_dir=(dir) def model_dir=(dir)
...@@ -82,6 +96,10 @@ module AnnotateModels ...@@ -82,6 +96,10 @@ module AnnotateModels
end end
end end
def schema_default(klass, column)
quote(klass.column_defaults[column.name])
end
# Use the column information in an ActiveRecord class # Use the column information in an ActiveRecord class
# to create a comment block containing a line for # to create a comment block containing a line for
# each column. The line contains the column name, # each column. The line contains the column name,
...@@ -113,10 +131,12 @@ module AnnotateModels ...@@ -113,10 +131,12 @@ module AnnotateModels
if options[:ignore_columns] if options[:ignore_columns]
cols.reject! { |col| col.name.match(/#{options[:ignore_columns]}/) } cols.reject! { |col| col.name.match(/#{options[:ignore_columns]}/) }
end end
cols = cols.sort_by(&:name) if(options[:sort]) cols = cols.sort_by(&:name) if(options[:sort])
cols = classified_sort(cols) if(options[:classified_sort])
cols.each do |col| cols.each do |col|
attrs = [] attrs = []
attrs << "default(#{quote(col.default)})" unless col.default.nil? attrs << "default(#{schema_default(klass, col)})" unless col.default.nil?
attrs << "not null" unless col.null attrs << "not null" unless col.null
attrs << "primary key" if klass.primary_key && (klass.primary_key.is_a?(Array) ? klass.primary_key.collect{|c|c.to_sym}.include?(col.name.to_sym) : col.name.to_sym == klass.primary_key.to_sym) attrs << "primary key" if klass.primary_key && (klass.primary_key.is_a?(Array) ? klass.primary_key.collect{|c|c.to_sym}.include?(col.name.to_sym) : col.name.to_sym == klass.primary_key.to_sym)
...@@ -151,7 +171,7 @@ module AnnotateModels ...@@ -151,7 +171,7 @@ module AnnotateModels
if options[:simple_indexes] && klass.table_exists?# Check out if this column is indexed if options[:simple_indexes] && klass.table_exists?# Check out if this column is indexed
indices = klass.connection.indexes(klass.table_name) indices = klass.connection.indexes(klass.table_name)
if indices = indices.select { |ind| ind.columns.include? col.name } if indices = indices.select { |ind| ind.columns.include? col.name }
indices.each do |ind| indices.sort_by{|ind| ind.name}.each do |ind|
ind = ind.columns.reject! { |i| i == col.name } ind = ind.columns.reject! { |i| i == col.name }
attrs << (ind.length == 0 ? "indexed" : "indexed => [#{ind.join(", ")}]") attrs << (ind.length == 0 ? "indexed" : "indexed => [#{ind.join(", ")}]")
end end
...@@ -212,7 +232,7 @@ module AnnotateModels ...@@ -212,7 +232,7 @@ module AnnotateModels
# === Options (opts) # === Options (opts)
# :force<Symbol>:: whether to update the file even if it doesn't seem to need it. # :force<Symbol>:: whether to update the file even if it doesn't seem to need it.
# :position_in_*<Symbol>:: where to place the annotated section in fixture or model file, # :position_in_*<Symbol>:: where to place the annotated section in fixture or model file,
# :before or :after. Default is :before. # :before, :top, :after or :bottom. Default is :before.
# #
def annotate_one_file(file_name, info_block, position, options={}) def annotate_one_file(file_name, info_block, position, options={})
if File.exist?(file_name) if File.exist?(file_name)
...@@ -241,15 +261,18 @@ module AnnotateModels ...@@ -241,15 +261,18 @@ module AnnotateModels
new_content = old_content.sub(PATTERN, "\n" + info_block) new_content = old_content.sub(PATTERN, "\n" + info_block)
end end
wrapper_open = options[:wrapper_open] ? "# #{options[:wrapper_open]}\n" : ""
wrapper_close = options[:wrapper_close] ? "\n# #{options[:wrapper_close]}" : ""
wrapped_info_block = "#{wrapper_open}#{info_block}#{wrapper_close}"
# if there *was* no old schema info (no substitution happened) or :force was passed, # if there *was* no old schema info (no substitution happened) or :force was passed,
# we simply need to insert it in correct position # we simply need to insert it in correct position
if new_content == old_content || options[:force] if new_content == old_content || options[:force]
old_content.sub!(encoding, '') old_content.sub!(encoding, '')
old_content.sub!(PATTERN, '') old_content.sub!(PATTERN, '')
new_content = options[position].to_s == 'after' ? new_content = %w(after bottom).include?(options[position].to_s) ?
(encoding_header + (old_content.rstrip + "\n\n" + info_block)) : (encoding_header + (old_content.rstrip + "\n\n" + wrapped_info_block)) :
(encoding_header + info_block + "\n" + old_content) (encoding_header + wrapped_info_block + "\n" + old_content)
end end
File.open(file_name, "wb") { |f| f.puts new_content } File.open(file_name, "wb") { |f| f.puts new_content }
...@@ -296,31 +319,23 @@ module AnnotateModels ...@@ -296,31 +319,23 @@ module AnnotateModels
did_annotate = false did_annotate = false
model_name = klass.name.underscore model_name = klass.name.underscore
table_name = klass.table_name table_name = klass.table_name
model_file_name = File.join(model_dir, file) model_file_name = File.join(file)
if annotate_one_file(model_file_name, info, :position_in_class, options_with_position(options, :position_in_class)) if annotate_one_file(model_file_name, info, :position_in_class, options_with_position(options, :position_in_class))
did_annotate = true did_annotate = true
end end
unless options[:exclude_tests] %w(test fixture factory serializer).each do |key|
did_annotate = TEST_PATTERNS. exclusion_key = "exclude_#{key.pluralize}".to_sym
map { |file| resolve_filename(file, model_name, table_name) }. patterns_constant = "#{key.upcase}_PATTERNS".to_sym
map { |file| annotate_one_file(file, info, :position_in_test, options_with_position(options, :position_in_test)) }. position_key = "position_in_#{key}".to_sym
detect { |result| result } || did_annotate
end
unless options[:exclude_fixtures] unless options[exclusion_key]
did_annotate = FIXTURE_PATTERNS. did_annotate = self.const_get(patterns_constant).
map { |file| resolve_filename(file, model_name, table_name) }. map { |file| resolve_filename(file, model_name, table_name) }.
map { |file| annotate_one_file(file, info, :position_in_fixture, options_with_position(options, :position_in_fixture)) }. map { |file| annotate_one_file(file, info, position_key, options_with_position(options, position_key)) }.
detect { |result| result } || did_annotate detect { |result| result } || did_annotate
end end
unless options[:exclude_factories]
did_annotate = FACTORY_PATTERNS.
map { |file| resolve_filename(file, model_name, table_name) }.
map { |file| annotate_one_file(file, info, :position_in_factory, options_with_position(options, :position_in_factory)) }.
detect { |result| result } || did_annotate
end end
return did_annotate return did_annotate
...@@ -335,35 +350,37 @@ module AnnotateModels ...@@ -335,35 +350,37 @@ module AnnotateModels
options.merge(:position=>(options[position_in] || options[:position])) options.merge(:position=>(options[position_in] || options[:position]))
end end
# Return a list of the model files to annotate. If we have # Return a list of the model files to annotate.
# command line arguments, they're assumed to be either # If we have command line arguments, they're assumed to the path
# the underscore or CamelCase versions of model names. # of model files from root dir. Otherwise we take all the model files
# Otherwise we take all the model files in the # in the model_dir directory.
# model_dir directory.
def get_model_files(options) def get_model_files(options)
if(!options[:is_rake])
models = ARGV.dup
models.shift
else
models = [] models = []
if(!options[:is_rake])
models = ARGV.dup.reject{|m| m.match(/^(.*)=/)}
end end
models.reject!{|m| m.match(/^(.*)=/)}
if models.empty? if models.empty?
begin begin
Dir.chdir(model_dir) do model_dir.each do |dir|
models = if options[:ignore_model_sub_dir] Dir.chdir(dir) do
Dir["*.rb"] lst =
if options[:ignore_model_sub_dir]
Dir["*.rb"].map{ |f| [dir, f] }
else else
Dir["**/*.rb"].reject{ |f| f["concerns/"] } Dir["**/*.rb"].reject{ |f| f["concerns/"] }.map{ |f| [dir, f] }
end
models.concat(lst)
end end
end end
rescue SystemCallError rescue SystemCallError
puts "No models found in directory '#{model_dir}'." puts "No models found in directory '#{model_dir.join("', '")}'."
puts "Either specify models on the command line, or use the --model-dir option." puts "Either specify models on the command line, or use the --model-dir option."
puts "Call 'annotate --help' for more info." puts "Call 'annotate --help' for more info."
exit 1 exit 1
end end
end end
models models
end end
...@@ -372,11 +389,13 @@ module AnnotateModels ...@@ -372,11 +389,13 @@ module AnnotateModels
# in subdirectories without namespacing. # in subdirectories without namespacing.
def get_model_class(file) def get_model_class(file)
model_path = file.gsub(/\.rb$/, '') model_path = file.gsub(/\.rb$/, '')
model_dir.each { |dir| model_path = model_path.gsub(/^#{dir}/, '').gsub(/^\//, '') }
begin begin
get_loaded_model(model_path) or raise LoadError.new("cannot load a model from #{file}") get_loaded_model(model_path) or raise LoadError.new("cannot load a model from #{file}")
rescue LoadError rescue LoadError
# this is for non-rails projects, which don't get Rails auto-require magic # this is for non-rails projects, which don't get Rails auto-require magic
if Kernel.require(File.expand_path("#{model_dir}/#{model_path}")) file_path = File.expand_path(file)
if File.file?(file_path) && Kernel.require(file_path)
retry retry
elsif model_path.match(/\//) elsif model_path.match(/\//)
model_path = model_path.split('/')[1..-1].join('/').to_s model_path = model_path.split('/')[1..-1].join('/').to_s
...@@ -421,10 +440,10 @@ module AnnotateModels ...@@ -421,10 +440,10 @@ module AnnotateModels
annotated = [] annotated = []
get_model_files(options).each do |file| get_model_files(options).each do |file|
annotate_model_file(annotated, file, header, options) annotate_model_file(annotated, File.join(file), header, options)
end end
if annotated.empty? if annotated.empty?
puts "Nothing annotated." puts "Nothing to annotate."
else else
puts "Annotated (#{annotated.length}): #{annotated.join(', ')}" puts "Annotated (#{annotated.length}): #{annotated.join(', ')}"
end end
...@@ -449,12 +468,13 @@ module AnnotateModels ...@@ -449,12 +468,13 @@ module AnnotateModels
deannotated = [] deannotated = []
deannotated_klass = false deannotated_klass = false
get_model_files(options).each do |file| get_model_files(options).each do |file|
file = File.join(file)
begin begin
klass = get_model_class(file) klass = get_model_class(file)
if klass < ActiveRecord::Base && !klass.abstract_class? if klass < ActiveRecord::Base && !klass.abstract_class?
model_name = klass.name.underscore model_name = klass.name.underscore
table_name = klass.table_name table_name = klass.table_name
model_file_name = File.join(model_dir, file) model_file_name = file
deannotated_klass = true if(remove_annotation_of_file(model_file_name)) deannotated_klass = true if(remove_annotation_of_file(model_file_name))
(TEST_PATTERNS + FIXTURE_PATTERNS + FACTORY_PATTERNS). (TEST_PATTERNS + FIXTURE_PATTERNS + FACTORY_PATTERNS).
...@@ -468,7 +488,7 @@ module AnnotateModels ...@@ -468,7 +488,7 @@ module AnnotateModels
end end
deannotated << klass if(deannotated_klass) deannotated << klass if(deannotated_klass)
rescue Exception => e rescue Exception => e
puts "Unable to deannotate #{file}: #{e.message}" puts "Unable to deannotate #{File.join(file)}: #{e.message}"
puts "\t" + e.backtrace.join("\n\t") if options[:trace] puts "\t" + e.backtrace.join("\n\t") if options[:trace]
end end
end end
...@@ -480,5 +500,27 @@ module AnnotateModels ...@@ -480,5 +500,27 @@ module AnnotateModels
gsub('%MODEL_NAME%', model_name). gsub('%MODEL_NAME%', model_name).
gsub('%TABLE_NAME%', table_name || model_name.pluralize) gsub('%TABLE_NAME%', table_name || model_name.pluralize)
end end
def classified_sort(cols)
rest_cols = []
timestamps = []
associations = []
id = nil
cols = cols.each do |c|
if c.name.eql?("id")
id = c
elsif (c.name.eql?("created_at") || c.name.eql?("updated_at"))
timestamps << c
elsif c.name[-3,3].eql?("_id")
associations << c
else
rest_cols << c
end
end
[rest_cols, timestamps, associations].each {|a| a.sort_by!(&:name) }
return ([id] << rest_cols << timestamps << associations).flatten
end
end end
end end
...@@ -23,7 +23,7 @@ module AnnotateRoutes ...@@ -23,7 +23,7 @@ module AnnotateRoutes
def self.do_annotations(options={}) def self.do_annotations(options={})
return unless(routes_exists?) return unless(routes_exists?)
position_after = options[:position_in_routes] != 'before' position_after = ! %w(before top).include?(options[:position_in_routes])
routes_map = `rake routes`.split(/\n/, -1) routes_map = `rake routes`.split(/\n/, -1)
......
module Annotate module Annotate
def self.version def self.version
'2.6.5' '2.6.6'
end end
end end
...@@ -18,7 +18,7 @@ task :annotate_models => :environment do ...@@ -18,7 +18,7 @@ task :annotate_models => :environment do
options[:position_in_test] = Annotate.fallback(ENV['position_in_test'], ENV['position']) options[:position_in_test] = Annotate.fallback(ENV['position_in_test'], ENV['position'])
options[:show_indexes] = Annotate.true?(ENV['show_indexes']) options[:show_indexes] = Annotate.true?(ENV['show_indexes'])
options[:simple_indexes] = Annotate.true?(ENV['simple_indexes']) options[:simple_indexes] = Annotate.true?(ENV['simple_indexes'])
options[:model_dir] = ENV['model_dir'] options[:model_dir] = ENV['model_dir'] ? ENV['model_dir'].split(',') : []
options[:include_version] = Annotate.true?(ENV['include_version']) options[:include_version] = Annotate.true?(ENV['include_version'])
options[:require] = ENV['require'] ? ENV['require'].split(',') : [] options[:require] = ENV['require'] ? ENV['require'].split(',') : []
options[:exclude_tests] = Annotate.true?(ENV['exclude_tests']) options[:exclude_tests] = Annotate.true?(ENV['exclude_tests'])
...@@ -30,7 +30,10 @@ task :annotate_models => :environment do ...@@ -30,7 +30,10 @@ task :annotate_models => :environment do
options[:format_markdown] = Annotate.true?(ENV['format_markdown']) options[:format_markdown] = Annotate.true?(ENV['format_markdown'])
options[:sort] = Annotate.true?(ENV['sort']) options[:sort] = Annotate.true?(ENV['sort'])
options[:force] = Annotate.true?(ENV['force']) options[:force] = Annotate.true?(ENV['force'])
options[:classified_sort] = Annotate.true?(ENV['classified_sort'])
options[:trace] = Annotate.true?(ENV['trace']) options[:trace] = Annotate.true?(ENV['trace'])
options[:wrapper_open] = Annotate.fallback(ENV['wrapper_open'], ENV['wrapper'])
options[:wrapper_close] = Annotate.fallback(ENV['wrapper_close'], ENV['wrapper'])
AnnotateModels.do_annotations(options) AnnotateModels.do_annotations(options)
end end
......
...@@ -10,7 +10,10 @@ describe AnnotateModels do ...@@ -10,7 +10,10 @@ describe AnnotateModels do
:table_name => table_name, :table_name => table_name,
:primary_key => primary_key, :primary_key => primary_key,
:column_names => columns.map { |col| col.name.to_s }, :column_names => columns.map { |col| col.name.to_s },
:columns => columns :columns => columns,
:column_defaults => Hash[columns.map { |col|
[col.name, col.default]
}]
} }
double("An ActiveRecord class", options) double("An ActiveRecord class", options)
...@@ -106,6 +109,24 @@ EOS ...@@ -106,6 +109,24 @@ EOS
EOS EOS
end end
it "should get schema info for integer and boolean with default" do
klass = mock_class(:users, :id, [
mock_column(:id, :integer),
mock_column(:size, :integer, :default => 20),
mock_column(:flag, :boolean, :default => false)
])
expect(AnnotateModels.get_schema_info(klass, "Schema Info")).to eql(<<-EOS)
# Schema Info
#
# Table name: users
#
# id :integer not null, primary key
# size :integer default(20), not null
# flag :boolean default(FALSE), not null
#
EOS
end
it "should get schema info as RDoc" do it "should get schema info as RDoc" do
klass = mock_class(:users, :id, [ klass = mock_class(:users, :id, [
mock_column(:id, :integer), mock_column(:id, :integer),
...@@ -136,9 +157,8 @@ EOS ...@@ -136,9 +157,8 @@ EOS
# todo: use 'files' gem instead # todo: use 'files' gem instead
def create(file, body="hi") def create(file, body="hi")
file_path = File.join(AnnotateModels.model_dir, file) file_path = File.join(AnnotateModels.model_dir[0], file)
FileUtils.mkdir_p(File.dirname(file_path)) FileUtils.mkdir_p(File.dirname(file_path))
File.open(file_path, "wb") do |f| File.open(file_path, "wb") do |f|
f.puts(body) f.puts(body)
end end
...@@ -146,7 +166,7 @@ EOS ...@@ -146,7 +166,7 @@ EOS
end end
def check_class_name(file, class_name) def check_class_name(file, class_name)
klass = AnnotateModels.get_model_class(file) klass = AnnotateModels.get_model_class(File.join(AnnotateModels.model_dir[0], file))
expect(klass).not_to eq(nil) expect(klass).not_to eq(nil)
expect(klass.name).to eq(class_name) expect(klass.name).to eq(class_name)
...@@ -294,7 +314,7 @@ EOS ...@@ -294,7 +314,7 @@ EOS
CONSTANT = 1 CONSTANT = 1
end end
EOS EOS
path = File.expand_path("#{AnnotateModels.model_dir}/loaded_class") path = File.expand_path('loaded_class', AnnotateModels.model_dir[0])
Kernel.load "#{path}.rb" Kernel.load "#{path}.rb"
expect(Kernel).not_to receive(:require).with(path) expect(Kernel).not_to receive(:require).with(path)
...@@ -425,11 +445,41 @@ end ...@@ -425,11 +445,41 @@ end
expect(File.read(@model_file_name)).to eq("#{@schema_info}\n#{@file_content}") expect(File.read(@model_file_name)).to eq("#{@schema_info}\n#{@file_content}")
end end
it "should put annotation before class if :position == 'top'" do
annotate_one_file :position => "top"
expect(File.read(@model_file_name)).to eq("#{@schema_info}\n#{@file_content}")
end
it "should put annotation before class if :position => :top" do
annotate_one_file :position => :top
expect(File.read(@model_file_name)).to eq("#{@schema_info}\n#{@file_content}")
end
it "should put annotation after class if :position => 'after'" do
annotate_one_file :position => 'after'
expect(File.read(@model_file_name)).to eq("#{@file_content}\n#{@schema_info}")
end
it "should put annotation after class if :position => :after" do it "should put annotation after class if :position => :after" do
annotate_one_file :position => :after annotate_one_file :position => :after
expect(File.read(@model_file_name)).to eq("#{@file_content}\n#{@schema_info}") expect(File.read(@model_file_name)).to eq("#{@file_content}\n#{@schema_info}")
end end
it "should put annotation after class if :position => 'bottom'" do
annotate_one_file :position => 'bottom'
expect(File.read(@model_file_name)).to eq("#{@file_content}\n#{@schema_info}")
end
it "should put annotation after class if :position => :bottom" do
annotate_one_file :position => :bottom
expect(File.read(@model_file_name)).to eq("#{@file_content}\n#{@schema_info}")
end
it 'should wrap annotation if wrapper is specified' do
annotate_one_file :wrapper_open => 'START', :wrapper_close => 'END'
expect(File.read(@model_file_name)).to eq("# START\n#{@schema_info}\n# END\n#{@file_content}")
end
describe "with existing annotation => :before" do describe "with existing annotation => :before" do
before do before do
annotate_one_file :position => :before annotate_one_file :position => :before
...@@ -527,7 +577,7 @@ end ...@@ -527,7 +577,7 @@ end
it "displays an error message" do it "displays an error message" do
expect(capturing(:stdout) { expect(capturing(:stdout) {
AnnotateModels.do_annotations :model_dir => @model_dir, :is_rake => true AnnotateModels.do_annotations :model_dir => @model_dir, :is_rake => true
}).to include("Unable to annotate user.rb: oops") }).to include("Unable to annotate #{@model_dir}/user.rb: oops")
end end
it "displays the full stack trace with --trace" do it "displays the full stack trace with --trace" do
...@@ -557,7 +607,7 @@ end ...@@ -557,7 +607,7 @@ end
it "displays an error message" do it "displays an error message" do
expect(capturing(:stdout) { expect(capturing(:stdout) {
AnnotateModels.remove_annotations :model_dir => @model_dir, :is_rake => true AnnotateModels.remove_annotations :model_dir => @model_dir, :is_rake => true
}).to include("Unable to deannotate user.rb: oops") }).to include("Unable to deannotate #{@model_dir}/user.rb: oops")
end end
it "displays the full stack trace" do it "displays the full stack trace" do
......
PATH PATH
remote: ../../.. remote: ../../..
specs: specs:
annotate (2.6.3) annotate (2.6.5)
activerecord (>= 2.3.0) activerecord (>= 2.3.0)
rake (>= 0.8.7) rake (>= 0.8.7)
...@@ -39,18 +39,18 @@ GEM ...@@ -39,18 +39,18 @@ GEM
coffee-rails (4.0.1) coffee-rails (4.0.1)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0) coffee-script (2.3.0)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.7.0) coffee-script-source (1.7.1)
erubis (2.7.0) erubis (2.7.0)
execjs (2.0.2) execjs (2.2.1)
hike (1.2.3) hike (1.2.3)
i18n (0.6.9) i18n (0.6.11)
jbuilder (2.0.7) jbuilder (2.1.3)
activesupport (>= 3.0.0, < 5) activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2) multi_json (~> 1.2)
jquery-rails (3.1.0) jquery-rails (3.1.1)
railties (>= 3.0, < 5.0) railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
json (1.8.1) json (1.8.1)
...@@ -58,9 +58,9 @@ GEM ...@@ -58,9 +58,9 @@ GEM
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
mime-types (1.25.1) mime-types (1.25.1)
minitest (5.3.4) minitest (5.4.0)
multi_json (1.10.1) multi_json (1.10.1)
polyglot (0.3.4) polyglot (0.3.5)
rack (1.5.2) rack (1.5.2)
rack-test (0.6.2) rack-test (0.6.2)
rack (>= 1.0) rack (>= 1.0)
...@@ -105,16 +105,16 @@ GEM ...@@ -105,16 +105,16 @@ GEM
sprockets (~> 2.8) sprockets (~> 2.8)
sqlite3 (1.3.9) sqlite3 (1.3.9)
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.3) thread_safe (0.3.4)
tilt (1.4.1) tilt (1.4.1)
treetop (1.4.15) treetop (1.4.15)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
turbolinks (2.2.2) turbolinks (2.2.2)
coffee-rails coffee-rails
tzinfo (1.1.0) tzinfo (1.2.1)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (2.5.0) uglifier (2.5.3)
execjs (>= 0.3.0) execjs (>= 0.3.0)
json (>= 1.8.0) json (>= 1.8.0)
......
# == Schema Information
#
# Table name: events
#
# id :integer not null, primary key
# content :string(255)
# created_at :datetime
# updated_at :datetime
#
module Sub1::Sub2::Sub3
class Event < ActiveRecord::Base
end
end
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# content :string(255)
# created_at :datetime
# updated_at :datetime
#
class Sub1::User < ActiveRecord::Base
end
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# content :string(255)
# count :integer default(0)
# status :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
#
class Task < ActiveRecord::Base class Task < ActiveRecord::Base
enum status: %w(normal active completed) enum status: %w(normal active completed)
end end
...@@ -2,7 +2,8 @@ class CreateTasks < ActiveRecord::Migration ...@@ -2,7 +2,8 @@ class CreateTasks < ActiveRecord::Migration
def change def change
create_table :tasks do |t| create_table :tasks do |t|
t.string :content t.string :content
t.column :status, default: 0 t.integer :count, :default => 0
t.boolean :status, :default => 0
t.timestamps t.timestamps
end end
end end
......
class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.string :content
t.timestamps
end
end
end
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :content
t.timestamps
end
end
end
...@@ -11,11 +11,24 @@ ...@@ -11,11 +11,24 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140526224112) do ActiveRecord::Schema.define(version: 20140705000010) do
create_table "events", force: true do |t|
t.string "content"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "tasks", force: true do |t| create_table "tasks", force: true do |t|
t.string "content" t.string "content"
t.integer "status" t.integer "count", default: 0
t.boolean "status", default: false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "users", force: true do |t|
t.string "content"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
......
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# content :string(255)
# count :integer default(0)
# status :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
#
require 'test_helper' require 'test_helper'
class TaskTest < ActiveSupport::TestCase class TaskTest < ActiveSupport::TestCase
......
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
group :development do
if(ENV['AUTOMATED_TEST'] && ENV['AUTOMATED_TEST'] != '')
gem 'annotate', :path => ENV['AUTOMATED_TEST']
else
gem 'annotate', :path => '../../..'
end
end
gem 'rails-observers'
PATH
remote: ../../..
specs:
annotate (2.6.5)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.0)
actionpack (= 4.2.0)
actionview (= 4.2.0)
activejob (= 4.2.0)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.0)
actionview (= 4.2.0)
activesupport (= 4.2.0)
rack (~> 1.6.0)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
actionview (4.2.0)
activesupport (= 4.2.0)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
activejob (4.2.0)
activesupport (= 4.2.0)
globalid (>= 0.3.0)
activemodel (4.2.0)
activesupport (= 4.2.0)
builder (~> 3.1)
activerecord (4.2.0)
activemodel (= 4.2.0)
activesupport (= 4.2.0)
arel (~> 6.0)
activesupport (4.2.0)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.0)
builder (3.2.2)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.8.0)
erubis (2.7.0)
execjs (2.2.2)
globalid (0.3.0)
activesupport (>= 4.1.0)
hike (1.2.3)
i18n (0.7.0)
jbuilder (2.2.6)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.2)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
loofah (2.0.1)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.4.3)
mini_portile (0.6.1)
minitest (5.5.0)
multi_json (1.10.1)
nokogiri (1.6.5)
mini_portile (~> 0.6.0)
rack (1.6.0)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.2.0)
actionmailer (= 4.2.0)
actionpack (= 4.2.0)
actionview (= 4.2.0)
activejob (= 4.2.0)
activemodel (= 4.2.0)
activerecord (= 4.2.0)
activesupport (= 4.2.0)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.0)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.5)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.1)
loofah (~> 2.0)
rails-observers (0.1.2)
activemodel (~> 4.0)
railties (4.2.0)
actionpack (= 4.2.0)
activesupport (= 4.2.0)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
json (~> 1.4)
sass (3.4.9)
sass-rails (5.0.0)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
spring (1.2.0)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.2.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.6.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
PLATFORMS
ruby
DEPENDENCIES
annotate!
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
rails (= 4.2.0)
rails-observers
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
sqlite3
turbolinks
uglifier (>= 1.3.0)
== README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
# == Schema Information
#
# Table name: events
#
# id :integer not null, primary key
# content :string
# created_at :datetime
# updated_at :datetime
#
module Sub1::Sub2::Sub3
class Event < ActiveRecord::Base
end
end
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# content :string
# created_at :datetime
# updated_at :datetime
#
class Sub1::User < ActiveRecord::Base
end
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# content :string
# count :integer default(0)
# status :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
#
class Task < ActiveRecord::Base
enum status: %w(normal active completed)
end
class TaskObserver < ActiveRecord::Observer
end
\ No newline at end of file
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Rails411
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
end
end
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.static_cache_control = 'public, max-age=3600'
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json
\ No newline at end of file
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_rails_4_1_1_session'
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
# Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
development:
secret_key_base: 6c17ffa1446409733e3bc5b3250a56dbbfe8fb1a235c966e89344814abca7c25a23647d3eef49d2a7e7751d501b294cc4a3911549441aa9ddffe45a36f40e96c
test:
secret_key_base: 952ea361989ff7bba92aae19f14cbd4ab5c1fe431a0d28420ab1d14593a4b15c905dffdb26f3ab14108c023540fa89ac9364a98fe48e402602ec01159fa64b91
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
class CreateTasks < ActiveRecord::Migration
def change
create_table :tasks do |t|
t.string :content
t.integer :count, default: 0
t.boolean :status, default: 0
t.timestamps
end
end
end
class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.string :content
t.timestamps
end
end
end
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :content
t.timestamps
end
end
end
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140705000010) do
create_table "events", force: :cascade do |t|
t.string "content"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "tasks", force: :cascade do |t|
t.string "content"
t.integer "count", default: 0
t.boolean "status", default: false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "users", force: :cascade do |t|
t.string "content"
t.datetime "created_at"
t.datetime "updated_at"
end
end
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# NOTE: only doing this in development as some production environments (Heroku)
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
# NOTE: to have a dev-mode tool do its thing in production.
if Rails.env.development?
task :set_annotation_options do
# You can override any of these by setting an environment variable of the
# same name.
Annotate.set_defaults({
'position_in_routes' => "before",
'position_in_class' => "before",
'position_in_test' => "before",
'position_in_fixture' => "before",
'position_in_factory' => "before",
'show_indexes' => "true",
'simple_indexes' => "false",
'model_dir' => "app/models",
'include_version' => "false",
'require' => "",
'exclude_tests' => "false",
'exclude_fixtures' => "false",
'exclude_factories' => "false",
'ignore_model_sub_dir' => "false",
'skip_on_db_migrate' => "false",
'format_bare' => "true",
'format_rdoc' => "false",
'format_markdown' => "false",
'sort' => "false",
'force' => "false",
'trace' => "false",
})
end
Annotate.load_tasks
end
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# content :string
# count :integer default(0)
# status :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
#
require 'test_helper'
class TaskTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment