Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
59704f48
Commit
59704f48
authored
Oct 20, 2011
by
Aleksei Kvitinskii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended user profile with social fields
parent
9ad444f0
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
93 additions
and
4 deletions
+93
-4
app/controllers/profile_controller.rb
app/controllers/profile_controller.rb
+6
-0
app/models/user.rb
app/models/user.rb
+5
-1
app/views/admin/users/_form.html.haml
app/views/admin/users/_form.html.haml
+15
-2
app/views/admin/users/show.html.haml
app/views/admin/users/show.html.haml
+11
-0
app/views/profile/show.html.haml
app/views/profile/show.html.haml
+25
-0
config/routes.rb
config/routes.rb
+1
-0
db/migrate/20111019212429_add_social_to_user.rb
db/migrate/20111019212429_add_social_to_user.rb
+7
-0
db/schema.rb
db/schema.rb
+4
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+3
-0
spec/requests/profile_spec.rb
spec/requests/profile_spec.rb
+16
-0
No files found.
app/controllers/profile_controller.rb
View file @
59704f48
...
@@ -3,6 +3,12 @@ class ProfileController < ApplicationController
...
@@ -3,6 +3,12 @@ class ProfileController < ApplicationController
@user
=
current_user
@user
=
current_user
end
end
def
social_update
@user
=
current_user
@user
.
update_attributes
(
params
[
:user
])
redirect_to
[
:profile
]
end
def
password
def
password
@user
=
current_user
@user
=
current_user
end
end
...
...
app/models/user.rb
View file @
59704f48
...
@@ -5,7 +5,8 @@ class User < ActiveRecord::Base
...
@@ -5,7 +5,8 @@ class User < ActiveRecord::Base
:recoverable
,
:rememberable
,
:trackable
,
:validatable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
# Setup accessible (or protected) attributes for your model
# Setup accessible (or protected) attributes for your model
attr_accessible
:email
,
:password
,
:password_confirmation
,
:remember_me
,
:name
,
:projects_limit
attr_accessible
:email
,
:password
,
:password_confirmation
,
:remember_me
,
:name
,
:projects_limit
,
:skype
,
:linkedin
,
:twitter
has_many
:users_projects
,
:dependent
=>
:destroy
has_many
:users_projects
,
:dependent
=>
:destroy
has_many
:projects
,
:through
=>
:users_projects
has_many
:projects
,
:through
=>
:users_projects
...
@@ -58,5 +59,8 @@ end
...
@@ -58,5 +59,8 @@ end
# name :string(255)
# name :string(255)
# admin :boolean default(FALSE), not null
# admin :boolean default(FALSE), not null
# projects_limit :integer
# projects_limit :integer
# skype :string
# linkedin :string
# twitter :string
#
#
app/views/admin/users/_form.html.haml
View file @
59704f48
...
@@ -25,13 +25,26 @@
...
@@ -25,13 +25,26 @@
=
f
.
label
:password_confirmation
=
f
.
label
:password_confirmation
%br
%br
=
f
.
password_field
:password_confirmation
=
f
.
password_field
:password_confirmation
.span-11
.field.prepend-top
.field.prepend-top.append-bottom
=
f
.
check_box
:admin
=
f
.
check_box
:admin
=
f
.
label
:admin
=
f
.
label
:admin
.span-11
.field.prepend-top
.field.prepend-top
=
f
.
text_field
:projects_limit
,
:class
=>
"small_input"
=
f
.
text_field
:projects_limit
,
:class
=>
"small_input"
=
f
.
label
:projects_limit
=
f
.
label
:projects_limit
.field
=
f
.
label
:skype
%br
=
f
.
text_field
:skype
.field
=
f
.
label
:linkedin
%br
=
f
.
text_field
:linkedin
.field
=
f
.
label
:twitter
%br
=
f
.
text_field
:twitter
.clear
.clear
%br
%br
.actions
.actions
...
...
app/views/admin/users/show.html.haml
View file @
59704f48
...
@@ -14,6 +14,17 @@
...
@@ -14,6 +14,17 @@
%b
Projects limit:
%b
Projects limit:
=
@admin_user
.
projects_limit
=
@admin_user
.
projects_limit
%p
%b
Skype:
=
@admin_user
.
skype
%p
%b
LinkedIn:
=
@admin_user
.
linkedin
%p
%b
Twitter:
=
@admin_user
.
twitter
.clear
.clear
=
link_to
'Edit'
,
edit_admin_user_path
(
@admin_user
)
=
link_to
'Edit'
,
edit_admin_user_path
(
@admin_user
)
\|
\|
...
...
app/views/profile/show.html.haml
View file @
59704f48
...
@@ -6,3 +6,28 @@
...
@@ -6,3 +6,28 @@
%p
%p
%b
Email:
%b
Email:
=
@user
.
email
=
@user
.
email
%br
=
form_for
@user
,
:url
=>
profile_edit_path
,
:method
=>
:put
do
|
f
|
-
if
@user
.
errors
.
any?
#error_explanation
%ul
-
@user
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
.div
=
f
.
label
:skype
%br
=
f
.
text_field
:skype
.div
=
f
.
label
:linkedin
%br
=
f
.
text_field
:linkedin
.div
=
f
.
label
:twitter
%br
=
f
.
text_field
:twitter
.actions
=
f
.
submit
'Save'
,
:class
=>
"lbutton vm"
config/routes.rb
View file @
59704f48
...
@@ -13,6 +13,7 @@ Gitlab::Application.routes.draw do
...
@@ -13,6 +13,7 @@ Gitlab::Application.routes.draw do
get
"errors/gitosis"
get
"errors/gitosis"
get
"profile/password"
,
:to
=>
"profile#password"
get
"profile/password"
,
:to
=>
"profile#password"
put
"profile/password"
,
:to
=>
"profile#password_update"
put
"profile/password"
,
:to
=>
"profile#password_update"
put
"profile/edit"
,
:to
=>
"profile#social_update"
get
"profile"
,
:to
=>
"profile#show"
get
"profile"
,
:to
=>
"profile#show"
#get "profile/:id", :to => "profile#show"
#get "profile/:id", :to => "profile#show"
...
...
db/migrate/20111019212429_add_social_to_user.rb
0 → 100644
View file @
59704f48
class
AddSocialToUser
<
ActiveRecord
::
Migration
def
change
add_column
:users
,
:skype
,
:string
add_column
:users
,
:linkedin
,
:string
add_column
:users
,
:twitter
,
:string
end
end
db/schema.rb
View file @
59704f48
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended to check this file into your version control system.
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
2011101
6195506
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
2011101
9212429
)
do
create_table
"issues"
,
:force
=>
true
do
|
t
|
create_table
"issues"
,
:force
=>
true
do
|
t
|
t
.
string
"title"
t
.
string
"title"
...
@@ -82,6 +82,9 @@ ActiveRecord::Schema.define(:version => 20111016195506) do
...
@@ -82,6 +82,9 @@ ActiveRecord::Schema.define(:version => 20111016195506) do
t
.
string
"name"
t
.
string
"name"
t
.
boolean
"admin"
,
:default
=>
false
,
:null
=>
false
t
.
boolean
"admin"
,
:default
=>
false
,
:null
=>
false
t
.
integer
"projects_limit"
,
:default
=>
10
t
.
integer
"projects_limit"
,
:default
=>
10
t
.
string
"skype"
t
.
string
"linkedin"
t
.
string
"twitter"
end
end
add_index
"users"
,
[
"email"
],
:name
=>
"index_users_on_email"
,
:unique
=>
true
add_index
"users"
,
[
"email"
],
:name
=>
"index_users_on_email"
,
:unique
=>
true
...
...
spec/models/user_spec.rb
View file @
59704f48
...
@@ -39,5 +39,8 @@ end
...
@@ -39,5 +39,8 @@ end
# name :string(255)
# name :string(255)
# admin :boolean default(FALSE), not null
# admin :boolean default(FALSE), not null
# projects_limit :integer
# projects_limit :integer
# skype :string
# linkedin :string
# twitter :string
#
#
spec/requests/profile_spec.rb
View file @
59704f48
...
@@ -14,6 +14,22 @@ describe "Profile" do
...
@@ -14,6 +14,22 @@ describe "Profile" do
it
{
page
.
should
have_content
(
@user
.
email
)
}
it
{
page
.
should
have_content
(
@user
.
email
)
}
end
end
describe
"Profile update"
do
before
do
visit
profile_path
fill_in
"user_skype"
,
:with
=>
"testskype"
fill_in
"user_linkedin"
,
:with
=>
"testlinkedin"
fill_in
"user_twitter"
,
:with
=>
"testtwitter"
click_button
"Save"
@user
.
reload
end
it
{
@user
.
skype
.
should
==
'testskype'
}
it
{
@user
.
linkedin
.
should
==
'testlinkedin'
}
it
{
@user
.
twitter
.
should
==
'testtwitter'
}
end
describe
"Password update"
do
describe
"Password update"
do
before
do
before
do
visit
profile_password_path
visit
profile_password_path
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment