devise_certifiable 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +10 -0
- data/LICENSE +19 -0
- data/README.rdoc +53 -0
- data/Rakefile +26 -0
- data/app/controllers/devise/certifications_controller.rb +34 -0
- data/app/views/devise/certifications/edit.html.erb +14 -0
- data/app/views/devise/mailer/certification_request.html.erb +8 -0
- data/config/locales/en.yml +17 -0
- data/devise_certifiable.gemspec +25 -0
- data/lib/devise_certifiable.rb +13 -0
- data/lib/devise_certifiable/controllers/helpers.rb +7 -0
- data/lib/devise_certifiable/controllers/url_helpers.rb +24 -0
- data/lib/devise_certifiable/mailer.rb +10 -0
- data/lib/devise_certifiable/model.rb +98 -0
- data/lib/devise_certifiable/rails.rb +12 -0
- data/lib/devise_certifiable/routes.rb +10 -0
- data/lib/devise_certifiable/schema.rb +12 -0
- data/lib/devise_certifiable/version.rb +3 -0
- data/lib/generators/active_record/devise_certifiable_generator.rb +13 -0
- data/lib/generators/active_record/templates/migration.rb +18 -0
- data/lib/generators/devise_certifiable/devise_certifiable_generator.rb +16 -0
- data/lib/generators/devise_certifiable/install_generator.rb +11 -0
- data/test/controllers/url_helpers_test.rb +34 -0
- data/test/generators/active_record_generator_test.rb +24 -0
- data/test/generators/devise_certifiable_generator_test.rb +27 -0
- data/test/generators/install_generator_test.rb +15 -0
- data/test/integration/certification_test.rb +80 -0
- data/test/mailers/certification_request_test.rb +63 -0
- data/test/models/certifiable_test.rb +172 -0
- data/test/models_test.rb +26 -0
- data/test/orm/active_record.rb +4 -0
- data/test/rails_app/Rakefile +10 -0
- data/test/rails_app/app/active_record/user.rb +7 -0
- data/test/rails_app/app/controllers/application_controller.rb +3 -0
- data/test/rails_app/app/controllers/home_controller.rb +4 -0
- data/test/rails_app/app/controllers/users_controller.rb +12 -0
- data/test/rails_app/app/helpers/application_helper.rb +3 -0
- data/test/rails_app/app/models/monster.rb +5 -0
- data/test/rails_app/app/views/home/index.html.erb +1 -0
- data/test/rails_app/app/views/layouts/application.html.erb +20 -0
- data/test/rails_app/app/views/users/index.html.erb +1 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +29 -0
- data/test/rails_app/config/boot.rb +11 -0
- data/test/rails_app/config/database.yml +18 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +22 -0
- data/test/rails_app/config/environments/production.rb +33 -0
- data/test/rails_app/config/environments/test.rb +33 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/devise.rb +179 -0
- data/test/rails_app/config/initializers/inflections.rb +2 -0
- data/test/rails_app/config/initializers/secret_token.rb +2 -0
- data/test/rails_app/config/routes.rb +6 -0
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +17 -0
- data/test/rails_app/lib/shared_user.rb +7 -0
- data/test/rails_app/script/rails +6 -0
- data/test/routes_test.rb +11 -0
- data/test/support/assertions.rb +24 -0
- data/test/support/helpers.rb +39 -0
- data/test/support/integration.rb +59 -0
- data/test/support/locale/en.yml +4 -0
- data/test/test_helper.rb +20 -0
- metadata +203 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateTables < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :users do |t|
|
4
|
+
t.string :username
|
5
|
+
|
6
|
+
t.database_authenticatable :null => false
|
7
|
+
t.confirmable
|
8
|
+
t.recoverable
|
9
|
+
t.timestamps
|
10
|
+
t.certifiable
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
drop_table :users
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
data/test/routes_test.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CertifiableRoutesTest < ActionController::TestCase
|
4
|
+
test 'map edit user certification' do
|
5
|
+
assert_recognizes({:controller => 'devise/certifications', :action => 'edit'}, {:path => 'users/certification/edit', :method => :get})
|
6
|
+
end
|
7
|
+
|
8
|
+
test 'map update user certification' do
|
9
|
+
assert_recognizes({:controller => 'devise/certifications', :action => 'update'}, {:path => 'users/certification', :method => :put})
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'active_support/test_case'
|
2
|
+
|
3
|
+
class ActiveSupport::TestCase
|
4
|
+
def assert_not(assertion)
|
5
|
+
assert !assertion
|
6
|
+
end
|
7
|
+
|
8
|
+
def assert_blank(assertion)
|
9
|
+
assert assertion.blank?
|
10
|
+
end
|
11
|
+
|
12
|
+
def assert_not_blank(assertion)
|
13
|
+
assert !assertion.blank?
|
14
|
+
end
|
15
|
+
alias :assert_present :assert_not_blank
|
16
|
+
|
17
|
+
def assert_email_sent(&block)
|
18
|
+
assert_difference('ActionMailer::Base.deliveries.size') { yield }
|
19
|
+
end
|
20
|
+
|
21
|
+
def assert_email_not_sent(&block)
|
22
|
+
assert_no_difference('ActionMailer::Base.deliveries.size') { yield }
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'active_support/test_case'
|
2
|
+
|
3
|
+
class ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup_mailer
|
6
|
+
ActionMailer::Base.deliveries = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def store_translations(locale, translations, &block)
|
10
|
+
begin
|
11
|
+
I18n.backend.store_translations(locale, translations)
|
12
|
+
yield
|
13
|
+
ensure
|
14
|
+
I18n.reload!
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_unique_email
|
19
|
+
@@email_count ||= 0
|
20
|
+
@@email_count += 1
|
21
|
+
"test#{@@email_count}@email.com"
|
22
|
+
end
|
23
|
+
|
24
|
+
def valid_attributes(attributes={})
|
25
|
+
{ :username => "usertest",
|
26
|
+
:email => generate_unique_email,
|
27
|
+
:password => '123456',
|
28
|
+
:password_confirmation => '123456' }.update(attributes)
|
29
|
+
end
|
30
|
+
|
31
|
+
def new_user(attributes={})
|
32
|
+
User.new(valid_attributes(attributes))
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_user(attributes={})
|
36
|
+
User.create!(valid_attributes(attributes))
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class ActionController::IntegrationTest
|
2
|
+
def warden
|
3
|
+
request.env['warden']
|
4
|
+
end
|
5
|
+
|
6
|
+
def create_user(options={})
|
7
|
+
user ||= begin
|
8
|
+
user = User.create!(
|
9
|
+
:username => 'usertest',
|
10
|
+
:email => generate_unique_email,
|
11
|
+
:password => options[:password] || '123456',
|
12
|
+
:password_confirmation => options[:password] || '123456',
|
13
|
+
:created_at => Time.now.utc
|
14
|
+
)
|
15
|
+
user.certify!(user) if options[:certify] == true
|
16
|
+
user.confirm! if options[:confirm] == true
|
17
|
+
user
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def sign_in_as_user(user = nil)
|
22
|
+
user ||= create_user
|
23
|
+
visit new_user_session_path
|
24
|
+
fill_in 'user_email', :with => user.email
|
25
|
+
fill_in 'user_password', :with => '123456'
|
26
|
+
click_button 'user_submit'
|
27
|
+
user
|
28
|
+
end
|
29
|
+
|
30
|
+
def sign_in_as_admin
|
31
|
+
admin = create_user(:certify => true, :confirm => true)
|
32
|
+
sign_in_as_user(admin)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Fix assert_redirect_to in integration sessions because they don't take into
|
36
|
+
# account Middleware redirects.
|
37
|
+
|
38
|
+
def assert_redirected_to(url)
|
39
|
+
assert [301, 302].include?(@integration_session.status),
|
40
|
+
"Expected status to be 301 or 302, got #{@integration_session.status}"
|
41
|
+
|
42
|
+
assert_url url, @integration_session.headers["Location"]
|
43
|
+
end
|
44
|
+
|
45
|
+
def assert_current_url(expected)
|
46
|
+
assert_url expected, current_url
|
47
|
+
end
|
48
|
+
|
49
|
+
def assert_url(expected, actual)
|
50
|
+
assert_equal prepend_host(expected), prepend_host(actual)
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def prepend_host(url)
|
56
|
+
url = "http://#{request.host}#{url}" if url[0] == ?/
|
57
|
+
url
|
58
|
+
end
|
59
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
|
3
|
+
|
4
|
+
$:.unshift File.dirname(__FILE__)
|
5
|
+
puts "\n==> Devise.orm = #{DEVISE_ORM.inspect}"
|
6
|
+
|
7
|
+
require "rails_app/config/environment"
|
8
|
+
require "rails/test_help"
|
9
|
+
require 'capybara/rails'
|
10
|
+
require "orm/#{DEVISE_ORM}"
|
11
|
+
|
12
|
+
I18n.load_path << File.expand_path("../support/locale/en.yml", __FILE__)
|
13
|
+
|
14
|
+
# Add support helpers
|
15
|
+
$:.unshift File.expand_path('../support', __FILE__)
|
16
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
17
|
+
|
18
|
+
class ActionDispatch::IntegrationTest
|
19
|
+
include Capybara
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise_certifiable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Luis Gracia
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-25 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rails
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 3.0.0
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: devise
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.2.0
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: devise_invitable
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.4.0
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: bundler
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.0.12
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
description: New sign ups need to be certified before they can sign in
|
61
|
+
email:
|
62
|
+
- lgraval@gmail.com
|
63
|
+
executables: []
|
64
|
+
|
65
|
+
extensions: []
|
66
|
+
|
67
|
+
extra_rdoc_files: []
|
68
|
+
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE
|
73
|
+
- README.rdoc
|
74
|
+
- Rakefile
|
75
|
+
- app/controllers/devise/certifications_controller.rb
|
76
|
+
- app/views/devise/certifications/edit.html.erb
|
77
|
+
- app/views/devise/mailer/certification_request.html.erb
|
78
|
+
- config/locales/en.yml
|
79
|
+
- devise_certifiable.gemspec
|
80
|
+
- lib/devise_certifiable.rb
|
81
|
+
- lib/devise_certifiable/controllers/helpers.rb
|
82
|
+
- lib/devise_certifiable/controllers/url_helpers.rb
|
83
|
+
- lib/devise_certifiable/mailer.rb
|
84
|
+
- lib/devise_certifiable/model.rb
|
85
|
+
- lib/devise_certifiable/rails.rb
|
86
|
+
- lib/devise_certifiable/routes.rb
|
87
|
+
- lib/devise_certifiable/schema.rb
|
88
|
+
- lib/devise_certifiable/version.rb
|
89
|
+
- lib/generators/active_record/devise_certifiable_generator.rb
|
90
|
+
- lib/generators/active_record/templates/migration.rb
|
91
|
+
- lib/generators/devise_certifiable/devise_certifiable_generator.rb
|
92
|
+
- lib/generators/devise_certifiable/install_generator.rb
|
93
|
+
- test/controllers/url_helpers_test.rb
|
94
|
+
- test/generators/active_record_generator_test.rb
|
95
|
+
- test/generators/devise_certifiable_generator_test.rb
|
96
|
+
- test/generators/install_generator_test.rb
|
97
|
+
- test/integration/certification_test.rb
|
98
|
+
- test/mailers/certification_request_test.rb
|
99
|
+
- test/models/certifiable_test.rb
|
100
|
+
- test/models_test.rb
|
101
|
+
- test/orm/active_record.rb
|
102
|
+
- test/rails_app/Rakefile
|
103
|
+
- test/rails_app/app/active_record/user.rb
|
104
|
+
- test/rails_app/app/controllers/application_controller.rb
|
105
|
+
- test/rails_app/app/controllers/home_controller.rb
|
106
|
+
- test/rails_app/app/controllers/users_controller.rb
|
107
|
+
- test/rails_app/app/helpers/application_helper.rb
|
108
|
+
- test/rails_app/app/models/monster.rb
|
109
|
+
- test/rails_app/app/views/home/index.html.erb
|
110
|
+
- test/rails_app/app/views/layouts/application.html.erb
|
111
|
+
- test/rails_app/app/views/users/index.html.erb
|
112
|
+
- test/rails_app/config.ru
|
113
|
+
- test/rails_app/config/application.rb
|
114
|
+
- test/rails_app/config/boot.rb
|
115
|
+
- test/rails_app/config/database.yml
|
116
|
+
- test/rails_app/config/environment.rb
|
117
|
+
- test/rails_app/config/environments/development.rb
|
118
|
+
- test/rails_app/config/environments/production.rb
|
119
|
+
- test/rails_app/config/environments/test.rb
|
120
|
+
- test/rails_app/config/initializers/backtrace_silencers.rb
|
121
|
+
- test/rails_app/config/initializers/devise.rb
|
122
|
+
- test/rails_app/config/initializers/inflections.rb
|
123
|
+
- test/rails_app/config/initializers/secret_token.rb
|
124
|
+
- test/rails_app/config/routes.rb
|
125
|
+
- test/rails_app/db/migrate/20100401102949_create_tables.rb
|
126
|
+
- test/rails_app/lib/shared_user.rb
|
127
|
+
- test/rails_app/script/rails
|
128
|
+
- test/routes_test.rb
|
129
|
+
- test/support/assertions.rb
|
130
|
+
- test/support/helpers.rb
|
131
|
+
- test/support/integration.rb
|
132
|
+
- test/support/locale/en.yml
|
133
|
+
- test/test_helper.rb
|
134
|
+
has_rdoc: true
|
135
|
+
homepage: https://github.com/luisico/devise_certifiable
|
136
|
+
licenses: []
|
137
|
+
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: "0"
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: "0"
|
155
|
+
requirements: []
|
156
|
+
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 1.6.2
|
159
|
+
signing_key:
|
160
|
+
specification_version: 3
|
161
|
+
summary: Sign up certification strategy for devise
|
162
|
+
test_files:
|
163
|
+
- test/controllers/url_helpers_test.rb
|
164
|
+
- test/generators/active_record_generator_test.rb
|
165
|
+
- test/generators/devise_certifiable_generator_test.rb
|
166
|
+
- test/generators/install_generator_test.rb
|
167
|
+
- test/integration/certification_test.rb
|
168
|
+
- test/mailers/certification_request_test.rb
|
169
|
+
- test/models/certifiable_test.rb
|
170
|
+
- test/models_test.rb
|
171
|
+
- test/orm/active_record.rb
|
172
|
+
- test/rails_app/Rakefile
|
173
|
+
- test/rails_app/app/active_record/user.rb
|
174
|
+
- test/rails_app/app/controllers/application_controller.rb
|
175
|
+
- test/rails_app/app/controllers/home_controller.rb
|
176
|
+
- test/rails_app/app/controllers/users_controller.rb
|
177
|
+
- test/rails_app/app/helpers/application_helper.rb
|
178
|
+
- test/rails_app/app/models/monster.rb
|
179
|
+
- test/rails_app/app/views/home/index.html.erb
|
180
|
+
- test/rails_app/app/views/layouts/application.html.erb
|
181
|
+
- test/rails_app/app/views/users/index.html.erb
|
182
|
+
- test/rails_app/config.ru
|
183
|
+
- test/rails_app/config/application.rb
|
184
|
+
- test/rails_app/config/boot.rb
|
185
|
+
- test/rails_app/config/database.yml
|
186
|
+
- test/rails_app/config/environment.rb
|
187
|
+
- test/rails_app/config/environments/development.rb
|
188
|
+
- test/rails_app/config/environments/production.rb
|
189
|
+
- test/rails_app/config/environments/test.rb
|
190
|
+
- test/rails_app/config/initializers/backtrace_silencers.rb
|
191
|
+
- test/rails_app/config/initializers/devise.rb
|
192
|
+
- test/rails_app/config/initializers/inflections.rb
|
193
|
+
- test/rails_app/config/initializers/secret_token.rb
|
194
|
+
- test/rails_app/config/routes.rb
|
195
|
+
- test/rails_app/db/migrate/20100401102949_create_tables.rb
|
196
|
+
- test/rails_app/lib/shared_user.rb
|
197
|
+
- test/rails_app/script/rails
|
198
|
+
- test/routes_test.rb
|
199
|
+
- test/support/assertions.rb
|
200
|
+
- test/support/helpers.rb
|
201
|
+
- test/support/integration.rb
|
202
|
+
- test/support/locale/en.yml
|
203
|
+
- test/test_helper.rb
|