devise-guests 0.3.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/Gemfile +2 -0
- data/devise-guests.gemspec +1 -1
- data/lib/devise-guests/controllers/helpers.rb +14 -11
- data/lib/devise-guests/version.rb +1 -1
- data/spec/controllers/application_controller_spec.rb +5 -5
- data/spec/helpers/devise_guests_helpers_spec.rb +1 -1
- data/spec/integration/simple_integration_spec.rb +1 -1
- data/spec/internal/config/initializers/devise.rb +1 -0
- data/spec/internal/db/combustion_test.sqlite +0 -0
- data/spec/spec_helper.rb +4 -0
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 116261fdbf67744f52cab29287d611418338fa5f
|
4
|
+
data.tar.gz: 2cd6be05426becf115076b2a50beddc3e244edd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9245e301b525acfd1fda18165050cac14dc3df60ebcce886160eb266fbab76c6654f9f6ada49afa6ef9aaf481be5f876d17b116f7533f77673210ab26d3554f1
|
7
|
+
data.tar.gz: 4ca01fcb81c4fa20147c3e1de2a5b8a7a95425b4e7bd6d651d72bc3ff3faf46951cb05d9ffbf2aca10d1f256b457a0d7dfaac4ac3647dd177f109d0641479cd8
|
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/devise-guests.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.add_dependency 'devise'
|
17
17
|
|
18
|
-
s.add_development_dependency "rspec"
|
18
|
+
s.add_development_dependency "rspec", "~> 3.0"
|
19
19
|
s.add_development_dependency "rake"
|
20
20
|
s.add_development_dependency "combustion", '~> 0.4.0'
|
21
21
|
s.add_development_dependency "rspec-rails"
|
@@ -33,13 +33,13 @@ module DeviseGuests::Controllers
|
|
33
33
|
return @guest_#{mapping} if @guest_#{mapping}
|
34
34
|
|
35
35
|
if session[:guest_#{mapping}_id]
|
36
|
-
@guest_#{mapping} = #{class_name}.
|
36
|
+
@guest_#{mapping} = #{class_name}.find_by(#{class_name}.authentication_keys.first => session[:guest_#{mapping}_id]) rescue nil
|
37
37
|
@guest_#{mapping} = nil if @guest_#{mapping}.respond_to? :guest and !@guest_#{mapping}.guest
|
38
38
|
end
|
39
39
|
|
40
40
|
@guest_#{mapping} ||= begin
|
41
41
|
u = create_guest_#{mapping}(session[:guest_#{mapping}_id])
|
42
|
-
session[:guest_#{mapping}_id] = u.
|
42
|
+
session[:guest_#{mapping}_id] = u.send(#{class_name}.authentication_keys.first)
|
43
43
|
u
|
44
44
|
end
|
45
45
|
|
@@ -61,16 +61,19 @@ module DeviseGuests::Controllers
|
|
61
61
|
end
|
62
62
|
|
63
63
|
private
|
64
|
-
def create_guest_#{mapping}
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
g.
|
69
|
-
g.
|
64
|
+
def create_guest_#{mapping} key = nil
|
65
|
+
auth_key = #{class_name}.authentication_keys.first
|
66
|
+
#{class_name}.new do |g|
|
67
|
+
g.send("\#{auth_key}=", send(:"guest_\#{auth_key}_authentication_key", key))
|
68
|
+
g.guest = true if g.respond_to? :guest
|
69
|
+
g.skip_confirmation! if g.respond_to?(:skip_confirmation!)
|
70
|
+
g.save(validate: false)
|
70
71
|
end
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
end
|
73
|
+
|
74
|
+
def guest_email_authentication_key key
|
75
|
+
key &&= nil unless key.to_s.match(/^guest/)
|
76
|
+
key ||= "guest_" + guest_#{mapping}_unique_suffix + "@example.com"
|
74
77
|
end
|
75
78
|
|
76
79
|
def guest_#{mapping}_unique_suffix
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
|
-
describe ApplicationController do
|
4
|
+
describe ApplicationController, :type => :controller do
|
5
5
|
controller do
|
6
6
|
|
7
7
|
end
|
@@ -12,16 +12,16 @@ describe ApplicationController do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should create an anonymous user for a guest" do
|
15
|
-
@mock_warden.
|
15
|
+
allow(@mock_warden).to receive(:authenticate).with(anything).and_return(false)
|
16
16
|
|
17
|
-
@controller.current_or_guest_user.email.
|
17
|
+
expect(@controller.current_or_guest_user.email).to match(/guest/)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should use the current user when available" do
|
21
21
|
m = double()
|
22
|
-
@mock_warden.
|
22
|
+
allow(@mock_warden).to receive(:authenticate).with(anything).and_return(m)
|
23
23
|
|
24
|
-
@controller.current_or_guest_user.
|
24
|
+
expect(@controller.current_or_guest_user).to eq(m)
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
Binary file
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-guests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '3.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +116,7 @@ extra_rdoc_files:
|
|
116
116
|
- LICENSE
|
117
117
|
- README.md
|
118
118
|
files:
|
119
|
+
- ".gitignore"
|
119
120
|
- Gemfile
|
120
121
|
- LICENSE
|
121
122
|
- README.md
|
@@ -139,6 +140,7 @@ files:
|
|
139
140
|
- spec/internal/config/database.yml
|
140
141
|
- spec/internal/config/initializers/devise.rb
|
141
142
|
- spec/internal/config/routes.rb
|
143
|
+
- spec/internal/db/combustion_test.sqlite
|
142
144
|
- spec/internal/db/schema.rb
|
143
145
|
- spec/internal/log/.gitignore
|
144
146
|
- spec/internal/public/favicon.ico
|
@@ -163,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
165
|
version: '0'
|
164
166
|
requirements: []
|
165
167
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
168
|
+
rubygems_version: 2.4.5.1
|
167
169
|
signing_key:
|
168
170
|
specification_version: 4
|
169
171
|
summary: Guest user implementation for devise
|
@@ -176,6 +178,7 @@ test_files:
|
|
176
178
|
- spec/internal/config/database.yml
|
177
179
|
- spec/internal/config/initializers/devise.rb
|
178
180
|
- spec/internal/config/routes.rb
|
181
|
+
- spec/internal/db/combustion_test.sqlite
|
179
182
|
- spec/internal/db/schema.rb
|
180
183
|
- spec/internal/log/.gitignore
|
181
184
|
- spec/internal/public/favicon.ico
|