simple_auth 0.1.8 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/.gitignore +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +13 -0
  4. data/Gemfile.lock +109 -0
  5. data/README.markdown +13 -29
  6. data/Rakefile +21 -33
  7. data/lib/simple_auth/action_controller.rb +42 -38
  8. data/lib/simple_auth/active_record.rb +59 -47
  9. data/lib/simple_auth/config.rb +8 -3
  10. data/lib/simple_auth/generator.rb +11 -0
  11. data/lib/simple_auth/railtie.rb +24 -0
  12. data/lib/simple_auth/session.rb +12 -0
  13. data/lib/simple_auth/version.rb +3 -3
  14. data/lib/simple_auth.rb +1 -7
  15. data/simple_auth.gemspec +35 -21
  16. data/spec/controllers/redirect_logged_user_spec.rb +87 -0
  17. data/spec/controllers/require_logged_user_spec.rb +105 -0
  18. data/spec/schema.rb +4 -0
  19. data/spec/simple_auth/active_record_spec.rb +32 -15
  20. data/spec/simple_auth/config_spec.rb +7 -1
  21. data/spec/simple_auth/helper_spec.rb +12 -16
  22. data/spec/simple_auth/session_spec.rb +9 -7
  23. data/spec/spec_helper.rb +9 -34
  24. data/spec/support/app/controllers/application_controller.rb +2 -0
  25. data/spec/support/app/models/account.rb +2 -0
  26. data/spec/{resources → support/app/models}/user.rb +1 -1
  27. data/spec/{resources → support/app}/views/dashboard/index.erb +0 -0
  28. data/spec/{resources → support/app}/views/session/new.erb +0 -0
  29. data/spec/support/config/boot.rb +14 -0
  30. data/spec/support/config/database.yml +3 -0
  31. data/spec/support/config/routes.rb +4 -0
  32. data/{generators/simple_auth/templates/simple_auth.rb → templates/initializer.rb} +5 -4
  33. metadata +47 -21
  34. data/generators/simple_auth/USAGE +0 -5
  35. data/generators/simple_auth/simple_auth_generator.rb +0 -7
  36. data/init.rb +0 -1
  37. data/spec/resources/controllers.rb +0 -35
  38. data/spec/simple_auth/action_controller_spec.rb +0 -117
metadata CHANGED
@@ -3,10 +3,10 @@ name: simple_auth
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
+ - 1
6
7
  - 0
7
8
  - 1
8
- - 8
9
- version: 0.1.8
9
+ version: 1.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nando Vieira
@@ -14,13 +14,25 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-09 00:00:00 -03:00
17
+ date: 2010-10-12 00:00:00 -03:00
18
18
  default_executable:
19
- dependencies: []
20
-
21
- description: |
22
- When Authlogic & Devise are just too much.
23
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rails
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 3
30
+ - 0
31
+ - 0
32
+ version: 3.0.0
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: When Authlogic & Devise are just too much.
24
36
  email: fnando.vieira@gmail.com
25
37
  executables: []
26
38
 
@@ -29,33 +41,41 @@ extensions: []
29
41
  extra_rdoc_files:
30
42
  - README.markdown
31
43
  files:
44
+ - .gitignore
45
+ - .rspec
46
+ - Gemfile
47
+ - Gemfile.lock
32
48
  - README.markdown
33
49
  - Rakefile
34
50
  - config/locales/en.yml
35
51
  - config/locales/pt.yml
36
- - generators/simple_auth/USAGE
37
- - generators/simple_auth/simple_auth_generator.rb
38
- - generators/simple_auth/templates/simple_auth.rb
39
- - init.rb
40
52
  - lib/simple_auth.rb
41
53
  - lib/simple_auth/action_controller.rb
42
54
  - lib/simple_auth/active_record.rb
43
55
  - lib/simple_auth/config.rb
