Commit 25da1415 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'jeromedalbert-add_website_url_to_user'

parents d95e56f0 f8aae4b7
...@@ -17,6 +17,7 @@ v 6.5.0 ...@@ -17,6 +17,7 @@ v 6.5.0
- Fix 500 error for rdoc files - Fix 500 error for rdoc files
- Ability to customize merge commit message (sponsored by Say Media) - Ability to customize merge commit message (sponsored by Say Media)
- Search autocomplete via ajax - Search autocomplete via ajax
- Add website url to user profile
v6.4.3 v6.4.3
- Don't use unicorn worker killer if PhusionPassenger is defined - Don't use unicorn worker killer if PhusionPassenger is defined
......
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
# confirmed_at :datetime # confirmed_at :datetime
# confirmation_sent_at :datetime # confirmation_sent_at :datetime
# unconfirmed_email :string(255) # unconfirmed_email :string(255)
# hide_no_ssh_key :boolean default(FALSE), not null # hide_no_ssh_key :boolean default(FALSE)
# website_url :string(255) default(""), not null
# #
require 'carrierwave/orm/activerecord' require 'carrierwave/orm/activerecord'
...@@ -52,7 +53,7 @@ class User < ActiveRecord::Base ...@@ -52,7 +53,7 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable, :omniauthable, :confirmable, :registerable :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :confirmable, :registerable
attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username, attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username,
:skype, :linkedin, :twitter, :color_scheme_id, :theme_id, :force_random_password, :skype, :linkedin, :twitter, :website_url, :color_scheme_id, :theme_id, :force_random_password,
:extern_uid, :provider, :password_expires_at, :avatar, :hide_no_ssh_key, :extern_uid, :provider, :password_expires_at, :avatar, :hide_no_ssh_key,
as: [:default, :admin] as: [:default, :admin]
...@@ -424,4 +425,14 @@ class User < ActiveRecord::Base ...@@ -424,4 +425,14 @@ class User < ActiveRecord::Base
order('id DESC').limit(1000). order('id DESC').limit(1000).
update_all(updated_at: Time.now) update_all(updated_at: Time.now)
end end
def full_website_url
return "http://#{website_url}" if website_url !~ /^https?:\/\//
website_url
end
def short_website_url
website_url.gsub(/https?:\/\//, '')
end
end end
...@@ -80,6 +80,9 @@ ...@@ -80,6 +80,9 @@
.form-group .form-group
= f.label :twitter, class: 'control-label' = f.label :twitter, class: 'control-label'
.col-sm-10= f.text_field :twitter, class: 'form-control' .col-sm-10= f.text_field :twitter, class: 'form-control'
.form-group
= f.label :website_url, class: 'control-label'
.col-sm-10= f.text_field :website_url, class: 'form-control'
.form-actions .form-actions
- if @user.new_record? - if @user.new_record?
......
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
.form-group .form-group
= f.label :twitter, class: "control-label" = f.label :twitter, class: "control-label"
.col-sm-10= f.text_field :twitter, class: "form-control" .col-sm-10= f.text_field :twitter, class: "form-control"
.form-group
= f.label :website_url, class: "control-label"
.col-sm-10= f.text_field :website_url, class: "form-control"
.form-group .form-group
= f.label :bio, class: "control-label" = f.label :bio, class: "control-label"
.col-sm-10 .col-sm-10
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
%li %li
%span.light Twitter: %span.light Twitter:
%strong= link_to user.twitter, "http://www.twitter.com/#{user.twitter}" %strong= link_to user.twitter, "http://www.twitter.com/#{user.twitter}"
- unless user.website_url.blank?
%li
%span.light Website url:
%strong= link_to user.short_website_url, user.full_website_url
- unless user.bio.blank? - unless user.bio.blank?
%li %li
%span.light Bio: %span.light Bio:
......
class AddWebsiteUrlToUsers < ActiveRecord::Migration
def change
add_column :users, :website_url, :string, {:null => false, :default => ''}
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20131217102743) do ActiveRecord::Schema.define(version: 20140116231608) do
create_table "broadcast_messages", force: true do |t| create_table "broadcast_messages", force: true do |t|
t.text "message", null: false t.text "message", null: false
...@@ -301,6 +301,7 @@ ActiveRecord::Schema.define(version: 20131217102743) do ...@@ -301,6 +301,7 @@ ActiveRecord::Schema.define(version: 20131217102743) do
t.datetime "confirmation_sent_at" t.datetime "confirmation_sent_at"
t.string "unconfirmed_email" t.string "unconfirmed_email"
t.boolean "hide_no_ssh_key", default: false t.boolean "hide_no_ssh_key", default: false
t.string "website_url", default: "", null: false
end end
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
......
...@@ -26,6 +26,7 @@ __You can login with both GitLab and LDAP credentials now__ ...@@ -26,6 +26,7 @@ __You can login with both GitLab and LDAP credentials now__
"skype": "", "skype": "",
"linkedin": "", "linkedin": "",
"twitter": "", "twitter": "",
"website_url": "",
"dark_scheme": false, "dark_scheme": false,
"theme_id": 1, "theme_id": 1,
"is_admin": false, "is_admin": false,
......
...@@ -20,6 +20,7 @@ GET /users ...@@ -20,6 +20,7 @@ GET /users
"skype": "", "skype": "",
"linkedin": "", "linkedin": "",
"twitter": "", "twitter": "",
"website_url": "",
"extern_uid": "john.smith", "extern_uid": "john.smith",
"provider": "provider_name", "provider": "provider_name",
"theme_id": 1, "theme_id": 1,
...@@ -38,6 +39,7 @@ GET /users ...@@ -38,6 +39,7 @@ GET /users
"skype": "", "skype": "",
"linkedin": "", "linkedin": "",
"twitter": "", "twitter": "",
"website_url": "",
"extern_uid": "jack.smith", "extern_uid": "jack.smith",
"provider": "provider_name", "provider": "provider_name",
"theme_id": 1, "theme_id": 1,
...@@ -74,6 +76,7 @@ Parameters: ...@@ -74,6 +76,7 @@ Parameters:
"skype": "", "skype": "",
"linkedin": "", "linkedin": "",
"twitter": "", "twitter": "",
"website_url": "",
"extern_uid": "john.smith", "extern_uid": "john.smith",
"provider": "provider_name", "provider": "provider_name",
"theme_id": 1, "theme_id": 1,
...@@ -102,6 +105,7 @@ Parameters: ...@@ -102,6 +105,7 @@ Parameters:
+ `skype` (optional) - Skype ID + `skype` (optional) - Skype ID
+ `linkedin` (optional) - Linkedin + `linkedin` (optional) - Linkedin
+ `twitter` (optional) - Twitter account + `twitter` (optional) - Twitter account
+ `website_url` (optional) - Website url
+ `projects_limit` (optional) - Number of projects user can create + `projects_limit` (optional) - Number of projects user can create
+ `extern_uid` (optional) - External UID + `extern_uid` (optional) - External UID
+ `provider` (optional) - External provider name + `provider` (optional) - External provider name
...@@ -127,6 +131,7 @@ Parameters: ...@@ -127,6 +131,7 @@ Parameters:
+ `skype` - Skype ID + `skype` - Skype ID
+ `linkedin` - Linkedin + `linkedin` - Linkedin
+ `twitter` - Twitter account + `twitter` - Twitter account
+ `website_url` - Website url
+ `projects_limit` - Limit projects each user can create + `projects_limit` - Limit projects each user can create
+ `extern_uid` - External UID + `extern_uid` - External UID
+ `provider` - External provider name + `provider` - External provider name
...@@ -174,6 +179,7 @@ GET /user ...@@ -174,6 +179,7 @@ GET /user
"skype": "", "skype": "",
"linkedin": "", "linkedin": "",
"twitter": "", "twitter": "",
"website_url": "",
"theme_id": 1, "theme_id": 1,
"color_scheme_id": 2, "color_scheme_id": 2,
"is_admin": false, "is_admin": false,
......
...@@ -8,8 +8,8 @@ Feature: Profile ...@@ -8,8 +8,8 @@ Feature: Profile
Scenario: I edit profile Scenario: I edit profile
Given I visit profile page Given I visit profile page
Then I change my contact info Then I change my profile info
And I should see new contact info And I should see new profile info
Scenario: I change my password without old one Scenario: I change my password without old one
Given I visit profile password page Given I visit profile password page
......
...@@ -6,18 +6,20 @@ class Profile < Spinach::FeatureSteps ...@@ -6,18 +6,20 @@ class Profile < Spinach::FeatureSteps
page.should have_content "Profile settings" page.should have_content "Profile settings"
end end
step 'I change my contact info' do step 'I change my profile info' do
fill_in "user_skype", with: "testskype" fill_in "user_skype", with: "testskype"
fill_in "user_linkedin", with: "testlinkedin" fill_in "user_linkedin", with: "testlinkedin"
fill_in "user_twitter", with: "testtwitter" fill_in "user_twitter", with: "testtwitter"
fill_in "user_website_url", with: "testurl"
click_button "Save changes" click_button "Save changes"
@user.reload @user.reload
end end
step 'I should see new contact info' do step 'I should see new profile info' do
@user.skype.should == 'testskype' @user.skype.should == 'testskype'
@user.linkedin.should == 'testlinkedin' @user.linkedin.should == 'testlinkedin'
@user.twitter.should == 'testtwitter' @user.twitter.should == 'testtwitter'
@user.website_url.should == 'testurl'
end end
step 'I change my avatar' do step 'I change my avatar' do
......
module API module API
module Entities module Entities
class User < Grape::Entity class User < Grape::Entity
expose :id, :username, :email, :name, :bio, :skype, :linkedin, :twitter, expose :id, :username, :email, :name, :bio, :skype, :linkedin, :twitter, :website_url,
:theme_id, :color_scheme_id, :state, :created_at, :extern_uid, :provider :theme_id, :color_scheme_id, :state, :created_at, :extern_uid, :provider
expose :is_admin?, as: :is_admin expose :is_admin?, as: :is_admin
expose :can_create_group?, as: :can_create_group expose :can_create_group?, as: :can_create_group
......
...@@ -36,6 +36,7 @@ module API ...@@ -36,6 +36,7 @@ module API
# skype - Skype ID # skype - Skype ID
# linkedin - Linkedin # linkedin - Linkedin
# twitter - Twitter account # twitter - Twitter account
# website_url - Website url
# projects_limit - Number of projects user can create # projects_limit - Number of projects user can create
# extern_uid - External authentication provider UID # extern_uid - External authentication provider UID
# provider - External provider # provider - External provider
...@@ -67,6 +68,7 @@ module API ...@@ -67,6 +68,7 @@ module API
# skype - Skype ID # skype - Skype ID
# linkedin - Linkedin # linkedin - Linkedin
# twitter - Twitter account # twitter - Twitter account
# website_url - Website url
# projects_limit - Limit projects each user can create # projects_limit - Limit projects each user can create
# extern_uid - External authentication provider UID # extern_uid - External authentication provider UID
# provider - External provider # provider - External provider
...@@ -78,7 +80,7 @@ module API ...@@ -78,7 +80,7 @@ module API
put ":id" do put ":id" do
authenticated_as_admin! authenticated_as_admin!
attrs = attributes_for_keys [:email, :name, :password, :skype, :linkedin, :twitter, :projects_limit, :username, :extern_uid, :provider, :bio, :can_create_group, :admin] attrs = attributes_for_keys [:email, :name, :password, :skype, :linkedin, :twitter, :website_url, :projects_limit, :username, :extern_uid, :provider, :bio, :can_create_group, :admin]
user = User.find(params[:id]) user = User.find(params[:id])
not_found!("User not found") unless user not_found!("User not found") unless user
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
# confirmed_at :datetime # confirmed_at :datetime
# confirmation_sent_at :datetime # confirmation_sent_at :datetime
# unconfirmed_email :string(255) # unconfirmed_email :string(255)
# hide_no_ssh_key :boolean default(FALSE)
# website_url :string(255) default(""), not null
# #
require 'spec_helper' require 'spec_helper'
...@@ -293,4 +295,48 @@ describe User do ...@@ -293,4 +295,48 @@ describe User do
user.avatar_type.should == ["only images allowed"] user.avatar_type.should == ["only images allowed"]
end end
end end
describe '#full_website_url' do
let(:user) { create(:user) }
it 'begins with http if website url omits it' do
user.website_url = 'test.com'
expect(user.full_website_url).to eq 'http://test.com'
end
it 'begins with http if website url begins with http' do
user.website_url = 'http://test.com'
expect(user.full_website_url).to eq 'http://test.com'
end
it 'begins with https if website url begins with https' do
user.website_url = 'https://test.com'
expect(user.full_website_url).to eq 'https://test.com'
end
end
describe '#short_website_url' do
let(:user) { create(:user) }
it 'does not begin with http if website url omits it' do
user.website_url = 'test.com'
expect(user.short_website_url).to eq 'test.com'
end
it 'does not begin with http if website url begins with http' do
user.website_url = 'http://test.com'
expect(user.short_website_url).to eq 'test.com'
end
it 'does not begin with https if website url begins with https' do
user.website_url = 'https://test.com'
expect(user.short_website_url).to eq 'test.com'
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment