diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb
index c39c5f5f1..418dddfef 100644
--- a/app/views/users/registrations/new.html.erb
+++ b/app/views/users/registrations/new.html.erb
@@ -6,15 +6,8 @@
<%= render 'shared/errors', resource: resource %>
- <%= f.text_field :first_name, autofocus: true,
- placeholder: t("devise_views.users.registrations.new.first_name_label") %>
- <%= f.text_field :last_name, placeholder: t("devise_views.users.registrations.new.last_name_label") %>
+ <%= f.text_field :username, placeholder: t("devise_views.users.registrations.new.username_label") %>
<%= f.email_field :email, placeholder: t("devise_views.users.registrations.new.email_label") %>
- <%= f.text_field :nickname, placeholder: t("devise_views.users.registrations.new.nickname_label") %>
-
- <%= f.check_box :use_nickname, label: t("devise_views.users.registrations.new.use_nickname_label") %>
-
- <%= f.text_field :phone_number, placeholder: t("devise_views.users.registrations.new.phone_number_label") %>
<%= f.password_field :password, autocomplete: "off",
placeholder: t("devise_views.users.registrations.new.password_label") %>
diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml
index 8a4063d9a..94b1fa0c9 100644
--- a/config/locales/activerecord.en.yml
+++ b/config/locales/activerecord.en.yml
@@ -18,9 +18,7 @@ en:
title: Title
user:
email: Email
- first_name: "First name"
- last_name: "Last name"
- nickname: Nickname
+ username: Username
password: Password
phone_number: Phone number
official_position: Official position
diff --git a/config/locales/activerecord.es.yml b/config/locales/activerecord.es.yml
index b5fa8050e..f566026de 100644
--- a/config/locales/activerecord.es.yml
+++ b/config/locales/activerecord.es.yml
@@ -18,9 +18,7 @@ es:
title: Título
user:
email: Correo electrónico
- first_name: Nombre
- last_name: Apellidos
- nickname: Pseudónimo
+ username: Nombre de usuario
password: Contraseña
phone_number: Teléfono
official_position: Cargo público
diff --git a/config/locales/devise_views.en.yml b/config/locales/devise_views.en.yml
index e5a1ec48d..c782806ec 100644
--- a/config/locales/devise_views.en.yml
+++ b/config/locales/devise_views.en.yml
@@ -50,12 +50,8 @@ en:
back_link: "Back"
new:
title: "Sign up"
- first_name_label: "First name"
- last_name_label: "Last name"
- nickname_label: "Nickname"
- use_nickname_label: "Use nickname"
+ username_label: "Username to use publicly"
email_label: "Email"
- phone_number_label: "Phone number"
password_label: "Password"
password_confirmation_label: "Confirm password"
submit: "Sign up"
diff --git a/config/locales/devise_views.es.yml b/config/locales/devise_views.es.yml
index c44ddfb31..18754529b 100644
--- a/config/locales/devise_views.es.yml
+++ b/config/locales/devise_views.es.yml
@@ -50,12 +50,8 @@ es:
back_link: "Atrás"
new:
title: "Registrarse"
- first_name_label: "Nombre"
- last_name_label: "Apellidos"
- nickname_label: "Pseudónimo"
- use_nickname_label: "Usar pseudónimo"
+ username_label: "Nombre a utilizar públicamente"
email_label: "Email"
- phone_number_label: "Teléfono"
password_label: "Contraseña"
password_confirmation_label: "Confirmar contraseña"
submit: "Registrarse"
diff --git a/config/locales/en.yml b/config/locales/en.yml
index a2ea265f3..1366b3e4b 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -120,12 +120,9 @@ en:
change_credentials_link: "Change my credentials"
avatar: "Avatar"
personal: "Personal data"
- first_name_label: "First Name"
- last_name_label: "Last Name"
+ username_label: "Username"
phone_number_label: "Phone number"
organization_name_label: "Organization name"
- use_nickname_label: "Use nickname"
- nickname_label: "Nickname"
notifications: Notifications
simple_captcha:
placeholder: "Enter the image value"
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 8d24181c4..e4a6a873c 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -120,12 +120,9 @@ es:
email_on_comment_reply_label: "Recibir un email cuando alguien contesta a mis comentarios"
avatar: "Avatar"
personal: "Datos personales"
- first_name_label: "Nombre"
- last_name_label: "Apellidos"
+ username_label: "Nombre de usuario"
phone_number_label: "Teléfono"
organization_name_label: "Nombre de la organización"
- use_nickname_label: "Usar pseudónimo"
- nickname_label: "Pseudónimo"
notifications: Notificaciones
simple_captcha:
placeholder: "Introduce el texto de la imagen"
diff --git a/db/migrate/20150821130019_changes_user_registrations_fields.rb b/db/migrate/20150821130019_changes_user_registrations_fields.rb
new file mode 100644
index 000000000..600762324
--- /dev/null
+++ b/db/migrate/20150821130019_changes_user_registrations_fields.rb
@@ -0,0 +1,10 @@
+class ChangesUserRegistrationsFields < ActiveRecord::Migration
+ def change
+ add_column :users, :username, :string
+
+ remove_column :users, :first_name, :string
+ remove_column :users, :last_name, :string
+ remove_column :users, :nickname, :string
+ remove_column :users, :use_nickname, :boolean, default: false, null: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6d3005fbf..3cd1b55d1 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150819135933) do
+ActiveRecord::Schema.define(version: 20150821130019) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -130,20 +130,17 @@ ActiveRecord::Schema.define(version: 20150819135933) do
t.string "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
- t.string "first_name"
- t.string "last_name"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
- t.string "nickname"
- t.boolean "use_nickname", default: false, null: false
t.boolean "email_on_debate_comment", default: false
t.boolean "email_on_comment_reply", default: false
t.string "official_position"
t.integer "official_level", default: 0
- t.string "phone_number", limit: 30
t.datetime "hidden_at"
+ t.string "phone_number", limit: 30
+ t.string "username"
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
diff --git a/spec/factories.rb b/spec/factories.rb
index a6090efbb..101ce2746 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -1,8 +1,7 @@
FactoryGirl.define do
factory :user do
- first_name 'Manuela'
- last_name 'Carmena'
+ username 'Manuela'
sequence(:email) { |n| "manuela#{n}@madrid.es" }
password 'judgmentday'
confirmed_at { Time.now }
diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb
index 28785ed08..93cfe3dd0 100644
--- a/spec/features/account_spec.rb
+++ b/spec/features/account_spec.rb
@@ -3,7 +3,7 @@ require 'rails_helper'
feature 'Account' do
background do
- @user = create(:user, first_name: "Manuela", last_name: "Colau")
+ @user = create(:user, username: "Manuela Colau")
login_as(@user)
end
@@ -14,8 +14,7 @@ feature 'Account' do
expect(current_path).to eq(account_path)
- expect(page).to have_selector("input[value='Manuela']")
- expect(page).to have_selector("input[value='Colau']")
+ expect(page).to have_selector("input[value='Manuela Colau']")
expect(page).to have_selector(avatar('Manuela Colau'), count: 1)
end
@@ -25,8 +24,7 @@ feature 'Account' do
visit account_path
expect(page).to have_selector("input[value='Manuela Corp']")
- expect(page).to_not have_selector("input[value='Manuela']")
- expect(page).to_not have_selector("input[value='Colau']")
+ expect(page).to_not have_selector("input[value='Manuela Colau']")
expect(page).to have_selector(avatar('Manuela Corp'), count: 1)
end
@@ -34,8 +32,7 @@ feature 'Account' do
scenario 'Edit' do
visit account_path
- fill_in 'account_first_name', with: 'Larry'
- fill_in 'account_last_name', with: 'Bird'
+ fill_in 'account_username', with: 'Larry Bird'
check 'account_email_on_debate_comment'
check 'account_email_on_comment_reply'
click_button 'Save changes'
@@ -44,8 +41,7 @@ feature 'Account' do
visit account_path
- expect(page).to have_selector("input[value='Larry']")
- expect(page).to have_selector("input[value='Bird']")
+ expect(page).to have_selector("input[value='Larry Bird']")
expect(page).to have_selector("input[id='account_email_on_debate_comment'][value='1']")
expect(page).to have_selector("input[id='account_email_on_comment_reply'][value='1']")
end
@@ -71,7 +67,7 @@ feature 'Account' do
scenario "Errors on edit" do
visit account_path
- fill_in 'account_first_name', with: ''
+ fill_in 'account_username', with: ''
click_button 'Save changes'
expect(page).to have_content error_message
diff --git a/spec/features/admin/officials_spec.rb b/spec/features/admin/officials_spec.rb
index 6824ccf62..90cd88501 100644
--- a/spec/features/admin/officials_spec.rb
+++ b/spec/features/admin/officials_spec.rb
@@ -3,7 +3,7 @@ require 'rails_helper'
feature 'Admin officials' do
background do
- @citizen = create(:user, first_name: "Citizen", last_name: "Kane")
+ @citizen = create(:user, username: "Citizen Kane")
@official = create(:user, official_position: "Mayor", official_level: 5)
@admin = create(:administrator)
login_as(@admin.user)
diff --git a/spec/features/comments_spec.rb b/spec/features/comments_spec.rb
index b820fffcd..f7738464a 100644
--- a/spec/features/comments_spec.rb
+++ b/spec/features/comments_spec.rb
@@ -80,8 +80,8 @@ feature 'Comments' do
end
scenario 'Reply', :js do
- citizen = create(:user, first_name: 'Ana')
- manuela = create(:user, first_name: 'Manuela')
+ citizen = create(:user, username: 'Ana')
+ manuela = create(:user, username: 'Manuela')
debate = create(:debate)
comment = create(:comment, commentable: debate, user: citizen)
diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb
index 2b7984833..42511f28c 100644
--- a/spec/features/users_spec.rb
+++ b/spec/features/users_spec.rb
@@ -6,8 +6,7 @@ feature 'Users' do
visit '/'
click_link 'Sign up'
- fill_in 'user_first_name', with: 'Manuela'
- fill_in 'user_last_name', with: 'Carmena'
+ fill_in 'user_username', with: 'Manuela Carmena'
fill_in 'user_email', with: 'manuela@madrid.es'
fill_in 'user_password', with: 'judgementday'
fill_in 'user_password_confirmation', with: 'judgementday'
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index f64888236..5a4bbdf88 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -30,6 +30,12 @@ describe User do
expect(subject).to be_valid
end
+ describe "#name" do
+ it "is the username when the user is not an organization" do
+ expect(subject.name).to eq(subject.username)
+ end
+ end
+
describe 'preferences' do
describe 'email_on_debate_comment' do
it 'should be false by default' do
@@ -44,45 +50,6 @@ describe User do
end
end
- describe 'use_nickname' do
- describe 'when true' do
- before { subject.use_nickname = true }
-
- it "activates the validation of nickname" do
- subject.nickname = nil
- expect(subject).to_not be_valid
-
- subject.nickname = "dredd"
- expect(subject).to be_valid
- end
-
- it "calculates the name using the nickname" do
- subject.nickname = "dredd"
- expect(subject.name).to eq("dredd")
- end
- end
-
- describe 'when false' do
- before { subject.use_nickname = false }
-
- it "activates the validation of first_name and last_name" do
- subject.first_name = nil
- subject.last_name = nil
- expect(subject).to_not be_valid
-
- subject.first_name = "Joseph"
- subject.last_name = "Dredd"
- expect(subject).to be_valid
- end
-
- it "calculates the name using first_name and last_name" do
- subject.first_name = "Joseph"
- subject.last_name = "Dredd"
- expect(subject.name).to eq("Joseph Dredd")
- end
- end
- end
-
describe "administrator?" do
it "is false when the user is not an admin" do
expect(subject.administrator?).to be false
@@ -152,9 +119,8 @@ describe User do
expect(subject.organization.name).to eq('org')
end
- it "deactivates the validation of first_name and last_name, and activates the validation of organization" do
- subject.first_name = nil
- subject.last_name = nil
+ it "deactivates the validation of username, and activates the validation of organization" do
+ subject.username = nil
expect(subject).to be_valid
subject.organization.name= nil
diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb
index 32252aa1a..21a98f56f 100644
--- a/spec/support/common_actions.rb
+++ b/spec/support/common_actions.rb
@@ -4,8 +4,7 @@ module CommonActions
visit '/'
click_link 'Sign up'
- fill_in 'user_first_name', with: 'Manuela'
- fill_in 'user_last_name', with: 'Carmena'
+ fill_in 'user_username', with: 'Manuela Carmena'
fill_in 'user_email', with: 'manuela@madrid.es'
fill_in 'user_password', with: 'judgementday'
fill_in 'user_password_confirmation', with: 'judgementday'