This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started tests, make more plugin-able
- Loading branch information
mooman
committed
Oct 2, 2010
1 parent
0d07380
commit f8f8bd9
Showing
14 changed files
with
145 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
puts 'i am loaded' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |