devise_invitable 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/controllers/invitations_controller.rb +10 -10
- data/devise_invitable.gemspec +7 -7
- data/lib/devise/controllers/{filters.rb → helpers.rb} +1 -1
- data/lib/devise_invitable.rb +1 -2
- data/lib/devise_invitable/locales/en.yml +1 -1
- data/lib/{devise/models/invitable.rb → devise_invitable/model.rb} +0 -0
- data/test/integration/invitable_test.rb +3 -3
- data/test/test_helper.rb +2 -3
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -68,6 +68,10 @@ Define a migration to add invitable to your model:
|
|
68
68
|
t.index :invitation_token
|
69
69
|
end
|
70
70
|
|
71
|
+
# Allow null encrypted_password and password_salt
|
72
|
+
change_column :your_table, :encrypted_password, :string, :null => true
|
73
|
+
change_column :your_table, :password_salt, :string, :null => true
|
74
|
+
|
71
75
|
Add :invitable to the devise line of your model, or to config.all in devise initializer if your model uses devise :all.
|
72
76
|
|
73
77
|
Override authenticate_resource! filter if you need to customize who can send invitations.
|
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
gem.authors = ["Sergio Cambra"]
|
13
13
|
gem.add_development_dependency 'mocha'
|
14
14
|
gem.add_development_dependency 'webrat'
|
15
|
-
gem.add_dependency 'devise', '~> 0.
|
15
|
+
gem.add_dependency 'devise', '~> 0.9.0'
|
16
16
|
end
|
17
17
|
Jeweler::GemcutterTasks.new
|
18
18
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
@@ -1,22 +1,17 @@
|
|
1
1
|
class InvitationsController < ApplicationController
|
2
|
-
include Devise::Controllers::
|
2
|
+
include Devise::Controllers::InternalHelpers
|
3
|
+
include Devise::Controllers::Common
|
3
4
|
|
4
5
|
before_filter :authenticate_resource!, :only => [:new, :create]
|
5
6
|
before_filter :require_no_authentication, :only => [:edit, :update]
|
6
7
|
helper_method :after_sign_in_path_for
|
7
8
|
|
8
|
-
# GET /resource/invitation/new
|
9
|
-
def new
|
10
|
-
build_resource
|
11
|
-
render_with_scope :new
|
12
|
-
end
|
13
|
-
|
14
9
|
# POST /resource/invitation
|
15
10
|
def create
|
16
|
-
self.resource = resource_class.
|
11
|
+
self.resource = resource_class.send(send_instructions_with, params[resource_name])
|
17
12
|
|
18
13
|
if resource.errors.empty?
|
19
|
-
set_flash_message :
|
14
|
+
set_flash_message :notice, :send_instructions
|
20
15
|
redirect_to after_sign_in_path_for(resource_name)
|
21
16
|
else
|
22
17
|
render_with_scope :new
|
@@ -35,10 +30,15 @@ class InvitationsController < ApplicationController
|
|
35
30
|
self.resource = resource_class.accept_invitation!(params[resource_name])
|
36
31
|
|
37
32
|
if resource.errors.empty?
|
38
|
-
set_flash_message :
|
33
|
+
set_flash_message :notice, :updated
|
39
34
|
sign_in_and_redirect(resource_name, resource)
|
40
35
|
else
|
41
36
|
render_with_scope :edit
|
42
37
|
end
|
43
38
|
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
def send_instructions_with
|
42
|
+
:send_invitation
|
43
|
+
end
|
44
44
|
end
|
data/devise_invitable.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{devise_invitable}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sergio Cambra"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-02-08}
|
13
13
|
s.description = %q{It adds support for send invitations by email (it requires to be authenticated) and accept the invitation setting the password}
|
14
14
|
s.email = %q{sergio@entrecables.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,12 +29,12 @@ Gem::Specification.new do |s|
|
|
29
29
|
"app/views/invitations/new.html.erb",
|
30
30
|
"devise_invitable.gemspec",
|
31
31
|
"init.rb",
|
32
|
-
"lib/devise/controllers/
|
32
|
+
"lib/devise/controllers/helpers.rb",
|
33
33
|
"lib/devise/controllers/url_helpers.rb",
|
34
|
-
"lib/devise/models/invitable.rb",
|
35
34
|
"lib/devise_invitable.rb",
|
36
35
|
"lib/devise_invitable/locales/en.yml",
|
37
36
|
"lib/devise_invitable/mailer.rb",
|
37
|
+
"lib/devise_invitable/model.rb",
|
38
38
|
"lib/devise_invitable/rails.rb",
|
39
39
|
"lib/devise_invitable/routes.rb",
|
40
40
|
"lib/devise_invitable/schema.rb",
|
@@ -109,16 +109,16 @@ Gem::Specification.new do |s|
|
|
109
109
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
110
110
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
111
111
|
s.add_development_dependency(%q<webrat>, [">= 0"])
|
112
|
-
s.add_runtime_dependency(%q<devise>, ["~> 0.
|
112
|
+
s.add_runtime_dependency(%q<devise>, ["~> 0.9.0"])
|
113
113
|
else
|
114
114
|
s.add_dependency(%q<mocha>, [">= 0"])
|
115
115
|
s.add_dependency(%q<webrat>, [">= 0"])
|
116
|
-
s.add_dependency(%q<devise>, ["~> 0.
|
116
|
+
s.add_dependency(%q<devise>, ["~> 0.9.0"])
|
117
117
|
end
|
118
118
|
else
|
119
119
|
s.add_dependency(%q<mocha>, [">= 0"])
|
120
120
|
s.add_dependency(%q<webrat>, [">= 0"])
|
121
|
-
s.add_dependency(%q<devise>, ["~> 0.
|
121
|
+
s.add_dependency(%q<devise>, ["~> 0.9.0"])
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
data/lib/devise_invitable.rb
CHANGED
@@ -3,8 +3,7 @@ Devise.module_eval do
|
|
3
3
|
mattr_accessor :invite_for
|
4
4
|
@@invite_for = 0
|
5
5
|
end
|
6
|
-
Devise
|
7
|
-
Devise::CONTROLLERS[:invitations] = [:invitable]
|
6
|
+
Devise.add_module :invitable, :controller => :invitations, :model => 'devise_invitable/model'
|
8
7
|
|
9
8
|
module DeviseInvitable; end
|
10
9
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
en:
|
2
2
|
devise:
|
3
3
|
invitations:
|
4
|
-
|
4
|
+
send_instructions: 'An email with instructions about how to set the password has been sent.'
|
5
5
|
updated: 'Your password was set successfully. You are now signed in.'
|
File without changes
|
@@ -40,7 +40,7 @@ class InvitationTest < ActionController::IntegrationTest
|
|
40
40
|
|
41
41
|
send_invitation
|
42
42
|
assert_template 'home/index'
|
43
|
-
assert_equal 'An email with instructions about how to set the password has been sent.', flash[:
|
43
|
+
assert_equal 'An email with instructions about how to set the password has been sent.', flash[:notice]
|
44
44
|
end
|
45
45
|
|
46
46
|
test 'authenticated user with invalid email should receive an error message' do
|
@@ -95,7 +95,7 @@ class InvitationTest < ActionController::IntegrationTest
|
|
95
95
|
set_password :invitation_token => user.invitation_token
|
96
96
|
|
97
97
|
assert_template 'home/index'
|
98
|
-
assert_equal 'Your password was set successfully. You are now signed in.', flash[:
|
98
|
+
assert_equal 'Your password was set successfully. You are now signed in.', flash[:notice]
|
99
99
|
assert user.reload.valid_password?('987654321')
|
100
100
|
end
|
101
101
|
|
@@ -109,7 +109,7 @@ class InvitationTest < ActionController::IntegrationTest
|
|
109
109
|
assert_not user.reload.valid_password?('987654321')
|
110
110
|
|
111
111
|
set_password :invitation_token => user.invitation_token
|
112
|
-
assert_equal 'Your password was set successfully. You are now signed in.', flash[:
|
112
|
+
assert_equal 'Your password was set successfully. You are now signed in.', flash[:notice]
|
113
113
|
assert user.reload.valid_password?('987654321')
|
114
114
|
end
|
115
115
|
|
data/test/test_helper.rb
CHANGED
@@ -4,9 +4,8 @@ require File.join(File.dirname(__FILE__), 'rails_app', 'config', 'environment')
|
|
4
4
|
require 'test_help'
|
5
5
|
require 'mocha'
|
6
6
|
require 'webrat'
|
7
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'devise', 'models', 'invitable')
|
8
7
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'devise', 'controllers', 'url_helpers')
|
9
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'devise', 'controllers', '
|
8
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'devise', 'controllers', 'helpers')
|
10
9
|
ActionView::Base.send :include, Devise::Controllers::UrlHelpers
|
11
10
|
|
12
11
|
path = File.join(File.dirname(__FILE__), '..', 'app', 'views')
|
@@ -37,7 +36,7 @@ ActionController::Routing::Routes.draw do |map|
|
|
37
36
|
map.devise_for :users
|
38
37
|
end
|
39
38
|
require File.join(File.dirname(__FILE__), '..', 'app', 'controllers', 'invitations_controller')
|
40
|
-
InvitationsController.send :include, Devise::Controllers::
|
39
|
+
InvitationsController.send :include, Devise::Controllers::Helpers
|
41
40
|
|
42
41
|
Webrat.configure do |config|
|
43
42
|
config.mode = :rails
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_invitable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Cambra
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-08 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
43
|
+
version: 0.9.0
|
44
44
|
version:
|
45
45
|
description: It adds support for send invitations by email (it requires to be authenticated) and accept the invitation setting the password
|
46
46
|
email: sergio@entrecables.com
|
@@ -64,12 +64,12 @@ files:
|
|
64
64
|
- app/views/invitations/new.html.erb
|
65
65
|
- devise_invitable.gemspec
|
66
66
|
- init.rb
|
67
|
-
- lib/devise/controllers/
|
67
|
+
- lib/devise/controllers/helpers.rb
|
68
68
|
- lib/devise/controllers/url_helpers.rb
|
69
|
-
- lib/devise/models/invitable.rb
|
70
69
|
- lib/devise_invitable.rb
|
71
70
|
- lib/devise_invitable/locales/en.yml
|
72
71
|
- lib/devise_invitable/mailer.rb
|
72
|
+
- lib/devise_invitable/model.rb
|
73
73
|
- lib/devise_invitable/rails.rb
|
74
74
|
- lib/devise_invitable/routes.rb
|
75
75
|
- lib/devise_invitable/schema.rb
|