Commit 59704f481e742710fff32c733047eb84478e505e
1 parent
9ad444f0
Exists in
master
and in
4 other branches
extended user profile with social fields
Showing
10 changed files
with
93 additions
and
4 deletions
Show diff stats
app/controllers/profile_controller.rb
... | ... | @@ -3,6 +3,12 @@ class ProfileController < ApplicationController |
3 | 3 | @user = current_user |
4 | 4 | end |
5 | 5 | |
6 | + def social_update | |
7 | + @user = current_user | |
8 | + @user.update_attributes(params[:user]) | |
9 | + redirect_to [:profile] | |
10 | + end | |
11 | + | |
6 | 12 | def password |
7 | 13 | @user = current_user |
8 | 14 | end | ... | ... |
app/models/user.rb
... | ... | @@ -5,7 +5,8 @@ class User < ActiveRecord::Base |
5 | 5 | :recoverable, :rememberable, :trackable, :validatable |
6 | 6 | |
7 | 7 | # Setup accessible (or protected) attributes for your model |
8 | - attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :projects_limit | |
8 | + attr_accessible :email, :password, :password_confirmation, :remember_me, | |
9 | + :name, :projects_limit, :skype, :linkedin, :twitter | |
9 | 10 | |
10 | 11 | has_many :users_projects, :dependent => :destroy |
11 | 12 | has_many :projects, :through => :users_projects |
... | ... | @@ -58,5 +59,8 @@ end |
58 | 59 | # name :string(255) |
59 | 60 | # admin :boolean default(FALSE), not null |
60 | 61 | # projects_limit :integer |
62 | +# skype :string | |
63 | +# linkedin :string | |
64 | +# twitter :string | |
61 | 65 | # |
62 | 66 | ... | ... |
app/views/admin/users/_form.html.haml
... | ... | @@ -25,13 +25,26 @@ |
25 | 25 | = f.label :password_confirmation |
26 | 26 | %br |
27 | 27 | = f.password_field :password_confirmation |
28 | - .span-11 | |
29 | - .field.prepend-top.append-bottom | |
28 | + .field.prepend-top | |
30 | 29 | = f.check_box :admin |
31 | 30 | = f.label :admin |
31 | + .span-11 | |
32 | 32 | .field.prepend-top |
33 | 33 | = f.text_field :projects_limit, :class => "small_input" |
34 | 34 | = f.label :projects_limit |
35 | + | |
36 | + .field | |
37 | + = f.label :skype | |
38 | + %br | |
39 | + = f.text_field :skype | |
40 | + .field | |
41 | + = f.label :linkedin | |
42 | + %br | |
43 | + = f.text_field :linkedin | |
44 | + .field | |
45 | + = f.label :twitter | |
46 | + %br | |
47 | + = f.text_field :twitter | |
35 | 48 | .clear |
36 | 49 | %br |
37 | 50 | .actions | ... | ... |
app/views/admin/users/show.html.haml
... | ... | @@ -14,6 +14,17 @@ |
14 | 14 | %b Projects limit: |
15 | 15 | = @admin_user.projects_limit |
16 | 16 | |
17 | + %p | |
18 | + %b Skype: | |
19 | + = @admin_user.skype | |
20 | + %p | |
21 | + %b LinkedIn: | |
22 | + = @admin_user.linkedin | |
23 | + %p | |
24 | + %b Twitter: | |
25 | + = @admin_user.twitter | |
26 | + | |
27 | + | |
17 | 28 | .clear |
18 | 29 | = link_to 'Edit', edit_admin_user_path(@admin_user) |
19 | 30 | \| | ... | ... |
app/views/profile/show.html.haml
... | ... | @@ -6,3 +6,28 @@ |
6 | 6 | %p |
7 | 7 | %b Email: |
8 | 8 | = @user.email |
9 | + | |
10 | +%br | |
11 | + | |
12 | += form_for @user, :url => profile_edit_path, :method => :put do |f| | |
13 | + -if @user.errors.any? | |
14 | + #error_explanation | |
15 | + %ul | |
16 | + - @user.errors.full_messages.each do |msg| | |
17 | + %li= msg | |
18 | + | |
19 | + .div | |
20 | + = f.label :skype | |
21 | + %br | |
22 | + = f.text_field :skype | |
23 | + .div | |
24 | + = f.label :linkedin | |
25 | + %br | |
26 | + = f.text_field :linkedin | |
27 | + .div | |
28 | + = f.label :twitter | |
29 | + %br | |
30 | + = f.text_field :twitter | |
31 | + .actions | |
32 | + = f.submit 'Save', :class => "lbutton vm" | |
33 | + | ... | ... |
config/routes.rb
... | ... | @@ -13,6 +13,7 @@ Gitlab::Application.routes.draw do |
13 | 13 | get "errors/gitosis" |
14 | 14 | get "profile/password", :to => "profile#password" |
15 | 15 | put "profile/password", :to => "profile#password_update" |
16 | + put "profile/edit", :to => "profile#social_update" | |
16 | 17 | get "profile", :to => "profile#show" |
17 | 18 | #get "profile/:id", :to => "profile#show" |
18 | 19 | ... | ... |
db/schema.rb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | # |
12 | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | |
14 | -ActiveRecord::Schema.define(:version => 20111016195506) do | |
14 | +ActiveRecord::Schema.define(:version => 20111019212429) do | |
15 | 15 | |
16 | 16 | create_table "issues", :force => true do |t| |
17 | 17 | t.string "title" |
... | ... | @@ -82,6 +82,9 @@ ActiveRecord::Schema.define(:version => 20111016195506) do |
82 | 82 | t.string "name" |
83 | 83 | t.boolean "admin", :default => false, :null => false |
84 | 84 | t.integer "projects_limit", :default => 10 |
85 | + t.string "skype" | |
86 | + t.string "linkedin" | |
87 | + t.string "twitter" | |
85 | 88 | end |
86 | 89 | |
87 | 90 | add_index "users", ["email"], :name => "index_users_on_email", :unique => true | ... | ... |
spec/models/user_spec.rb
spec/requests/profile_spec.rb
... | ... | @@ -14,6 +14,22 @@ describe "Profile" do |
14 | 14 | it { page.should have_content(@user.email) } |
15 | 15 | end |
16 | 16 | |
17 | + describe "Profile update" do | |
18 | + before do | |
19 | + visit profile_path | |
20 | + fill_in "user_skype", :with => "testskype" | |
21 | + fill_in "user_linkedin", :with => "testlinkedin" | |
22 | + fill_in "user_twitter", :with => "testtwitter" | |
23 | + click_button "Save" | |
24 | + @user.reload | |
25 | + end | |
26 | + | |
27 | + it { @user.skype.should == 'testskype' } | |
28 | + it { @user.linkedin.should == 'testlinkedin' } | |
29 | + it { @user.twitter.should == 'testtwitter' } | |
30 | + end | |
31 | + | |
32 | + | |
17 | 33 | describe "Password update" do |
18 | 34 | before do |
19 | 35 | visit profile_password_path | ... | ... |