dm-devise 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+ require 'test_helper'
2
+
3
+ # See data_mapper_test.rb in this folder for what this file is doing.
4
+
5
+ class ValidatableTest < ActiveSupport::TestCase
6
+ undef test_should_require_a_password_with_minimum_of_6_characters
7
+
8
+ # DataMapper uses a :value_between error message when given a minimum and
9
+ # maximum; ActiveModel shows either the :too_long or :too_short message.
10
+ test 'should require a password with minimum of 6 characters' do
11
+ user = new_user(:password => '12345', :password_confirmation => '12345')
12
+ assert user.invalid?
13
+ # assert_equal 'is too short (minimum is 6 characters)', user.errors[:password].join
14
+ assert_equal 'must be between 6 and 20 characters long', user.errors[:password].join
15
+ end
16
+
17
+ undef test_should_require_a_password_with_maximum_of_20_characters_long
18
+
19
+ # Same issue as previous test
20
+ test 'should require a password with maximum of 20 characters long' do
21
+ user = new_user(:password => 'x'*21, :password_confirmation => 'x'*21)
22
+ assert user.invalid?
23
+ # assert_equal 'is too long (maximum is 20 characters)', user.errors[:password].join
24
+ assert_equal 'must be between 6 and 20 characters long', user.errors[:password].join
25
+ end
26
+
27
+ end
28
+
29
+ class AuthenticationWithScopesTest < ActionController::IntegrationTest
30
+
31
+ undef test_registration_in_xml_format
32
+
33
+ # DM's validates_confirmation_of requires the confirmation field to be present,
34
+ # while ActiveModel by default skips the confirmation test if the confirmation
35
+ # value is nil. This test takes advantage of AM's behavior, so just add the
36
+ # :password_confirmation value.
37
+ test 'registration in xml format' do
38
+ assert_nothing_raised do
39
+ # post user_registration_path(:format => 'xml', :user => {:email => "test@example.com", :password => "invalid"} )
40
+ post user_registration_path(:format => 'xml', :user => {:email => "test@example.com", :password => "invalid", :password_confirmation => "invalid"} )
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,12 @@
1
+ class Admin
2
+ include DataMapper::Resource
3
+
4
+ property :id, Serial
5
+ property :username, String
6
+
7
+ devise :database_authenticatable, :registerable, :timeoutable, :recoverable
8
+
9
+ def self.create!(*args)
10
+ create(*args)
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ module Shim
2
+ end
@@ -0,0 +1,20 @@
1
+ class User
2
+ include DataMapper::Resource
3
+
4
+ property :id, Serial
5
+ property :username, String
6
+
7
+ devise :database_authenticatable, :confirmable, :lockable, :recoverable,
8
+ :registerable, :rememberable, :timeoutable, :token_authenticatable,
9
+ :trackable, :validatable
10
+
11
+ timestamps :at
12
+
13
+ def self.create!(*args)
14
+ create(*args)
15
+ end
16
+
17
+ def self.destroy_all
18
+ all.destroy
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ class Admin
2
+ include DataMapper::Resource
3
+
4
+ property :id, Serial
5
+ property :username, String
6
+
7
+ devise :database_authenticatable, :registerable, :timeoutable, :recoverable
8
+
9
+ def self.create!(*args)
10
+ create(*args)
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ module Shim
2
+ end
@@ -0,0 +1,20 @@
1
+ class User
2
+ include DataMapper::Resource
3
+
4
+ property :id, Serial
5
+ property :username, String
6
+
7
+ devise :database_authenticatable, :confirmable, :lockable, :recoverable,
8
+ :registerable, :rememberable, :timeoutable, :token_authenticatable,
9
+ :trackable, :validatable
10
+
11
+ timestamps :at
12
+
13
+ def self.create!(*args)
14
+ create(*args)
15
+ end
16
+
17
+ def self.destroy_all
18
+ all.destroy
19
+ end
20
+ end
@@ -0,0 +1,37 @@
1
+ APP_ROOT = File.expand_path("#{DEVISE_PATH}/test/rails_app")
2
+ require "#{APP_ROOT}/config/boot"
3
+
4
+ require "action_controller/railtie"
5
+ require "action_mailer/railtie"
6
+ require "active_resource/railtie"
7
+ require "rails/test_unit/railtie"
8
+
9
+ Bundler.require :default, DEVISE_ORM
10
+
11
+ begin
12
+ require "#{DEVISE_ORM}/railtie"
13
+ rescue LoadError
14
+ end
15
+
16
+ require "devise"
17
+
18
+ module RailsApp
19
+ class Application < Rails::Application
20
+ # Add additional load paths for your own custom dirs
21
+ config.root = APP_ROOT
22
+ config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers views).include?($1) }
23
+ config.autoload_paths += [ File.expand_path("#{File.dirname(__FILE__)}/../app/#{DEVISE_ORM}") ]
24
+
25
+ # Configure generators values. Many other options are available, be sure to check the documentation.
26
+ # config.generators do |g|
27
+ # g.orm :active_record
28
+ # g.template_engine :erb
29
+ # g.test_framework :test_unit, :fixture => true
30
+ # end
31
+
32
+ # Configure sensitive parameters which will be filtered from the log file.
33
+ config.filter_parameters << :password
34
+
35
+ config.action_mailer.default_url_options = { :host => "localhost:3000" }
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!
@@ -0,0 +1,21 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ DEVISE_ORM = (ENV["DEVISE_ORM"] || :data_mapper).to_sym
3
+ DEVISE_PATH = ENV['DEVISE_PATH']
4
+
5
+ puts "\n==> Devise.orm = #{DEVISE_ORM.inspect}"
6
+
7
+ require "rails_app/config/environment"
8
+ require "rails/test_help"
9
+ require "orm/#{DEVISE_ORM}"
10
+
11
+ I18n.load_path << "#{DEVISE_PATH}/test/support/locale/en.yml"
12
+ require 'mocha'
13
+
14
+ Webrat.configure do |config|
15
+ config.mode = :rails
16
+ config.open_error_files = false
17
+ end
18
+
19
+ # Add support to load paths so we can overwrite broken webrat setup
20
+ $:.unshift "#{DEVISE_PATH}/test/support"
21
+ Dir["#{DEVISE_PATH}/test/support/**/*.rb"].each { |f| require f }
metadata ADDED
@@ -0,0 +1,235 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dm-devise
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Jared Morgan
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-06 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: dm-core
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 23
30
+ segments:
31
+ - 1
32
+ - 0
33
+ - 0
34
+ version: 1.0.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: dm-migrations
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 23
46
+ segments:
47
+ - 1
48
+ - 0
49
+ - 0
50
+ version: 1.0.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: dm-validations
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 23
62
+ segments:
63
+ - 1
64
+ - 0
65
+ - 0
66
+ version: 1.0.0
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: dm-serializer
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 23
78
+ segments:
79
+ - 1
80
+ - 0
81
+ - 0
82
+ version: 1.0.0
83
+ type: :runtime
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: dm-timestamps
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ hash: 23
94
+ segments:
95
+ - 1
96
+ - 0
97
+ - 0
98
+ version: 1.0.0
99
+ type: :runtime
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: dm-rails
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ hash: 23
110
+ segments:
111
+ - 1
112
+ - 0
113
+ - 0
114
+ version: 1.0.0
115
+ type: :runtime
116
+ version_requirements: *id006
117
+ - !ruby/object:Gem::Dependency
118
+ name: warden
119
+ prerelease: false
120
+ requirement: &id007 !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ hash: 57
126
+ segments:
127
+ - 0
128
+ - 10
129
+ - 7
130
+ version: 0.10.7
131
+ type: :runtime
132
+ version_requirements: *id007
133
+ - !ruby/object:Gem::Dependency
134
+ name: bcrypt-ruby
135
+ prerelease: false
136
+ requirement: &id008 !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ hash: 15
142
+ segments:
143
+ - 2
144
+ - 1
145
+ - 2
146
+ version: 2.1.2
147
+ type: :runtime
148
+ version_requirements: *id008
149
+ description: dm-devise adds DataMapper support to devise (http://github.com/plataformatec/devise) for authentication support for Rails
150
+ email: jmorgan@morgancreative.net
151
+ executables: []
152
+
153
+ extensions: []
154
+
155
+ extra_rdoc_files:
156
+ - LICENSE
157
+ - README.rdoc
158
+ files:
159
+ - .document
160
+ - .gitignore
161
+ - Gemfile
162
+ - Gemfile.lock
163
+ - LICENSE
164
+ - README.rdoc
165
+ - Rakefile
166
+ - dm-devise.gemspec
167
+ - lib/devise/orm/data_mapper.rb
168
+ - lib/devise/orm/data_mapper/compatibility.rb
169
+ - lib/devise/orm/data_mapper/date_time.rb
170
+ - lib/devise/orm/data_mapper/dm-validations.rb
171
+ - lib/devise/orm/data_mapper/schema.rb
172
+ - lib/devise/orm/data_mapper_active_model.rb
173
+ - lib/dm-devise/version.rb
174
+ - lib/generators/data_mapper/devise_generator.rb
175
+ - test/orm/data_mapper.rb
176
+ - test/orm/data_mapper_active_model.rb
177
+ - test/overrides/data_mapper_test.rb
178
+ - test/overrides/dm_validations_test.rb
179
+ - test/rails_app/app/data_mapper/admin.rb
180
+ - test/rails_app/app/data_mapper/shim.rb
181
+ - test/rails_app/app/data_mapper/user.rb
182
+ - test/rails_app/app/data_mapper_active_model/admin.rb
183
+ - test/rails_app/app/data_mapper_active_model/shim.rb
184
+ - test/rails_app/app/data_mapper_active_model/user.rb
185
+ - test/rails_app/config/application.rb
186
+ - test/rails_app/config/environment.rb
187
+ - test/test_helper.rb
188
+ has_rdoc: true
189
+ homepage: http://github.com/jm81/dm-devise
190
+ licenses: []
191
+
192
+ post_install_message:
193
+ rdoc_options:
194
+ - --charset=UTF-8
195
+ require_paths:
196
+ - lib
197
+ required_ruby_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ hash: 3
203
+ segments:
204
+ - 0
205
+ version: "0"
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
+ none: false
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ hash: 3
212
+ segments:
213
+ - 0
214
+ version: "0"
215
+ requirements: []
216
+
217
+ rubyforge_project:
218
+ rubygems_version: 1.3.7
219
+ signing_key:
220
+ specification_version: 3
221
+ summary: Support for using DataMapper ORM with devise
222
+ test_files:
223
+ - test/test_helper.rb
224
+ - test/rails_app/config/environment.rb
225
+ - test/rails_app/config/application.rb
226
+ - test/rails_app/app/data_mapper/admin.rb
227
+ - test/rails_app/app/data_mapper/shim.rb
228
+ - test/rails_app/app/data_mapper/user.rb
229
+ - test/rails_app/app/data_mapper_active_model/admin.rb
230
+ - test/rails_app/app/data_mapper_active_model/shim.rb
231
+ - test/rails_app/app/data_mapper_active_model/user.rb
232
+ - test/overrides/data_mapper_test.rb
233
+ - test/overrides/dm_validations_test.rb
234
+ - test/orm/data_mapper.rb
235
+ - test/orm/data_mapper_active_model.rb