Permalink
Browse files

fix some premature optimizations that bit me in the ass

  • Loading branch information...
1 parent 907a406 commit 6944f6e660c90ece2317169acfff08660eeac2aa @rsl committed Dec 6, 2012
Showing with 54 additions and 55 deletions.
  1. +53 −6 test/acts_as_url/adapter/active_record.rb
  2. +0 −48 test/acts_as_url/example_classes.rb
  3. +1 −1 test/acts_as_url_test.rb
@@ -1,15 +1,16 @@
require 'rubygems'
gem 'activerecord'
require 'active_record'
-
-RAILS_ROOT = File.expand_path(File.dirname(__FILE__))
-
require "stringex"
+puts "-------------------------------------------------"
+puts "Running ActsAsUrl tests with ActiveRecord adapter"
+puts "-------------------------------------------------"
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "acts_as_url.sqlite3")
ActiveRecord::Migration.verbose = false
-ActiveRecord::Schema.define(:version => 1) do
+ActiveRecord::Schema.define do
create_table :documents, :force => true do |t|
t.string :title, :url, :other
end
@@ -56,5 +57,51 @@
end
ActiveRecord::Migration.verbose = true
-BASE_CLASS = ActiveRecord::Base
-require File.join(File.expand_path(File.dirname(__FILE__)), '../example_classes.rb')
+class Document < ActiveRecord::Base
+ acts_as_url :title
+end
+
+class Updatument < ActiveRecord::Base
+ acts_as_url :title, :sync_url => true
+end
+
+class Mocument < ActiveRecord::Base
+ acts_as_url :title, :scope => :other, :sync_url => true
+end
+
+class Permument < ActiveRecord::Base
+ acts_as_url :title, :url_attribute => :permalink
+end
+
+class Procument < ActiveRecord::Base
+ acts_as_url :non_attribute_method
+
+ def non_attribute_method
+ "#{title} got massaged"
+ end
+end
+
+class Blankument < ActiveRecord::Base
+ acts_as_url :title, :only_when_blank => true
+end
+
+class Duplicatument < ActiveRecord::Base
+ acts_as_url :title, :duplicate_count_separator => "---"
+end
+
+class Validatument < ActiveRecord::Base
+ acts_as_url :title, :sync_url => true
+ validates_presence_of :title
+end
+
+class Ununiqument < ActiveRecord::Base
+ acts_as_url :title, :allow_duplicates => true
+end
+
+class Limitument < ActiveRecord::Base
+ acts_as_url :title, :limit => 13
+end
+
+class Skipument < ActiveRecord::Base
+ acts_as_url :title, :exclude => ["_So_Fucking_Special"]
+end
@@ -1,48 +0,0 @@
-class Document < BASE_CLASS
- acts_as_url :title
-end
-
-class Updatument < BASE_CLASS
- acts_as_url :title, :sync_url => true
-end
-
-class Mocument < BASE_CLASS
- acts_as_url :title, :scope => :other, :sync_url => true
-end
-
-class Permument < BASE_CLASS
- acts_as_url :title, :url_attribute => :permalink
-end
-
-class Procument < BASE_CLASS
- acts_as_url :non_attribute_method
-
- def non_attribute_method
- "#{title} got massaged"
- end
-end
-
-class Blankument < BASE_CLASS
- acts_as_url :title, :only_when_blank => true
-end
-
-class Duplicatument < BASE_CLASS
- acts_as_url :title, :duplicate_count_separator => "---"
-end
-
-class Validatument < BASE_CLASS
- acts_as_url :title, :sync_url => true
- validates_presence_of :title
-end
-
-class Ununiqument < BASE_CLASS
- acts_as_url :title, :allow_duplicates => true
-end
-
-class Limitument < BASE_CLASS
- acts_as_url :title, :limit => 13
-end
-
-class Skipument < BASE_CLASS
- acts_as_url :title, :exclude => ["_So_Fucking_Special"]
-end
View
@@ -1,6 +1,6 @@
# encoding: UTF-8
require 'test_helper'
-# NOTE: Stringex gets required inside the adapter
+
adapter = ENV['ADAPTER'] || 'active_record'
require File.join(File.expand_path(File.dirname(__FILE__)), "acts_as_url/adapter/#{adapter}.rb")

0 comments on commit 6944f6e

Please sign in to comment.