Commit 206813e15c9e1fdcdf6b3f8ca39bef3e562ce826
Committed by
Daniela Feitosa
1 parent
02d6694f
Exists in
master
and in
10 other branches
Remove secondary_email from user
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Gustavo Coelho <gust.rod.coelho@gmail.com> Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Showing
12 changed files
with
15 additions
and
167 deletions
Show diff stats
src/noosfero-spb/gov_user/db/migrate/20160105122610_remove_secondary_email_from_user.rb
0 → 100644
src/noosfero-spb/gov_user/lib/ext/person.rb
| @@ -14,14 +14,6 @@ class Person | @@ -14,14 +14,6 @@ class Person | ||
| 14 | false | 14 | false |
| 15 | end | 15 | end |
| 16 | 16 | ||
| 17 | - def secondary_email | ||
| 18 | - self.user.secondary_email unless self.user.nil? | ||
| 19 | - end | ||
| 20 | - | ||
| 21 | - def secondary_email= value | ||
| 22 | - self.user.secondary_email = value unless self.user.nil? | ||
| 23 | - end | ||
| 24 | - | ||
| 25 | def institutions | 17 | def institutions |
| 26 | institutions = [] | 18 | institutions = [] |
| 27 | unless self.user.institutions.nil? | 19 | unless self.user.institutions.nil? |
src/noosfero-spb/gov_user/lib/ext/user.rb
| @@ -2,59 +2,6 @@ require_dependency 'user' | @@ -2,59 +2,6 @@ require_dependency 'user' | ||
| 2 | 2 | ||
| 3 | class User | 3 | class User |
| 4 | 4 | ||
| 5 | - GOV_SUFFIX = /^.*@[gov.br|jus.br|leg.br|mp.br]+$/ | ||
| 6 | - | ||
| 7 | has_and_belongs_to_many :institutions | 5 | has_and_belongs_to_many :institutions |
| 8 | 6 | ||
| 9 | - validate :email_different_secondary?, :email_has_already_been_used?, | ||
| 10 | - :secondary_email_format | ||
| 11 | - | ||
| 12 | - scope :primary_or_secondary_email_already_used?, lambda { |email| | ||
| 13 | - where("email=? OR secondary_email=?", email, email) | ||
| 14 | - } | ||
| 15 | - | ||
| 16 | - def email_different_secondary? | ||
| 17 | - self.errors.add( | ||
| 18 | - :base, | ||
| 19 | - _("Email must be different from secondary email.") | ||
| 20 | - ) if self.email == self.secondary_email | ||
| 21 | - end | ||
| 22 | - | ||
| 23 | - def email_has_already_been_used? | ||
| 24 | - user_already_saved = User.find(:first, | ||
| 25 | - :conditions => ["email = ?", self.email]) | ||
| 26 | - | ||
| 27 | - if user_already_saved.nil? | ||
| 28 | - primary_email_hasnt_been_used = | ||
| 29 | - User.primary_or_secondary_email_already_used?(self.email).empty? | ||
| 30 | - | ||
| 31 | - if !self.secondary_email.nil? and self.secondary_email.empty? | ||
| 32 | - self.secondary_email = nil | ||
| 33 | - end | ||
| 34 | - | ||
| 35 | - secondary_email_hasnt_been_used = | ||
| 36 | - User.primary_or_secondary_email_already_used?(self.secondary_email). | ||
| 37 | - empty? | ||
| 38 | - | ||
| 39 | - if !primary_email_hasnt_been_used or !secondary_email_hasnt_been_used | ||
| 40 | - self.errors.add(:base, _("E-mail or secondary e-mail already taken.")) | ||
| 41 | - end | ||
| 42 | - end | ||
| 43 | - end | ||
| 44 | - | ||
| 45 | - def secondary_email_format | ||
| 46 | - if !self.secondary_email.nil? and self.secondary_email.length > 0 | ||
| 47 | - test = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/ | ||
| 48 | - | ||
| 49 | - unless test.match(self.secondary_email) | ||
| 50 | - self.errors.add(:base, _("Invalid secondary email format.")) | ||
| 51 | - end | ||
| 52 | - end | ||
| 53 | - end | ||
| 54 | - | ||
| 55 | - private | ||
| 56 | - | ||
| 57 | - def valid_format?(value, string_format) | ||
| 58 | - !value.nil? && value.length > 0 && !string_format.match(value).nil? | ||
| 59 | - end | ||
| 60 | end | 7 | end |
src/noosfero-spb/gov_user/lib/gov_user_plugin.rb
| @@ -187,7 +187,7 @@ class GovUserPlugin < Noosfero::Plugin | @@ -187,7 +187,7 @@ class GovUserPlugin < Noosfero::Plugin | ||
| 187 | identifier | 187 | identifier |
| 188 | name) | 188 | name) |
| 189 | 189 | ||
| 190 | - fields[:user_fields] = %w(secondary_email email) | 190 | + fields[:user_fields] = %w(email) |
| 191 | fields | 191 | fields |
| 192 | end | 192 | end |
| 193 | 193 |
src/noosfero-spb/gov_user/public/views/user-edit-profile.js
| @@ -158,7 +158,6 @@ modulejs.define('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoic | @@ -158,7 +158,6 @@ modulejs.define('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoic | ||
| 158 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_contact_phone")); | 158 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_contact_phone")); |
| 159 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_cell_phone")); | 159 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_cell_phone")); |
| 160 | try_to_remove(containers, $("#select_institution")); | 160 | try_to_remove(containers, $("#select_institution")); |
| 161 | - try_to_remove(containers, $("#user_secondary_email").parent().parent()); | ||
| 162 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_email")); | 161 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_email")); |
| 163 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_name")); | 162 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_name")); |
| 164 | try_to_remove(containers, $(".pseudoformlabel").parent().parent()); | 163 | try_to_remove(containers, $(".pseudoformlabel").parent().parent()); |
| @@ -191,7 +190,6 @@ modulejs.define('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoic | @@ -191,7 +190,6 @@ modulejs.define('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoic | ||
| 191 | fix_phone_mask_format("#profile_data_contact_phone"); | 190 | fix_phone_mask_format("#profile_data_contact_phone"); |
| 192 | 191 | ||
| 193 | add_blur_fields("#profile_data_email", "email_error", invalid_email_validation); | 192 | add_blur_fields("#profile_data_email", "email_error", invalid_email_validation); |
| 194 | - add_blur_fields("#user_secondary_email", "email_error", invalid_email_validation, true); | ||
| 195 | add_blur_fields("#profile_data_personal_website", "site_error", invalid_site_validation); | 193 | add_blur_fields("#profile_data_personal_website", "site_error", invalid_site_validation); |
| 196 | add_blur_fields("#profile_data_organization_website", "site_error", invalid_site_validation); | 194 | add_blur_fields("#profile_data_organization_website", "site_error", invalid_site_validation); |
| 197 | } | 195 | } |
src/noosfero-spb/gov_user/test/helpers/plugin_test_helper.rb
| @@ -2,13 +2,12 @@ require File.dirname(__FILE__) + '/../helpers/institution_test_helper' | @@ -2,13 +2,12 @@ require File.dirname(__FILE__) + '/../helpers/institution_test_helper' | ||
| 2 | 2 | ||
| 3 | module PluginTestHelper | 3 | module PluginTestHelper |
| 4 | 4 | ||
| 5 | - def create_person name, email, password, password_confirmation, secondary_email, state="state", city="city" | 5 | + def create_person name, email, password, password_confirmation, state="state", city="city" |
| 6 | user = create_user( | 6 | user = create_user( |
| 7 | name.to_slug, | 7 | name.to_slug, |
| 8 | email, | 8 | email, |
| 9 | password, | 9 | password, |
| 10 | - password_confirmation, | ||
| 11 | - secondary_email | 10 | + password_confirmation |
| 12 | ) | 11 | ) |
| 13 | person = Person::new | 12 | person = Person::new |
| 14 | 13 | ||
| @@ -26,14 +25,13 @@ module PluginTestHelper | @@ -26,14 +25,13 @@ module PluginTestHelper | ||
| 26 | person | 25 | person |
| 27 | end | 26 | end |
| 28 | 27 | ||
| 29 | - def create_user login, email, password, password_confirmation, secondary_email | 28 | + def create_user login, email, password, password_confirmation |
| 30 | user = User.new | 29 | user = User.new |
| 31 | 30 | ||
| 32 | user.login = login | 31 | user.login = login |
| 33 | user.email = email | 32 | user.email = email |
| 34 | user.password = password | 33 | user.password = password |
| 35 | user.password_confirmation = password_confirmation | 34 | user.password_confirmation = password_confirmation |
| 36 | - user.secondary_email = secondary_email | ||
| 37 | 35 | ||
| 38 | user | 36 | user |
| 39 | end | 37 | end |
src/noosfero-spb/gov_user/test/unit/institutions_block_test.rb
| @@ -27,7 +27,6 @@ class InstitutionsBlockTest < ActiveSupport::TestCase | @@ -27,7 +27,6 @@ class InstitutionsBlockTest < ActiveSupport::TestCase | ||
| 27 | "jose_augusto@email.com", | 27 | "jose_augusto@email.com", |
| 28 | "aaaaaaa", | 28 | "aaaaaaa", |
| 29 | "aaaaaaa", | 29 | "aaaaaaa", |
| 30 | - 'jose@secondary.com', | ||
| 31 | "DF", | 30 | "DF", |
| 32 | "Gama" | 31 | "Gama" |
| 33 | ) | 32 | ) |
src/noosfero-spb/gov_user/test/unit/person_test.rb
| @@ -12,7 +12,6 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | @@ -12,7 +12,6 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | ||
| 12 | "user@email.com", | 12 | "user@email.com", |
| 13 | "123456", | 13 | "123456", |
| 14 | "123456", | 14 | "123456", |
| 15 | - "user@secondaryemail.com", | ||
| 16 | "Any State", | 15 | "Any State", |
| 17 | "Some City" | 16 | "Some City" |
| 18 | ) | 17 | ) |
| @@ -22,7 +21,7 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | @@ -22,7 +21,7 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | ||
| 22 | @person.cell_phone = "76888919" | 21 | @person.cell_phone = "76888919" |
| 23 | @person.contact_phone = "987654321" | 22 | @person.contact_phone = "987654321" |
| 24 | 23 | ||
| 25 | - assert_equal(67, @plugin.calc_percentage_registration(@person)) | 24 | + assert_equal(64, @plugin.calc_percentage_registration(@person)) |
| 26 | 25 | ||
| 27 | @person.comercial_phone = "11223344" | 26 | @person.comercial_phone = "11223344" |
| 28 | @person.country = "I dont know" | 27 | @person.country = "I dont know" |
| @@ -34,10 +33,4 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | @@ -34,10 +33,4 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | ||
| 34 | 33 | ||
| 35 | assert_equal(100, @plugin.calc_percentage_registration(@person)) | 34 | assert_equal(100, @plugin.calc_percentage_registration(@person)) |
| 36 | end | 35 | end |
| 37 | - | ||
| 38 | - should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do | ||
| 39 | - @user.secondary_email = "test_email@com.br" | ||
| 40 | - @user.email = "test_email@net.br" | ||
| 41 | - assert @user.save | ||
| 42 | - end | ||
| 43 | end | 36 | end |
src/noosfero-spb/gov_user/test/unit/user_test.rb
| @@ -4,96 +4,22 @@ require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | @@ -4,96 +4,22 @@ require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
| 4 | class UserTest < ActiveSupport::TestCase | 4 | class UserTest < ActiveSupport::TestCase |
| 5 | include PluginTestHelper | 5 | include PluginTestHelper |
| 6 | 6 | ||
| 7 | - should 'not save user whose both email and secondary email are the same' do | ||
| 8 | - user = fast_create(User) | ||
| 9 | - user.email = "test@email.com" | ||
| 10 | - user.secondary_email = "test@email.com" | ||
| 11 | - | ||
| 12 | - assert !user.save | ||
| 13 | - end | ||
| 14 | - | ||
| 15 | - should 'not save user whose email and secondary email have been taken' do | ||
| 16 | - user1 = create_default_user | ||
| 17 | - user2 = fast_create(User) | ||
| 18 | - | ||
| 19 | - user2.email = "primary@email.com" | ||
| 20 | - user2.secondary_email = "secondary@email.com" | ||
| 21 | - assert !user2.save | ||
| 22 | - end | ||
| 23 | - | ||
| 24 | should 'not save user whose email has already been used' do | 7 | should 'not save user whose email has already been used' do |
| 25 | user1 = create_default_user | 8 | user1 = create_default_user |
| 26 | user2 = fast_create(User) | 9 | user2 = fast_create(User) |
| 27 | 10 | ||
| 28 | user2.email = "primary@email.com" | 11 | user2.email = "primary@email.com" |
| 29 | - user2.secondary_email = "noosfero@email.com" | ||
| 30 | - assert !user2.save | ||
| 31 | - end | ||
| 32 | - | ||
| 33 | - should 'not save user whose email has been taken another in users secondary email' do | ||
| 34 | - user1 = create_default_user | ||
| 35 | - user2 = fast_create(User) | ||
| 36 | - | ||
| 37 | - user2.login = "another-login" | ||
| 38 | - user2.email = "secondary@email.com" | ||
| 39 | - user2.secondary_email = "noosfero@email.com" | ||
| 40 | - assert !user2.save | ||
| 41 | - end | ||
| 42 | - | ||
| 43 | - should 'not save user whose secondary email has been taken used in another users email' do | ||
| 44 | - user1 = create_default_user | ||
| 45 | - user2 = fast_create(User) | ||
| 46 | - | ||
| 47 | - user2.login = "another-login" | ||
| 48 | - user2.email = "noosfero@email.com" | ||
| 49 | - user2.secondary_email = "primary@email.com" | ||
| 50 | assert !user2.save | 12 | assert !user2.save |
| 51 | end | 13 | end |
| 52 | 14 | ||
| 53 | - should 'not save user whose secondary email has already been used in another users secondary email' do | ||
| 54 | - user1 = create_default_user | ||
| 55 | - user2 = fast_create(User) | ||
| 56 | - | ||
| 57 | - user2.login = "another-login" | ||
| 58 | - user2.email = "noosfero@email.com" | ||
| 59 | - user2.secondary_email = "secondary@email.com" | ||
| 60 | - assert !user2.save | ||
| 61 | - end | ||
| 62 | - | ||
| 63 | - should 'not save user whose secondary email is in the wrong format' do | ||
| 64 | - user = fast_create(User) | ||
| 65 | - user.email = "test@email.com" | ||
| 66 | - user.secondary_email = "notarightformat.com" | ||
| 67 | - | ||
| 68 | - assert !user.save | ||
| 69 | - | ||
| 70 | - user.secondary_email = "not@arightformatcom" | ||
| 71 | - | ||
| 72 | - assert !user.save | ||
| 73 | - end | ||
| 74 | - | ||
| 75 | - should 'save more than one user without secondary email' do | ||
| 76 | - user = fast_create(User) | ||
| 77 | - user.email = "test@email.com" | ||
| 78 | - user.secondary_email = "" | ||
| 79 | - user.save | ||
| 80 | - | ||
| 81 | - user2 = fast_create(User) | ||
| 82 | - user2.email = "test2@email.com" | ||
| 83 | - user2.secondary_email = "" | ||
| 84 | - assert user2.save | ||
| 85 | - end | ||
| 86 | - | ||
| 87 | private | 15 | private |
| 88 | 16 | ||
| 89 | def create_default_user | 17 | def create_default_user |
| 90 | user = fast_create(User) | 18 | user = fast_create(User) |
| 91 | user.login = "a-login" | 19 | user.login = "a-login" |
| 92 | user.email = "primary@email.com" | 20 | user.email = "primary@email.com" |
| 93 | - user.secondary_email = "secondary@email.com" | ||
| 94 | user.save | 21 | user.save |
| 95 | 22 | ||
| 96 | return user | 23 | return user |
| 97 | end | 24 | end |
| 98 | - | ||
| 99 | end | 25 | end |
src/noosfero-spb/gov_user/views/person_editor_extras.html.erb
| 1 | -<div class="formfieldline"> | ||
| 2 | - <%= label_tag "user[secondary_email]", _('Secondary e-mail')+":", :class=>"formlabel" %> | ||
| 3 | - | ||
| 4 | - <div class="formfield type-text"> | ||
| 5 | - <%= text_field_tag "user[secondary_email]", context.profile.user.secondary_email %> | ||
| 6 | - </div> | ||
| 7 | -</div> | ||
| 8 | - | ||
| 9 | - | ||
| 10 | <div class="formfieldline" id="select_institution"> | 1 | <div class="formfieldline" id="select_institution"> |
| 11 | <%= label_tag "user[institution_ids]", _('Institutions'), :class=>"formlabel" %> | 2 | <%= label_tag "user[institution_ids]", _('Institutions'), :class=>"formlabel" %> |
| 12 | 3 |
src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb
| @@ -236,10 +236,6 @@ Given /^I click on the last button with class "([^"]*)"$/ do |selector| | @@ -236,10 +236,6 @@ Given /^I click on the last button with class "([^"]*)"$/ do |selector| | ||
| 236 | evaluate_script "jQuery('#{selector}').last().trigger('click') && true" | 236 | evaluate_script "jQuery('#{selector}').last().trigger('click') && true" |
| 237 | end | 237 | end |
| 238 | 238 | ||
| 239 | -Given /^the user "([^"]*)" has "([^"]*)" as secondary e\-mail$/ do |login, email| | ||
| 240 | - User[login].update_attributes(:secondary_email => email) | ||
| 241 | -end | ||
| 242 | - | ||
| 243 | Given /^I click on anything with selector "([^"]*)"$/ do |selector| | 239 | Given /^I click on anything with selector "([^"]*)"$/ do |selector| |
| 244 | page.evaluate_script("jQuery('##{selector}').click();") | 240 | page.evaluate_script("jQuery('##{selector}').click();") |
| 245 | end | 241 | end |
src/noosfero-spb/software_communities/lib/ext/profile_helper.rb
| 1 | require_dependency 'profile_helper' | 1 | require_dependency 'profile_helper' |
| 2 | 2 | ||
| 3 | module ProfileHelper | 3 | module ProfileHelper |
| 4 | - PERSON_CATEGORIES[:mpog_profile_information] = [:secondary_email, | ||
| 5 | - :institutions] | 4 | + PERSON_CATEGORIES[:mpog_profile_information] = [:institutions] |
| 6 | 5 | ||
| 7 | def display_mpog_field(title, profile, field, force = false) | 6 | def display_mpog_field(title, profile, field, force = false) |
| 8 | unless force || profile.may_display_field_to?(field, user) | 7 | unless force || profile.may_display_field_to?(field, user) |