noosfero | Fix: allowing submission of not logged users

Daniela Feitosa gitlab at gitlab.com
Fri Mar 13 17:51:42 BRT 2015


Daniela Feitosa pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>

Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/5b7b8e5273a8ef165d8dba64e500832583da4835">5b7b8e52</a> by Daniela Feitosa
Fix: allowing submission of not logged users

Added the missing character to identify form

- - - - -


Changes:

=====================================
plugins/custom_forms/controllers/custom_forms_plugin_profile_controller.rb
=====================================
--- a/plugins/custom_forms/controllers/custom_forms_plugin_profile_controller.rb
+++ b/plugins/custom_forms/controllers/custom_forms_plugin_profile_controller.rb
@@ -9,7 +9,7 @@ class CustomFormsPluginProfileController < ProfileController
       @submission = CustomFormsPlugin::Submission.find_by_form_id_and_profile_id(@form.id,user.id)
       @submission ||= CustomFormsPlugin::Submission.new(:form => @form, :profile => user)
     else
-      @submission = CustomFormsPlugin::Submission.new(:form => @for)
+      @submission = CustomFormsPlugin::Submission.new(:form => @form)
     end
 
     # build the answers

=====================================
plugins/custom_forms/test/functional/custom_forms_plugin_profile_controller_test.rb
=====================================
--- a/plugins/custom_forms/test/functional/custom_forms_plugin_profile_controller_test.rb
+++ b/plugins/custom_forms/test/functional/custom_forms_plugin_profile_controller_test.rb
@@ -29,6 +29,17 @@ class CustomFormsPluginProfileControllerTest < ActionController::TestCase
     assert_redirected_to :action => 'show'
   end
 
+  should 'save submission if fields are ok and user is not logged in' do
+    logout
+    form = CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software')
+    field = CustomFormsPlugin::TextField.create(:name => 'Name', :form => form)
+
+    assert_difference 'CustomFormsPlugin::Submission.count', 1 do
+      post :show, :profile => profile.identifier, :id => form.id, :author_name => "john", :author_email => 'john at example.com', :submission => {field.id.to_s => 'Noosfero'}
+    end
+    assert_redirected_to :action => 'show'
+  end
+
   should 'disable fields if form expired' do
     form = CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software', :begining => Time.now + 1.day)
     form.fields << CustomFormsPlugin::TextField.create(:name => 'Field Name', :form => form, :default_value => "First Field")

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150313/2127f1c7/attachment.html>


More information about the Noosfero-dev mailing list