Commit f448634b0cff1c24fe97c43c1bd2634c0bf555c5

Authored by Victor Costa
1 parent 80b43289

rails3: fix custom_forms plugin

Showing 26 changed files with 93 additions and 79 deletions   Show diff stats
plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
@@ -75,13 +75,14 @@ class CustomFormsPluginMyprofileController < MyProfileController @@ -75,13 +75,14 @@ class CustomFormsPluginMyprofileController < MyProfileController
75 format.csv do 75 format.csv do
76 # CSV contains form fields, timestamp, user name and user email 76 # CSV contains form fields, timestamp, user name and user email
77 columns = @form.fields.count + 3 77 columns = @form.fields.count + 3
78 - csv_content = CSV.generate_line(['Timestamp', 'Name', 'Email'] + @form.fields.map(&:name)) + "\n" 78 + csv_content = CSV.generate_line(['Timestamp', 'Name', 'Email'] + @form.fields.map(&:name))
79 @submissions.each do |s| 79 @submissions.each do |s|
80 fields = [s.updated_at.strftime('%Y/%m/%d %T %Z'), s.profile.present? ? s.profile.name : s.author_name, s.profile.present? ? s.profile.email : s.author_email] 80 fields = [s.updated_at.strftime('%Y/%m/%d %T %Z'), s.profile.present? ? s.profile.name : s.author_name, s.profile.present? ? s.profile.email : s.author_email]
81 @form.fields.each do |f| 81 @form.fields.each do |f|
82 fields << s.answers.select{|a| a.field == f}.map{|answer| answer.to_s} 82 fields << s.answers.select{|a| a.field == f}.map{|answer| answer.to_s}
83 end 83 end
84 - CSV.generate_row(fields, columns, csv_content) 84 + fields = fields.flatten
  85 + csv_content << CSV.generate_line(fields + (columns - fields.size).times.map{""})
85 end 86 end
86 send_data csv_content, :type => 'text/csv', :filename => "#{@form.name}.csv" 87 send_data csv_content, :type => 'text/csv', :filename => "#{@form.name}.csv"
87 end 88 end
plugins/custom_forms/controllers/custom_forms_plugin_profile_controller.rb
@@ -7,9 +7,9 @@ class CustomFormsPluginProfileController &lt; ProfileController @@ -7,9 +7,9 @@ class CustomFormsPluginProfileController &lt; ProfileController
7 @form = CustomFormsPlugin::Form.find(params[:id]) 7 @form = CustomFormsPlugin::Form.find(params[:id])
8 if user 8 if user
9 @submission ||= CustomFormsPlugin::Submission.find_by_form_id_and_profile_id(@form.id,user.id) 9 @submission ||= CustomFormsPlugin::Submission.find_by_form_id_and_profile_id(@form.id,user.id)
10 - @submission ||= CustomFormsPlugin::Submission.new(:form_id => @form.id, :profile_id => user.id) 10 + @submission ||= CustomFormsPlugin::Submission.new(:form => @form, :profile => user)
11 else 11 else
12 - @submission ||= CustomFormsPlugin::Submission.new(:form_id => @form.id) 12 + @submission ||= CustomFormsPlugin::Submission.new(:form => @form)
13 end 13 end
14 14
15 # build the answers 15 # build the answers
plugins/custom_forms/lib/custom_forms_plugin/alternative.rb
@@ -4,5 +4,7 @@ class CustomFormsPlugin::Alternative &lt; ActiveRecord::Base @@ -4,5 +4,7 @@ class CustomFormsPlugin::Alternative &lt; ActiveRecord::Base
4 validates_presence_of :label 4 validates_presence_of :label
5 5
6 belongs_to :field, :class_name => 'CustomFormsPlugin::Field' 6 belongs_to :field, :class_name => 'CustomFormsPlugin::Field'
  7 +
  8 + attr_accessible :label, :field, :position
7 end 9 end
8 10
plugins/custom_forms/lib/custom_forms_plugin/answer.rb
1 -class CustomFormsPlugin::Answer < Noosfero::Plugin::ActiveRecord 1 +class CustomFormsPlugin::Answer < ActiveRecord::Base
  2 + set_table_name :custom_forms_plugin_answers
2 belongs_to :field, :class_name => 'CustomFormsPlugin::Field' 3 belongs_to :field, :class_name => 'CustomFormsPlugin::Field'
3 belongs_to :submission, :class_name => 'CustomFormsPlugin::Submission' 4 belongs_to :submission, :class_name => 'CustomFormsPlugin::Submission'
4 5
5 validates_presence_of :field 6 validates_presence_of :field
6 validate :value_mandatory, :if => 'field.present?' 7 validate :value_mandatory, :if => 'field.present?'
7 8
  9 + attr_accessible :field, :value, :submission
  10 +
8 def value_mandatory 11 def value_mandatory
9 if field.mandatory && value.blank? 12 if field.mandatory && value.blank?
10 errors.add(:value, _("is mandatory.").fix_i18n) 13 errors.add(:value, _("is mandatory.").fix_i18n)
plugins/custom_forms/lib/custom_forms_plugin/field.rb
@@ -3,6 +3,8 @@ class CustomFormsPlugin::Field &lt; ActiveRecord::Base @@ -3,6 +3,8 @@ class CustomFormsPlugin::Field &lt; ActiveRecord::Base
3 3
4 validates_presence_of :name 4 validates_presence_of :name
5 5
  6 + attr_accessible :name, :form, :mandatory, :type, :position, :default_value, :select_field_type, :alternatives_attributes
  7 +
6 belongs_to :form, :class_name => 'CustomFormsPlugin::Form' 8 belongs_to :form, :class_name => 'CustomFormsPlugin::Form'
7 has_many :answers, :class_name => 'CustomFormsPlugin::Answer' 9 has_many :answers, :class_name => 'CustomFormsPlugin::Answer'
8 10
plugins/custom_forms/lib/custom_forms_plugin/form.rb
@@ -13,6 +13,8 @@ class CustomFormsPlugin::Form &lt; Noosfero::Plugin::ActiveRecord @@ -13,6 +13,8 @@ class CustomFormsPlugin::Form &lt; Noosfero::Plugin::ActiveRecord
13 validate :period_range, :if => Proc.new { |f| f.begining.present? && f.ending.present? } 13 validate :period_range, :if => Proc.new { |f| f.begining.present? && f.ending.present? }
14 validate :access_format 14 validate :access_format
15 15
  16 + attr_accessible :name, :profile, :for_admission, :access, :begining, :ending, :description, :fields_attributes, :profile_id, :on_membership
  17 +
