Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Commit

Permalink
started tests, make more plugin-able
Browse files Browse the repository at this point in the history
  • Loading branch information
mooman committed Oct 2, 2010
1 parent 0d07380 commit f8f8bd9
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 37 deletions.
13 changes: 13 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source "http://gemcutter.org"

gem "rails", "3.0.0"

gem 'sqlite3-ruby'
gem 'sequel'
gem 'sequel-rails'

gem "warden", "1.0.0"
gem "webrat", "0.7.1"
gem "mocha", :require => false
gem "bcrypt-ruby", :require => "bcrypt"
gem "oauth2"
37 changes: 0 additions & 37 deletions README

This file was deleted.

30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Sequel mapping to Devise
========================

**A gem plugin is coming soon! (once all the tests passes)**

I like to extend only the models I need for Devise:

class User < Sequel::Model
extend Devise::Models
extend Devise::Orm::Sequel::Hook

# usually active_model is included already in any Sequel Rails 3 connectors
# plugin :active_model
plugin :validation_class_methods

devise ...
end

But if you want them to be globally available for all your Sequal models, then uncomment the lines at the bottom of the sequel.rb file in the plugin. Hopefully this can be more elegant in the future where you can set an option somewhere.

Let us know if you have any suggestions and/or questions by creating a new issue.

Credits / Contributors
======================

Rachot Moragraan
Daniel Lyons

A lot of testing designs are from dm-devise.

17 changes: 17 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'rake'
require 'rake/testtask'

desc 'Run Devise tests using Sequel. Specify path to devise with DEVISE_PATH'
Rake::TestTask.new(:test) do |test|
ENV['DEVISE_ORM'] ||= 'sequel'
ENV['DEVISE_PATH'] ||= File.expand_path('../devise')
unless File.exist?(ENV['DEVISE_PATH'])
puts "Specify the path to devise (e.g. rake DEVISE_PATH=/path/to/devise). Not found at #{ENV['DEVISE_PATH']}"
exit
end
test.libs << 'lib' << 'test'
test.libs << "#{ENV['DEVISE_PATH']}/lib"
test.libs << "#{ENV['DEVISE_PATH']}/test"
test.test_files = FileList["#{ENV['DEVISE_PATH']}/test/**/*_test.rb"] + FileList['test/**/*_test.rb']
test.verbose = true
end
File renamed without changes.
9 changes: 9 additions & 0 deletions test/orm/sequel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Sequel.extension :migration
Sequel::Migrator.apply(Sequel::Model.db, "#{DEVISE_PATH}/test/rails_app/db/migrate")
puts 'db migrated'

class ActiveSupport::TestCase
setup do
puts 'im supposed to be doing something'
end
end
Binary file added test/rails_app/app/sequel/.shim.rb.swp
Binary file not shown.
6 changes: 6 additions & 0 deletions test/rails_app/app/sequel/admin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'shared_admin'

class Admin < Sequel::Model
include Shim
include SharedAdmin
end
10 changes: 10 additions & 0 deletions test/rails_app/app/sequel/shim.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Shim
extend ::ActiveSupport::Concern

included do
extend ::Devise::Models
extend ::Devise::Orm::Sequel::Hook

plugin :validation_class_methods
end
end
6 changes: 6 additions & 0 deletions test/rails_app/app/sequel/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'shared_user'

class User < Sequel::Model
include Shim
include SharedUser
end
25 changes: 25 additions & 0 deletions test/rails_app/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
APP_ROOT = File.expand_path("#{DEVISE_PATH}/test/rails_app")
require "#{APP_ROOT}/config/boot"

require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"

require 'sequel'
require "sequel-rails/railtie"
require "devise"

module RailsApp
class Application < Rails::Application
# Add additional load paths for your own custom dirs
config.root = APP_ROOT
config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers views).include?($1) }
config.autoload_paths += [ File.expand_path("#{File.dirname(__FILE__)}/../app/sequel") ]

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters << :password

config.action_mailer.default_url_options = { :host => "localhost:3000" }
end
end
5 changes: 5 additions & 0 deletions test/rails_app/config/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
RailsApp::Application.initialize!
1 change: 1 addition & 0 deletions test/rails_app/config/initializers/blah.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts 'i am loaded'
23 changes: 23 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ENV["RAILS_ENV"] = "test"
DEVISE_ORM = :sequel
DEVISE_PATH = ENV['DEVISE_PATH']

puts "\n==> Devise.orm = :sequel"

require "rails_app/config/environment"
require "rails/test_help"
require "orm/sequel"

I18n.load_path << "#{DEVISE_PATH}/test/support/locale/en.yml"
require 'mocha'

Webrat.configure do |config|
config.mode = :rails
config.open_error_files = false
end

Devise::Oauth.test_mode!

# Add support to load paths so we can overwrite broken webrat setup
$:.unshift "#{DEVISE_PATH}/test/support"
Dir["#{DEVISE_PATH}/test/support/**/*.rb"].each { |f| require f }

0 comments on commit f8f8bd9

Please sign in to comment.