Commit a43d588b3a2697a2f472b30dc2feec48788fd5ff
Committed by
Arthur Esposte
1 parent
34c2b8b6
Exists in
master
and in
5 other branches
Removing Users attributes and validations. Now, if you need to use secondary_ema…
…il or other attribute you need to enable the specific user plugin Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
16 changed files
with
14 additions
and
437 deletions
Show diff stats
db/migrate/20150408130613_remove_secondary_email_from_user.rb
0 → 100644
features/user_profile_edition.feature
@@ -23,11 +23,6 @@ Feature: Institution Field | @@ -23,11 +23,6 @@ Feature: Institution Field | ||
23 | | Ministerio do Planejamento | MP | BR | DF | Brasilia | 41.769.591/0001-43 | Autarquia | Judiciario | Federal | Ministerio do Planejamento | | 23 | | Ministerio do Planejamento | MP | BR | DF | Brasilia | 41.769.591/0001-43 | Autarquia | Judiciario | Federal | Ministerio do Planejamento | |
24 | And I am logged in as mpog_admin | 24 | And I am logged in as mpog_admin |
25 | 25 | ||
26 | - Scenario: Go to control panel when clicked on 'Complete your profile' link | ||
27 | - When I follow "Complete your profile" | ||
28 | - Then I should see "Profile settings for " | ||
29 | - And I should see "Personal information" | ||
30 | - | ||
31 | @selenium | 26 | @selenium |
32 | Scenario: Add more then one instituion on profile editor | 27 | Scenario: Add more then one instituion on profile editor |
33 | Given I follow "Edit Profile" | 28 | Given I follow "Edit Profile" |
@@ -40,11 +35,6 @@ Feature: Institution Field | @@ -40,11 +35,6 @@ Feature: Institution Field | ||
40 | And I should see "Governo do DF" within ".institutions_added" | 35 | And I should see "Governo do DF" within ".institutions_added" |
41 | 36 | ||
42 | @selenium | 37 | @selenium |
43 | - Scenario: Verify text information to use governmental e-mail | ||
44 | - Given I follow "Edit Profile" | ||
45 | - Then I should see "If you work in a public agency use your government e-Mail" | ||
46 | - | ||
47 | - @selenium | ||
48 | Scenario: Verify if field 'city' is shown when Brazil is selected | 38 | Scenario: Verify if field 'city' is shown when Brazil is selected |
49 | Given I follow "Edit Profile" | 39 | Given I follow "Edit Profile" |
50 | Then I should see "City" | 40 | Then I should see "City" |
@@ -61,4 +51,3 @@ Feature: Institution Field | @@ -61,4 +51,3 @@ Feature: Institution Field | ||
61 | And I fill in "input_institution" with "Some Nonexistent Institution" | 51 | And I fill in "input_institution" with "Some Nonexistent Institution" |
62 | And I sleep for 1 seconds | 52 | And I sleep for 1 seconds |
63 | Then I should see "No institution found" | 53 | Then I should see "No institution found" |
64 | - |
lib/ext/person.rb
@@ -4,10 +4,6 @@ require_dependency 'person' | @@ -4,10 +4,6 @@ require_dependency 'person' | ||
4 | 4 | ||
5 | class Person | 5 | class Person |
6 | 6 | ||
7 | - settings_items :percentage_incomplete, :type => :string, :default => "" | ||
8 | - | ||
9 | - attr_accessible :percentage_incomplete | ||
10 | - | ||
11 | delegate :login, :to => :user, :prefix => true | 7 | delegate :login, :to => :user, :prefix => true |
12 | 8 | ||
13 | def institutions | 9 | def institutions |
@@ -20,14 +16,6 @@ class Person | @@ -20,14 +16,6 @@ class Person | ||
20 | institutions | 16 | institutions |
21 | end | 17 | end |
22 | 18 | ||
23 | - def secondary_email | ||
24 | - self.user.secondary_email unless self.user.nil? | ||
25 | - end | ||
26 | - | ||
27 | - def secondary_email= value | ||
28 | - self.user.secondary_email = value unless self.user.nil? | ||
29 | - end | ||
30 | - | ||
31 | def software? | 19 | def software? |
32 | false | 20 | false |
33 | end | 21 | end |
lib/ext/user.rb
@@ -2,89 +2,6 @@ require_dependency 'user' | @@ -2,89 +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, :email_suffix_is_gov? | ||
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 | - def email_suffix_is_gov? | ||
56 | - check_gov_suffix_in_secondary_email | ||
57 | - check_gov_email_have_institution | ||
58 | - end | ||
59 | - | ||
60 | - private | ||
61 | - | ||
62 | - def valid_format?(value, string_format) | ||
63 | - !value.nil? && value.length > 0 && !string_format.match(value).nil? | ||
64 | - end | ||
65 | - | ||
66 | - def check_gov_suffix_in_secondary_email | ||
67 | - unless primary_email_has_gov_suffix? | ||
68 | - self.errors.add( | ||
69 | - :base, | ||
70 | - _("The governamental email must be the primary one.") | ||
71 | - ) if secondary_email_has_gov_suffix? | ||
72 | - end | ||
73 | - end | ||
74 | - | ||
75 | - def check_gov_email_have_institution | ||
76 | - self.errors.add( | ||
77 | - :base, | ||
78 | - _("Institution is obligatory if user has a government email.") | ||
79 | - ) if primary_email_has_gov_suffix? && self.institutions.blank? | ||
80 | - end | ||
81 | - | ||
82 | - def primary_email_has_gov_suffix? | ||
83 | - valid_format?(self.email, GOV_SUFFIX) | ||
84 | - end | ||
85 | - | ||
86 | - def secondary_email_has_gov_suffix? | ||
87 | - valid_format?(self.secondary_email, GOV_SUFFIX) | ||
88 | - end | ||
89 | - | ||
90 | -end | ||
91 | \ No newline at end of file | 7 | \ No newline at end of file |
8 | +end |
lib/software_communities_plugin.rb
@@ -17,22 +17,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -17,22 +17,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
17 | _('Add Public Software and MPOG features.') | 17 | _('Add Public Software and MPOG features.') |
18 | end | 18 | end |
19 | 19 | ||
20 | - # Hotspot to insert html without an especific hotspot on view. | ||
21 | - def body_beginning | ||
22 | - return if context.session[:user].nil? or context.session[:hide_incomplete_percentage] == true | ||
23 | - | ||
24 | - person = context.environment.people.where(:user_id=>context.session[:user]).first | ||
25 | - | ||
26 | - if context.profile && context.profile.person? and !person.nil? | ||
27 | - @person = person | ||
28 | - @percentege = calc_percentage_registration(person) | ||
29 | - | ||
30 | - if @percentege >= 0 and @percentege < 100 | ||
31 | - expanded_template('incomplete_registration.html.erb') | ||
32 | - end | ||
33 | - end | ||
34 | - end | ||
35 | - | ||
36 | def profile_editor_extras | 20 | def profile_editor_extras |
37 | profile = context.profile | 21 | profile = context.profile |
38 | 22 | ||
@@ -125,7 +109,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -125,7 +109,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
125 | views/new-software.js | 109 | views/new-software.js |
126 | views/user-edit-profile.js | 110 | views/user-edit-profile.js |
127 | views/create-institution.js | 111 | views/create-institution.js |
128 | - views/complete-registration.js | ||
129 | views/search-software-catalog.js | 112 | views/search-software-catalog.js |
130 | views/profile-tabs-software.js | 113 | views/profile-tabs-software.js |
131 | views/new-community.js | 114 | views/new-community.js |
@@ -152,17 +135,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -152,17 +135,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
152 | end | 135 | end |
153 | end | 136 | end |
154 | 137 | ||
155 | - def calc_percentage_registration(person) | ||
156 | - required_list = profile_required_list | ||
157 | - empty_fields = profile_required_empty_list person | ||
158 | - count = required_list[:person_fields].count + | ||
159 | - required_list[:user_fields].count | ||
160 | - percentege = 100 - ((empty_fields.count * 100) / count) | ||
161 | - person.percentage_incomplete = percentege | ||
162 | - person.save(validate: false) | ||
163 | - percentege | ||
164 | - end | ||
165 | - | ||
166 | def admin_panel_links | 138 | def admin_panel_links |
167 | [ | 139 | [ |
168 | { | 140 | { |
@@ -177,37 +149,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -177,37 +149,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
177 | 149 | ||
178 | protected | 150 | protected |
179 | 151 | ||
180 | - def profile_required_list | ||
181 | - fields = {} | ||
182 | - fields[:person_fields] = %w(cell_phone | ||
183 | - contact_phone | ||
184 | - comercial_phone | ||
185 | - country | ||
186 | - city | ||
187 | - state | ||
188 | - organization_website | ||
189 | - image | ||
190 | - identifier | ||
191 | - name) | ||
192 | - | ||
193 | - fields[:user_fields] = %w(secondary_email email) | ||
194 | - fields | ||
195 | - end | ||
196 | - | ||
197 | - | ||
198 | - def profile_required_empty_list(person) | ||
199 | - empty_fields = [] | ||
200 | - required_list = profile_required_list | ||
201 | - | ||
202 | - required_list[:person_fields].each do |field| | ||
203 | - empty_fields << field.sub('_',' ') if person.send(field).blank? | ||
204 | - end | ||
205 | - required_list[:user_fields].each do |field| | ||
206 | - empty_fields << field.sub('_',' ') if person.user.send(field).blank? | ||
207 | - end | ||
208 | - empty_fields | ||
209 | - end | ||
210 | - | ||
211 | def user_transaction | 152 | def user_transaction |
212 | user_editor_institution_actions | 153 | user_editor_institution_actions |
213 | 154 |
public/initializer.js
@@ -7,7 +7,6 @@ | @@ -7,7 +7,6 @@ | ||
7 | 'NewSoftware', | 7 | 'NewSoftware', |
8 | 'UserEditProfile', | 8 | 'UserEditProfile', |
9 | 'CreateInstitution', | 9 | 'CreateInstitution', |
10 | - 'CompleteRegistration', | ||
11 | 'SearchSoftwareCatalog', | 10 | 'SearchSoftwareCatalog', |
12 | 'SoftwareDownload', | 11 | 'SoftwareDownload', |
13 | 'ProfileTabsSoftware', | 12 | 'ProfileTabsSoftware', |
public/style.css
@@ -38,27 +38,6 @@ | @@ -38,27 +38,6 @@ | ||
38 | width: 180px; | 38 | width: 180px; |
39 | } | 39 | } |
40 | 40 | ||
41 | -#complete_registration { | ||
42 | - padding: 5px; | ||
43 | - width: 100%; | ||
44 | - background-color: #fff; | ||
45 | -} | ||
46 | - | ||
47 | -#complete_registration a { | ||
48 | - text-decoration: none; | ||
49 | -} | ||
50 | - | ||
51 | -#complete_registration a:hover { | ||
52 | - font-weight: bold; | ||
53 | -} | ||
54 | - | ||
55 | -#complete_registration_percentage { | ||
56 | - width: 100%; | ||
57 | - height: 20px; | ||
58 | - background: #fff; | ||
59 | - border: solid 1px #000; | ||
60 | -} | ||
61 | - | ||
62 | #profile-data .invalid { | 41 | #profile-data .invalid { |
63 | border-color: rgb(127, 0, 0); | 42 | border-color: rgb(127, 0, 0); |
64 | box-shadow: 0px 0px 7px red; | 43 | box-shadow: 0px 0px 7px red; |
public/views/complete-registration.js
@@ -1,60 +0,0 @@ | @@ -1,60 +0,0 @@ | ||
1 | -modulejs.define('CompleteRegistration', ['jquery', 'NoosferoRoot'], function($, NoosferoRoot) { | ||
2 | - 'use strict'; | ||
3 | - | ||
4 | - | ||
5 | - var AJAX_URL = { | ||
6 | - hide_registration_incomplete_percentage: | ||
7 | - NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/hide_registration_incomplete_percentage") | ||
8 | - }; | ||
9 | - | ||
10 | - | ||
11 | - function hide_incomplete_percentage(evt) { | ||
12 | - evt.preventDefault(); | ||
13 | - | ||
14 | - jQuery.get(AJAX_URL.hide_registration_incomplete_percentage, {hide:true}, function(response){ | ||
15 | - if( response === true ) { | ||
16 | - jQuery("#complete_registration").fadeOut(); | ||
17 | - } | ||
18 | - }); | ||
19 | - } | ||
20 | - | ||
21 | - | ||
22 | - function show_complete_progressbar() { | ||
23 | - var percentage = jQuery("#complete_registration_message span").html(); | ||
24 | - var canvas_tag = document.getElementById("complete_registration_percentage"); | ||
25 | - | ||
26 | - if( canvas_tag !== null ) { | ||
27 | - var context = canvas_tag.getContext("2d"); | ||
28 | - | ||
29 | - percentage = canvas_tag.width*(percentage/100.0); | ||
30 | - | ||
31 | - context.beginPath(); | ||
32 | - context.rect(0, 0, percentage, canvas_tag.height); | ||
33 | - context.fillStyle = '#00FF00'; | ||
34 | - context.fill(); | ||
35 | - } | ||
36 | - } | ||
37 | - | ||
38 | - | ||
39 | - function repositioning_bar_percentage() { | ||
40 | - var complete_message = $("#complete_registration").remove(); | ||
41 | - | ||
42 | - $(".profile-info-options").before(complete_message); | ||
43 | - } | ||
44 | - | ||
45 | - | ||
46 | - return { | ||
47 | - isCurrentPage: function() { | ||
48 | - return $("#complete_registration").length === 1; | ||
49 | - }, | ||
50 | - | ||
51 | - | ||
52 | - init: function() { | ||
53 | - repositioning_bar_percentage(); | ||
54 | - | ||
55 | - jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); | ||
56 | - | ||
57 | - show_complete_progressbar(); | ||
58 | - } | ||
59 | - } | ||
60 | -}); | ||
61 | \ No newline at end of file | 0 | \ No newline at end of file |
test/helpers/plugin_test_helper.rb
@@ -46,13 +46,12 @@ module PluginTestHelper | @@ -46,13 +46,12 @@ module PluginTestHelper | ||
46 | community | 46 | community |
47 | end | 47 | end |
48 | 48 | ||
49 | - def create_person name, email, password, password_confirmation, secondary_email, state, city | 49 | + def create_person name, email, password, password_confirmation, state, city |
50 | user = create_user( | 50 | user = create_user( |
51 | name.to_slug, | 51 | name.to_slug, |
52 | email, | 52 | email, |
53 | password, | 53 | password, |
54 | password_confirmation, | 54 | password_confirmation, |
55 | - secondary_email | ||
56 | ) | 55 | ) |
57 | person = Person::new | 56 | person = Person::new |
58 | 57 | ||
@@ -70,14 +69,13 @@ module PluginTestHelper | @@ -70,14 +69,13 @@ module PluginTestHelper | ||
70 | person | 69 | person |
71 | end | 70 | end |
72 | 71 | ||
73 | - def create_user login, email, password, password_confirmation, secondary_email | 72 | + def create_user login, email, password, password_confirmation |
74 | user = User.new | 73 | user = User.new |
75 | 74 | ||
76 | user.login = login | 75 | user.login = login |
77 | user.email = email | 76 | user.email = email |
78 | user.password = password | 77 | user.password = password |
79 | user.password_confirmation = password_confirmation | 78 | user.password_confirmation = password_confirmation |
80 | - user.secondary_email = secondary_email | ||
81 | 79 | ||
82 | user | 80 | user |
83 | end | 81 | end |
test/unit/communities_block_test.rb
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | @@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
5 | class CommunitiesBlockTest < ActiveSupport::TestCase | 5 | class CommunitiesBlockTest < ActiveSupport::TestCase |
6 | include PluginTestHelper | 6 | include PluginTestHelper |
7 | def setup | 7 | def setup |
8 | - @person = create_person("My Name", "user@email.com", "123456", "123456", "user@secondary_email.com", "Any State", "Some City") | 8 | + @person = create_person("My Name", "user@email.com", "123456", "123456", "Any State", "Some City") |
9 | 9 | ||
10 | @gov_power = GovernmentalPower.create(:name=>"Some Gov Power") | 10 | @gov_power = GovernmentalPower.create(:name=>"Some Gov Power") |
11 | @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") | 11 | @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") |
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_silva@email.com", | ||
31 | "DF", | 30 | "DF", |
32 | "Gama" | 31 | "Gama" |
33 | ) | 32 | ) |
test/unit/software_communities_person_test.rb
@@ -15,7 +15,6 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | @@ -15,7 +15,6 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | ||
15 | "user@email.com", | 15 | "user@email.com", |
16 | "123456", | 16 | "123456", |
17 | "123456", | 17 | "123456", |
18 | - "user@secondary_email.com", | ||
19 | "Any State", | 18 | "Any State", |
20 | "Some City" | 19 | "Some City" |
21 | ) | 20 | ) |
@@ -29,13 +28,6 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | @@ -29,13 +28,6 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | ||
29 | assert_kind_of Noosfero::Plugin, @plugin | 28 | assert_kind_of Noosfero::Plugin, @plugin |
30 | end | 29 | end |
31 | 30 | ||
32 | - | ||
33 | - should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do | ||
34 | - @user.secondary_email = "test_email@com.br" | ||
35 | - @user.email = "test_email@net.br" | ||
36 | - assert @user.save | ||
37 | - end | ||
38 | - | ||
39 | should 'save person with a valid full name' do | 31 | should 'save person with a valid full name' do |
40 | p = Person::new :name=>"S1mpl3 0f N4m3", :identifier=>"simple-name" | 32 | p = Person::new :name=>"S1mpl3 0f N4m3", :identifier=>"simple-name" |
41 | p.user = fast_create(:user) | 33 | p.user = fast_create(:user) |
@@ -63,23 +55,6 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | @@ -63,23 +55,6 @@ class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase | ||
63 | assert !p.save , _("Name Should begin with a capital letter and no special characters") | 55 | assert !p.save , _("Name Should begin with a capital letter and no special characters") |
64 | end | 56 | end |
65 | 57 | ||
66 | - should 'calculate the percentege of person incomplete fields' do | ||
67 | - @person.cell_phone = "76888919" | ||
68 | - @person.contact_phone = "987654321" | ||
69 | - | ||
70 | - assert_equal(67, @plugin.calc_percentage_registration(@person)) | ||
71 | - | ||
72 | - @person.comercial_phone = "11223344" | ||
73 | - @person.country = "I dont know" | ||
74 | - @person.state = "I dont know" | ||
75 | - @person.city = "I dont know" | ||
76 | - @person.organization_website = "www.whatever.com" | ||
77 | - @person.image = Image::new :uploaded_data=>fixture_file_upload('/files/rails.png', 'image/png') | ||
78 | - @person.save | ||
79 | - | ||
80 | - assert_equal(100, @plugin.calc_percentage_registration(@person)) | ||
81 | - end | ||
82 | - | ||
83 | should 'get a list of softwares of a person' do | 58 | should 'get a list of softwares of a person' do |
84 | software1 = create_software_info "noosfero" | 59 | software1 = create_software_info "noosfero" |
85 | software2 = create_software_info "colab" | 60 | software2 = create_software_info "colab" |
test/unit/software_communities_plugin_user_test.rb
@@ -1,138 +0,0 @@ | @@ -1,138 +0,0 @@ | ||
1 | -require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
3 | - | ||
4 | -class SoftwareCommunitiesPluginUserTest < ActiveSupport::TestCase | ||
5 | - include PluginTestHelper | ||
6 | - | ||
7 | - should 'not save user whose both email and secondary email are the same' do | ||
8 | - | ||
9 | - user = fast_create(User) | ||
10 | - user.email = "test@email.com" | ||
11 | - user.secondary_email = "test@email.com" | ||
12 | - | ||
13 | - assert !user.save | ||
14 | - end | ||
15 | - | ||
16 | - should 'not save user whose email and secondary email have been taken' do | ||
17 | - user1 = create_default_user | ||
18 | - user2 = fast_create(User) | ||
19 | - | ||
20 | - user2.email = "primary@email.com" | ||
21 | - user2.secondary_email = "secondary@email.com" | ||
22 | - assert !user2.save | ||
23 | - end | ||
24 | - | ||
25 | - should 'not save user whose email has already been used' do | ||
26 | - user1 = create_default_user | ||
27 | - user2 = fast_create(User) | ||
28 | - | ||
29 | - user2.email = "primary@email.com" | ||
30 | - user2.secondary_email = "noosfero@email.com" | ||
31 | - assert !user2.save | ||
32 | - end | ||
33 | - | ||
34 | - should 'not save user whose email has been taken another in users secondary email' do | ||
35 | - user1 = create_default_user | ||
36 | - user2 = fast_create(User) | ||
37 | - | ||
38 | - user2.login = "another-login" | ||
39 | - user2.email = "secondary@email.com" | ||
40 | - user2.secondary_email = "noosfero@email.com" | ||
41 | - assert !user2.save | ||
42 | - end | ||
43 | - | ||
44 | - should 'not save user whose secondary email has been taken used in another users email' do | ||
45 | - user1 = create_default_user | ||
46 | - user2 = fast_create(User) | ||
47 | - | ||
48 | - user2.login = "another-login" | ||
49 | - user2.email = "noosfero@email.com" | ||
50 | - user2.secondary_email = "primary@email.com" | ||
51 | - assert !user2.save | ||
52 | - end | ||
53 | - | ||
54 | - should 'not save user whose secondary email has already been used in another users secondary email' do | ||
55 | - user1 = create_default_user | ||
56 | - user2 = fast_create(User) | ||
57 | - | ||
58 | - user2.login = "another-login" | ||
59 | - user2.email = "noosfero@email.com" | ||
60 | - user2.secondary_email = "secondary@email.com" | ||
61 | - assert !user2.save | ||
62 | - end | ||
63 | - | ||
64 | - should 'not save user whose secondary email is in the wrong format' do | ||
65 | - user = fast_create(User) | ||
66 | - user.email = "test@email.com" | ||
67 | - user.secondary_email = "notarightformat.com" | ||
68 | - | ||
69 | - assert !user.save | ||
70 | - | ||
71 | - user.secondary_email = "not@arightformatcom" | ||
72 | - | ||
73 | - assert !user.save | ||
74 | - end | ||
75 | - | ||
76 | - should 'save more than one user without secondary email' do | ||
77 | - user = fast_create(User) | ||
78 | - user.email = "test@email.com" | ||
79 | - user.secondary_email = "" | ||
80 | - user.save | ||
81 | - | ||
82 | - user2 = fast_create(User) | ||
83 | - user2.email = "test2@email.com" | ||
84 | - user2.secondary_email = "" | ||
85 | - assert user2.save | ||
86 | - end | ||
87 | - should 'return an error if secondary email is governmental and primary is not' do | ||
88 | - invalid_msg = "The governamental email must be the primary one." | ||
89 | - user = fast_create(User) | ||
90 | - | ||
91 | - user.email = "test@email.com" | ||
92 | - user.secondary_email = "test@gov.br" | ||
93 | - | ||
94 | - assert !user.save | ||
95 | - assert user.errors.full_messages.include?(invalid_msg) | ||
96 | - end | ||
97 | - | ||
98 | - should 'have institution if email is governmental' do | ||
99 | - user = fast_create(User) | ||
100 | - | ||
101 | - user.email = "testtest@gov.br" | ||
102 | - | ||
103 | - user.institutions = [] | ||
104 | - assert !user.save, "this should not save" | ||
105 | - | ||
106 | - gov_power = GovernmentalPower.create(:name=>"Some Gov Power") | ||
107 | - gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") | ||
108 | - juridical_nature = JuridicalNature.create(:name => "Autarquia") | ||
109 | - institution = create_public_institution( | ||
110 | - "Ministerio Publico da Uniao", | ||
111 | - "MPU", | ||
112 | - "BR", | ||
113 | - "DF", | ||
114 | - "Gama", | ||
115 | - juridical_nature, | ||
116 | - gov_power, | ||
117 | - gov_sphere, | ||
118 | - "44.555.666/7777-88" | ||
119 | - ) | ||
120 | - institution.save! | ||
121 | - | ||
122 | - user.institutions << institution | ||
123 | - assert user.save, "this should save" | ||
124 | - end | ||
125 | - | ||
126 | - private | ||
127 | - | ||
128 | - def create_default_user | ||
129 | - user = fast_create(User) | ||
130 | - user.login = "a-login" | ||
131 | - user.email = "primary@email.com" | ||
132 | - user.secondary_email = "secondary@email.com" | ||
133 | - user.save | ||
134 | - | ||
135 | - return user | ||
136 | - end | ||
137 | - | ||
138 | -end |
test/unit/softwares_block_test.rb
@@ -27,7 +27,6 @@ class SoftwaresBlockTest < ActiveSupport::TestCase | @@ -27,7 +27,6 @@ class SoftwaresBlockTest < ActiveSupport::TestCase | ||
27 | "jose_augusto@email.com", | 27 | "jose_augusto@email.com", |
28 | "aaaaaaa", | 28 | "aaaaaaa", |
29 | "aaaaaaa", | 29 | "aaaaaaa", |
30 | - "jose_silva@email.com", | ||
31 | "DF", | 30 | "DF", |
32 | "Gama" | 31 | "Gama" |
33 | ) | 32 | ) |
views/incomplete_registration.html.erb
@@ -1,11 +0,0 @@ | @@ -1,11 +0,0 @@ | ||
1 | -<div id='complete_registration'> | ||
2 | - <div id="complete_registration_message"> | ||
3 | - <div><%= _("Complete Profile")+": <span>#{@percentege}</span>%" %></div> | ||
4 | - <canvas id="complete_registration_percentage" width="100%" height="20"></canvas> | ||
5 | - <div> | ||
6 | - <%= link_to _("Complete your profile"), "#{Noosfero.root}/myprofile/#{@person.identifier}/profile_editor/edit" %> | | ||
7 | - <%= link_to _("Hide"), "#", :class=>"hide-incomplete-percentage" %> | ||
8 | - </div> | ||
9 | - </div> | ||
10 | - </div> | ||
11 | -</div> |
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 | <div class="formfieldline" id="select_institution"> | 1 | <div class="formfieldline" id="select_institution"> |
10 | <%= label_tag "user[institution_ids]", _('Institutions'), :class=>"formlabel" %> | 2 | <%= label_tag "user[institution_ids]", _('Institutions'), :class=>"formlabel" %> |
11 | 3 |