added user edit, show view info and spec for user profile update
This commit is contained in:
parent
c48c8afa51
commit
a2dd90d355
8 changed files with 155 additions and 14 deletions
|
|
@ -24,6 +24,8 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
# Only allow a trusted parameter "white list" through.
|
# Only allow a trusted parameter "white list" through.
|
||||||
def user_params
|
def user_params
|
||||||
params.require(:user).permit(:name, :biography, :nickname, :affiliation)
|
params.require(:user).permit(:name, :biography, :nickname, :affiliation,
|
||||||
|
:website_url, :linkedin, :twitter, :googleplus,
|
||||||
|
:gnu, :diaspora, :github, :gitlab, :gna, :savannah)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ class User < ActiveRecord::Base
|
||||||
scope :admin, -> { where(is_admin: true) }
|
scope :admin, -> { where(is_admin: true) }
|
||||||
|
|
||||||
validates :email, presence: true
|
validates :email, presence: true
|
||||||
|
|
||||||
validates :username,
|
validates :username,
|
||||||
uniqueness: {
|
uniqueness: {
|
||||||
case_sensitive: false
|
case_sensitive: false
|
||||||
|
|
@ -62,6 +61,9 @@ class User < ActiveRecord::Base
|
||||||
presence: true
|
presence: true
|
||||||
|
|
||||||
validate :biography_limit
|
validate :biography_limit
|
||||||
|
validates :website_url, :linkedin, :googleplus, :gnu, :twitter, :gitlab, :github, :gna, :savannah, :diaspora,
|
||||||
|
format: { with: URI.regexp(%w(http https)), message: 'This is an invalid URL. It should start with http or https'},
|
||||||
|
allow_blank: true
|
||||||
|
|
||||||
##
|
##
|
||||||
# Checkes if the user attended the event
|
# Checkes if the user attended the event
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,18 @@
|
||||||
= link_to 'Change your avatar here', 'https://gravatar.com'
|
= link_to 'Change your avatar here', 'https://gravatar.com'
|
||||||
= f.input :affiliation, as: :string,
|
= f.input :affiliation, as: :string,
|
||||||
hint: 'This could be a company, a user group, or nothing at all.'
|
hint: 'This could be a company, a user group, or nothing at all.'
|
||||||
|
= f.input :website_url, type: :url, label: 'Personal Website'
|
||||||
|
= f.inputs :name => 'Social Media' do
|
||||||
|
= f.input :linkedin, type: :url
|
||||||
|
= f.input :twitter, type: :url
|
||||||
|
= f.input :googleplus, type: :url, label: 'Google+ Url'
|
||||||
|
= f.input :gnu, type: :url, label: 'GNU Social'
|
||||||
|
= f.input :diaspora, type: :url
|
||||||
|
= f.inputs :name => 'Social Code' do
|
||||||
|
= f.input :github, type: :url
|
||||||
|
= f.input :gitlab, type: :url
|
||||||
|
= f.input :savannah, type: :url
|
||||||
|
= f.input :gna, type: :url, label: 'Gna!'
|
||||||
= f.input :biography, input_html: { rows: 5, data: { provide: 'markdown-editable' }, 'onkeyup' => "word_count(this, 'biography-count', 150)" },
|
= f.input :biography, input_html: { rows: 5, data: { provide: 'markdown-editable' }, 'onkeyup' => "word_count(this, 'biography-count', 150)" },
|
||||||
hint: markdown_hint
|
hint: markdown_hint
|
||||||
You have used
|
You have used
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,69 @@
|
||||||
= markdown(@user.biography)
|
= markdown(@user.biography)
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
- if @user.events.confirmed.any?
|
%h3 Social Media and Social Code
|
||||||
%h3
|
%table.table
|
||||||
= "#{@user.name} presents #{pluralize(@user.events.confirmed.count, 'Event')}:"
|
%tr
|
||||||
%ul.list-unstyled
|
%td
|
||||||
- @user.events.confirmed.each do |event|
|
%b Website
|
||||||
%li
|
%td
|
||||||
%h4
|
= @user.website_url.present? ? @user.website_url : '-'
|
||||||
= link_to event.title, conference_program_proposal_path(event.program.conference.short_title, event.id)
|
%tr
|
||||||
%strong
|
%td
|
||||||
at
|
%b Linkedin
|
||||||
= event.program.conference.title
|
%td
|
||||||
|
= @user.linkedin.present? ? @user.linkedin : '-'
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%b Twitter
|
||||||
|
%td
|
||||||
|
= @user.twitter.present? ? @user.twitter : '-'
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%b GooglePlus
|
||||||
|
%td
|
||||||
|
= @user.googleplus.present? ? @user.googleplus : '-'
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%b GNU Social
|
||||||
|
%td
|
||||||
|
= @user.gnu.present? ? @user.gnu : '-'
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%b Diaspora
|
||||||
|
%td
|
||||||
|
= @user.diaspora.present? ? @user.diaspora : '-'
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%b Savannah
|
||||||
|
%td
|
||||||
|
= @user.savannah.present? ? @user.savannah : '-'
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%b Github
|
||||||
|
%td
|
||||||
|
= @user.github.present? ? @user.github : '-'
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%b Gitlab
|
||||||
|
%td
|
||||||
|
= @user.gitlab.present? ? @user.gitlab : '-'
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%b Gna!
|
||||||
|
%td
|
||||||
|
= @user.gna.present? ? @user.gna : '-'
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
- if @user.events.confirmed.any?
|
||||||
|
%h3
|
||||||
|
= "#{@user.name} presents #{pluralize(@user.events.confirmed.count, 'Event')}:"
|
||||||
|
%ul.list-unstyled
|
||||||
|
- @user.events.confirmed.each do |event|
|
||||||
|
%li
|
||||||
|
%h4
|
||||||
|
= link_to event.title, conference_program_proposal_path(event.program.conference.short_title, event.id)
|
||||||
|
%strong
|
||||||
|
at
|
||||||
|
= event.program.conference.title
|
||||||
|
|
|
||||||
14
db/migrate/20160830122446_add_twitter_to_users.rb
Normal file
14
db/migrate/20160830122446_add_twitter_to_users.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
class AddTwitterToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :twitter, :string
|
||||||
|
add_column :users, :googleplus, :string
|
||||||
|
add_column :users, :linkedin, :string
|
||||||
|
add_column :users, :gnu, :string
|
||||||
|
add_column :users, :diaspora, :string
|
||||||
|
add_column :users, :github, :string
|
||||||
|
add_column :users, :gitlab, :string
|
||||||
|
add_column :users, :gna, :string
|
||||||
|
add_column :users, :savannah, :string
|
||||||
|
add_column :users, :website_url, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
12
db/schema.rb
12
db/schema.rb
|
|
@ -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: 20160815140302) do
|
ActiveRecord::Schema.define(version: 20160830122446) do
|
||||||
|
|
||||||
create_table "ahoy_events", force: :cascade do |t|
|
create_table "ahoy_events", force: :cascade do |t|
|
||||||
t.uuid "visit_id", limit: 16
|
t.uuid "visit_id", limit: 16
|
||||||
|
|
@ -489,6 +489,16 @@ ActiveRecord::Schema.define(version: 20160815140302) do
|
||||||
t.boolean "is_admin", default: false
|
t.boolean "is_admin", default: false
|
||||||
t.string "username"
|
t.string "username"
|
||||||
t.boolean "is_disabled", default: false
|
t.boolean "is_disabled", default: false
|
||||||
|
t.string "twitter"
|
||||||
|
t.string "googleplus"
|
||||||
|
t.string "linkedin"
|
||||||
|
t.string "gnu"
|
||||||
|
t.string "diaspora"
|
||||||
|
t.string "github"
|
||||||
|
t.string "gitlab"
|
||||||
|
t.string "gna"
|
||||||
|
t.string "savannah"
|
||||||
|
t.string "website_url"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,17 @@ FactoryGirl.define do
|
||||||
sequence(:username) { |n| "username#{n}" }
|
sequence(:username) { |n| "username#{n}" }
|
||||||
password 'changeme'
|
password 'changeme'
|
||||||
password_confirmation 'changeme'
|
password_confirmation 'changeme'
|
||||||
|
googleplus { Faker::Internet.url('http://plus.google.com/testosemurl') }
|
||||||
|
linkedin {Faker::Internet.url('http://linkedin.com/testosemuser')}
|
||||||
|
website_url { Faker::Internet.url('http://example.com') }
|
||||||
|
gnu { Faker::Internet.url('http://gnu.io/testosemurl') }
|
||||||
|
twitter { Faker::Internet.url('http://twitter.com/testosemuser') }
|
||||||
|
github { Faker::Internet.url('http://github.com/testosemuser') }
|
||||||
|
gitlab { Faker::Internet.url('http://gitlab.com/testosemuser') }
|
||||||
|
savannah { Faker::Internet.url('http://savannah.gnu.org/testosemuser') }
|
||||||
|
diaspora { Faker::Internet.url('http://joindiaspora.com/testosemuser') }
|
||||||
|
gna { Faker::Internet.url('http://gna.com/testosemuser') }
|
||||||
|
|
||||||
confirmed_at { Time.now }
|
confirmed_at { Time.now }
|
||||||
biography <<-EOS
|
biography <<-EOS
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,40 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature User do
|
feature User do
|
||||||
|
|
||||||
|
let!(:user) {create(:user)}
|
||||||
|
|
||||||
|
describe 'update user profile' do
|
||||||
|
scenario 'sucessfully', feature: true do
|
||||||
|
sign_in user
|
||||||
|
visit edit_user_path(user.id)
|
||||||
|
fill_in 'user_website_url', with: 'http://www.example1.com'
|
||||||
|
fill_in 'user_linkedin', with: 'http://www.linkedin.com/testosemuser1'
|
||||||
|
fill_in 'user_gnu', with: 'http://gnu.io/testosemuser1'
|
||||||
|
fill_in 'user_twitter', with: 'http://www.twitter.com/testosemuser1'
|
||||||
|
fill_in 'user_github', with: 'http://www.github.com/testosemuser1'
|
||||||
|
fill_in 'user_gitlab', with: 'http://www.gitlab.com/testosemuser1'
|
||||||
|
fill_in 'user_gna', with: 'http://www.gna.com/testosemuser1'
|
||||||
|
fill_in 'user_diaspora', with: 'http://joindiaspora.com/testosemuser1'
|
||||||
|
fill_in 'user_savannah', with: 'http://savannah.gnu.org/testosemuser1'
|
||||||
|
fill_in 'user_googleplus', with: 'http://plus.google.com/testosemurl1'
|
||||||
|
|
||||||
|
click_button 'Update'
|
||||||
|
|
||||||
|
expect(flash). to eq('User was successfully updated.')
|
||||||
|
user.reload
|
||||||
|
expect(user.website_url).to eq('http://www.example1.com')
|
||||||
|
expect(user.linkedin).to eq('http://www.linkedin.com/testosemuser1')
|
||||||
|
expect(user.gnu).to eq('http://gnu.io/testosemuser1')
|
||||||
|
expect(user.twitter).to eq('http://www.twitter.com/testosemuser1')
|
||||||
|
expect(user.github).to eq('http://www.github.com/testosemuser1')
|
||||||
|
expect(user.gitlab).to eq('http://www.gitlab.com/testosemuser1')
|
||||||
|
expect(user.googleplus).to eq('http://plus.google.com/testosemurl1')
|
||||||
|
expect(user.gna).to eq('http://www.gna.com/testosemuser1')
|
||||||
|
expect(user.diaspora).to eq('http://joindiaspora.com/testosemuser1')
|
||||||
|
expect(user.savannah).to eq('http://savannah.gnu.org/testosemuser1')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
shared_examples 'admin ability' do
|
shared_examples 'admin ability' do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
@ -9,4 +43,5 @@ feature User do
|
||||||
describe 'admin' do
|
describe 'admin' do
|
||||||
it_behaves_like 'admin ability', :admin
|
it_behaves_like 'admin ability', :admin
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue