From 768db9b26e8aeb5bb51cb8b52ceb60645a78951d Mon Sep 17 00:00:00 2001 From: Daniel Bucher Date: Thu, 5 Jun 2014 21:37:12 +0000 Subject: [PATCH] profile_editor: added mass-assign support for person's fields --- app/models/person.rb | 2 +- test/functional/profile_editor_controller_test.rb | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index dd33c4d..d0d0521 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -1,7 +1,7 @@ # A person is the profile of an user holding all relationships with the rest of the system class Person < Profile - attr_accessible :organization, :contact_information, :sex, :birth_date + 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 SEARCH_FILTERS += %w[ more_popular diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index a6b0f28..55509bf 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -6,7 +6,7 @@ class ProfileEditorController; def rescue_action(e) raise e end; end class ProfileEditorControllerTest < ActionController::TestCase all_fixtures - + def setup @controller = ProfileEditorController.new @request = ActionController::TestRequest.new @@ -20,11 +20,11 @@ class ProfileEditorControllerTest < ActionController::TestCase def test_local_files_reference assert_local_files_reference :get, :index, :profile => profile.identifier end - + def test_valid_xhtml assert_valid_xhtml end - + def test_index get :index, :profile => profile.identifier assert_template 'index' @@ -50,7 +50,7 @@ class ProfileEditorControllerTest < ActionController::TestCase end should 'saving profile info' do - person = profile + person = profile post :edit, :profile => profile.identifier, :profile_data => { 'name' => 'new person', 'contact_information' => 'new contact information', 'address' => 'new address', 'sex' => 'female' } assert_redirected_to :controller => 'profile_editor', :action => 'index' person = Person.find(person.id) @@ -60,6 +60,15 @@ class ProfileEditorControllerTest < ActionController::TestCase assert_equal 'female', person.sex end + should 'mass assign all environment configurable person fields' do + person = profile + + 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" } + + assert_response :redirect + assert_redirected_to :controller => 'profile_editor', :action => 'index' + end + should 'not permmit if not logged' do logout get :index, :profile => profile.identifier @@ -426,7 +435,7 @@ class ProfileEditorControllerTest < ActionController::TestCase get :index, :profile => ent.identifier assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{ent.identifier}/profile_editor/enable" } end - + should 'link to disable enterprise' do ent = fast_create(Enterprise, :enabled => true) get :index, :profile => ent.identifier -- libgit2 0.21.2