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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7329fab1798a4c760c934f5fc78731361295dd2
4
- data.tar.gz: 946773a13249939a4a2096e85e875b970f753aeb
3
+ metadata.gz: 116261fdbf67744f52cab29287d611418338fa5f
4
+ data.tar.gz: 2cd6be05426becf115076b2a50beddc3e244edd1
5
5
  SHA512:
6
- metadata.gz: 50b69c022469f239b6a48a31384522ac5e732ebc2a922f1731a53a76bb1823782f47e1a540907634367738ef486b3735272ddceb67eee5b5f283583f2ad9e377
7
- data.tar.gz: 8f15f1ba4d180f7f257cb2cbefb9e6bc44764fdccc8348714f022dd7a629feeb0e38676d8b66f0b3deb630f0fbc6d8c280aac6cab6a25f25388b63de07a51010
6
+ metadata.gz: 9245e301b525acfd1fda18165050cac14dc3df60ebcce886160eb266fbab76c6654f9f6ada49afa6ef9aaf481be5f876d17b116f7533f77673210ab26d3554f1
7
+ data.tar.gz: 4ca01fcb81c4fa20147c3e1de2a5b8a7a95425b4e7bd6d651d72bc3ff3faf46951cb05d9ffbf2aca10d1f256b457a0d7dfaac4ac3647dd177f109d0641479cd8
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile CHANGED
@@ -9,3 +9,5 @@ group :test do
9
9
  gem 'activerecord'
10
10
  gem 'actionmailer'
11
11
  end
12
+
13
+ gem 'transpec'
@@ -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}.find_by_email(session[:guest_#{mapping}_id]) rescue nil
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.email
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} email = nil
65
- email &&= nil unless email.to_s.match(/^guest/)
66
- email ||= "guest_" + guest_#{mapping}_unique_suffix + "@example.com"
67
- u = #{class_name}.new.tap do |g|
68
- g.email = email
69
- g.save
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
- u.password = u.password_confirmation = email
72
- u.guest = true if u.respond_to? :guest
73
- u
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,3 +1,3 @@
1
1
  module DeviseGuests
2
- VERSION = '0.3.3'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -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.stub(:authenticate).with(anything).and_return(false)
15
+ allow(@mock_warden).to receive(:authenticate).with(anything).and_return(false)
16
16
 
17
- @controller.current_or_guest_user.email.should =~ /guest/
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.stub(:authenticate).with(anything).and_return(m)
22
+ allow(@mock_warden).to receive(:authenticate).with(anything).and_return(m)
23
23
 
24
- @controller.current_or_guest_user.should == m
24
+ expect(@controller.current_or_guest_user).to eq(m)
25
25
  end
26
26
 
27
27
  end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "devise guest helpers" do
3
+ describe "devise guest helpers", :type => :helper do
4
4
 
5
5
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Simple Integration" do
3
+ describe "Simple Integration", :type => :request do
4
4
  it "should work" do
5
5
  end
6
6
  end
@@ -3,4 +3,5 @@ Devise.setup do |config|
3
3
  require 'devise-guests'
4
4
 
5
5
  config.helpers << DeviseGuests::Controllers::Helpers
6
+ config.secret_key = '71da52cff5ef1a77c9ccdc5153993e0e58054c288c86e005d9f7eca6ac7a9279825c7903f1de5960e900543ab0cf7f85b6d307c43b53719bebcdb9cdcfe8b7e7'
6
7
  end
@@ -16,3 +16,7 @@ Combustion.initialize!(:active_record,:action_mailer)
16
16
  require 'rspec/rails'
17
17
  require 'capybara/rails'
18
18
 
19
+ RSpec.configure do |config|
20
+ config.infer_spec_type_from_file_location!
21
+ end
22
+
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.3.3
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: 2014-02-18 00:00:00.000000000 Z
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.2.0
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