as_user 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +8 -0
- data/{LICENSE → MIT-LICENSE} +2 -4
- data/README.rdoc +3 -0
- data/Rakefile +39 -1
- data/app/assets/javascripts/as_user/application.js +15 -0
- data/app/assets/stylesheets/as_user/application.css +13 -0
- data/app/controllers/as_user/application_controller.rb +4 -0
- data/app/controllers/as_user/users_controller.rb +87 -0
- data/app/helpers/as_user/application_helper.rb +4 -0
- data/app/helpers/as_user/users_helper.rb +4 -0
- data/app/models/user.rb +15 -0
- data/app/views/as_user/users/_form.html.erb +29 -0
- data/app/views/as_user/users/edit.html.erb +6 -0
- data/app/views/as_user/users/index.html.erb +27 -0
- data/app/views/as_user/users/new.html.erb +5 -0
- data/app/views/as_user/users/show.html.erb +20 -0
- data/app/views/layouts/as_user/application.html.erb +14 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20121213033825_create_as_user_users.rb +12 -0
- data/lib/as_user.rb +1 -7
- data/lib/as_user/engine.rb +5 -0
- data/lib/as_user/version.rb +1 -1
- data/lib/tasks/as_user_tasks.rake +4 -0
- data/test/as_user_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +55 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/db/schema.rb +26 -0
- data/test/dummy/log/development.log +52 -0
- data/test/dummy/log/test.log +2182 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/fixtures/as_user/users.yml +11 -0
- data/test/functional/as_user/users_controller_test.rb +53 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/as_user/user_test.rb +58 -0
- data/test/unit/helpers/as_user/users_helper_test.rb +6 -0
- metadata +154 -15
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/README.md +0 -29
- data/as_user.gemspec +0 -17
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -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'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module AsUser
|
4
|
+
class UsersControllerTest < ActionController::TestCase
|
5
|
+
=begin
|
6
|
+
setup do
|
7
|
+
@user = users(:one)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "should get index" do
|
11
|
+
get :index
|
12
|
+
assert_response :success
|
13
|
+
assert_not_nil assigns(:users)
|
14
|
+
end
|
15
|
+
|
16
|
+
test "should get new" do
|
17
|
+
get :new
|
18
|
+
assert_response :success
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should create user" do
|
22
|
+
assert_difference('User.count') do
|
23
|
+
post :create, user: { email: @user.email, name: @user.name, password_digest: @user.password_digest }
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_redirected_to user_path(assigns(:user))
|
27
|
+
end
|
28
|
+
|
29
|
+
test "should show user" do
|
30
|
+
get :show, id: @user
|
31
|
+
assert_response :success
|
32
|
+
end
|
33
|
+
|
34
|
+
test "should get edit" do
|
35
|
+
get :edit, id: @user
|
36
|
+
assert_response :success
|
37
|
+
end
|
38
|
+
|
39
|
+
test "should update user" do
|
40
|
+
put :update, id: @user, user: { email: @user.email, name: @user.name, password_digest: @user.password_digest }
|
41
|
+
assert_redirected_to user_path(assigns(:user))
|
42
|
+
end
|
43
|
+
|
44
|
+
test "should destroy user" do
|
45
|
+
assert_difference('User.count', -1) do
|
46
|
+
delete :destroy, id: @user
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_redirected_to users_path
|
50
|
+
end
|
51
|
+
=end
|
52
|
+
end
|
53
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
module AsUser
|
5
|
+
class UserTest < ActiveSupport::TestCase
|
6
|
+
setup do
|
7
|
+
end
|
8
|
+
|
9
|
+
teardown do
|
10
|
+
User.destroy_all
|
11
|
+
end
|
12
|
+
|
13
|
+
test "only save valid user" do
|
14
|
+
email = "dummy#{Time.now.to_f}@domain.com"
|
15
|
+
user = User.new(email: email, name: "dummy", password: "dummy",password_confirmation: "dummy")
|
16
|
+
assert user.save
|
17
|
+
|
18
|
+
# without name
|
19
|
+
user = User.new(email: "dummy#{Time.now.to_f}@domain.com", password: "dummy",password_confirmation: "dummy")
|
20
|
+
assert !user.save
|
21
|
+
|
22
|
+
# name too long
|
23
|
+
user = User.new(email: "dummy#{Time.now.to_f}@domain.com", name: "abcdefghigabcdefghigabcdefghigabcdefghigabcdefghig", password: "dummy",password_confirmation: "dummy")
|
24
|
+
assert !user.save
|
25
|
+
user = User.new(email: "dummy#{Time.now.to_f}@domain.com", name: "abcdefghigabcdefghigabcdefghigabcdefghigabcdefghi", password: "dummy",password_confirmation: "dummy")
|
26
|
+
assert user.save
|
27
|
+
|
28
|
+
user = User.new(email: "dummy#{Time.now.to_f}@domain.com", name: "一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十", password: "dummy",password_confirmation: "dummy")
|
29
|
+
assert !user.save
|
30
|
+
user = User.new(email: "dummy#{Time.now.to_f}@domain.com", name: "一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九", password: "dummy",password_confirmation: "dummy")
|
31
|
+
assert user.save
|
32
|
+
|
33
|
+
# email invalid
|
34
|
+
user = User.new(email: "dummy#{Time.now.to_f}@domain", name: "dummy", password: "dummy",password_confirmation: "dummy")
|
35
|
+
assert !user.save
|
36
|
+
user = User.new(email: "dummy", name: "dummy", password: "dummy",password_confirmation: "dummy")
|
37
|
+
assert !user.save
|
38
|
+
user = User.new(name: "dummy", password: "dummy",password_confirmation: "dummy")
|
39
|
+
assert !user.save
|
40
|
+
user = User.new(email: email, name: "dummy", password: "dummy",password_confirmation: "dummy")
|
41
|
+
assert !user.save
|
42
|
+
assert user.errors.messages[:email].include? "has already been taken"
|
43
|
+
|
44
|
+
# invalid password
|
45
|
+
user = User.new(email: "dummy#{Time.now.to_f}@domain.com", name: "dummy", password: "du",password_confirmation: "dummy")
|
46
|
+
assert !user.save
|
47
|
+
user = User.new(email: "dummy#{Time.now.to_f}@domain.com", name: "dummy", password_confirmation: "dummy")
|
48
|
+
assert !user.save
|
49
|
+
user = User.new(email: "dummy#{Time.now.to_f}@domain.com", name: "dummy", password: "dummy")
|
50
|
+
assert !user.save
|
51
|
+
user = User.new(email: "dummy#{Time.now.to_f}@domain.com", name: "dummy", password: "dummy",password_confirmation: "dummz")
|
52
|
+
assert !user.save
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: as_user
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,25 +9,125 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
|
12
|
+
date: 2012-12-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.9
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.9
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bcrypt-ruby
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: pg
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: the most basic features
|
16
63
|
email:
|
17
64
|
- as181920@hotmail.com
|
18
65
|
executables: []
|
19
66
|
extensions: []
|
20
67
|
extra_rdoc_files: []
|
21
68
|
files:
|
22
|
-
- .
|
23
|
-
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
-
|
27
|
-
- as_user.
|
28
|
-
-
|
69
|
+
- app/controllers/as_user/application_controller.rb
|
70
|
+
- app/controllers/as_user/users_controller.rb
|
71
|
+
- app/helpers/as_user/users_helper.rb
|
72
|
+
- app/helpers/as_user/application_helper.rb
|
73
|
+
- app/views/as_user/users/show.html.erb
|
74
|
+
- app/views/as_user/users/index.html.erb
|
75
|
+
- app/views/as_user/users/_form.html.erb
|
76
|
+
- app/views/as_user/users/edit.html.erb
|
77
|
+
- app/views/as_user/users/new.html.erb
|
78
|
+
- app/views/layouts/as_user/application.html.erb
|
79
|
+
- app/models/user.rb
|
80
|
+
- app/assets/javascripts/as_user/application.js
|
81
|
+
- app/assets/stylesheets/as_user/application.css
|
82
|
+
- config/routes.rb
|
83
|
+
- db/migrate/20121213033825_create_as_user_users.rb
|
29
84
|
- lib/as_user/version.rb
|
30
|
-
|
85
|
+
- lib/as_user/engine.rb
|
86
|
+
- lib/as_user.rb
|
87
|
+
- lib/tasks/as_user_tasks.rake
|
88
|
+
- MIT-LICENSE
|
89
|
+
- Rakefile
|
90
|
+
- README.rdoc
|
91
|
+
- CHANGELOG.rdoc
|
92
|
+
- test/functional/as_user/users_controller_test.rb
|
93
|
+
- test/unit/helpers/as_user/users_helper_test.rb
|
94
|
+
- test/unit/as_user/user_test.rb
|
95
|
+
- test/as_user_test.rb
|
96
|
+
- test/integration/navigation_test.rb
|
97
|
+
- test/dummy/app/controllers/application_controller.rb
|
98
|
+
- test/dummy/app/helpers/application_helper.rb
|
99
|
+
- test/dummy/app/views/layouts/application.html.erb
|
100
|
+
- test/dummy/app/assets/javascripts/application.js
|
101
|
+
- test/dummy/app/assets/stylesheets/application.css
|
102
|
+
- test/dummy/Rakefile
|
103
|
+
- test/dummy/public/404.html
|
104
|
+
- test/dummy/public/favicon.ico
|
105
|
+
- test/dummy/public/422.html
|
106
|
+
- test/dummy/public/500.html
|
107
|
+
- test/dummy/README.rdoc
|
108
|
+
- test/dummy/config.ru
|
109
|
+
- test/dummy/script/rails
|
110
|
+
- test/dummy/db/schema.rb
|
111
|
+
- test/dummy/log/test.log
|
112
|
+
- test/dummy/log/development.log
|
113
|
+
- test/dummy/config/database.yml
|
114
|
+
- test/dummy/config/application.rb
|
115
|
+
- test/dummy/config/initializers/mime_types.rb
|
116
|
+
- test/dummy/config/initializers/session_store.rb
|
117
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
118
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
119
|
+
- test/dummy/config/initializers/secret_token.rb
|
120
|
+
- test/dummy/config/initializers/inflections.rb
|
121
|
+
- test/dummy/config/environments/production.rb
|
122
|
+
- test/dummy/config/environments/test.rb
|
123
|
+
- test/dummy/config/environments/development.rb
|
124
|
+
- test/dummy/config/boot.rb
|
125
|
+
- test/dummy/config/locales/en.yml
|
126
|
+
- test/dummy/config/routes.rb
|
127
|
+
- test/dummy/config/environment.rb
|
128
|
+
- test/test_helper.rb
|
129
|
+
- test/fixtures/as_user/users.yml
|
130
|
+
homepage: https://github.com/as181920/as_user
|
31
131
|
licenses: []
|
32
132
|
post_install_message:
|
33
133
|
rdoc_options: []
|
@@ -50,5 +150,44 @@ rubyforge_project:
|
|
50
150
|
rubygems_version: 1.8.24
|
51
151
|
signing_key:
|
52
152
|
specification_version: 3
|
53
|
-
summary: basic user handling
|
54
|
-
test_files:
|
153
|
+
summary: basic user handling and authentication solution for rails
|
154
|
+
test_files:
|
155
|
+
- test/functional/as_user/users_controller_test.rb
|
156
|
+
- test/unit/helpers/as_user/users_helper_test.rb
|
157
|
+
- test/unit/as_user/user_test.rb
|
158
|
+
- test/as_user_test.rb
|
159
|
+
- test/integration/navigation_test.rb
|
160
|
+
- test/dummy/app/controllers/application_controller.rb
|
161
|
+
- test/dummy/app/helpers/application_helper.rb
|
162
|
+
- test/dummy/app/views/layouts/application.html.erb
|
163
|
+
- test/dummy/app/assets/javascripts/application.js
|
164
|
+
- test/dummy/app/assets/stylesheets/application.css
|
165
|
+
- test/dummy/Rakefile
|
166
|
+
- test/dummy/public/404.html
|
167
|
+
- test/dummy/public/favicon.ico
|
168
|
+
- test/dummy/public/422.html
|
169
|
+
- test/dummy/public/500.html
|
170
|
+
- test/dummy/README.rdoc
|
171
|
+
- test/dummy/config.ru
|
172
|
+
- test/dummy/script/rails
|
173
|
+
- test/dummy/db/schema.rb
|
174
|
+
- test/dummy/log/test.log
|
175
|
+
- test/dummy/log/development.log
|
176
|
+
- test/dummy/config/database.yml
|
177
|
+
- test/dummy/config/application.rb
|
178
|
+
- test/dummy/config/initializers/mime_types.rb
|
179
|
+
- test/dummy/config/initializers/session_store.rb
|
180
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
181
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
182
|
+
- test/dummy/config/initializers/secret_token.rb
|
183
|
+
- test/dummy/config/initializers/inflections.rb
|
184
|
+
- test/dummy/config/environments/production.rb
|
185
|
+
- test/dummy/config/environments/test.rb
|
186
|
+
- test/dummy/config/environments/development.rb
|
187
|
+
- test/dummy/config/boot.rb
|
188
|
+
- test/dummy/config/locales/en.yml
|
189
|
+
- test/dummy/config/routes.rb
|
190
|
+
- test/dummy/config/environment.rb
|
191
|
+
- test/test_helper.rb
|
192
|
+
- test/fixtures/as_user/users.yml
|
193
|
+
has_rdoc:
|