56
+ - lib/simple_auth/generator.rb
44
57
  - lib/simple_auth/helper.rb
58
+ - lib/simple_auth/railtie.rb
45
59
  - lib/simple_auth/session.rb
46
60
  - lib/simple_auth/version.rb
47
61
  - simple_auth.gemspec
48
- - spec/resources/controllers.rb
49
- - spec/resources/user.rb
50
- - spec/resources/views/dashboard/index.erb
51
- - spec/resources/views/session/new.erb
62
+ - spec/controllers/redirect_logged_user_spec.rb
63
+ - spec/controllers/require_logged_user_spec.rb
52
64
  - spec/schema.rb
53
- - spec/simple_auth/action_controller_spec.rb
54
65
  - spec/simple_auth/active_record_spec.rb
55
66
  - spec/simple_auth/config_spec.rb
56
67
  - spec/simple_auth/helper_spec.rb
57
68
  - spec/simple_auth/session_spec.rb
58
69
  - spec/spec_helper.rb
70
+ - spec/support/app/controllers/application_controller.rb
71
+ - spec/support/app/models/account.rb
72
+ - spec/support/app/models/user.rb
73
+ - spec/support/app/views/dashboard/index.erb
74
+ - spec/support/app/views/session/new.erb
75
+ - spec/support/config/boot.rb
76
+ - spec/support/config/database.yml
77
+ - spec/support/config/routes.rb
78
+ - templates/initializer.rb
59
79
  has_rdoc: true
60
80
  homepage: http://github.com/fnando/simple_auth
61
81
  licenses: []
@@ -66,6 +86,7 @@ rdoc_options:
66
86
  require_paths:
67
87
  - lib
68
88
  required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
69
90
  requirements:
70
91
  - - ">="
71
92
  - !ruby/object:Gem::Version
@@ -73,6 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
94
  - 0
74
95
  version: "0"
75
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
76
98
  requirements:
77
99
  - - ">="
78
100
  - !ruby/object:Gem::Version
@@ -82,17 +104,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
104
  requirements: []
83
105
 
84
106
  rubyforge_project:
85
- rubygems_version: 1.3.6
107
+ rubygems_version: 1.3.7
86
108
  signing_key:
87
109
  specification_version: 3
88
110
  summary: A simple authentication system for Rails apps
89
111
  test_files:
90
- - spec/resources/controllers.rb
91
- - spec/resources/user.rb
112
+ - spec/controllers/redirect_logged_user_spec.rb
113
+ - spec/controllers/require_logged_user_spec.rb
92
114
  - spec/schema.rb
93
- - spec/simple_auth/action_controller_spec.rb
94
115
  - spec/simple_auth/active_record_spec.rb
95
116
  - spec/simple_auth/config_spec.rb
96
117
  - spec/simple_auth/helper_spec.rb
97
118
  - spec/simple_auth/session_spec.rb
98
119
  - spec/spec_helper.rb
