dm-devise 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,21 @@
1
+ == 2.1.0
2
+
3
+ * deprecations
4
+ * Remove support for apply_schema
5
+
6
+ == 2.0.1
7
+
8
+ * enhancements
9
+ * DM 1.3.0.beta compatibility (snusnu)
10
+
11
+ == 2.0.0
12
+
13
+ * enhancements
14
+ * Improve Compatibility hook methods
15
+ * Add Compatibility#email_was
16
+ * Compatibility#save(:validate => false) - Use _persist instead of save!
17
+ * Include property statements in generated models
18
+
1
19
  == 1.5.0
2
20
 
3
21
  * enhancements
data/Gemfile CHANGED
@@ -15,7 +15,7 @@ end
15
15
  DM_VERSION = '~> 1.2.0'
16
16
 
17
17
  group :development do
18
- gem 'rails', '~> 3.1.0'
18
+ gem 'rails', '~> 3.2.0'
19
19
  gem 'dm-sqlite-adapter', DM_VERSION
20
20
 
21
21
  gem 'dm-core', DM_VERSION
@@ -1,17 +1,21 @@
1
+ *IMPORTANT:* The apply_schema option is removed in dm-devise 2.1. If you are upgrading, please read: https://github.com/jm81/dm-devise/wiki/How-to:-upgrade-to-devise-2.0-schema-style
2
+
3
+ *IMPORTANT:* Devise 2.1 is out. If you are upgrading, please read: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.1
4
+
5
+ *IMPORTANT:* Devise 2.0 is out. If you are upgrading, please read: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0
6
+
1
7
  = dm-devise
2
8
 
