authn 2.6.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/authn/model.rb CHANGED
@@ -5,9 +5,8 @@ module AuthN
5
5
  end
6
6
 
7
7
  module ClassMethods
8
- def has_authentication(o = {})
9
- options = AuthN.config.table.any? ? o.merge!(AuthN.config) : o
10
- config.merge! options
8
+ def has_authentication(options = {})
9
+ merge_config_with options
11
10
  end
12
11
 
13
12
  def config=(options)
@@ -38,6 +37,12 @@ module AuthN
38
37
  # Return false if account was found and password didn't match
39
38
  # Return nil if account wasn't found OR password wasn't given
40
39
  end
40
+
41
+ private
42
+
43
+ def merge_config_with(options)
44
+ config.merge! options.merge! AuthN.config
45
+ end
41
46
  end
42
47
  end
43
48
  end
data/lib/authn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module AuthN
2
- VERSION = "2.6.0"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -3,64 +3,62 @@ require_relative '../../helper'
3
3
 
4
4
  class TestAuthNModel < MiniTest::Unit::TestCase
5
5
  def setup
6
-
6
+ @account = Account.new
7
7
  end
8
8
 
9
- # def has_authentication(o = {})
10
- # options = AuthN::Config::DEFAULTS.dup
11
- # options.merge! AuthN.config if AuthN.config.to_hash
12
- # options.merge! o unless o.empty?
13
- # config options
9
+ # def has_authentication(options = {})
10
+ # merge_config_with options
14
11
  # end
15
- def test_
16
- actual =
17
- expected =
18
- assert_equal expected, actual
12
+ def test_model_gets_has_authentication_method
13
+ assert Account.public_methods.include? :has_authentication
19
14
  end
20
15
 
21
- def test_
16
+ def test_has_authentication_config_combinds_with_default_config
22
17
  actual =
23
18
  expected =
24
19
  assert_equal expected, actual
25
20
  end
26
21
 
27
- def test_
22
+ def test_has_autehntication_config_merges_in_model_config
28
23
  actual =
29
24
  expected =
30
25
  assert_equal expected, actual
31
26
  end
32
27
 
33
- def test_
28
+ # def config=(options)
29
+ # @@config = options
30
+ # end
31
+ #
32
+ # def config
33
+ # @@config ||= AuthN::Config.new
34
+ # end
35
+ def test_model_has_class_wide_config_settings
34
36
  actual =
35
37
  expected =
36
38
  assert_equal expected, actual
37
39
  end
38
40
 
39
41
  # def authenticate(identifiers = {})
40
- # password = identifiers.delete :password
41
- # criteria = where identifiers
42
+ # password = identifiers.delete AuthN.config.login_password_key
43
+ # criteria = send AuthN.config.model_critera_method, identifiers
42
44
  # instance = criteria.first
43
45
  # if instance && password
44
- # if instance.authenticate password
45
- # instance
46
- # else
47
- # false
48
- # end
46
+ # instance.authenticate(password) ? instance : false
49
47
  # end
50
48
  # end
51
- def test_
49
+ def test_authenticate_returns_instance_if_given_good_credentials
52
50
  actual =
53
51
  expected =
54
52
  assert_equal expected, actual
55
53
  end
56
54
 
57
- def test_
55
+ def test_authenticate_returns_false_if_bad_password
58
56
  actual =
59
57
  expected =
60
58
  assert_equal expected, actual
61
59
  end
62
60
 
63
- def test_
61
+ def test_authenticate_return_nil_if_no_record_found
64
62
  actual =
65
63
  expected =
66
64
  assert_equal expected, actual
@@ -3,7 +3,6 @@ require_relative '../../helper'
3
3
 
4
4
  class TestAuthNSession < MiniTest::Unit::TestCase
5
5
  def setup
6
- AuthN.config.account_klass = :Account
7
6
  Account.password "12341234"
8
7
  @controller = Controller.new
9
8
  @controller.session = {}
@@ -3,6 +3,6 @@ require_relative '../../helper'
3
3
 
4
4
  class TestAuthNVersion < MiniTest::Unit::TestCase
5
5
  def test_that_version_is_latest
6
- assert_equal "2.6.0", AuthN::VERSION
6
+ assert_equal "3.1.0", AuthN::VERSION
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authn
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 3.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-03 00:00:00.000000000 Z
12
+ date: 2012-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -132,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  segments:
134
134
  - 0
135
- hash: 251754304822765398
135
+ hash: 3456173400469928444
136
136
  required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  none: false
138
138
  requirements:
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  segments:
143
143
  - 0
144
- hash: 251754304822765398
144
+ hash: 3456173400469928444
145
145
  requirements: []
146
146
  rubyforge_project:
147
147
  rubygems_version: 1.8.24