[Git][noosfero/noosfero][master] 2 commits: custom-fields: update even when it is empty
Rodrigo Souto
gitlab at mg.gitlab.com
Thu Mar 1 15:27:25 BRT 2018
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
6f20b78b by Rodrigo Souto at 2018-02-28T17:41:58Z
custom-fields: update even when it is empty
- - - - -
ce3eef54 by Rodrigo Souto at 2018-03-01T18:27:11Z
Merge branch 'custom-fields-remove' into 'master'
custom-fields: update even when it is empty
See merge request noosfero/noosfero!1410
- - - - -
2 changed files:
- app/controllers/my_profile/cms_controller.rb
- test/functional/cms_controller_test.rb
Changes:
=====================================
app/controllers/my_profile/cms_controller.rb
=====================================
--- a/app/controllers/my_profile/cms_controller.rb
+++ b/app/controllers/my_profile/cms_controller.rb
@@ -90,7 +90,9 @@ class CmsController < MyProfileController
@article.image.save!
end
params_metadata = params[:article].try(:delete, :metadata) || {}
+ custom_fields = params_metadata.try(:delete, :custom_fields) || {}
@article.metadata = @article.metadata.merge(params_metadata)
+ @article.metadata[:custom_fields] = custom_fields
@article.last_changed_by = user
if @article.update(params[:article])
if !continue
=====================================
test/functional/cms_controller_test.rb
=====================================
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -2117,6 +2117,23 @@ class CmsControllerTest < ActionController::TestCase
assert_equal '5', a.metadata['custom_fields']['field1']['value']
end
+ should 'update custom_fields even when it is empty' do
+ a = @profile.articles.build(:name => 'my article')
+ a.metadata = {
+ 'mydata' => 'data',
+ :custom_fields => { :field1 => { value: 1 }, :field2 => { value: 5 } }
+ }
+ a.save!
+
+ post :edit, :profile => @profile.identifier, :id => a.id, :article => {
+ :body => 'new content for this article'}
+
+ a.reload
+
+ assert a.metadata['custom_fields']['field1'].blank?
+ assert a.metadata['custom_fields']['field2'].blank?
+ end
+
should 'execute upload_file method with single upload file option not exist in profile' do
get :upload_files, profile: profile.identifier
assert_template 'upload_files'
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/3d0f722cb0bf6f8cc26bbbde23580a9f7b128749...ce3eef545ccdf39a7324ad6c1fd4275056e31360
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/3d0f722cb0bf6f8cc26bbbde23580a9f7b128749...ce3eef545ccdf39a7324ad6c1fd4275056e31360
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180301/d2a1e2d3/attachment-0001.html>
More information about the Noosfero-dev
mailing list