devise_custom_authenticatable 0.2.0 → 0.3.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5dc5774c65c328dcfa617054bf761c78e0d5d9c0
4
+ data.tar.gz: db9eae55f8650c0a47af5e5f33b567d32c66ff57
5
+ SHA512:
6
+ metadata.gz: b33d874f8bc81ac725729af24354da1f687a3be9334407c41d1a71fa7397edcc162dd3bc4d9a46e63e4885ad8cd2883f1f5426b18529a1e39772fc7eae155543
7
+ data.tar.gz: 0593a3a5f6848671f483ba07d55162e4a4d7ebdd0148d77b048938cd3e22b9821058b0e7f76aeab6d70ce3175fa112e7d499ac9fb97ae4ab3bbd97ed5aa19449
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ examples.txt
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --require spec_helper
@@ -2,6 +2,9 @@ language: ruby
2
2
  script: "bundle exec rspec spec"
3
3
  rvm:
4
4
  - 1.9.3
5
- - 2.0.0
6
- - 2.1.0
7
- - jruby
5
+ - 2.3.1
6
+ - jruby-1.7.26
7
+ - jruby-9.1.5.0
8
+
9
+ sudo: false
10
+ cache: bundler
@@ -18,3 +18,7 @@
18
18
 
19
19
  * Feature: fail authentication if `#valid_for_custom_authentication?` returns false (use `#skip_custom_strategies` in order to pass to another stategy)
20
20
  * Feature: `#after_custom_authentication` method added
21
+
22
+ ## v0.3.0
23
+
24
+ * works with devise 4.2
@@ -18,10 +18,20 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", "~> 2.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
24
 
25
- spec.add_dependency "devise", ">= 2", "< 4"
26
25
 
26
+ if defined?(RUBY_VERSION) && RUBY_VERSION >= "2.1" || defined?(JRUBY_VERSION) && JRUBY_VERSION >= "9000"
27
+ spec.add_development_dependency "activemodel", ">= 3.1"
28
+
29
+ spec.add_dependency "devise", ">= 2", "< 5"
30
+ else
31
+ spec.add_development_dependency "activemodel", "< 5"
32
+ spec.add_development_dependency "activesupport", "< 5"
33
+ spec.add_development_dependency "rack", "~> 1.6.4"
34
+
35
+ spec.add_dependency "devise", ">= 2", "< 4"
36
+ end
27
37
  end
@@ -1,7 +1,7 @@
1
1
  require 'devise/strategies/authenticatable'
2
2
 
3
3
  module Devise::Strategies
4
- # Strategy for delegateing authentication logic to custom model's method
4
+ # Strategy for delegating authentication logic to custom model's method
5
5
  class CustomAuthenticatable < Authenticatable
6
6
 
7
7
  def authenticate!
@@ -1,3 +1,3 @@
1
1
  module DeviseCustomAuthenticatable
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Devise::Models::CustomAuthenticatable do
1
+ RSpec.describe Devise::Models::CustomAuthenticatable do
4
2
  before(:each) do
5
3
  @it = CustomAuthenticatableTestClass.new
6
4
  end
@@ -12,8 +10,8 @@ describe Devise::Models::CustomAuthenticatable do
12
10
 
13
11
  describe "#authenticated_by_any_custom_strategy? helper" do
14
12
  before(:each) do
15
- @it.stub(authenticated_by_test1_strategy?: true)
16
- @it.stub(authenticated_by_test2_strategy?: true)
13
+ allow(@it).to receive(:authenticated_by_test1_strategy?).and_return(true)
14
+ allow(@it).to receive(:authenticated_by_test2_strategy?).and_return(true)
17
15
  end
18
16
 
19
17
  context "should call all given strategy methods and" do
@@ -21,18 +19,18 @@ describe Devise::Models::CustomAuthenticatable do
21
19
  expect(@it).to receive(:authenticated_by_test1_strategy?).with('password').and_return(false)
22
20
  expect(@it).to receive(:authenticated_by_test2_strategy?).and_return(false)
23
21
 
