Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksei Kvitinskii <aleksei.kvitinskii@active.by>2011-10-20 02:34:05 +0400
committerAleksei Kvitinskii <aleksei.kvitinskii@active.by>2011-10-20 02:34:05 +0400
commit59704f481e742710fff32c733047eb84478e505e (patch)
treed837909ea9b6e1387c71de5ef2c2ae568323f28c
parent9ad444f02efbeb30365cdf7f23f9b2f846b45a03 (diff)
extended user profile with social fields
-rw-r--r--app/controllers/profile_controller.rb6
-rw-r--r--app/models/user.rb6
-rw-r--r--app/views/admin/users/_form.html.haml17
-rw-r--r--app/views/admin/users/show.html.haml11
-rw-r--r--app/views/profile/show.html.haml25
-rw-r--r--config/routes.rb1
-rw-r--r--db/migrate/20111019212429_add_social_to_user.rb7
-rw-r--r--db/schema.rb5
-rw-r--r--spec/models/user_spec.rb3
-rw-r--r--spec/requests/profile_spec.rb16
10 files changed, 93 insertions, 4 deletions
diff --git a/app/controllers/profile_controller.rb b/app/controllers/profile_controller.rb
index 666c6309dce..c8477729a92 100644
--- a/app/controllers/profile_controller.rb
+++ b/app/controllers/profile_controller.rb
@@ -3,6 +3,12 @@ class ProfileController < ApplicationController
@user = current_user
end
+ def social_update
+ @user = current_user
+ @user.update_attributes(params[:user])
+ redirect_to [:profile]
+ end
+
def password
@user = current_user
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 0972f006dbd..7736599e7eb 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -5,7 +5,8 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable
# 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 :projects, :through => :users_projects
@@ -58,5 +59,8 @@ end
# name :string(255)
# admin :boolean default(FALSE), not null
# projects_limit :integer
+# skype :string
+# linkedin :string
+# twitter :string
#
diff --git a/app/views/admin/users/_form.html.haml b/app/views/admin/users/_form.html.haml
index 17be416fa1d..aa9df298e11 100644
--- a/app/views/admin/users/_form.html.haml
+++ b/app/views/admin/users/_form.html.haml
@@ -25,13 +25,26 @@
= f.label :password_confirmation
%br
= f.password_field :password_confirmation
- .span-11
- .field.prepend-top.append-bottom
+ .field.prepend-top
= f.check_box :admin
= f.label :admin
+ .span-11
.field.prepend-top
= f.text_field :projects_limit, :class => "small_input"
= 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
%br
.actions
diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml
index b1d110bec27..aee73c38ee7 100644
--- a/app/views/admin/users/show.html.haml
+++ b/app/views/admin/users/show.html.haml
@@ -14,6 +14,17 @@
%b 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
= link_to 'Edit', edit_admin_user_path(@admin_user)
\|
diff --git a/app/views/profile/show.html.haml b/app/views/profile/show.html.haml
index 12737ba8143..ef23a1692a1 100644
--- a/app/views/profile/show.html.haml
+++ b/app/views/profile/show.html.haml
@@ -6,3 +6,28 @@
%p
%b 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"
+
diff --git a/config/routes.rb b/config/routes.rb
index 9ee3f0d06fc..8a40a8fef89 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -13,6 +13,7 @@ Gitlab::Application.routes.draw do
get "errors/gitosis"
get "profile/password", :to => "profile#password"
put "profile/password", :to => "profile#password_update"
+ put "profile/edit", :to => "profile#social_update"
get "profile", :to => "profile#show"
#get "profile/:id", :to => "profile#show"
diff --git a/db/migrate/20111019212429_add_social_to_user.rb b/db/migrate/20111019212429_add_social_to_user.rb
new file mode 100644
index 00000000000..b0ffe5366a4
--- /dev/null
+++ b/db/migrate/20111019212429_add_social_to_user.rb
@@ -0,0 +1,7 @@
+class AddSocialToUser < ActiveRecord::Migration
+ def change
+ add_column :users, :skype, :string
+ add_column :users, :linkedin, :string
+ add_column :users, :twitter, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index a819697640a..6408792f9ac 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111016195506) do
+ActiveRecord::Schema.define(:version => 20111019212429) do
create_table "issues", :force => true do |t|
t.string "title"
@@ -82,6 +82,9 @@ ActiveRecord::Schema.define(:version => 20111016195506) do
t.string "name"
t.boolean "admin", :default => false, :null => false
t.integer "projects_limit", :default => 10
+ t.string "skype"
+ t.string "linkedin"
+ t.string "twitter"
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 77abe2ca935..32fb90a317c 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -39,5 +39,8 @@ end
# name :string(255)
# admin :boolean default(FALSE), not null
# projects_limit :integer
+# skype :string
+# linkedin :string
+# twitter :string
#
diff --git a/spec/requests/profile_spec.rb b/spec/requests/profile_spec.rb
index 07fdc4abdc6..5838f63b40b 100644
--- a/spec/requests/profile_spec.rb
+++ b/spec/requests/profile_spec.rb
@@ -14,6 +14,22 @@ describe "Profile" do
it { page.should have_content(@user.email) }
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
before do
visit profile_password_path