16 before_validation do |form| 18 before_validation do |form|
17 form.slug = form.name.to_slug if form.name.present? 19 form.slug = form.name.to_slug if form.name.present?
18 form.access = nil if form.access.blank? 20 form.access = nil if form.access.blank?
@@ -23,11 +25,11 @@ class CustomFormsPlugin::Form &lt; Noosfero::Plugin::ActiveRecord @@ -23,11 +25,11 @@ class CustomFormsPlugin::Form &lt; Noosfero::Plugin::ActiveRecord
23 tasks.each {|task| task.cancel} 25 tasks.each {|task| task.cancel}
24 end 26 end
25 27
26 - named_scope :from, lambda {|profile| {:conditions => {:profile_id => profile.id}}}  
27 - named_scope :on_memberships, {:conditions => {:on_membership => true, :for_admission => false}}  
28 - named_scope :for_admissions, {:conditions => {:for_admission => true}} 28 + scope :from, lambda {|profile| {:conditions => {:profile_id => profile.id}}}
  29 + scope :on_memberships, {:conditions => {:on_membership => true, :for_admission => false}}
  30 + scope :for_admissions, {:conditions => {:for_admission => true}}
29 =begin 31 =begin
30 - named_scope :accessible_to lambda do |profile| 32 + scope :accessible_to lambda do |profile|
31 #TODO should verify is profile is associated with the form owner 33 #TODO should verify is profile is associated with the form owner
32 profile_associated = ??? 34 profile_associated = ???
33 {:conditions => [" 35 {:conditions => ["
plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb
@@ -5,7 +5,7 @@ class CustomFormsPlugin::MembershipSurvey &lt; Task @@ -5,7 +5,7 @@ class CustomFormsPlugin::MembershipSurvey &lt; Task
5 5
6 include CustomFormsPlugin::Helper 6 include CustomFormsPlugin::Helper
7 7
8 - named_scope :from, lambda {|profile| {:conditions => {:requestor_id => profile.id}}} 8 + scope :from, lambda {|profile| {:conditions => {:requestor_id => profile.id}}}
9 9
10 def perform 10 def perform
11 form = CustomFormsPlugin::Form.find(form_id) 11 form = CustomFormsPlugin::Form.find(form_id)
plugins/custom_forms/lib/custom_forms_plugin/submission.rb
@@ -4,6 +4,8 @@ class CustomFormsPlugin::Submission &lt; Noosfero::Plugin::ActiveRecord @@ -4,6 +4,8 @@ class CustomFormsPlugin::Submission &lt; Noosfero::Plugin::ActiveRecord
4 4
5 has_many :answers, :class_name => 'CustomFormsPlugin::Answer', :dependent => :destroy 5 has_many :answers, :class_name => 'CustomFormsPlugin::Answer', :dependent => :destroy
6 6
  7 + attr_accessible :form, :profile
  8 +
7 validates_presence_of :form 9 validates_presence_of :form
8 validates_presence_of :author_name, :author_email, :if => lambda {|submission| submission.profile.nil?} 10 validates_presence_of :author_name, :author_email, :if => lambda {|submission| submission.profile.nil?}
9 validates_uniqueness_of :author_email, :scope => :form_id, :allow_nil => true 11 validates_uniqueness_of :author_email, :scope => :form_id, :allow_nil => true
plugins/custom_forms/lib/custom_forms_plugin/text_field.rb
1 class CustomFormsPlugin::TextField < CustomFormsPlugin::Field 1 class CustomFormsPlugin::TextField < CustomFormsPlugin::Field
2 set_table_name :custom_forms_plugin_fields 2 set_table_name :custom_forms_plugin_fields
  3 +
  4 + attr_accessible :name
3 end 5 end
plugins/custom_forms/lib/ext/role_assignment_trigger.rb
@@ -14,7 +14,7 @@ module RoleAssignmentTrigger @@ -14,7 +14,7 @@ module RoleAssignmentTrigger
14 end 14 end
15 end 15 end
16 16
17 - before_validation_on_create do |ra| 17 + before_validation :on => :create do |ra|
18 proceed_creation = true 18 proceed_creation = true
19 if ra.resource.kind_of?(Profile) 19 if ra.resource.kind_of?(Profile)
20 profile = ra.resource 20 profile = ra.resource
plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb
@@ -41,7 +41,7 @@ class CustomFormsPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -41,7 +41,7 @@ class CustomFormsPluginMyprofileControllerTest &lt; ActionController::TestCase
41 format = '%Y-%m-%d %H:%M' 41 format = '%Y-%m-%d %H:%M'
42 begining = Time.now.strftime(format) 42 begining = Time.now.strftime(format)
43 ending = (Time.now + 1.day).strftime(format) 43 ending = (Time.now + 1.day).strftime(format)
44 - assert_difference CustomFormsPlugin::Form, :count, 1 do 44 + assert_difference 'CustomFormsPlugin::Form.count', 1 do
45 post :create, :profile => profile.identifier, 45 post :create, :profile => profile.identifier,
46 :form => { 46 :form => {
47 :name => 'My Form', 47 :name => 'My Form',
@@ -102,7 +102,7 @@ class CustomFormsPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -102,7 +102,7 @@ class CustomFormsPluginMyprofileControllerTest &lt; ActionController::TestCase
102 :type => 'CustomFormsPlugin::TextField' 102 :type => 'CustomFormsPlugin::TextField'
103 } 103 }
104 end 104 end
105 - assert_difference CustomFormsPlugin::Form, :count, 1 do 105 + assert_difference 'CustomFormsPlugin::Form.count', 1 do
106 post :create, :profile => profile.identifier, 106 post :create, :profile => profile.identifier,
107 :form => { 107 :form => {
108 :name => 'My Form', 108 :name => 'My Form',
@@ -139,7 +139,7 @@ class CustomFormsPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -139,7 +139,7 @@ class CustomFormsPluginMyprofileControllerTest &lt; ActionController::TestCase
139 :type => 'CustomFormsPlugin::TextField', 139 :type => 'CustomFormsPlugin::TextField',
140 :position => '1' 140 :position => '1'
141 } 141 }
142 - assert_difference CustomFormsPlugin::Form, :count, 1 do 142 + assert_difference 'CustomFormsPlugin::Form.count', 1 do
143 post :create, :profile => profile.identifier, 143 post :create, :profile => profile.identifier,
144 :form => { 144 :form => {
145 :name => 'My Form', 145 :name => 'My Form',
@@ -195,26 +195,26 @@ class CustomFormsPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -195,26 +195,26 @@ class CustomFormsPluginMyprofileControllerTest &lt; ActionController::TestCase
195 195
196 answer = CustomFormsPlugin::Answer.create!(:value => 'example', :field => field) 196 answer = CustomFormsPlugin::Answer.create!(:value => 'example', :field => field)
197 197
198 - sub1 = CustomFormsPlugin::Submission.create!(:author_name => "john", :author_email => 'john@example.com', :form => form) 198 + sub1 = create(CustomFormsPlugin::Submission, :author_name => "john", :author_email => 'john@example.com', :form => form)
199 sub1.answers << answer 199 sub1.answers << answer
200 200
201 bob = create_user('bob').person 201 bob = create_user('bob').person
202 sub2 = CustomFormsPlugin::Submission.create!(:profile => bob, :form => form) 202 sub2 = CustomFormsPlugin::Submission.create!(:profile => bob, :form => form)
203 203
204 get :submissions, :profile => profile.identifier, :id => form.id, :format => 'csv' 204 get :submissions, :profile => profile.identifier, :id => form.id, :format => 'csv'
205 - assert_equal @response.content_type, 'text/csv'  
206 - assert_equal @response.body.split("\n")[0], 'Timestamp,Name,Email,Title'  
207 - assert_equal @response.body.split("\n")[1], "#{sub1.updated_at.strftime('%Y/%m/%d %T %Z')},john,john@example.com,example"  
208 - assert_equal @response.body.split("\n")[2], "#{sub2.updated_at.strftime('%Y/%m/%d %T %Z')},bob,#{bob.email},\"\"" 205 + assert_equal 'text/csv', @response.content_type
  206 + assert_equal 'Timestamp,Name,Email,Title', @response.body.split("\n")[0]
  207 + assert_equal "#{sub1.updated_at.strftime('%Y/%m/%d %T %Z')},john,john@example.com,example", @response.body.split("\n")[1]
  208 + assert_equal "#{sub2.updated_at.strftime('%Y/%m/%d %T %Z')},bob,#{bob.email},\"\"", @response.body.split("\n")[2]
209 end 209 end
210 210
211 should 'order submissions by name or time' do 211 should 'order submissions by name or time' do
212 form = CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software') 212 form = CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software')
213 field = CustomFormsPlugin::TextField.create!(:name => "Title") 213 field = CustomFormsPlugin::TextField.create!(:name => "Title")
214 form.fields << field 214 form.fields << field
215 - sub1 = CustomFormsPlugin::Submission.create!(:author_name => "john", :author_email => 'john@example.com', :form => form) 215 + sub1 = create(CustomFormsPlugin::Submission, :author_name => "john", :author_email => 'john@example.com', :form => form)
216 bob = create_user('bob').person 216 bob = create_user('bob').person
217 - sub2 = CustomFormsPlugin::Submission.create!(:profile => bob, :form => form) 217 + sub2 = create(CustomFormsPlugin::Submission, :profile => bob, :form => form)
218 218
219 get :submissions, :profile => profile.identifier, :id => form.id, :sort_by => 'time' 219 get :submissions, :profile => profile.identifier, :id => form.id, :sort_by => 'time'
220 assert_not_nil assigns(:sort_by) 220 assert_not_nil assigns(:sort_by)
plugins/custom_forms/test/functional/custom_forms_plugin_profile_controller_test.rb
@@ -22,7 +22,7 @@ class CustomFormsPluginProfileControllerTest &lt; ActionController::TestCase @@ -22,7 +22,7 @@ class CustomFormsPluginProfileControllerTest &lt; ActionController::TestCase
22 field1 = CustomFormsPlugin::TextField.create(:name => 'Name', :form => form, :mandatory => true) 22 field1 = CustomFormsPlugin::TextField.create(:name => 'Name', :form => form, :mandatory => true)
23 field2 = CustomFormsPlugin::TextField.create(:name => 'License', :form => form) 23 field2 = CustomFormsPlugin::TextField.create(:name => 'License', :form => form)
24 24
25 - assert_difference CustomFormsPlugin::Submission, :count, 1 do 25 + assert_difference 'CustomFormsPlugin::Submission.count', 1 do
26 post :show, :profile => profile.identifier, :id => form.id, :submission => {field1.id.to_s => 'Noosfero', field2.id.to_s => 'GPL'} 26 post :show, :profile => profile.identifier, :id => form.id, :submission => {field1.id.to_s => 'Noosfero', field2.id.to_s => 'GPL'}
27 end 27 end
28 assert !session[:notice].include?('not saved') 28 assert !session[:notice].include?('not saved')
plugins/custom_forms/test/unit/custom_forms_plugin/answer_test.rb
@@ -4,13 +4,13 @@ class CustomFormsPlugin::AnswerTest &lt; ActiveSupport::TestCase @@ -4,13 +4,13 @@ class CustomFormsPlugin::AnswerTest &lt; ActiveSupport::TestCase
4 should 'validates presence of field' do 4 should 'validates presence of field' do
5 answer = CustomFormsPlugin::Answer.new 5 answer = CustomFormsPlugin::Answer.new
6 answer.valid? 6 answer.valid?
7 - assert answer.errors.invalid?(:field) 7 + assert answer.errors.include?(:field)
8 8
9 form = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => fast_create(Profile)) 9 form = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => fast_create(Profile))
10 field = CustomFormsPlugin::Field.create!(:name => 'License', :form => form) 10 field = CustomFormsPlugin::Field.create!(:name => 'License', :form => form)
11 answer.field = field 11 answer.field = field
12 answer.valid? 12 answer.valid?
13 - assert !answer.errors.invalid?(:field) 13 + assert !answer.errors.include?(:field)
14 end 14 end
15 15
16 should 'belong to a submission' do 16 should 'belong to a submission' do
@@ -27,11 +27,11 @@ class CustomFormsPlugin::AnswerTest &lt; ActiveSupport::TestCase @@ -27,11 +27,11 @@ class CustomFormsPlugin::AnswerTest &lt; ActiveSupport::TestCase
27 field = CustomFormsPlugin::Field.create!(:name => 'License', :form => form, :mandatory => true) 27 field = CustomFormsPlugin::Field.create!(:name => 'License', :form => form, :mandatory => true)
28 answer = CustomFormsPlugin::Answer.new(:field => field) 28 answer = CustomFormsPlugin::Answer.new(:field => field)
29 answer.valid? 29 answer.valid?
30 - assert answer.errors.invalid?(:value) 30 + assert answer.errors.include?(:value)
31 31
32 answer.value = "GPL" 32 answer.value = "GPL"
33 answer.valid? 33 answer.valid?
34 - assert !answer.errors.invalid?(:value) 34 + assert !answer.errors.include?(:value)
35 end 35 end
36 36
37 should 'make string representation show answers' do 37 should 'make string representation show answers' do
plugins/custom_forms/test/unit/custom_forms_plugin/field_test.rb
@@ -27,7 +27,7 @@ class CustomFormsPlugin::FieldTest &lt; ActiveSupport::TestCase @@ -27,7 +27,7 @@ class CustomFormsPlugin::FieldTest &lt; ActiveSupport::TestCase
27 license_field = CustomFormsPlugin::Field.create!(:name => 'License', :form => form) 27 license_field = CustomFormsPlugin::Field.create!(:name => 'License', :form => form)
28 url_field = CustomFormsPlugin::Field.create!(:name => 'URL', :form => form) 28 url_field = CustomFormsPlugin::Field.create!(:name => 'URL', :form => form)
29 29
30 - assert_no_difference CustomFormsPlugin::Form, :count do 30 + assert_no_difference 'CustomFormsPlugin::Form.count' do
31 url_field.destroy 31 url_field.destroy
32 end 32 end
33 assert_equal form.fields, [license_field] 33 assert_equal form.fields, [license_field]
plugins/custom_forms/test/unit/custom_forms_plugin/form_test.rb
@@ -4,14 +4,14 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase @@ -4,14 +4,14 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase
4 should 'validates presence of a profile and a name' do 4 should 'validates presence of a profile and a name' do
5 form = CustomFormsPlugin::Form.new 5 form = CustomFormsPlugin::Form.new
6 form.valid? 6 form.valid?
7 - assert form.errors.invalid?(:profile)  
8 - assert form.errors.invalid?(:name) 7 + assert form.errors.include?(:profile)
  8 + assert form.errors.include?(:name)
9 9
10 form.profile = fast_create(Profile) 10 form.profile = fast_create(Profile)
11 form.name = 'Free Software' 11 form.name = 'Free Software'
12 form.valid? 12 form.valid?
13 - assert !form.errors.invalid?(:profile)  
14 - assert !form.errors.invalid?(:name) 13 + assert !form.errors.include?(:profile)
  14 + assert !form.errors.include?(:name)
15 end 15 end
16 16
17 should 'have many fields including fields subclasses' do 17 should 'have many fields including fields subclasses' do
@@ -46,11 +46,11 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase @@ -46,11 +46,11 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase
46 CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software') 46 CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software')
47 form = CustomFormsPlugin::Form.new(:profile => profile, :name => 'Free Software') 47 form = CustomFormsPlugin::Form.new(:profile => profile, :name => 'Free Software')
48 form.valid? 48 form.valid?
49 - assert form.errors.invalid?(:slug) 49 + assert form.errors.include?(:slug)
50 50
51 form.profile = another_profile 51 form.profile = another_profile
52 form.valid? 52 form.valid?
53 - assert !form.errors.invalid?(:slug) 53 + assert !form.errors.include?(:slug)
54 end 54 end
55 55
56 should 'validate the difference between ending and beginning is positive' do 56 should 'validate the difference between ending and beginning is positive' do
@@ -60,11 +60,11 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase @@ -60,11 +60,11 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase
60 form.begining = Time.now 60 form.begining = Time.now
61 form.ending = Time.now + 1.day 61 form.ending = Time.now + 1.day
62 assert form.valid? 62 assert form.valid?
63 - assert !form.errors.invalid?(:base) 63 + assert !form.errors.include?(:base)
64 64
65 form.ending = Time.now - 2.day 65 form.ending = Time.now - 2.day
66 assert !form.valid? 66 assert !form.valid?
67 - assert form.errors.invalid?(:base) 67 + assert form.errors.include?(:base)
68 end 68 end
69 69
70 should 'define form expiration' do 70 should 'define form expiration' do
@@ -108,38 +108,38 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase @@ -108,38 +108,38 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase
108 should 'validates format of access' do 108 should 'validates format of access' do
109 form = CustomFormsPlugin::Form.new 109 form = CustomFormsPlugin::Form.new
110 form.valid? 110 form.valid?
111 - assert !form.errors.invalid?(:access) 111 + assert !form.errors.include?(:access)
112 112
113 form.access = 'bli' 113 form.access = 'bli'
114 form.valid? 114 form.valid?
115 - assert form.errors.invalid?(:access) 115 + assert form.errors.include?(:access)
116 116
117 form.access = 'logged' 117 form.access = 'logged'
118 form.valid? 118 form.valid?
119 - assert !form.errors.invalid?(:access) 119 + assert !form.errors.include?(:access)
120 120
121 form.access = 'associated' 121 form.access = 'associated'
122 form.valid? 122 form.valid?
123 - assert !form.errors.invalid?(:access) 123 + assert !form.errors.include?(:access)
124 124
125 form.access = {:bli => 1} 125 form.access = {:bli => 1}
126 form.valid? 126 form.valid?
127 - assert form.errors.invalid?(:access) 127 + assert form.errors.include?(:access)
128 128
129 form.access = 999 129 form.access = 999
130 form.valid? 130 form.valid?
131 - assert form.errors.invalid?(:access) 131 + assert form.errors.include?(:access)
132 132
133 p1 = fast_create(Profile) 133 p1 = fast_create(Profile)
134 form.access = p1.id 134 form.access = p1.id
135 form.valid? 135 form.valid?
136 - assert !form.errors.invalid?(:access) 136 + assert !form.errors.include?(:access)
137 137
138 p2 = fast_create(Profile) 138 p2 = fast_create(Profile)
139 p3 = fast_create(Profile) 139 p3 = fast_create(Profile)
140 form.access = [p1,p2,p3].map(&:id) 140 form.access = [p1,p2,p3].map(&:id)
141 form.valid? 141 form.valid?
142 - assert !form.errors.invalid?(:access) 142 + assert !form.errors.include?(:access)
143 end 143 end
144 144
145 should 'defines who is able to access the form' do 145 should 'defines who is able to access the form' do
@@ -173,7 +173,7 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase @@ -173,7 +173,7 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase
173 assert form.accessible_to(owner) 173 assert form.accessible_to(owner)
174 end 174 end
175 175
176 - should 'have a named_scope that retrieve forms from a profile' do 176 + should 'have a scope that retrieve forms from a profile' do
177 profile = fast_create(Profile) 177 profile = fast_create(Profile)
178 another_profile = fast_create(Profile) 178 another_profile = fast_create(Profile)
179 f1 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => profile) 179 f1 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => profile)
@@ -181,20 +181,20 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase @@ -181,20 +181,20 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase
181 f3 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => another_profile) 181 f3 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => another_profile)
182 scope = CustomFormsPlugin::Form.from(profile) 182 scope = CustomFormsPlugin::Form.from(profile)
183 183
184 - assert_equal ActiveRecord::NamedScope::Scope, scope.class 184 + assert_equal ActiveRecord::Relation, scope.class
185 assert_includes scope, f1 185 assert_includes scope, f1
186 assert_includes scope, f2 186 assert_includes scope, f2
187 assert_not_includes scope, f3 187 assert_not_includes scope, f3
188 end 188 end
189 189
190 - should 'have a named_scope that retrieves all forms that are triggered on membership' do 190 + should 'have a scope that retrieves all forms that are triggered on membership' do
191 profile = fast_create(Profile) 191 profile = fast_create(Profile)
192 f1 = CustomFormsPlugin::Form.create!(:name => 'On membership 1', :profile => profile, :on_membership => true) 192 f1 = CustomFormsPlugin::Form.create!(:name => 'On membership 1', :profile => profile, :on_membership => true)
193 f2 = CustomFormsPlugin::Form.create!(:name => 'On membership 2', :profile => profile, :on_membership => true) 193 f2 = CustomFormsPlugin::Form.create!(:name => 'On membership 2', :profile => profile, :on_membership => true)
194 f3 = CustomFormsPlugin::Form.create!(:name => 'Not on memberhsip', :profile => profile, :on_membership => false) 194 f3 = CustomFormsPlugin::Form.create!(:name => 'Not on memberhsip', :profile => profile, :on_membership => false)
195 scope = CustomFormsPlugin::Form.from(profile).on_memberships 195 scope = CustomFormsPlugin::Form.from(profile).on_memberships
196 196
197 - assert_equal ActiveRecord::NamedScope::Scope, scope.class 197 + assert_equal ActiveRecord::Relation, scope.class
198 assert_includes scope, f1 198 assert_includes scope, f1
199 assert_includes scope, f2 199 assert_includes scope, f2
200 assert_not_includes scope, f3 200 assert_not_includes scope, f3
@@ -205,7 +205,7 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase @@ -205,7 +205,7 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase
205 license_field = CustomFormsPlugin::Field.create!(:name => 'License', :form => form) 205 license_field = CustomFormsPlugin::Field.create!(:name => 'License', :form => form)
206 url_field = CustomFormsPlugin::Field.create!(:name => 'URL', :form => form) 206 url_field = CustomFormsPlugin::Field.create!(:name => 'URL', :form => form)
207 207
208 - assert_difference CustomFormsPlugin::Field, :count, -2 do 208 + assert_difference 'CustomFormsPlugin::Field.count', -2 do
209 form.destroy 209 form.destroy
210 end 210 end
211 end 211 end
@@ -218,14 +218,14 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase @@ -218,14 +218,14 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase
218 assert_equal form.fields, [url_field, license_field] 218 assert_equal form.fields, [url_field, license_field]
219 end 219 end
220 220
221 - should 'have a named_scope that retrieves all forms required for membership' do 221 + should 'have a scope that retrieves all forms required for membership' do
222 profile = fast_create(Profile) 222 profile = fast_create(Profile)
223 f1 = CustomFormsPlugin::Form.create!(:name => 'For admission 1', :profile => profile, :for_admission => true) 223 f1 = CustomFormsPlugin::Form.create!(:name => 'For admission 1', :profile => profile, :for_admission => true)
224 f2 = CustomFormsPlugin::Form.create!(:name => 'For admission 2', :profile => profile, :for_admission => true) 224 f2 = CustomFormsPlugin::Form.create!(:name => 'For admission 2', :profile => profile, :for_admission => true)
225 f3 = CustomFormsPlugin::Form.create!(:name => 'Not for admission', :profile => profile, :for_admission => false) 225 f3 = CustomFormsPlugin::Form.create!(:name => 'Not for admission', :profile => profile, :for_admission => false)
226 scope = CustomFormsPlugin::Form.from(profile).for_admissions 226 scope = CustomFormsPlugin::Form.from(profile).for_admissions
227 227
228 - assert_equal ActiveRecord::NamedScope::Scope, scope.class 228 + assert_equal ActiveRecord::Relation, scope.class
229 assert_includes scope, f1 229 assert_includes scope, f1
230 assert_includes scope, f2 230 assert_includes scope, f2
231 assert_not_includes scope, f3 231 assert_not_includes scope, f3
@@ -237,7 +237,7 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase @@ -237,7 +237,7 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase
237 f2 = CustomFormsPlugin::Form.create!(:name => 'For admission', :profile => profile, :on_membership => true, :for_admission => true) 237 f2 = CustomFormsPlugin::Form.create!(:name => 'For admission', :profile => profile, :on_membership => true, :for_admission => true)
238 scope = CustomFormsPlugin::Form.from(profile).on_memberships 238 scope = CustomFormsPlugin::Form.from(profile).on_memberships
239 239
240 - assert_equal ActiveRecord::NamedScope::Scope, scope.class 240 + assert_equal ActiveRecord::Relation, scope.class
241 assert_includes scope, f1 241 assert_includes scope, f1
242 assert_not_includes scope, f2 242 assert_not_includes scope, f2
243 end 243 end
plugins/custom_forms/test/unit/custom_forms_plugin/membership_survey_test.rb
@@ -4,11 +4,11 @@ class CustomFormsPlugin::MembershipSurveyTest &lt; ActiveSupport::TestCase @@ -4,11 +4,11 @@ class CustomFormsPlugin::MembershipSurveyTest &lt; ActiveSupport::TestCase
4 should 'validates presence of form_id' do 4 should 'validates presence of form_id' do
5 task = CustomFormsPlugin::MembershipSurvey.new 5 task = CustomFormsPlugin::MembershipSurvey.new
6 task.valid? 6 task.valid?
7 - assert task.errors.invalid?(:form_id) 7 + assert task.errors.include?(:form_id)
8 8
9 task.form_id = 1 9 task.form_id = 1
10 task.valid? 10 task.valid?
11 - assert !task.errors.invalid?(:form_id) 11 + assert !task.errors.include?(:form_id)
12 end 12 end
13 13
14 should 'create submission with answers on perform' do 14 should 'create submission with answers on perform' do
@@ -18,7 +18,7 @@ class CustomFormsPlugin::MembershipSurveyTest &lt; ActiveSupport::TestCase @@ -18,7 +18,7 @@ class CustomFormsPlugin::MembershipSurveyTest &lt; ActiveSupport::TestCase
18 field = CustomFormsPlugin::Field.create!(:name => 'Name', :form => form) 18 field = CustomFormsPlugin::Field.create!(:name => 'Name', :form => form)
19 task = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :submission => {field.id.to_s => 'Jack'}, :target => person, :requestor => profile) 19 task = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :submission => {field.id.to_s => 'Jack'}, :target => person, :requestor => profile)
20 20
21 - assert_difference CustomFormsPlugin::Submission, :count, 1 do 21 + assert_difference 'CustomFormsPlugin::Submission.count', 1 do
22 task.finish 22 task.finish
23 end 23 end
24 24
@@ -29,7 +29,7 @@ class CustomFormsPlugin::MembershipSurveyTest &lt; ActiveSupport::TestCase @@ -29,7 +29,7 @@ class CustomFormsPlugin::MembershipSurveyTest &lt; ActiveSupport::TestCase
29 assert_equal answer.value, 'Jack' 29 assert_equal answer.value, 'Jack'
30 end 30 end
31 31
32 - should 'have a named_scope that retrieves all tasks requested by profile' do 32 + should 'have a scope that retrieves all tasks requested by profile' do
33 profile = fast_create(Profile) 33 profile = fast_create(Profile)
34 person = fast_create(Person) 34 person = fast_create(Person)
35 form = CustomFormsPlugin::Form.create!(:name => 'Simple Form', :profile => profile) 35 form = CustomFormsPlugin::Form.create!(:name => 'Simple Form', :profile => profile)
@@ -37,7 +37,7 @@ class CustomFormsPlugin::MembershipSurveyTest &lt; ActiveSupport::TestCase @@ -37,7 +37,7 @@ class CustomFormsPlugin::MembershipSurveyTest &lt; ActiveSupport::TestCase
37 task2 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => fast_create(Profile)) 37 task2 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => fast_create(Profile))
38 scope = CustomFormsPlugin::MembershipSurvey.from(profile) 38 scope = CustomFormsPlugin::MembershipSurvey.from(profile)
39 39
40 - assert_equal ActiveRecord::NamedScope::Scope, scope.class 40 + assert_equal ActiveRecord::Relation, scope.class
41 assert_includes scope, task1 41 assert_includes scope, task1
42 assert_not_includes scope, task2 42 assert_not_includes scope, task2
43 end 43 end
plugins/custom_forms/test/unit/custom_forms_plugin/submission_test.rb
@@ -4,12 +4,12 @@ class CustomFormsPlugin::SubmissionTest &lt; ActiveSupport::TestCase @@ -4,12 +4,12 @@ class CustomFormsPlugin::SubmissionTest &lt; ActiveSupport::TestCase
4 should 'validates presence of form' do 4 should 'validates presence of form' do
5 submission = CustomFormsPlugin::Submission.new 5 submission = CustomFormsPlugin::Submission.new
6 submission.valid? 6 submission.valid?
7 - assert submission.errors.invalid?(:form) 7 + assert submission.errors.include?(:form)
8 8
9 form = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => fast_create(Profile)) 9 form = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => fast_create(Profile))
10 submission.form = form 10 submission.form = form
11 submission.valid? 11 submission.valid?
12 - assert !submission.errors.invalid?(:form) 12 + assert !submission.errors.include?(:form)
13 end 13 end
14 14
15 should 'belong to a profile' do 15 should 'belong to a profile' do
@@ -22,14 +22,14 @@ class CustomFormsPlugin::SubmissionTest &lt; ActiveSupport::TestCase @@ -22,14 +22,14 @@ class CustomFormsPlugin::SubmissionTest &lt; ActiveSupport::TestCase
22 should 'require presence of author name and email if profile is nil' do 22 should 'require presence of author name and email if profile is nil' do
23 submission = CustomFormsPlugin::Submission.new 23 submission = CustomFormsPlugin::Submission.new
24 submission.valid? 24 submission.valid?
25 - assert submission.errors.invalid?(:author_name)  
26 - assert submission.errors.invalid?(:author_email) 25 + assert submission.errors.include?(:author_name)
  26 + assert submission.errors.include?(:author_email)
