goma 0.0.1.gamma → 0.0.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +13 -9
- data/Rakefile +14 -0
- data/goma.gemspec +6 -0
- data/lib/generators/goma/erb/templates/confirmation/new.html.erb +2 -2
- data/lib/generators/goma/erb/templates/password/edit.html.erb +6 -6
- data/lib/generators/goma/erb/templates/unlock/new.html.erb +1 -1
- data/lib/generators/goma/erb/templates/user/_form.html.erb +1 -1
- data/lib/generators/goma/erb/templates/user/new.html.erb +4 -0
- data/lib/generators/goma/mailer/erb/templates/activation_needed_email.text.erb +1 -1
- data/lib/generators/goma/model/active_record_generator.rb +1 -0
- data/lib/generators/goma/model/oauth/active_record_generator.rb +3 -3
- data/lib/generators/goma/resource_route/resource_route_generator.rb +13 -9
- data/lib/generators/goma/scaffold_controller/templates/confirmation_controller.rb +8 -4
- data/lib/generators/goma/scaffold_controller/templates/oauth_controller.rb +5 -0
- data/lib/generators/goma/scaffold_controller/templates/password_controller.rb +9 -4
- data/lib/generators/goma/scaffold_controller/templates/unlock_controller.rb +1 -0
- data/lib/generators/goma/scaffold_controller/templates/user_controller.rb +41 -1
- data/lib/goma/config.rb +4 -4
- data/lib/goma/models/authenticatable.rb +20 -9
- data/lib/goma/models/confirmable.rb +15 -9
- data/lib/goma/models/password_authenticatable.rb +2 -1
- data/lib/goma/models/recoverable.rb +1 -1
- data/lib/goma/models/validatable.rb +4 -4
- data/lib/goma/railtie.rb +1 -0
- data/lib/goma/version.rb +1 -1
- data/test/integration/confirmable_integration_test.rb +185 -0
- data/test/integration/lockable_integration_test.rb +49 -0
- data/test/integration/omniauthable_integration_test.rb +64 -12
- data/test/integration/password_authenticatable_integration_test.rb +40 -0
- data/test/integration/recoverable_integration_test.rb +96 -0
- data/test/integration/rememberable_integration_test.rb +14 -0
- data/test/models/confirmable_test.rb +6 -6
- data/test/models/omniauthable_test.rb +2 -2
- data/test/rails_app/app/controllers/authentications_controller.rb +5 -0
- data/test/rails_app/app/controllers/confirmations_controller.rb +8 -4
- data/test/rails_app/app/controllers/passwords_controller.rb +9 -4
- data/test/rails_app/app/controllers/unlocks_controller.rb +1 -0
- data/test/rails_app/app/controllers/users_controller.rb +25 -2
- data/test/rails_app/app/views/confirmations/new.html.erb +2 -2
- data/test/rails_app/app/views/layouts/application.html.erb +3 -1
- data/test/rails_app/app/views/passwords/edit.html.erb +6 -6
- data/test/rails_app/app/views/unlocks/new.html.erb +1 -1
- data/test/rails_app/app/views/user_mailer/activation_needed_email.text.erb +1 -1
- data/test/rails_app/app/views/users/_form.html.erb +1 -1
- data/test/rails_app/app/views/users/new.html.erb +1 -0
- data/test/rails_app/config/initializers/omniauth.rb +0 -1
- data/test/rails_app/config/routes.rb +6 -10
- data/test/rails_app/db/migrate/{20140512081308_create_users.rb → 20140515111009_create_users.rb} +0 -0
- data/test/rails_app/db/migrate/{20140512081309_create_authentications.rb → 20140515111010_create_authentications.rb} +0 -0
- data/test/rails_app/db/schema.rb +1 -1
- data/test/test_helper.rb +43 -0
- metadata +33 -13
- data/test/controllers/confirmations_controller_test.rb +0 -14
- data/test/controllers/users_controller_test.rb +0 -12
- data/test/integration/authenticatable_integration_test.rb +0 -26
@@ -1,32 +1,28 @@
|
|
1
1
|
RailsApp::Application.routes.draw do
|
2
|
-
|
2
|
+
|
3
3
|
get '/auth/:provider/callback', to: 'authentications#create'
|
4
|
+
get '/auth/failure', to: 'authentications#failure'
|
5
|
+
|
4
6
|
|
5
7
|
resources :unlocks, only: [:show, :new, :create]
|
6
8
|
|
7
9
|
resources :passwords, only: [:new, :create, :edit, :update]
|
8
10
|
|
9
11
|
resources :confirmations, only: [:show, :new, :create] do
|
10
|
-
get :email,
|
12
|
+
get :email, on: :member
|
11
13
|
end
|
12
14
|
|
15
|
+
|
13
16
|
resource :session, only: [:new, :create, :destroy]
|
14
17
|
|
15
18
|
resources :users
|
16
19
|
|
17
|
-
resources :unlocks, only: [:show, :new, :create,]
|
18
|
-
|
19
|
-
resources :confirmations, only: [:new, :create] do
|
20
|
-
get :activate, on: :member
|
21
|
-
get :confirm, on: :member
|
22
|
-
end
|
23
|
-
|
24
20
|
root to: 'home#index'
|
25
21
|
|
26
22
|
get 'login' => 'sessions#new', as: :login
|
27
23
|
delete 'logout' => 'sessions#destroy', as: :logout
|
28
24
|
|
29
|
-
get 'secret/index'
|
25
|
+
get 'secret/index', as: :secret
|
30
26
|
get 'secret/not_track'
|
31
27
|
get 'secret/not_timeout'
|
32
28
|
get 'secret/not_validate_session'
|
data/test/rails_app/db/migrate/{20140512081308_create_users.rb → 20140515111009_create_users.rb}
RENAMED
File without changes
|
File without changes
|
data/test/rails_app/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20140515111010) do
|
15
15
|
|
16
16
|
create_table "authentications", force: true do |t|
|
17
17
|
t.string "provider"
|
data/test/test_helper.rb
CHANGED
@@ -12,6 +12,8 @@ end
|
|
12
12
|
require 'mocha/setup'
|
13
13
|
require 'shoulda-context'
|
14
14
|
require 'timecop'
|
15
|
+
require 'capybara/rails'
|
16
|
+
|
15
17
|
require 'minitest/ansi'
|
16
18
|
MiniTest::ANSI.use!
|
17
19
|
require 'byebug'
|
@@ -46,6 +48,8 @@ class ActionController::TestCase
|
|
46
48
|
end
|
47
49
|
|
48
50
|
class ActionDispatch::IntegrationTest
|
51
|
+
include Capybara::DSL
|
52
|
+
|
49
53
|
def signed_cookie(key)
|
50
54
|
controller.send(:cookies).signed[key]
|
51
55
|
end
|
@@ -69,6 +73,45 @@ class ActionDispatch::IntegrationTest
|
|
69
73
|
def current_user
|
70
74
|
warden.user(scope: :user)
|
71
75
|
end
|
76
|
+
|
77
|
+
# for Capybara
|
78
|
+
def _controller
|
79
|
+
page.driver.request.env['action_controller.instance']
|
80
|
+
end
|
81
|
+
|
82
|
+
def _request
|
83
|
+
_controller.request
|
84
|
+
end
|
85
|
+
|
86
|
+
def _session
|
87
|
+
_request.session
|
88
|
+
end
|
89
|
+
|
90
|
+
def _flash
|
91
|
+
_request.flash
|
92
|
+
end
|
93
|
+
|
94
|
+
def _warden
|
95
|
+
_request.env['warden']
|
96
|
+
end
|
97
|
+
|
98
|
+
def _current_user
|
99
|
+
_warden.user(scope: :user)
|
100
|
+
end
|
101
|
+
|
102
|
+
def _cookies
|
103
|
+
_request.cookies
|
104
|
+
end
|
105
|
+
|
106
|
+
def _signed_cookie(key)
|
107
|
+
_controller.send(:cookies).signed[key]
|
108
|
+
end
|
109
|
+
|
110
|
+
def _update_signed_cookies(data)
|
111
|
+
data.each do |k, v|
|
112
|
+
_cookies[k.to_s] = generate_signed_cookie(v)
|
113
|
+
end
|
114
|
+
end
|
72
115
|
end
|
73
116
|
|
74
117
|
OmniAuth.config.test_mode = true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaro Imai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: capybara
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: minitest-ansi
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -267,15 +281,16 @@ files:
|
|
267
281
|
- lib/goma/warden.rb
|
268
282
|
- lib/tasks/goma_tasks.rake
|
269
283
|
- test/config_test.rb
|
270
|
-
- test/controllers/confirmations_controller_test.rb
|
271
284
|
- test/controllers/helpers_test.rb
|
272
285
|
- test/controllers/lockable_controller_test.rb
|
273
286
|
- test/controllers/sessions_controller_test.rb
|
274
|
-
- test/controllers/users_controller_test.rb
|
275
287
|
- test/fabricators/users_fabricator.rb
|
276
288
|
- test/goma_test.rb
|
277
|
-
- test/integration/
|
289
|
+
- test/integration/confirmable_integration_test.rb
|
290
|
+
- test/integration/lockable_integration_test.rb
|
278
291
|
- test/integration/omniauthable_integration_test.rb
|
292
|
+
- test/integration/password_authenticatable_integration_test.rb
|
293
|
+
- test/integration/recoverable_integration_test.rb
|
279
294
|
- test/integration/rememberable_integration_test.rb
|
280
295
|
- test/integration/routes_integration_test.rb
|
281
296
|
- test/integration/timeoutable_integration_test.rb
|
@@ -369,8 +384,8 @@ files:
|
|
369
384
|
- test/rails_app/config/initializers/wrap_parameters.rb
|
370
385
|
- test/rails_app/config/locales/en.yml
|
371
386
|
- test/rails_app/config/routes.rb
|
372
|
-
- test/rails_app/db/migrate/
|
373
|
-
- test/rails_app/db/migrate/
|
387
|
+
- test/rails_app/db/migrate/20140515111009_create_users.rb
|
388
|
+
- test/rails_app/db/migrate/20140515111010_create_authentications.rb
|
374
389
|
- test/rails_app/db/schema.rb
|
375
390
|
- test/rails_app/lib/assets/.keep
|
376
391
|
- test/rails_app/log/.keep
|
@@ -392,7 +407,11 @@ post_install_message: "\n\e[32mThank you for installing!\n\nYou can use this gem
|
|
392
407
|
\ \e[0mconfig.action_mailer.default_url_options = { host: 'localhost:3000' }\e[32m\n\n
|
393
408
|
\ in production, :host should be set to the actual host of your application.\n\n===========================================================================\n\n\nThat's
|
394
409
|
it.\n\nThis gem is in early development phase and I do not recommend you to use
|
395
|
-
this for production for a while.\nBug reports and pull requests are welcome.\n\
|
410
|
+
this for production for a while.\nBug reports and pull requests are welcome.\n\nI
|
411
|
+
am surprised that this gem has been downloaded over 200 times, in spite of pre release
|
412
|
+
versions of v0.0.1.\nAnd, I feel bad about there were lots of bugs and incomplete
|
413
|
+
implementations in previous versions.\n\nI will release this as a release candidate,
|
414
|
+
but will add lots of code before v0.0.1.\n\nEnjoy!\e[0m\n"
|
396
415
|
rdoc_options: []
|
397
416
|
require_paths:
|
398
417
|
- lib
|
@@ -414,15 +433,16 @@ specification_version: 4
|
|
414
433
|
summary: An authentication solution for Rails 4
|
415
434
|
test_files:
|
416
435
|
- test/config_test.rb
|
417
|
-
- test/controllers/confirmations_controller_test.rb
|
418
436
|
- test/controllers/helpers_test.rb
|
419
437
|
- test/controllers/lockable_controller_test.rb
|
420
438
|
- test/controllers/sessions_controller_test.rb
|
421
|
-
- test/controllers/users_controller_test.rb
|
422
439
|
- test/fabricators/users_fabricator.rb
|
423
440
|
- test/goma_test.rb
|
424
|
-
- test/integration/
|
441
|
+
- test/integration/confirmable_integration_test.rb
|
442
|
+
- test/integration/lockable_integration_test.rb
|
425
443
|
- test/integration/omniauthable_integration_test.rb
|
444
|
+
- test/integration/password_authenticatable_integration_test.rb
|
445
|
+
- test/integration/recoverable_integration_test.rb
|
426
446
|
- test/integration/rememberable_integration_test.rb
|
427
447
|
- test/integration/routes_integration_test.rb
|
428
448
|
- test/integration/timeoutable_integration_test.rb
|
@@ -516,8 +536,8 @@ test_files:
|
|
516
536
|
- test/rails_app/config/initializers/wrap_parameters.rb
|
517
537
|
- test/rails_app/config/locales/en.yml
|
518
538
|
- test/rails_app/config/routes.rb
|
519
|
-
- test/rails_app/db/migrate/
|
520
|
-
- test/rails_app/db/migrate/
|
539
|
+
- test/rails_app/db/migrate/20140515111009_create_users.rb
|
540
|
+
- test/rails_app/db/migrate/20140515111010_create_authentications.rb
|
521
541
|
- test/rails_app/db/schema.rb
|
522
542
|
- test/rails_app/lib/assets/.keep
|
523
543
|
- test/rails_app/log/.keep
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ConfirmationsControllerTest < ActionController::TestCase
|
4
|
-
test 'should activate user' do
|
5
|
-
user = User.new(username: 'foo', email: 'foo@example.com', password: 'password', password_confirmation: 'password')
|
6
|
-
user.save!
|
7
|
-
|
8
|
-
get :show, id: user.raw_confirmation_token
|
9
|
-
assert_redirected_to new_session_url
|
10
|
-
assert flash[:notice]
|
11
|
-
user.reload
|
12
|
-
assert user.activated?
|
13
|
-
end
|
14
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class UsersControllerTest < ActionController::TestCase
|
4
|
-
# This test might not be needed
|
5
|
-
test 'should create user' do
|
6
|
-
assert_difference 'User.count', 1 do
|
7
|
-
post :create, {user: {username: 'foo', email: 'foo@example.com', password: 'password', password_confirmation: 'password'}}
|
8
|
-
end
|
9
|
-
assert_redirected_to new_session_url
|
10
|
-
assert flash[:notice]
|
11
|
-
end
|
12
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class AuthenticatableSessionIntegrationTest < ActionDispatch::IntegrationTest
|
4
|
-
def setup
|
5
|
-
@user = Fabricate(:user)
|
6
|
-
end
|
7
|
-
|
8
|
-
test 'should login' do
|
9
|
-
post 'session', username_or_email: @user.email, password: 'password'
|
10
|
-
assert_equal @user, request.env['warden'].user(:user)
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'should redirect back correctly' do
|
14
|
-
get 'secret/index'
|
15
|
-
assert_redirected_to root_url
|
16
|
-
post 'session', username_or_email: @user.email, password: 'password'
|
17
|
-
assert_redirected_to secret_index_url
|
18
|
-
end
|
19
|
-
|
20
|
-
test 'should redirect back url with parameters correctly' do
|
21
|
-
get 'secret/index?page=100'
|
22
|
-
assert_redirected_to root_url
|
23
|
-
post 'session', username_or_email: @user.email, password: 'password'
|
24
|
-
assert_redirected_to '/secret/index?page=100'
|
25
|
-
end
|
26
|
-
end
|