120
+ - spec/support/app/controllers/application_controller.rb
121
+ - spec/support/app/models/account.rb
122
+ - spec/support/app/models/user.rb
123
+ - spec/support/config/boot.rb
124
+ - spec/support/config/routes.rb
@@ -1,5 +0,0 @@
1
- Description:
2
- Create an initializer file for SimpleAuth library.
3
-
4
- Examples:
5
- script/generate simple_auth
@@ -1,7 +0,0 @@
1
- class SimpleAuthGenerator < Rails::Generator::Base
2
- def manifest
3
- record do |m|
4
- m.file "simple_auth.rb", "config/initializers/simple_auth.rb"
5
- end
6
- end
7
- end
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require "simple_auth"
@@ -1,35 +0,0 @@
1
- # Add routes
2
- if ENV["TARGET"] == "rails3"
3
- # Rails.application.routes.add_route "/:controller/:action/:id"
4
- else
5
- ActionController::Routing::Routes.add_route "/:controller/:action/:id"
6
- ActionController::Routing::Routes.add_named_route :login, "/login", :controller => "session", :action => "new"
7
- ActionController::Routing::Routes.add_named_route :dashboard, "/dashboard", :controller => "dashboard", :action => "index"
8
- end
9
-
10
- class SampleController < ActionController::Base
11
- end
12
-
13
- class SessionController < ActionController::Base
14
- redirect_logged_user :to => {:controller => "dashboard"}
15
-
16
- def new
17
- @user_session = SimpleAuth::Session.new
18
- end
19
-
20
- def create
21
- @user_session = SimpleAuth::Session.new(params[:session])
22
-
23
- if @user_session.save
24
- redirect_to session.delete(:return_to) || dashboard_path
25
- else
26
- flash[:alert] = "Invalid login/password."
27
- render :new
28
- end
29
- end
30
- end
31
-
32
- class DashboardController < ActionController::Base
33
- def index
34
- end
35
- end
@@ -1,117 +0,0 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
2
-
3
- describe DashboardController, :type => :controller do
4
- before do
5
- @user = User.create(
6
- :login => "johndoe",
7
- :email => "john@doe.com",
8
- :password => "test",
9
- :password_confirmation => "test"
10
- )
11
- end
12
-
13
- describe "require_logged_user" do
14
- context "unlogged user" do
15
- before do
16
- if ENV["TARGET"] != "rails3"
17
- DashboardController.filter_chain.pop if DashboardController.filter_chain.count > 1
18
- end
19
- end
20
-
21
- context "return to" do
22
- before do
23
- DashboardController.require_logged_user :to => "/login"
24
- end
25
-
26
- it "should set return to" do
27
- get :index
28
- session[:return_to].should == "/dashboard"
29
- end
30
-
31
- it "should set warning message" do
32
- get :index
33
- flash[:alert].should == "You need to be logged"
34
- end
35
-
36
- it "should redirect when user is not authorized" do
37
- @controller.should_receive(:logged_in?).and_return(true)
38
- @controller.should_receive(:authorized?).and_return(false)
39
-
40
- get :index
41
- response.should redirect_to("/login")
42
- end
43
- end
44
-
45
- it "should be redirected [hash]" do
46
- DashboardController.require_logged_user :to => {:controller => "session", :action => "new"}
47
-
48
- get :index
49
-
50
- if ENV["TARGET"] == "rails3"
51
- response.should redirect_to("/login")
52
- else
53
- response.should redirect_to("/session/new")
54
- end
55
- end
56
-
57
- it "should be redirected [block]" do
58
- DashboardController.require_logged_user :to => proc { login_path }
59
-
60
- get :index
61
- response.should redirect_to("/login")
62
- end
63
-
64
- it "should be redirected [string]" do
65
- DashboardController.require_logged_user :to => "/login"
66
-
67
- get :index
68
- response.should redirect_to("/login")
69
- end
70
- end
71
-
72
- context "logged user" do
73
- before do
74
- session[:record_id] = @user.id
75
- get :index
76
- end
77
-
78
- it "should render page" do
79
- response.should render_template(:index)
80
- end
81
- end
82
- end
83
- end
84
-
85
- describe SessionController, :type => :controller do
86
- before do
87
- @user = User.create(
88
- :login => "johndoe",
89
- :email => "john@doe.com",
90
- :password => "test",
91
- :password_confirmation => "test"
92
- )
93
- end
94
-
95
- describe "redirect_logged_users" do
96
- context "unlogged user" do
97
- before do
98
- get :new
99
- end
100
-
101
- it "should render page" do
102
- response.should render_template(:new)
103
- end
104
- end
105
-
106
- context "logged user" do
107
- before do
108
- session[:record_id] = @user.id
109
- get :new
110
- end
111
-
112
- it "should be redirected" do
113
- response.should redirect_to("/dashboard")
114
- end
115
- end
116
- end
117
- end