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 | false |
| 15 | 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 | 17 | def institutions |
| 26 | 18 | institutions = [] |
| 27 | 19 | unless self.user.institutions.nil? | ... | ... |
src/noosfero-spb/gov_user/lib/ext/user.rb
| ... | ... | @@ -2,59 +2,6 @@ require_dependency 'user' |
| 2 | 2 | |
| 3 | 3 | class User |
| 4 | 4 | |
| 5 | - GOV_SUFFIX = /^.*@[gov.br|jus.br|leg.br|mp.br]+$/ | |
| 6 | - | |
| 7 | 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 | 7 | end | ... | ... |
src/noosfero-spb/gov_user/lib/gov_user_plugin.rb
src/noosfero-spb/gov_user/public/views/user-edit-profile.js
| ... | ... | @@ -158,7 +158,6 @@ modulejs.define('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoic |
| 158 | 158 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_contact_phone")); |
| 159 | 159 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_cell_phone")); |
| 160 | 160 | try_to_remove(containers, $("#select_institution")); |
| 161 | - try_to_remove(containers, $("#user_secondary_email").parent().parent()); | |
| 162 | 161 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_email")); |
| 163 | 162 | try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_name")); |
| 164 | 163 | try_to_remove(containers, $(".pseudoformlabel").parent().parent()); |
| ... | ... | @@ -191,7 +190,6 @@ modulejs.define('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoic |
| 191 | 190 | fix_phone_mask_format("#profile_data_contact_phone"); |
| 192 | 191 | |
| 193 | 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 | 193 | add_blur_fields("#profile_data_personal_website", "site_error", invalid_site_validation); |
| 196 | 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 | 2 | |
| 3 | 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 | 6 | user = create_user( |
| 7 | 7 | name.to_slug, |
| 8 | 8 | email, |
| 9 | 9 | password, |
| 10 | - password_confirmation, | |
| 11 | - secondary_email | |
| 10 | + password_confirmation | |
| 12 | 11 | ) |
| 13 | 12 | person = Person::new |
| 14 | 13 | |
| ... | ... | @@ -26,14 +25,13 @@ module PluginTestHelper |
| 26 | 25 | person |
| 27 | 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 | 29 | user = User.new |
| 31 | 30 | |
| 32 | 31 | user.login = login |
| 33 | 32 | user.email = email |
| 34 | 33 | user.password = password |
| 35 | 34 | user.password_confirmation = password_confirmation |
| 36 | - user.secondary_email = secondary_email | |
| 37 | 35 | |
| 38 | 36 | user |
| 39 | 37 | end | ... | ... |
src/noosfero-spb/gov_user/test/unit/institutions_block_test.rb
src/noosfero-spb/gov_user/test/unit/person_test.rb
| ... | ... | @@ -12,7 +12,6 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase |
| 12 | 12 | "user@email.com", |
| 13 | 13 | "123456", |
| 14 | 14 | "123456", |
| 15 | - "user@secondaryemail.com", | |
| 16 | 15 | "Any State", |
| 17 | 16 | "Some City" |
| 18 | 17 | ) |
| ... | ... | @@ -22,7 +21,7 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase |
| 22 | 21 | @person.cell_phone = "76888919" |
| 23 | 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 | 26 | @person.comercial_phone = "11223344" |
| 28 | 27 | @person.country = "I dont know" |
| ... | ... | @@ -34,10 +33,4 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase |
| 34 | 33 | |
| 35 | 34 | assert_equal(100, @plugin.calc_percentage_registration(@person)) |
| 36 | 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 | 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 | 4 | class UserTest < ActiveSupport::TestCase |
| 5 | 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 | 7 | should 'not save user whose email has already been used' do |
| 25 | 8 | user1 = create_default_user |
| 26 | 9 | user2 = fast_create(User) |
| 27 | 10 | |
| 28 | 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 | 12 | assert !user2.save |
| 51 | 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 | 15 | private |
| 88 | 16 | |
| 89 | 17 | def create_default_user |
| 90 | 18 | user = fast_create(User) |
| 91 | 19 | user.login = "a-login" |
| 92 | 20 | user.email = "primary@email.com" |
| 93 | - user.secondary_email = "secondary@email.com" | |
| 94 | 21 | user.save |
| 95 | 22 | |
| 96 | 23 | return user |
| 97 | 24 | end |
| 98 | - | |
| 99 | 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 | 1 | <div class="formfieldline" id="select_institution"> |
| 11 | 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 | 236 | evaluate_script "jQuery('#{selector}').last().trigger('click') && true" |
| 237 | 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 | 239 | Given /^I click on anything with selector "([^"]*)"$/ do |selector| |
| 244 | 240 | page.evaluate_script("jQuery('##{selector}').click();") |
| 245 | 241 | end | ... | ... |
src/noosfero-spb/software_communities/lib/ext/profile_helper.rb
| 1 | 1 | require_dependency 'profile_helper' |
| 2 | 2 | |
| 3 | 3 | module ProfileHelper |
| 4 | - PERSON_CATEGORIES[:mpog_profile_information] = [:secondary_email, | |
| 5 | - :institutions] | |
| 4 | + PERSON_CATEGORIES[:mpog_profile_information] = [:institutions] | |
| 6 | 5 | |
| 7 | 6 | def display_mpog_field(title, profile, field, force = false) |
| 8 | 7 | unless force || profile.may_display_field_to?(field, user) | ... | ... |