24
- expect(@it.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_false
22
+ expect(@it.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_falsey
25
23
  end
26
24
 
27
25
  it "return true if any of them return true" do
28
26
  expect(@it).to receive(:authenticated_by_test1_strategy?).with('password').and_return(false)
29
27
  expect(@it).to receive(:authenticated_by_test2_strategy?).and_return(true)
30
28
 
31
- expect(@it.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_true
29
+ expect(@it.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_truthy
32
30
  end
33
31
 
34
32
  it "return true if all of them return true" do
35
- expect(@it.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_true
33
+ expect(@it.authenticated_by_any_custom_strategy?('password', :test1, :test2)).to be_truthy
36
34
  end
37
35
  end
38
36
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Devise::Models::CustomAuthenticatable do
1
+ RSpec.describe Devise::Models::CustomAuthenticatable do
4
2
  before(:each) do
5
3
  @resource = CustomAuthenticatableTestClass.new
6
4
  @it = Devise::Strategies::CustomAuthenticatable.new(env_with_params, :user)
@@ -8,17 +6,19 @@ describe Devise::Models::CustomAuthenticatable do
8
6
 
9
7
  describe "#authenticate!" do
10
8
  before(:each) do
11
- password_hash = { password: 'password' }
12
- @it.stub( password_hash )
13
- @it.stub(authentication_hash: password_hash)
14
- @it.stub_chain(:mapping, :to, :find_for_authentication).and_return(@resource)
15
- @it.stub(:validate) do |resource, &block|
9
+ allow(@it).to receive(:password).and_return('password')
10
+ allow(@it).to receive(:authentication_hash).and_return(password: 'password')
11
+ allow(@it).to receive_message_chain("mapping.to.find_for_authentication").and_return(@resource)
12
+
13
+ allow(@it).to receive(:validate) do |resource, &block|
16
14
  expect(resource).to eq @resource
17
15
  block.call
18
16
  end
19
17
  end
20
18
 
21
19
  it "should pass to another strategy if #valid_for_custom_authentication? is not defined" do
20
+ @resource.instance_eval('undef :valid_for_custom_authentication?')
21
+
22
22
  expect(@resource).to receive(:after_custom_authentication).never
23
23
  expect(@it).to receive(:validate).never
24
24
  expect(@it).to receive(:pass).once.and_return('skip')
@@ -1,2 +1,102 @@
1
1
  require 'devise_custom_authenticatable'
2
2
  require 'support/helpers'
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
7
+ # this file to always be loaded, without a need to explicitly require it in any
8
+ # files.
9
+ #
10
+ # Given that it is always loaded, you are encouraged to keep this file as
11
+ # light-weight as possible. Requiring heavyweight dependencies from this file
12
+ # will add to the boot time of your test suite on EVERY test run, even for an
13
+ # individual file that may not need all of that loaded. Instead, consider making
14
+ # a separate helper file that requires the additional dependencies and performs
15
+ # the additional setup, and require it from the spec files that actually need
16
+ # it.
17
+ #
18
+ # The `.rspec` file also contains a few flags that are not defaults but that
19
+ # users commonly want.
20
+ #
21
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
+ RSpec.configure do |config|
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
47
+ # have no way to turn it off -- the option exists only for backwards
48
+ # compatibility in RSpec 3). It causes shared context metadata to be
49
+ # inherited by the metadata hash of host groups and examples, rather than
50
+ # triggering implicit auto-inclusion in groups with matching metadata.
51
+ config.shared_context_metadata_behavior = :apply_to_host_groups
52
+
53
+ # This allows you to limit a spec run to individual examples or groups
54
+ # you care about by tagging them with `:focus` metadata. When nothing
55
+ # is tagged with `:focus`, all examples get run. RSpec also provides
56
+ # aliases for `it`, `describe`, and `context` that include `:focus`
57
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
58
+ config.filter_run_when_matching :focus
59
+
60
+ # Allows RSpec to persist some state between runs in order to support
61
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
62
+ # you configure your source control system to ignore this file.
63
+ config.example_status_persistence_file_path = "spec/examples.txt"
64
+
65
+ # Limits the available syntax to the non-monkey patched syntax that is
66
+ # recommended. For more details, see:
67
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
68
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
69
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
70
+ config.disable_monkey_patching!
71
+
72
+ # This setting enables warnings. It's recommended, but in some cases may
73
+ # be too noisy due to issues in dependencies.
74
+ config.warnings = false
75
+
76
+ # Many RSpec users commonly either run the entire suite or an individual
77
+ # file, and it's useful to allow more verbose output when running an
78
+ # individual spec file.
79
+ if config.files_to_run.one?
80
+ # Use the documentation formatter for detailed output,
81
+ # unless a formatter has already been configured
82
+ # (e.g. via a command-line flag).
83
+ config.default_formatter = 'doc'
84
+ end
85
+
86
+ # Print the 10 slowest examples and example groups at the
87
+ # end of the spec run, to help surface which specs are running
88
+ # particularly slow.
89
+ config.profile_examples = 10
90
+
91
+ # Run specs in random order to surface order dependencies. If you find an
92
+ # order dependency and want to debug it, you can fix the order by providing
93
+ # the seed, which is printed after each run.
94
+ # --seed 1234
95
+ config.order = :random
96
+
97
+ # Seed global randomization in this process using the `--seed` CLI option.
98
+ # Setting this allows you to use `--seed` to deterministically reproduce
99
+ # test failures related to randomization by passing the same `--seed` value
100
+ # as the one that triggered the failure.
101
+ Kernel.srand config.seed
102
+ end
@@ -1,5 +1,9 @@
1
1
  class CustomAuthenticatableTestClass
2
2
  include Devise::Models::CustomAuthenticatable
3
+
4
+ def valid_for_custom_authentication?(*args); end
5
+ def authenticated_by_test1_strategy?(*args); end
6
+ def authenticated_by_test2_strategy?(*args); end
3
7
  end
4
8
 
5
9
  def env_with_params(path = "/", params = {}, env = {})
metadata CHANGED
@@ -1,86 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_custom_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Artūrs Mekšs
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-24 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '1.3'
19
+ version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '1.3'
26
+ version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activemodel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
52
60
  - !ruby/object:Gem::Version
53
- version: '2.0'
61
+ version: '3.1'
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ~>
66
+ - - ">="
60
67
  - !ruby/object:Gem::Version
61
- version: '2.0'
68
+ version: '3.1'
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: devise
64
71
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
72
  requirements:
67
- - - ! '>='
73
+ - - ">="
68
74
  - !ruby/object:Gem::Version
69
75
  version: '2'
70
- - - <
76
+ - - "<"
71
77
  - !ruby/object:Gem::Version
72
- version: '4'
78
+ version: '5'
73
79
  type: :runtime
74
80
  prerelease: false
75
81
  version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
82
  requirements:
78
- - - ! '>='
83
+ - - ">="
79
84
  - !ruby/object:Gem::Version
80
85
  version: '2'
81
- - - <
86
+ - - "<"
82
87
  - !ruby/object:Gem::Version
83
- version: '4'
88
+ version: '5'
84
89
  description: Simple way to customize devise authentication logic and still be inline
85
90
  with all other devise parts
86
91
  email:
@@ -89,9 +94,9 @@ executables: []
89
94
  extensions: []
90
95
  extra_rdoc_files: []
91
96
  files:
92
- - .gitignore
93
- - .rspec
94
- - .travis.yml
97
+ - ".gitignore"
98
+ - ".rspec"
99
+ - ".travis.yml"
95
100
  - CHANGELOG.md
96
101
  - Gemfile
97
102
  - LICENSE.txt
@@ -109,34 +114,27 @@ files:
109
114
  homepage: https://github.com/AMekss/devise_custom_authenticatable
110
115
  licenses:
111
116
  - MIT
117
+ metadata: {}
112
118
  post_install_message:
113
119
  rdoc_options: []
114
120
  require_paths:
115
121
  - lib
116
122
  required_ruby_version: !ruby/object:Gem::Requirement
117
- none: false
118
123
  requirements:
119
- - - ! '>='
124
+ - - ">="
120
125
  - !ruby/object:Gem::Version
121
126
  version: '0'
122
- segments:
123
- - 0
124
- hash: 1558931694658309700
125
127
  required_rubygems_version: !ruby/object:Gem::Requirement
126
- none: false
127
128
  requirements:
128
- - - ! '>='
129
+ - - ">="
129
130
  - !ruby/object:Gem::Version
130
131
  version: '0'
131
- segments:
132
- - 0
133
- hash: 1558931694658309700
134
132
  requirements: []
135
133
  rubyforge_project:
136
- rubygems_version: 1.8.25
134
+ rubygems_version: 2.5.1
137
135
  signing_key:
138
- specification_version: 3
139
- summary: ! 'Extends Devise with new module :custom_authenticatable, when enabled it
136
+ specification_version: 4
137
+ summary: 'Extends Devise with new module :custom_authenticatable, when enabled it
140
138
  will call #valid_for_custom_authentication? method on resource model for your customizations'
141
139
  test_files:
142
140
  - spec/devise/models/custom_authenticatable_spec.rb