27 27
28 submission.author_name = 'Jack Sparrow' 28 submission.author_name = 'Jack Sparrow'
29 submission.author_email = 'jack@black-pearl.com' 29 submission.author_email = 'jack@black-pearl.com'
30 submission.valid? 30 submission.valid?
31 - assert !submission.errors.invalid?(:author_name)  
32 - assert !submission.errors.invalid?(:author_email) 31 + assert !submission.errors.include?(:author_name)
  32 + assert !submission.errors.include?(:author_email)
33 end 33 end
34 34
35 should 'have answers' do 35 should 'have answers' do
plugins/custom_forms/test/unit/ext/role_assingment_test.rb
@@ -10,7 +10,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase @@ -10,7 +10,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase
10 f2 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 2', :on_membership => true) 10 f2 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 2', :on_membership => true)
11 f3 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 3', :on_membership => false) 11 f3 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 3', :on_membership => false)
12 12
13 - assert_difference CustomFormsPlugin::MembershipSurvey, :count, 2 do 13 + assert_difference 'CustomFormsPlugin::MembershipSurvey.count', 2 do
14 organization.add_member(person) 14 organization.add_member(person)
15 end 15 end
16 end 16 end
@@ -22,7 +22,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase @@ -22,7 +22,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase
22 person = fast_create(Person) 22 person = fast_create(Person)
23 form = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form', :on_membership => true, :access => 'associated') 23 form = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form', :on_membership => true, :access => 'associated')
24 24
25 - assert_difference CustomFormsPlugin::MembershipSurvey, :count, 1 do 25 + assert_difference 'CustomFormsPlugin::MembershipSurvey.count', 1 do
26 organization.add_member(person) 26 organization.add_member(person)
27 end 27 end
28 end 28 end
@@ -35,14 +35,14 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase @@ -35,14 +35,14 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase
35 form1 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 1', :on_membership => true) 35 form1 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 1', :on_membership => true)
36 organization.add_member(person) 36 organization.add_member(person)
37 37
38 - assert_difference CustomFormsPlugin::MembershipSurvey.pending, :count, -1 do 38 + assert_difference 'CustomFormsPlugin::MembershipSurvey.pending.count', -1 do
39 organization.remove_member(person) 39 organization.remove_member(person)
40 end 40 end
41 41
42 form2 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 2', :for_admission => true) 42 form2 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 2', :for_admission => true)
43 organization.add_member(person) 43 organization.add_member(person)
44 44
45 - assert_difference CustomFormsPlugin::AdmissionSurvey.pending, :count, -1 do 45 + assert_difference 'CustomFormsPlugin::AdmissionSurvey.pending.count', -1 do
46 organization.remove_member(person) 46 organization.remove_member(person)
47 end 47 end
48 48
@@ -50,7 +50,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase @@ -50,7 +50,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase
50 tasks = CustomFormsPlugin::MembershipSurvey.all.last(2) 50 tasks = CustomFormsPlugin::MembershipSurvey.all.last(2)
51 tasks.each {|t| t.status = Task::Status::FINISHED } 51 tasks.each {|t| t.status = Task::Status::FINISHED }
52 tasks.each {|t| t.save! } 52 tasks.each {|t| t.save! }
53 - assert_no_difference CustomFormsPlugin::MembershipSurvey.finished, :count do 53 + assert_no_difference 'CustomFormsPlugin::MembershipSurvey.finished.count' do
54 organization.remove_member(person) 54 organization.remove_member(person)
55 end 55 end
56 end 56 end
@@ -64,7 +64,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase @@ -64,7 +64,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase
64 f2 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 2', :for_admission => true) 64 f2 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 2', :for_admission => true)
65 f3 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 3', :for_admission => false) 65 f3 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 3', :for_admission => false)
66 66
67 - assert_difference CustomFormsPlugin::AdmissionSurvey, :count, 2 do 67 + assert_difference 'CustomFormsPlugin::AdmissionSurvey.count', 2 do
68 organization.add_member(person) 68 organization.add_member(person)
69 end 69 end
70 assert !organization.members.include?(person) 70 assert !organization.members.include?(person)
plugins/custom_forms/views/custom_forms_plugin_myprofile/_field.html.erb
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 <%= f.hidden_field(:position) %> 12 <%= f.hidden_field(:position) %>
13 13
14 <%= f.hidden_field :_destroy, :class => 'destroy-field' %> 14 <%= f.hidden_field :_destroy, :class => 'destroy-field' %>
15 - <%= button_to_function :delete, _('Remove field'), "customFormsPlugin.removeFieldBox(this, #{_('Are you sure you want to remove this field?').to_json})" %> 15 + <%= button_to_function :delete, _('Remove field'), "customFormsPlugin.removeFieldBox(this, #{j _('Are you sure you want to remove this field?').to_json})" %>
16 <%= yield %> 16 <%= yield %>
17 </div> 17 </div>
18 </fieldset> 18 </fieldset>
plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb
1 <% self.extend(CustomFormsPlugin::Helper) %> 1 <% self.extend(CustomFormsPlugin::Helper) %>
2 <%= render :file => 'shared/tiny_mce', :locals => {:mode => 'simple'} %> 2 <%= render :file => 'shared/tiny_mce', :locals => {:mode => 'simple'} %>
3 3
4 -<%= f.error_messages %> 4 +<%= error_messages_for :form %>
5 <%= required labelled_form_field _('Name'), f.text_field(:name) %> 5 <%= required labelled_form_field _('Name'), f.text_field(:name) %>
6 <%= labelled_form_field(_('What is the time limit for this form to be filled?'), ( 6 <%= labelled_form_field(_('What is the time limit for this form to be filled?'), (
7 date_range_field('form[begining]', 'form[ending]', @form.begining, @form.ending, 7 date_range_field('form[begining]', 'form[ending]', @form.begining, @form.ending,
@@ -31,8 +31,8 @@ @@ -31,8 +31,8 @@
31 </ul> 31 </ul>
32 32
33 <div class="addition-buttons"> 33 <div class="addition-buttons">
34 - <%= button(:add, _('Add a new text field'), '#', :onclick => "customFormsPlugin.addFields(this, 'fields', #{html_for_field(f, :fields, CustomFormsPlugin::TextField).to_json}); return false")%>  
35 - <%= button(:add, _('Add a new select field'), '#', :onclick => "customFormsPlugin.addFields(this, 'fields', #{html_for_field(f, :fields, CustomFormsPlugin::SelectField).to_json}); return false")%> 34 + <%= button(:add, _('Add a new text field'), '#', :onclick => "customFormsPlugin.addFields(this, 'fields', #{j html_for_field(f, :fields, CustomFormsPlugin::TextField).to_json}); return false")%>
  35 + <%= button(:add, _('Add a new select field'), '#', :onclick => "customFormsPlugin.addFields(this, 'fields', #{j html_for_field(f, :fields, CustomFormsPlugin::SelectField).to_json}); return false")%>
36 </div> 36 </div>
37 37
38 <% button_bar do %> 38 <% button_bar do %>
plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_alternative.html.erb
@@ -7,6 +7,6 @@ @@ -7,6 +7,6 @@
7 7
8 <td> 8 <td>
9 <%= f.hidden_field :_destroy, :class => 'destroy-field' %> 9 <%= f.hidden_field :_destroy, :class => 'destroy-field' %>
10 - <%= button_to_function_without_text :remove, _('Remove alternative'), "customFormsPlugin.removeAlternative(this, #{_('Are you sure you want to remove this alternative?').to_json})", :class => 'remove-field', :title => _('Remove alternative') %> 10 + <%= button_to_function_without_text :remove, _('Remove alternative'), "customFormsPlugin.removeAlternative(this, #{j _('Are you sure you want to remove this alternative?').to_json})", :class => 'remove-field', :title => _('Remove alternative') %>
11 </td> 11 </td>
12 </tr> 12 </tr>
plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb
1 -<% render :layout => 'field', :locals => { :f => f } do %> 1 +<%= render :layout => 'field', :locals => { :f => f } do %>
2 <div class="field-select-type"> 2 <div class="field-select-type">
3 <%= _('Type:') %> 3 <%= _('Type:') %>
4 <%= f.radio_button(:select_field_type, 'radio') %> 4 <%= f.radio_button(:select_field_type, 'radio') %>
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 <tfoot> 22 <tfoot>
23 <tr class="addition-buttons"> 23 <tr class="addition-buttons">
24 <td colspan="3"> 24 <td colspan="3">
25 - <%= button(:add, _('Add a new alternative'), '#', :onclick => "customFormsPlugin.addFields(this, 'alternatives', #{html_for_field(f, :alternatives, CustomFormsPlugin::Alternative).to_json}); return false") %> 25 + <%= button(:add, _('Add a new alternative'), '#', :onclick => "customFormsPlugin.addFields(this, 'alternatives', #{j html_for_field(f, :alternatives, CustomFormsPlugin::Alternative).to_json}); return false") %>
26 </td> 26 </td>
27 </tr> 27 </tr>
28 </tfoot> 28 </tfoot>
plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_text_field.html.erb
1 -<% render :layout => 'field', :locals => { :f => f } do %> 1 +<%= render :layout => 'field', :locals => { :f => f } do %>
2 <div class="field-text-default"> 2 <div class="field-text-default">
3 <%= f.label(:default_value, _('Default text:')) %> 3 <%= f.label(:default_value, _('Default text:')) %>
4 <%= f.text_field(:default_value) %> 4 <%= f.text_field(:default_value) %>
plugins/custom_forms/views/custom_forms_plugin_myprofile/edit.html.erb
1 <h1><%= _('Edit form') %></h1> 1 <h1><%= _('Edit form') %></h1>
2 2
3 -<%= form_for :form, @form, :url => { :action => 'update', :id => params[:id] } do |f| %> 3 +<%= form_for @form, :as => :form, :url => { :action => 'update', :id => params[:id] } do |f| %>
4 <%= render :partial => 'form', :locals => {:f => f} %> 4 <%= render :partial => 'form', :locals => {:f => f} %>
5 <% end %> 5 <% end %>
plugins/custom_forms/views/custom_forms_plugin_myprofile/new.html.erb
1 <h1><%= _('New form') %></h1> 1 <h1><%= _('New form') %></h1>
2 2
3 -<%= form_for :form, @form, :url => { :action => 'create', :id => params[:id] } do |f| %> 3 +<%= form_for @form, :as => :form, :url => { :action => 'create', :id => params[:id] } do |f| %>
4 <%= render :partial => 'form', :locals => {:f => f} %> 4 <%= render :partial => 'form', :locals => {:f => f} %>
5 <% end %> 5 <% end %>
plugins/custom_forms/views/custom_forms_plugin_profile/show.html.erb
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 12
13 <%= error_messages_for :submission %> 13 <%= error_messages_for :submission %>
14 14
15 - <%= form_for :submission, @submission do |f| %> 15 + <%= form_for :submission do |f| %>
16 <% if !user %> 16 <% if !user %>
17 <%= required labelled_form_field _('Author name'), text_field_tag(:author_name, @submission.author_name) %> 17 <%= required labelled_form_field _('Author name'), text_field_tag(:author_name, @submission.author_name) %>
18 <%= required labelled_form_field _('Author email'), text_field_tag(:author_email, @submission.author_email) %> 18 <%= required labelled_form_field _('Author email'), text_field_tag(:author_email, @submission.author_email) %>