diff --git a/.gitignore b/.gitignore index 3dd573d..1ed0492 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,8 @@ db/schema.rb* *.log *.sqlite3 *.swp +Gemfile.lock +.bundle +vendor/bundle +config/registry.yml +public/coverage diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..68b3a4c --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +1.9.3-p551 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e8e3471 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source "http://www.rubygems.org" + +gemspec diff --git a/README b/README index 0ff69fe..bac62bf 100644 --- a/README +++ b/README @@ -6,14 +6,23 @@ === Installation - script/plugin install git://github.com/berk/registry.git + # Gemfile + gem 'registry', :git => 'https://github.com/ss/registry.git' +== Testing/Coverage -=== Test + # setup test environment + rbenv install 1.9.3-p551 + gem install bundler -v '~>1.0.0' + bundle install --clean --path=vendor/bundle + bundle exec rake db:migrate - script/server - point your browser at http://localhost:3000/registry + # run tests + bundle exec rake test + # generate coverage report + bundle exec rake registry:coverage + # point your browser at http://localhost:3000/coverage/ === Usage @@ -37,7 +46,7 @@ === Example usage in app/controllers/api_controller.rb - + class ApiController < ActionController::Base before_filter :ensure_api_enabled, :check_rate_limit @@ -80,21 +89,21 @@ development: api_request_window: 100 - + test: api_request_window: 100 - + production: api_enabled: false api_request_limit: 10 api_request_window: 10000 - + in lib/tasks/my_tasks.rake desc 'Import configuration' task :import_configuration => [:environment] do - Registry.import("#{Rails.root}/config/registry.yml") + Registry.import("#{Rails.root}/config/registry.yml", :verbose => true) end --- diff --git a/Rakefile b/Rakefile index fbebfca..d531538 100644 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,5 @@ require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' -require 'rake/rdoctask' require 'tasks/rails' diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..2bf1c1c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.3.1 diff --git a/app/models/registry/entry.rb b/app/models/registry/entry.rb index 06fae46..426f46e 100644 --- a/app/models/registry/entry.rb +++ b/app/models/registry/entry.rb @@ -22,7 +22,7 @@ # require 'registry' -require File.expand_path(File.dirname(__FILE__) + '/../../../vendor/gems/metaskills-acts_as_versioned-0.6.3/lib/acts_as_versioned') +require 'acts_as_versioned' module Registry class Entry < ActiveRecord::Base @@ -85,7 +85,12 @@ def self.export!(file_path = DEFAULT_YML_LOCATION) # ==== Parameters # # * +file_path+ - Path to yml file. - # * +opts+ - Optional, merge options (see documentation for merge method) + # * +opts+ - Optional parameters + # + # ==== Options + # + # * verbose - If true, print information to stderr. + # * merge options (see documentation for merge method) # # ==== File Format # @@ -113,6 +118,7 @@ def self.import!(file_path = DEFAULT_YML_LOCATION, opts={}) hash = YAML.load_file(file_path) default_entries = hash.delete(Registry::DEFAULTS_KEY) || {} hash.each do |env, entries| + STDERR.puts "Importing: #{env}" if opts[:verbose] root(env).merge(default_entries.deep_merge(entries), opts) end end @@ -236,9 +242,13 @@ def to_form_property_hash # * +hash+ - Optional, hash to update. # # call-seq: - # Registry::Entry.root.export #=> {'api' => {'enabled' => true}} + # Registry::Entry.root.export #=> {'api' => {'enabled' => true}, '_last_updated_at' => ...} def export(hash={}, entries=nil) - entries ||= Entry.all(:conditions => ['env = ? and id != ?', env, id]) + + if entries.nil? + entries = Entry.all(:conditions => ['env = ? and id != ?', env, id]) + hash['_last_updated_at'] = entries.inject(Time.at(0)) {|old_max, entry| [old_max, entry.updated_at].max} + end properties, entries = entries.partition {|entry| entry.parent_id == id && !entry.folder?} properties.each do |p| diff --git a/app/views/registry/registry/viewport.html.erb b/app/views/registry/registry/viewport.html.erb index 4e228c5..88a7038 100644 --- a/app/views/registry/registry/viewport.html.erb +++ b/app/views/registry/registry/viewport.html.erb @@ -10,16 +10,16 @@ - + } %> diff --git a/config/database.yml b/config/database.yml index 1f6bdf8..668978a 100644 --- a/config/database.yml +++ b/config/database.yml @@ -11,17 +11,3 @@ test: database: db/test.sqlite3 pool: 5 timeout: 5000 - -pg_development: - adapter: postgresql - host: localhost - encoding: utf8 - username: postgres - database: sme_dev - -pg_test: - adapter: postgresql - host: localhost - encoding: utf8 - username: postgres - database: sme_test diff --git a/config/environment.rb b/config/environment.rb index 46fc971..9c0c715 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,7 +1,7 @@ # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') -RAILS_GEM_VERSION = '2.3.10' unless defined? RAILS_GEM_VERSION +RAILS_GEM_VERSION = '2.3.18' unless defined? RAILS_GEM_VERSION Rails::Initializer.run do |config| # Settings in config/environments/* take precedence over those specified here. diff --git a/config/environments/test.rb b/config/environments/test.rb index 06996bf..454406f 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -2,6 +2,9 @@ require 'pp' +require 'test/unit' +require 'mocha/setup' + # 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 @@ -25,3 +28,12 @@ config.action_mailer.delivery_method = :test config.action_controller.session = { :key => "_test_session", :secret => "218d878f47b437169e7de9975d2e1286" } + +if ENV['COVERAGE'] + require 'simplecov' + FileUtils.rm_rf(Rails.root + 'public/coverage') + SimpleCov.start 'rails' do + add_filter '/vendor/bundle/' + coverage_dir 'public/coverage' + end +end diff --git a/config/preinitializer.rb b/config/preinitializer.rb new file mode 100644 index 0000000..5d27894 --- /dev/null +++ b/config/preinitializer.rb @@ -0,0 +1,20 @@ +begin + require 'rubygems' + require 'bundler' +rescue LoadError + raise "Could not load the bundler gem. Install it with `gem install bundler`." +end + +if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24") + raise RuntimeError, "Your bundler version is too old for Rails 2.3.\n" + + "Run `gem install bundler` to upgrade." +end + +begin + # Set up load paths for all bundled gems + ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__) + Bundler.setup +rescue Bundler::GemNotFound + raise RuntimeError, "Bundler couldn't find some gems.\n" + + "Did you run `bundle install`?" +end diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/lib/acts_as_versioned.rb b/lib/acts_as_versioned.rb similarity index 100% rename from vendor/gems/metaskills-acts_as_versioned-0.6.3/lib/acts_as_versioned.rb rename to lib/acts_as_versioned.rb diff --git a/lib/registry/transcoder.rb b/lib/registry/transcoder.rb index bfa1ff8..6b0356a 100644 --- a/lib/registry/transcoder.rb +++ b/lib/registry/transcoder.rb @@ -34,7 +34,13 @@ # Date transcoder config.add_transcoder do to_db {|value| value.strftime("%Y-%m-%d")} - from_db {|string| Date.parse(string)} + from_db do |string| + result = Date.strptime(string, '%d-%m-%Y') rescue nil + result ||= Date.strptime(string, '%Y-%m-%d') rescue nil + result ||= Date.strptime(string, '%m-%d-%Y') rescue nil + + result || string + end matches do |value| value.is_a?(Date) or # to_db diff --git a/lib/tasks/registry.rake b/lib/tasks/registry.rake index 2a74e4a..1d1b8fa 100644 --- a/lib/tasks/registry.rake +++ b/lib/tasks/registry.rake @@ -6,12 +6,9 @@ namespace :registry do end desc 'Generate coverage report' - task :coverage => [:environment] do - excludes = %w[boot.rb config vendor].join(',') - output_dir = "#{Rails.root}/public/coverage" - files = Dir['test/{unit,functional}/**/*_test.rb'].join(' ') - rm_rf(output_dir) - sh "rcov --rails -t --sort coverage -o public/coverage -x 'gems' #{files}" + task :coverage do + ENV['COVERAGE'] = '1' + system('rake test') end desc "Set a registry value (eg 'api.enabled'=true)" diff --git a/registry.gemspec b/registry.gemspec new file mode 100644 index 0000000..9938896 --- /dev/null +++ b/registry.gemspec @@ -0,0 +1,26 @@ +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + +Gem::Specification.new do |gem| + gem.name = "registry" + gem.version = IO.read('VERSION') + gem.authors = ["Michael Berkovich", "Scott Steadman"] + gem.email = ["registry-gem@stdmn.com"] + gem.description = %q{Framework for controlling application behavior through configurable properties} + gem.summary = gem.description + gem.homepage = "https://github.com/ss/registry" + gem.license = 'MIT' + + gem.add_development_dependency 'iconv' + gem.add_development_dependency 'mocha' + gem.add_development_dependency 'rails', '~> 2.3.0' + gem.add_development_dependency 'rake', '0.9.2.2' + gem.add_development_dependency 'shoulda', '3.0.1' + gem.add_development_dependency 'simplecov', '~>0.6.0' + gem.add_development_dependency 'sqlite3', '~>1.3.0' + + gem.files = `git ls-files`.split($/) + gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } + gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) + gem.require_paths = ["lib"] +end diff --git a/script/breakpointer b/script/breakpointer index 64af76e..d7db15a 100755 --- a/script/breakpointer +++ b/script/breakpointer @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/breakpointer' \ No newline at end of file +require File.expand_path('../../config/boot', __FILE__) +require 'commands/breakpointer' diff --git a/script/console b/script/console index ca2f865..e76d91b 100755 --- a/script/console +++ b/script/console @@ -1,4 +1,4 @@ #!/usr/bin/env ruby $lazy_load_rails = true -require File.dirname(__FILE__) + '/../config/boot' +require File.expand_path('../../config/boot', __FILE__) require 'commands/console' diff --git a/script/dbconsole b/script/dbconsole index caa60ce..83c8436 100755 --- a/script/dbconsole +++ b/script/dbconsole @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' +require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole' diff --git a/script/destroy b/script/destroy index fa0e6fc..88d295f 100755 --- a/script/destroy +++ b/script/destroy @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/destroy' \ No newline at end of file +require File.expand_path('../../config/boot', __FILE__) +require 'commands/destroy' diff --git a/script/generate b/script/generate index ef976e0..62a8a4c 100755 --- a/script/generate +++ b/script/generate @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/generate' \ No newline at end of file +require File.expand_path('../../config/boot', __FILE__) +require 'commands/generate' diff --git a/script/plugin b/script/plugin index 26ca64c..b82201f 100755 --- a/script/plugin +++ b/script/plugin @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/plugin' \ No newline at end of file +require File.expand_path('../../config/boot', __FILE__) +require 'commands/plugin' diff --git a/script/runner b/script/runner index ccc30f9..be4c5d4 100755 --- a/script/runner +++ b/script/runner @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/runner' \ No newline at end of file +require File.expand_path('../../config/boot', __FILE__) +require 'commands/runner' diff --git a/script/server b/script/server index dfabcb8..b9fcb71 100755 --- a/script/server +++ b/script/server @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/server' \ No newline at end of file +require File.expand_path('../../config/boot', __FILE__) +require 'commands/server' diff --git a/script/skynet b/script/skynet deleted file mode 100755 index 5a0a8ae..0000000 --- a/script/skynet +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env ruby - -# Load your rails app -require File.expand_path(File.dirname(__FILE__)) + '/../config/environment' -require 'rubygems' -require 'skynet' -require 'erb' -require 'pp' - -Skynet::CONFIG[:LAUNCHER_PATH] ||= File.expand_path(__FILE__) -Skynet::CONFIG[:SKYNET_LOG_LEVEL] ||= Logger::ERROR -Skynet::CONFIG[:MYSQL_QUEUE_DATABASE] ||= 'skynet_queue' - -SKYNET_GUID = GuidGenerator.new(:namespace => :skynet, :batch_size => 10_000) -Skynet::CONFIG[:GUID_GENERATOR] = lambda { SKYNET_GUID.next } - -## See config/initializers/skynet.rb for more settings - -class ExceptionReport - include SkynetDebugger - def self.save(worker, exception) - mock_controller = OpenStruct.new(:name => worker.class.name) - LoggedException.create_from_exception(mock_controller, exception) - end -end -Skynet.start diff --git a/script/sweatshop b/script/sweatshop deleted file mode 100755 index 7f12613..0000000 --- a/script/sweatshop +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env ruby - -if ARGV.include?('-d') - ARGV.delete('-d') - ARGV.unshift('start') unless ARGV.detect{|a| ['start', 'restart'].include?(a)} - - root = File.expand_path(File.dirname(__FILE__) + '/..') - ARGV << "--rails=#{root}" - - system("ruby #{root}/vendor/gems/sweatshop/lib/sweatshop/sweatd.rb #{ARGV.join(' ')}") - exit $?.exitstatus -else - puts "Loading Rails..." - require File.dirname(__FILE__) + '/../config/environment' - puts "Listening for new tasks..." - Sweatshop.do_all_tasks -end diff --git a/test/functional/registry/registry_controller_test.rb b/test/functional/registry/registry_controller_test.rb index d1df6eb..2d3f597 100644 --- a/test/functional/registry/registry_controller_test.rb +++ b/test/functional/registry/registry_controller_test.rb @@ -1,4 +1,4 @@ -require 'test/test_helper.rb' +require 'test_helper.rb' class Registry::RegistryControllerTest < ActionController::TestCase @@ -41,7 +41,7 @@ def setup get :folders, :node => folder.parent.id assert_response :success expected = [{'id' => folder.id.to_s, 'key' => 'folder', 'label' => 'Label', 'text' => 'Label', 'cls' => 'folder'}] - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) end test 'folder' do @@ -52,7 +52,7 @@ def setup 'success' => true, 'folders' => [{'id' => @root.id.to_s, 'key' => @root.key, 'label' => @root.label, 'text' => @root.label, 'cls' => 'folder'}] } - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) end test 'folder creation' do @@ -66,7 +66,7 @@ def setup 'success' => true, 'folders' => [{'id' => @root.folders.first.id.to_s, 'key' => 'key', 'label' => 'Label', 'text' => 'Label', 'cls' => 'folder'}] } - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) assert_equal id, Registry::Folder.last.user_id end end @@ -86,7 +86,7 @@ def setup 'success' => true, 'folders' => [{'id' => child.id.to_s, 'key' => 'Key', 'label' => 'Label', 'text' => 'Label', 'cls' => 'folder'}] } - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) assert_equal id, child.user_id end end @@ -101,7 +101,7 @@ def setup 'success' => true, 'properties' => [{'label' => '', 'value' => '', 'description' => '', 'key' => ''}] } - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) end test 'property creation' do @@ -115,7 +115,7 @@ def setup 'success' => true, 'properties' => [{'label' => 'Label', 'value' => 'value', 'description' => 'Description', 'key' => 'key'}] } - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) assert_equal id, Registry::Entry.last.user_id end end @@ -135,7 +135,7 @@ def setup 'success' => true, 'properties' => [{'key' => 'Key', 'value' => 'Value', 'label' => 'Label', 'description' => 'Description'}] } - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) assert_equal id, Registry::Entry.last.user_id end end @@ -153,7 +153,7 @@ def setup {'id' => two.id.to_s, 'key' => 'two', 'value' => '2', 'label' => 'two', 'description' => '', 'access_code' => 'Registry.two', 'notes' => ''}, ] } - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) end test 'properties put' do @@ -168,7 +168,7 @@ def setup {'id' => one.id.to_s, 'key' => 'one', 'value' => '2', 'label' => 'one', 'description' => '', 'access_code' => 'Registry.one', 'notes' => ''}, ] } - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) assert_equal id, Registry::Entry.last.user_id end end @@ -185,7 +185,7 @@ def setup 'success' => true, 'properties' => [] } - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) assert_equal id, Registry::Entry::Version.last.user_id end end @@ -207,7 +207,7 @@ def setup {'id' => first.id.to_s, 'value' => '1', 'label' => 'one', 'updated' => first.updated_at.to_s, 'notes' => '', 'user' => ''}, ] } - assert_equal expected, JSON.parse(@response.body) + assert_equal expected, ActiveSupport::JSON.decode(@response.body) end diff --git a/test/test_helper.rb b/test/test_helper.rb index fefff2e..a536921 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,7 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../config/environment') require 'test_help' require 'ostruct' -require 'init' class ActiveSupport::TestCase diff --git a/test/unit/registry/entry_test.rb b/test/unit/registry/entry_test.rb index 41190b3..feb4024 100644 --- a/test/unit/registry/entry_test.rb +++ b/test/unit/registry/entry_test.rb @@ -1,4 +1,4 @@ -require 'test/test_helper' +require 'test_helper' module Registry class EntryTest < ActiveRecord::TestCase @@ -17,14 +17,14 @@ def setup test 'export!' do expected = create_entries - assert_equal expected, Entry.export!(CONFIG) + assert_hash expected, Entry.export!(CONFIG) assert_equal true, File.exists?(CONFIG), 'Export file should be created' end test 'export! no file' do File.delete(Entry::DEFAULT_YML_LOCATION) rescue nil expected = create_entries - assert_equal expected, Entry.export!(nil) + assert_hash expected, Entry.export!(nil) assert_equal false, File.exists?(Entry::DEFAULT_YML_LOCATION), 'Export file should NOT be created' end @@ -54,12 +54,13 @@ def setup expected = { 'dev' => { - 'one' => 'preserve', - 'two' => {'one' => 'preserve', 'two' => 'new'}, - 'tre' => 'new', + '_last_updated_at' => '__any__', + 'one' => 'preserve', + 'two' => {'one' => 'preserve', 'two' => 'new'}, + 'tre' => 'new', } } - assert_equal expected, Entry.export!(nil) + assert_hash expected, Entry.export!(nil) end test 'versioning' do @@ -124,8 +125,8 @@ def setup Entry.root.merge({'keep' => {:keep => 'ignored'}, :keep => 'ignored'}, :delete => true) - expected = {'keep' => {:keep => true}, :keep => 'keep'} - assert_equal expected, Entry.root.export + expected = {'keep' => {:keep => true}, :keep => 'keep', '_last_updated_at' => '__any__'} + assert_hash expected, Entry.root.export end test 'child' do @@ -169,6 +170,8 @@ def create_entries(envs=nil, folders=nil, values=nil) entries[env][folder.key].store(key, value) end end + + entries[env]['_last_updated_at'] = '__any__' end entries diff --git a/test/unit/registry/transcoder/base_test.rb b/test/unit/registry/transcoder/base_test.rb index 6891ba9..4f448d9 100644 --- a/test/unit/registry/transcoder/base_test.rb +++ b/test/unit/registry/transcoder/base_test.rb @@ -1,4 +1,4 @@ -require 'test/test_helper' +require 'test_helper' module Registry module Transcoder @@ -24,6 +24,17 @@ class BaseTest < ActiveSupport::TestCase assert_same self, Transcoder.from_db(self) end + test 'date_parsing different formats' do + date_string = '2007-01-16' + assert_equal Date.strptime(date_string, '%Y-%m-%d'), Transcoder.from_db(date_string) + date_string = '01-16-2007' + assert_equal Date.strptime(date_string, '%m-%d-%Y'), Transcoder.from_db(date_string) + date_string = '16-01-2007' + assert_equal Date.strptime(date_string, '%d-%m-%Y'), Transcoder.from_db(date_string) + date_string = '99-99-99' + assert_equal date_string, Transcoder.from_db(date_string) + end + test 'from_db handles leading zeros in ranges' do assert_equal 0 .. 9, Transcoder.from_db('00 .. 09'), 'leading zero range transcoding failed' end diff --git a/test/unit/registry/transcoder/dsl_test.rb b/test/unit/registry/transcoder/dsl_test.rb index fd72c31..403bae1 100644 --- a/test/unit/registry/transcoder/dsl_test.rb +++ b/test/unit/registry/transcoder/dsl_test.rb @@ -1,4 +1,4 @@ -require 'test/test_helper' +require 'test_helper' module Registry module Transcoder diff --git a/test/unit/registry_test.rb b/test/unit/registry_test.rb index 6583a7b..daf2ef2 100755 --- a/test/unit/registry_test.rb +++ b/test/unit/registry_test.rb @@ -1,4 +1,4 @@ -require 'test/test_helper' +require 'test_helper' class RegistryTest < ActiveSupport::TestCase @@ -85,6 +85,7 @@ def setup end expected = { + '_last_updated_at' => '__any__', 'unchanged' => { 'string' => 'default', }, @@ -96,7 +97,7 @@ def setup 'string' => 'new', }, } - assert_equal expected, Registry.to_hash + assert_hash expected, Registry.to_hash end test 'import with purge' do @@ -221,6 +222,21 @@ def setup assert_equal 1, wrapper.one end + test '_last_updated_at' do + assert_equal Time.at(0), Registry._last_updated_at + + reg = { + 'api' => { + :enabled => true, + 'limit' => 1, + }, + } + Registry::Entry.root.merge(reg) + Registry.reset + + assert_not_equal Time.at(0), Registry._last_updated_at + end + private def registry_hash_with_defaults diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/CHANGELOG b/vendor/gems/metaskills-acts_as_versioned-0.6.3/CHANGELOG deleted file mode 100644 index 533360c..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/CHANGELOG +++ /dev/null @@ -1,115 +0,0 @@ - -[master] - - * - -[0.6.3] - - * (04 Apr 2009) Remove :dependent => :delete_all options as it is hard to override with - association_options. [Ken Collins] - -[0.6.2] - - * (08 Feb 2009) Avoid error with model preload by removing create_versioned_table call in AAV call. [Ngoc Dao] - * (08 Feb 2009) Do not force updated_at [Ngoc Dao] - * (08 Feb 2009) Change the create_versioned_table class method to ask the connection if table_exists?. Fixes - a bug that allows adapters that allow user owned prefixes for table names. [Ken Collins] - - -[0.6.1] - - * (29 Dec 2008) Remove #versions_count really. [Ken Collins] - * (30 Dec 2008) Add assert_sql support in boot.rb. Also changed core lib to order by the has many versions - association with the version_column, support with tests. [Ken Collins] - -[0.6] - - * (23 Dec 2008) Clean up old old code and start move towards new gem [Ken Collins] - * Starting a .gitignore file. - * Moving to a test/lib based directory structure with a boot and AAV test case based from ActiveRecord's case. - * Create rake test and test_dbs tasks. - * Create a gemspec for publishing as a gem. - -[0.5.2] - - * (16 Jun 2008) Backwards Compatibility is overrated (big updates for rails 2.1) - * Use ActiveRecord 2.1's dirty attribute checking instead [Asa Calow] - * Remove last traces of #non_versioned_fields - * Remove AR::Base.find_version and AR::Base.find_versions, rely on AR association proxies and named_scope - * Remove #versions_count, rely on AR association counter caching. - * Remove #versioned_attributes, basically the same as AR::Base.versioned_columns - - * (5 Oct 2006) Allow customization of #versions association options [Dan Peterson] - -[0.5.1] - - * (8 Aug 2006) Versioned models now belong to the unversioned model. @article_version.article.class => Article [Aslak Hellesoy] - -[0.5] - - * (21 Apr 2006) Added without_locking and without_revision methods. - Foo.without_revision do - @foo.update_attributes ... - end - -[0.4] - - * (28 March 2006) Rename non_versioned_fields to non_versioned_columns (old one is kept for compatibility). - * (28 March 2006) Made explicit documentation note that string column names are required for non_versioned_columns. - -[0.3.1] - - * (7 Jan 2006) explicitly set :foreign_key option for the versioned model's belongs_to assocation for STI [Caged] - * (7 Jan 2006) added tests to prove has_many :through joins work - -[0.3] - - * (2 Jan 2006) added ability to share a mixin with versioned class - * (2 Jan 2006) changed the dynamic version model to MyModel::Version - -[0.2.4] - - * (27 Nov 2005) added note about possible destructive behavior of if_changed? [Michael Schuerig] - -[0.2.3] - - * (12 Nov 2005) fixed bug with old behavior of #blank? [Michael Schuerig] - * (12 Nov 2005) updated tests to use ActiveRecord Schema - -[0.2.2] - - * (3 Nov 2005) added documentation note to #acts_as_versioned [Martin Jul] - -[0.2.1] - - * (6 Oct 2005) renamed dirty? to changed? to keep it uniform. it was aliased to keep it backwards compatible. - -[0.2] - - * (6 Oct 2005) added find_versions and find_version class methods. - - * (6 Oct 2005) removed transaction from create_versioned_table(). - this way you can specify your own transaction around a group of operations. - - * (30 Sep 2005) fixed bug where find_versions() would order by 'version' twice. (found by Joe Clark) - - * (26 Sep 2005) added :sequence_name option to acts_as_versioned to set the sequence name on the versioned model - -[0.1.3] - - * (18 Sep 2005) First RubyForge release - -[0.1.2] - - * check if module is already included when acts_as_versioned is called - -[0.1.1] - - * Adding tests and rdocs - -[0.1] - - * Initial transfer from Rails ticket: http://dev.rubyonrails.com/ticket/1974 - - - diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/MIT-LICENSE b/vendor/gems/metaskills-acts_as_versioned-0.6.3/MIT-LICENSE deleted file mode 100644 index 5851fda..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2005 Rick Olson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/README.rdoc b/vendor/gems/metaskills-acts_as_versioned-0.6.3/README.rdoc deleted file mode 100644 index 147f2d3..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/README.rdoc +++ /dev/null @@ -1,24 +0,0 @@ - -= MetaSkills ActsAsVersioned - -A fork of Rick Olson's ActsAsVersioned plugin that has been gem'ized along with a few features I need. This library -adds simple versioning to an ActiveRecord class which of course requires ActiveRecord for use. - -Has tests for many DBs in ActiveRecord version 2.2.2 - - -== Resources - -Install the gem manually. - - $ sudo gem install metaskills-acts_as_versioned - -Or with a rails config.gem dependency. - - config.gem 'metaskills-acts_as_versioned', :lib => 'acts_as_versioned', :source => 'http://gems.github.com/' - - -The git repository is located here: - -* http://github.com/metaskills/acts_as_versioned/tree/master - diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/RUNNING_UNIT_TESTS b/vendor/gems/metaskills-acts_as_versioned-0.6.3/RUNNING_UNIT_TESTS deleted file mode 100644 index 7241fbd..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/RUNNING_UNIT_TESTS +++ /dev/null @@ -1,21 +0,0 @@ - -== Creating the test database - -The default name for the test databases is can be found in the test/lib/database.yml files. By -default the tests will run on sqlite3 but can be changed using and ENV['DB'] variable like postresql, -mysql or even sqlserver. - -== Running with Rake - -The easiest way to run the unit tests is through Rake. The default task runs all the test cases. -There is even a rake task called test_dbs that will run all test cases for each DB. - -== Running by hand - -Unit tests are located in test directory. If you only want to run a single test suite, -or don't want to bother with Rake, you can do so with something like: - - cd test ; ruby -I "test" versioned_test.rb - -Likewise you can just hit Command-R if you are using TextMate. - diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/Rakefile b/vendor/gems/metaskills-acts_as_versioned-0.6.3/Rakefile deleted file mode 100644 index 4896c96..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/Rakefile +++ /dev/null @@ -1,24 +0,0 @@ -require 'rubygems' -require 'rake/testtask' - -desc 'Default: Test ActsAsVersioned with default ActiveRecord version.' -task :default => :test - -desc 'Test ActsAsVersioned with default ActiveRecord version.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' << 'test' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Test ActsAsVersioned with all databases.' -task :test_dbs do - test = Rake::Task['test'] - dbs = ['sqlite3','postgresql','mysql','sqlserver'] - dbs.each do |db| - ENV['DB'] = db - test.invoke - test.reenable - end -end - diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/authors.yml b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/authors.yml deleted file mode 100644 index bd7a5ae..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/authors.yml +++ /dev/null @@ -1,6 +0,0 @@ -caged: - id: 1 - name: caged -mly: - id: 2 - name: mly \ No newline at end of file diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/landmark_versions.yml b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/landmark_versions.yml deleted file mode 100644 index 2dbd54e..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/landmark_versions.yml +++ /dev/null @@ -1,7 +0,0 @@ -washington: - id: 1 - landmark_id: 1 - version: 1 - name: Washington, D.C. - latitude: 38.895 - longitude: -77.036667 diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/landmarks.yml b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/landmarks.yml deleted file mode 100644 index cf06390..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/landmarks.yml +++ /dev/null @@ -1,7 +0,0 @@ -washington: - id: 1 - name: Washington, D.C. - latitude: 38.895 - longitude: -77.036667 - doesnt_trigger_version: This is not important - version: 1 diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/locked_pages.yml b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/locked_pages.yml deleted file mode 100644 index 318e776..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/locked_pages.yml +++ /dev/null @@ -1,10 +0,0 @@ -welcome: - id: 1 - title: Welcome to the weblog - lock_version: 24 - type: LockedPage -thinking: - id: 2 - title: So I was thinking - lock_version: 24 - type: SpecialLockedPage diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/locked_pages_revisions.yml b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/locked_pages_revisions.yml deleted file mode 100644 index 3a1be5a..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/locked_pages_revisions.yml +++ /dev/null @@ -1,27 +0,0 @@ -welcome_1: - id: 1 - page_id: 1 - title: Welcome to the weblg - lock_version: 23 - version_type: LockedPage - -welcome_2: - id: 2 - page_id: 1 - title: Welcome to the weblog - lock_version: 24 - version_type: LockedPage - -thinking_1: - id: 3 - page_id: 2 - title: So I was thinking!!! - lock_version: 23 - version_type: SpecialLockedPage - -thinking_2: - id: 4 - page_id: 2 - title: So I was thinking - lock_version: 24 - version_type: SpecialLockedPage diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/page_versions.yml b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/page_versions.yml deleted file mode 100644 index ef565fa..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/page_versions.yml +++ /dev/null @@ -1,16 +0,0 @@ -welcome_2: - id: 1 - page_id: 1 - title: Welcome to the weblog - body: Such a lovely day - version: 24 - author_id: 1 - revisor_id: 1 -welcome_1: - id: 2 - page_id: 1 - title: Welcome to the weblg - body: Such a lovely day - version: 23 - author_id: 2 - revisor_id: 2 diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/pages.yml b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/pages.yml deleted file mode 100644 index 9f4ab54..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/pages.yml +++ /dev/null @@ -1,8 +0,0 @@ -welcome: - id: 1 - title: Welcome to the weblog - body: Such a lovely day - version: 24 - author_id: 1 - revisor_id: 1 - created_on: "2008-01-01 00:00:00" \ No newline at end of file diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/widgets.yml b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/widgets.yml deleted file mode 100644 index 139597f..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/fixtures/widgets.yml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/helper.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/helper.rb deleted file mode 100644 index 10bd2f4..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/helper.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'test/unit' -require File.join(File.dirname(__FILE__),'lib/boot') unless defined?(ActiveRecord) -require 'acts_as_versioned' - -class AAVTestCase < ActiveRecord::TestCase - - self.use_transactional_fixtures = true - self.use_instantiated_fixtures = false - - fixtures :all - set_fixture_class :page_versions => Page::Version - - protected - - def assert_sql(*patterns_to_match) - $queries_executed = [] - yield - ensure - failed_patterns = [] - patterns_to_match.each do |pattern| - failed_patterns << pattern unless $queries_executed.any?{ |sql| pattern === sql } - end - assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map(&:inspect).join(', ')} not found in:\n#{$queries_executed.inspect}" - end - -end - diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/lib/boot.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/lib/boot.rb deleted file mode 100644 index 075ed77..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/lib/boot.rb +++ /dev/null @@ -1,68 +0,0 @@ - -# Requiring ActiveRecord via RubyGems. - -require 'rubygems' - -PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__),'..','..')) -AR_VERSION = ENV['AR_VERSION'] || '2.2.2' - -['.','lib','test','test/models'].each do |test_lib| - load_path = File.expand_path(File.join(PROJECT_ROOT,test_lib)) - $LOAD_PATH.unshift(load_path) unless $LOAD_PATH.include?(load_path) -end - -puts "Using ActiveRecord #{AR_VERSION} from gems" -gem 'activerecord', AR_VERSION -require 'active_record' - - -# Setting up ActiveRecord TestCase and fixtures. We make sure our setup runs before setup_fixtures. - -FIXTURES_ROOT = PROJECT_ROOT + "/test/fixtures" -MIGRATIONS_ROOT = PROJECT_ROOT + "/test/migrations" - -require 'active_record/fixtures' -require 'active_record/test_case' - - -# Establishing the ActiveRecord connection and DB specific tasks. - -ardb = ENV['DB'] || 'sqlite3' -arconfig = YAML::load(IO.read("#{PROJECT_ROOT}/test/lib/database.yml")) - -case ardb -when 'sqlserver' - gem 'rails-sqlserver-2000-2005-adapter' - require 'active_record/connection_adapters/sqlserver_adapter' -end - -ActiveRecord::Base.logger = Logger.new("#{PROJECT_ROOT}/test/debug.log") -ActiveRecord::Base.configurations = {'test' => arconfig[ardb]} -ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) -puts "With database: #{ardb}" - -ActiveRecord::Base.connection.class.class_eval do - IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/] - def execute_with_query_record(sql, name = nil, &block) - $queries_executed ||= [] - $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r } - execute_without_query_record(sql, name, &block) - end - alias_method_chain :execute, :query_record -end - - -# Creating the DB schema and DB specific tasks. - -ActiveRecord::Migration.verbose = false - -load(File.dirname(__FILE__)+"/schema.rb") - -case ardb -when 'postgresql' - ActiveRecord::Base.connection.execute "DROP SEQUENCE widgets_seq;" rescue nil - ActiveRecord::Base.connection.remove_column :widget_versions, :id - ActiveRecord::Base.connection.execute "CREATE SEQUENCE widgets_seq START 101;" - ActiveRecord::Base.connection.execute "ALTER TABLE widget_versions ADD COLUMN id INTEGER PRIMARY KEY DEFAULT nextval('widgets_seq');" -end - diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/lib/database.yml b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/lib/database.yml deleted file mode 100644 index ab3c51c..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/lib/database.yml +++ /dev/null @@ -1,26 +0,0 @@ - -sqlite3: - adapter: sqlite3 - database: ":memory:" - -postgresql: - adapter: postgresql - username: postgres - password: postgres - database: acts_as_versioned_plugin_test - min_messages: ERROR - -mysql: - adapter: mysql - host: localhost - username: rails - password: - database: acts_as_versioned_plugin_test - -sqlserver: - adapter: sqlserver - mode: ODBC - username: rails - password: - dsn: acts_as_versioned_plugin_test - diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/lib/schema.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/lib/schema.rb deleted file mode 100644 index 38def5f..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/lib/schema.rb +++ /dev/null @@ -1,91 +0,0 @@ -ActiveRecord::Base.class_eval do - - connection.create_table :pages, :force => true do |t| - t.column :version, :integer - t.column :title, :string, :limit => 255 - t.column :body, :text - t.column :created_on, :datetime - t.column :updated_on, :datetime - t.column :author_id, :integer - t.column :revisor_id, :integer - end - - connection.create_table :page_versions, :force => true do |t| - t.column :page_id, :integer - t.column :version, :integer - t.column :title, :string, :limit => 255 - t.column :body, :text - t.column :created_on, :datetime - t.column :updated_on, :datetime - t.column :author_id, :integer - t.column :revisor_id, :integer - end - - connection.add_index :page_versions, [:page_id, :version], :unique => true - - connection.create_table :authors, :force => true do |t| - t.column :page_id, :integer - t.column :name, :string - end - - connection.create_table :locked_pages, :force => true do |t| - t.column :lock_version, :integer - t.column :title, :string, :limit => 255 - t.column :body, :text - t.column :type, :string, :limit => 255 - end - - connection.create_table :locked_pages_revisions, :force => true do |t| - t.column :page_id, :integer - t.column :lock_version, :integer - t.column :title, :string, :limit => 255 - t.column :body, :text - t.column :version_type, :string, :limit => 255 - t.column :updated_at, :datetime - end - - connection.add_index :locked_pages_revisions, [:page_id, :lock_version], :unique => true - - connection.create_table :widgets, :force => true do |t| - t.column :name, :string, :limit => 50 - t.column :foo, :string - t.column :version, :integer - t.column :updated_at, :datetime - end - - connection.create_table :widget_versions, :force => true do |t| - t.column :widget_id, :integer - t.column :name, :string, :limit => 50 - t.column :version, :integer - t.column :updated_at, :datetime - end - - connection.add_index :widget_versions, [:widget_id, :version], :unique => true - - connection.create_table :landmarks, :force => true do |t| - t.column :name, :string - t.column :latitude, :float - t.column :longitude, :float - t.column :doesnt_trigger_version, :string - t.column :version, :integer - end - - connection.create_table :landmark_versions, :force => true do |t| - t.column :landmark_id, :integer - t.column :name, :string - t.column :latitude, :float - t.column :longitude, :float - t.column :doesnt_trigger_version, :string - t.column :version, :integer - end - - connection.add_index :landmark_versions, [:landmark_id, :version], :unique => true - - connection.create_table :things, :force => true do |t| - t.column :title, :text - t.column :price, :decimal, :precision => 7, :scale => 2 - t.column :type, :string - end - -end - diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/migration_test.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/migration_test.rb deleted file mode 100644 index 0e81567..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/migration_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'helper' -require 'models/thing' - -class MigrationTest < AAVTestCase - - self.use_transactional_fixtures = false - - setup :migrate_up, :create_thing - teardown :migrate_down - - - test "that the price column has remembered its value correctly" do - assert_equal @thing.price, @thing.versions.first.price - assert_equal @thing.title, @thing.versions.first.title - assert_equal @thing[:type], @thing.versions.first[:type] - end - - test "to make sure that the precision of the price column has been preserved" do - assert_equal 7, Thing::Version.columns.find{|c| c.name == "price"}.precision - assert_equal 2, Thing::Version.columns.find{|c| c.name == "price"}.scale - end - - - protected - - def migrate_up - ActiveRecord::Migrator.up(MIGRATIONS_ROOT) - Thing.reset_column_information - end - - def create_thing - @thing = Thing.create :title => 'blah blah', :price => 123.45, :type => 'Thing' - end - - def migrate_down - ActiveRecord::Migrator.down(MIGRATIONS_ROOT) - ActiveRecord::Base.connection.initialize_schema_migrations_table - ActiveRecord::Base.connection.assume_migrated_upto_version(0) - end - - -end - diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/migrations/1_add_versioned_tables.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/migrations/1_add_versioned_tables.rb deleted file mode 100644 index 8a68ebf..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/migrations/1_add_versioned_tables.rb +++ /dev/null @@ -1,19 +0,0 @@ -class AddVersionedTables < ActiveRecord::Migration - - def self.up - drop_table :things rescue nil - drop_table :thing_versions rescue nil - create_table :things do |t| - t.column :title, :text - t.column :price, :decimal, :precision => 7, :scale => 2 - t.column :type, :string - end - Thing.create_versioned_table - end - - def self.down - drop_table :things rescue nil - drop_table :thing_versions rescue nil - end - -end diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/author.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/author.rb deleted file mode 100644 index 4ac53f7..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/author.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Author < ActiveRecord::Base - has_many :pages -end diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/landmark.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/landmark.rb deleted file mode 100644 index cb9b930..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/landmark.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Landmark < ActiveRecord::Base - acts_as_versioned :if_changed => [ :name, :longitude, :latitude ] -end diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/page.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/page.rb deleted file mode 100644 index daf7c1b..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/page.rb +++ /dev/null @@ -1,38 +0,0 @@ -class Page < ActiveRecord::Base - belongs_to :author - has_many :authors, :through => :versions, :order => 'name' - belongs_to :revisor, :class_name => 'Author' - has_many :revisors, :class_name => 'Author', :through => :versions, :order => 'name' - acts_as_versioned :if => :feeling_good? do - def self.included(base) - base.cattr_accessor :feeling_good - base.feeling_good = true - base.belongs_to :author - base.belongs_to :revisor, :class_name => 'Author' - end - def feeling_good? - @@feeling_good == true - end - end -end - -module LockedPageExtension - def hello_world - 'hello_world' - end -end - -class LockedPage < ActiveRecord::Base - acts_as_versioned \ - :inheritance_column => :version_type, - :foreign_key => :page_id, - :table_name => :locked_pages_revisions, - :class_name => 'LockedPageRevision', - :version_column => :lock_version, - :limit => 2, - :if_changed => :title, - :extend => LockedPageExtension -end - -class SpecialLockedPage < LockedPage -end diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/thing.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/thing.rb deleted file mode 100644 index 891f378..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/thing.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Thing < ActiveRecord::Base - - attr_accessor :version - acts_as_versioned - - -end diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/widget.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/widget.rb deleted file mode 100644 index 14bd3c2..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/models/widget.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Widget < ActiveRecord::Base - acts_as_versioned :sequence_name => 'widgets_seq', :association_options => { - :dependent => :nullify, :order => 'version desc' - } - non_versioned_columns << 'foo' -end diff --git a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/versioned_test.rb b/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/versioned_test.rb deleted file mode 100644 index 6db5520..0000000 --- a/vendor/gems/metaskills-acts_as_versioned-0.6.3/test/versioned_test.rb +++ /dev/null @@ -1,335 +0,0 @@ -require 'helper' - -class VersionedTest < AAVTestCase - - - test "saves versioned copy" do - p = Page.create! :title => 'first title', :body => 'first body' - assert !p.new_record? - assert_equal 1, p.versions.size - assert_equal 1, p.version - assert_instance_of Page.versioned_class, p.versions.first - end - - test "version has unique created on" do - p = pages(:welcome) - p.title = 'update me' - p.save! - assert_not_equal p.created_on, p.versions.latest.created_on - end - - test "saves without revision" do - p = pages(:welcome) - old_versions = p.versions.count - p.save_without_revision - p.without_revision do - p.update_attributes :title => 'changed' - end - assert_equal old_versions, p.versions.count - end - - test "rollback with version number" do - p = pages(:welcome) - assert_equal 24, p.version - assert_equal 'Welcome to the weblog', p.title - assert p.revert_to!(23), "Couldn't revert to 23" - assert_equal 23, p.version - assert_equal 'Welcome to the weblg', p.title - end - - test "versioned class name" do - assert_equal 'Version', Page.versioned_class_name - assert_equal 'LockedPageRevision', LockedPage.versioned_class_name - end - - test "versioned class" do - assert_equal Page::Version, Page.versioned_class - assert_equal LockedPage::LockedPageRevision, LockedPage.versioned_class - end - - test "special methods" do - assert_nothing_raised { pages(:welcome).feeling_good? } - assert_nothing_raised { pages(:welcome).versions.first.feeling_good? } - assert_nothing_raised { locked_pages(:welcome).hello_world } - assert_nothing_raised { locked_pages(:welcome).versions.first.hello_world } - end - - test "version objects are ordered by the version columns" do - p = pages(:welcome) - assert_sql(/ORDER BY version ASC/) { p.versions(true) } - assert_equal [23,24], p.versions.map(&:version) - end - - test "rollback with version class" do - p = pages(:welcome) - assert_equal 24, p.version - assert_equal 'Welcome to the weblog', p.title - assert p.revert_to!(p.versions.find_by_version(23)), "Couldn't revert to 23" - assert_equal 23, p.version - assert_equal 'Welcome to the weblg', p.title - end - - test "rollback fails with invalid revision" do - p = locked_pages(:welcome) - assert !p.revert_to!(locked_pages(:thinking)) - end - - test "saves versioned copy with options" do - p = LockedPage.create! :title => 'first title' - assert !p.new_record? - assert_equal 1, p.versions.size - assert_instance_of LockedPage.versioned_class, p.versions.first - end - - test "rollback with version number with options" do - p = locked_pages(:welcome) - assert_equal 'Welcome to the weblog', p.title - assert_equal 'LockedPage', p.versions.first.version_type - assert p.revert_to!(p.versions.first.lock_version), "Couldn't revert to 23" - assert_equal 'Welcome to the weblg', p.title - assert_equal 'LockedPage', p.versions.first.version_type - end - - test "rollback with version class with options" do - p = locked_pages(:welcome) - assert_equal 'Welcome to the weblog', p.title - assert_equal 'LockedPage', p.versions.first.version_type - assert p.revert_to!(p.versions.first), "Couldn't revert to 1" - assert_equal 'Welcome to the weblg', p.title - assert_equal 'LockedPage', p.versions.first.version_type - end - - test "saves versioned copy with sti" do - p = SpecialLockedPage.create! :title => 'first title' - assert !p.new_record? - assert_equal 1, p.versions.size - assert_instance_of LockedPage.versioned_class, p.versions.first - assert_equal 'SpecialLockedPage', p.versions.first.version_type - end - - test "rollback with version number with sti" do - p = locked_pages(:thinking) - assert_equal 'So I was thinking', p.title - - assert p.revert_to!(p.versions.first.lock_version), "Couldn't revert to 1" - assert_equal 'So I was thinking!!!', p.title - assert_equal 'SpecialLockedPage', p.versions.first.version_type - end - - test "lock version works with versioning" do - p = locked_pages(:thinking) - p2 = LockedPage.find(p.id) - p.title = 'fresh title' - p.save - assert_equal 2, p.versions.size # limit! - assert_raises(ActiveRecord::StaleObjectError) do - p2.title = 'stale title' - p2.save - end - end - - test "version if condition" do - p = Page.create! :title => "title" - assert_equal 1, p.version - Page.feeling_good = false - p.save - assert_equal 1, p.version - Page.feeling_good = true - end - - test "version if condition2" do - # set new if condition - Page.class_eval do - def new_feeling_good() title[0..0] == 'a'; end - alias_method :old_feeling_good, :feeling_good? - alias_method :feeling_good?, :new_feeling_good - end - p = Page.create! :title => "title" - assert_equal 1, p.version # version does not increment - assert_equal 1, p.versions.count - p.update_attributes(:title => 'new title') - assert_equal 1, p.version # version does not increment - assert_equal 1, p.versions.count - p.update_attributes(:title => 'a title') - assert_equal 2, p.version - assert_equal 2, p.versions.count - # reset original if condition - Page.class_eval { alias_method :feeling_good?, :old_feeling_good } - end - - test "version if condition with block" do - # set new if condition - old_condition = Page.version_condition - Page.version_condition = Proc.new { |page| page.title[0..0] == 'b' } - p = Page.create! :title => "title" - assert_equal 1, p.version # version does not increment - assert_equal 1, p.versions.count - p.update_attributes(:title => 'a title') - assert_equal 1, p.version # version does not increment - assert_equal 1, p.versions.count - p.update_attributes(:title => 'b title') - assert_equal 2, p.version - assert_equal 2, p.versions.count - # reset original if condition - Page.version_condition = old_condition - end - - test "version no limit" do - p = Page.create! :title => "title", :body => 'first body' - p.save - p.save - 5.times do |i| - p.title = "title#{i}" - p.save - assert_equal "title#{i}", p.title - assert_equal (i+2), p.version - end - end - - test "version max limit" do - p = LockedPage.create! :title => "title" - p.update_attributes(:title => "title1") - p.update_attributes(:title => "title2") - 5.times do |i| - p.title = "title#{i}" - p.save - assert_equal "title#{i}", p.title - assert_equal (i+4), p.lock_version - assert p.versions(true).size <= 2, "locked version can only store 2 versions" - end - end - - test "track altered attributes default value" do - assert !Page.track_altered_attributes - assert LockedPage.track_altered_attributes - assert SpecialLockedPage.track_altered_attributes - end - - test "track altered attributes" do - p = LockedPage.create! :title => "title" - assert_equal 1, p.lock_version - assert_equal 1, p.versions(true).size - p.body = 'whoa' - assert !p.save_version? - p.save - assert_equal 2, p.lock_version # still increments version because of optimistic locking - assert_equal 1, p.versions(true).size - p.title = 'updated title' - assert p.save_version? - p.save - assert_equal 3, p.lock_version - assert_equal 1, p.versions(true).size # version 1 deleted - p.title = 'updated title!' - assert p.save_version? - p.save - assert_equal 4, p.lock_version - assert_equal 2, p.versions(true).size # version 1 deleted - end - - test "find versions" do - assert_equal 1, locked_pages(:welcome).versions.find(:all, :conditions => ['title LIKE ?', '%weblog%']).size - end - - test "find version" do - assert_equal page_versions(:welcome_1), pages(:welcome).versions.find_by_version(23) - end - - test "with sequence" do - assert_equal 'widgets_seq', Widget.versioned_class.sequence_name - 3.times { Widget.create! :name => 'new widget' } - assert_equal 3, Widget.count - assert_equal 3, Widget.versioned_class.count - end - - test "has many through" do - assert_equal [authors(:caged), authors(:mly)], pages(:welcome).authors - end - - test "has many through with custom association" do - assert_equal [authors(:caged), authors(:mly)], pages(:welcome).revisors - end - - test "referential integrity" do - pages(:welcome).destroy - assert_equal 0, Page.count - assert_equal 2, Page::Version.count - end - - test "association options" do - association = Page.reflect_on_association(:versions) - options = association.options - association = Widget.reflect_on_association(:versions) - options = association.options - assert_equal :nullify, options[:dependent] - assert_equal 'version desc', options[:order] - assert_equal 'widget_id', options[:foreign_key] - widget = Widget.create! :name => 'new widget' - assert_equal 1, Widget.count - assert_equal 1, Widget.versioned_class.count - widget.destroy - assert_equal 0, Widget.count - assert_equal 1, Widget::Version.count - end - - test "versioned records should belong to parent" do - page = pages(:welcome) - page_version = page.versions.last - assert_equal page, page_version.page - end - - test "unaltered attributes" do - landmarks(:washington).attributes = landmarks(:washington).attributes.except("id") - assert !landmarks(:washington).changed? - end - - test "unchanged string attributes" do - landmarks(:washington).attributes = landmarks(:washington).attributes.except("id").inject({}) { |params, (key, value)| params.update(key => value.to_s) } - assert !landmarks(:washington).changed? - end - - test "should find earliest version" do - assert_equal page_versions(:welcome_1), pages(:welcome).versions.earliest - end - - test "should find latest version" do - assert_equal page_versions(:welcome_2), pages(:welcome).versions.latest - end - - test "should find previous version" do - assert_equal page_versions(:welcome_1), page_versions(:welcome_2).previous - assert_equal page_versions(:welcome_1), pages(:welcome).versions.before(page_versions(:welcome_2)) - end - - test "should find next version" do - assert_equal page_versions(:welcome_2), page_versions(:welcome_1).next - assert_equal page_versions(:welcome_2), pages(:welcome).versions.after(page_versions(:welcome_1)) - end - - test "should find version count" do - assert_equal 2, pages(:welcome).versions.size - end - - test "if changed creates version if a listed column is changed" do - landmarks(:washington).name = "Washington" - assert landmarks(:washington).changed? - assert landmarks(:washington).altered? - end - - test "if changed creates version if all listed columns are changed" do - landmarks(:washington).name = "Washington" - landmarks(:washington).latitude = 1.0 - landmarks(:washington).longitude = 1.0 - assert landmarks(:washington).changed? - assert landmarks(:washington).altered? - end - - test "if changed does not create new version if unlisted column is changed" do - landmarks(:washington).doesnt_trigger_version = "This should not trigger version" - assert landmarks(:washington).changed? - assert !landmarks(:washington).altered? - end - - -end - -