3
9
  dm-devise lets you use devise (http://github.com/plataformatec/devise) with
4
10
  DataMapper.
5
11
 
6
- dm-devise is intended for use with Rails 3 and devise >= 1.1. It may work with
7
- earlier versions, but it's not been tested (if you try, please let Jared Morgan
8
- (http://github.com/jm81) know how it goes.)
12
+ dm-devise is intended for use with Rails >= 3.2 and devise >= 2.1.
9
13
 
10
14
  This README only covers dm-devise specifics. Make sure to read the devise
11
15
  README http://github.com/plataformatec/devise/blob/master/README.rdoc
12
16
 
13
- Last tested against devise master: 2012-02-13, commit aa36719bd95971d49e27e2091ad08af067355cce
14
- Last tested against devise release 2.0.1, 1.5.3
17
+ Last tested against devise master: 2012-05-17, commit f6259531c36795be2766ffefd50de1f8803fc5cd
18
+ Last tested against devise release 2.1.0
15
19
 
16
20
  == Installation
17
21
 
@@ -23,7 +27,7 @@ Add dm-devise and dm gems to your Gemfile. The following gems are required:
23
27
  gem 'dm-timestamps', '~> 1.2.0'
24
28
  gem 'dm-rails', '~> 1.2.0'
25
29
  gem 'dm-validations', '~> 1.2.0' # Do not include if using data_mapper_active_model
26
- gem 'dm-devise', '~> 2.0.1'
30
+ gem 'dm-devise', '~> 2.1.0'
27
31
 
28
32
  If you're using Active Model validations, do not include dm-validations in your
29
33
  Gemfile.
@@ -75,11 +79,6 @@ active_model::
75
79
  The advantage to this is Active Model's I18n support for error messages, and
76
80
  it uses the same validations lib as devise does by default.
77
81
 
78
- === apply_schema
79
-
80
- Tells if dm-devise should apply the devise database schema. You may want to
81
- set this to false if working with a legacy schema.
82
-
83
82
  === data_mapper_validation_messages
84
83
 
85
84
  Messages to use as the default DataMapper validation error messages. The
@@ -1,8 +1,6 @@
1
1
  require 'dm-devise'
2
2
  require 'devise/orm/data_mapper/compatibility'
3
- require 'devise/orm/data_mapper/schema'
4
3
  require 'devise/orm/data_mapper/date_time'
5
- require 'devise/orm/data_mapper/serializable'
6
4
  require 'devise/orm/data_mapper/validations/dm-validations'
7
5
  require 'devise/orm/data_mapper/validations/active_model'
8
6
  require 'orm_adapter/adapters/data_mapper'
@@ -12,8 +10,6 @@ module Devise
12
10
  module DataMapper
13
11
  module Hook
14
12
  def devise_modules_hook!
15
- extend Schema
16
-
17
13
  if Devise.data_mapper_validation_lib == 'active_model'
18
14
  include ActiveModel::Validations
19
15
  include ActiveModelCompatibility
@@ -23,8 +19,6 @@ module Devise
23
19
  include Compatibility
24
20
 
25
21
  yield
26
- return unless Devise.apply_schema
27
- devise_modules.each { |m| send(m) if respond_to?(m, true) }
28
22
  end
29
23
  end
30
24
  end
@@ -64,6 +64,23 @@ module Devise
64
64
  def email_was
65
65
  original_attributes[:email]
66
66
  end
67
+
68
+ # Redefine properties_to_serialize in models for more secure defaults.
69
+ # By default, it removes from the serializable model all attributes that
70
+ # are *not* accessible. You can remove this default by using :force_exclude
71
+ # and passing a new list of attributes you want to exempt. All attributes
72
+ # given to :exclude will simply add names to exempt to Devise internal list.
73
+ def properties_to_serialize(options=nil)
74
+ options ||= {}
75
+ if options.key?(:force_except) || options.key?(:force_exclude)
76
+ options[:exclude] = options.delete(:force_except) || options.delete(:force_exclude)
77
+ super(options)
78
+ else
79
+ blacklist = Devise::Models::Authenticatable.const_defined?(:BLACKLIST_FOR_SERIALIZATION) ? Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION : []
80
+ except = Array(options[:exclude]) + Array(options[:except]) + blacklist
81
+ super(options.merge(:exclude => except))
82
+ end
83
+ end
67
84
  end
68
85
  end
69
86
  end
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Devise
3
- VERSION = '2.0.1'.freeze
3
+ VERSION = '2.1.0'.freeze
4
4
  end
5
5
  end
@@ -53,6 +53,9 @@ module DataMapper
53
53
 
54
54
  ## Token authenticatable
55
55
  # property :authentication_token, String, :length => 255
56
+
57
+ ## Invitable
58
+ # property :invitation_token, String, :length => 255
56
59
  RUBY
57
60
  end
58
61
  end
@@ -19,13 +19,7 @@ module DataMapper
19
19
  VALIDATIONS
20
20
  inject_into_file devise_init_file, validations, :before => ' # ==> ORM configuration'
21
21
 
22
- data_mapper_options = <<APPLY_SCHEMA
23
-
24
- # ==> Apply Schema
25
- # Tells if dm-devise should apply the devise database schema via property
26
- # declarations. You may want to set this to false if working with a legacy
27
- # schema.
28
- # config.apply_schema = true
22
+ data_mapper_options = <<OPTIONS
29
23
 
30
24
  # ==> dm-validations Default Error Messages
31
25
  # Messages to use as the default DataMapper validation error messages. The
@@ -35,7 +29,7 @@ VALIDATIONS
35
29
  # :not_locked, and :expired). If set to false, the messages are left as
36
30
  # defined by the dm-validations gem. See dm-devise.rb for default.
37
31
  # config.data_mapper_validation_messages = {}
38
- APPLY_SCHEMA
32
+ OPTIONS
39
33
  inject_into_file devise_init_file, data_mapper_options, :after => "orm/data_mapper'\n"
40
34
  end
41
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-14 00:00:00.000000000 Z
12
+ date: 2012-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dm-core
16
- requirement: &73066270 !ruby/object:Gem::Requirement
16
+ requirement: &84857470 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '2.0'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *73066270
27
+ version_requirements: *84857470
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: dm-migrations
30
- requirement: &73065590 !ruby/object:Gem::Requirement
30
+ requirement: &84857070 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -38,10 +38,10 @@ dependencies:
38
38
  version: '2.0'
39
39
  type: :runtime
40
40
  prerelease: false
41
- version_requirements: *73065590
41
+ version_requirements: *84857070
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: dm-serializer
44
- requirement: &73065090 !ruby/object:Gem::Requirement
44
+ requirement: &84856700 !ruby/object:Gem::Requirement
45
45
  none: false
46
46
  requirements:
47
47
  - - ! '>='
@@ -52,10 +52,10 @@ dependencies:
52
52
  version: '2.0'
53
53
  type: :runtime
54
54
  prerelease: false
55
- version_requirements: *73065090
55
+ version_requirements: *84856700
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: dm-timestamps
58
- requirement: &73064350 !ruby/object:Gem::Requirement
58
+ requirement: &84856330 !ruby/object:Gem::Requirement
59
59
  none: false
60
60
  requirements:
61
61
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '2.0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *73064350
69
+ version_requirements: *84856330
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: dm-rails
72
- requirement: &73063600 !ruby/object:Gem::Requirement
72
+ requirement: &84855950 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -80,10 +80,10 @@ dependencies:
80
80
  version: '2.0'
81
81
  type: :runtime
82
82
  prerelease: false
83
- version_requirements: *73063600
83
+ version_requirements: *84855950
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: devise
86
- requirement: &73062940 !ruby/object:Gem::Requirement
86
+ requirement: &84855550 !ruby/object:Gem::Requirement
87
87
  none: false
88
88
  requirements:
89
89
  - - ! '>='
@@ -91,7 +91,7 @@ dependencies:
91
91
  version: '1.3'
92
92
  type: :runtime
93
93
  prerelease: false
94
- version_requirements: *73062940
94
+ version_requirements: *84855550
95
95
  description: dm-devise adds DataMapper support to devise (http://github.com/plataformatec/devise)
96
96
  for authentication support for Rails
97
97
  email: jmorgan@morgancreative.net
@@ -110,8 +110,6 @@ files:
110
110
  - lib/devise/orm/data_mapper.rb
111
111
  - lib/devise/orm/data_mapper/compatibility.rb
112
112
  - lib/devise/orm/data_mapper/date_time.rb
113
- - lib/devise/orm/data_mapper/schema.rb
114
- - lib/devise/orm/data_mapper/serializable.rb
115
113
  - lib/devise/orm/data_mapper/validations/active_model.rb
116
114
  - lib/devise/orm/data_mapper/validations/dm-validations.rb
117
115
  - lib/devise/orm/data_mapper_active_model.rb
@@ -120,7 +118,6 @@ files:
120
118
  - lib/generators/data_mapper/devise_generator.rb
121
119
  - lib/generators/data_mapper/devise_install_generator.rb
122
120
  - test/data_mapper/compatibility_test.rb
123
- - test/data_mapper/schema_test.rb
124
121
  - test/generators/data_mapper_generator_test.rb
125
122
  - test/orm/data_mapper.rb
126
123
  - test/overrides/data_mapper_test.rb
@@ -1,41 +0,0 @@
1
- require 'dm-devise'
2
- require 'devise/schema'
3
-
4
- module Devise
5
- module Orm
6
- module DataMapper
7
- module Schema
8
- include Devise::Schema
9
-
10
- SCHEMA_OPTIONS = {
11
- :null => :required,
12
- :limit => :length
13
- }
14
-
15
- # Tell how to apply schema methods. This automatically maps :limit to
16
- # :length and :null to :required.
17
- def apply_devise_schema(name, type, options={})
18
- return false if properties[name]
19
- SCHEMA_OPTIONS.each do |old_key, new_key|
20
- next unless options.key?(old_key)
21
- if :null == old_key
22
- # :required is opposite of :null
23
- options[new_key] = !options.delete(old_key)
24
- else
25
- options[new_key] = options.delete(old_key)
26
- end
27
- end
28
-
29
- if String == type && !options[:length]
30
- options[:length] = 255
31
- end
32
-
33
- options[:required] ||= false
34
-
35
- options.delete(:default) if options[:default].nil?
36
- property name, type, options
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,36 +0,0 @@
1
- module Devise
2
- module Models
3
- # This module redefines properties_to_serialize in models for more
4
- # secure defaults. By default, it removes from the serializable model
5
- # all attributes whose writer or reader is *not* public. You can remove this default
6
- # by using :force_except and passing a new list of attributes you want
7
- # to exempt. All attributes given to :exclude will simply add names to
8
- # exempt to Devise internal list.
9
- module Serializable
10
- extend ActiveSupport::Concern
11
-
12
- def properties_to_serialize(options=nil)
13
- options ||= {}
14
- if options.key?(:force_except) || options.key?(:force_exclude)
15
- options[:exclude] = options.delete(:force_except) || options.delete(:force_exclude)
16
- super(options)
17
- else
18
- except = Array(options[:exclude]) + Array(options[:except])
19
- super(options.merge(:exclude => except + self.class.blacklist_keys))
20
- end
21
- end
22
-
23
- # Get back to DataMapper's #to_xml.
24
- def to_xml(*args)
25
- super
26
- end
27
-
28
- module ClassMethods
29
- # Returns keys that should be removed when serializing the record.
30
- def blacklist_keys
31
- @blacklist_keys ||= properties.select { |property| property.reader_visibility != :public || property.writer_visibility != :public }.map(&:name)
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,16 +0,0 @@
1
- require 'test_helper'
2
-
3
- class DataMapperSchemaTest < ActiveSupport::TestCase
4
- test 'required explicitly set to false' do
5
- begin
6
- DataMapper::Property.required(true)
7
- model = Class.new(User)
8
- model.apply_devise_schema :required_string, String, :required => true
9
- model.apply_devise_schema :not_required_string, String
10
- assert model.properties['required_string'].required?
11
- assert !model.properties['not_required_string'].required?
12
- ensure
13
- DataMapper::Property.required(false)
14
- end
15
- end
16
- end