devise_custom_authenticatable 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5dc5774c65c328dcfa617054bf761c78e0d5d9c0
4
- data.tar.gz: db9eae55f8650c0a47af5e5f33b567d32c66ff57
3
+ metadata.gz: 1e126cdae305f283e0598a29cf6c846b8c3eb06d
4
+ data.tar.gz: 9446a9ab199cece55d70a707b2512df695cd8a23
5
5
  SHA512:
6
- metadata.gz: b33d874f8bc81ac725729af24354da1f687a3be9334407c41d1a71fa7397edcc162dd3bc4d9a46e63e4885ad8cd2883f1f5426b18529a1e39772fc7eae155543
7
- data.tar.gz: 0593a3a5f6848671f483ba07d55162e4a4d7ebdd0148d77b048938cd3e22b9821058b0e7f76aeab6d70ce3175fa112e7d499ac9fb97ae4ab3bbd97ed5aa19449
6
+ metadata.gz: 3db096d6c13521718d224149c2a6fd98cca58698d3773d7109817dc3388febbf1be9e50dc8c129817cb0c30e438585ca3b2f2c90dd5eb71f3aae904e92d343ae
7
+ data.tar.gz: f086ae0c2460d26275903f83f36d5674e6c0b3008bed69d7574e84bbc4d5a86611a69a5cbb2980ea823787b5555b381ef045d69eb0ff61219801ee89e08311f6
@@ -22,3 +22,7 @@
22
22
  ## v0.3.0
23
23
 
24
24
  * works with devise 4.2
25
+
26
+ ## v0.3.1
27
+
28
+ * Fix: conflict of password writer when used together with :database_authenticatable module
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.add_development_dependency "pry"
24
25
 
25
26
 
26
27
  if defined?(RUBY_VERSION) && RUBY_VERSION >= "2.1" || defined?(JRUBY_VERSION) && JRUBY_VERSION >= "9000"
@@ -31,6 +32,7 @@ Gem::Specification.new do |spec|
31
32
  spec.add_development_dependency "activemodel", "< 5"
32
33
  spec.add_development_dependency "activesupport", "< 5"
33
34
  spec.add_development_dependency "rack", "~> 1.6.4"
35
+ spec.add_development_dependency "nokogiri", "~> 1.6.8.1"
34
36
 
35
37
  spec.add_dependency "devise", ">= 2", "< 4"
36
38
  end
@@ -5,7 +5,12 @@ module Devise::Models
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- attr_accessor :password
8
+ attr_reader :password
9
+ end
10
+
11
+ def password=(password)
12
+ @password = password
13
+ super if defined?(super)
9
14
  end
10
15
 
11
16
  def authenticated_by_any_custom_strategy?(password, *strategies)
@@ -21,9 +26,6 @@ module Devise::Models
21
26
  # A callback initiated after successfully authenticating. This can be
22
27
  # used to insert your own logic that is only run after the user successfully
23
28
  # authenticates.
24
- def after_custom_authentication
25
-
26
- end
27
-
29
+ def after_custom_authentication; end
28
30
  end
29
31
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseCustomAuthenticatable
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -1,38 +1,45 @@
1
1
  RSpec.describe Devise::Models::CustomAuthenticatable do
2
- before(:each) do
3
- @it = CustomAuthenticatableTestClass.new
2
+ subject(:resource) { CustomAuthenticatableTestClass.new }
3
+
4
+ it "defines password attribute accessors" do
5
+ resource.password = 'password'
6
+ expect(resource.password).to eq 'password'
4
7
  end
5
8
 
6
- it "password attribute accessors should be defined" do
7
- @it.password = 'password'
8
- expect(@it.password).to eq 'password'
9
+ context "when password setter already defined for resource model" do
10
+ subject(:resource) { CustomAuthenticatableTestClassWithPasswordWriter.new }
11
+
12
+ it "preserves original setter" do
13
+ resource.password = 'password'
14
+ expect(resource.password).to eq 'password'
15
+ expect(resource.encrypted_password).to eq 'password_encrypted'
16
+ end
9
17
  end
10
18
 
11
19
  describe "#authenticated_by_any_custom_strategy? helper" do
12
20
  before(:each) do
13
- allow(@it).to receive(:authenticated_by_test1_strategy?).and_return(true)
14
- allow(@it).to receive(:authenticated_by_test2_strategy?).and_return(true)
21
+ allow(resource).to receive(:authenticated_by_test1_strategy?).and_return(true)
22
+ allow(resource).to receive(:authenticated_by_test2_strategy?).and_return(true)
15
23
  end
16
24
 
17
25
  context "should call all given strategy methods and" do
18
- it "return false if all of them return false" do
19
- expect(@it).to receive(:authenticated_by_test1_strategy?).with('password').and_return(false)
20
- expect(@it).to receive(:authenticated_by_test2_strategy?).and_return(false)
26
+ it "returns false if all of them return false" do
27
+ expect(resource).to receive(:authenticated_by_test1_strategy?).with('password').and_return(false)
28
+ expect(resource).to receive(:authenticated_by_test2_strategy?).and_return(false)
21
29
 
22
- expect(@it.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_falsey
30
+ expect(resource.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_falsey
23
31
  end
24
32
 
25
- it "return true if any of them return true" do
26
- expect(@it).to receive(:authenticated_by_test1_strategy?).with('password').and_return(false)
27
- expect(@it).to receive(:authenticated_by_test2_strategy?).and_return(true)
33
+ it "returns true if any of them return true" do
34
+ expect(resource).to receive(:authenticated_by_test1_strategy?).with('password').and_return(false)
35
+ expect(resource).to receive(:authenticated_by_test2_strategy?).and_return(true)
28
36
 
29
- expect(@it.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_truthy
37
+ expect(resource.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_truthy
30
38
  end
31
39
 
32
- it "return true if all of them return true" do
33
- expect(@it.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_truthy
40
+ it "returns true if all of them return true" do
41
+ expect(resource.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_truthy
34
42
  end
35
43
  end
36
44
  end
37
-
38
45
  end
@@ -6,6 +6,24 @@ class CustomAuthenticatableTestClass
6
6
  def authenticated_by_test2_strategy?(*args); end
7
7
  end
8
8
 
9
+ module TestPasswordModule
10
+ extend ActiveSupport::Concern
11
+
12
+ included do
13
+ attr_accessor :encrypted_password
14
+ end
15
+
16
+ def password=(new_password)
17
+ @password = new_password
18
+ self.encrypted_password = "#{new_password}_encrypted" if @password.present?
19
+ end
20
+ end
21
+
22
+ class CustomAuthenticatableTestClassWithPasswordWriter
23
+ include TestPasswordModule
24
+ include Devise::Models::CustomAuthenticatable
25
+ end
26
+
9
27
  def env_with_params(path = "/", params = {}, env = {})
10
28
  method = params.delete(:method) || "GET"
11
29
  env = { 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => "#{method}" }.merge(env)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_custom_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artūrs Mekšs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-06 00:00:00.000000000 Z
11
+ date: 2016-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: activemodel
57
71
  requirement: !ruby/object:Gem::Requirement