diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb
index 1150b14..151b01e 100644
--- a/app/controllers/my_profile/profile_editor_controller.rb
+++ b/app/controllers/my_profile/profile_editor_controller.rb
@@ -15,20 +15,14 @@ class ProfileEditorController < MyProfileController
@possible_domains = profile.possible_domains
if request.post?
params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash)
- begin
- Profile.transaction do
- Image.transaction do
- if profile.update_attributes!(params[:profile_data])
- redirect_to :action => 'index', :profile => profile.identifier
- end
+ Profile.transaction do
+ Image.transaction do
+ if @profile_data.update_attributes(params[:profile_data])
+ redirect_to :action => 'index', :profile => profile.identifier
+ else
+ profile.identifier = params[:profile] if profile.identifier.blank?
end
- end
- rescue Exception => ex
- if profile.identifier.blank?
- profile.identifier = params[:profile]
- end
- session[:notice] = _('Cannot update profile')
- logger.error ex.to_s
+ end
end
end
end
diff --git a/app/models/person.rb b/app/models/person.rb
index 2627e8e..3dc93c5 100644
--- a/app/models/person.rb
+++ b/app/models/person.rb
@@ -157,11 +157,6 @@ class Person < Profile
validates_multiparameter_assignments
- validates_each :birth_date do |record,attr,value|
- date_str = record.birth_date_before_type_cast
- record.errors.add(attr) if value.blank? && !date_str.blank?
- end
-
def self.fields
FIELDS
end
diff --git a/app/views/profile_editor/_person_form.html.erb b/app/views/profile_editor/_person_form.html.erb
index 4c8a2f8..ca25acf 100644
--- a/app/views/profile_editor/_person_form.html.erb
+++ b/app/views/profile_editor/_person_form.html.erb
@@ -16,7 +16,7 @@
<%= optional_field(@person, 'jabber_id', f.text_field(:jabber_id, :rel => _('Jabber'))) %>
<%= optional_field(@person, 'personal_website', f.text_field(:personal_website, :rel => _('Personal website'))) %>
<%= optional_field(@person, 'sex', f.radio_group(:profile_data, :sex, [ ['male',_('Male')], ['female',_('Female')] ])) %>
-<%= optional_field(@person, 'birth_date', labelled_form_field(_('Birth date'), '
' + pick_date(:profile_data, :birth_date, {:start_year => (Date.today.year - 100), :end_year => (Date.today.year - 5)}) + '
')) %>
+<%= optional_field(@person, 'birth_date', labelled_form_field(_('Birth date'), date_field('profile_data[birth_date]', @profile_data. birth_date, '%Y-%m-%d', {:change_month => true, :change_year => true, :year_range => '-100:-5', :date_format => 'yy-mm-dd'}, {:id => 'profile_data_birth_date'}))) %>
<%= optional_field(@person, 'nationality', f.text_field(:nationality, :rel => _('Nationality'))) %>
<%= optional_field(@person, 'country', select_country(_('Country'), 'profile_data', 'country', {:class => 'type-select'})) %>
<%= optional_field(@person, 'state', f.text_field(:state, :id => 'state_field', :rel => _('State'))) %>
diff --git a/features/edit_profile.feature b/features/edit_profile.feature
index 114454e..3745c28 100644
--- a/features/edit_profile.feature
+++ b/features/edit_profile.feature
@@ -6,30 +6,6 @@ Feature: edit profile
| joao |
Given I am logged in as "joao"
- Scenario: Warn about invalid birth date when active
- Given the following person fields are active fields
- | display_name |
- | birth_date |
- When I go to joao's control panel
- And I follow "Edit Profile"
- And I select "November" from "profile_data_birth_date_2i"
- And I select "15" from "profile_data_birth_date_3i"
- And I press "Save"
- Then I should see "Birth date is invalid"
- And I should not see "Birth date can't be blank"
-
- Scenario: Warn about invalid birth date when required
- Given the following person fields are required fields
- | display_name |
- | birth_date |
- When I go to joao's control panel
- And I follow "Edit Profile"
- And I select "November" from "profile_data_birth_date_2i"
- And I select "15" from "profile_data_birth_date_3i"
- And I press "Save"
- Then I should see "Birth date is invalid"
- And I should not see "Birth date can't be blank"
-
Scenario: Not warn if birth date is valid when active
Given the following person fields are active fields
| display_name |
diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb
index d6663a0..f925c53 100644
--- a/test/unit/person_test.rb
+++ b/test/unit/person_test.rb
@@ -1152,21 +1152,6 @@ class PersonTest < ActiveSupport::TestCase
assert_includes Person.more_active, profile
end
- should 'handle multiparameter attribute exception on birth date field' do
- assert_nothing_raised ActiveRecord::MultiparameterAssignmentErrors do
- p = Person.new(
- :name => 'birthday', :identifier => 'birthday',
- 'birth_date(1i)' => '', 'birth_date(2i)' => '6', 'birth_date(3i)' => '16'
- )
- end
- end
-
- should 'not accept an empty year on birth date' do
- p = Person.new(:birth_date => "1115")
- p.valid?
- assert p.errors[:birth_date.to_s].present?
- end
-
should 'associate report with the correct complaint' do
p1 = create_user('user1').person
p2 = create_user('user2').person
--
libgit2 0.21.2