Commit 768db9b26e8aeb5bb51cb8b52ceb60645a78951d
1 parent
247ad826
Exists in
master
and in
29 other branches
profile_editor: added mass-assign support for person's fields
Added mass-assign support for all person's field that are configurable on the fields environment page. (ActionItem3147)
Showing
2 changed files
with
15 additions
and
6 deletions
Show diff stats
app/models/person.rb
1 | # A person is the profile of an user holding all relationships with the rest of the system | 1 | # A person is the profile of an user holding all relationships with the rest of the system |
2 | class Person < Profile | 2 | class Person < Profile |
3 | 3 | ||
4 | - attr_accessible :organization, :contact_information, :sex, :birth_date | 4 | + attr_accessible :organization, :contact_information, :sex, :birth_date, :cell_phone, :comercial_phone, :jabber_id, :personal_website, :nationality, :address_reference, :district, :schooling, :schooling_status, :formation, :custom_formation, :area_of_study, :custom_area_of_study, :professional_activity, :organization_website |
5 | 5 | ||
6 | SEARCH_FILTERS += %w[ | 6 | SEARCH_FILTERS += %w[ |
7 | more_popular | 7 | more_popular |
test/functional/profile_editor_controller_test.rb
@@ -6,7 +6,7 @@ class ProfileEditorController; def rescue_action(e) raise e end; end | @@ -6,7 +6,7 @@ class ProfileEditorController; def rescue_action(e) raise e end; end | ||
6 | 6 | ||
7 | class ProfileEditorControllerTest < ActionController::TestCase | 7 | class ProfileEditorControllerTest < ActionController::TestCase |
8 | all_fixtures | 8 | all_fixtures |
9 | - | 9 | + |
10 | def setup | 10 | def setup |
11 | @controller = ProfileEditorController.new | 11 | @controller = ProfileEditorController.new |
12 | @request = ActionController::TestRequest.new | 12 | @request = ActionController::TestRequest.new |
@@ -20,11 +20,11 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -20,11 +20,11 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
20 | def test_local_files_reference | 20 | def test_local_files_reference |
21 | assert_local_files_reference :get, :index, :profile => profile.identifier | 21 | assert_local_files_reference :get, :index, :profile => profile.identifier |
22 | end | 22 | end |
23 | - | 23 | + |
24 | def test_valid_xhtml | 24 | def test_valid_xhtml |
25 | assert_valid_xhtml | 25 | assert_valid_xhtml |
26 | end | 26 | end |
27 | - | 27 | + |
28 | def test_index | 28 | def test_index |
29 | get :index, :profile => profile.identifier | 29 | get :index, :profile => profile.identifier |
30 | assert_template 'index' | 30 | assert_template 'index' |
@@ -50,7 +50,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -50,7 +50,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
50 | end | 50 | end |
51 | 51 | ||
52 | should 'saving profile info' do | 52 | should 'saving profile info' do |
53 | - person = profile | 53 | + person = profile |
54 | post :edit, :profile => profile.identifier, :profile_data => { 'name' => 'new person', 'contact_information' => 'new contact information', 'address' => 'new address', 'sex' => 'female' } | 54 | post :edit, :profile => profile.identifier, :profile_data => { 'name' => 'new person', 'contact_information' => 'new contact information', 'address' => 'new address', 'sex' => 'female' } |
55 | assert_redirected_to :controller => 'profile_editor', :action => 'index' | 55 | assert_redirected_to :controller => 'profile_editor', :action => 'index' |
56 | person = Person.find(person.id) | 56 | person = Person.find(person.id) |
@@ -60,6 +60,15 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -60,6 +60,15 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
60 | assert_equal 'female', person.sex | 60 | assert_equal 'female', person.sex |
61 | end | 61 | end |
62 | 62 | ||
63 | + should 'mass assign all environment configurable person fields' do | ||
64 | + person = profile | ||
65 | + | ||
66 | + post :edit, :profile => profile.identifier, :profile_data => { "nickname" => "ze", "description" => "Just a regular ze.", "contact_information" => "What?", "contact_phone" => "+0551133445566", "cell_phone" => "+0551188889999", "comercial_phone" => "+0551144336655", "jabber_id" => "ze1234", "personal_website" => "http://ze.com.br", "sex" => "male", "birth_date" => "2014-06-04", "nationality" => "Brazilian", "country" => "BR", "state" => "DF", "city" => "Brasilia", "zip_code" => "70300-010", "address" => "Palacio do Planalto", "address_reference" => "Praca dos tres poderes", "district" => "DF", "schooling" => "Undergraduate", "schooling_status" => "Concluded", "formation" => "Engineerings", "area_of_study" => "Metallurgy", "professional_activity" => "Metallurgic", "organization" => "Metal Corp.", "organization_website" => "http://metal.com" } | ||
67 | + | ||
68 | + assert_response :redirect | ||
69 | + assert_redirected_to :controller => 'profile_editor', :action => 'index' | ||
70 | + end | ||
71 | + | ||
63 | should 'not permmit if not logged' do | 72 | should 'not permmit if not logged' do |
64 | logout | 73 | logout |
65 | get :index, :profile => profile.identifier | 74 | get :index, :profile => profile.identifier |
@@ -426,7 +435,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -426,7 +435,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
426 | get :index, :profile => ent.identifier | 435 | get :index, :profile => ent.identifier |
427 | assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{ent.identifier}/profile_editor/enable" } | 436 | assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{ent.identifier}/profile_editor/enable" } |
428 | end | 437 | end |
429 | - | 438 | + |
430 | should 'link to disable enterprise' do | 439 | should 'link to disable enterprise' do |
431 | ent = fast_create(Enterprise, :enabled => true) | 440 | ent = fast_create(Enterprise, :enabled => true) |
432 | get :index, :profile => ent.identifier | 441 | get :index, :profile => ent.identifier |